From: Ritu S. <sf...@us...> - 2004-06-17 10:27:12
|
Update of /cvsroot/smartfrog/core/components/jetty/src/org/smartfrog/services/jetty/contexts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14430/contexts Modified Files: Servlet.java WebApplication.java Log Message: Modified for dynamic adding of listeners and contexts to running jetty server Index: WebApplication.java =================================================================== RCS file: /cvsroot/smartfrog/core/components/jetty/src/org/smartfrog/services/jetty/contexts/WebApplication.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WebApplication.java 16 Jun 2004 12:19:07 -0000 1.1 --- WebApplication.java 17 Jun 2004 10:26:46 -0000 1.2 *************** *** 2,5 **** --- 2,6 ---- import java.rmi.RemoteException; + import org.mortbay.http.HttpServer; import org.smartfrog.services.jetty.contexts.Context; *************** *** 7,16 **** import org.mortbay.jetty.servlet.AbstractSessionManager; import org.mortbay.jetty.servlet.ServletHandler; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.prim.PrimImpl; import org.smartfrog.sfcore.prim.TerminationRecord; import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.common.SmartFrogException; ! import org.smartfrog.services.jetty.SFJetty; /** * A WebApplication context class for jetty server --- 8,20 ---- import org.mortbay.jetty.servlet.AbstractSessionManager; import org.mortbay.jetty.servlet.ServletHandler; + import org.smartfrog.sfcore.common.Logger; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.prim.PrimImpl; import org.smartfrog.sfcore.prim.TerminationRecord; + import org.smartfrog.sfcore.processcompound.ProcessCompound; + import org.smartfrog.sfcore.processcompound.SFProcess; import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.common.SmartFrogException; ! /** * A WebApplication context class for jetty server *************** *** 29,32 **** --- 33,40 ---- String webApp = "\\demo\\webapps\\root"; boolean requestId = false; + + ProcessCompound process = null; + + HttpServer server = null; WebApplicationContext context = new WebApplicationContext(); *************** *** 43,50 **** */ public void sfDeploy() throws SmartFrogException, RemoteException { ! super.sfDeploy(); ! Prim parent = this.sfParent(); ! Prim grandParent = parent.sfParent(); ! jettyhome = (String)grandParent.sfResolveId("jettyhome"); contextPath = sfResolve(contextPathRef, contextPath, true); webApp = sfResolve(webAppRef, jettyhome + webApp, true); --- 51,58 ---- */ public void sfDeploy() throws SmartFrogException, RemoteException { ! super.sfDeploy(); ! process = SFProcess.getProcessCompound(); ! server = (HttpServer)process.sfResolveId("Jetty Server"); ! jettyhome = (String)process.sfResolveId("jettyhome"); contextPath = sfResolve(contextPathRef, contextPath, true); webApp = sfResolve(webAppRef, jettyhome + webApp, true); *************** *** 61,65 **** super.sfStart(); addcontext(contextPath,webApp,requestId); ! SFJetty.server.addContext(context); } --- 69,78 ---- super.sfStart(); addcontext(contextPath,webApp,requestId); ! server.addContext(context); ! try { ! context.start(); ! } catch(Exception ex){ ! throw SmartFrogException.forward(ex); ! } } *************** *** 68,72 **** */ public void sfTerminateWith(TerminationRecord status) { ! SFJetty.server.removeContext(context); super.sfTerminateWith(status); } --- 81,90 ---- */ public void sfTerminateWith(TerminationRecord status) { ! try{ ! context.stop(); ! } catch(Exception ex){ ! Logger.log(" Interrupted on WebApplicationContext termination " + ex); ! } ! server.removeContext(context); super.sfTerminateWith(status); } *************** *** 85,88 **** sessionmanager.setUseRequestedId(requestId); } - } --- 103,105 ---- Index: Servlet.java =================================================================== RCS file: /cvsroot/smartfrog/core/components/jetty/src/org/smartfrog/services/jetty/contexts/Servlet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Servlet.java 16 Jun 2004 12:19:29 -0000 1.1 --- Servlet.java 17 Jun 2004 10:26:46 -0000 1.2 *************** *** 2,16 **** import java.rmi.RemoteException; import org.mortbay.http.HttpServer; import org.smartfrog.services.jetty.contexts.Context; import org.mortbay.jetty.servlet.ServletHttpContext; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.prim.PrimImpl; import org.smartfrog.sfcore.prim.TerminationRecord; import org.smartfrog.sfcore.compound.Compound; import org.smartfrog.sfcore.compound.CompoundImpl; import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.common.SmartFrogException; - import org.smartfrog.services.jetty.SFJetty; import org.mortbay.http.handler.ResourceHandler; --- 2,19 ---- import java.rmi.RemoteException; + import org.mortbay.http.HttpServer; import org.smartfrog.services.jetty.contexts.Context; import org.mortbay.jetty.servlet.ServletHttpContext; + import org.smartfrog.sfcore.common.Logger; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.prim.PrimImpl; import org.smartfrog.sfcore.prim.TerminationRecord; + import org.smartfrog.sfcore.processcompound.ProcessCompound; + import org.smartfrog.sfcore.processcompound.SFProcess; import org.smartfrog.sfcore.compound.Compound; import org.smartfrog.sfcore.compound.CompoundImpl; import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.common.SmartFrogException; import org.mortbay.http.handler.ResourceHandler; *************** *** 33,36 **** --- 36,43 ---- String mapfromPath; String maptoPath; + + ProcessCompound process = null; + + HttpServer server = null; ServletHttpContext context; *************** *** 49,55 **** context = new ServletHttpContext(); sfAddAttribute("Context", context); ! Prim parent = this.sfParent(); ! Prim grandParent = parent.sfParent(); ! jettyhome = (String)grandParent.sfResolveId("jettyhome"); contextPath = sfResolve(contextPathRef, contextPath, true); resourceBase = sfResolve(resourceBaseRef, --- 56,62 ---- context = new ServletHttpContext(); sfAddAttribute("Context", context); ! process = SFProcess.getProcessCompound(); ! server = (HttpServer)process.sfResolveId("Jetty Server"); ! jettyhome = (String)process.sfResolveId("jettyhome"); contextPath = sfResolve(contextPathRef, contextPath, true); resourceBase = sfResolve(resourceBaseRef, *************** *** 67,72 **** public void sfStart() throws SmartFrogException, RemoteException { super.sfStart(); ! addcontext(contextPath,resourceBase,classPath); ! SFJetty.server.addContext(context); } --- 74,84 ---- public void sfStart() throws SmartFrogException, RemoteException { super.sfStart(); ! addcontext(contextPath,resourceBase,classPath); ! server.addContext(context); ! try { ! context.start(); ! } catch(Exception ex){ ! throw SmartFrogException.forward(ex); ! } } *************** *** 75,79 **** */ public void sfTerminateWith(TerminationRecord status) { ! SFJetty.server.removeContext(context); super.sfTerminateWith(status); } --- 87,96 ---- */ public void sfTerminateWith(TerminationRecord status) { ! try{ ! context.stop(); ! } catch(Exception ex){ ! Logger.log(" Interrupted on ServletHttpContext termination " + ex); ! } ! server.removeContext(context); super.sfTerminateWith(status); } |