If you have the jetty-maven-plugin properly configured in the pom.xml, then everything is already set up.
For Jetty Standalone, please see my other post about configuring JNDI in jetty standalone.
Passing parameters through JNDI proved to be very simple. In src/main/webapp/WEB-INF create a file jetty-env.xml, with the following contents:
<?xml version="1.0"?> <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"> <Configure id="thisfile" class="org.eclipse.jetty.webapp.WebAppContext"> <New class="org.eclipse.jetty.plus.jndi.EnvEntry"> <Arg><Ref id="thisfile"/></Arg> <Arg>paramname</Arg> <Arg type="java.lang.String">A sample parameter value</Arg> <Arg type="boolean">false</Arg> </New> </Configure>
You can then load your parameter through the standard naming context:
import javax.naming.Context; import javax.naming.InitialContext; ... Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); String param = (String) envCtx.lookup("paramname");
Of course, you can add other parameters, rename paramname to something that makes more sense, or use other data types. Please note: Jetty supports more datatypes than required by the J2EE standard.
The is the very best beard trimmer best beard trimmer for guys for several elements, beard trimmers not the least which it has sufficient bells blogrip.com and whistles making an airplane blog rip cabin jealous. They're not just for read full article program.
ReplyDelete