[jboss-user] [EJB 3.0] - Re: EJBs and XML-RPCs

ejb3workshop do-not-reply at jboss.com
Wed Aug 1 09:20:07 EDT 2007


I suggest you take a look at chapter 16 in the Final EJB3 Specification.  (ejb-3_0-fr-spec-ejbcore.pdf)


  | <enterprise-beans>
  | <session>
  | ...
  | <ejb-name>EmployeeService</ejb-name>
  | <ejb-class>com.wombat.empl.EmployeeServiceBean</ejb-class>
  | ...
  | <env-entry>
  | <description>
  | The maximum number of tax exemptions
  | allowed to be set.
  | </description>
  | <env-entry-name>maxExemptions</env-entry-name>
  | <env-entry-type>java.lang.Integer</env-entry-type>
  | <env-entry-value>15</env-entry-value>
  | </env-entry>
  | <env-entry>
  | <description>
  | The minimum number of tax exemptions
  | allowed to be set.
  | </description>
  | <env-entry-name>minExemptions</env-entry-name>
  | <env-entry-type>java.lang.Integer</env-entry-type>
  | <env-entry-value>1</env-entry-value>
  | </env-entry>
  | <env-entry>
  | <env-entry-name>foo/name1</env-entry-name>
  | <env-entry-type>java.lang.String</env-entry-type>
  | <env-entry-value>value1</env-entry-value>
  | </env-entry>
  | <env-entry>
  | <env-entry-name>foo/bar/name2</env-entry-name>
  | <env-entry-type>java.lang.Boolean</env-entry-type>
  | <env-entry-value>true</env-entry-value>
  | </env-entry>
  | <env-entry>
  | <description>Some description.</description>
  | <env-entry-name>name3</env-entry-name>
  | <env-entry-type>java.lang.Integer</env-entry-type>
  | </env-entry>
  | <env-entry>
  | <env-entry-name>foo/name4</env-entry-name>
  | <env-entry-type>java.lang.Integer</env-entry-type>
  | <env-entry-value>10</env-entry-value>
  | </env-entry>
  | ...
  | </session>
  | </enterprise-beans>
  | 

and then access it as 


  | // Obtain the enterprise bean?s environment naming context.
  | Context initCtx = new InitialContext();
  | Context myEnv = (Context)initCtx.lookup("java:comp/env");
  | // Obtain the maximum number of tax exemptions
  | // configured by the Deployer.
  | Integer maxExemptions =
  | (Integer)myEnv.lookup(?maxExemptions?);
  | // Obtain the minimum number of tax exemptions
  | // configured by the Deployer.
  | Integer minExemptions =
  | (Integer)myEnv.lookup(?minExemptions?);
  | // Use the environment entries to customize business logic.
  | if (numberOfExeptions > maxExemptions ||
  | numberOfExemptions < minExemptions)
  | throw new InvalidNumberOfExemptionsException();
  | // Get some more environment entries. These environment
  | // entries are stored in subcontexts.
  | String val1 = (String)myEnv.lookup(?foo/name1?);
  | Boolean val2 = (Boolean)myEnv.lookup(?foo/bar/name2?);
  | // The enterprise bean can also lookup using full pathnames.
  | Integer val3 = (Integer)
  | initCtx.lookup("java:comp/env/name3");
  | Integer val4 = (Integer)
  | initCtx.lookup("java:comp/env/foo/name4");
  | 

Hope this helps
Alex

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

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



More information about the jboss-user mailing list