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:

  1. add resource bundle in faces-config.xml file follows:

     <application>     <resource-bundle>         <base-name>/yourproperties</base-name>         <var>yourproperties</var>     </resource-bundle> </application> 
  2. add corresponding yourproperties.properties file in classpath or maven resources folder follows:
    maven resource folder

  3. in container managed bean add following snippet:

    private string somestring;  @postconstruct public void loadproperty(){     somestring = resourcebundle.getbundle("/yourproperties").getstring("prop1");  } 

Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -