1 Reply Latest reply on May 11, 2012 4:04 PM by fenris_uy

    aop configurable MailListener

    fenris_uy

      Hi, I have the following MailListener in JBoss 5.1

       

      {code}@MessageDriven(activationConfig={

          @ActivationConfigProperty(propertyName="mailServer", propertyValue="serverurl"),

          @ActivationConfigProperty(propertyName="mailFolder", propertyValue="INBOX"),

          @ActivationConfigProperty(propertyName="storeProtocol", propertyValue="imaps"),

          @ActivationConfigProperty(propertyName="userName", propertyValue="userName"),

          @ActivationConfigProperty(propertyName="password", propertyValue="password")

      })

      @ResourceAdapter("mail-ra.rar")

      public class MailListenerMDB implements MailListener {{code}

       

      That listens correctly for incoming email. Now I need to have the MDB configurable for deployment in development and/or production.

       

      Acording to the tutorials I have seen online I should be able to configure it doing this.

       

      {code}@MessageDriven

      @ResourceAdapter("mail-ra.rar")

      @AspectDomain("MailDrivenBean")

      public class MailListenerMDB implements MailListener {{code:xml}

       

       

      With a file MailDB-aop.xml on my deploy folder that reads like this

       

      <?xml version="1.0" encoding="UTF-8"?>

      <aop xmlns="urn:jboss:aop-beans:1.0">

         <domain name="MailDrivenBean" extends="Message Driven Bean" inheritBindings="true">

            <annotation expr="!class(@org.jboss.ejb3.annotation.DefaultActivationSpecs)">

               @org.jboss.ejb3.annotation.DefaultActivationSpecs (value={@javax.ejb.ActivationConfigProperty(propertyName="mailServer", propertyValue="serverUrl"), @javax.ejb.ActivationConfigProperty(propertyName="mailFolder", propertyValue="INBOX"), @javax.ejb.ActivationConfigProperty(propertyName="storeProtocol", propertyValue="imaps"),@javax.ejb.ActivationConfigProperty(propertyName="userName", propertyValue="userName"), @javax.ejb.ActivationConfigProperty(propertyName="password", propertyValue="password")})

            </annotation>

         </domain>

      </aop>

       

      But when I deploy my modified MailListener I get this error

       

      DEPLOYMENTS IN ERROR:

        Deployment "jboss.j2ee:jar=FactElect_External.jar,name=MailListenerMDB,service=EJB3" is in error due to the following reason(s): org.jboss.deployers.spi.DeploymentException: Required config property RequiredConfigPropertyMetaData@72cff6b[name=mailFolder descriptions=[DescriptionMetaData@d1c5bb0[language=en]]] for messagingType 'org.jboss.resource.adapter.mail.inflow.MailListener' not found in activation config [] ra=jboss.jca:service=RARDeployment,name='mail-ra.rar'

       

      Any idea of what I'm doing wrong?

       

      Thanks.

       

      Message was edited by: Fabricio González

      Solved some markup problems

        • 1. Re: aop configurable MailListener
          fenris_uy

          Didn't managed to do this with AOP but managed to configure my MailListener with properties.

           

          I did it by setting the activationConfigs of this MDB in an XML descriptor. In which I used ${properties} that I setted with the PropertiesServices using a -service.xml file on my Deploy directory.

           

          Example of this files

           

          <ejb-jar xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">

            <enterprise-beans>

              <message-driven>

                <ejb-name>MailDrivenBean</ejb-name>

                <ejb-class>com.antel.dti.factelect.maillistener.MailListenerMDB</ejb-class>

                <activation-config>

                  <activation-config-property>

                    <activation-config-property-name>userName</activation-config-property-name>

                    <activation-config-property-value>${proyect.email.userName}</activation-config-property-value>

          .... SNIP ....

           

           

          ----------------------------------------------------

           

          <server>

             <mbean code="org.jboss.varia.property.SystemPropertiesService" name="pcf:service=MyProperties">

                                 <attribute name="Properties">

                            proyect.email.userName=MYUSER

                  </attribute>

                </mbean>

          </server>

          1 of 1 people found this helpful