hi john, 
imho the gwt is just a webapp. so i'm a bit confused why talking about threads 
in a j2ee env? 

if i understand you right you want to share one neo4j instance between 
different gwt apps(services).  i would propose creating a context-listener, on 
application startup the embedded-graph-db is placed in the servlet context.
(see the code-snippets)


a other approach would be accessing the neo4j-server direct from the gwt 
(javascript) code through the rest-api. this assumes a driver written in 
gwt-java/javascript.
@jim i hope to find the time this friday creating a lab-project this friday for 
this  :)


cheers
/thomas



----
// register in web.xml !!!!
public class NeoContextListner implements ServletContextListener {
  private static final String CONTEXT_KEY = "neo4j-instance";

  public static EmbeddedGraphDatabase getNeo4JInstance(ServletContext 
servletContext) {
      return (EmbeddedGraphDatabase) servletContext.getAttribute(CONTEXT_KEY);
  }

  public void contextInitialized(ServletContextEvent servletContextEvent) {
      EmbeddedGraphDatabase db = new EmbeddedGraphDatabase("/tmp/db");
      ServletContext servletContext = servletContextEvent.getServletContext();
      servletContext.setAttribute(CONTEXT_KEY, db);
  }

  public void contextDestroyed(ServletContextEvent servletContextEvent) {
      ServletContext servletContext = servletContextEvent.getServletContext();
      EmbeddedGraphDatabase db = getNeo4JInstance(servletContext);
      db.shutdown();
  }
}

usage:

public class TestServiceImpl extends RemoteServiceServlet implements 
TestService {
 public AnyResult doIt(String argument) {
      EmbeddedGraphDatabase db = 
NeoContextListner.getNeo4JInstance(getServletContext());
.... use it
  }

}


Am 09.05.2011 um 23:11 schrieb Christoph K.:

> Hi John,
> 
> if i unterstand Jim right, he means that you should fire up threads on the
> serverside implementation which handle client requests and deal with a
> single instance of the embeddedgraphdatabase.
> 
> greetings
> Chris
> 
> On Mon, May 9, 2011 at 11:06 PM, John Doran <john.do...@hotmail.com> wrote:
> 
>> Hi Jim,
>> Thanks for the reply, I haven't delved into the server aspect of neo4j(I'll
>> leave that until I finish up college). I'll have to refresh my threading
>> knowledge, you reckon each time users want to interact with the db to
>> create
>> a thread and this would stop any exceptions relating to not being able to
>> connect to the database(because it's in use).
>> Regards,
>> John.


_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to