.
/WEB -INF/jetty-env.xml :
<New id="DS" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg><Ref id="studentsApp"/></Arg>
<Arg>jdbc/DS</Arg>
<Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
<Set name="Url">jdbc:mysql://localhost:3306/students</Set>
<Set name="User">root</Set>
<Set name="Password">root</Set>
</New>
</Arg>
</New>
. jndi scopes - .
, java: comp/, jndi , . jndi:
Context t = (Context)new InitialContext().lookup("java:comp");
listContext(t, "");
private static final void listContext(Context ctx, String indent) {
try {
NamingEnumeration list = ctx.listBindings("");
while (list.hasMore()) {
Binding item = (Binding) list.next();
String className = item.getClassName();
String name = item.getName();
System.out.println(indent + className + " " + name);
Object o = item.getObject();
if (o instanceof javax.naming.Context) {
listContext((Context) o, indent + " ");
}
}
} catch (NamingException ex) {
System.out.println(ex);
}
}
, jetty-web.xml - :
<Call class="org.eclipse.jetty.util.log.Log" name="info"><Arg>Starting my super test application</Arg></Call>
jetty-web.xml, .
jetty-web.xml context.xml, $JETTY_HOME/, MySQL $JETTY_HOME/lib/ext, .
, Jetty JNDI, jetty-web.xml.
source
share