Version: 9.4.5.v20170502 |
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services for sponsored feature development
You can configure naming resources to reference in a web.xml
file and access from within the java:comp/env
naming environment of the webapp during execution.
Specifically, you can configure support for the following web.xml
elements:
<env-entry/>
<resource-ref/>
<resource-env-ref/>
Configuring env-entries shows you how to set up overrides for env-entry
elements in web.xml
, while Configuring resource-refs
and resource-env-refs
discusses how to configure support resources such as javax.sql.DataSource
.
You can also plug a JTA javax.transaction.UserTransaction
implementation into Jetty so that webapps can look up java:comp/UserTransaction
to obtain a distributed transaction manager: see Configuring XA Transactions.
You must declare the objects you want bound into the Jetty environment so that you can then hook into your webapp via env-entry
, resource-ref
and resource-env-refs
in web.xml
.
You create these bindings by using declarations of the following types:
org.eclipse.jetty.plus.jndi.EnvEntry
env-entry
type of entriesorg.eclipse.jetty.plus.jndi.Resource
org.eclipse.jetty.plus.jndi.Transaction
org.eclipse.jetty.plus.jndi.Link
web.xml
resource name and a naming entryDeclarations of each of these types follow the same general pattern:
<New class="org.eclipse.jetty.plus.jndi.xxxx">
<Arg><!-- scope --></Arg>
<Arg><!-- name --></Arg>
<Arg><!-- value --></Arg>
</New>
You can place these declarations into three different files, depending on your needs and the scope of the resources being declared.
You can define naming resources in three places:
jetty.xml
file are scoped at either the JVM level or the Server level.
The classes for the resource must be visible at the Jetty container level.
If the classes for the resource only exist inside your webapp, you must declare it in a WEB-INF/jetty-env.xml
file.WEB-INF/jetty-env.xml
file are scoped to the web app in which the file resides.
While you can enter JVM or Server scopes if you choose, we do not recommend doing so.
The resources defined here may use classes from inside your webapp.
This is a Jetty-specific mechanism.jetty.xml
file, classes associated with the resource must be visible on the container’s classpath.Naming resources within Jetty belong to one of three different scopes, in increasing order of restrictiveness:
The name is unique across the JVM instance, and is visible to all application code.
You represent this scope by a null
first parameter to the resource declaration.
For example:
<New id="cf" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg> <!-- empty arg -->
<Arg>jms/connectionFactory</Arg>
<Arg>
<New class="org.apache.activemq.ActiveMQConnectionFactory">
<Arg>vm://localhost?broker.persistent=false</Arg>
</New>
</Arg>
</New>
The name is unique to a Server instance, and is only visible to code associated with that instance. You represent this scope by referencing the Server instance as the first parameter to the resource declaration. For example:
<Configure id="Server" class="org.eclipse.jetty.Server">
<New id="cf" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg><Ref refid="Server"/></Arg> <!-- reference to Server instance -->
<Arg>jms/connectionFactory</Arg>
<Arg>
<New class="org.apache.activemq.ActiveMQConnectionFactory">
<Arg>vm://localhost?broker.persistent=false</Arg>
</New>
</Arg>
</New>
</Configure>
The name is unique to the WebAppContext instance, and is only visible to code associated with that instance.
You represent this scope by referencing the WebAppContext
instance as the first parameter to the resource declaration.
For example:
<Configure id='wac' class="org.eclipse.jetty.webapp.WebAppContext">
<New id="cf" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg><Ref refid='wac'/></Arg> <!-- reference to WebAppContext -->
<Arg>jms/connectionFactory</Arg>
<Arg>
<New class="org.apache.activemq.ActiveMQConnectionFactory">
<Arg>vm://localhost?broker.persistent=false</Arg>
</New>
</Arg>
</New>
</Configure>
You can bind four types of objects into a Jetty JNDI reference:
web.xml
and as referenced in the Jetty environment.