Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <GlobalNamingResources>
- <Resource name="jdbc/ApplicationContext_DatabaseName" auth="Container" type="javax.sql.DataSource"
- username="dbUsername" password="dbPasswd"
- url="jdbc:postgresql://localhost/dbname"
- driverClassName="org.postgresql.Driver"
- initialSize="5" maxWait="5000"
- maxActive="120" maxIdle="5"
- validationQuery="select 1"
- poolPreparedStatements="true"/>
- </GlobalNamingResources/>
- <Context path="/ApplicationContext" ... >
- <!--
- "global" attribute links to GlobalNamingResources in the ${catalina.base}/conf/server.xml (server administrator team)
- "name" attribute is relative to the application-private JNDI context java:comp/env/ and is looked up from the java web application (application developer team)
- -->
- <ResourceLink global="jdbc/ApplicationContext_DatabaseName" name="jdbc/DatabaseName" type="javax.sql.DataSource"/>
- </Context>
- <resource-ref>
- <description>DatabaseName's Datasource</description>
- <res-ref-name>jdbc/DatabaseName</res-ref-name>
- <res-type>javax.sql.DataSource</res-type>
- <res-auth>Container</res-auth>
- </resource-ref>
- <jee:jndi-lookup id="DatabaseNameDataSource"
- jndi-name="jdbc/DatabaseName"
- expected-type="javax.sql.DataSource" />
- <GlobalNamingResources>
- <Resource name="jdbc/ApplicationContext_DatabaseName1" ... />
- <Resource name="jdbc/ApplicationContext_DatabaseName2" ... />
- ...
- </GlobalNamingResources/>
- <Context path="/ApplicationContext" ... >
- <ResourceLink global="jdbc/ApplicationContext_DatabaseName1" name="jdbc/DatabaseName1" ... />
- <ResourceLink global="jdbc/ApplicationContext_DatabaseName2" name="jdbc/DatabaseName2" ... />
- ...
- </Context>
- <resource-ref>
- <description>DatabaseName1's Datasource</description>
- <res-ref-name>jdbc/DatabaseName1</res-ref-name> ...
- </resource-ref>
- <resource-ref>
- <description>DatabaseName2's Datasource</description>
- <res-ref-name>jdbc/DatabaseName2</res-ref-name> ...
- </resource-ref>
- ...
- <jee:jndi-lookup id="DatabaseName1DataSource"
- jndi-name="jdbc/DatabaseName1" ... />
- <jee:jndi-lookup id="DatabaseName2DataSource"
- jndi-name="jdbc/DatabaseName2" ... />
- ...
- <GlobalNamingResources>
- <Resource name="jdbc/ApplicationContextX_DatabaseName1" ... />
- <Resource name="jdbc/ApplicationContextX_DatabaseName2" ... />
- <Resource name="jdbc/ApplicationContextY_DatabaseName1" ... />
- <Resource name="jdbc/ApplicationContextY_DatabaseName2" ... />
- ...
- </GlobalNamingResources/>
- <GlobalNamingResources>
- <Resource name="jdbc/ApplicationContextX_DatabaseName" ... />
- <Resource name="jdbc/ApplicationContextY_DatabaseName" ... />
- <Context path="/ApplicationContextX" ... >
- <ResourceLink global="jdbc/ApplicationContextX_DatabaseName" name="jdbc/DatabaseName" ... />
- </Context>
- <Context path="/ApplicationContextY" ... >
- <ResourceLink global="jdbc/ApplicationContextY_DatabaseName" name="jdbc/DatabaseName" ... />
- </Context>
- <Context path="/ApplicationContextX" ... >
- <ResourceLink global="jdbc/ApplicationContextX_DatabaseName" name="jdbc/applicationXprivateDatabaseName" ... />
- </Context>
- <Context path="/ApplicationContextY" ... >
- <ResourceLink global="jdbc/ApplicationContextY_DatabaseName" name="jdbc/applicationYprivateDatabaseName" ... />
- </Context>
- <context:property-placeholder location="classpath:app.properties"/>
- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- <property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
- <property name="url" value="jdbc:oracle:thin:@${db.host}:${db.port}:${db.user}"/>
- <property name="username" value="${db.user}"/>
- <property name="password" value="${db.pass}"/>
- </bean>
- @Value("${db.user}") String defaultSchema;
- @Inject ApplicationContext context;
- Enviroment env = context.getEnvironment();
- String defaultSchema = env.getProperty("db.user");
- @Value('${db.user:testdb}') private String dbUserName;
- <property name='username' value='${db.user.${env}}'/>
- <Loader className="org.apache.catalina.loader.VirtualWebappLoader"
- virtualClasspath="/srv/web/app/"/>
- <Context>
- ...
- <Resource auth="Container" factory="com.benasmussen.jndi.url.URLFactory"
- name="url/MyUrl" type="java.net.URL" url="file:///your/path/to/file"/>
- ...
- </Context>
- <jee:jndi-lookup id="myUrl" jndi-name="java:comp/env/url/MyUrl" expected-type="java.net.URL" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement