[jboss-user] [EJB 3.0] - Specifying default values to @Service attributes (JBoss 5.0.

csorbag do-not-reply at jboss.com
Wed Apr 15 15:27:36 EDT 2009


Hi,

I have a service ejb annotated with @Service. It has an attribute I'd like to assign different default values in different environments. 

For example:


  | @Service
  | public class MyService {
  |   private int simpleAttribute;
  | 
  |   public int getSimpleAttribute() {...}
  | 
  |   public void setSimpleAttribute(int value) {...}
  | }

I have a build script that generates two different EARs. One for test environment and one for production environment. I'm looking for a way to  specify different default values to attributes for test and production environments. My idea was to use injection and env-refs in ejb-jar.xml or jboss.xml to inject different values. According to jboss' official ejb3 tutorial I should be able to reference the service using the  tag within either ejb-jar.xml or jboss.xml. But whenever I specify the  tag I get an exception when deploying the ejb, telling me that "service" is not a valid child of enterprise-beans tag. I also tried to reference the service as a regular ejb using  tag, but than I get an exception while deploying the bean: java.lang.UnsupportedOperationException: Instead use JBossServicePolicyDecorator

What is the standard way to assign default values to service EJB's attributes without hardcoding them into source code?

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4225730#4225730

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4225730



More information about the jboss-user mailing list