Skip to content

Instantly share code, notes, and snippets.

@juliandunn
Created June 8, 2012 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliandunn/2897842 to your computer and use it in GitHub Desktop.
Save juliandunn/2897842 to your computer and use it in GitHub Desktop.
Jetty Mongo Session example
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<New id="mongodb" class="com.mongodb.Mongo">
<Arg>
<New class="java.util.ArrayList">
<Call name="add">
<Arg>
<New class="com.mongodb.ServerAddress">
<Arg type="java.lang.String">localhost</Arg>
<Arg type="int">27017</Arg>
</New>
</Arg>
</Call>
<!-- More Call statements here for bootstrap secondaries -->
</New>
</Arg>
<Call name="getDB">
<Arg>sessions</Arg>
<Call id="sessionDocument" name="getCollection">
<Arg>sessions_theapp</Arg>
</Call>
</Call>
<!-- Also want to be able to read from secondaries for sessions -->
<!-- XXX does not work - syntax error?
<Set name="ReadPreference" type="com.mongodb.ReadPreference">com.mongodb.ReadPreference.SECONDARY</Set>
-->
</New>
<!-- set on the current object, i.e. the Jetty runtime itself -->
<Set name="sessionIdManager">
<New id="mongoIdMgr" class="org.eclipse.jetty.nosql.mongodb.MongoSessionIdManager">
<Arg><Ref id="Server"/></Arg>
<Arg><Ref id="sessionDocument"/></Arg>
<Set name="workerName">plat1</Set>
</New>
</Set>
</Configure>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment