<commit_before>/* DO NOT EDIT: File is auto-generated */
package <%= service.data_module.ejb.service_package %>;

@SuppressWarnings( { "UnusedDeclaration", "JavaDoc" } )
@javax.ejb.TransactionAttribute( javax.ejb.TransactionAttributeType.REQUIRES_NEW )
@javax.ejb.Startup
@javax.ejb.Singleton( name = <%= service.ejb.boundary_interface_name %>.EJB_NAME )
@javax.ejb.ConcurrencyManagement( javax.ejb.ConcurrencyManagementType.BEAN )
public class <%= service.ejb.boundary_implementation_name %>
<%= service.ejb.boundary_extends ? "  extends #{service.ejb.boundary_extends}" : "" %>
  implements <%= service.ejb.boundary_interface_name %><% if service.ejb.remote? %>, <%= service.ejb.qualified_remote_service_name %><% end %><% if service.jmx? %>, <%= service.jmx.qualified_service_name %><% end %>
{
<% if service.jmx? %>
  private javax.management.ObjectName _objectName;

  @javax.annotation.PostConstruct
  public void registerInJMX()
  {
    try
    {
      _objectName = new javax.management.ObjectName( <%= service.jmx.qualified_service_name %>.OBJECT_NAME );
      //noinspection EjbThisExpressionInspection
      java.lang.management.ManagementFactory.getPlatformMBeanServer().registerMBean( this, _objectName );
    }
    catch( final Exception e )
    {
      throw new IllegalStateException( "Unable to register <%= service.qualified_name %> service in JMX registry due to: " + e, e );
    }
  }

  @javax.annotation.PreDestroy
  public void unregisterFromJMX()
  {
    try
    {
      java.lang.management.ManagementFactory.getPlatformMBeanServer().unregisterMBean( _objectName );
    }
    catch( final Exception e )
    {
      throw new IllegalStateException( "Unable to unregister <%= service.qualified_name %> service from JMX registry due to: " + e, e );
    }
  }
<% end %>

<% service.methods.collect {|method|method.parameters.select{|parameter|parameter.reference?}.collect{|parameter|parameter.referenced_entity}}.flatten.sort{|a,b| a.name.to_s <=> b.name.to_s }.uniq.each do |entity| %>
  @javax.ejb.EJB
  private <%= entity.jpa.qualified_dao_service_name %> _<%= entity.qualified_name.gsub('.','') %>DAO;
<% end %>
  @javax.ejb.EJB
  private <%= service.ejb.service_name %> _service;

<% service.methods.each do |method|
%>  @Override
  public <%= annotated_type(method.return_value, :ejb, :boundary) %> <%= Domgen::Naming.camelize(method.name) %>(<%= method.parameters.collect{|p| "final #{annotated_type(p, :ejb, :boundary)} #{p.name}" }.join(', ') %>)<%=
    method.exceptions.empty? ? '' : "\n    throws #{method.exceptions.collect{|e| e.ee.qualified_name}.join(', ')}"
%><%
   return_prefix = ''
   transform = ''
   if method.return_value.return_type != :void
     if method.return_value.ejb.java_type == method.return_value.ejb.java_type(:boundary)
       return_prefix = "return "
     else
       return_prefix = "#{annotated_type(method.return_value, :ejb)} value = "
       if !method.return_value.collection?
         transform = "return #{modality_default_to_transport("value", method.return_value, :ejb)};"
       else
         return_prefix = "#{annotated_type(method.return_value, :ejb)} result = "
         transform = <<-JAVA
        final #{annotated_type(method.return_value, :ejb, :boundary)} $result = new java.util.#{method.return_value.collection_type == :set ? "HashSet" : "ArrayList" }<#{method.return_value.ejb.java_component_type(:boundary)}>();
        for( final #{method.return_value.ejb.java_component_type} k: result )
        {<commit_msg>Avoid null exception when a null is returned in nullable collection<commit_after>/* DO NOT EDIT: File is auto-generated */
package <%= service.data_module.ejb.service_package %>;

@SuppressWarnings( { "UnusedDeclaration", "JavaDoc" } )
@javax.ejb.TransactionAttribute( javax.ejb.TransactionAttributeType.REQUIRES_NEW )
@javax.ejb.Startup
@javax.ejb.Singleton( name = <%= service.ejb.boundary_interface_name %>.EJB_NAME )
@javax.ejb.ConcurrencyManagement( javax.ejb.ConcurrencyManagementType.BEAN )
public class <%= service.ejb.boundary_implementation_name %>
<%= service.ejb.boundary_extends ? "  extends #{service.ejb.boundary_extends}" : "" %>
  implements <%= service.ejb.boundary_interface_name %><% if service.ejb.remote? %>, <%= service.ejb.qualified_remote_service_name %><% end %><% if service.jmx? %>, <%= service.jmx.qualified_service_name %><% end %>
{
<% if service.jmx? %>
  private javax.management.ObjectName _objectName;

  @javax.annotation.PostConstruct
  public void registerInJMX()
  {
    try
    {
      _objectName = new javax.management.ObjectName( <%= service.jmx.qualified_service_name %>.OBJECT_NAME );
      //noinspection EjbThisExpressionInspection
      java.lang.management.ManagementFactory.getPlatformMBeanServer().registerMBean( this, _objectName );
    }
    catch( final Exception e )
    {
      throw new IllegalStateException( "Unable to register <%= service.qualified_name %> service in JMX registry due to: " + e, e );
    }
  }

  @javax.annotation.PreDestroy
  public void unregisterFromJMX()
  {
    try
    {
      java.lang.management.ManagementFactory.getPlatformMBeanServer().unregisterMBean( _objectName );
    }
    catch( final Exception e )
    {
      throw new IllegalStateException( "Unable to unregister <%= service.qualified_name %> service from JMX registry due to: " + e, e );
    }
  }
<% end %>

<% service.methods.collect {|method|method.parameters.select{|parameter|parameter.reference?}.collect{|parameter|parameter.referenced_entity}}.flatten.sort{|a,b| a.name.to_s <=> b.name.to_s }.uniq.each do |entity| %>
  @javax.ejb.EJB
  private <%= entity.jpa.qualified_dao_service_name %> _<%= entity.qualified_name.gsub('.','') %>DAO;
<% end %>
  @javax.ejb.EJB
  private <%= service.ejb.service_name %> _service;

<% service.methods.each do |method|
%>  @Override
  public <%= annotated_type(method.return_value, :ejb, :boundary) %> <%= Domgen::Naming.camelize(method.name) %>(<%= method.parameters.collect{|p| "final #{annotated_type(p, :ejb, :boundary)} #{p.name}" }.join(', ') %>)<%=
    method.exceptions.empty? ? '' : "\n    throws #{method.exceptions.collect{|e| e.ee.qualified_name}.join(', ')}"
%><%
   return_prefix = ''
   transform = ''
   if method.return_value.return_type != :void
     if method.return_value.ejb.java_type == method.return_value.ejb.java_type(:boundary)
       return_prefix = "return "
     else
       return_prefix = "#{annotated_type(method.return_value, :ejb)} value = "
       if !method.return_value.collection?
         transform = "return #{modality_default_to_transport("value", method.return_value, :ejb)};"
       else
         return_prefix = "#{annotated_type(method.return_value, :ejb)} result = "
         transform = method.return_value.nullable? ? "if ( null == result ) { return null; }\n" : ''
         transform = transform + <<-JAVA
        final #{annotated_type(method.return_value, :ejb, :boundary)} $result = new java.util.#{method.return_value.collection_type == :set ? "HashSet" : "ArrayList" }<#{method.return_value.ejb.java_component_type(:boundary)}>();
        for( final #{method.return_value.ejb.java_component_type} k: result )
        {
{'fraction_non_alphanumeric': 0.15407179773711413, 'fraction_numerical': 0.0, 'mean_word_length': 4.331347728965004, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4667012', 'n_tokens_mistral': 2426, 'n_tokens_neox': 2294, 'n_words': 391}