commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-commons-sandbox/hivemind build.xml
Date Thu, 16 Oct 2003 22:30:29 GMT
hlship      2003/10/16 15:30:29

  Modified:    hivemind/framework project.xml
               hivemind/framework/src/java/org/apache/commons/hivemind/test
                        HiveMindTestCase.java
               hivemind/framework/src/java/org/apache/commons/hivemind
                        HiveMindMessages.properties
               hivemind/xdocs services.xml navigation.xml case1.xml
  Added:       hivemind/framework/src/test/hivemind/test/servlet
                        MockServletContext.java MockFilterConfig.java
                        TestHiveMindFilter.java MockRequest.java
                        MockFilterChain.java MockResponse.java
               hivemind/xdocs filter.xml
               hivemind/framework/src/java/org/apache/commons/hivemind/servlet
                        package.html HiveMindFilter.java
               hivemind build.xml
  Log:
  Add a basic servlet filter to make it easier to use HiveMind in a servlet application.
  
  Revision  Changes    Path
  1.10      +6 -1      jakarta-commons-sandbox/hivemind/framework/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/framework/project.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- project.xml	9 Oct 2003 23:16:24 -0000	1.9
  +++ project.xml	16 Oct 2003 22:30:28 -0000	1.10
  @@ -64,6 +64,11 @@
         <url>http://xml.apache.org/xerces/</url>
       </dependency> 
       
  +    <dependency>
  +    	<id>servletapi</id>	
  +    	<version>2.3</version>
  +    </dependency>
  +    
   		<!-- For building the Ant tasks -->
   		
       <dependency>
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/framework/src/test/hivemind/test/servlet/MockServletContext.java
  
  Index: MockServletContext.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package hivemind.test.servlet;
  
  import java.io.InputStream;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.Enumeration;
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Set;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.Servlet;
  import javax.servlet.ServletContext;
  import javax.servlet.ServletException;
  
  /**
   * Mock implementation of ServletContext.
   *
   * @author Howard Lewis Ship
   * @version $Id: MockServletContext.java,v 1.1 2003/10/16 22:30:29 hlship Exp $
   */
  public class MockServletContext implements ServletContext
  {
  	private Map _attributes = new HashMap();
  
      public ServletContext getContext(String arg0)
      {
          return null;
      }
  
      public int getMajorVersion()
      {
          return 0;
      }
  
      public int getMinorVersion()
      {
          return 0;
      }
  
      public String getMimeType(String arg0)
      {
          return null;
      }
  
      public Set getResourcePaths(String arg0)
      {
          return null;
      }
  
      public URL getResource(String arg0) throws MalformedURLException
      {
          return null;
      }
  
      public InputStream getResourceAsStream(String arg0)
      {
          return null;
      }
  
      public RequestDispatcher getRequestDispatcher(String arg0)
      {
          return null;
      }
  
      public RequestDispatcher getNamedDispatcher(String arg0)
      {
          return null;
      }
  
      public Servlet getServlet(String arg0) throws ServletException
      {
          return null;
      }
  
      public Enumeration getServlets()
      {
          return null;
      }
  
      public Enumeration getServletNames()
      {
          return null;
      }
  
      public void log(String arg0)
      {
  
      }
  
      public void log(Exception arg0, String arg1)
      {
  
      }
  
      public void log(String arg0, Throwable arg1)
      {
  
      }
  
      public String getRealPath(String arg0)
      {
          return null;
      }
  
      public String getServerInfo()
      {
          return null;
      }
  
      public String getInitParameter(String arg0)
      {
          return null;
      }
  
      public Enumeration getInitParameterNames()
      {
          return null;
      }
  
      public Object getAttribute(String name)
      {
          return _attributes.get(name);
      }
  
      public Enumeration getAttributeNames()
      {
          return null;
      }
  
      public void setAttribute(String name, Object value)
      {
  		_attributes.put(name, value);
      }
  
      public void removeAttribute(String name)
      {
      	_attributes.remove(name);
  
      }
  
      public String getServletContextName()
      {
          return null;
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/framework/src/test/hivemind/test/servlet/MockFilterConfig.java
  
  Index: MockFilterConfig.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package hivemind.test.servlet;
  
  import java.util.Enumeration;
  
  import javax.servlet.FilterConfig;
  import javax.servlet.ServletContext;
  
  public class MockFilterConfig implements FilterConfig
  {
      private ServletContext _servletContext;
      public MockFilterConfig()
      {
      }
  
      public MockFilterConfig(ServletContext context)
      {
          _servletContext = context;
      }
  
      public String getFilterName()
      {
          return null;
      }
  
      public ServletContext getServletContext()
      {
          return _servletContext;
      }
  
      public String getInitParameter(String arg0)
      {
          return null;
      }
  
      public Enumeration getInitParameterNames()
      {
          return null;
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/framework/src/test/hivemind/test/servlet/TestHiveMindFilter.java
  
  Index: TestHiveMindFilter.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package hivemind.test.servlet;
  
  import javax.servlet.Filter;
  import javax.servlet.FilterConfig;
  import javax.servlet.ServletContext;
  import javax.servlet.http.HttpServletRequest;
  
  import org.apache.commons.hivemind.ApplicationRuntimeException;
  import org.apache.commons.hivemind.HiveMind;
  import org.apache.commons.hivemind.Registry;
  import org.apache.commons.hivemind.service.ThreadCleanupListener;
  import org.apache.commons.hivemind.service.ThreadEventNotifier;
  import org.apache.commons.hivemind.servlet.HiveMindFilter;
  import org.apache.commons.hivemind.test.HiveMindTestCase;
  
  public class TestHiveMindFilter extends HiveMindTestCase
  {
      private static class Listener implements ThreadCleanupListener
      {
          private boolean _cleanup;
  
          public void threadDidCleanup()
          {
              _cleanup = true;
          }
  
          public boolean getCleanup()
          {
              return _cleanup;
          }
  
      }
  
      public TestHiveMindFilter(String name)
      {
          super(name);
      }
  
      public void testBasic() throws Exception
      {
          ServletContext servletContext = new MockServletContext();
          FilterConfig filterConfig = new MockFilterConfig(servletContext);
  
          Filter f = new HiveMindFilter();
  
          f.init(filterConfig);
  
          Registry r = (Registry) servletContext.getAttribute(HiveMindFilter.CONTEXT_KEY);
  
          assertNotNull(r);
  
          ThreadEventNotifier t =
              (ThreadEventNotifier) r.getService(
                  HiveMind.THREAD_EVENT_NOTIFIER_SERVICE,
                  ThreadEventNotifier.class);
  
          Listener l = new Listener();
  
          t.addThreadCleanupListener(l);
  
          HttpServletRequest request = new MockRequest();
  
          f.doFilter(request, new MockResponse(), new MockFilterChain());
  
          assertSame(r, HiveMindFilter.getRegistry(request));
  
          assertEquals(true, l.getCleanup());
  
          f.destroy();
  
          try
          {
              t.addThreadCleanupListener(null);
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
              assertExceptionSubstring(ex, "The HiveMind Registry has been shutdown.");
          }
      }
  
      public void testExceptionInInit() throws Exception
      {
          Filter f = new HiveMindFilter();
  
          interceptLogging(HiveMindFilter.class.getName());
  
          f.init(null);
  
          // It's a NPE that gets thrown.
  
          assertLoggedMessage("null");
  
          f.doFilter(new MockRequest(), new MockResponse(), new MockFilterChain());
  
          f.destroy();
      }
  
      public void testDestroyWithoutRepository()
      {
          Filter f = new HiveMindFilter();
  
          f.destroy();
      }
  
      public void testFilterWithoutRepository() throws Exception
      {
          Filter f = new HiveMindFilter();
  
          f.doFilter(new MockRequest(), new MockResponse(), new MockFilterChain());
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/framework/src/test/hivemind/test/servlet/MockRequest.java
  
  Index: MockRequest.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package hivemind.test.servlet;
  
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.UnsupportedEncodingException;
  import java.security.Principal;
  import java.util.Enumeration;
  import java.util.HashMap;
  import java.util.Locale;
  import java.util.Map;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletInputStream;
  import javax.servlet.http.Cookie;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  
  /**
   * Mock implementation of HttpServletRequest.
   *
   * @author Howard Lewis Ship
   * @version $Id: MockRequest.java,v 1.1 2003/10/16 22:30:29 hlship Exp $
   */
  public class MockRequest implements HttpServletRequest
  {
      private Map _attributes = new HashMap();
  
      public String getAuthType()
      {
          return null;
      }
  
      public Cookie[] getCookies()
      {
          return null;
      }
  
      public long getDateHeader(String arg0)
      {
          return 0;
      }
  
      public String getHeader(String arg0)
      {
          return null;
      }
  
      public Enumeration getHeaders(String arg0)
      {
          return null;
      }
  
      public Enumeration getHeaderNames()
      {
          return null;
      }
  
      public int getIntHeader(String arg0)
      {
          return 0;
      }
  
      public String getMethod()
      {
          return null;
      }
  
      public String getPathInfo()
      {
          return null;
      }
  
      public String getPathTranslated()
      {
          return null;
      }
  
      public String getContextPath()
      {
          return null;
      }
  
      public String getQueryString()
      {
          return null;
      }
  
      public String getRemoteUser()
      {
          return null;
      }
  
      public boolean isUserInRole(String arg0)
      {
          return false;
      }
  
      public Principal getUserPrincipal()
      {
          return null;
      }
  
      public String getRequestedSessionId()
      {
          return null;
      }
  
      public String getRequestURI()
      {
          return null;
      }
  
      public StringBuffer getRequestURL()
      {
          return null;
      }
  
      public String getServletPath()
      {
          return null;
      }
  
      public HttpSession getSession(boolean arg0)
      {
          return null;
      }
  
      public HttpSession getSession()
      {
          return null;
      }
  
      public boolean isRequestedSessionIdValid()
      {
          return false;
      }
  
      public boolean isRequestedSessionIdFromCookie()
      {
          return false;
      }
  
      public boolean isRequestedSessionIdFromURL()
      {
          return false;
      }
  
      public boolean isRequestedSessionIdFromUrl()
      {
          return false;
      }
  
      public Object getAttribute(String name)
      {
          return _attributes.get(name);
      }
  
      public Enumeration getAttributeNames()
      {
          return null;
      }
  
      public String getCharacterEncoding()
      {
          return null;
      }
  
      public void setCharacterEncoding(String arg0) throws UnsupportedEncodingException
      {
  
      }
  
      public int getContentLength()
      {
          return 0;
      }
  
      public String getContentType()
      {
          return null;
      }
  
      public ServletInputStream getInputStream() throws IOException
      {
          return null;
      }
  
      public String getParameter(String arg0)
      {
          return null;
      }
  
      public Enumeration getParameterNames()
      {
          return null;
      }
  
      public String[] getParameterValues(String arg0)
      {
          return null;
      }
  
      public Map getParameterMap()
      {
          return null;
      }
  
      public String getProtocol()
      {
          return null;
      }
  
      public String getScheme()
      {
          return null;
      }
  
      public String getServerName()
      {
          return null;
      }
  
      public int getServerPort()
      {
          return 0;
      }
  
      public BufferedReader getReader() throws IOException
      {
          return null;
      }
  
      public String getRemoteAddr()
      {
          return null;
      }
  
      public String getRemoteHost()
      {
          return null;
      }
  
      public void setAttribute(String name, Object value)
      {
          _attributes.put(name, value);
      }
  
      public void removeAttribute(String name)
      {
          _attributes.remove(name);
      }
  
      public Locale getLocale()
      {
          return null;
      }
  
      public Enumeration getLocales()
      {
          return null;
      }
  
      public boolean isSecure()
      {
          return false;
      }
  
      public RequestDispatcher getRequestDispatcher(String arg0)
      {
          return null;
      }
  
      public String getRealPath(String arg0)
      {
          return null;
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/framework/src/test/hivemind/test/servlet/MockFilterChain.java
  
  Index: MockFilterChain.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package hivemind.test.servlet;
  
  import java.io.IOException;
  
  import javax.servlet.FilterChain;
  import javax.servlet.ServletException;
  import javax.servlet.ServletRequest;
  import javax.servlet.ServletResponse;
  
  /**
   * Mock/empty implementation of FilterChain.
   *
   * @author Howard Lewis Ship
   * @version $Id: MockFilterChain.java,v 1.1 2003/10/16 22:30:29 hlship Exp $
   */
  public class MockFilterChain implements FilterChain
  {
  
      public void doFilter(ServletRequest arg0, ServletResponse arg1)
          throws IOException, ServletException
      {
  
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/framework/src/test/hivemind/test/servlet/MockResponse.java
  
  Index: MockResponse.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package hivemind.test.servlet;
  
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.util.Locale;
  
  import javax.servlet.ServletOutputStream;
  import javax.servlet.http.Cookie;
  import javax.servlet.http.HttpServletResponse;
  
  public class MockResponse implements HttpServletResponse
  {
  
      public void addCookie(Cookie arg0)
      {
  
      }
  
      public boolean containsHeader(String arg0)
      {
          return false;
      }
  
      public String encodeURL(String arg0)
      {
          return null;
      }
  
      public String encodeRedirectURL(String arg0)
      {
          return null;
      }
  
      public String encodeUrl(String arg0)
      {
          return null;
      }
  
      public String encodeRedirectUrl(String arg0)
      {
          return null;
      }
  
      public void sendError(int arg0, String arg1) throws IOException
      {
  
      }
  
      public void sendError(int arg0) throws IOException
      {
  
      }
  
      public void sendRedirect(String arg0) throws IOException
      {
  
      }
  
      public void setDateHeader(String arg0, long arg1)
      {
  
      }
  
      public void addDateHeader(String arg0, long arg1)
      {
  
      }
  
      public void setHeader(String arg0, String arg1)
      {
  
      }
  
      public void addHeader(String arg0, String arg1)
      {
  
      }
  
      public void setIntHeader(String arg0, int arg1)
      {
  
      }
  
      public void addIntHeader(String arg0, int arg1)
      {
  
      }
  
      public void setStatus(int arg0)
      {
  
      }
  
      public void setStatus(int arg0, String arg1)
      {
  
      }
  
      public String getCharacterEncoding()
      {
          return null;
      }
  
      public ServletOutputStream getOutputStream() throws IOException
      {
          return null;
      }
  
      public PrintWriter getWriter() throws IOException
      {
          return null;
      }
  
      public void setContentLength(int arg0)
      {
  
      }
  
      public void setContentType(String arg0)
      {
  
      }
  
      public void setBufferSize(int arg0)
      {
  
      }
  
      public int getBufferSize()
      {
          return 0;
      }
  
      public void flushBuffer() throws IOException
      {
  
      }
  
      public void resetBuffer()
      {
  
      }
  
      public boolean isCommitted()
      {
          return false;
      }
  
      public void reset()
      {
  
      }
  
      public void setLocale(Locale arg0)
      {
  
      }
  
      public Locale getLocale()
      {
          return null;
      }
  
  }
  
  
  
  1.5       +2 -2      jakarta-commons-sandbox/hivemind/framework/src/java/org/apache/commons/hivemind/test/HiveMindTestCase.java
  
  Index: HiveMindTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/framework/src/java/org/apache/commons/hivemind/test/HiveMindTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- HiveMindTestCase.java	12 Oct 2003 10:13:56 -0000	1.4
  +++ HiveMindTestCase.java	16 Oct 2003 22:30:29 -0000	1.5
  @@ -279,7 +279,7 @@
           {
               LoggingEvent e = (LoggingEvent) events.get(i);
   
  -            String eventMessage = e.getMessage().toString();
  +            String eventMessage = String.valueOf(e.getMessage());
   
               if (eventMessage.indexOf(message) >= 0)
                   return;
  
  
  
  1.7       +8 -2      jakarta-commons-sandbox/hivemind/framework/src/java/org/apache/commons/hivemind/HiveMindMessages.properties
  
  Index: HiveMindMessages.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/framework/src/java/org/apache/commons/hivemind/HiveMindMessages.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- HiveMindMessages.properties	14 Oct 2003 15:33:18 -0000	1.6
  +++ HiveMindMessages.properties	16 Oct 2003 22:30:29 -0000	1.7
  @@ -140,4 +140,10 @@
   NameLookup.no-object=Lookup of ''{0}'' resulted in null (expected instance of {1}).
   NameLookup.wrong-type=JNDI object ''{0}'' ({1}) is not assignable to {2}.
   
  -BaseEJBProxy.result-not-usable=Remote stub {0} from home interface ''{1}'' ({2}) does not implement the EJB remote interface {3}.
  \ No newline at end of file
  +BaseEJBProxy.result-not-usable=Remote stub {0} from home interface ''{1}'' ({2}) does not implement the EJB remote interface {3}.
  +
  +# servlet
  +
  +HiveMindFilter.init=Constructing HiveMind Registry.
  +HiveMindFilter.cleanup-error=Unable to cleanup current thread: {0}
  +
  
  
  
  1.31      +4 -30     jakarta-commons-sandbox/hivemind/xdocs/services.xml
  
  Index: services.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/services.xml,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- services.xml	9 Oct 2003 22:58:16 -0000	1.30
  +++ services.xml	16 Oct 2003 22:30:29 -0000	1.31
  @@ -370,35 +370,9 @@
   </p>
   
   <p>
  -For example, a servlet application may want to add the following:	
  -</p>
  -
  -<source>
  -public void service(ServletRequest request, ServletResponse response)
  -throws ServletException, IOException
  -{
  -  try
  -  {
  -    super.service(request, response);
  -  }
  -  finally
  -  {
  -    getThreadEventNotifier().fireThreadCleanup(); 
  -  } 
  -}
  -	
  -</source>
  -
  -<p>
  -You'll, of course, have to fill in the details, such as the implementation of
  -<code>getThreadEventNotifier()</code>. Presumably, your servlet constructs
  -a HiveMind registry from its <code>init()</code> method.
  -</p>
  -
  -<p>
  -Another option is to implement the above logic inside a servlet filter (if Servlet API 2.3 is
  -available). This option will make it easier to apply the thread logic to multiple servlets
  -within a single application.	
  +HiveMind includes a <a href="filter.html">servlet filter</a>	to take care creating the
  +Registry and managing
  +the ThreadEventNotifier.
   </p>
   		
   			
  
  
  
  1.24      +2 -1      jakarta-commons-sandbox/hivemind/xdocs/navigation.xml
  
  Index: navigation.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/navigation.xml,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- navigation.xml	9 Oct 2003 22:58:16 -0000	1.23
  +++ navigation.xml	16 Oct 2003 22:30:29 -0000	1.24
  @@ -27,6 +27,7 @@
   			<item name="Multi-Threading" href="/multithreading.html"/>
   			<item name="Creating New Interceptors" href="/interceptors.html"/>
   			<item name="Overriding Services" href="/override.html"/>
  +			<item name="Servlets" href="/filter.html"/>
   			<item name="Case Study #1: Application Startup/Shutdown"
   				href="case1.html"/>
   		</menu>
  
  
  
  1.11      +55 -55    jakarta-commons-sandbox/hivemind/xdocs/case1.xml
  
  Index: case1.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/case1.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- case1.xml	10 Oct 2003 19:25:41 -0000	1.10
  +++ case1.xml	16 Oct 2003 22:30:29 -0000	1.11
  @@ -17,33 +17,33 @@
   This case study is based on work done for my current employer, who has not (yet)
   given approval to mention the project by name. The package names and module
   ids have been changed, and some minor changes and simplifications have been made.
  -The actual name of the product has been disguised as <em>Oubliette</em>.
  +The actual name of the product has been disguised as <em>Panorama</em>.
   </blockquote>
   
   	
   <p>
  -The Oubliette product is a fairly large J2EE web application deployed into BEA WebLogic.  Oubliette consists
  +The Panorama product is a fairly large J2EE web application deployed into BEA WebLogic.  Panorama consists
   of well over six thousand classes, divided into a large number of tools and services.
  -Oubliette has been a production project for several years, long before HiveMind was available. 
  -HiveMind's introduction into Oubliette (on something of a trial basis) was to cleanup the startup
  +Panorama has been a production project for several years, long before HiveMind was available. 
  +HiveMind's introduction into Panorama (on something of a trial basis) was to cleanup the startup
   and shutdown process for the application.
   </p>	
   
   <p>
  -Oubliette runs inside BEA WebLogic as an enterprise application; however, it is still logically a 
  +Panorama runs inside BEA WebLogic as an enterprise application; however, it is still logically a 
   number of subsystems, many of which require some form of startup or shutdown logic.  For example,
  -the Oubliette Help service caches help data stored in the database; the Oubliette Mail tool sets up
  +the Panorama Help service caches help data stored in the database; the Panorama Mail tool sets up
   periodic database cleanup jobs.  All told, there are over 40 startup tasks, and a handful of shutdown
   tasks.
   </p>
   
   <p>
   Prior to HiveMind, a single EJB was the focus of all this startup and shutdown activity.
  -A small WebLogic startup class would invoke the EJB, and the EJB would invoke static methods
  +A small WebLogic startup class would invoke the EJB, and the EJB implementation would invoke static methods
   on many other classes (some of which would lookup other EJBs and invoke methods on them).  
   This approach had grown quite unwieldy, especially in light of efforts
  -to improve and modularize the Oubliette build process.	HiveMind was brought in to rationalize
  -this aspect of Oubliette, with the goal being to make the fewest possible changes
  +to improve and modularize the Panorama build process.	HiveMind was brought in to rationalize
  +this aspect of Panorama, with the goal being to make the fewest possible changes
   to existing code.
   </p>
   
  @@ -64,28 +64,28 @@
   
   <p>
   The overall approach is to provide HiveMind module deployment descriptors for the various
  -tools and services of Oubliette; each module  contributes tasks to a Startup or Shutdown configuration point.
  +tools and services of Panorama; each module  contributes tasks to a Startup or Shutdown configuration point.
   </p>
   
   <p>
   A WebLogic shutdown class is still used and the original EJB still exists to allow an orderly shutdown.	
  -Ultimatelconfigurationy, this is required due to class loader issues; the EJB will have visibility to the HiveMind library,
  +Ultimately, this is required due to class loader issues; the EJB will have visibility to the HiveMind library,
   but the startup class may not.
   </p>
   
   </section>
   
  -<section name="Module oubliette.framework.startup">
  +<section name="Module panorama.framework.startup">
   
   <p>
  -The <code>oubliette.framework.startup</code> ("initialization and shutdown") module
  +The <code>panorama.framework.startup</code> ("initialization and shutdown") module
   contains the services and configuration points for startup and shutdown.  It also contains
   Java classes corresponding to task contributions.
   </p>	
   	
   <source><![CDATA[<?xml version="1.0"?>
  -<module id="oubliette.framework.startup" version="1.0.0">
  -	<description>Module for startup and shutdown code within Oubliette.</description>
  +<module id="panorama.framework.startup" version="1.0.0">
  +	<description>Module for startup and shutdown code within Panorama.</description>
   	
   	<configuration-point id="Startup">
   		<description>Defines startup tasks.</description>
  @@ -110,7 +110,7 @@
   				</attribute>
   				<rules>
   					<create-object
  -						class="com.oubliette.framework.startup.service.Task"
  +						class="com.panorama.framework.startup.service.Task"
   						/>
   					<read-attribute attribute="order" property="order"
   						translator="int"/>
  @@ -133,7 +133,7 @@
   					</attribute>
   					<rules>
   						<create-object
  -							class="com.oubliette.framework.startup.service.StaticTask"
  +							class="com.panorama.framework.startup.service.StaticTask"
   							/>
   						<read-attribute attribute="class" property="className"/>
   						<read-attribute attribute="method" property="methodName"
  @@ -152,13 +152,13 @@
   	
   	<contribution configuration-id="Startup">
   		<task title="Python" order="50"
  -			class="com.oubliette.framework.startup.common.PythonStartup"/>
  +			class="com.panorama.framework.startup.common.PythonStartup"/>
   	</contribution>
   	
   	<contribution configuration-id="Shutdown">		
   		<task title="Update Status" order="100">
   			<invoke-static
  -				class="com.oubliette.framework.startup.common.OublietteStatus"
  +				class="com.panorama.framework.startup.common.PanoramaStatus"
   				method="shutdown"/>
   		</task>
   	</contribution>
  @@ -166,7 +166,7 @@
   	<service-point id="Startup" interface="java.lang.Runnable">
   		<invoke-factory service-id="hivemind.BuilderFactory">
   			<construct
  -				class="com.oubliette.framework.startup.service.TaskExecutor"
  +				class="com.panorama.framework.startup.service.TaskExecutor"
   				log-property="log"
   				messages-property="messages">
   				<set-configuration property="tasks" configuration-id="Startup"/>
  @@ -179,7 +179,7 @@
   	<service-point id="Shutdown" interface="java.lang.Runnable">
   		<invoke-factory service-id="hivemind.BuilderFactory">
   			<construct
  -				class="com.oubliette.framework.startup.service.TaskExecutor"
  +				class="com.panorama.framework.startup.service.TaskExecutor"
   				log-property="log"
   				messages-property="messages">
   				<set-configuration property="tasks" configuration-id="Shutdown"/>
  @@ -227,7 +227,7 @@
   The task to execute is specified in one of three ways:
   <ul>
   <li>As a Java class implementing the
  -	 <code>com.oubliette.framework.startup.service.Executable</code> interface (using the <code>class</code> attribute)</li>
  +	 <code>com.panorama.framework.startup.service.Executable</code> interface (using the <code>class</code> attribute)</li>
   <li>As a HiveMind service, implementing the service (using the <code>service-id</code> attribute)</li>
   <li>As a public static method of a class (using the enclosed <code>&lt;invoke-static&gt;</code> element)</li>
   </ul>
  @@ -236,7 +236,7 @@
   <p>
   The <code>Executable</code> interface is similar to the <code>java.lang.Runnable</code> interface:
   <source>
  -package com.oubliette.framework.startup.service;
  +package com.panorama.framework.startup.service;
   
   /**
    * Variation of <code>java.lang.Runnable</code> that allows for
  @@ -272,15 +272,15 @@
   </p>	
   
   <source>
  -package com.oubliette.framework.startup.service;
  +package com.panorama.framework.startup.service;
   
   import org.apache.commons.hivemind.Orderable;
   
   /**
  - * Configuration element for the <code>oubliette.framework.startup.Startup</code> or
  - * <code>oubliette.framework.startup.Shutdown</code>
  + * Configuration element for the <code>panorama.framework.startup.Startup</code> or
  + * <code>panorama.framework.startup.Shutdown</code>
    * configuration points.  Each element has a title,
  - * an {@link com.oubliette.framework.startup.service.Executable}
  + * an {@link com.panorama.framework.startup.service.Executable}
    * object, and an order
    * (used to sort the Startup items into an order of execution).
    */
  @@ -345,7 +345,7 @@
   </p>
   	
   <source><![CDATA[
  -package com.oubliette.framework.startup.service;
  +package com.panorama.framework.startup.service;
   
   import java.util.List;
   
  @@ -354,7 +354,7 @@
   import org.apache.commons.logging.Log;
   
   /**
  - * Implementation for the <code>oubliette.framework.startup.Startup</code> 
  + * Implementation for the <code>panorama.framework.startup.Startup</code> 
    * and <code>Shutdown</code> services.
    * Reads the corresponding configuration, sorts the elements,
    * and executes each. 
  @@ -482,7 +482,7 @@
   </p>
   
   <source>
  -package com.oubliette.framework.startup.service;
  +package com.panorama.framework.startup.service;
   
   import java.lang.reflect.InvocationTargetException;
   import java.lang.reflect.Method;
  @@ -493,7 +493,7 @@
   
   /**
    * Implementation of
  - * {@link com.oubliette.framework.startup.service.Executable}
  + * {@link com.panorama.framework.startup.service.Executable}
    * that Invokes a static method on a public class.
    */
   public class StaticTask extends BaseLocatable implements Executable
  @@ -578,17 +578,17 @@
   
   <p>
   Other modules, in their HiveMind module deployment descriptors, make contributions
  -into the Startup and Shutdown configuration points of the <code>oubliette.framework.startup</code>
  +into the Startup and Shutdown configuration points of the <code>panorama.framework.startup</code>
   module.  For example:
   
   <source><![CDATA[
   <?xml version="1.0"?>
  -<module id="oubliette.coreservice.mail" version="1.0.0">
  +<module id="panorama.coreservice.mail" version="1.0.0">
   		
  -	<configuration point-id="oubliette.framework.startup.Startup">
  +	<configuration point-id="panorama.framework.startup.Startup">
   
   		<task title="Mail" order="2600" 
  -			class="com.oubliette.coreservice.mail.startup.MailStartup"/>	
  +			class="com.panorama.coreservice.mail.startup.MailStartup"/>	
   	  
   	</configuration>
   	
  @@ -601,13 +601,13 @@
   Other modules take advantage of the &lt;invoke-static&gt; element:
   
   <source><![CDATA[<?xml version="1.0"?>
  -<module id="oubliette.coreservice.garbagecollection" version="1.0.0">
  +<module id="panorama.coreservice.garbagecollection" version="1.0.0">
   	
  -	<configuration point-id="oubliette.framework.startup.Startup">
  +	<configuration point-id="panorama.framework.startup.Startup">
   		
   		<task title="Scheduling Garbage Collection" order="3900">
   			<invoke-static
  -				class="com.oubliette.coreservice.garbagecollection.startup.GarbageCollectionStartup"
  +				class="com.panorama.coreservice.garbagecollection.startup.GarbageCollectionStartup"
   				/>
   		</task>
   			
  @@ -631,7 +631,7 @@
       {
           LOG.info("*** Bootstrapping HiveMind Registry ***");
   
  -        if (OublietteRuntime.getHiveMindRegistry() != null)
  +        if (PanoramaRuntime.getHiveMindRegistry() != null)
           {
               LOG.info(
                   "Registry is already initialized (the application appears to have been redeployed).");
  @@ -648,19 +648,19 @@
   
                Registry registry = builder.constructRegistry(Locale.getDefault());
   
  -             OublietteRuntime.setHiveMindRegistry(registry);
  +             PanoramaRuntime.setHiveMindRegistry(registry);
   
                Runnable startup =
  -                 (Runnable)registry.getService("oubliette.framework.startup.Startup", Runnable.class);
  +                 (Runnable)registry.getService("panorama.framework.startup.Startup", Runnable.class);
   
  -             LOG.info("*** Executing oubliette.framework.startup.Startup service ***");
  +             LOG.info("*** Executing panorama.framework.startup.Startup service ***");
   
                startup.run();
            }
            catch (Exception ex)
            {
                LOG.error(
  -                 "Unable to execute oubliette.framework.startup.Startup service: " + ex.getMessage());
  +                 "Unable to execute panorama.framework.startup.Startup service: " + ex.getMessage());
            }
        }
   ]]></source>
  @@ -680,13 +680,13 @@
   We take advantage of a WebLogic extension to know when the application server is being shut down.
   
   <source>
  -package com.oubliette.framework.startup;
  +package com.panorama.framework.startup;
   
   import javax.naming.InitialContext;
   import javax.rmi.PortableRemoteObject;
   
  -import com.oubliette.framework.startup.ejb.Shutdown;
  -import com.oubliette.framework.startup.ejb.ShutdownHome;
  +import com.panorama.framework.startup.ejb.Shutdown;
  +import com.panorama.framework.startup.ejb.ShutdownHome;
   
   /**
    * Shutdown class called by the WebLogic container.
  @@ -694,7 +694,7 @@
   public class Shutdown
   {
       private final static String EJB_JNDI_NAME =
  -        "com.oubliette.framework.startup.ejb.initshutHome";
  +        "com.panorama.framework.startup.ejb.initshutHome";
   
       /** Prevent instantiation */
       private Shutdown()
  @@ -725,7 +725,7 @@
   <p>
   The implementation of the initshut EJB is similarily straight-forward:
   <source><![CDATA[
  -package com.oubliette.framework.startup.ejb;
  +package com.panorama.framework.startup.ejb;
   
   import java.rmi.RemoteException;
   
  @@ -736,7 +736,7 @@
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  -import com.oubliette.framework.ejb.BaseSessionBean;
  +import com.panorama.framework.ejb.BaseSessionBean;
   
   /**
    * Handles shutdown logic.
  @@ -752,16 +752,16 @@
       }
   
       /**
  -     * Called by J2EE Container shutdown class for Oubliette shutdown processing.
  +     * Called by J2EE Container shutdown class for Panorama shutdown processing.
        * 
        * <p>
  -     * Gets the <code>oubliette.framework.startup.Shutdown</code> service and executes it.
  +     * Gets the <code>panorama.framework.startup.Shutdown</code> service and executes it.
        * 
        */
       
       public void shutdown() throws RemoteException
       {
  -        Registry registry = OublietteRuntime.getHiveMindRegistry();
  +        Registry registry = PanoramaRuntime.getHiveMindRegistry();
   
           if (registry == null)
           {
  @@ -771,11 +771,11 @@
           }
   
           Runnable r =
  -            (Runnable)registry.getService("oubliette.framework.startup.Shutdown", Runnable.class);
  +            (Runnable)registry.getService("panorama.framework.startup.Shutdown", Runnable.class);
   
           r.run();
   
  -        LOG.info("**** Oubliette shutdown complete ****");
  +        LOG.info("**** Panorama shutdown complete ****");
       }
   }]]>
   </source>	
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/xdocs/filter.xml
  
  Index: filter.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- $Id: filter.xml,v 1.1 2003/10/16 22:30:29 hlship Exp $ -->
  <!DOCTYPE document [
  	<!ENTITY % common-links SYSTEM "../common/links.xml">
  	%common-links;
  	]>
  <document>
  	<properties>
  		<title>HiveMind Servlet Filter</title>
  		<author email="hlship@apache.org">Howard M. Lewis Ship</author>
  	</properties>
  	<body>
  
  <section name="Introduction">
  
  <p>
  HiveMind includes a feature to streamline the use of HiveMind within a web application: a
  <a href="http://developer.java.sun.com/developer/EJTechTips/2002/tt0813.html#tip1">servlet filter</a>
  that can automatically construct the HiveMind Registry and ensure that
  end-of-request thread cleanup occurs.
  </p>
  
  <p>
  The filter class is <a href="&apiroot;/servlet/HiveMindFilter.html">HiveMindFilter</a>. It constructs
  a standard HiveMind Registry when initialized, and will shutdown the Registry when the containing
  application is undeployed.
  </p>
  
  <p>
  Each request will be terminated with a call to the
  <a href="&apiroot;/service/ThreadEventNotifier.html">ThreadEventNotifier</a>'s <code>fireThreadCleanup()</code>
  method, which will cleanup any thread-local values, including service implementations that are bound to the
  current thread.
  </p>
  
  <p>
  The HiveMindFilter class includes a static method for accessing the Registry.	
  </p>
  
  </section>
  
  <section name="Deployment Descriptor">
  	
  <p>
  To make use of the filter, it must be declared inside the web deployment descriptor (web.xml). Filters
  can be attached to servlets, or URL patterns, or both.  Here's an example:
  </p>
  
  <source><![CDATA[
  <filter>
    <filter-name>HiveMindFilter</filter-name>
    <filter-class>org.apache.commons.hivemind.servlet.HiveMindFilter</filter-class>
  </filter>
  
  <servlet>
    <servlet-name>MyServlet</servlet-name>
    <servlet-class>myco.servlets.MyServlet</servlet-class>
  </servlet>
  
  <filter-mapping>
    <filter-name>HiveMindFilter</filter-name>
    <servlet-name>MyServlet</servlet-name>
  </filter-mapping>
  ]]>
  	
  </source>
  	
  </section>
  </body>
  </document>
  
  
  1.1                  jakarta-commons-sandbox/hivemind/framework/src/java/org/apache/commons/hivemind/servlet/package.html
  
  Index: package.html
  ===================================================================
  <!-- $Id: package.html,v 1.1 2003/10/16 22:30:29 hlship Exp $ -->
  
  <body>
  
  Classes to support use of HiveMind within servlet applications.
  
  </body>
  
  
  1.1                  jakarta-commons-sandbox/hivemind/framework/src/java/org/apache/commons/hivemind/servlet/HiveMindFilter.java
  
  Index: HiveMindFilter.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.hivemind.servlet;
  
  import java.io.IOException;
  import java.util.Locale;
  
  import javax.servlet.Filter;
  import javax.servlet.FilterChain;
  import javax.servlet.FilterConfig;
  import javax.servlet.ServletException;
  import javax.servlet.ServletRequest;
  import javax.servlet.ServletResponse;
  import javax.servlet.http.HttpServletRequest;
  
  import org.apache.commons.hivemind.ClassResolver;
  import org.apache.commons.hivemind.HiveMind;
  import org.apache.commons.hivemind.Registry;
  import org.apache.commons.hivemind.impl.DefaultClassResolver;
  import org.apache.commons.hivemind.impl.RegistryBuilder;
  import org.apache.commons.hivemind.service.ThreadEventNotifier;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /**
   * Servlet filter that constructs the Registry at startup. It ensures that each request is
   * properly terminated with a call to
   * {@link org.apache.commons.hivemind.service.ThreadEventNotifier#fireThreadCleanup()}.
   * It also makes the Registry available during the request by
   * storing it as a request attribute.
   *
   * @author Howard Lewis Ship
   * @version $Id: HiveMindFilter.java,v 1.1 2003/10/16 22:30:29 hlship Exp $
   */
  public class HiveMindFilter implements Filter
  {
      private static final Log LOG = LogFactory.getLog(HiveMindFilter.class);
  
      /**
       * ServletContext attribute key that stores the Registry.
       */
      public static final String CONTEXT_KEY = "org.apache.commons.hivemind.DefaultRegistry";
  
      /**
       * Request attribute key that stores the Registry.
       */
  
      public static final String REQUEST_KEY = "org.apache.commons.hivemind.RequestRegistry";
  
      private Registry _registry;
      private ThreadEventNotifier _notifier;
  
      /**
       * Constructs a {@link Registry} and stores it into the
       * <code>ServletContext</code>. Any exception throws is logged.
       */
      public void init(FilterConfig config) throws ServletException
      {
          LOG.info(HiveMind.getMessage("HiveMindFilter.init"));
  
          try
          {
              ClassResolver resolver = new DefaultClassResolver();
              RegistryBuilder builder = new RegistryBuilder();
  
              builder.processModules(resolver);
  
              _registry = builder.constructRegistry(getRegistryLocale());
              _notifier =
                  (ThreadEventNotifier) _registry.getService(
                      HiveMind.THREAD_EVENT_NOTIFIER_SERVICE,
                      ThreadEventNotifier.class);
  
              config.getServletContext().setAttribute(CONTEXT_KEY, _registry);
          }
          catch (Exception ex)
          {
              LOG.error(ex.getMessage(), ex);
          }
      }
  
      /**
       * Returns the default Locale.  Subclasses may override to select a particular
       * locale for the Registry.
       */
      protected Locale getRegistryLocale()
      {
          return Locale.getDefault();
      }
  
      /**
       * Passes the request to the filter chain, but then invokes
       * {@link ThreadEventNotifier#fireThreadCleanup()} (from a finally block).
       */
      public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
          throws IOException, ServletException
      {
          try
          {
              request.setAttribute(REQUEST_KEY, _registry);
  
              chain.doFilter(request, response);
          }
          finally
          {
              cleanupThread();
          }
  
      }
  
  	/**
  	 * Cleanup the thread, ignoring any exceptions that may be thrown.
  	 */
      private void cleanupThread()
      {
          try
          {
              if (_notifier != null)
                  _notifier.fireThreadCleanup();
          }
          catch (Exception ex)
          {
              LOG.error(HiveMind.format("HiveMindFilter.cleanup-error", ex.getMessage(), ex));
          }
      }
  
      /**
       * Invokes {@link Registry#shutdown()}.
       */
      public void destroy()
      {
          if (_registry != null)
              _registry.shutdown();
      }
  
  	/**
  	 * Returns the {@link Registry} that was stored as a request attribute
  	 * in {@link #doFilter(ServletRequest, ServletResponse, FilterChain)}.
  	 */
      public static Registry getRegistry(HttpServletRequest request)
      {
          return (Registry) request.getAttribute(REQUEST_KEY);
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <!--build.xml generated by maven from project.xml version 1.0-alpha-3
    on date October 16 2003, time 1121-->
  
  <project default="jar" name="commons-hivemind" basedir=".">
    <property name="defaulttargetdir" value="target">
    </property>
    <property name="libdir" value="target/lib">
    </property>
    <property name="classesdir" value="target/classes">
    </property>
    <property name="testclassesdir" value="target/test-classes">
    </property>
    <property name="testreportdir" value="target/test-reports">
    </property>
    <property name="distdir" value="dist">
    </property>
    <property name="javadocdir" value="dist/docs/api">
    </property>
    <property name="final.name" value="commons-hivemind-1.0-alpha-3">
    </property>
    <target name="init" description="o Initializes some properties">
      <mkdir dir="${libdir}">
      </mkdir>
      <condition property="noget">
        <equals arg2="only" arg1="${build.sysclasspath}">
        </equals>
      </condition>
    </target>
    <target name="compile" description="o Compile the code" depends="get-deps">
      <mkdir dir="${classesdir}">
      </mkdir>
      <javac destdir="${classesdir}" deprecation="true" debug="true" optimize="false" excludes="**/package.html">
        <src>
          <pathelement location="C:\workspace\hivemind\framework\src\java">
          </pathelement>
        </src>
        <classpath>
          <fileset dir="${libdir}">
            <include name="*.jar">
            </include>
          </fileset>
        </classpath>
      </javac>
      <copy todir="${classesdir}">
        <fileset dir="C:\workspace\hivemind\framework\src\java">
          <include name="**/*.xsd">
          </include>
          <include name="**/*.properties">
          </include>
        </fileset>
      </copy>
      <copy todir="${classesdir}">
        <fileset dir="C:\workspace\hivemind\framework\src\descriptor">
        </fileset>
      </copy>
      <copy todir="${testclassesdir}">
        <fileset dir="C:\workspace\hivemind\framework\src\test">
          <include name="**/*.xml">
          </include>
          <include name="**/*.properties">
          </include>
          <include name="**/*.png">
          </include>
        </fileset>
      </copy>
      <copy todir="${testclassesdir}">
        <fileset dir="C:\workspace\hivemind\framework\src\conf">
          <include name="*.properties">
          </include>
        </fileset>
      </copy>
    </target>
    <target name="jar" description="o Create the jar" depends="compile,test">
      <jar jarfile="target/${final.name}.jar" excludes="**/package.html" basedir="${classesdir}">
      </jar>
    </target>
    <target name="clean" description="o Clean up the generated directories">
      <delete dir="${defaulttargetdir}">
      </delete>
      <delete dir="${distdir}">
      </delete>
    </target>
    <target name="dist" description="o Create a distribution" depends="jar, javadoc">
      <mkdir dir="dist">
      </mkdir>
      <copy todir="dist">
        <fileset dir="${defaulttargetdir}" includes="*.jar">
        </fileset>
        <fileset dir="${basedir}" includes="LICENSE*, README*">
        </fileset>
      </copy>
    </target>
    <target name="test" description="o Run the test cases" if="test.failure" depends="internal-test">
      <fail message="There were test failures.">
      </fail>
    </target>
    <target name="internal-test" depends="compile-tests">
      <mkdir dir="${testreportdir}">
      </mkdir>
      <junit dir="./" failureproperty="test.failure" printSummary="yes" fork="true" haltonerror="true">
        <sysproperty key="basedir" value=".">
        </sysproperty>
        <formatter type="xml">
        </formatter>
        <formatter usefile="false" type="plain">
        </formatter>
        <classpath>
          <fileset dir="${libdir}">
            <include name="*.jar">
            </include>
          </fileset>
          <pathelement path="${testclassesdir}">
          </pathelement>
          <pathelement path="${classesdir}">
          </pathelement>
        </classpath>
        <batchtest todir="${testreportdir}">
          <fileset dir="C:\workspace\hivemind\framework\src\test">
            <include name="**/Test*.java">
            </include>
          </fileset>
        </batchtest>
      </junit>
    </target>
    <target name="compile-tests" depends="compile">
      <mkdir dir="${testclassesdir}">
      </mkdir>
      <javac destdir="${testclassesdir}" deprecation="true" debug="true" optimize="false" excludes="**/package.html">
        <src>
          <pathelement location="C:\workspace\hivemind\framework\src\test">
          </pathelement>
        </src>
        <classpath>
          <fileset dir="${libdir}">
            <include name="*.jar">
            </include>
          </fileset>
          <pathelement path="${classesdir}">
          </pathelement>
        </classpath>
      </javac>
    </target>
    <target name="javadoc" description="o Generate javadoc" depends="jar">
      <mkdir dir="${javadocdir}">
      </mkdir>
      <tstamp>
        <format pattern="2003-yyyy" property="year">
        </format>
      </tstamp>
      <property name="copyright" value="Copyright &amp;copy; 2003 Apache Software Foundation. All Rights Reserved.">
      </property>
      <property name="title" value="HiveMind Framework 1.0-alpha-3 API">
      </property>
      <javadoc bottom="Copyright &amp;copy; 2003 Apache Software Foundation. All Rights Reserved." windowtitle="HiveMind Framework 1.0-alpha-3 API" use="true" private="true" destdir="${javadocdir}" author="true" doctitle="HiveMind Framework 1.0-alpha-3 API" version="true" sourcepath="C:\workspace\hivemind\framework\src\java" packagenames="org.apache.commons.hivemind.*">
        <classpath>
          <fileset dir="${libdir}">
            <include name="*.jar">
            </include>
          </fileset>
          <pathelement location="target/${final.name}.jar">
          </pathelement>
        </classpath>
      </javadoc>
    </target>
    <target name="get-deps" unless="noget" depends="init">
      <get dest="${libdir}/commons-logging-1.0.3.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/commons-logging/jars/commons-logging-1.0.3.jar">
      </get>
      <get dest="${libdir}/commons-lang-2.0.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/commons-lang/jars/commons-lang-2.0.jar">
      </get>
      <get dest="${libdir}/commons-beanutils-1.6.1.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/commons-beanutils/jars/commons-beanutils-1.6.1.jar">
      </get>
      <get dest="${libdir}/javassist-2.6.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/jboss/jars/javassist-2.6.jar">
      </get>
      <get dest="${libdir}/xml-apis-1.0.b2.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xml-apis/jars/xml-apis-1.0.b2.jar">
      </get>
      <get dest="${libdir}/ant-1.5.1.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/ant/jars/ant-1.5.1.jar">
      </get>
      <get dest="${libdir}/xerces-2.2.1.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xerces/jars/xerces-2.2.1.jar">
      </get>
      <get dest="${libdir}/commons-collections-2.1.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/commons-collections/jars/commons-collections-2.1.jar">
      </get>
      <get dest="${libdir}/oro-2.0.6.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/oro/jars/oro-2.0.6.jar">
      </get>
      <get dest="${libdir}/junit-3.8.1.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/junit/jars/junit-3.8.1.jar">
      </get>
      <get dest="${libdir}/log4j-1.2.7.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/log4j/jars/log4j-1.2.7.jar">
      </get>
      <get dest="${libdir}/saxon-6.5.2.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/saxon/jars/saxon-6.5.2.jar">
      </get>
      <get dest="${libdir}/junit-3.8.1.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/junit/jars/junit-3.8.1.jar">
      </get>
      <get dest="${libdir}/ant-1.5.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/ant/jars/ant-1.5.jar">
      </get>
      <get dest="${libdir}/ant-optional-1.5.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/ant/jars/ant-optional-1.5.jar">
      </get>
    </target>
    <target name="install-maven">
      <get dest="${user.home}/maven-install-latest.jar" usetimestamp="true" src="${repo}/maven/maven-install-latest.jar">
      </get>
      <unjar dest="${maven.home}" src="${user.home}/maven-install-latest.jar">
      </unjar>
    </target>
  </project>
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message