glassfish - Inject a file using @Resource and JNDI in JEE6 -
is possible inject file using jndi , @resource in jee6?
if how setup , jndi (file) resource in glassfish?
if objective configure properties file follows:
@inject @resource("meta-inf/aws.properties") properties awsproperties;
then want use weld extension explained in weld documentation here
it simple adding pom
<dependency> <groupid>org.jboss.weld</groupid> <artifactid>weld-extensions</artifactid> <version>${weld.extensions.version}</version> <type>pom</type> <scope>import</scope> </dependency>
otherwise
see article programmatic approach.
or else,
store properties in db schema table , use jpa 2.0 retrieve them using jta pointing jndi.
or if application jsf one:
add resource bundle in faces-config.xml file follows:
<application> <resource-bundle> <base-name>/yourproperties</base-name> <var>yourproperties</var> </resource-bundle> </application>
add corresponding yourproperties.properties file in classpath or maven resources folder follows:
in container managed bean add following snippet:
private string somestring; @postconstruct public void loadproperty(){ somestring = resourcebundle.getbundle("/yourproperties").getstring("prop1"); }
Comments
Post a Comment