cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r583577 - in /incubator/cxf/branches/2.0.x-fixes: ./ integration/jca/src/main/java/org/apache/cxf/jca/cxf/ integration/jca/src/main/java/org/apache/cxf/jca/servant/ integration/jca/src/test/java/org/apache/cxf/jca/servant/ rt/transports/htt...
Date Wed, 10 Oct 2007 19:02:41 GMT
Author: dkulp
Date: Wed Oct 10 12:02:40 2007
New Revision: 583577

URL: http://svn.apache.org/viewvc?rev=583577&view=rev
Log:
Merged revisions 583087 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r583087 | ningjiang | 2007-10-09 05:29:43 -0400 (Tue, 09 Oct 2007) | 1 line
  
  CXF-1093 applied patch of delegating the thread pool request to the WorkManager , thanks
Jeff. Also fixed a typo in the jaxws ClientServerTest
........

Added:
    incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/CXFWorkAdapter.java
      - copied unchanged from r583087, incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/cxf/CXFWorkAdapter.java
    incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/WorkManagerThreadPool.java
      - copied unchanged from r583087, incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/cxf/WorkManagerThreadPool.java
    incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/servant/EJBEndpointTest.java
      - copied unchanged from r583087, incubator/cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/servant/EJBEndpointTest.java
Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/JCABusFactory.java
    incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/servant/EJBEndpoint.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/JCABusFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/JCABusFactory.java?rev=583577&r1=583576&r2=583577&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/JCABusFactory.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/JCABusFactory.java
Wed Oct 10 12:02:40 2007
@@ -30,6 +30,9 @@
 import java.util.logging.Logger;
 
 import javax.resource.ResourceException;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkManager;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
@@ -54,6 +57,7 @@
     private ClassLoader appserverClassLoader;
     private ManagedConnectionFactoryImpl mcf;
     private Object raBootstrapContext;
+    
 
     public JCABusFactory(ManagedConnectionFactoryImpl aMcf) {
         this.mcf = aMcf;
@@ -102,7 +106,7 @@
     protected void initializeServants() throws ResourceException {
         if (isMonitorEJBServicePropertiesEnabled()) {            
             LOG.info("Ejb service properties auto-detect enabled. ");
-            startPropertiesMonitorThread();
+            startPropertiesMonitorWorker();
         } else {            
             URL propsUrl = mcf.getEJBServicePropertiesURLInstance();
             if (propsUrl != null) {
@@ -124,6 +128,7 @@
                 EJBServantConfig config = new EJBServantConfig(theJNDIName, value);
                 EJBEndpoint ejbEndpoint = new EJBEndpoint(config);
                 ejbEndpoint.setEjbServantBaseURL(mcf.getEJBServantBaseURL());
+                ejbEndpoint.setWorkManager(getWorkManager());
                 Server servant = ejbEndpoint.publish();
                 
                 synchronized (servantsCache) {
@@ -140,16 +145,20 @@
     }
     
 
-    private void startPropertiesMonitorThread() throws ResourceException {
+    private void startPropertiesMonitorWorker() throws ResourceException {
         Integer pollIntervalInteger = mcf.getEJBServicePropertiesPollInterval();
         int pollInterval = pollIntervalInteger.intValue();
         
         LOG.info("Ejb service properties poll interval is: [" + pollInterval + " seconds]");
         
-        EJBServicePropertiesMonitorRunnable r = new EJBServicePropertiesMonitorRunnable(pollInterval);
-        Thread t = new Thread(r);
-        t.setDaemon(true);
-        t.start();
+        EJBServicePropertiesMonitorWorker worker = new EJBServicePropertiesMonitorWorker(pollInterval);
+        if (getWorkManager() != null) {
+            getWorkManager().startWork(worker, CXFWorkAdapter.DEFAULT_START_TIME_OUT, null,
worker);
+        } else {
+            Thread t = new Thread(worker);
+            t.setDaemon(true);
+            t.start();
+        }
     }
 
     private boolean isMonitorEJBServicePropertiesEnabled() throws ResourceException {
@@ -239,13 +248,15 @@
         init();
     }
     
-    private class EJBServicePropertiesMonitorRunnable implements Runnable {
+    private class EJBServicePropertiesMonitorWorker extends CXFWorkAdapter implements Work
{
         private long previousModificationTime;
         private final int pollIntervalSeconds;
         private final File propsFile;
-        private boolean continuing = true;
+        
+        //The release() method will be called on separate thread while the run() is processing.
+        private volatile boolean continuing = true;
 
-        EJBServicePropertiesMonitorRunnable(int pollInterval) throws ResourceException {
+        EJBServicePropertiesMonitorWorker(int pollInterval) throws ResourceException {
             pollIntervalSeconds = pollInterval;
             propsFile = new File(mcf.getEJBServicePropertiesURLInstance().getPath());
         }
@@ -268,6 +279,10 @@
                 }
             } while (continuing);
         }
+        
+        public void release() {
+            this.continuing = false;
+        }
 
         protected boolean isPropertiesFileModified() {
             boolean fileModified = false;
@@ -285,6 +300,14 @@
     // for unit test
     protected void setBootstrapContext(Object ctx) {
         raBootstrapContext = ctx;
+    }
+
+    public WorkManager getWorkManager() {
+        if (getBootstrapContext() instanceof BootstrapContext) {
+            BootstrapContext context = (BootstrapContext)getBootstrapContext();
+            return context.getWorkManager();
+        }
+        return null;
     }
     
     

Modified: incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/servant/EJBEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/servant/EJBEndpoint.java?rev=583577&r1=583576&r2=583577&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/servant/EJBEndpoint.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/servant/EJBEndpoint.java
Wed Oct 10 12:02:40 2007
@@ -21,19 +21,28 @@
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.logging.Logger;
 
 import javax.ejb.EJBHome;
 import javax.jws.WebService;
 import javax.naming.Context;
 import javax.naming.InitialContext;
+import javax.resource.spi.work.WorkManager;
 import javax.rmi.PortableRemoteObject;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.jca.cxf.WorkManagerThreadPool;
+import org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine;
+import org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory;
+import org.mortbay.jetty.AbstractConnector;
+import org.mortbay.jetty.nio.SelectChannelConnector;
 
 
 public class EJBEndpoint {
@@ -48,6 +57,8 @@
     
     private String ejbServantBaseURL;
     
+    private WorkManager workManager;
+    
     public EJBEndpoint(EJBServantConfig ejbConfig) {
         this.config = ejbConfig;
     }
@@ -72,9 +83,33 @@
                                                                : getDefaultEJBServantBaseURL();
         String address = baseAddress + "/" + config.getJNDIName();
         factory.setAddress(address);
+        if (getWorkManager() != null) {
+            setWorkManagerThreadPoolToJetty(factory.getBus(), baseAddress);
+        }
         
+        Server server = factory.create();
         LOG.info("Published EJB Endpoint of [" + config.getJNDIName() + "] at [" + address
+ "]");
-        return factory.create();
+        
+        return server;
+    }
+    
+    
+    protected void setWorkManagerThreadPoolToJetty(Bus bus, String baseAddress) {
+        JettyHTTPServerEngineFactory engineFactory = bus.getExtension(JettyHTTPServerEngineFactory.class);
+        int port = getAddressPort(baseAddress);
+        if (engineFactory.retrieveJettyHTTPServerEngine(port) != null) {
+            return;
+        }
+        JettyHTTPServerEngine engine = new JettyHTTPServerEngine();
+        AbstractConnector connector = new SelectChannelConnector();
+        connector.setPort(port);
+        connector.setThreadPool(new WorkManagerThreadPool(getWorkManager()));
+        engine.setConnector(connector);
+        engine.setPort(port);
+        
+        List<JettyHTTPServerEngine> engineList = new ArrayList<JettyHTTPServerEngine>();
+        engineList.add(engine);
+        engineFactory.setEnginesList(engineList);
     }
     
     public String getServiceClassName() throws Exception {
@@ -95,6 +130,18 @@
         return "http://" + hostName + ":9999";
     }
     
+    public int getAddressPort(String address) {
+        int index = address.lastIndexOf(":");
+        int end = address.lastIndexOf("/");
+        if (index == 4) {
+            return 80;
+        }
+        if (end < index) {
+            return new Integer(address.substring(index + 1)).intValue();
+        } 
+        return new Integer(address.substring(index + 1, end)).intValue();
+    }
+    
     private static boolean isJaxWsServiceInterface(Class<?> cls) {
         if (cls == null) {
             return false;
@@ -119,5 +166,15 @@
         }
         return false;
     }
+
+    public WorkManager getWorkManager() {
+        return workManager;
+    }
+
+    public void setWorkManager(WorkManager workManager) {
+        this.workManager = workManager;
+    }
+    
+    
     
 }

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java?rev=583577&r1=583576&r2=583577&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
Wed Oct 10 12:02:40 2007
@@ -166,7 +166,7 @@
      */
     public void shutdown() {
         if (shouldDestroyPort()) {
-            if (servantCount == 0) {
+            if (factory != null && servantCount == 0) {
                 factory.destroyForPort(port);
             } else {
                 LOG.log(Level.WARNING, "FAILED_TO_SHOWDOWN_ENGINE_MSG", port);

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java?rev=583577&r1=583576&r2=583577&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
Wed Oct 10 12:02:40 2007
@@ -144,7 +144,7 @@
      * This call retrieves a previously configured JettyHTTPServerEngine for the
      * given port. If none exists, this call returns null.
      */
-    protected synchronized JettyHTTPServerEngine retrieveJettyHTTPServerEngine(int port)
{
+    public synchronized JettyHTTPServerEngine retrieveJettyHTTPServerEngine(int port) {
         return portMap.get(port);
     }
 

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java?rev=583577&r1=583576&r2=583577&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
Wed Oct 10 12:02:40 2007
@@ -85,7 +85,7 @@
                                              "SoapPort");
     
     private final QName fakePortName = new QName("http://apache.org/hello_world_soap_http",
-                                                 "FackPort");
+                                                 "FakePort");
     
     
     private final QName portName1  = new QName("http://apache.org/hello_world_soap_http",



Mime
View raw message