User: janb    
  Date: 02/02/19 21:37:24

  Modified:    jetty/src/main/org/jboss/jetty
                        JBossWebApplicationContext.java Jetty.java
                        JettyService.java JettyServiceMBean.java
  Log:
  Removed necessity for jetty.xml for config.
  
  Revision  Changes    Path
  1.26      +3 -4      
contrib/jetty/src/main/org/jboss/jetty/JBossWebApplicationContext.java
  
  Index: JBossWebApplicationContext.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JBossWebApplicationContext.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- JBossWebApplicationContext.java   20 Feb 2002 00:15:35 -0000      1.25
  +++ JBossWebApplicationContext.java   20 Feb 2002 05:37:23 -0000      1.26
  @@ -5,7 +5,7 @@
    * See terms of license at gnu.org.
    */
   
  -// $Id: JBossWebApplicationContext.java,v 1.25 2002/02/20 00:15:35 jules_gosnell 
Exp $
  +// $Id: JBossWebApplicationContext.java,v 1.26 2002/02/20 05:37:23 janb Exp $
   
   // A Jetty HttpServer with the interface expected by JBoss'
   // J2EEDeployer...
  @@ -52,15 +52,14 @@
                               WebApplication webApp,
                               DocumentBuilder parser,
                               String warUrl,
  -                            String webDefaults,
  -                            boolean unpackWars,
                               String storageStrategy,
                               String snapshotFrequency,
                               String notificationPolicy,
                               String subjAttrName)
       throws java.io.IOException
       {
  -      super(httpServer, contextPathSpec, warUrl, webDefaults, unpackWars);
  +     
  +         super(httpServer, contextPathSpec, warUrl);
   
         _log              = Logger.getLogger(getClass().getName()+"#" + 
contextPathSpec);
         _descriptorParser = descriptorParser;
  
  
  
  1.39      +151 -57   contrib/jetty/src/main/org/jboss/jetty/Jetty.java
  
  Index: Jetty.java
  ===================================================================
  RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/Jetty.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- Jetty.java        20 Feb 2002 00:15:35 -0000      1.38
  +++ Jetty.java        20 Feb 2002 05:37:23 -0000      1.39
  @@ -5,7 +5,7 @@
    * See terms of license at gnu.org.
    */
   
  -// $Id: Jetty.java,v 1.38 2002/02/20 00:15:35 jules_gosnell Exp $
  +// $Id: Jetty.java,v 1.39 2002/02/20 05:37:23 janb Exp $
   
   // A Jetty HttpServer with the interface expected by JBoss'
   // J2EEDeployer...
  @@ -15,11 +15,21 @@
   package org.jboss.jetty;
   
   //------------------------------------------------------------------------------
  -
  +import java.io.ByteArrayOutputStream;
   import java.net.URL;
   import java.util.Hashtable;
   import javax.xml.parsers.DocumentBuilder;
   import javax.xml.parsers.DocumentBuilderFactory;
  +
  +import org.w3c.dom.Element;
  +import javax.xml.transform.Transformer;
  +import javax.xml.transform.TransformerFactory;
  +import javax.xml.transform.TransformerException;
  +import javax.xml.transform.TransformerConfigurationException;
  +import javax.xml.transform.dom.DOMSource;
  +import javax.xml.transform.stream.StreamResult;
  +
  +    
   import org.jboss.deployment.DeploymentException;
   import org.jboss.jetty.xml.JettyResolver;
   import org.jboss.logging.Logger;
  @@ -27,7 +37,7 @@
   import org.jboss.web.WebApplication;
   import org.mortbay.jetty.servlet.WebApplicationContext;
   import org.mortbay.util.MultiException;
  -
  +import org.mortbay.xml.XmlConfiguration;
   //------------------------------------------------------------------------------
   
   /**
  @@ -35,7 +45,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Julian Gosnell</a>
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Andreas Schaefer</a>.
  - * @version $Revision: 1.38 $
  + * @version $Revision: 1.39 $
    *
    * <p><b>Revisions:</b>
    *
  @@ -55,6 +65,12 @@
     DocumentBuilder               _parser;
     Logger                        _log     = Logger.getLogger(Jetty.class);
   
  +    // the XML snippet
  +    String _xmlConfigString = null;
  +    
  +    // the XML snippet as a DOM element
  +    Element _configElement = null;
  +    
     Jetty()
     {
       super();
  @@ -92,22 +108,6 @@
         _log.warn("JSP compilation requires $JAVA_HOME/lib/tools.jar on your 
JBOSS_CLASSPATH");
     }
   
  -  //----------------------------------------
  -  // jettyHome property
  -  //----------------------------------------
  -
  -  synchronized void
  -    setJettyHome(String jettyHome) // not public
  -  {
  -    if (jettyHome!=null)
  -      System.setProperty("jetty.home", jettyHome);
  -  }
  -
  -  public synchronized String
  -    getJettyHome()
  -  {
  -    return System.getProperty("jetty.home");
  -  }
   
     //----------------------------------------
     // unpackWars property
  @@ -133,11 +133,35 @@
   
     String _webDefault;
   
  -  public synchronized void
  +    /** If a webdefault.xml file has been specified in
  +     * jboss-service.xml then we try and use that.
  +     *
  +     * If we cannot find it, then we will use the one
  +     * shipped as standard with Jetty and issue a warning.
  +     * 
  +     * If the jboss-service.xml file does not specify a
  +     * custom one, then we again default to the standard one.
  +     * @param webDefault 
  +     */
  +    public synchronized void
       setWebDefault(String webDefault)
  -  {
  -    webDefault=fixURL(findResourceInJar(webDefault).toString());
  -    _webDefault=webDefault;
  +    {
  +        if (webDefault != null)
  +        {
  +            URL webDefaultURL = findResourceInJar(webDefault);
  +            if (webDefaultURL != null)
  +                _webDefault=fixURL(webDefaultURL.toString());
  +            else
  +                _webDefault = null;
  +                _log.warn ("Cannot find resource for "+webDefault+": using 
default");
  +        }
  +        else
  +            _webDefault = null;
  +        
  +        if (_log.isDebugEnabled())
  +           _log.debug ("webdefault specification is: "+_webDefault);
  +        
  +   
     }
   
     public synchronized String
  @@ -218,39 +242,97 @@
       return _subjectAttributeName;
     }
   
  -  //----------------------------------------
  -  // configuration property
  -  //----------------------------------------
   
  -  String _configuration=null;
  -
  -  public synchronized void
  -    setConfiguration(String configUrl)
  -  {
  -    if (configUrl==null)
  -      return;
   
  -    configUrl=fixURL(findResourceInJar(configUrl).toString());
  +    
  +    //----------------------------------------
  +    // configuration property
  +    //----------------------------------------
   
  -    try
  +    public Element getConfigurationElement ()
       {
  -      if (_log.isDebugEnabled())
  -     _log.debug("loading configuration: "+configUrl);
  -      configure(configUrl);
  -      _log.debug("configuratin loaded");
  -      _configuration=configUrl;
  +        return _configElement;
  +        
       }
  -    catch (Exception e)
  +    
  +    /** 
  +     * @param configElement XML fragment from jboss-service.xml
  +     */
  +    public void setConfigurationElement (Element configElement)
       {
  -      _log.error("problem loading configuration: "+configUrl, e);
  -    }
  -  }
   
  -  public synchronized String
  -    getConfiguration()
  -  {
  -    return _configuration;
  -  }
  +        // convert to an xml string to pass into Jetty's normal
  +        // configuration mechanism
  +        _configElement = configElement;
  +        
  +        try
  +        {
  +            DOMSource source = new DOMSource(configElement);
  +            
  +            ByteArrayOutputStream stream = new ByteArrayOutputStream();
  +            
  +            StreamResult result = new StreamResult (stream);
  +            
  +            TransformerFactory factory = TransformerFactory.newInstance();
  +            Transformer transformer = factory.newTransformer();
  +            transformer.transform (source, result);
  +            
  +            _xmlConfigString = stream.toString();
  +            
  +            // get rid of the first line, as this will be prepended by
  +            // the XmlConfiguration
  +            int index = _xmlConfigString.indexOf("?>");
  +            if ( index >= 0)
  +            {
  +                index += 2;
  +                
  +                while ((_xmlConfigString.charAt(index) == '\n')
  +                       ||
  +                       (_xmlConfigString.charAt(index) == '\r'))
  +                    index++;
  +            }
  +            
  +            _xmlConfigString = _xmlConfigString.substring(index);
  +
  +            _log.debug ("Passing xml config to jetty:\n"+_xmlConfigString);
  +            
  +            setXMLConfiguration (_xmlConfigString);
  +            
  +         }
  +         catch (TransformerConfigurationException tce)
  +         {
  +             _log.error ("Can't transform config Element -> xml:", tce);
  +         }
  +         catch (TransformerException te)
  +         {
  +             _log.error ("Can't transform config Element -> xml:", te);
  +         }
  +         catch (Exception e)
  +         {
  +             _log.error("Unexpected exception converting configuration Element -> 
xml", e);
  +         }
  +    }
  +    
  +    /* Actually perform the configuration
  +     * @param xmlString 
  +     */
  +    private void setXMLConfiguration (String xmlString)
  +    {
  +        
  +        try
  +        {
  +            XmlConfiguration xmlConfigurator = new XmlConfiguration (xmlString);
  +            xmlConfigurator.configure(this);
  +        }
  +        catch (Exception e)
  +        {
  +            _log.error("problem configuring Jetty:", e);
  +        }
  +    }
  +    
  +    
  +   
  +    
   
     //----------------------------------------------------------------------------
     // 'deploy' interface
  @@ -277,13 +359,25 @@
   
         // deploy the WebApp
         WebApplicationContext app=
  -     new JBossWebApplicationContext(this, contextPath, descriptorParser, wa, 
_parser,
  -                                    fixedWarUrl, getWebDefault(), getUnpackWars(),
  -                                    getHttpSessionStorageStrategy(),
  -                                    getHttpSessionSnapshotFrequency(),
  -                                    getHttpSessionSnapshotNotificationPolicy(),
  -                                    getSubjectAttributeName());
  -
  +          new JBossWebApplicationContext(this, contextPath,
  +                                         descriptorParser, wa, _parser,
  +                                         fixedWarUrl,
  +                                         getHttpSessionStorageStrategy(),
  +                                         getHttpSessionSnapshotFrequency(),
  +                                         getHttpSessionSnapshotNotificationPolicy(),
  +                                         getSubjectAttributeName());
  +
  +      
  +      // configure whether the context is to flatten the classes in
  +      // the WAR or not      
  +      app.setExtractWAR (getUnpackWars());
  +
  +
  +      // if a different webdefaults.xml file has been provided, use it
  +      if (getWebDefault() != null)
  +          app.setDefaultsDescriptor (getWebDefault());
  +      
  +      
         String virtualHost=null;
         addContext(virtualHost, app);
   
  
  
  
  1.50      +75 -71    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.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- JettyService.java 20 Feb 2002 00:15:35 -0000      1.49
  +++ JettyService.java 20 Feb 2002 05:37:23 -0000      1.50
  @@ -5,7 +5,7 @@
    * See terms of license at gnu.org.
    */
   
  -// $Id: JettyService.java,v 1.49 2002/02/20 00:15:35 jules_gosnell Exp $
  +// $Id: JettyService.java,v 1.50 2002/02/20 05:37:23 janb Exp $
   
   //------------------------------------------------------------------------------
   
  @@ -15,10 +15,12 @@
   
   import java.io.IOException;
   import java.io.InputStream;
  +
   import java.net.URL;
   import javax.management.MBeanRegistration;
   import javax.management.MBeanServer;
   import javax.management.ObjectName;
  +import org.w3c.dom.Element;
   import org.jboss.deployment.DeploymentException;
   import org.jboss.jetty.log.JBossLogSink;
   import org.jboss.logging.Logger;
  @@ -29,28 +31,37 @@
   import org.mortbay.util.jmx.LogMBean;
   import org.mortbay.util.Log;
   
  +
  +
   //------------------------------------------------------------------------------
   /**
    * A service to launch jetty from JMX.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Julian Gosnell</a>
  - * @version $Revision: 1.49 $
  + * @version $Revision: 1.50 $
    */
   
   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;
  -  ObjectName  _codeBeanName = null;
  -  ObjectName  _logBeanName  = null;
  +    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;
  +    ObjectName _codeBeanName = null;
  +    
  +    ObjectName _logBeanName = null;
  +
  +    Element _configElement = null;
  + 
  +    
  +    
   
     public
       JettyService()
  @@ -60,7 +71,9 @@
       // that logging models are connected before configure-time (via
       // MLET file) which is done before initialise-time.
       ensureLogging();
  +
       ensureNaming();
  +
     }
   
     //----------------------------------------------------------------------------
  @@ -76,6 +89,9 @@
       return name;
     }
   
  +
  +  
  +    
     //----------------------------------------------------------------------------
   
     public void
  @@ -115,7 +131,7 @@
       // why doesn't this work? - investigate...
       //    _jetty.setLogSink(logSink);
   
  -    _log.debug("connected JBoss and Jetty Log models");
  +    _log.info("connected JBoss and Jetty Log models");
     }
   
     /** the usual path separators we know */
  @@ -128,7 +144,6 @@
   
       // make a Jetty...
       Jetty tmp = new Jetty();
  -    tmp.setJettyHome(getJettyHome());
       tmp.setWebDefault(getWebDefault());
       tmp.setUnpackWars(getUnpackWars());
       tmp.setHttpSessionStorageStrategy(getHttpSessionStorageStrategy());
  @@ -137,8 +152,6 @@
       tmp.setSubjectAttributeName(getSubjectAttributeName());
   
       _jetty=tmp;              // now we are initialised.
  -
  -    _log.debug("Instantiated and configured server");
     }
   
     protected void
  @@ -150,14 +163,17 @@
       {
         try
         {
  -     _log.debug("MBean peers WILL be created for Jetty Contexts");
  +          _log.info("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, _codeBeanName);
        _server.registerMBean(_logbean, _logBeanName);
  +
         }
         catch (Throwable e)
         {
  @@ -166,10 +182,10 @@
       }
       else
       {
  -      _log.debug("MBean peers WILL NOT be created for Jetty Contexts");
  +        _log.info("MBean peers WILL NOT be created for Jetty Contexts");
       }
  -
  -    _jetty.setConfiguration(_configuration);
  +    _jetty.setConfigurationElement (_configElement);
  +    
     }
   
     protected void
  @@ -260,6 +276,7 @@
         }
         _debug=null;
   
  +
         try
         {
        _server.unregisterMBean(_logBeanName);
  @@ -269,6 +286,7 @@
        _log.error ("problem unregistering LogMBean", e);
         }
         _logbean=null;
  +
       }
       else
         _log.warn("Jetty has already been destroyed");
  @@ -353,7 +371,7 @@
     public void
       setUnpackWars(boolean unpackWars)
     {
  -    if (_log.isDebugEnabled())
  +      if (_log.isDebugEnabled())
         _log.debug("set UnpackWars to "+unpackWars);
   
       if (isInitialised())
  @@ -366,6 +384,7 @@
   
     protected String _webDefault=null;
   
  +
     public String
       getWebDefault()
     {
  @@ -378,8 +397,9 @@
     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);
  @@ -387,6 +407,7 @@
         _webDefault=webDefault;
     }
   
  +
     //----------------------------------------------------------------------------
   
     protected String 
_storageStrategy="org.jboss.jetty.session.CoarseDistributedStore";
  @@ -462,8 +483,37 @@
         _snapshotNotificationPolicy=snapshotNotificationPolicy;
     }
   
  -  //----------------------------------------------------------------------------
  +    //----------------------------------------------------------------------------
  +    /** Get the extended Jetty configuration XML fragment
  +     * @return Jetty XML fragment embedded in jboss-service.xml
  +     */
  +    public Element getConfigurationElement ()
  +    {
  +        if (isInitialised())
  +            return _jetty.getConfigurationElement();
  +        else
  +            return _configElement;
  +    }
  +    
  +    
  +    //----------------------------------------------------------------------------
  +    /** Configure Jetty
  +     * @param configElement XML fragment from jboss-service.xml
  +     */
  +    public void setConfigurationElement (Element configElement)
  +    {
  +        if (_log.isDebugEnabled())
  +        {
  +            _log.debug("set Configuration to xml fragment");
  +        }
  +
  +        if (isInitialised())
  +            _jetty.setConfigurationElement (configElement);
  +        
  +         _configElement=configElement;
  +    }
   
  +    
     protected String _subjectAttributeName=null; // "j_subject"
   
     public String
  @@ -487,53 +537,7 @@
         _subjectAttributeName=subjectAttributeName;
     }
   
  -  //----------------------------------------------------------------------------
  -
  -  protected String _configuration=null;
  -
  -  public String
  -    getConfiguration()
  -  {
  -    if (isInitialised())
  -      return _jetty.getConfiguration();
  -    else
  -      return _configuration;
  -  }
  -
  -  public void
  -    setConfiguration(String configUrl)
  -  {
  -    if (_log.isDebugEnabled())
  -      _log.debug("set Configuration to "+configUrl);
  -
  -    if (isInitialised())
  -      _jetty.setConfiguration(configUrl);
  -    else
  -      _configuration=configUrl;
  -  }
  -
  -  //----------------------------------------------------------------------------
  -
  -  protected static String _jettyHome=null;
  + 
  +    
   
  -  public String
  -    getJettyHome()
  -  {
  -    if (isInitialised())
  -      return _jetty.getJettyHome();
  -    else
  -      return _jettyHome;
  -  }
  -
  -  public void
  -    setJettyHome(String jettyHome)
  -  {
  -    if (_log.isDebugEnabled())
  -      _log.debug("set JettyHome to "+jettyHome);
  -
  -    if (isInitialised())
  -      _jetty.setJettyHome(jettyHome);
  -    else
  -      _jettyHome=jettyHome;
  -  }
   }
  
  
  
  1.16      +6 -9      contrib/jetty/src/main/org/jboss/jetty/JettyServiceMBean.java
  
  Index: JettyServiceMBean.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JettyServiceMBean.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- JettyServiceMBean.java    19 Feb 2002 23:22:32 -0000      1.15
  +++ JettyServiceMBean.java    20 Feb 2002 05:37:24 -0000      1.16
  @@ -7,6 +7,8 @@
   
   package org.jboss.jetty;
   
  +import org.w3c.dom.Element;
  +
   import javax.management.ObjectName;
   
   import org.jboss.util.jmx.ObjectNameFactory;
  @@ -17,18 +19,15 @@
    * ???
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sebastien Alborini</a>
  - * @version $Revision: 1.15 $
  + * @version $Revision: 1.16 $
    */
   public interface JettyServiceMBean
      extends org.jboss.web.AbstractWebContainerMBean
   {
      ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.web:service=Jetty");
   
  -   void setConfiguration(String configUrl);
  -   String getConfiguration();
  -
  -   // void setProperty(String property);
  -   // String getProperty();
  +    public void setConfigurationElement (Element configElement);
  +    public Element getConfigurationElement ();
   
      boolean getPublishMBeans();
      void setPublishMBeans(boolean publishMBeans);
  @@ -48,9 +47,7 @@
      String getHttpSessionSnapshotNotificationPolicy();
      void setHttpSessionSnapshotNotificationPolicy(String snapshotNotificationPolicy);
   
  +
      String getSubjectAttributeName();
      void setSubjectAttributeName(String subjectAttributeName);
  -
  -   void setJettyHome(String jettyHome);
  -   String getJettyHome();
   }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to