Return-Path: Delivered-To: apmail-incubator-geronimo-cvs-archive@www.apache.org Received: (qmail 13173 invoked from network); 16 Jan 2004 02:19:27 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 16 Jan 2004 02:19:27 -0000 Received: (qmail 84098 invoked by uid 500); 16 Jan 2004 02:19:08 -0000 Delivered-To: apmail-incubator-geronimo-cvs-archive@incubator.apache.org Received: (qmail 83991 invoked by uid 500); 16 Jan 2004 02:19:07 -0000 Mailing-List: contact geronimo-cvs-help@incubator.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: geronimo-dev@incubator.apache.org Delivered-To: mailing list geronimo-cvs@incubator.apache.org Received: (qmail 83976 invoked from network); 16 Jan 2004 02:19:07 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 16 Jan 2004 02:19:07 -0000 Received: (qmail 13147 invoked by uid 1712); 16 Jan 2004 02:19:23 -0000 Date: 16 Jan 2004 02:19:23 -0000 Message-ID: <20040116021923.13146.qmail@minotaur.apache.org> From: djencks@apache.org To: incubator-geronimo-cvs@apache.org Subject: cvs commit: incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/jetty JettyWebAccessLog.java JettyWebApplication.java JettyWebConnector.java JettyWebContainer.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N djencks 2004/01/15 18:19:23 Modified: modules/web/src/java/org/apache/geronimo/web AbstractWebAccessLog.java AbstractWebApplication.java AbstractWebConnector.java AbstractWebContainer.java WebApplication.java modules/web/src/java/org/apache/geronimo/web/jetty JettyWebAccessLog.java JettyWebApplication.java JettyWebConnector.java JettyWebContainer.java Log: Initial GBean-ization Revision Changes Path 1.3 +91 -63 incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/AbstractWebAccessLog.java Index: AbstractWebAccessLog.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/AbstractWebAccessLog.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- AbstractWebAccessLog.java 30 Dec 2003 08:28:57 -0000 1.2 +++ AbstractWebAccessLog.java 16 Jan 2004 02:19:23 -0000 1.3 @@ -58,13 +58,18 @@ package org.apache.geronimo.web; import java.net.URI; +import java.util.Arrays; import org.apache.geronimo.kernel.service.GeronimoMBeanInfo; import org.apache.geronimo.kernel.service.GeronimoAttributeInfo; - +import org.apache.geronimo.gbean.GBeanInfo; +import org.apache.geronimo.gbean.GBeanInfoFactory; +import org.apache.geronimo.gbean.GAttributeInfo; +import org.apache.geronimo.gbean.GConstructorInfo; /* -------------------------------------------------------------------------------------- */ + /** * AbstractWebAccessLog * @@ -72,28 +77,46 @@ */ public abstract class AbstractWebAccessLog implements WebAccessLog { - protected String logImpl; + private static final GBeanInfo GBEAN_INFO; + + protected String logImplementationClass; protected URI logLocation; protected String logPattern; protected String logSuffix; protected String logPrefix; protected String logDateFormat; - protected int rolloverHrs =0; - protected boolean resolutionEnabled = false; - protected boolean appendEnabled = true; + protected int logRolloverIntervalHrs = 0; + protected boolean resolveHostNames = false; + protected boolean append = true; protected int logRetentionDays; + //deprecated, remove when GBean only + public AbstractWebAccessLog() { + } + public AbstractWebAccessLog(String logImplementationClass, URI logLocation, String logPattern, int logRetentionDays, + int logRolloverIntervalHrs, String logPrefix, String logSuffix, String logDateFormat, + boolean resolveHostNames, boolean append) { + this.logImplementationClass = logImplementationClass; + this.logLocation = logLocation; + this.logPattern = logPattern; + this.logRetentionDays = logRetentionDays; + this.logRolloverIntervalHrs = logRolloverIntervalHrs; + this.logPrefix = logPrefix; + this.logSuffix = logSuffix; + this.logDateFormat = logDateFormat; + this.resolveHostNames = resolveHostNames; + this.append = append; + } /* -------------------------------------------------------------------------------------- */ /* * @param uri * @see org.apache.geronimo.web.WebAccessLog#setLogLocation(java.net.URI) */ - public void setLogLocation(URI uri) - { - logLocation = uri; + public void setLogLocation(URI uri) { + logLocation = uri; } /* -------------------------------------------------------------------------------------- */ @@ -101,8 +124,7 @@ * @return * @see org.apache.geronimo.web.WebAccessLog#getLogLocation() */ - public URI getLogLocation() - { + public URI getLogLocation() { return logLocation; } @@ -111,14 +133,13 @@ * @param pattern * @see org.apache.geronimo.web.WebAccessLog#setLogPattern(java.lang.String) */ - public void setLogPattern(String pattern) - { - if (pattern.equalsIgnoreCase (NCSA_COMMON_NAME)) + public void setLogPattern(String pattern) { + if (pattern.equalsIgnoreCase(NCSA_COMMON_NAME)) logPattern = NCSA_COMMON_PATTERN; - else if (pattern.equalsIgnoreCase (NCSA_EXTENDED_NAME)) - logPattern = NCSA_EXTENDED_PATTERN; - else - logPattern = pattern; + else if (pattern.equalsIgnoreCase(NCSA_EXTENDED_NAME)) + logPattern = NCSA_EXTENDED_PATTERN; + else + logPattern = pattern; } /* -------------------------------------------------------------------------------------- */ @@ -126,9 +147,8 @@ * @return * @see org.apache.geronimo.web.WebAccessLog#getLogPattern() */ - public String getLogPattern() - { - return logPattern; + public String getLogPattern() { + return logPattern; } /* -------------------------------------------------------------------------------------- */ @@ -136,9 +156,8 @@ * @param days * @see org.apache.geronimo.web.WebAccessLog#setLogRetentionDays(int) */ - public void setLogRetentionDays(int days) - { - logRetentionDays = days; + public void setLogRetentionDays(int days) { + logRetentionDays = days; } /* -------------------------------------------------------------------------------------- */ @@ -146,9 +165,8 @@ * @return * @see org.apache.geronimo.web.WebAccessLog#getLogRetentionDays() */ - public int getLogRetentionDays() - { - return logRetentionDays; + public int getLogRetentionDays() { + return logRetentionDays; } /* -------------------------------------------------------------------------------------- */ @@ -156,9 +174,8 @@ * @param state * @see org.apache.geronimo.web.WebAccessLog#setLogRollover(boolean) */ - public void setLogRolloverIntervalHrs(int hrs) - { - rolloverHrs = hrs; + public void setLogRolloverIntervalHrs(int hrs) { + logRolloverIntervalHrs = hrs; } /* -------------------------------------------------------------------------------------- */ @@ -166,9 +183,8 @@ * @return * @see org.apache.geronimo.web.WebAccessLog#getLogRollover() */ - public int getLogRolloverIntervalHrs() - { - return rolloverHrs; + public int getLogRolloverIntervalHrs() { + return logRolloverIntervalHrs; } /* -------------------------------------------------------------------------------------- */ @@ -176,8 +192,7 @@ * @param prefix * @see org.apache.geronimo.web.WebAccessLog#setLogPrefix(java.lang.String) */ - public void setLogPrefix(String prefix) - { + public void setLogPrefix(String prefix) { logPrefix = prefix; } @@ -186,8 +201,7 @@ * @return * @see org.apache.geronimo.web.WebAccessLog#getLogPrefix() */ - public String getLogPrefix() - { + public String getLogPrefix() { return logPrefix; } @@ -196,8 +210,7 @@ * @param suffix * @see org.apache.geronimo.web.WebAccessLog#setLogSuffix(java.lang.String) */ - public void setLogSuffix(String suffix) - { + public void setLogSuffix(String suffix) { logSuffix = suffix; } @@ -206,8 +219,7 @@ * @return * @see org.apache.geronimo.web.WebAccessLog#getLogSuffix() */ - public String getLogSuffix() - { + public String getLogSuffix() { return logSuffix; } @@ -216,8 +228,7 @@ * @param dateFormat * @see org.apache.geronimo.web.WebAccessLog#setLogDateFormat(java.lang.String) */ - public void setLogDateFormat(String dateFormat) - { + public void setLogDateFormat(String dateFormat) { logDateFormat = dateFormat; } @@ -226,8 +237,7 @@ * @return * @see org.apache.geronimo.web.WebAccessLog#getLogDateFormat() */ - public String getLogDateFormat() - { + public String getLogDateFormat() { return logDateFormat; } @@ -236,9 +246,8 @@ * @param state * @see org.apache.geronimo.web.WebAccessLog#setResolveHostNames(boolean) */ - public void setResolveHostNames(boolean state) - { - resolutionEnabled = state; + public void setResolveHostNames(boolean state) { + resolveHostNames = state; } /* -------------------------------------------------------------------------------------- */ @@ -246,9 +255,8 @@ * @return * @see org.apache.geronimo.web.WebAccessLog#getResolveHostNames() */ - public boolean getResolveHostNames() - { - return resolutionEnabled; + public boolean getResolveHostNames() { + return resolveHostNames; } /* -------------------------------------------------------------------------------------- */ @@ -256,9 +264,8 @@ * @return * @see org.apache.geronimo.web.WebAccessLog#getAppend() */ - public boolean getAppend() - { - return appendEnabled; + public boolean getAppend() { + return append; } /* -------------------------------------------------------------------------------------- */ @@ -266,9 +273,8 @@ * @param state * @see org.apache.geronimo.web.WebAccessLog#setAppend(boolean) */ - public void setAppend(boolean state) - { - appendEnabled = state; + public void setAppend(boolean state) { + append = state; } /* -------------------------------------------------------------------------------------- */ @@ -276,9 +282,8 @@ * @return * @see org.apache.geronimo.web.WebAccessLog#getLogImplementationClass() */ - public String getLogImplementationClass() - { - return logImpl; + public String getLogImplementationClass() { + return logImplementationClass; } /* -------------------------------------------------------------------------------------- */ @@ -286,9 +291,32 @@ * @param classname * @see org.apache.geronimo.web.WebAccessLog#setLogImplementationClass(java.lang.String) */ - public void setLogImplementationClass(String classname) - { - logImpl = classname; + public void setLogImplementationClass(String classname) { + logImplementationClass = classname; + } + + static { + GBeanInfoFactory infoFactory = new GBeanInfoFactory(AbstractWebAccessLog.class.getName()); + infoFactory.addAttribute(new GAttributeInfo("LogImplementationClass", true, "class of log implementation. I think this is speculative")); + infoFactory.addAttribute(new GAttributeInfo("LogLocation", true, "URI indicating where to put the log")); + infoFactory.addAttribute(new GAttributeInfo("LogPattern", true, "NCSA log pattern spec")); + infoFactory.addAttribute(new GAttributeInfo("LogRetentionDays", true, "Number of days to retain logs")); + infoFactory.addAttribute(new GAttributeInfo("LogRolloverIntervalHrs", true, "Hours between log rollovers")); + infoFactory.addAttribute(new GAttributeInfo("LogPrefix", true, "file name prefix for log files")); + infoFactory.addAttribute(new GAttributeInfo("LogSuffix", true, "file name suffix for log files")); + infoFactory.addAttribute(new GAttributeInfo("LogDateFormat", true, "Date format to use in logs, following java.text.DateFormat (??)")); + infoFactory.addAttribute(new GAttributeInfo("ResolveHostNames", true, "Should host names be resolved")); + infoFactory.addAttribute(new GAttributeInfo("Append", true, "Should logs be appended or overwritten (? rolled over)")); + infoFactory.setConstructor(new GConstructorInfo( + Arrays.asList(new Object[] {"LogImplementationClass", "LogLocation", "LogPattern", "LogRetentionDays", "LogRolloverIntervalHrs", "LogPrefix", + "LogSuffix", "LogDateFormat", "ResolveHostNames", "Append"}), + Arrays.asList(new Object[] {String.class, URI.class, String.class, Integer.TYPE, Integer.TYPE, String.class, String.class, String.class, Boolean.TYPE, Boolean.TYPE}) + )); + GBEAN_INFO = infoFactory.getBeanInfo(); + } + + public static GBeanInfo getGbeanInfo() { + return GBEAN_INFO; } public static GeronimoMBeanInfo getGeronimoMBeanInfo() throws Exception { 1.13 +100 -44 incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/AbstractWebApplication.java Index: AbstractWebApplication.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/AbstractWebApplication.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- AbstractWebApplication.java 30 Dec 2003 08:28:57 -0000 1.12 +++ AbstractWebApplication.java 16 Jan 2004 02:19:23 -0000 1.13 @@ -58,6 +58,7 @@ import java.net.URI; +import java.util.Arrays; import javax.management.ObjectName; import javax.naming.Context; @@ -67,6 +68,11 @@ import org.apache.geronimo.deployment.model.geronimo.web.GeronimoWebAppDocument; import org.apache.geronimo.deployment.model.web.Servlet; import org.apache.geronimo.deployment.model.web.WebApp; +import org.apache.geronimo.gbean.GAttributeInfo; +import org.apache.geronimo.gbean.GBeanInfo; +import org.apache.geronimo.gbean.GBeanInfoFactory; +import org.apache.geronimo.gbean.GConstructorInfo; +import org.apache.geronimo.gbean.GEndpointInfo; import org.apache.geronimo.kernel.service.GeronimoMBeanEndpoint; import org.apache.geronimo.kernel.service.GeronimoMBeanInfo; import org.apache.geronimo.transaction.manager.UserTransactionImpl; @@ -83,6 +89,8 @@ */ public abstract class AbstractWebApplication implements WebApplication { + private static final GBeanInfo GBEAN_INFO; + //uri of the webapp protected final URI uri; @@ -108,10 +116,27 @@ protected String contextPath; //class loading delegation model. Default to web-app scope - private boolean java2ClassloadingCompliance; + private boolean java2ClassLoadingCompliance; private ClassLoader parentClassLoader; private UserTransactionImpl userTransaction; + public AbstractWebApplication(URI uri, ClassLoader parentClassLoader, WebApp webApp, GeronimoWebAppDocument geronimoWebAppDocument, String contextPath, + Context context, boolean java2ClassLoadingCompliance, TransactionManager transactionManager, TrackedConnectionAssociator trackedConnectionAssociator) { + this.uri = uri; + this.parentClassLoader = parentClassLoader; + this.webApp = webApp; + this.geronimoWebAppDoc = geronimoWebAppDocument; + this.contextPath = contextPath; + this.context = context; + this.java2ClassLoadingCompliance = java2ClassLoadingCompliance; + userTransaction = new UserTransactionImpl(); + userTransaction.setTransactionManager(transactionManager); + userTransaction.setTrackedConnectionAssociator(trackedConnectionAssociator); + } + + /** + * @deprecated, remove when GBean -only + */ public AbstractWebApplication(WebApplicationContext webApplicationContext) { uri = webApplicationContext.uri; parentClassLoader = webApplicationContext.parentClassLoader; @@ -120,7 +145,7 @@ contextPath = webApplicationContext.contextPath; context = webApplicationContext.context; userTransaction = webApplicationContext.userTransaction; - java2ClassloadingCompliance = webApplicationContext.java2ClassLoadingCompliance; + java2ClassLoadingCompliance = webApplicationContext.java2ClassLoadingCompliance; } public TransactionManager getTransactionManager() { @@ -143,7 +168,7 @@ * @return the URI of the webapp * @see org.apache.geronimo.web.WebApplication#getURI() */ - public URI getURI (){ + public URI getURI() { return uri; } @@ -153,8 +178,8 @@ * webapps wanting to load class will try their own context class loader first. * @return true if application is using Java 2 compliant class loading */ - public boolean getJava2ClassloadingCompliance() { - return java2ClassloadingCompliance; + public boolean getJava2ClassLoadingCompliance() { + return java2ClassLoadingCompliance; } @@ -190,7 +215,7 @@ return geronimoWebAppDoc; } - public WebApp getWebApp () { + public WebApp getWebApp() { return webApp; } //computed info: @@ -201,18 +226,18 @@ * @see org.apache.geronimo.web.WebApplication#getServlets() */ public String[] getServlets() { - if (servlets == null) { - if (webApp == null) - return null; - - Servlet[] servletObjs = webApp.getServlet(); - servlets = new String[servletObjs.length]; - for (int i=0; iWebContainer value - */ - public void setWebContainer(JettyWebContainer webContainer) { - this.webContainer = webContainer; - - if (webContainer != null) { - jetty = (webContainer).getJettyServer(); - } else { - jetty = null; - } + public void registerLog(Server jetty) throws Exception { + jetty.setRequestLog(jettyAccessLog); + jettyAccessLog.start(); } - public JettyWebContainer getWebContainer() { - return webContainer; + public void unregisterLog(Server jetty) throws InterruptedException { + //shouldn't we actually unregister? + if (jettyAccessLog instanceof NCSARequestLog) { + jettyAccessLog.stop(); + } } - public void setMBeanContext(GeronimoMBeanContext context) { } @@ -156,18 +172,18 @@ Class logImplClass = Thread.currentThread().getContextClassLoader().loadClass(getLogImplementationClass()); //get the default constructor, if it has one Constructor constructor = logImplClass.getConstructor(defaultConstructorSignature); - jettyLog = (RequestLog) constructor.newInstance(defaultConstructorArgs); + jettyAccessLog = (RequestLog) constructor.newInstance(defaultConstructorArgs); log.warn("RequestLog does not support rich configuration"); - jetty.setRequestLog(jettyLog); - jettyLog.start(); + //jetty.setRequestLog(jettyAccessLog); + //jettyAccessLog.start(); return; } log.info("Using org.mortbay.http.NCSARequestLog as log impl"); - jettyLog = new NCSARequestLog(); - NCSARequestLog ncsaLog = (NCSARequestLog) jettyLog; + jettyAccessLog = new NCSARequestLog(); + NCSARequestLog ncsaLog = (NCSARequestLog) jettyAccessLog; // set up the configuration of the access log ncsaLog.setBuffered(getBuffering()); @@ -209,9 +225,9 @@ filename = filename + (getLogSuffix() == null ? "" : getLogSuffix()) + ".log"; ncsaLog.setFilename(logDir.getCanonicalPath() + File.separator + filename); - jetty.setRequestLog(ncsaLog); + //jetty.setRequestLog(ncsaLog); - ncsaLog.start(); + //ncsaLog.start(); } catch (Exception e) { log.error(e); throw new RuntimeException("Could not start JettyWebAccessLog", e); @@ -222,10 +238,10 @@ return false; } - public void doStop(){ + public void doStop() { try { - if (jettyLog instanceof NCSARequestLog) - jettyLog.stop(); + if (jettyAccessLog instanceof NCSARequestLog) + jettyAccessLog.stop(); } catch (InterruptedException e) { throw new RuntimeException("Could not stop JettyWebAccessLog", e); } @@ -235,15 +251,47 @@ } - public RequestLog getJettyLog() { - return jettyLog; + public RequestLog getJettyAccessLog() { + return jettyAccessLog; } + static { + GBeanInfoFactory infoFactory = new GBeanInfoFactory("Jetty Web Access Log", "Wrapped Jetty access log", JettyWebAccessLog.class.getName(), AbstractWebAccessLog.getGbeanInfo()); + infoFactory.addAttribute(new GAttributeInfo("Buffering", true, "Should log buffer")); + infoFactory.addOperation(new GOperationInfo("registerLog", new String[]{"Jetty Server"}, new String[]{Server.class.getName()})); + infoFactory.addOperation(new GOperationInfo("unregisterLog", new String[]{"Jetty Server"}, new String[]{Server.class.getName()})); + infoFactory.setConstructor(new GConstructorInfo( + Arrays.asList(new Object[]{"LogImplementationClass", "LogLocation", "LogPattern", + "LogRetentionDays", "LogRolloverIntervalHrs", "LogPrefix", + "LogSuffix", "LogDateFormat", "ResolveHostNames", + "Append", "Buffering"}), + Arrays.asList(new Object[]{String.class, URI.class, String.class, + Integer.TYPE, Integer.TYPE, String.class, + String.class, String.class, Boolean.TYPE, + Boolean.TYPE, Boolean.TYPE}) + )); + GBEAN_INFO = infoFactory.getBeanInfo(); + } + + public static GBeanInfo getGbeanInfo() { + return GBEAN_INFO; + } + + + /** + * @deprecated, remove when GBean -only + */ public static GeronimoMBeanInfo getGeronimoMBeanInfo() throws Exception { GeronimoMBeanInfo mbeanInfo = AbstractWebAccessLog.getGeronimoMBeanInfo(); mbeanInfo.setTargetClass(JettyWebAccessLog.class); mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Buffering", true, true)); - mbeanInfo.addEndpoint(new GeronimoMBeanEndpoint("WebContainer", JettyWebContainer.class, ObjectName.getInstance(AbstractWebContainer.BASE_WEB_CONTAINER_NAME + AbstractWebContainer.CONTAINER_CLAUSE + "Jetty"), true)); + mbeanInfo.addOperationInfo(new GeronimoOperationInfo("registerLog", new GeronimoParameterInfo[] { + new GeronimoParameterInfo("Jetty Server", Server.class, "Jetty server") + }, GeronimoOperationInfo.ACTION, "register this log with jetty")); + mbeanInfo.addOperationInfo(new GeronimoOperationInfo("unregisterLog", new GeronimoParameterInfo[] { + new GeronimoParameterInfo("Jetty Server", Server.class, "Jetty server") + }, GeronimoOperationInfo.ACTION, "unregister this log with jetty")); + //mbeanInfo.addEndpoint(new GeronimoMBeanEndpoint("WebContainer", JettyWebContainer.class, ObjectName.getInstance(AbstractWebContainer.BASE_WEB_CONTAINER_NAME + AbstractWebContainer.CONTAINER_CLAUSE + "Jetty"), true)); return mbeanInfo; } } 1.10 +52 -17 incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/jetty/JettyWebApplication.java Index: JettyWebApplication.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/jetty/JettyWebApplication.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- JettyWebApplication.java 30 Dec 2003 08:28:58 -0000 1.9 +++ JettyWebApplication.java 16 Jan 2004 02:19:23 -0000 1.10 @@ -5,15 +5,23 @@ import java.io.InputStreamReader; import java.net.URI; import java.net.URL; +import java.util.Collections; + +import javax.naming.Context; +import javax.transaction.TransactionManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator; +import org.apache.geronimo.deployment.model.geronimo.web.GeronimoWebAppDocument; +import org.apache.geronimo.deployment.model.web.WebApp; +import org.apache.geronimo.gbean.GBeanInfo; +import org.apache.geronimo.gbean.GBeanInfoFactory; +import org.apache.geronimo.gbean.GOperationInfo; import org.apache.geronimo.kernel.service.GeronimoMBeanInfo; import org.apache.geronimo.kernel.service.GeronimoOperationInfo; import org.apache.geronimo.kernel.service.GeronimoParameterInfo; import org.apache.geronimo.web.AbstractWebApplication; -import org.apache.geronimo.web.AbstractWebContainer; -import org.apache.geronimo.web.WebContainer; import org.mortbay.jetty.servlet.WebApplicationContext; @@ -27,16 +35,38 @@ */ public class JettyWebApplication extends AbstractWebApplication { + private static final GBeanInfo GBEAN_INFO; + + private static final Log log = LogFactory.getLog(JettyWebApplication.class); + private static String CONTAINER_NAME = "Jetty"; private JettyWebApplicationContext jettyContext; - private static final Log log = LogFactory.getLog(JettyWebApplication.class); - private AbstractWebContainer webContainer; public JettyWebApplication() { super(new org.apache.geronimo.web.WebApplicationContext()); } + public JettyWebApplication(URI uri, ClassLoader parentClassLoader, WebApp webApp, GeronimoWebAppDocument geronimoWebAppDocument, String contextPath, + Context context, boolean java2ClassLoadingCompliance, TransactionManager transactionManager, TrackedConnectionAssociator trackedConnectionAssociator) { + super(uri, parentClassLoader, webApp, geronimoWebAppDocument, contextPath, context, + java2ClassLoadingCompliance, transactionManager, trackedConnectionAssociator); + if (uri == null) { + jettyContext = new JettyWebApplicationContext(); + } else { + jettyContext = new JettyWebApplicationContext(uri.toString()); + } + //we could perhaps use geronimo classloading + //jettyContext.setClassLoader(classLoader); + jettyContext.setParentClassLoader(parentClassLoader); + jettyContext.setContextPath(contextPath); + jettyContext.setClassLoaderJava2Compliant(java2ClassLoadingCompliance); + jettyContext.setComponentContext(context); + } + + /** + * @deprecated, remove when GBean -only + */ public JettyWebApplication(org.apache.geronimo.web.WebApplicationContext webApplicationContext) { super(webApplicationContext); URI uri = webApplicationContext.uri; @@ -66,16 +96,16 @@ BufferedReader reader = null; try { - URL url = new URL (jettyContext.getDeploymentDescriptor()); + URL url = new URL(jettyContext.getDeploymentDescriptor()); StringBuffer strbuff = new StringBuffer(); - reader = new BufferedReader(new InputStreamReader (url.openStream())); + reader = new BufferedReader(new InputStreamReader(url.openStream())); boolean more = true; while (more) { - String line = reader.readLine (); + String line = reader.readLine(); if (line == null) more = false; else - strbuff.append (line); + strbuff.append(line); } deploymentDescriptorStr = strbuff.toString(); @@ -83,10 +113,9 @@ return deploymentDescriptorStr; } catch (IOException e) { - log.error (e); + log.error(e); return null; - } - finally { + } finally { try { reader.close(); } catch (IOException e) { @@ -100,18 +129,24 @@ return jettyContext; } - public void setWebContainer(WebContainer webContainer) { - this.webContainer = (AbstractWebContainer) webContainer; + static { + GBeanInfoFactory infoFactory = new GBeanInfoFactory("Jetty Web Application", "Wrapped Jetty application", JettyWebApplication.class.getName(), AbstractWebApplication.getGbeanInfo()); + infoFactory.addOperation(new GOperationInfo("getJettyContext", Collections.EMPTY_LIST)); + GBEAN_INFO = infoFactory.getBeanInfo(); } - public WebContainer getWebContainer() { - return webContainer; + public static GBeanInfo getGbeanInfo() { + return GBEAN_INFO; } + + /** + * @deprecated, remove when GBean -only + */ public static GeronimoMBeanInfo getGeronimoMBeanInfo() throws Exception { GeronimoMBeanInfo mbeanInfo = AbstractWebApplication.getGeronimoMBeanInfo(CONTAINER_NAME); mbeanInfo.setTargetClass(JettyWebApplication.class.getName()); - mbeanInfo.addOperationInfo(new GeronimoOperationInfo("getJettyContext", new GeronimoParameterInfo[] {}, GeronimoOperationInfo.INFO, "Retrieve the internal JettyContext")); + mbeanInfo.addOperationInfo(new GeronimoOperationInfo("getJettyContext", new GeronimoParameterInfo[]{}, GeronimoOperationInfo.INFO, "Retrieve the internal JettyContext")); return mbeanInfo; } } 1.7 +35 -3 incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/jetty/JettyWebConnector.java Index: JettyWebConnector.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/jetty/JettyWebConnector.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- JettyWebConnector.java 30 Dec 2003 08:28:58 -0000 1.6 +++ JettyWebConnector.java 16 Jan 2004 02:19:23 -0000 1.7 @@ -57,9 +57,14 @@ package org.apache.geronimo.web.jetty; import java.lang.reflect.Constructor; +import java.util.Collections; +import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.geronimo.gbean.GBeanInfo; +import org.apache.geronimo.gbean.GBeanInfoFactory; +import org.apache.geronimo.gbean.GOperationInfo; import org.apache.geronimo.kernel.service.GeronimoMBeanContext; import org.apache.geronimo.kernel.service.GeronimoMBeanInfo; import org.apache.geronimo.kernel.service.GeronimoMBeanTarget; @@ -76,12 +81,25 @@ * @version $Revision$ $Date$ */ public class JettyWebConnector extends AbstractWebConnector implements GeronimoMBeanTarget { + private final static GBeanInfo GBEAN_INFO; private final static Log log = LogFactory.getLog(JettyWebConnector.class); private final static Class[] _defaultConstructorSignature = new Class[]{}; private final static Object[] _defaultConstructorArgs = new Object[]{}; private HttpListener listener = null; /** + * @deprecated, remove when GBean -only + */ + public JettyWebConnector() { + + } + + public JettyWebConnector(String protocol, String iface, int port, int maxConnections, int maxIdleTime, List contexts) { + super(protocol, iface, port, maxConnections, maxIdleTime, contexts); + } + + + /** * Set up the port for the Connector to listen on. * It is not permitted to change the port if the * connector is in operation. @@ -133,7 +151,8 @@ /** * Start the connector - * + * TODO this fishing for the listener class should be done in the deployer. + * TODO This should get a listener as a constructor argument. */ public void doStart() { try { @@ -222,10 +241,23 @@ return listener; } + static { + GBeanInfoFactory infoFactory = new GBeanInfoFactory("Jetty Web Connector", "Wrapped Jetty listener", JettyWebConnector.class.getName(), AbstractWebConnector.getGbeanInfo()); + infoFactory.addOperation(new GOperationInfo("getListener", Collections.EMPTY_LIST)); + GBEAN_INFO = infoFactory.getBeanInfo(); + } + + public static GBeanInfo getGbeanInfo() { + return GBEAN_INFO; + } + + /** + * @deprecated, remove when GBean -only + */ public static GeronimoMBeanInfo getGeronimoMBeanInfo() throws Exception { GeronimoMBeanInfo mbeanInfo = AbstractWebConnector.getGeronimoMBeanInfo(); mbeanInfo.setTargetClass(JettyWebConnector.class); - mbeanInfo.addOperationInfo(new GeronimoOperationInfo("getListener", new GeronimoParameterInfo[] {}, GeronimoOperationInfo.INFO, "Retrieve the internal HTTP Listener")); + mbeanInfo.addOperationInfo(new GeronimoOperationInfo("getListener", new GeronimoParameterInfo[]{}, GeronimoOperationInfo.INFO, "Retrieve the internal HTTP Listener")); return mbeanInfo; } 1.11 +61 -4 incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/jetty/JettyWebContainer.java Index: JettyWebContainer.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/jetty/JettyWebContainer.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- JettyWebContainer.java 30 Dec 2003 08:28:58 -0000 1.10 +++ JettyWebContainer.java 16 Jan 2004 02:19:23 -0000 1.11 @@ -56,15 +56,25 @@ package org.apache.geronimo.web.jetty; +import java.util.Arrays; +import java.util.Collection; +import java.net.URI; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.geronimo.kernel.management.StateManageable; import org.apache.geronimo.kernel.service.GeronimoMBeanInfo; import org.apache.geronimo.web.AbstractWebContainer; import org.apache.geronimo.web.WebApplication; +import org.apache.geronimo.web.WebAccessLog; import org.apache.geronimo.web.WebConnector; +import org.apache.geronimo.gbean.GBeanInfo; +import org.apache.geronimo.gbean.GBeanInfoFactory; +import org.apache.geronimo.gbean.GEndpointInfo; +import org.apache.geronimo.gbean.GConstructorInfo; import org.mortbay.jetty.Server; import org.mortbay.jetty.servlet.WebApplicationContext; +import org.w3c.dom.Document; /** * Base class for jetty web containers. @@ -73,16 +83,28 @@ * @version $Revision$ $Date$ */ public class JettyWebContainer extends AbstractWebContainer { + private final static GBeanInfo GBEAN_INFO; private final Log log = LogFactory.getLog(JettyWebContainer.class); private final Server jettyServer; + /** + * @deprecated, remove when GBean -only + */ + public JettyWebContainer() throws Exception { + jettyServer = new Server(); + jettyServer.start(); + } - public JettyWebContainer() throws Exception - { + public JettyWebContainer(URI defaultWebXmlURI, Document defaultWebXmlDoc, Collection webApplications, Collection webConnectors, Collection webAccessLogs) throws Exception { + super(defaultWebXmlURI, defaultWebXmlDoc); jettyServer = new Server(); jettyServer.start(); + //Does order matter here? + setWebApplications(webApplications); + setWebAccessLogs(webAccessLogs); + setWebConnectors(webConnectors); } /** @@ -175,9 +197,44 @@ } catch (InterruptedException e) { throw new RuntimeException("could not stop jetty context", e); } - jettyServer.removeContext (((JettyWebApplication)webapp).getJettyContext()); + jettyServer.removeContext(webApplicationContext); + } + + protected void webAccessLogAdded(WebAccessLog webAccessLog) { + try { + ((JettyWebAccessLog)webAccessLog).registerLog(jettyServer); + } catch (Exception e) { + throw new RuntimeException(e); + } } + protected void WebAccessLogRemoval(WebAccessLog webAccessLog) { + try { + ((JettyWebAccessLog)webAccessLog).unregisterLog(jettyServer); + } catch (InterruptedException e) { + log.info(e); + //???ignore??? + } + } + + static { + GBeanInfoFactory infoFactory = new GBeanInfoFactory("Jetty Web Container", "Geronimo integrated Jetty Server", JettyWebContainer.class.getName(), AbstractWebContainer.getGBeanInfo()); + infoFactory.addEndpoint(new GEndpointInfo("WebApplications", JettyWebApplication.class.getName())); + infoFactory.addEndpoint(new GEndpointInfo("WebConnectors", JettyWebConnector.class.getName())); + infoFactory.addEndpoint(new GEndpointInfo("WebAccessLogs", JettyWebAccessLog.class.getName())); + infoFactory.setConstructor(new GConstructorInfo( + Arrays.asList(new Object[] {"DefaultWebXmlURI", "DefaultWebXmlDoc", "WebApplications", "WebConnectors", "WebAccessLogs", }), + Arrays.asList(new Object[] {URI.class, Document.class, Collection.class, Collection.class, Collection.class }))); + GBEAN_INFO = infoFactory.getBeanInfo(); + } + + public static GBeanInfo getGbeanInfo() { + return GBEAN_INFO; + } + + /** + * @deprecated, remove when GBean -only + */ public static GeronimoMBeanInfo getGeronimoMBeanInfo() throws Exception { return AbstractWebContainer.getGeronimoMBeanInfo(JettyWebContainer.class, "Jetty", JettyWebApplication.class, JettyWebConnector.class, JettyWebAccessLog.class); }