I have Singleton
enterprise bean, which starts immediately after deploy. I packed EJB into jar
and want to distribute it. I set several fields of Singleton like private final String initParam = "value";
. How can I expose those init parameters to administrator who will be deploy my jar
onto his own GlassFish server?
You can use Environment Entries, these should fit your needs.
Such parameters must be described in ejb-jar.xml:
<enterprise-beans>
<session>
<ejb-name>YourBean</ejb-name>
<env-entry>
<description>Your description</description>
<env-entry-name>yourParam</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>defaultValue</env-entry-value>
</env-entry>
</session>
</enterprise-beans>
The value of the env-entry could be injected into your bean like below:
@Resource(name = "yourParam")
private String initParam;
Env-entries could be modifed from the console of your container, normally it is a more convenient way for admins, comparing to property file modification or creating JVM parameters.
Here is some doc from Oracle: http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/env_entry/env_entry.html