User: jules_gosnell
  Date: 02/03/20 12:58:31

  Modified:    jetty/src/main/org/jboss/jetty Tag: Branch_2_4
                        JBossUserRealm.java JBossWebApplicationContext.java
                        Jetty.java JettyResolver.java JettyService.java
  Log:
  going for a release on Jetty 3.1.7 (with one fix)
  this is mainly backporting from JBoss3/Jetty4 src
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.7   +6 -5      contrib/jetty/src/main/org/jboss/jetty/Attic/JBossUserRealm.java
  
  Index: JBossUserRealm.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/Attic/JBossUserRealm.java,v
  retrieving revision 1.2.2.6
  retrieving revision 1.2.2.7
  diff -u -r1.2.2.6 -r1.2.2.7
  --- JBossUserRealm.java       28 Feb 2002 19:21:13 -0000      1.2.2.6
  +++ JBossUserRealm.java       20 Mar 2002 20:58:31 -0000      1.2.2.7
  @@ -5,7 +5,7 @@
    * See terms of license at gnu.org.
    */
   
  -// $Id: JBossUserRealm.java,v 1.2.2.6 2002/02/28 19:21:13 danch Exp $
  +// $Id: JBossUserRealm.java,v 1.2.2.7 2002/03/20 20:58:31 jules_gosnell Exp $
   
   package org.jboss.jetty;
   
  @@ -15,6 +15,7 @@
   import javax.naming.InitialContext;
   import javax.naming.NamingException;
   import org.apache.log4j.Category;
  +import org.jboss.logging.Logger;
   import org.jboss.security.AuthenticationManager;
   import org.jboss.security.RealmMapping;
   import org.jboss.security.SecurityAssociation;
  @@ -26,7 +27,7 @@
   /** An implementation of UserRealm that integrates with the JBossSX
    * security manager associted with the web application.
    * @author  [EMAIL PROTECTED]
  - * @version $Revision: 1.2.2.6 $
  + * @version $Revision: 1.2.2.7 $
    *
    * <p><b>Revisions:</b>
    * 
  @@ -38,7 +39,7 @@
    */
   
   public class JBossUserRealm implements UserRealm {
  -   private Category _log;
  +  private Logger                 _log;
      private String _realmName;
      private AuthenticationManager _securityMgr;
      private RealmMapping _realmMapping;
  @@ -116,8 +117,8 @@
         }
      }
   
  -   public JBossUserRealm(Category log, String realmName) {
  -      _log = log;
  +   public JBossUserRealm(String realmName) {
  +      _log = Logger.getLogger(JBossUserRealm.class.getName() + "#" + _realmName);
         _realmName = realmName;
         _log.info("Security- created JBossUserRealm: "+_realmName);
      }
  
  
  
  1.34.2.2  +305 -31   
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.34.2.1
  retrieving revision 1.34.2.2
  diff -u -r1.34.2.1 -r1.34.2.2
  --- JBossWebApplicationContext.java   20 Mar 2002 00:30:24 -0000      1.34.2.1
  +++ JBossWebApplicationContext.java   20 Mar 2002 20:58:31 -0000      1.34.2.2
  @@ -5,71 +5,345 @@
    * See terms of license at gnu.org.
    */
   
  -// $Id: JBossWebApplicationContext.java,v 1.34.2.1 2002/03/20 00:30:24 
jules_gosnell Exp $
  +// $Id: JBossWebApplicationContext.java,v 1.34.2.2 2002/03/20 20:58:31 
jules_gosnell Exp $
   
   // A Jetty HttpServer with the interface expected by JBoss'
   // J2EEDeployer...
   
  +//------------------------------------------------------------------------------
  +
   package org.jboss.jetty;
   
  -import org.apache.log4j.Category;
  +//------------------------------------------------------------------------------
  +
  +import java.io.FileNotFoundException;
  +import java.io.IOException;
  +import java.net.URL;
  +import java.net.URLClassLoader;
  +import javax.xml.parsers.DocumentBuilder;
  +import org.jboss.jetty.JBossUserRealm;
  +import org.jboss.logging.Logger;
   import org.jboss.web.AbstractWebContainer.WebDescriptorParser;
   import org.jboss.web.WebApplication;
  +import org.mortbay.http.ContextLoader;
   import org.mortbay.http.HttpServer;
  +import org.mortbay.http.handler.SecurityHandler;
   import org.mortbay.jetty.servlet.WebApplicationContext;
  -import org.w3c.dom.Element;
  +import org.mortbay.util.Resource;
  +import org.xml.sax.InputSource;
  +
  +import java.util.Iterator;
  +import java.util.List;
  +import java.util.ArrayList;
  +
  +//------------------------------------------------------------------------------
   
   public class
     JBossWebApplicationContext
     extends WebApplicationContext
   {
  -  Category            _log;
  +  Logger              _log;
  +  Jetty               _jetty;
     WebDescriptorParser _descriptorParser;
     WebApplication      _webApp;
  +  DocumentBuilder     _parser;
  +  //  String              _subjAttrName="j_subject";
   
     public
  -    JBossWebApplicationContext(HttpServer httpServer,
  +    JBossWebApplicationContext(Jetty jetty,
                               String contextPathSpec,
  -                            Category log,
                               WebDescriptorParser descriptorParser,
  -                            WebApplication webApp)
  +                            WebApplication webApp,
  +                            DocumentBuilder parser/*,*/
  +                            /*String warUrl*/)
  +    throws IOException
       {
  -      super(httpServer, contextPathSpec);
   
  -      _log              = log;
  +      super(jetty, contextPathSpec/*, warUrl*/);
  +
  +      _log              = Logger.getLogger(getClass().getName()+"#" + 
contextPathSpec);
  +      _jetty            = jetty;
         _descriptorParser = descriptorParser;
         _webApp           = webApp;
  +      _parser           = parser;
  +      //      _subjAttrName     = jetty.getSubjectAttributeName();
       }
   
  -  public void
  -    start()
  -    throws Exception
  +  /* ------------------------------------------------------------ */
  +  /** Get the context SecurityHandler.
  +   * Conveniance method. If no SecurityHandler exists, a new one is added to
  +   * the context at position 0.
  +   * @return SecurityHandler
  +   */
  +
  +  class
  +    JBossSXSecurityHandler
  +    extends SecurityHandler
  +    {
  +      public void start()
  +        throws Exception
  +     {
  +       // Add the JBoss security realm
  +       String realmName = getRealm();
  +       if (realmName!=null)
  +       {
  +         // these need to be cached and reused by name...MAYBE - TODO
  +         getHttpServer().addRealm(new JBossUserRealm(realmName));
  +       }
  +
  +       // this is causing a printout which implies a separate
  +       // SecurityHandler has also started...
  +       super.start();
  +     }
  +    }
  +
  +  /**
  +   * return the first JBossSXSecurityHandler, inserting one at the
  +   * beginning of the list, if no other can be found.
  +   *
  +   * @return a <code>SecurityHandler</code> value
  +   */
  +  public SecurityHandler
  +    getSecurityHandler()
       {
  -      // Add the JBoss security realm
  -      String realmName = getRealm();
  -      if (realmName!=null)
  -     setRealm(realmName,new JBossUserRealm(_log, realmName));
  +      SecurityHandler securityHandler=null;
  +      securityHandler=(SecurityHandler)getHandler(JBossSXSecurityHandler.class);
  +      if (securityHandler==null)
  +      {
  +     securityHandler=new JBossSXSecurityHandler();
  +     addHandler(0,securityHandler);
  +      }
  +      return securityHandler;
  +    }
   
  -      super.start();
  +  // avoid Jetty maoning about things that it doesn't but AbstractWebContainer does 
do...
  +
  +  //   protected void
  +  //     initWebXmlElement(String element, org.mortbay.xml.XmlParser.Node node)
  +  //     throws Exception
  +  //     {
  +  //       // this is ugly - should be dispatched through a hash-table or 
introspection...
  +  //
  +  //       // these are handled by AbstractWebContainer
  +  //       if ("resource-ref".equals(element) ||
  +  //           "env-entry".equals(element) ||
  +  //           "ejb-ref".equals(element) ||
  +  //           "ejb-local-ref".equals(element) ||
  +  //           "security-domain".equals(element))
  +  //       {
  +  //         //_log.info("Don't moan : "+element);
  +  //       }
  +  //       else if ("distributable".equals(element))
  +  //       {
  +  //         
((DistributedHttpSessionManager)getServletHandler().getSessionManager()).
  +  //           setDistributed(true);
  +  //       }
  +  //       // these are handled by Jetty
  +  //       else
  +  //         super.initWebXmlElement(element, node);
  +  //     }
  +
  +  // hack our class loader to be Java2 compliant - i.e. always
  +  // delegate upwards before looking locally. This will be changed to
  +  // a non-compliant strategy later when JBoss' new ClassLoader is
  +  // ready.
  +
  +  //   protected void initClassLoader(boolean forceContextLoader)
  +  //     throws java.net.MalformedURLException, IOException
  +  //     {
  +  //       // force the creation of a context class loader for JBoss
  +  //       // web apps
  +  //       super.initClassLoader(true);
  +  //
  +  //       ClassLoader _loader=getClassLoader();
  +  //       if (_loader instanceof org.mortbay.http.ContextLoader)
  +  //         
((org.mortbay.http.ContextLoader)_loader).setJava2Compliant(_jetty.getJava2ClassLoadingCompliance());
  +  //     }
  +
  +//   String _separator=System.getProperty("path.separator");
  +//
  +//   public String
  +//     getFileClassPath()
  +//     {
  +//       List List=new ArrayList();
  +//       getFileClassPath(getClassLoader(), List);
  +//
  +//       String classpath="";
  +//       for (Iterator i=List.iterator(); i.hasNext();)
  +//       {
  +//   URL url=(URL)i.next();
  +//
  +//   //      if (url.getProtocol().equals("njar"))
  +//   //      {
  +//   //        try
  +//   //        {
  +//   //          URLConnection conn=url.openConnection();
  +//   //          //url=conn.getURL();
  +//   //          _log.warn("JSP CONNECTION: "+conn);
  +//   //        }
  +//   //        catch (IOException ignore)
  +//   //        {
  +//   //        }
  +//   //      }
  +//
  +//   if (!url.getProtocol().equals("file")) // tmp warning
  +//   {
  +//     _log.warn("JSP classpath: non-'file' protocol: "+url);
  +//     continue;
  +//   }
  +//
  +//           try
  +//           {
  +//             Resource res = Resource.newResource (url);
  +//             if (res.getFile()==null)
  +//               _log.warn("bad classpath entry: "+url);
  +//             else
  +//             {
  +//               String tmp=res.getFile().getCanonicalPath();
  +//       //      _log.info("JSP FILE: "+url+" --> "+tmp+" : "+url.getProtocol());
  +//       if (classpath.indexOf(tmp)==-1) // TODO - we should do this
  +//         classpath+=(classpath.length()==0?"":_separator)+tmp;
  +//             }
  +//           }
  +//           catch (IOException ioe)
  +//           {
  +//             _log.warn ("JSP Classpath is damaged, can't convert path for :"+url, 
ioe);
  +//           }
  +//       }
  +//
  +//       _log.info("JSP classpath: "+classpath);
  +//       return classpath;
  +//     }
  +//
  +//   public void
  +//     getFileClassPath(ClassLoader cl, List list)
  +//     {
  +//       if (cl==null)
  +//   return;
  +//
  +//       URL[] urls=null;
  +//
  +//       /*
  +//       if (cl instanceof org.jboss.system.UnifiedClassLoader)
  +//   urls=((org.jboss.system.UnifiedClassLoader)cl).getAllURLs();
  +//       else if (cl instanceof org.jboss.system.MBeanClassLoader)
  +//   urls=((org.jboss.system.MBeanClassLoader)cl).getURLs();
  +//   else */ if (cl instanceof java.net.URLClassLoader)
  +//   urls=((java.net.URLClassLoader)cl).getURLs();
  +//
  +//       _log.info("CLASSLOADER: "+cl);
  +//       _log.info("URLs: "+(urls!=null?urls.length:0));
  +//
  +//       if (urls!=null)
  +//   for (int i=0; i<urls.length; i++)
  +//   {
  +//     URL url=urls[i];
  +//     _log.info("URL: "+url);
  +//     if (!list.contains(url))
  +//       list.add(url);
  +//   }
  +//
  +//       getFileClassPath(cl.getParent(), list);
  +//     }
  +
  +  //   public String
  +  //     getFileClassPath(ClassLoader cl)
  +  //     {
  +  //       String classpath="";
  +  //       String[] entries=_jetty.getCompileClasspath(cl);
  +  //
  +  //       for (int i=0; i<entries.length; i++)
  +  //       {
  +  //         try
  +  //         {
  +  //           Resource res = Resource.newResource (entries[i]);
  +  //           if (res.getFile()==null)
  +  //             _log.warn("bad classpath entry: "+entries[i]);
  +  //           else
  +  //           {
  +  //             String tmp=res.getFile().getCanonicalPath();
  +  //             classpath+=(classpath.length()==0?"":_separator)+tmp;
  +  //           }
  +  //         }
  +  //         catch (IOException ioe)
  +  //         {
  +  //           _log.warn ("JSP Classpath is damaged, can't convert path for 
:"+entries[i], ioe);
  +  //         }
  +  //       }
  +  //
  +  //       if (_log.isDebugEnabled())
  +  //         _log.debug("JSP classpath: "+classpath);
  +  //
  +  //       return classpath;
  +  //     }
  +
  +  // given a resource name, find the jar file that contains that resource...
  +  //   protected String
  +  //     findJarByResource(String resource)
  +  //     throws Exception
  +  //     {
  +  //       String path=getClass().getClassLoader().getResource(resource).toString();
  +  //       // lose initial "jar:file:" and final "!/..."
  +  //       return 
path.substring("jar:file:".length(),path.length()-(resource.length()+2));
  +  //     }
  +
  +  protected void
  +    startHandlers()
  +    throws Exception
  +    {
  +      setUpENC();
  +      super.startHandlers();
  +    }
   
  -      ClassLoader loader = getClassLoader();
  -      _log.info("WebApp Context's ClassLoader is:"+loader);
  +  protected void
  +    setUpENC()
  +    {
  +      _webApp.setClassLoader(Thread.currentThread().getContextClassLoader());
  +      _webApp.setName(getDisplayName());
  +      _webApp.setAppData(this);
   
  -      // sanity check - the classloader with which we are called
  -      // (i.e. the one that Jetty has used for the webapps context)
  -      // should be either the one we specified, or a descendent of it.
  +      try
  +      {
  +     // MANDATORY - web.xml
  +     Resource web=getResource("/WEB-INF/web.xml");
  +     _webApp.setWebApp(_parser.parse(new 
InputSource(web.toString())).getDocumentElement());
  +      }
  +      catch (Exception e)
         {
  -     ClassLoader cl = loader;
  -     while (cl!=null && cl!=_webApp.getClassLoader())
  -       cl=cl.getParent();
  +     _log.error("problem locating web.xml", e);
  +      }
   
  -     if (cl==null)
  -       _log.warn("WebApp Context's ClassLoader is of incorrect descent:"+loader);
  +      try
  +      {
  +     // OPTIONAL - jboss-web.xml
  +     Resource jbossWeb=getResource("/WEB-INF/jboss-web.xml");
  +     if (jbossWeb!=null)
  +       
_webApp.setJbossWeb(_parser.parse(jbossWeb.getInputStream()).getDocumentElement());
  +      }
  +      catch (FileNotFoundException e)
  +      {
  +     _log.debug("no jboss-web.xml found");
  +      }
  +      catch (IOException e)
  +      {
  +     _log.debug("no jboss-web.xml found");
  +      }
  +      catch (Exception e)
  +      {
  +        _log.error("problem locating jboss-web.xml", e);
         }
   
  -      // Setup the JNDI environment
  -      Element webAppDD = _webApp.getWebApp();
  -      Element jbossDD  = _webApp.getJbossWeb();
  -      _descriptorParser.parseWebAppDescriptors(loader, webAppDD, jbossDD);
  +      try
  +      {
  +     _log.debug("setting up ENC...");
  +     _descriptorParser.parseWebAppDescriptors(_webApp.getClassLoader(),
  +                                              _webApp.getWebApp(),
  +                                              _webApp.getJbossWeb());
  +     _log.debug("setting up ENC succeeded");
  +      }
  +      catch (Exception e)
  +      {
  +     _log.error("failed to setup ENC", e);
  +      }
       }
   }
  
  
  
  1.9.2.9   +124 -49   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.9.2.8
  retrieving revision 1.9.2.9
  diff -u -r1.9.2.8 -r1.9.2.9
  --- Jetty.java        20 Mar 2002 00:31:54 -0000      1.9.2.8
  +++ Jetty.java        20 Mar 2002 20:58:31 -0000      1.9.2.9
  @@ -5,46 +5,79 @@
    * See terms of license at gnu.org.
    */
   
  -// $Id: Jetty.java,v 1.9.2.8 2002/03/20 00:31:54 jules_gosnell Exp $
  +// $Id: Jetty.java,v 1.9.2.9 2002/03/20 20:58:31 jules_gosnell Exp $
   
   // A Jetty HttpServer with the interface expected by JBoss'
   // J2EEDeployer...
   
  +//------------------------------------------------------------------------------
  +
   package org.jboss.jetty;
   
  +//------------------------------------------------------------------------------
  +
  +
   import java.io.FileNotFoundException;
   import java.net.URL;
   import java.util.Hashtable;
   import javax.xml.parsers.DocumentBuilder;
   import javax.xml.parsers.DocumentBuilderFactory;
  -import org.apache.log4j.Category;
   import org.jboss.deployment.DeploymentException;
  +import org.jboss.logging.Logger;
  +import org.jboss.security.SecurityAssociation;
   import org.jboss.web.AbstractWebContainer.WebDescriptorParser;
   import org.jboss.web.WebApplication;
  +import org.mortbay.http.HandlerContext;
  +import org.mortbay.http.HttpException;
   import org.mortbay.http.HttpHandler;
  +import org.mortbay.http.HttpRequest;
  +import org.mortbay.http.HttpResponse;
   import org.mortbay.jetty.servlet.WebApplicationContext;
  +import org.mortbay.util.MultiException;
   import org.mortbay.util.Resource;
   
  +//------------------------------------------------------------------------------
  +
   public class Jetty
     extends org.mortbay.jetty.Server
   {
  -  Category _log;
  -  JettyResolver _resolver;
  +  static DocumentBuilderFactory _factory = DocumentBuilderFactory.newInstance();
  +
  +  DocumentBuilder               _parser;
  +  Logger                        _log     = Logger.getLogger(Jetty.class);
  +  JettyService                  _service;
   
  -  Jetty(Category log)
  +  Jetty(JettyService service)
     {
       super();
  -    _log=log;
  +
  +    _service=service;
   
       // resolver should be populated from a configuration file.
  -    _resolver=new JettyResolver(_log);
  +    JettyResolver resolver = new JettyResolver();
   
  -    URL 
stdWeb=findResourceInJar("org.mortbay.http.HttpServer","org/mortbay/jetty/servlet/web.dtd");
  -    _resolver.put("-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN", stdWeb);
  +    // populate dtd resolver
  +    URL stdWeb22=findResourceInJar("org/mortbay/jetty/servlet/web.dtd");
  +    resolver.put("-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN", 
stdWeb22);
  +
  +    URL jbossWeb2=findResourceInJar("org/jboss/metadata/jboss-web.dtd");
  +    resolver.put("-//jBoss//DTD Web Application 2.2//EN", jbossWeb2);
  +    resolver.put("-//JBoss//DTD Web Application 2.2//EN", jbossWeb2);
   
  -    URL 
jbossWeb=findResourceInJar("org.jboss.web.AbstractWebContainer","org/jboss/metadata/jboss-web.dtd");
  -    _resolver.put("-//jBoss//DTD Web Application 2.2//EN", jbossWeb);
  -    _resolver.put("-//JBoss//DTD Web Application 2.2//EN", jbossWeb);
  +    try
  +    {
  +      _parser=_factory.newDocumentBuilder();
  +      _parser.setEntityResolver(resolver);
  +      //      _parser.setErrorHandler();
  +    }
  +    catch (Exception e)
  +    {
  +      _log.error("problem building descriptor parser", e);
  +    }
  +
  +    // check support for JSP compilation...
  +    if 
(findResourceInJar("com/sun/tools/javac/v8/resources/javac.properties")==null)
  +      _log.warn("JSP compilation requires $JAVA_HOME/lib/tools.jar on your 
JBOSS_CLASSPATH");
     }
   
     //----------------------------------------
  @@ -65,6 +98,31 @@
     }
   
     //----------------------------------------
  +  // class loader delegation policy property
  +  //----------------------------------------
  +  boolean _loaderCompliance = true;
  +
  +  /**
  +   * @param loaderCompliance if true, Jetty delegates class loading
  +   *to parent class loader first, false implies servlet spec 2.3 compliance
  +   */
  +  public synchronized void
  +    setJava2ClassLoadingCompliance (boolean loaderCompliance)
  +  {
  +    _loaderCompliance = loaderCompliance;
  +  }
  +
  +  /**
  +   * @return true if Java2 style class loading delegation, false if
  +   *servlet2.3 spec compliance
  +   */
  +  public synchronized boolean
  +    getJava2ClassLoadingCompliance ()
  +  {
  +    return _loaderCompliance;
  +  }
  +
  +  //----------------------------------------
     // unpackWars property
     //----------------------------------------
   
  @@ -150,51 +208,46 @@
         // check whether the context already exists... - a bit hacky,
         // could be nicer...
         if (getContext(null, contextPath, 0)!=null)
  -     _log.warn("WARNING: A WebApplication is already deployed in context 
'"+contextPath+"' - proceed at your own risk.");
  -
  -      // deploy the WebApp
  -      WebApplicationContext app=new JBossWebApplicationContext(this, contextPath, 
_log, descriptorParser, wa);
  -      wa.setAppData(app);
  -
  -      addContext(null, app);
  -
  -      // Use the same ClassLoader as JBoss - this allows optimisation
  -      // of calls to EJBs...
  -      ClassLoader cl=Thread.currentThread().getContextClassLoader();
  -      app.setClassLoader(cl);
  -      wa.setClassLoader(cl);
  +     _log.warn("A WebApplication is already deployed in context '"+contextPath+"' - 
proceed at your own risk.");
   
         String fixedWarUrl=warUrl+(warUrl.endsWith("/")?"":"/");
  -      app.initialize(fixedWarUrl, getWebDefault(), getUnpackWars());
  -
  -      wa.setName(app.getDisplayName());
  +      //      String fixedWarUrl=warUrl;
   
  -      DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
  -      DocumentBuilder parser=factory.newDocumentBuilder();
  -
  -      // locate and register $JETTY_HOME//etc/dtd/web.dtd
  -      //      parser.setErrorHandler();
  -      parser.setEntityResolver(_resolver);
  +      // deploy the WebApp
  +      WebApplicationContext app=
  +     new JBossWebApplicationContext(this, contextPath,
  +                                    descriptorParser, wa, _parser/*,
  +                                                                   fixedWarUrl*/);
  +
  +      /*
  +      // 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());
  +      */
   
  -      // MANDATORY - web.xml
  -      Resource web=app.getResource("/WEB-INF/web.xml");
  -      wa.setWebApp(parser.parse(web.getInputStream()).getDocumentElement());
  +      String virtualHost=null;
  +      addContext(virtualHost, app);
   
         try
         {
  -     // OPTIONAL - jboss-web.xml
  -     Resource jbossWeb=app.getResource("/WEB-INF/jboss-web.xml");
  -     if (jbossWeb!=null)
  -       wa.setJbossWeb(parser.parse(jbossWeb.getInputStream()).getDocumentElement());
  +     // finally start the app
  +     app.initialize(fixedWarUrl, getWebDefault(), getUnpackWars());
  +     app.start();
         }
  -      catch (FileNotFoundException e)
  +      catch (MultiException me)
         {
  -     _log.info("no jboss-web.xml found");
  +     _log.warn("problem deploying "+warUrl+" to "+contextPath);
  +     for (int i=0; i<me.size(); i++)
  +     {
  +       Exception e=me.getException(i);
  +       _log.warn(e, e);
  +     }
         }
  -
  -      // finally start the app
  -      app.start();
  -
         // keep track of deployed contexts for undeployment
         _deployed.put(warUrl, app);
   
  @@ -225,7 +278,7 @@
   
         _deployed.remove(warUrl);
   
  -      _log.info("successfully undeployed "+warUrl);
  +      _log.info("Successfully undeployed "+warUrl);
       }
       catch (Exception e)
       {
  @@ -245,7 +298,7 @@
     //----------------------------------------------------------------------------
   
     public URL
  -    findResourceInJar(String sibling, String name)
  +    findResourceInJar(String name)
     {
       URL url=null;
   
  @@ -259,5 +312,27 @@
       }
   
       return url;
  +  }
  +
  +  /** Override service method to allow ditching of security info
  +   * after a request has been processed
  +   * @param request
  +   * @param response
  +   * @return
  +   * @exception IOException
  +   * @exception HttpException
  +   */
  +  public org.mortbay.http.HandlerContext
  +    service(HttpRequest request, HttpResponse response)
  +    throws HttpException, java.io.IOException
  +  {
  +    try
  +    {
  +      return super.service(request,response);
  +    }
  +    finally
  +    {
  +      SecurityAssociation.setPrincipal(null);
  +    }
     }
   }
  
  
  
  1.1.6.5   +12 -12    contrib/jetty/src/main/org/jboss/jetty/Attic/JettyResolver.java
  
  Index: JettyResolver.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/Attic/JettyResolver.java,v
  retrieving revision 1.1.6.4
  retrieving revision 1.1.6.5
  diff -u -r1.1.6.4 -r1.1.6.5
  --- JettyResolver.java        19 Mar 2002 21:44:55 -0000      1.1.6.4
  +++ JettyResolver.java        20 Mar 2002 20:58:31 -0000      1.1.6.5
  @@ -5,17 +5,21 @@
    * See terms of license at gnu.org.
    */
   
  -// $Id$
  +//------------------------------------------------------------------------------
   
   package org.jboss.jetty;
   
  +//------------------------------------------------------------------------------
  +
   import java.io.IOException;
   import java.net.URL;
   import java.util.HashMap;
  -import org.apache.log4j.Category;
  +import org.jboss.logging.Logger;
   import org.xml.sax.EntityResolver;
   import org.xml.sax.InputSource;
   
  +//------------------------------------------------------------------------------
  +
   // I could use a Hashtable instead of HashMap, but the current usage
   // of this class (populate/write and then use/read) makes this
   // unecessary. If at a later date usage changes this should be
  @@ -24,29 +28,25 @@
   public class JettyResolver
     implements EntityResolver
   {
  -  protected Category _log;
  +  protected Logger   _log = Logger.getLogger(JettyResolver.class);
     protected HashMap  _map=new HashMap();
   
  -  public
  -    JettyResolver(Category log)
  -  {
  -    _log=log;
  -  }
  -
     public InputSource
       resolveEntity (String publicId, String systemId)
     {
  -    _log.info("resolving "+publicId+" : "+systemId);
  +    if (_log.isDebugEnabled())
  +      _log.debug("resolving "+publicId+" : "+systemId);
   
       URL url=(URL)_map.get(publicId);
   
       if (url==null)
       {
  -      _log.warn("WARNING: no resolution for "+publicId+" - are you using a 
supported JSDK version?");
  +      _log.warn("no resolution for "+publicId+" - are you using a supported JSDK 
version?");
       }
       else
       {
  -      _log.info("resolved "+publicId+" : "+url);
  +      if (_log.isDebugEnabled())
  +     _log.debug("resolved "+publicId+" : "+url);
         try
         {
        InputSource is=new InputSource(url.openConnection().getInputStream());
  
  
  
  1.15.2.4  +32 -33    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.15.2.3
  retrieving revision 1.15.2.4
  diff -u -r1.15.2.3 -r1.15.2.4
  --- JettyService.java 2 Dec 2001 02:08:53 -0000       1.15.2.3
  +++ JettyService.java 20 Mar 2002 20:58:31 -0000      1.15.2.4
  @@ -4,11 +4,15 @@
    * Distributable under GPL license.
    * See terms of license at gnu.org.
    */
  - 
  -// $Id: JettyService.java,v 1.15.2.3 2001/12/02 02:08:53 starksm Exp $
  +
  +// $Id: JettyService.java,v 1.15.2.4 2002/03/20 20:58:31 jules_gosnell Exp $
  +
  +//------------------------------------------------------------------------------
   
   package org.jboss.jetty;
   
  +//------------------------------------------------------------------------------
  +
   import java.io.File;
   import java.io.IOException;
   import java.io.InputStream;
  @@ -18,7 +22,6 @@
   import javax.management.MBeanRegistration;
   import javax.management.MBeanServer;
   import javax.management.ObjectName;
  -
   import org.jboss.deployment.DeploymentException;
   import org.jboss.util.ServiceMBeanSupport;
   import org.jboss.web.AbstractWebContainer.WebDescriptorParser;
  @@ -31,25 +34,21 @@
   import org.mortbay.util.Log;
   import org.mortbay.xml.XmlConfiguration;
   
  +//------------------------------------------------------------------------------
   /**
    *   A service to launch jetty from JMX.
  - *      
  + *
    *   @see <related>
    *   @author <a href="mailto:[EMAIL PROTECTED]";>Julian Gosnell</a>
  - *   @version $Revision: 1.15.2.3 $
  + *   @version $Revision: 1.15.2.4 $
    */
   
  -// 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";
  -  
  +
     JettyMBean   _mbean  = null;
     Jetty        _jetty  = null;
     MBeanServer  _server = null;
  @@ -71,18 +70,18 @@
     {
       name = getObjectName(server, name);
       _server = server;
  -    
  +
       return name;
     }
   
     //----------------------------------------------------------------------------
  -  
  +
     protected void
       ensureLogging()
     {
       // sort out a JBossLogSink for use by Jetty. This will bridge the
       // API between Jetty and Log4J...
  -    
  +
       JBossLogSink logSink = new JBossLogSink();
       try
       {
  @@ -96,25 +95,25 @@
       logSink.start();
       Log.instance().disableLog(); // remove default logger
       Log.instance().add(logSink);
  -    
  +
       // why doesn't this work? - investigate...
       //    _jetty.setLogSink(logSink);
  -    
  +
       log.info("connected JBoss and Jetty Log models");
     }
  -  
  +
     protected void
       ensureProperties()
       throws IOException
     {
       String props="jetty.properties";
       InputStream propertiesIn = 
getClass().getClassLoader().getResourceAsStream(props);
  -    
  +
       if (propertiesIn == null)
         throw new IOException("failed to load "+props);
  -    
  +
       System.getProperties().load(propertiesIn);
  -    
  +
       log.info("loaded properties from: "+props);
     }
   
  @@ -122,7 +121,7 @@
       ensureJetty()
     {
       // make a Jetty...
  -    Jetty tmp = new Jetty(log.getCategory()); // tmp - until we have initialised 
it...
  +    Jetty tmp = new Jetty(this); // tmp - until we have initialised it...
       tmp.setJettyHome(getJettyHome());
       tmp.setWebDefault(getWebDefault());
       tmp.setUnpackWars(getUnpackWars());
  @@ -166,7 +165,7 @@
       ensureJetty();
       ensureConfig();
     }
  -  
  +
     //----------------------------------------------------------------------------
     // 'name' interface
     //----------------------------------------------------------------------------
  @@ -177,7 +176,7 @@
     {
       return new ObjectName(OBJECT_NAME);
     }
  -  
  +
     public String
       getName()
     {
  @@ -200,7 +199,7 @@
       else
         log.warn("Jetty has already been initialised");
     }
  -  
  +
     protected boolean _started=false;
   
     public void
  @@ -216,7 +215,7 @@
       else
         log.warn("Jetty has already been started");
     }
  -   
  +
     public void
       stopService()
     {
  @@ -261,7 +260,7 @@
     {
       return _jetty.deploy(path, warUrl, parser);
     }
  -     
  +
     public void
       performUndeploy(String warUrl)
       throws DeploymentException
  @@ -276,25 +275,25 @@
     {
       return (_jetty!=null);
     }
  -  
  +
     protected boolean
       isStarted()
     {
       return (_jetty!=null && _started);
     }
  -  
  +
     protected boolean
       isStopped()
     {
       return (!_started);
     }
  -  
  +
     protected boolean
       isDestroyed()
     {
       return (_jetty==null);
     }
  -  
  +
     //----------------------------------------------------------------------------
   
     protected boolean _publishMBeans=false;
  @@ -338,7 +337,7 @@
     }
   
     //----------------------------------------------------------------------------
  -  
  +
     protected String _webDefault=null;
   
     public String
  @@ -362,7 +361,7 @@
     }
   
     //----------------------------------------------------------------------------
  -  
  +
     protected String _configuration=null;
   
     public String
  @@ -384,7 +383,7 @@
       else
         _configuration=configUrl;
     }
  -  
  +
     //----------------------------------------------------------------------------
   
     protected static String _jettyHome=null;
  
  
  

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

Reply via email to