When I attempt to load adapters as follows:
(assume that "Server" is a grizzlyWebServer )
-----------------------
this.Server.addGrizzlyAdapter(sa, new String[]{ContextPath});
in a loop which is read from the hashmap containing the Grizzly adapter and its coresponding context (as one context is specific to one servlet in this instance)
output:
DEBUG >> API.GrizzlyHarness : About to load servlet: /OortCloud/test2 to root folder: .
DEBUG >> API.GrizzlyHarness : About to load servlet: /OortCloud/test3 to root folder: .
DEBUG >> API.GrizzlyHarness : About to load servlet: /OortCloud/debug to root folder: .
DEBUG >> API.GrizzlyHarness : About to load servlet: /OortCloud/test to root folder: .
Only the first adapter gets installed, the subsequent adapters are not loaded (at least to their specified context). So I can only acess test2 if I specify a RootFolder I can access all
can someone onfirm
----- Original Message ----
From: Richard Corsale <igf1_at_yahoo.com>
To: users_at_grizzly.dev.java.net
Sent: Friday, February 27, 2009 1:42:41 PM
Subject: issue 460?
ohhh see I was adding contexts one at a time, in a loop rather than all
at once (we really should encapsulate the context in the adapter as a
constructor param, since its mandatory for and relative to the
grizzlyadapter :) )
heres how I have been doing it:
This
is the bean that holds servlets/GrizzlyAdapters and their relitive
contexts, I refer to this as a ServletServer as it makes more sence (to
me) to load servlets into a server.
-----------------------------------
public class ServletServer{
private HashMap<String, ServletAdapter> ServletAdapters = new HashMap<String, ServletAdapter>();
public ServletServer(Servlet ServletClass, String ServletContext) {
addServlet(ServletContext, ServletClass);
}
public ServletServer() {
}
/**
* Adds a new servlet to this server, will overwrite an existing instance if
* the contexts collide.
*
* @param Context <b the context/uri for this servlet >
* @param ServletInstance
*/
public void addServlet(String ServletContext, Servlet ServletInstance){
ServletAdapter sa = new ServletAdapter();
sa.setServletInstance(ServletInstance);
// sa.setRootFolder(OortFileUtils.instance.getObjectsDirectory(ServletInstance));
sa.setHandleStaticResources(true);
sa.addInitParameter("default-encoding", "UTF-8");
sa.setContextPath(ServletContext);
sa.setProperty("load-on-startup","1");
this.ServletAdapters.put(ServletContext, sa);
}
public HashMap<String, ServletAdapter> getServletAdapters() {
return ServletAdapters;
}
}
And here is the controller code that loads these adapters into the GrizzlyWebserver from the bean
-------------------------------------------------
public void doLoadServletServer(ServletServer servletServer){
HashMap<String, ServletAdapter> servletStore = servletServer.getServletAdapters();
for(String context: servletStore.keySet()){
ServletAdapter sa = servletStore.get(context);
// String RootFolder = OortFileUtils.getObjectsDirectory(servletStore.get(context));
// sa.setRootFolder(RootFolder);
loadServletAdapter(sa);
}
}
private void loadServletAdapter(ServletAdapter sa){
OortDebug.out.print("About to load servlet: "+sa.getContextPath()+" to root folder: "+sa.getRootFolder() , this);
this.Server.addGrizzlyAdapter(sa, new String[]{sa.getContextPath()});
}
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
For additional commands, e-mail: users-help_at_grizzly.dev.java.net