<commit_before>/* DO NOT EDIT: File is auto-generated */
package <%= to_package(method.jms.qualified_mdb_name) %>;

<%

config_properties = {}
config_properties['connectionFactoryLookup'] = method.service.data_module.repository.jms.connection_factory_resource_name
config_properties['destinationLookup'] = method.jms.destination_resource_name
config_properties['destinationType'] = method.jms.destination_type
config_properties['messageSelector'] = method.jms.message_selector if method.jms.message_selector
config_properties['acknowledgeMode'] = method.jms.acknowledge_mode
config_properties['clientID'] = method.jms.client_id if method.jms.client_id
config_properties['subscriptionName'] = method.jms.subscription_name if method.jms.subscription_name
if ( config_properties['destinationType'] == 'javax.jms.Topic' )
  config_properties['subscriptionDurability'] = method.jms.durable? ? 'Durable' : 'NonDurable'
end

-%>

@javax.annotation.Generated( "Domgen" )
@java.lang.SuppressWarnings( { "UnusedDeclaration", "JavaDoc" } )
@javax.ejb.MessageDriven( name = "<%= method.jms.resource_name %>",
                          activationConfig =
                            {
<%
index = 0
config_properties.each_pair do |key, value|
 index += 1
 -%>
                              @javax.ejb.ActivationConfigProperty( propertyName = "<%= key %>", propertyValue = "<%= value %>" )<%= config_properties.size == index ? '' : ',' %>
<% end -%>
                            } )
@javax.ejb.TransactionManagement( javax.ejb.TransactionManagementType.CONTAINER )
@javax.ejb.TransactionAttribute( javax.ejb.TransactionAttributeType.REQUIRED )
@javax.ejb.ConcurrencyManagement( javax.ejb.ConcurrencyManagementType.BEAN )
public class <%= method.jms.mdb_name %>
  implements javax.jms.MessageListener
{
  private static final java.util.logging.Logger LOG = java.util.logging.Logger.getLogger( <%= method.jms.mdb_name %>.class.getName() );

  @javax.inject.Inject
  private <%= method.service.ejb.service_name %> _service;

<%
  parameter = method.parameters.empty? ? nil : method.parameters[0]
  if parameter
   Domgen.error("parameters for #{method.qualified_name} should only have 1 parameter") unless method.parameters.size == 1
   encoded_type = "#{parameter.name}Message"
   boundary_type = parameter.ejb.java_component_type(:boundary)
   in_container = !(parameter.struct? && !parameter.collection?)
-%>
  @javax.xml.bind.annotation.XmlRootElement( name = "<%= parameter.xml.name %>" )
  @javax.xml.bind.annotation.XmlAccessorType( javax.xml.bind.annotation.XmlAccessType.FIELD )
  @javax.xml.bind.annotation.XmlType( name = "<%= method.name %><%= method.service.name %>_<%= parameter.name %>"<% if in_container %>, propOrder = {"Value"}<% end %> )
  public static class <%= encoded_type %>
<% unless in_container -%>
      extends <%= parameter.referenced_struct.ee.qualified_name %>
<% end -%>
  {
<% if in_container -%>
    @javax.xml.bind.annotation.XmlValue
    <%= boundary_type %> Value;
<% else -%>
<% if parameter.referenced_struct.fields.size != 0 %>
  public <%= encoded_type %>( <%= parameter.referenced_struct.fields.collect {|field| "final #{annotated_type(field, :ee, :boundary)} #{field.name}" }.join(", ") %> )
  {
    super( <%= parameter.referenced_struct.fields.collect {|field| field.name.to_s }.join(", ") %> );
  }
<% end -%>
<% end -%>
  }
<% end -%>

  public void onMessage( final javax.jms.Message message )
  {
    try
    {
      if ( message instanceof javax.jms.TextMessage )
      {
<%
  if parameter
-%>
        final javax.jms.TextMessage textMessage = (javax.jms.TextMessage)message;
        final String text = textMessage.getText();
        final javax.xml.bind.JAXBContext context = javax.xml.bind.JAXBContext.newInstance( <%= encoded_type %>.class );
        final javax.xml.bind.Unmarshaller marshaller = context.createUnmarshaller();
        final java.io.StringReader reader = new java.io.StringReader( text );

        final <%= encoded_type %> decoded = (<%= encoded_type %>) marshaller.unmarshal( reader );

        final <%= boundary_type %> parameter = <%= (parameter.struct? && !parameter.collection?) ? 'decoded' : 'decoded.Value' %>;
<% end -%>
        _service.<%= Domgen::Naming.camelize(method.name) %>(<%= method.parameters.empty? ? '' : ' parameter ' %>);
      }
      else
      {
        throw new RuntimeException( "<%= method.jms.mdb_name %> can only process TextMessages but received a " + message.getClass() );
      }
    }
    catch ( final Exception e )
    {
      LOG.log( java.util.logging.Level.WARNING, "Error processing the incoming message: " + e.getMessage(), e );
      throw new RuntimeException( e );
    }<commit_msg>Handle externally defined messages in mdbs<commit_after>/* DO NOT EDIT: File is auto-generated */
package <%= to_package(method.jms.qualified_mdb_name) %>;

<%

config_properties = {}
config_properties['connectionFactoryLookup'] = method.service.data_module.repository.jms.connection_factory_resource_name
config_properties['destinationLookup'] = method.jms.destination_resource_name
config_properties['destinationType'] = method.jms.destination_type
config_properties['messageSelector'] = method.jms.message_selector if method.jms.message_selector
config_properties['acknowledgeMode'] = method.jms.acknowledge_mode
config_properties['clientID'] = method.jms.client_id if method.jms.client_id
config_properties['subscriptionName'] = method.jms.subscription_name if method.jms.subscription_name
if ( config_properties['destinationType'] == 'javax.jms.Topic' )
  config_properties['subscriptionDurability'] = method.jms.durable? ? 'Durable' : 'NonDurable'
end

-%>

@javax.annotation.Generated( "Domgen" )
@java.lang.SuppressWarnings( { "UnusedDeclaration", "JavaDoc" } )
@javax.ejb.MessageDriven( name = "<%= method.jms.resource_name %>",
                          activationConfig =
                            {
<%
index = 0
config_properties.each_pair do |key, value|
 index += 1
 -%>
                              @javax.ejb.ActivationConfigProperty( propertyName = "<%= key %>", propertyValue = "<%= value %>" )<%= config_properties.size == index ? '' : ',' %>
<% end -%>
                            } )
@javax.ejb.TransactionManagement( javax.ejb.TransactionManagementType.CONTAINER )
@javax.ejb.TransactionAttribute( javax.ejb.TransactionAttributeType.REQUIRED )
@javax.ejb.ConcurrencyManagement( javax.ejb.ConcurrencyManagementType.BEAN )
public class <%= method.jms.mdb_name %>
  implements javax.jms.MessageListener
{
  private static final java.util.logging.Logger LOG = java.util.logging.Logger.getLogger( <%= method.jms.mdb_name %>.class.getName() );

  @javax.inject.Inject
  private <%= method.service.ejb.service_name %> _service;

<%
  parameter = method.parameters.empty? ? nil : method.parameters[0]
  if parameter
   Domgen.error("parameters for #{method.qualified_name} should only have 1 parameter") unless method.parameters.size == 1
   encoded_type = parameter.non_standard_type? ? parameter.parameter_type : "#{parameter.name}Message"
   boundary_type = parameter.ejb.java_component_type(:boundary)
   in_container = !(parameter.struct? && !parameter.collection?)
   unless parameter.non_standard_type?
-%>
  @javax.xml.bind.annotation.XmlRootElement( name = "<%= parameter.xml.name %>" )
  @javax.xml.bind.annotation.XmlAccessorType( javax.xml.bind.annotation.XmlAccessType.FIELD )
  @javax.xml.bind.annotation.XmlType( name = "<%= method.name %><%= method.service.name %>_<%= parameter.name %>"<% if in_container %>, propOrder = {"Value"}<% end %> )
  public static class <%= encoded_type %>
<% unless in_container -%>
      extends <%= parameter.referenced_struct.ee.qualified_name %>
<% end -%>
  {
<% if in_container -%>
    @javax.xml.bind.annotation.XmlValue
    <%= boundary_type %> Value;
<% else -%>
<% if parameter.referenced_struct.fields.size != 0 %>
  public <%= encoded_type %>( <%= parameter.referenced_struct.fields.collect {|field| "final #{annotated_type(field, :ee, :boundary)} #{field.name}" }.join(", ") %> )
  {
    super( <%= parameter.referenced_struct.fields.collect {|field| field.name.to_s }.join(", ") %> );
  }
<% end -%>
<% end -%>
  }
<% end -%>
<% end -%>

  public void onMessage( final javax.jms.Message message )
  {
    try
    {
      if ( message instanceof javax.jms.TextMessage )
      {
<%
  if parameter
-%>
        final javax.jms.TextMessage textMessage = (javax.jms.TextMessage)message;
        final String text = textMessage.getText();
        final javax.xml.bind.JAXBContext context = javax.xml.bind.JAXBContext.newInstance( <%= encoded_type %>.class );
        final javax.xml.bind.Unmarshaller marshaller = context.createUnmarshaller();
        final java.io.StringReader reader = new java.io.StringReader( text );

        final <%= encoded_type %> decoded = (<%= encoded_type %>) marshaller.unmarshal( reader );

        final <%= boundary_type %> parameter = <%= ((parameter.struct? || parameter.non_standard_type?) && !parameter.collection?) ? 'decoded' : 'decoded.Value' %>;
<% end -%>
        _service.<%= Domgen::Naming.camelize(method.name) %>(<%= method.parameters.empty? ? '' : ' parameter ' %>);
      }
      else
      {
        throw new RuntimeException( "<%= method.jms.mdb_name %> can only process TextMessages but received a " + message.getClass() );
      }
    }
    catch ( final Exception e )
    {
      LOG.log( java.util.logging.Level.WARNING, "Error processing the incoming message: " + e.getMessage(), e );
      throw new RuntimeException( e );
    }
{'fraction_non_alphanumeric': 0.15162000629128658, 'fraction_numerical': 0.0012582573136206354, 'mean_word_length': 3.9599583983359334, 'pattern_counts': {'":': 0, '<': 88, '<?xml version=': 0, '>': 88, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 18}, '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': '5756503', 'n_tokens_mistral': 3012, 'n_tokens_neox': 2896, 'n_words': 503}