[jboss-svn-commits] JBL Code SVN: r30960 - in labs/jbossesb/branches/JBESB_4_7_CP/product: rosetta/src/org/jboss/internal/soa/esb/dependencies and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jan 6 13:21:27 EST 2010
Author: kevin.conner at jboss.com
Date: 2010-01-06 13:21:27 -0500 (Wed, 06 Jan 2010)
New Revision: 30960
Added:
labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/client/ESBInVMTransport.java
labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/server/ESBInVMServerTransport.java
Modified:
labs/jbossesb/branches/JBESB_4_7_CP/product/install/registry-jboss-service-jbossas5.xml
labs/jbossesb/branches/JBESB_4_7_CP/product/install/registry-jboss-service.xml
labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIService.java
labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIServiceMBean.java
labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/client/JuddiInVMTransport.java
labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/server/JuddiInVMServerTransport.java
Log:
Support multiple invm juddi nodes: JBESB-3079
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/install/registry-jboss-service-jbossas5.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/install/registry-jboss-service-jbossas5.xml 2010-01-06 17:35:42 UTC (rev 30959)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/install/registry-jboss-service-jbossas5.xml 2010-01-06 18:21:27 UTC (rev 30960)
@@ -11,7 +11,6 @@
</value-factory>
</attribute>
<attribute name="PropertiesFileDir">${jboss.server.data.dir}</attribute>
- <attribute name="NodeName">default</attribute>
<attribute name="NumThreads">20</attribute>
<attribute name="Timeout">20</attribute>
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/install/registry-jboss-service.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/install/registry-jboss-service.xml 2010-01-06 17:35:42 UTC (rev 30959)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/install/registry-jboss-service.xml 2010-01-06 18:21:27 UTC (rev 30960)
@@ -4,7 +4,6 @@
<mbean code="org.jboss.internal.soa.esb.dependencies.JuddiRMIService" name="jboss.esb:service=JuddiRMI" description="Juddi RMI Service">
<attribute name="PropertiesResourceFile">esb.juddi.xml</attribute>
<attribute name="PropertiesFileDir">${jboss.server.data.dir}</attribute>
- <attribute name="NodeName">default</attribute>
<attribute name="NumThreads">20</attribute>
<attribute name="Timeout">20</attribute>
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIService.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIService.java 2010-01-06 17:35:42 UTC (rev 30959)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIService.java 2010-01-06 18:21:27 UTC (rev 30960)
@@ -32,7 +32,7 @@
import java.net.URL;
import org.apache.log4j.Logger;
-import org.jboss.internal.soa.esb.registry.server.JuddiInVMServerTransport;
+import org.jboss.internal.soa.esb.registry.server.ESBInVMServerTransport;
import org.jboss.internal.soa.esb.util.PropertiesHelper;
import org.jboss.internal.soa.esb.util.XMLHelper;
import org.jboss.system.ServiceMBeanSupport;
@@ -48,11 +48,10 @@
private String propertiesResourceFile ;
private String propertiesFileDir;
- private String nodeName ;
private int numThreads = 20 ;
private long timeout = 20 ;
- private JuddiInVMServerTransport inVMServerTransport ;
+ private ESBInVMServerTransport inVMServerTransport ;
public String getPropertiesResourceFile()
{
@@ -64,16 +63,6 @@
this.propertiesResourceFile = propertiesResourceFile;
}
- public String getNodeName()
- {
- return nodeName;
- }
-
- public void setNodeName(final String nodeName)
- {
- this.nodeName = nodeName;
- }
-
public int getNumThreads()
{
return numThreads;
@@ -156,7 +145,7 @@
try
{
- final JuddiInVMServerTransport inVMServerTransport = new JuddiInVMServerTransport(nodeName) ;
+ final ESBInVMServerTransport inVMServerTransport = new ESBInVMServerTransport() ;
inVMServerTransport.start(numThreads) ;
this.inVMServerTransport = inVMServerTransport ;
}
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIServiceMBean.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIServiceMBean.java 2010-01-06 17:35:42 UTC (rev 30959)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIServiceMBean.java 2010-01-06 18:21:27 UTC (rev 30960)
@@ -33,10 +33,6 @@
void setPropertiesFileDir(final String directory);
- public String getNodeName() ;
-
- public void setNodeName(final String nodeName) ;
-
public int getNumThreads() ;
public void setNumThreads(final int numThreads) ;
Added: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/client/ESBInVMTransport.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/client/ESBInVMTransport.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/client/ESBInVMTransport.java 2010-01-06 18:21:27 UTC (rev 30960)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.internal.soa.esb.registry.client;
+
+import org.apache.juddi.v3.client.transport.TransportException;
+import org.apache.juddi.v3_service.JUDDIApiPortType;
+import org.uddi.v3_service.UDDICustodyTransferPortType;
+import org.uddi.v3_service.UDDIInquiryPortType;
+import org.uddi.v3_service.UDDIPublicationPortType;
+import org.uddi.v3_service.UDDISecurityPortType;
+import org.uddi.v3_service.UDDISubscriptionListenerPortType;
+import org.uddi.v3_service.UDDISubscriptionPortType;
+
+/**
+ * ESB specific InVM transport interface implemented by the scoped service.
+ *
+ * @author <a href='mailto:Kevin.Conner at jboss.com'>Kevin Conner</a>
+ */
+public interface ESBInVMTransport
+{
+ /**
+ * Return an API service for the specified node name and endpoint URL.
+ * @param nodeName The node name.
+ * @param endpointURL The endpoint URL
+ * @return The API service implementation.
+ * @throws TransportException For exceptions obtaining the service implementation.
+ */
+ public JUDDIApiPortType getJUDDIApiService(final String nodeName, final String endpointURL)
+ throws TransportException ;
+
+ /**
+ * Return a Custody Transfer service for the specified node name and endpoint URL.
+ * @param nodeName The node name.
+ * @param endpointURL The endpoint URL
+ * @return The Custody Transfer service implementation.
+ * @throws TransportException For exceptions obtaining the service implementation.
+ */
+ public UDDICustodyTransferPortType getUDDICustodyTransferService(final String nodeName, final String endpointURL)
+ throws TransportException ;
+
+ /**
+ * Return an Inquiry service for the specified node name and endpoint URL.
+ * @param nodeName The node name.
+ * @param endpointURL The endpoint URL
+ * @return The Inquiry service implementation.
+ * @throws TransportException For exceptions obtaining the service implementation.
+ */
+ public UDDIInquiryPortType getUDDIInquiryService(final String nodeName, final String endpointURL)
+ throws TransportException ;
+
+ /**
+ * Return a Publish service for the specified node name and endpoint URL.
+ * @param nodeName The node name.
+ * @param endpointURL The endpoint URL
+ * @return The Publish service implementation.
+ * @throws TransportException For exceptions obtaining the service implementation.
+ */
+ public UDDIPublicationPortType getUDDIPublishService(final String nodeName, final String endpointURL)
+ throws TransportException ;
+
+ /**
+ * Return a Security service for the specified node name and endpoint URL.
+ * @param nodeName The node name.
+ * @param endpointURL The endpoint URL
+ * @return The Security service implementation.
+ * @throws TransportException For exceptions obtaining the service implementation.
+ */
+ public UDDISecurityPortType getUDDISecurityService(final String nodeName, final String endpointURL)
+ throws TransportException ;
+
+ /**
+ * Return a Subscription Listener service for the specified node name and endpoint URL.
+ * @param nodeName The node name.
+ * @param endpointURL The endpoint URL
+ * @return The Subscription Listener service implementation.
+ * @throws TransportException For exceptions obtaining the service implementation.
+ */
+ public UDDISubscriptionListenerPortType getUDDISubscriptionListenerService(final String nodeName, final String endpointURL)
+ throws TransportException ;
+
+ /**
+ * Return a Subscription service for the specified node name and endpoint URL.
+ * @param nodeName The node name.
+ * @param endpointURL The endpoint URL
+ * @return The Subscription service implementation.
+ * @throws TransportException For exceptions obtaining the service implementation.
+ */
+ public UDDISubscriptionPortType getUDDISubscriptionService(final String nodeName, final String endpointURL)
+ throws TransportException ;
+}
Property changes on: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/client/ESBInVMTransport.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/client/JuddiInVMTransport.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/client/JuddiInVMTransport.java 2010-01-06 17:35:42 UTC (rev 30959)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/client/JuddiInVMTransport.java 2010-01-06 18:21:27 UTC (rev 30960)
@@ -31,7 +31,6 @@
import org.uddi.v3_service.UDDISubscriptionListenerPortType;
import org.uddi.v3_service.UDDISubscriptionPortType;
-
/**
* InVM transport specific to the ESB installation.
*
@@ -43,13 +42,19 @@
/**
* The implementation of the ESB specific InVM Transport.
*/
- private static Transport implementation ;
+ private static ESBInVMTransport implementation ;
/**
+ * The node name of the current transport.
+ */
+ private final String nodeName ;
+
+ /**
* Default constructor.
*/
public JuddiInVMTransport()
{
+ this(null) ;
}
/**
@@ -58,55 +63,56 @@
*/
public JuddiInVMTransport(final String nodeName)
{
+ this.nodeName = (nodeName != null ? nodeName : Transport.DEFAULT_NODE_NAME) ;
}
@Override
public JUDDIApiPortType getJUDDIApiService(final String endpointURL)
throws TransportException
{
- return getImplementation().getJUDDIApiService(endpointURL) ;
+ return getImplementation().getJUDDIApiService(nodeName, endpointURL) ;
}
@Override
public UDDICustodyTransferPortType getUDDICustodyTransferService(final String endpointURL)
throws TransportException
{
- return getImplementation().getUDDICustodyTransferService(endpointURL) ;
+ return getImplementation().getUDDICustodyTransferService(nodeName, endpointURL) ;
}
@Override
public UDDIInquiryPortType getUDDIInquiryService(final String endpointURL)
throws TransportException
{
- return getImplementation().getUDDIInquiryService(endpointURL) ;
+ return getImplementation().getUDDIInquiryService(nodeName, endpointURL) ;
}
@Override
public UDDIPublicationPortType getUDDIPublishService(final String endpointURL)
throws TransportException
{
- return getImplementation().getUDDIPublishService(endpointURL) ;
+ return getImplementation().getUDDIPublishService(nodeName, endpointURL) ;
}
@Override
public UDDISecurityPortType getUDDISecurityService(final String endpointURL)
throws TransportException
{
- return getImplementation().getUDDISecurityService(endpointURL) ;
+ return getImplementation().getUDDISecurityService(nodeName, endpointURL) ;
}
@Override
public UDDISubscriptionListenerPortType getUDDISubscriptionListenerService(final String endpointURL)
throws TransportException
{
- return getImplementation().getUDDISubscriptionListenerService(endpointURL) ;
+ return getImplementation().getUDDISubscriptionListenerService(nodeName, endpointURL) ;
}
@Override
public UDDISubscriptionPortType getUDDISubscriptionService(final String endpointURL)
throws TransportException
{
- return getImplementation().getUDDISubscriptionService(endpointURL) ;
+ return getImplementation().getUDDISubscriptionService(nodeName, endpointURL) ;
}
/**
@@ -114,7 +120,7 @@
* @return The current implementation.
* @throws TransportException if no implementation has been configured.
*/
- public static synchronized Transport getImplementation()
+ public static synchronized ESBInVMTransport getImplementation()
throws TransportException
{
if (implementation == null)
@@ -128,7 +134,7 @@
* Set the current implementation.
* @param implementation The current implementation.
*/
- public static synchronized void setImplementation(final Transport implementation)
+ public static synchronized void setImplementation(final ESBInVMTransport implementation)
{
JuddiInVMTransport.implementation = implementation ;
}
Added: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/server/ESBInVMServerTransport.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/server/ESBInVMServerTransport.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/server/ESBInVMServerTransport.java 2010-01-06 18:21:27 UTC (rev 30960)
@@ -0,0 +1,234 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.internal.soa.esb.registry.server;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.juddi.v3.client.transport.Transport;
+import org.apache.juddi.v3.client.transport.TransportException;
+import org.apache.juddi.v3_service.JUDDIApiPortType;
+import org.jboss.internal.soa.esb.registry.client.ESBInVMTransport;
+import org.jboss.internal.soa.esb.registry.client.JuddiInVMTransport;
+import org.uddi.v3_service.UDDICustodyTransferPortType;
+import org.uddi.v3_service.UDDIInquiryPortType;
+import org.uddi.v3_service.UDDIPublicationPortType;
+import org.uddi.v3_service.UDDISecurityPortType;
+import org.uddi.v3_service.UDDISubscriptionListenerPortType;
+import org.uddi.v3_service.UDDISubscriptionPortType;
+
+
+/**
+ * ESB InVM server side delegating to node specific transports.
+ *
+ * @author <a href='Kevin.Conner at jboss.com'>Kevin Conner</a>
+ */
+public class ESBInVMServerTransport implements ESBInVMTransport
+{
+ /**
+ * Our class loader.
+ */
+ private final ClassLoader classLoader = getClass().getClassLoader() ;
+
+ /**
+ * The configured transports.
+ */
+ private final ConcurrentHashMap<String, Transport> transports = new ConcurrentHashMap<String, Transport>() ;
+
+ /**
+ * The executor service.
+ */
+ private final AtomicReference<ExecutorService> executorServiceReference = new AtomicReference<ExecutorService>();
+
+ /**
+ * Return an API service for the specified node name and endpoint URL.
+ * @param nodeName The node name.
+ * @param endpointURL The endpoint URL
+ * @return The API service implementation.
+ * @throws TransportException For exceptions obtaining the service implementation.
+ */
+ public JUDDIApiPortType getJUDDIApiService(final String nodeName, final String endpointURL)
+ throws TransportException
+ {
+ return getTransport(nodeName).getJUDDIApiService(endpointURL) ;
+ }
+
+
+ /**
+ * Return a Custody Transfer service for the specified node name and endpoint URL.
+ * @param nodeName The node name.
+ * @param endpointURL The endpoint URL
+ * @return The Custody Transfer service implementation.
+ * @throws TransportException For exceptions obtaining the service implementation.
+ */
+ public UDDICustodyTransferPortType getUDDICustodyTransferService(final String nodeName, final String endpointURL)
+ throws TransportException
+ {
+ return getTransport(nodeName).getUDDICustodyTransferService(endpointURL) ;
+ }
+
+
+ /**
+ * Return an Inquiry service for the specified node name and endpoint URL.
+ * @param nodeName The node name.
+ * @param endpointURL The endpoint URL
+ * @return The Inquiry service implementation.
+ * @throws TransportException For exceptions obtaining the service implementation.
+ */
+ public UDDIInquiryPortType getUDDIInquiryService(final String nodeName, final String endpointURL)
+ throws TransportException
+ {
+ return getTransport(nodeName).getUDDIInquiryService(endpointURL) ;
+ }
+
+
+ /**
+ * Return a Publish service for the specified node name and endpoint URL.
+ * @param nodeName The node name.
+ * @param endpointURL The endpoint URL
+ * @return The Publish service implementation.
+ * @throws TransportException For exceptions obtaining the service implementation.
+ */
+ public UDDIPublicationPortType getUDDIPublishService(final String nodeName, final String endpointURL)
+ throws TransportException
+ {
+ return getTransport(nodeName).getUDDIPublishService(endpointURL) ;
+ }
+
+
+ /**
+ * Return a Security service for the specified node name and endpoint URL.
+ * @param nodeName The node name.
+ * @param endpointURL The endpoint URL
+ * @return The Security service implementation.
+ * @throws TransportException For exceptions obtaining the service implementation.
+ */
+ public UDDISecurityPortType getUDDISecurityService(final String nodeName, final String endpointURL)
+ throws TransportException
+ {
+ return getTransport(nodeName).getUDDISecurityService(endpointURL) ;
+ }
+
+
+ /**
+ * Return a Subscription Listener service for the specified node name and endpoint URL.
+ * @param nodeName The node name.
+ * @param endpointURL The endpoint URL
+ * @return The Subscription Listener service implementation.
+ * @throws TransportException For exceptions obtaining the service implementation.
+ */
+ public UDDISubscriptionListenerPortType getUDDISubscriptionListenerService(final String nodeName, final String endpointURL)
+ throws TransportException
+ {
+ return getTransport(nodeName).getUDDISubscriptionListenerService(endpointURL) ;
+ }
+
+
+ /**
+ * Return a Subscription service for the specified node name and endpoint URL.
+ * @param nodeName The node name.
+ * @param endpointURL The endpoint URL
+ * @return The Subscription service implementation.
+ * @throws TransportException For exceptions obtaining the service implementation.
+ */
+ public UDDISubscriptionPortType getUDDISubscriptionService(final String nodeName, final String endpointURL)
+ throws TransportException
+ {
+ return getTransport(nodeName).getUDDISubscriptionService(endpointURL) ;
+ }
+
+ /**
+ * Get the transport for the specified node.
+ * @param nodeName The node name.
+ * @return The in vm transport.
+ */
+ private Transport getTransport(final String nodeName)
+ {
+ final Transport transport = transports.get(nodeName) ;
+ if (transport != null)
+ {
+ return transport ;
+ }
+
+ final JuddiInVMServerTransport juddiTransport = new JuddiInVMServerTransport(nodeName, executorServiceReference) ;
+ final Transport current = transports.putIfAbsent(nodeName, juddiTransport) ;
+ return (current != null ? current: juddiTransport) ;
+ }
+
+ /**
+ * Start the background executor.
+ * @param numThreads The number of threads for the background executor.
+ */
+ public void start(final int numThreads)
+ throws TransportException
+ {
+ if (!executorServiceReference.compareAndSet(null, Executors.newFixedThreadPool(numThreads, new ScopedThreadFactory())))
+ {
+ throw new TransportException("Executor service already initialised") ;
+ }
+ JuddiInVMTransport.setImplementation(this) ;
+ }
+
+ /**
+ * Stop the background executor.
+ * @param timeout The number of seconds to wait for the background executor to terminate.
+ */
+ public void stop(final long timeout)
+ throws InterruptedException
+ {
+ final ExecutorService executorService = executorServiceReference.getAndSet(null) ;
+ if (executorService != null)
+ {
+ JuddiInVMTransport.setImplementation(null) ;
+ executorService.shutdown() ;
+ executorService.awaitTermination(timeout, TimeUnit.SECONDS) ;
+ }
+ }
+
+ /**
+ * Thread factory executing within the scoped classloader.
+ *
+ * @author kevin
+ */
+ private final class ScopedThreadFactory implements ThreadFactory
+ {
+ /**
+ * The default executor factory.
+ */
+ private final ThreadFactory defaultFactory = Executors.defaultThreadFactory() ;
+
+ /**
+ * Return a new daemon thread.
+ * @param runnable The runnable associated with the thread.
+ */
+ public Thread newThread(final Runnable runnable)
+ {
+ final Thread thread = defaultFactory.newThread(runnable) ;
+ thread.setContextClassLoader(classLoader) ;
+ return thread ;
+ }
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/server/ESBInVMServerTransport.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/server/JuddiInVMServerTransport.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/server/JuddiInVMServerTransport.java 2010-01-06 17:35:42 UTC (rev 30959)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/registry/server/JuddiInVMServerTransport.java 2010-01-06 18:21:27 UTC (rev 30960)
@@ -26,10 +26,7 @@
import java.lang.reflect.Proxy;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.configuration.ConfigurationException;
@@ -37,7 +34,6 @@
import org.apache.juddi.v3.client.transport.Transport;
import org.apache.juddi.v3.client.transport.TransportException;
import org.apache.juddi.v3_service.JUDDIApiPortType;
-import org.jboss.internal.soa.esb.registry.client.JuddiInVMTransport;
import org.jboss.soa.esb.util.ClassUtil;
import org.uddi.v3_service.UDDICustodyTransferPortType;
import org.uddi.v3_service.UDDIInquiryPortType;
@@ -67,285 +63,319 @@
/**
* The juddi api port type instance.
*/
- private JUDDIApiPortType juddiApiPortType ;
+ private final AtomicReference<JUDDIApiPortType> juddiApiPortTypeRef = new AtomicReference<JUDDIApiPortType>() ;
/**
* The uddi custody transfer port type instance.
*/
- private UDDICustodyTransferPortType uddiCustodyTransferPortType ;
+ private final AtomicReference<UDDICustodyTransferPortType> uddiCustodyTransferPortTypeRef = new AtomicReference<UDDICustodyTransferPortType>() ;
/**
* The uddi inquiry port type instance.
*/
- private UDDIInquiryPortType uddiInquiryPortType ;
+ private final AtomicReference<UDDIInquiryPortType> uddiInquiryPortTypeRef = new AtomicReference<UDDIInquiryPortType>() ;
/**
* The uddi publication port type instance.
*/
- private UDDIPublicationPortType uddiPublicationPortType ;
+ private final AtomicReference<UDDIPublicationPortType> uddiPublicationPortTypeRef = new AtomicReference<UDDIPublicationPortType>() ;
/**
* The uddi security port type instance.
*/
- private UDDISecurityPortType uddiSecurityPortType ;
+ private final AtomicReference<UDDISecurityPortType> uddiSecurityPortTypeRef = new AtomicReference<UDDISecurityPortType>() ;
/**
* The uddi subscription listener port type instance.
*/
- private UDDISubscriptionListenerPortType uddiSubscriptionListenerPortType ;
+ private final AtomicReference<UDDISubscriptionListenerPortType> uddiSubscriptionListenerPortTypeRef = new AtomicReference<UDDISubscriptionListenerPortType>() ;
/**
* The uddi subscription port type instance.
*/
- private UDDISubscriptionPortType uddiSubscriptionPortType ;
+ private final AtomicReference<UDDISubscriptionPortType> uddiSubscriptionPortTypeRef = new AtomicReference<UDDISubscriptionPortType>() ;
/**
* The executor service.
*/
- private final AtomicReference<ExecutorService> executorServiceReference = new AtomicReference<ExecutorService>();
+ private final AtomicReference<ExecutorService> executorServiceReference ;
/**
* Construct the InVM server transport instance with the delegated instance.
* @param nodeName The node name of the transport.
*/
- public JuddiInVMServerTransport(final String nodeName)
+ public JuddiInVMServerTransport(final String nodeName, final AtomicReference<ExecutorService> executorServiceReference)
{
this.nodeName = nodeName ;
+ this.executorServiceReference = executorServiceReference ;
}
@Override
- public synchronized JUDDIApiPortType getJUDDIApiService(final String endpointURL)
+ public JUDDIApiPortType getJUDDIApiService(final String endpointURL)
throws TransportException
{
- if (juddiApiPortType == null)
+ final JUDDIApiPortType current = juddiApiPortTypeRef.get() ;
+ if (current != null)
{
- final String juddiApiUrl ;
- if (endpointURL == null)
+ return current ;
+ }
+ final String juddiApiUrl ;
+ if (endpointURL == null)
+ {
+ try
{
- try
- {
- juddiApiUrl = UDDIClerkManager.getClientConfig().getUDDINode(nodeName).getJuddiApiUrl() ;
- }
- catch (final ConfigurationException ce)
- {
- throw new TransportException("Could not discover juddiApiUrl for node " + nodeName, ce) ;
- }
+ juddiApiUrl = UDDIClerkManager.getClientConfig().getUDDINode(nodeName).getJuddiApiUrl() ;
}
- else
+ catch (final ConfigurationException ce)
{
- juddiApiUrl = endpointURL ;
+ throw new TransportException("Could not discover juddiApiUrl for node " + nodeName, ce) ;
}
- final Object delegatePortType = createDelegate(juddiApiUrl) ;
-
- final InvocationHandler handler = new TaskHandler(delegatePortType) ;
- juddiApiPortType = (JUDDIApiPortType) Proxy.newProxyInstance(classLoader,
- new Class[] {JUDDIApiPortType.class}, handler) ;
}
- return juddiApiPortType ;
+ else
+ {
+ juddiApiUrl = endpointURL ;
+ }
+ final Object delegatePortType = createDelegate(juddiApiUrl) ;
+
+ final InvocationHandler handler = new TaskHandler(delegatePortType) ;
+ final JUDDIApiPortType juddiApiPortType = (JUDDIApiPortType) Proxy.newProxyInstance(classLoader,
+ new Class[] {JUDDIApiPortType.class}, handler) ;
+ if (juddiApiPortTypeRef.compareAndSet(null, juddiApiPortType))
+ {
+ return juddiApiPortType ;
+ }
+ else
+ {
+ return juddiApiPortTypeRef.get() ;
+ }
}
@Override
- public synchronized UDDICustodyTransferPortType getUDDICustodyTransferService(final String endpointURL)
+ public UDDICustodyTransferPortType getUDDICustodyTransferService(final String endpointURL)
throws TransportException
{
- if (uddiCustodyTransferPortType == null)
+ final UDDICustodyTransferPortType current = uddiCustodyTransferPortTypeRef.get() ;
+ if (current != null)
{
- final String custodyTransferUrl ;
- if (endpointURL == null)
+ return current ;
+ }
+ final String custodyTransferUrl ;
+ if (endpointURL == null)
+ {
+ try
{
- try
- {
- custodyTransferUrl = UDDIClerkManager.getClientConfig().getUDDINode(nodeName).getCustodyTransferUrl() ;
- }
- catch (final ConfigurationException ce)
- {
- throw new TransportException("Could not discover custodyTransferUrl for node " + nodeName, ce) ;
- }
+ custodyTransferUrl = UDDIClerkManager.getClientConfig().getUDDINode(nodeName).getCustodyTransferUrl() ;
}
- else
+ catch (final ConfigurationException ce)
{
- custodyTransferUrl = endpointURL ;
+ throw new TransportException("Could not discover custodyTransferUrl for node " + nodeName, ce) ;
}
- final Object delegatePortType = createDelegate(custodyTransferUrl) ;
- final InvocationHandler handler = new TaskHandler(delegatePortType) ;
- uddiCustodyTransferPortType = (UDDICustodyTransferPortType) Proxy.newProxyInstance(classLoader,
- new Class[] {UDDICustodyTransferPortType.class}, handler) ;
}
- return uddiCustodyTransferPortType ;
+ else
+ {
+ custodyTransferUrl = endpointURL ;
+ }
+ final Object delegatePortType = createDelegate(custodyTransferUrl) ;
+ final InvocationHandler handler = new TaskHandler(delegatePortType) ;
+ final UDDICustodyTransferPortType uddiCustodyTransferPortType = (UDDICustodyTransferPortType) Proxy.newProxyInstance(classLoader,
+ new Class[] {UDDICustodyTransferPortType.class}, handler) ;
+ if (uddiCustodyTransferPortTypeRef.compareAndSet(null, uddiCustodyTransferPortType))
+ {
+ return uddiCustodyTransferPortType ;
+ }
+ else
+ {
+ return uddiCustodyTransferPortTypeRef.get() ;
+ }
}
@Override
- public synchronized UDDIInquiryPortType getUDDIInquiryService(final String endpointURL)
+ public UDDIInquiryPortType getUDDIInquiryService(final String endpointURL)
throws TransportException
{
- if (uddiInquiryPortType == null)
+ final UDDIInquiryPortType current = uddiInquiryPortTypeRef.get() ;
+ if (current != null)
{
- final String inquiryUrl ;
- if (endpointURL == null)
+ return current ;
+ }
+ final String inquiryUrl ;
+ if (endpointURL == null)
+ {
+ try
{
- try
- {
- inquiryUrl = UDDIClerkManager.getClientConfig().getUDDINode(nodeName).getInquiryUrl() ;
- }
- catch (final ConfigurationException ce)
- {
- throw new TransportException("Could not discover inquiryUrl for node " + nodeName, ce) ;
- }
+ inquiryUrl = UDDIClerkManager.getClientConfig().getUDDINode(nodeName).getInquiryUrl() ;
}
- else
+ catch (final ConfigurationException ce)
{
- inquiryUrl = endpointURL ;
+ throw new TransportException("Could not discover inquiryUrl for node " + nodeName, ce) ;
}
- final Object delegatePortType = createDelegate(inquiryUrl) ;
- final InvocationHandler handler = new TaskHandler(delegatePortType) ;
- uddiInquiryPortType = (UDDIInquiryPortType) Proxy.newProxyInstance(classLoader,
- new Class[] {UDDIInquiryPortType.class}, handler) ;
}
- return uddiInquiryPortType ;
+ else
+ {
+ inquiryUrl = endpointURL ;
+ }
+ final Object delegatePortType = createDelegate(inquiryUrl) ;
+ final InvocationHandler handler = new TaskHandler(delegatePortType) ;
+ final UDDIInquiryPortType uddiInquiryPortType = (UDDIInquiryPortType) Proxy.newProxyInstance(classLoader,
+ new Class[] {UDDIInquiryPortType.class}, handler) ;
+ if (uddiInquiryPortTypeRef.compareAndSet(null, uddiInquiryPortType))
+ {
+ return uddiInquiryPortType ;
+ }
+ else
+ {
+ return uddiInquiryPortTypeRef.get() ;
+ }
}
@Override
- public synchronized UDDIPublicationPortType getUDDIPublishService(final String endpointURL)
+ public UDDIPublicationPortType getUDDIPublishService(final String endpointURL)
throws TransportException
{
- if (uddiPublicationPortType == null)
+ final UDDIPublicationPortType current = uddiPublicationPortTypeRef.get() ;
+ if (current != null)
{
- final String publishUrl ;
- if (endpointURL == null)
+ return current ;
+ }
+ final String publishUrl ;
+ if (endpointURL == null)
+ {
+ try
{
- try
- {
- publishUrl = UDDIClerkManager.getClientConfig().getUDDINode(nodeName).getPublishUrl() ;
- }
- catch (final ConfigurationException ce)
- {
- throw new TransportException("Could not discover publishUrl for node " + nodeName, ce) ;
- }
+ publishUrl = UDDIClerkManager.getClientConfig().getUDDINode(nodeName).getPublishUrl() ;
}
- else
+ catch (final ConfigurationException ce)
{
- publishUrl = endpointURL ;
+ throw new TransportException("Could not discover publishUrl for node " + nodeName, ce) ;
}
- final Object delegatePortType = createDelegate(publishUrl) ;
- final InvocationHandler handler = new TaskHandler(delegatePortType) ;
- uddiPublicationPortType = (UDDIPublicationPortType) Proxy.newProxyInstance(classLoader,
- new Class[] {UDDIPublicationPortType.class}, handler) ;
}
- return uddiPublicationPortType ;
+ else
+ {
+ publishUrl = endpointURL ;
+ }
+ final Object delegatePortType = createDelegate(publishUrl) ;
+ final InvocationHandler handler = new TaskHandler(delegatePortType) ;
+ final UDDIPublicationPortType uddiPublicationPortType = (UDDIPublicationPortType) Proxy.newProxyInstance(classLoader,
+ new Class[] {UDDIPublicationPortType.class}, handler) ;
+ if (uddiPublicationPortTypeRef.compareAndSet(null, uddiPublicationPortType))
+ {
+ return uddiPublicationPortType ;
+ }
+ else
+ {
+ return uddiPublicationPortTypeRef.get() ;
+ }
}
@Override
- public synchronized UDDISecurityPortType getUDDISecurityService(final String endpointURL)
+ public UDDISecurityPortType getUDDISecurityService(final String endpointURL)
throws TransportException
{
- if (uddiSecurityPortType == null)
+ final UDDISecurityPortType current = uddiSecurityPortTypeRef.get() ;
+ if (current != null)
{
- final String securityUrl ;
- if (endpointURL == null)
+ return current ;
+ }
+ final String securityUrl ;
+ if (endpointURL == null)
+ {
+ try
{
- try
- {
- securityUrl = UDDIClerkManager.getClientConfig().getUDDINode(nodeName).getSecurityUrl() ;
- }
- catch (final ConfigurationException ce)
- {
- throw new TransportException("Could not discover securityUrl for node " + nodeName, ce) ;
- }
+ securityUrl = UDDIClerkManager.getClientConfig().getUDDINode(nodeName).getSecurityUrl() ;
}
- else
+ catch (final ConfigurationException ce)
{
- securityUrl = endpointURL ;
+ throw new TransportException("Could not discover securityUrl for node " + nodeName, ce) ;
}
- final Object delegatePortType = createDelegate(securityUrl) ;
- final InvocationHandler handler = new TaskHandler(delegatePortType) ;
- uddiSecurityPortType = (UDDISecurityPortType) Proxy.newProxyInstance(classLoader,
- new Class[] {UDDISecurityPortType.class}, handler) ;
}
- return uddiSecurityPortType ;
+ else
+ {
+ securityUrl = endpointURL ;
+ }
+ final Object delegatePortType = createDelegate(securityUrl) ;
+ final InvocationHandler handler = new TaskHandler(delegatePortType) ;
+ final UDDISecurityPortType uddiSecurityPortType = (UDDISecurityPortType) Proxy.newProxyInstance(classLoader,
+ new Class[] {UDDISecurityPortType.class}, handler) ;
+ if (uddiSecurityPortTypeRef.compareAndSet(null, uddiSecurityPortType))
+ {
+ return uddiSecurityPortType ;
+ }
+ else
+ {
+ return uddiSecurityPortTypeRef.get() ;
+ }
}
@Override
- public synchronized UDDISubscriptionListenerPortType getUDDISubscriptionListenerService(final String endpointURL)
+ public UDDISubscriptionListenerPortType getUDDISubscriptionListenerService(final String endpointURL)
throws TransportException
{
- if (uddiSubscriptionListenerPortType == null)
+ final UDDISubscriptionListenerPortType current = uddiSubscriptionListenerPortTypeRef.get() ;
+ if (current != null)
{
- final String subscriptionListenerUrl ;
- if (endpointURL == null)
+ return current ;
+ }
+ final String subscriptionListenerUrl ;
+ if (endpointURL == null)
+ {
+ try
{
- try
- {
- subscriptionListenerUrl = UDDIClerkManager.getClientConfig().getUDDINode(nodeName).getSubscriptionListenerUrl() ;
- }
- catch (final ConfigurationException ce)
- {
- throw new TransportException("Could not discover subscriptionListenerUrl for node " + nodeName, ce) ;
- }
+ subscriptionListenerUrl = UDDIClerkManager.getClientConfig().getUDDINode(nodeName).getSubscriptionListenerUrl() ;
}
- else
+ catch (final ConfigurationException ce)
{
- subscriptionListenerUrl = endpointURL ;
+ throw new TransportException("Could not discover subscriptionListenerUrl for node " + nodeName, ce) ;
}
- final Object delegatePortType = createDelegate(subscriptionListenerUrl) ;
- final InvocationHandler handler = new TaskHandler(delegatePortType) ;
- uddiSubscriptionListenerPortType = (UDDISubscriptionListenerPortType) Proxy.newProxyInstance(classLoader,
- new Class[] {UDDISubscriptionListenerPortType.class}, handler) ;
}
- return uddiSubscriptionListenerPortType ;
+ else
+ {
+ subscriptionListenerUrl = endpointURL ;
+ }
+ final Object delegatePortType = createDelegate(subscriptionListenerUrl) ;
+ final InvocationHandler handler = new TaskHandler(delegatePortType) ;
+ final UDDISubscriptionListenerPortType uddiSubscriptionListenerPortType = (UDDISubscriptionListenerPortType) Proxy.newProxyInstance(classLoader,
+ new Class[] {UDDISubscriptionListenerPortType.class}, handler) ;
+ if (uddiSubscriptionListenerPortTypeRef.compareAndSet(null, uddiSubscriptionListenerPortType))
+ {
+ return uddiSubscriptionListenerPortType ;
+ }
+ else
+ {
+ return uddiSubscriptionListenerPortTypeRef.get() ;
+ }
}
@Override
- public synchronized UDDISubscriptionPortType getUDDISubscriptionService(final String endpointURL)
+ public UDDISubscriptionPortType getUDDISubscriptionService(final String endpointURL)
throws TransportException
{
- if (uddiSubscriptionPortType == null)
+ final UDDISubscriptionPortType current = uddiSubscriptionPortTypeRef.get() ;
+ if (current != null)
{
- final String subscriptionUrl ;
- if (endpointURL == null)
+ return current ;
+ }
+ final String subscriptionUrl ;
+ if (endpointURL == null)
+ {
+ try
{
- try
- {
- subscriptionUrl = UDDIClerkManager.getClientConfig().getUDDINode(nodeName).getSubscriptionUrl() ;
- }
- catch (final ConfigurationException ce)
- {
- throw new TransportException("Could not discover subscriptionUrl for node " + nodeName, ce) ;
- }
+ subscriptionUrl = UDDIClerkManager.getClientConfig().getUDDINode(nodeName).getSubscriptionUrl() ;
}
- else
+ catch (final ConfigurationException ce)
{
- subscriptionUrl = endpointURL ;
+ throw new TransportException("Could not discover subscriptionUrl for node " + nodeName, ce) ;
}
- final Object delegatePortType = createDelegate(subscriptionUrl) ;
- final InvocationHandler handler = new TaskHandler(delegatePortType) ;
- uddiSubscriptionPortType = (UDDISubscriptionPortType) Proxy.newProxyInstance(classLoader,
- new Class[] {UDDISubscriptionPortType.class}, handler) ;
}
- return uddiSubscriptionPortType ;
- }
-
- /**
- * Start the background executor.
- * @param numThreads The number of threads for the background executor.
- */
- public void start(final int numThreads)
- throws TransportException
- {
- if (!executorServiceReference.compareAndSet(null, Executors.newFixedThreadPool(numThreads, new ScopedThreadFactory())))
+ else
{
- throw new TransportException("Executor service already initialised") ;
+ subscriptionUrl = endpointURL ;
}
- JuddiInVMTransport.setImplementation(this) ;
- }
-
- /**
- * Stop the background executor.
- * @param timeout The number of seconds to wait for the background executor to terminate.
- */
- public void stop(final long timeout)
- throws InterruptedException
- {
- final ExecutorService executorService = executorServiceReference.getAndSet(null) ;
- if (executorService != null)
+ final Object delegatePortType = createDelegate(subscriptionUrl) ;
+ final InvocationHandler handler = new TaskHandler(delegatePortType) ;
+ final UDDISubscriptionPortType uddiSubscriptionPortType = (UDDISubscriptionPortType) Proxy.newProxyInstance(classLoader,
+ new Class[] {UDDISubscriptionPortType.class}, handler) ;
+ if (uddiSubscriptionPortTypeRef.compareAndSet(null, uddiSubscriptionPortType))
{
- JuddiInVMTransport.setImplementation(null) ;
- executorService.shutdown() ;
- executorService.awaitTermination(timeout, TimeUnit.SECONDS) ;
+ return uddiSubscriptionPortType ;
}
+ else
+ {
+ return uddiSubscriptionPortTypeRef.get() ;
+ }
}
/**
@@ -419,28 +449,4 @@
}
}
}
-
- /**
- * Thread factory executing within the scoped classloader.
- *
- * @author kevin
- */
- private final class ScopedThreadFactory implements ThreadFactory
- {
- /**
- * The default executor factory.
- */
- private final ThreadFactory defaultFactory = Executors.defaultThreadFactory() ;
-
- /**
- * Return a new daemon thread.
- * @param runnable The runnable associated with the thread.
- */
- public Thread newThread(final Runnable runnable)
- {
- final Thread thread = defaultFactory.newThread(runnable) ;
- thread.setContextClassLoader(classLoader) ;
- return thread ;
- }
- }
}
More information about the jboss-svn-commits
mailing list