User: jules_gosnell Date: 02/02/17 16:26:01 Modified: jetty/src/main/org/jboss/jetty JettyService.java Log: reenable Jan's logging stuff - fixed Revision Changes Path 1.47 +68 -72 contrib/jetty/src/main/org/jboss/jetty/JettyService.java Index: JettyService.java =================================================================== RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JettyService.java,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- JettyService.java 15 Feb 2002 00:46:52 -0000 1.46 +++ JettyService.java 18 Feb 2002 00:26:01 -0000 1.47 @@ -5,7 +5,7 @@ * See terms of license at gnu.org. */ -// $Id: JettyService.java,v 1.46 2002/02/15 00:46:52 user57 Exp $ +// $Id: JettyService.java,v 1.47 2002/02/18 00:26:01 jules_gosnell Exp $ //------------------------------------------------------------------------------ @@ -26,7 +26,7 @@ import org.jboss.web.AbstractWebContainer; import org.jboss.web.WebApplication; import org.mortbay.util.jmx.CodeMBean; -//import org.mortbay.util.jmx.LogMBean; +import org.mortbay.util.jmx.LogMBean; import org.mortbay.util.Log; //------------------------------------------------------------------------------ @@ -34,26 +34,23 @@ * A service to launch jetty from JMX. * * @author <a href="mailto:[EMAIL PROTECTED]">Julian Gosnell</a> - * @version $Revision: 1.46 $ + * @version $Revision: 1.47 $ */ -// NOTES - -// I could parameterise the properties file - do we still need it - -// shouldn't it use MLET ? - public class JettyService extends AbstractWebContainer implements JettyServiceMBean, MBeanRegistration { public static final String NAME = "Jetty"; - Logger _log = Logger.getLogger(JettyService.class); - JettyMBean _mbean = null; - CodeMBean _debug = null; - Jetty _jetty = null; - MBeanServer _server = null; - // LogMBean _logbean = null; + Logger _log = Logger.getLogger(JettyService.class); + JettyMBean _mbean = null; + CodeMBean _debug = null; + Jetty _jetty = null; + MBeanServer _server = null; + LogMBean _logbean = null; + ObjectName _codeBeanName = null; + ObjectName _logBeanName = null; public JettyService() @@ -63,6 +60,7 @@ // that logging models are connected before configure-time (via // MLET file) which is done before initialise-time. ensureLogging(); + ensureNaming(); } //---------------------------------------------------------------------------- @@ -80,6 +78,20 @@ //---------------------------------------------------------------------------- + public void + ensureNaming() + { + try + { + _codeBeanName = new ObjectName(JettyMBean.JBOSS_DOMAIN+":Jetty=Debug"); + _logBeanName = new ObjectName(JettyMBean.JBOSS_DOMAIN+":Jetty=Log"); + } + catch (Exception e) + { + _log.error("Could not format names for Jetty debug and log manager MBeans"); + } + } + protected void ensureLogging() { @@ -89,7 +101,7 @@ JBossLogSink logSink = new JBossLogSink(); try { - logSink.initialize(Logger.getLogger("org.jboss.jetty.Jetty")); + logSink.initialize(Logger.getLogger("org.jboss.jetty.Jetty")); } catch(Exception e) { @@ -103,34 +115,13 @@ // why doesn't this work? - investigate... // _jetty.setLogSink(logSink); - _log.debug("connected JBoss and Jetty Log models"); + if (_log.isDebugEnabled()) + _log.debug("connected JBoss and Jetty Log models"); } /** the usual path separators we know */ protected final static String KNOWN_PATH_SEPARATORS=":;"; - /** - * enter the jetty.properties file to the system properties such that - * Jasper will find the right jars to compile - */ - protected void - ensureProperties() - throws IOException - { - String props="jetty.properties"; - // InputStream propertiesIn = getClass().getClassLoader().getResourceAsStream(props); - InputStream propertiesIn = new URL(Jetty.fixURL(getClass().getClassLoader().getResource(props).toString())).openStream(); - - if (propertiesIn == null) - throw new IOException("failed to load "+props); - - System.getProperties().load(propertiesIn); - - if (_log.isDebugEnabled()) { - _log.debug("Loaded properties from: "+props); - } - } - protected void ensureJetty() { @@ -147,7 +138,8 @@ _jetty=tmp; // now we are initialised. - _log.debug("Instantiated and configured server"); + if (_log.isDebugEnabled()) + _log.debug("Instantiated and configured server"); } protected void @@ -159,13 +151,15 @@ { try { - _log.debug("MBean peers WILL be created for Jetty Contexts"); - _mbean = new JettyMBean(_jetty); - _debug = new CodeMBean(); - // _logbean = new LogMBean(); + if (_log.isDebugEnabled()) + _log.debug("MBean peers WILL be created for Jetty Contexts"); + + _mbean = new JettyMBean(_jetty); + _debug = new CodeMBean(); + _logbean = new LogMBean(); _server.registerMBean(_mbean, null); - _server.registerMBean(_debug, new ObjectName(_mbean.getDefaultDomain()+":Jetty=Debug")); - // _server.registerMBean (_logbean, new ObjectName(_mbean.getDefaultDomain()+":Jetty=Log")); + _server.registerMBean(_debug, _codeBeanName); + _server.registerMBean(_logbean, _logBeanName); } catch (Throwable e) { @@ -174,7 +168,8 @@ } else { - _log.debug("MBean peers WILL NOT be created for Jetty Contexts"); + if (_log.isDebugEnabled()) + _log.debug("MBean peers WILL NOT be created for Jetty Contexts"); } _jetty.setConfiguration(_configuration); @@ -184,7 +179,6 @@ ensureService() throws Exception { - ensureProperties(); ensureJetty(); ensureConfig(); } @@ -261,13 +255,23 @@ _mbean=null; try { - _server.unregisterMBean(new ObjectName("jboss.web:Jetty=Debug")); + _server.unregisterMBean(_codeBeanName); } catch(Exception e) { _log.error("problem unregistering CodeMBean", e); } _debug=null; + + try + { + _server.unregisterMBean(_logBeanName); + } + catch (Exception e) + { + _log.error ("problem unregistering LogMBean", e); + } + _logbean=null; } else _log.warn("Jetty has already been destroyed"); @@ -330,9 +334,8 @@ public void setPublishMBeans(boolean publishMBeans) { - if (_log.isDebugEnabled()) { - _log.debug("set PublishMBeans to "+publishMBeans); - } + if (_log.isDebugEnabled()) + _log.debug("set PublishMBeans to "+publishMBeans); _publishMBeans=publishMBeans; } @@ -353,9 +356,8 @@ public void setUnpackWars(boolean unpackWars) { - if (_log.isDebugEnabled()) { - _log.debug("set UnpackWars to "+unpackWars); - } + if (_log.isDebugEnabled()) + _log.debug("set UnpackWars to "+unpackWars); if (isInitialised()) _jetty.setUnpackWars(unpackWars); @@ -379,9 +381,8 @@ public void setWebDefault(String webDefault) { - if (_log.isDebugEnabled()) { - _log.debug("set WebDefault to "+webDefault); - } + if (_log.isDebugEnabled()) + _log.debug("set WebDefault to "+webDefault); if (isInitialised()) _jetty.setWebDefault(webDefault); @@ -405,9 +406,8 @@ public void setHttpSessionStorageStrategy(String storageStrategy) { - if (_log.isDebugEnabled()) { - _log.debug("set HttpSessionStorageStrategy to "+storageStrategy); - } + if (_log.isDebugEnabled()) + _log.debug("set HttpSessionStorageStrategy to "+storageStrategy); if (isInitialised()) _jetty.setHttpSessionStorageStrategy(storageStrategy); @@ -431,9 +431,8 @@ public void setHttpSessionSnapshotFrequency(String snapshotFrequency) { - if (_log.isDebugEnabled()) { - _log.debug("set HttpSessionSnapshotFrequency to "+snapshotFrequency); - } + if (_log.isDebugEnabled()) + _log.debug("set HttpSessionSnapshotFrequency to "+snapshotFrequency); if (isInitialised()) _jetty.setHttpSessionSnapshotFrequency(snapshotFrequency); @@ -457,9 +456,8 @@ public void setHttpSessionSnapshotNotificationPolicy(String snapshotNotificationPolicy) { - if (_log.isDebugEnabled()) { - _log.debug("set HttpSessionSnapshotNotificationPolicy to "+snapshotNotificationPolicy); - } + if (_log.isDebugEnabled()) + _log.debug("set HttpSessionSnapshotNotificationPolicy to "+snapshotNotificationPolicy); if (isInitialised()) _jetty.setHttpSessionSnapshotNotificationPolicy(snapshotNotificationPolicy); @@ -483,9 +481,8 @@ public void setConfiguration(String configUrl) { - if (_log.isDebugEnabled()) { - _log.debug("set Configuration to "+configUrl); - } + if (_log.isDebugEnabled()) + _log.debug("set Configuration to "+configUrl); if (isInitialised()) _jetty.setConfiguration(configUrl); @@ -509,9 +506,8 @@ public void setJettyHome(String jettyHome) { - if (_log.isDebugEnabled()) { - _log.debug("set JettyHome to "+jettyHome); - } + if (_log.isDebugEnabled()) + _log.debug("set JettyHome to "+jettyHome); if (isInitialised()) _jetty.setJettyHome(jettyHome);
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development