User: jules   
  Date: 00/12/11 12:01:48

  Modified:    jetty/src/main/org/jboss/jetty JBossLogSink.java
                        JettyService.java JettyServiceMBean.java
  Log:
  Update jboss-jetty to work with new JMX structure.
  Work around a change in Jetty
  Allow multiple configuration files to be read
  
  Revision  Changes    Path
  1.2       +26 -2     contrib/jetty/src/main/org/jboss/jetty/JBossLogSink.java
  
  Index: JBossLogSink.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/contrib/jetty/src/main/org/jboss/jetty/JBossLogSink.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JBossLogSink.java 2000/11/10 01:10:13     1.1
  +++ JBossLogSink.java 2000/12/11 20:01:48     1.2
  @@ -1,5 +1,5 @@
   // ========================================================================
  -// $Id: JBossLogSink.java,v 1.1 2000/11/10 01:10:13 jules Exp $
  +// $Id: JBossLogSink.java,v 1.2 2000/12/11 20:01:48 jules Exp $
   // ========================================================================
   /*
    * jBoss, the OpenSource EJB server
  @@ -18,7 +18,7 @@
    * logging APIs.
    *
    * @see
  - * @version $Id: JBossLogSink.java,v 1.1 2000/11/10 01:10:13 jules Exp $
  + * @version $Id: JBossLogSink.java,v 1.2 2000/12/11 20:01:48 jules Exp $
    * @author Jules Gosnell (jules)
    */
   public class JBossLogSink
  @@ -77,6 +77,30 @@
                 boolean logOneLine)
     {
       // is it possible to translate these into JBoss logging options...?
  +  }
  +  
  +  public void
  +    setOptions(String logOptions)
  +  {  
  +//     setOptions((logOptions.indexOf(OPT_TIMESTAMP) >= 0),
  +//          (logOptions.indexOf(OPT_LABEL) >= 0),
  +//          (logOptions.indexOf(OPT_TAG) >= 0),
  +//          (logOptions.indexOf(OPT_STACKSIZE) >= 0),
  +//          (logOptions.indexOf(OPT_STACKTRACE) >= 0),
  +//          (logOptions.indexOf(OPT_ONELINE) >= 0));
  +  }
  +  
  +  public String
  +    getOptions()
  +  {
  +//     return
  +//       (_logTimeStamps?"t":"")+
  +//       (_logLabels?"L":"")+
  +//       (_logTags?"T":"")+
  +//       (_logStackSize?"s":"")+
  +//       (_logStackTrace?"S":"")+
  +//       (_logOneLine?"O":"");
  +    return "";
     }
     
     /* ------------------------------------------------------------ */
  
  
  
  1.5       +65 -18    contrib/jetty/src/main/org/jboss/jetty/JettyService.java
  
  Index: JettyService.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/contrib/jetty/src/main/org/jboss/jetty/JettyService.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JettyService.java 2000/11/16 01:32:45     1.4
  +++ JettyService.java 2000/12/11 20:01:48     1.5
  @@ -12,6 +12,7 @@
   import java.io.InputStream;
   import java.io.IOException;
   import java.util.Hashtable;
  +import java.util.Vector;
   
   import javax.management.*;
   
  @@ -30,18 +31,42 @@
    *      
    *   @see <related>
    *   @author <a href="mailto:[EMAIL PROTECTED]">Julian Gosnell</a>
  - *   @version $Revision: 1.4 $
  + *   @version $Revision: 1.5 $
    */
   public class JettyService extends ServiceMBeanSupport
     implements JettyServiceMBean, MBeanRegistration
   {
  +  class JettyLog extends Log
  +  {
  +    Object _source=null;     // should really be in same package as Log
  +
  +    public
  +      JettyLog()
  +    {
  +      super();
  +    }
  +
  +    public
  +      JettyLog(Object source)
  +    {
  +      super(source);
  +      _source=source;                // hack
  +    }
  +    
  +    public void
  +      log(String type, String message)
  +    {
  +      Logger.getLogger().fireNotification(type, _source, message);
  +    }
  +  }
  +  
     public static final String NAME = "Jetty";
   
  -  Log          _log        = new Log(getName());
  +  Log          _log        = new JettyLog(getName());
     JBossLogSink _logSink    = new JBossLogSink();
     HttpServer   _server     = null;
     String       _home       = null;
  -  String       _config     = null;
  +  Vector       _configs    = new Vector();
     Hashtable    _deployed   = new Hashtable();
   
     protected void
  @@ -68,6 +93,9 @@
         URL jettyUrl = jettyClass.getProtectionDomain().getCodeSource().getLocation();
         _home = new File(new File(jettyUrl.getFile()).getParent()).getParent();
         System.setProperty("jetty.home", _home);
  +
  +      // tell Jetty to use JBoss' XML Parser - Yeugghhhhhh !
  +      //      System.setProperty("org.xml.sax.parser", "com.sun.xml.parser.Parser");
         
         // connect Jetty and JBoss log models...
         try{_logSink.initialize(_log);}catch(Exception e){e.printStackTrace();}
  @@ -101,8 +129,13 @@
         try
         {
        // now add server config...
  -     XmlConfiguration xc=new XmlConfiguration(new URL(_config));
  -     xc.configure(_server);
  +     for (int i=0; i<_configs.size(); i++)
  +     {
  +       String config=(String)_configs.elementAt(i);
  +       URL url=new URL(config);
  +       XmlConfiguration xc=new XmlConfiguration(url);
  +       xc.configure(_server);
  +     }
         }
         catch(Exception e)
         {
  @@ -120,9 +153,8 @@
     //----------------------------------------------------------------------------
   
     public
  -    JettyService(String config)
  +    JettyService()
     {
  -    _config=config;
     }
   
     //----------------------------------------------------------------------------
  @@ -150,19 +182,21 @@
       startService()
       throws Exception
     {
  -    System.out.println("Starting Jetty (jetty.mortbay.com)");
  +    Log.setLog(_log);
  +    Logger.log("Starting (jetty.mortbay.com)");
       ensureService();         // lazy construction
       // should check whether already running ? TODO
       _server.start();
  +    Log.unsetLog();
     }
      
     public void
       stopService()
     {
       // should check whether already stopped ? TODO
  -    System.out.println("Stopping Jetty - if using sun jdk 1.3 on linux, waits 1 
minute for Sun bug 4386498... ");
  +    Logger.log("Stopping- if using sun jdk 1.3 on linux, waits 1 minute for Sun bug 
4386498... ");
       try {_server.stop();} catch (Exception e) {e.printStackTrace();}
  -    System.out.println("Jetty Stopped");
  +    Logger.log("Stopped Successfully");
     }
   
     //----------------------------------------------------------------------------
  @@ -174,7 +208,8 @@
       throws DeploymentException
     {
       Log.setLog(log);
  -             
  +    Logger.log("Deploying- context:"+path+" webapp:"+warUrl);
  +    
       try
       {
         // deploy the WebApp
  @@ -185,25 +220,25 @@
         // give Jetty it's correct default resource file - should be parameterised...
         String defaultResource=_home+"/etc/webdefault.xml";
         
  -      System.out.println("About to deploy - "+contextPath+" maps to "+warDir);
         WebApplicationContext app = _server.addWebApplication(contextPath,
                                                            warDir,
                                                            defaultResource);
         
         // Use the same ClassLoader as JBoss - this allows optimisation
         // of calls to EJBs...
  -
  +      
         // Greg reckons that as long as we set the ClassLoader before
         // start()-ing it should do the business...
         ClassLoader cl=Thread.currentThread().getContextClassLoader();
  -      System.out.println("using ClassLoader - "+cl);
         app.setClassLoader(cl);
  -
  +      
         // finally - start the WebApp...
         app.start();
         
         // keep track of deployed contexts for undeployment
         _deployed.put(warUrl, app);
  +      
  +      Logger.log("Deployed successfully");
       }
       catch (Exception e)
       {
  @@ -221,6 +256,7 @@
       throws DeploymentException
     {
       Log.setLog(log);
  +    Logger.log("Undeploying- webapp:"+warUrl);
                
       try
       {
  @@ -241,22 +277,21 @@
        {
          i++;
          hc=_server.getContext(null, app.getContextPath()+"/*", i);
  -       System.out.println("trying - "+app.getContextPath()+"/*"+" - "+hc);
        }
        while (hc!=null && hc!= app);
        
        if (hc==app)
        {
  -       System.out.println("found WebApp for removal : "+i);
          _server.removeContext(null, app.getContextPath()+"/*", i);
        }
        else
        {
  -       System.out.println("could not remove WebApp Context : "+i);
  +       Logger.log("could not remove WebApp Context : "+i);
        }
         }
         
         _deployed.remove(app);
  +      Logger.log("Undeployed successfully");
       }
       catch (Exception e)
       {
  @@ -272,5 +307,17 @@
       isDeployed(String warUrl)
     {
       return _deployed.containsKey(warUrl);
  +  }
  +
  +  // I want multiple configs - but we'll make do with one for the
  +  // moment...
  +  public void
  +    setConfiguration(String configUrl)
  +  {
  +    Log.setLog(_log);
  +    Logger.log("Adding configuration- "+configUrl);
  +    _configs.addElement(configUrl);
  +    Logger.log("Added successfully");
  +    Log.unsetLog();
     }
   }
  
  
  
  1.2       +1 -0      contrib/jetty/src/main/org/jboss/jetty/JettyServiceMBean.java
  
  Index: JettyServiceMBean.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/contrib/jetty/src/main/org/jboss/jetty/JettyServiceMBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JettyServiceMBean.java    2000/11/10 01:10:14     1.1
  +++ JettyServiceMBean.java    2000/12/11 20:01:48     1.2
  @@ -16,7 +16,7 @@
    *      
    *   @see <related>
    *   @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
  - *   @version $Revision: 1.1 $
  + *   @version $Revision: 1.2 $
    */
   public interface JettyServiceMBean
     extends org.jboss.util.ServiceMBean
  @@ -32,4 +32,5 @@
        
     public boolean isDeployed(String warUrl);
   
  +  public void setConfiguration(String configUrl);
   }
  
  
  

Reply via email to