You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wadi-commits@incubator.apache.org by bd...@apache.org on 2005/12/15 16:14:47 UTC

svn commit: r357037 - in /incubator/wadi/trunk/modules/tomcat55: pom.xml src/main/java/org/codehaus/wadi/tomcat55/TomcatManager.java

Author: bdudney
Date: Thu Dec 15 08:14:42 2005
New Revision: 357037

URL: http://svn.apache.org/viewcvs?rev=357037&view=rev
Log:
simplify configuration...

Modified:
    incubator/wadi/trunk/modules/tomcat55/pom.xml
    incubator/wadi/trunk/modules/tomcat55/src/main/java/org/codehaus/wadi/tomcat55/TomcatManager.java

Modified: incubator/wadi/trunk/modules/tomcat55/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/tomcat55/pom.xml?rev=357037&r1=357036&r2=357037&view=diff
==============================================================================
--- incubator/wadi/trunk/modules/tomcat55/pom.xml (original)
+++ incubator/wadi/trunk/modules/tomcat55/pom.xml Thu Dec 15 08:14:42 2005
@@ -27,6 +27,16 @@
         </dependency>
 
         <dependency>
+          <groupId>org.springframework</groupId>
+          <artifactId>spring</artifactId>
+        </dependency>
+
+        <dependency>
+          <groupId>mx4j</groupId>
+          <artifactId>mx4j</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>wadi</groupId>
             <artifactId>wadi-core</artifactId>
             <scope>provided</scope>

Modified: incubator/wadi/trunk/modules/tomcat55/src/main/java/org/codehaus/wadi/tomcat55/TomcatManager.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/tomcat55/src/main/java/org/codehaus/wadi/tomcat55/TomcatManager.java?rev=357037&r1=357036&r2=357037&view=diff
==============================================================================
--- incubator/wadi/trunk/modules/tomcat55/src/main/java/org/codehaus/wadi/tomcat55/TomcatManager.java (original)
+++ incubator/wadi/trunk/modules/tomcat55/src/main/java/org/codehaus/wadi/tomcat55/TomcatManager.java Thu Dec 15 08:14:42 2005
@@ -19,15 +19,12 @@
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.regex.Pattern;
-
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpSessionAttributeListener;
 import javax.servlet.http.HttpSessionListener;
-
 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
 import org.apache.catalina.Lifecycle;
@@ -43,269 +40,265 @@
 import org.apache.commons.logging.LogFactory;
 import org.codehaus.wadi.ManagerConfig;
 import org.codehaus.wadi.impl.Filter;
-import org.codehaus.wadi.impl.SpringManagerFactory;
 import org.codehaus.wadi.impl.StandardManager;
-import org.codehaus.wadi.impl.StandardSessionWrapperFactory;
-import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class TomcatManager implements ManagerConfig, Lifecycle, Manager
-{
-  protected static final Log _log = LogFactory.getLog(TomcatManager.class);
-
-  protected StandardManager _wadi;
-  protected Container _container;
-  protected boolean _distributable;
-  protected int _sessionCounter; // push back into WADI - TODO
-  protected int _maxActive; // exactly what does this mean ? - probably only valid for some Evicter types... - TODO
-  protected int _expiredSessions; // TODO - wire up
-  protected int _rejectedSessions; // TODO - wire up
-  protected PropertyChangeSupport _propertyChangeListeners=new PropertyChangeSupport(this); 	// actual notifications are done by aspects...
-
-  // org.codehaus.wadi.ManagerConfig
-
-  public ServletContext getServletContext() {
-    return ((Context)_container).getServletContext();
-  }
-
-  public void callback(StandardManager manager) {
-    // install Listeners ...
-    Context context=((Context)_container);
-
-    Object[] sessionListeners=context.getApplicationLifecycleListeners();
-    List sll=new ArrayList();
-    for (int i=0; i<sessionListeners.length; i++) {
-      Object listener=sessionListeners[i];
-      if (listener instanceof HttpSessionListener)
-	sll.add((HttpSessionListener)listener);
-    }
-    manager.setSessionListeners((HttpSessionListener[])sll.toArray(new HttpSessionListener[sll.size()]));
-
-    Object[] attributeListeners=context.getApplicationEventListeners();
-    List all=new ArrayList();
-    for (int i=0; i<attributeListeners.length; i++) {
-      Object listener=attributeListeners[i];
-      if (listener instanceof HttpSessionAttributeListener)
-	all.add((HttpSessionAttributeListener)listener);
-    }
-    manager.setAttributelisteners((HttpSessionAttributeListener[])all.toArray(new HttpSessionAttributeListener[all.size()]));
-  }
-
-  // org.apache.catalina.Lifecycle
-
-  // actual notifications are done by aspects...
-  protected LifecycleSupport _lifecycleListeners=new LifecycleSupport(this);
-
-  public void addLifecycleListener(LifecycleListener listener) {
-    _lifecycleListeners.addLifecycleListener(listener);
-  }
-
-  public LifecycleListener[] findLifecycleListeners() {
-    return _lifecycleListeners.findLifecycleListeners();
-  }
-
-  public void removeLifecycleListener(LifecycleListener listener) {
-    _lifecycleListeners.removeLifecycleListener(listener);
-  }
-
-  public void start() throws LifecycleException {
-	  try {
-          String resources[] = {"/org/codehaus/wadi/tomcat55/tomcat55Config.xml",
-                                "/org/codehaus/wadi/impl/wadiConfig.xml"};
-          ApplicationContext ctx = new ClassPathXmlApplicationContext(resources);
-          _wadi = (StandardManager)ctx.getBean("SessionManager");
-		  //_wadi=(StandardManager)SpringManagerFactory.create(is, "SessionManager", 
-          //      new TomcatSessionFactory(), new StandardSessionWrapperFactory());
-	  } catch (Exception e) {
-		  throw new RuntimeException("Required resource: '/WEB-INF/wadi-web.xml' not found - please check the web app.", e);
-	  }
-	  
-	  _wadi.init(this);
-	  try {
-		  _wadi.start();
-		  
-		  if (_container==null) {
-			  _log.warn("container not set - fn-ality will be limited");
-		  } else {
-			  Context context=((Context)_container);
-			  
-			  // install Valve
-			  ((StandardContext)context).addValve(new Valve(Pattern.compile("127\\.0\\.0\\.1|192\\.168\\.0\\.\\d{1,3}")));
-			  
-			  // install filter
-			  String filterName="WadiFilter";
-			  FilterDef fd=new FilterDef();
-			  fd.setFilterName(filterName);
-			  fd.setFilterClass(Filter.class.getName());
-			  context.addFilterDef(fd);
-			  FilterMap fm=new FilterMap();
-			  fm.setFilterName(filterName);
-			  fm.setURLPattern("/*");
-			  context.addFilterMap(fm);
-			  
-			  //				// is this a distributable webapp ?
-			  //				boolean distributable=context.getDistributable();
-			  //				if (distributable && !_distributable)
-			  //				setDistributable(distributable);
-		  }
-		  
-	  } catch (Exception e) {
-		  throw new LifecycleException(e);
-	  }
-  }
-
-  public void stop() throws LifecycleException {
-    try {
-      _wadi.stop();
-    } catch (Exception e) {
-      throw new LifecycleException(e);
-    }
-  }
-
-  // org.apache.catalina.Manager
-
-  public Container getContainer() {
-    return _container;
-  }
-
-  public void setContainer(Container container) {
-    _container=container;
-  }
-
-  public boolean getDistributable() {
-    return _distributable;
-  }
-
-  public void setDistributable(boolean distributable) { // TODO - reconcile with WADI's idea of this setting...
-    _distributable=distributable;
-  }
-
-  public String getInfo() {
-    return "<code>&lt;"+getClass().getName()+"&gt;/&lt;1.0b&gt;</code>";
-  }
-
-  public int getMaxInactiveInterval() {
-    return _wadi.getMaxInactiveInterval();
-  }
-
-  public void setMaxInactiveInterval(int interval) {
-    _wadi.setMaxInactiveInterval(interval);
-  }
-
-  public int getSessionIdLength() {
-    return _wadi.getSessionIdFactory().getSessionIdLength();
-  }
-
-  public void setSessionIdLength(int sessionIdLength) {
-    _wadi.getSessionIdFactory().setSessionIdLength(sessionIdLength);
-  }
-
-  public int getSessionCounter() {
-    return _sessionCounter;
-  }
-
-  public void setSessionCounter(int sessionCounter) {
-    _sessionCounter=sessionCounter;
-  }
-
-  public int getMaxActive() {
-    return _maxActive;
-  }
-
-  public void setMaxActive(int maxActive) {
-    _maxActive=maxActive;
-  }
-
-  public int getActiveSessions() {
-    // probably the size of the Memory map... - TODO
-    return 0;
-  }
-
-  public int getExpiredSessions() {
-    return _expiredSessions;
-  }
-
-  public void setExpiredSessions(int expiredSessions) {
-    _expiredSessions=expiredSessions;
-  }
-
-  public int getRejectedSessions() {
-    return _rejectedSessions;
-  }
-
-  public void setRejectedSessions(int rejectedSessions) {
-    _rejectedSessions=rejectedSessions;
-  }
-
-  public int getSessionMaxAliveTime() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  public void setSessionMaxAliveTime(int arg0) {
-    // TODO Auto-generated method stub
-
-  }
-
-  public int getSessionAverageAliveTime() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  public void setSessionAverageAliveTime(int arg0) {
-    // TODO Auto-generated method stub
-
-  }
-
-  public void add(Session session) {
-    // perhaps hook up to an Immoter ? - TODO
-  }
-
-  public void addPropertyChangeListener(PropertyChangeListener listener) {
-    _propertyChangeListeners.addPropertyChangeListener(listener);
-  }
-
-  public Session createEmptySession() {
-    throw new UnsupportedOperationException();
-  }
-
-  public Session createSession() {
-    return (TomcatSession)_wadi.create();
-  }
-
-  public Session createSession(String arg0) {
-      if (_log.isInfoEnabled()) _log.info("createSession("+arg0+")");
-      return (TomcatSession)_wadi.create();
-  }
-
-  public Session findSession(String id) throws IOException {
-	  //throw new UnsupportedOperationException();
-	  if (_log.isWarnEnabled()) _log.warn("findSession("+id+") called - currently unsupported");
-	  return null;
-  }
-
-  public Session[] findSessions() {
-    throw new UnsupportedOperationException();
-  }
-
-  public void load() throws ClassNotFoundException, IOException {
-    // perhaps hook up to promoteToLocal();
-  }
-
-  public void remove(Session session) {
-    // perhaps hook up to an Emoter - TODO
-  }
-
-  public void removePropertyChangeListener(PropertyChangeListener listener) {
-    _propertyChangeListeners.removePropertyChangeListener(listener);
-  }
-
-  public void unload() throws IOException {
-    // perhaps hook up to demoteToShared();
-  }
-
-  public void backgroundProcess() {
-    // not used - Evicter is attached to a Timer by super()...
-  }
+public class TomcatManager implements ManagerConfig, Lifecycle, Manager {
+    protected static final Log _log = LogFactory.getLog(TomcatManager.class);
+    protected StandardManager _wadi;
+    protected Container _container;
+    protected boolean _distributable;
+    protected int _sessionCounter; // push back into WADI - TODO
+    protected int _maxActive; // exactly what does this mean ? - probably only
+                                // valid for some Evicter types... - TODO
+    protected int _expiredSessions; // TODO - wire up
+    protected int _rejectedSessions; // TODO - wire up
+    protected PropertyChangeSupport _propertyChangeListeners = new PropertyChangeSupport(
+            this); // actual notifications are done by aspects...
+
+    // org.codehaus.wadi.ManagerConfig
+    public ServletContext getServletContext() {
+        return ((Context) _container).getServletContext();
+    }
+
+    public void callback(StandardManager manager) {
+        // install Listeners ...
+        Context context = ((Context) _container);
+        Object[] sessionListeners = context.getApplicationLifecycleListeners();
+        List sll = new ArrayList();
+        for (int i = 0; i < sessionListeners.length; i++) {
+            Object listener = sessionListeners[i];
+            if (listener instanceof HttpSessionListener)
+                sll.add((HttpSessionListener) listener);
+        }
+        manager.setSessionListeners((HttpSessionListener[]) sll
+                .toArray(new HttpSessionListener[sll.size()]));
+        Object[] attributeListeners = context.getApplicationEventListeners();
+        List all = new ArrayList();
+        for (int i = 0; i < attributeListeners.length; i++) {
+            Object listener = attributeListeners[i];
+            if (listener instanceof HttpSessionAttributeListener)
+                all.add((HttpSessionAttributeListener) listener);
+        }
+        manager.setAttributelisteners((HttpSessionAttributeListener[]) all
+                .toArray(new HttpSessionAttributeListener[all.size()]));
+    }
+
+    // org.apache.catalina.Lifecycle
+    // actual notifications are done by aspects...
+    protected LifecycleSupport _lifecycleListeners = new LifecycleSupport(this);
+
+    public void addLifecycleListener(LifecycleListener listener) {
+        _lifecycleListeners.addLifecycleListener(listener);
+    }
+
+    public LifecycleListener[] findLifecycleListeners() {
+        return _lifecycleListeners.findLifecycleListeners();
+    }
+
+    public void removeLifecycleListener(LifecycleListener listener) {
+        _lifecycleListeners.removeLifecycleListener(listener);
+    }
+
+    public void start() throws LifecycleException {
+        try {
+            String resources[] = {
+                    "org/codehaus/wadi/tomcat55/tomcat55Config.xml",
+                    "org/codehaus/wadi/impl/wadiConfig.xml" };
+            ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
+                    resources, false);
+            // have to set the class loader because 
+            ctx.setClassLoader(getClass().getClassLoader());
+            ctx.refresh();
+            _wadi = (StandardManager) ctx.getBean("SessionManager");
+        } catch (Exception e) {
+            throw new RuntimeException(
+                    "Required resource: '/WEB-INF/wadi-web.xml' not found - please check the web app.",
+                    e);
+        }
+        _wadi.init(this);
+        try {
+            _wadi.start();
+            if (_container == null) {
+                _log.warn("container not set - fn-ality will be limited");
+            } else {
+                Context context = ((Context) _container);
+                // install Valve
+                ((StandardContext) context).addValve(new Valve(Pattern
+                        .compile("127\\.0\\.0\\.1|192\\.168\\.0\\.\\d{1,3}")));
+                // install filter
+                String filterName = "WadiFilter";
+                FilterDef fd = new FilterDef();
+                fd.setFilterName(filterName);
+                fd.setFilterClass(Filter.class.getName());
+                context.addFilterDef(fd);
+                FilterMap fm = new FilterMap();
+                fm.setFilterName(filterName);
+                fm.setURLPattern("/*");
+                context.addFilterMap(fm);
+                // // is this a distributable webapp ?
+                // boolean distributable=context.getDistributable();
+                // if (distributable && !_distributable)
+                // setDistributable(distributable);
+            }
+        } catch (Exception e) {
+            throw new LifecycleException(e);
+        }
+    }
+
+    public void stop() throws LifecycleException {
+        try {
+            _wadi.stop();
+        } catch (Exception e) {
+            throw new LifecycleException(e);
+        }
+    }
+
+    // org.apache.catalina.Manager
+    public Container getContainer() {
+        return _container;
+    }
+
+    public void setContainer(Container container) {
+        _container = container;
+    }
+
+    public boolean getDistributable() {
+        return _distributable;
+    }
+
+    public void setDistributable(boolean distributable) { // TODO - reconcile
+                                                            // with WADI's idea
+                                                            // of this
+                                                            // setting...
+        _distributable = distributable;
+    }
+
+    public String getInfo() {
+        return "<code>&lt;" + getClass().getName() + "&gt;/&lt;1.0b&gt;</code>";
+    }
+
+    public int getMaxInactiveInterval() {
+        return _wadi.getMaxInactiveInterval();
+    }
+
+    public void setMaxInactiveInterval(int interval) {
+        _wadi.setMaxInactiveInterval(interval);
+    }
+
+    public int getSessionIdLength() {
+        return _wadi.getSessionIdFactory().getSessionIdLength();
+    }
+
+    public void setSessionIdLength(int sessionIdLength) {
+        _wadi.getSessionIdFactory().setSessionIdLength(sessionIdLength);
+    }
+
+    public int getSessionCounter() {
+        return _sessionCounter;
+    }
+
+    public void setSessionCounter(int sessionCounter) {
+        _sessionCounter = sessionCounter;
+    }
+
+    public int getMaxActive() {
+        return _maxActive;
+    }
+
+    public void setMaxActive(int maxActive) {
+        _maxActive = maxActive;
+    }
 
+    public int getActiveSessions() {
+        // probably the size of the Memory map... - TODO
+        return 0;
+    }
+
+    public int getExpiredSessions() {
+        return _expiredSessions;
+    }
+
+    public void setExpiredSessions(int expiredSessions) {
+        _expiredSessions = expiredSessions;
+    }
+
+    public int getRejectedSessions() {
+        return _rejectedSessions;
+    }
+
+    public void setRejectedSessions(int rejectedSessions) {
+        _rejectedSessions = rejectedSessions;
+    }
+
+    public int getSessionMaxAliveTime() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public void setSessionMaxAliveTime(int arg0) {
+        // TODO Auto-generated method stub
+    }
+
+    public int getSessionAverageAliveTime() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public void setSessionAverageAliveTime(int arg0) {
+        // TODO Auto-generated method stub
+    }
+
+    public void add(Session session) {
+        // perhaps hook up to an Immoter ? - TODO
+    }
+
+    public void addPropertyChangeListener(PropertyChangeListener listener) {
+        _propertyChangeListeners.addPropertyChangeListener(listener);
+    }
+
+    public Session createEmptySession() {
+        throw new UnsupportedOperationException();
+    }
+
+    public Session createSession() {
+        return (TomcatSession) _wadi.create();
+    }
+
+    public Session createSession(String arg0) {
+        if (_log.isInfoEnabled())
+            _log.info("createSession(" + arg0 + ")");
+        return (TomcatSession) _wadi.create();
+    }
+
+    public Session findSession(String id) throws IOException {
+        // throw new UnsupportedOperationException();
+        if (_log.isWarnEnabled())
+            _log.warn("findSession(" + id + ") called - currently unsupported");
+        return null;
+    }
+
+    public Session[] findSessions() {
+        throw new UnsupportedOperationException();
+    }
+
+    public void load() throws ClassNotFoundException, IOException {
+        // perhaps hook up to promoteToLocal();
+    }
+
+    public void remove(Session session) {
+        // perhaps hook up to an Emoter - TODO
+    }
+
+    public void removePropertyChangeListener(PropertyChangeListener listener) {
+        _propertyChangeListeners.removePropertyChangeListener(listener);
+    }
+
+    public void unload() throws IOException {
+        // perhaps hook up to demoteToShared();
+    }
+
+    public void backgroundProcess() {
+        // not used - Evicter is attached to a Timer by super()...
+    }
 }