java ee - Modify configuration properties of ejb-jar.xml during deployment in GlassFish 4.0 -


i have ejb-jar.xml contains configuration information 1 of mdb. in there configuration of:

 <activation-config-property>         <activation-config-property-name>addresslist</activation-config-property-name>         <activation-config-property-value>mq://test.server.uk:7676</activation-config-property-value> </activation-config-property> 

as project built , packaged , distributed off users need able make sure value can modified users have different server addresses.

currently have option set address in properties file. there anyway modify xml during deployment on glassfish 4.0 property value?

if not going have set value every time wants application , re-build it?

i open putting configuration else need have dynamic users can set server addresses in properties file.

one thing can try use @aroundconstruct interceptor set value on mdb @ runtime. it's worthwhile note while possible use placeholders in ejb-jar.xml, it's container-dependent, , apparent lack of reading material on how it's done glassfish should source of worry you. let's try this:

  1. define interceptor on mdb:

    @messagedriven @interceptors(addresslistinterceptor.class) public class yourmdb 
  2. define interceptor

    public class addresslistinterceptor {      @aroundconstruct     private void begin(invocationcontext ictxt) {          /**load property prior point */           activationconfigproperty addresslist = new activationconfigproperty{                                                    public string propertyname(){                                                     return "addresslist";                                                   }                                                   public string propertyvalue(){                                                     return theaddresslist;                                                    }                                   public class<? extends annotation> annotationtype(){                                       return activationconfigproperty.class;                                   }                                                                  };            try {                 /**get annotations, intention of adding yours (addresslist) array using method demonstrated in                    http://stackoverflow.com/a/14276270/1530938  */                annotations[] annotations = ictxt.getclass().getannotations();                   ictxt.proceed(); //this allow processing continue normal            } catch (exception ex) {             }     } 

apart unfortunate need scan , modify annotations yourself, approach buys you're allowed step lifecycle of mdb , modify value of annotation, before bean intantiated. time bean put service, it'll take value you've set , should in order


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -