tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r940338 - in /tomcat/trunk/java/org/apache/catalina: connector/Connector.java connector/CoyoteAdapter.java core/StandardService.java startup/Embedded.java
Date Sun, 02 May 2010 23:47:52 GMT
Author: markt
Date: Sun May  2 23:47:51 2010
New Revision: 940338

URL: http://svn.apache.org/viewvc?rev=940338&view=rev
Log:
Simplify the connector. Keep a reference to just the Service rather than the Service and the
Engine.

Modified:
    tomcat/trunk/java/org/apache/catalina/connector/Connector.java
    tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
    tomcat/trunk/java/org/apache/catalina/core/StandardService.java
    tomcat/trunk/java/org/apache/catalina/startup/Embedded.java

Modified: tomcat/trunk/java/org/apache/catalina/connector/Connector.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Connector.java?rev=940338&r1=940337&r2=940338&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Connector.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Connector.java Sun May  2 23:47:51 2010
@@ -25,7 +25,6 @@ import javax.management.MBeanServer;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
-import org.apache.catalina.Container;
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleState;
 import org.apache.catalina.Service;
@@ -99,12 +98,6 @@ public class Connector extends Lifecycle
 
 
     /**
-     * The Container used for processing requests received by this Connector.
-     */
-    protected Container container = null;
-
-
-    /**
      * The "enable DNS lookups" flag for this Connector.
      */
     protected boolean enableLookups = false;
@@ -330,7 +323,6 @@ public class Connector extends Lifecycle
     public void setService(Service service) {
 
         this.service = service;
-        // FIXME: setProperty("service", service);
 
     }
 
@@ -357,34 +349,7 @@ public class Connector extends Lifecycle
 
     }
 
-
-    /**
-     * Return the Container used for processing requests received by this
-     * Connector.
-     */
-    public Container getContainer() {
-        if( container==null ) {
-            // Lazy - maybe it was added later
-            findContainer();
-        }
-        return (container);
-
-    }
-
-
-    /**
-     * Set the Container used for processing requests received by this
-     * Connector.
-     *
-     * @param container The new Container to use
-     */
-    public void setContainer(Container container) {
-
-        this.container = container;
-
-    }
-
-
+    
     /**
      * Return the "enable DNS lookups" flag.
      */
@@ -1023,53 +988,16 @@ public class Connector extends Lifecycle
         }
     }
 
-    protected void findContainer() {
-        try {
-            // Register to the service
-            ObjectName parentName=new ObjectName( domain + ":" +
-                    "type=Service");
-
-            if(log.isDebugEnabled())
-                log.debug("Adding to " + parentName );
-            if( mserver.isRegistered(parentName )) {
-                mserver.invoke(parentName, "addConnector", new Object[] { this },
-                        new String[] {"org.apache.catalina.connector.Connector"});
-                // As a side effect we'll get the container field set
-                // Also initialize will be called
-                //return;
-            }
-            // XXX Go directly to the Engine
-            // initialize(); - is called by addConnector
-            ObjectName engName=new ObjectName( domain + ":" + "type=Engine");
-            if( mserver.isRegistered(engName )) {
-                Object obj=mserver.getAttribute(engName, "managedResource");
-                if(log.isDebugEnabled())
-                      log.debug("Found engine " + obj + " " + obj.getClass());
-                container=(Container)obj;
-
-                if(log.isDebugEnabled())
-                    log.debug("Initialized");
-                // As a side effect we'll get the container field set
-                // Also initialize will be called
-                return;
-            }
-        } catch( Exception ex ) {
-            log.error( "Error finding container " + ex);
-        }
-    }
 
     @Override
     protected void initInternal() throws LifecycleException {
 
-        if( container==null ) {
-            findContainer();
-        }
-        
         if (oname == null) {
             try {
                 // we are loaded directly, via API - and no name was given to us
                 // Engine name is used as domain name for MBeans
-                oname = createObjectName(container.getName(), "Connector");
+                oname = createObjectName(
+                        getService().getContainer().getName(), "Connector");
                 Registry.getRegistry(null, null)
                     .registerComponent(this, oname, null);
             } catch (Exception e) {

Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=940338&r1=940337&r2=940338&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Sun May  2 23:47:51
2010
@@ -209,7 +209,7 @@ public class CoyoteAdapter implements Ad
                 req.getRequestProcessor().setWorkerThreadName(Thread.currentThread().getName());
                 
                 // Calling the container
-                connector.getContainer().getPipeline().getFirst().event(request, response,
request.getEvent());
+                connector.getService().getContainer().getPipeline().getFirst().event(request,
response, request.getEvent());
 
                 if (!error && !response.isClosed() && (request.getAttribute(Globals.EXCEPTION_ATTR)
!= null)) {
                     // An unexpected exception occurred while processing the event, so
@@ -217,7 +217,7 @@ public class CoyoteAdapter implements Ad
                     request.getEvent().setEventType(CometEvent.EventType.ERROR);
                     request.getEvent().setEventSubType(null);
                     error = true;
-                    connector.getContainer().getPipeline().getFirst().event(request, response,
request.getEvent());
+                    connector.getService().getContainer().getPipeline().getFirst().event(request,
response, request.getEvent());
                 }
                 if (response.isClosed() || !request.isComet()) {
                     if (status==SocketStatus.OPEN) {
@@ -225,7 +225,7 @@ public class CoyoteAdapter implements Ad
                         request.getEvent().setEventType(CometEvent.EventType.END);
                         request.getEvent().setEventSubType(null);
                         error = true;
-                        connector.getContainer().getPipeline().getFirst().event(request,
response, request.getEvent());
+                        connector.getService().getContainer().getPipeline().getFirst().event(request,
response, request.getEvent());
                     }
                     res.action(ActionCode.ACTION_COMET_END, null);
                 } else if (!error && read && request.getAvailable()) {
@@ -234,7 +234,7 @@ public class CoyoteAdapter implements Ad
                     request.getEvent().setEventType(CometEvent.EventType.ERROR);
                     request.getEvent().setEventSubType(CometEvent.EventSubType.IOEXCEPTION);
                     error = true;
-                    connector.getContainer().getPipeline().getFirst().event(request, response,
request.getEvent());
+                    connector.getService().getContainer().getPipeline().getFirst().event(request,
response, request.getEvent());
                 }
                 return (!error);
             } catch (Throwable t) {
@@ -289,7 +289,7 @@ public class CoyoteAdapter implements Ad
                     // Calling the container
                     try {
                         impl.complete();
-                        connector.getContainer().getPipeline().getFirst().invoke(request,
response);
+                        connector.getService().getContainer().getPipeline().getFirst().invoke(request,
response);
                     } finally {
                         success = false;
                     }
@@ -305,10 +305,10 @@ public class CoyoteAdapter implements Ad
                 } else if (impl.getState()==AsyncContextImpl.AsyncState.ERROR_DISPATCHING)
{
                     async = false;
                     success = false;
-                    connector.getContainer().getPipeline().getFirst().invoke(request, response);
+                    connector.getService().getContainer().getPipeline().getFirst().invoke(request,
response);
                 } else {
                     try {
-                        connector.getContainer().getPipeline().getFirst().invoke(request,
response);
+                        connector.getService().getContainer().getPipeline().getFirst().invoke(request,
response);
                     } catch (RuntimeException x) {
                         impl.setErrorState(x);
                     }
@@ -406,9 +406,9 @@ public class CoyoteAdapter implements Ad
             req.getRequestProcessor().setWorkerThreadName(Thread.currentThread().getName());
             if (postParseRequest(req, request, res, response)) {
                 //check valves if we support async
-                request.setAsyncSupported(connector.getContainer().getPipeline().isAsyncSupported());
+                request.setAsyncSupported(connector.getService().getContainer().getPipeline().isAsyncSupported());
                 // Calling the container
-                connector.getContainer().getPipeline().getFirst().invoke(request, response);
+                connector.getService().getContainer().getPipeline().getFirst().invoke(request,
response);
 
                 if (request.isComet()) {
                     if (!response.isClosed() && !response.isError()) {

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardService.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardService.java?rev=940338&r1=940337&r2=940338&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardService.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardService.java Sun May  2 23:47:51 2010
@@ -143,10 +143,6 @@ public class StandardService extends Lif
                 // Ignore
             }
         }
-        synchronized (connectors) {
-            for (int i = 0; i < connectors.length; i++)
-                connectors[i].setContainer(this.container);
-        }
         if (getState().isAvailable() && (oldContainer != null)) {
             try {
                 oldContainer.stop();
@@ -236,7 +232,6 @@ public class StandardService extends Lif
     public void addConnector(Connector connector) {
 
         synchronized (connectors) {
-            connector.setContainer(this.container);
             connector.setService(this);
             Connector results[] = new Connector[connectors.length + 1];
             System.arraycopy(connectors, 0, results, 0, connectors.length);
@@ -314,7 +309,6 @@ public class StandardService extends Lif
                     log.error("Connector.stop", e);
                 }
             }
-            connectors[j].setContainer(null);
             connector.setService(null);
             int k = 0;
             Connector results[] = new Connector[connectors.length - 1];

Modified: tomcat/trunk/java/org/apache/catalina/startup/Embedded.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/Embedded.java?rev=940338&r1=940337&r2=940338&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/Embedded.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/Embedded.java Sun May  2 23:47:51 2010
@@ -655,7 +655,7 @@ public class Embedded  extends StandardS
         while (true) {
             int n = -1;
             for (int i = 0; i < connectors.length; i++) {
-                if (connectors[i].getContainer() == engine) {
+                if (connectors[i].getService().getContainer() == engine) {
                     n = i;
                     break;
                 }



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


Mime
View raw message