[jboss-svn-commits] JBL Code SVN: r26212 - in labs/jbossesb/branches/JBESB_4_2_1_GA_CP: product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect and 3 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Apr 22 14:20:37 EDT 2009


Author: kevin.conner at jboss.com
Date: 2009-04-22 14:20:37 -0400 (Wed, 22 Apr 2009)
New Revision: 26212

Modified:
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/JUDDIAspect.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/aop/resources/META-INF/jboss-aop.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/build.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServer.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServerMBean.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/junit/src/org/jboss/soa/esb/server/aop/AOPUnitTest.java
Log:
Handle race in jUDDI business detail: JBESB-1507

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/JUDDIAspect.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/JUDDIAspect.java	2009-04-22 15:39:57 UTC (rev 26211)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/JUDDIAspect.java	2009-04-22 18:20:37 UTC (rev 26212)
@@ -21,6 +21,9 @@
  */
 package org.jboss.internal.soa.esb.services.registry.aspect;
 
+import java.util.Vector;
+
+import org.jboss.aop.joinpoint.MethodCalledByMethodInvocation;
 import org.jboss.aop.joinpoint.MethodInvocation;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -29,6 +32,8 @@
 /**
  * Aspect used to support CDATA sections from within jUDDI.
  * 
+ * Also intercepts calls for services when constructing the organizational information.
+ * 
  * @author <a href='mailto:Kevin.Conner at jboss.com'>Kevin Conner</a>
  */
 public class JUDDIAspect
@@ -54,4 +59,10 @@
         
         return sb.toString().trim();
     }
+    
+    public Object fetchServiceByBusinessKey(final MethodCalledByMethodInvocation invocation)
+        throws Throwable
+    {
+        return new Vector<Object>() ;
+    }
 }

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/aop/resources/META-INF/jboss-aop.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/aop/resources/META-INF/jboss-aop.xml	2009-04-22 15:39:57 UTC (rev 26211)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/aop/resources/META-INF/jboss-aop.xml	2009-04-22 18:20:37 UTC (rev 26212)
@@ -14,5 +14,9 @@
    <bind pointcut="execution(* org.apache.juddi.util.xml.XMLUtils->getText(..))">
       <advice name="getText" aspect="org.jboss.internal.soa.esb.services.registry.aspect.JUDDIAspect"/>
    </bind>
+
+   <bind pointcut="withincode(* org.apache.juddi.datastore.jdbc.JDBCDataStore->fetchBusiness(..)) AND call(* org.apache.juddi.datastore.jdbc.JDBCDataStore->fetchServiceByBusinessKey(..))">
+      <advice name="fetchServiceByBusinessKey" aspect="org.jboss.internal.soa.esb.services.registry.aspect.JUDDIAspect"/>
+   </bind>
 </aop>
 

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/build.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/build.xml	2009-04-22 15:39:57 UTC (rev 26211)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/build.xml	2009-04-22 18:20:37 UTC (rev 26212)
@@ -162,9 +162,13 @@
             <aopclasspath path="${org.jboss.esb.rosetta.aop.classes.dir}"/>
         </aopc>
         <aopc compilerclasspathref="aop-classpath">
-            <classpath path="${org.jboss.esb.rosetta.aopc.juddi.classes.dir}"/>
+            <classpath>
+              <pathelement path="${org.jboss.esb.rosetta.aopc.juddi.classes.dir}"/>
+              <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="commons-logging*.jar"/>
+            </classpath>
             <src path="${org.jboss.esb.rosetta.aopc.juddi.classes.dir}"/>
             <include name="org/apache/juddi/util/xml/XMLUtils.class"/>
+            <include name="org/apache/juddi/datastore/jdbc/JDBCDataStore.class"/>
             <aoppath path="aop/resources/META-INF/jboss-aop.xml"/>
             <aopclasspath path="${org.jboss.esb.rosetta.aop.classes.dir}"/>
         </aopc>

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java	2009-04-22 15:39:57 UTC (rev 26211)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java	2009-04-22 18:20:37 UTC (rev 26212)
@@ -92,7 +92,7 @@
 			ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, "org.jboss.soa.esb.:category");
             Classification classification = blm.createClassification(cScheme, "category", category);
 			service.addClassification(classification);
-			organization.addService(service);
+			service.setProvidingOrganization(organization);
 			saveRegistryObject(service, jaxrConnectionFactory);
 		} finally {
 			jaxrConnectionFactory.closeConnection(connection);
@@ -225,9 +225,9 @@
 	{
 		List<String> serviceNames = new ArrayList<String>();
 		try {
-			Collection services = getJBossESBOrganization().getServices();
-			for (Iterator i=services.iterator();i.hasNext();) {
-				String serviceName = ((Service)i.next()).getName().getValue();
+			Collection<Service> services = findServices();
+			for (Service service: services) {
+				String serviceName = service.getName().getValue();
 				serviceNames.add(serviceName);
 			}
 		} catch (JAXRException je) {
@@ -497,6 +497,31 @@
 	}
 
     /**
+     * Finds all services for the organization.
+     */
+    @SuppressWarnings("unchecked")
+    protected Collection<Service> findServices() throws JAXRException
+    {
+        Collection<Service> services = new ArrayList<Service>();
+        Connection connection = jaxrConnectionFactory.getConnection();
+        try {
+            // Get registry service and business query manager
+            RegistryService rs = connection.getRegistryService();
+            BusinessQueryManager bqm = rs.getBusinessQueryManager();
+            //Find based upon qualifier type and values
+            logger.log(Level.DEBUG, "Going to query the registry for services");
+            BulkResponse response = bqm.findServices(getJBossESBOrganization().getKey(),
+                null, null, null, null);
+            if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
+                services = (Collection<Service>) response.getCollection();
+            }
+            return services;
+        } finally {
+            jaxrConnectionFactory.closeConnection(connection);
+        }
+    }
+
+    /**
 	 * Create a jbossesb organization under which we will register all our services.
 	 *
 	 * @return
@@ -628,14 +653,18 @@
 
     /**
 	 * finds the JBossESB Organizationa and creates one if it is not there.
+	 * Note, there are no services associated with this information.
+	 * 
 	 * @return JBossESB Organization
 	 * @throws JAXRException
 	 */
-	private Organization getJBossESBOrganization() throws JAXRException
+	private synchronized Organization getJBossESBOrganization() throws JAXRException
 	{
-		jbossESBOrganization = findOrganization("Red Hat/JBossESB", jaxrConnectionFactory);
 		if (jbossESBOrganization==null) {
-			jbossESBOrganization = createJBossESBOrganization(jaxrConnectionFactory);
+			jbossESBOrganization = findOrganization("Red Hat/JBossESB", jaxrConnectionFactory);
+			if (jbossESBOrganization==null) {
+				jbossESBOrganization = createJBossESBOrganization(jaxrConnectionFactory);
+			}
 		}
 		return jbossESBOrganization;
 	}

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServer.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServer.java	2009-04-22 15:39:57 UTC (rev 26211)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServer.java	2009-04-22 18:20:37 UTC (rev 26212)
@@ -22,6 +22,7 @@
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.Collection;
+import java.util.List;
 
 import javax.xml.registry.BulkResponse;
 import javax.xml.registry.BusinessQueryManager;
@@ -29,6 +30,7 @@
 import javax.xml.registry.JAXRException;
 import javax.xml.registry.JAXRResponse;
 import javax.xml.registry.RegistryService;
+import javax.xml.registry.infomodel.Organization;
 import javax.xml.registry.infomodel.Service;
 import javax.xml.registry.infomodel.ServiceBinding;
 
@@ -101,6 +103,30 @@
         return null ;
     }
     
+    public String verifyServiceRetrieval()
+        throws RegistryException
+    {
+        final Registry registry = RegistryFactory.getRegistry() ;
+        final List<String> services = registry.findAllServices() ;
+        if ((services == null) || (services.size() == 0))
+        {
+            return "No services returned from query" ;
+        }
+        return null ;
+    }
+    
+    public String verifyOrganizationalStructure()
+        throws RegistryException, JAXRException
+    {
+        final Organization jbossESBOrganization = JAXRRegistryImpl.findOrganization("Red Hat/JBossESB", new JAXRConnectionFactory());
+        final Collection<Service> services = jbossESBOrganization.getServices() ;
+        if ((services != null) & (services.size() > 0))
+        {
+            return "Services returned in organization information" ;
+        }
+        return null ;
+    }
+    
     private String verifyHeuristic(final String value)
     {
         final char[] contents = value.toCharArray() ;
@@ -144,33 +170,40 @@
             
             final ScoutConnectionFactory scoutConnectionFactory = new ScoutConnectionFactory() ;
             final Connection connection = scoutConnectionFactory.getConnection();
-            final RegistryService rs = connection.getRegistryService();
-            final BusinessQueryManager bqm = rs.getBusinessQueryManager();
-            final BulkResponse bulkResponse = bqm.findServiceBindings(service.getKey(),null,null,null);
-            if (bulkResponse.getStatus()!=JAXRResponse.STATUS_SUCCESS)
+            try
             {
-                return "findServiceBindings failed" ;
-            }
-            final Collection<ServiceBinding> serviceBindings = (Collection<ServiceBinding>)bulkResponse.getCollection();
-            if ((serviceBindings == null) || (serviceBindings.size() == 0))
-            {
-                return "could not find service bindings for DeadLetterService" ;
-            }
-            
-            for(ServiceBinding serviceBinding: serviceBindings)
-            {
-                final Service bindingService = serviceBinding.getService() ;
-                if (bindingService == null)
+                final RegistryService rs = connection.getRegistryService();
+                final BusinessQueryManager bqm = rs.getBusinessQueryManager();
+                final BulkResponse bulkResponse = bqm.findServiceBindings(service.getKey(),null,null,null);
+                if (bulkResponse.getStatus()!=JAXRResponse.STATUS_SUCCESS)
                 {
-                    return "Could not find service associated with binding" ;
+                    return "findServiceBindings failed" ;
                 }
-                if (bindingService.getProvidingOrganization() != null)
+                final Collection<ServiceBinding> serviceBindings = (Collection<ServiceBinding>)bulkResponse.getCollection();
+                if ((serviceBindings == null) || (serviceBindings.size() == 0))
                 {
-                    return "FAILED: Organization is present in service binding" ;
+                    return "could not find service bindings for DeadLetterService" ;
                 }
+                
+                for(ServiceBinding serviceBinding: serviceBindings)
+                {
+                    final Service bindingService = serviceBinding.getService() ;
+                    if (bindingService == null)
+                    {
+                        return "Could not find service associated with binding" ;
+                    }
+                    if (bindingService.getProvidingOrganization() != null)
+                    {
+                        return "FAILED: Organization is present in service binding" ;
+                    }
+                }
+                
+                return null ;
             }
-            
-            return null ;
+            finally
+            {
+                scoutConnectionFactory.closeConnection(connection) ;
+            }
         }
     }
     
@@ -185,5 +218,10 @@
         {
             return super.getConnection() ;
         }
+        
+        public void closeConnection(Connection connection)
+        {
+            super.closeConnection(connection) ;
+        }
     }
 }

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServerMBean.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServerMBean.java	2009-04-22 15:39:57 UTC (rev 26211)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServerMBean.java	2009-04-22 18:20:37 UTC (rev 26212)
@@ -40,4 +40,10 @@
     
     public String verifyJUDDICDataIssue()
         throws RegistryException, MarshalException, ServiceNotFoundException ;
+
+    public String verifyServiceRetrieval()
+        throws RegistryException ;
+
+    public String verifyOrganizationalStructure()
+        throws RegistryException, JAXRException ;
 }

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/junit/src/org/jboss/soa/esb/server/aop/AOPUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/junit/src/org/jboss/soa/esb/server/aop/AOPUnitTest.java	2009-04-22 15:39:57 UTC (rev 26211)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/junit/src/org/jboss/soa/esb/server/aop/AOPUnitTest.java	2009-04-22 18:20:37 UTC (rev 26212)
@@ -75,6 +75,34 @@
     }
     
     /**
+     * Test service retrieval.
+     * @throws Exception For any failures.
+     */
+    public void testServiceRetrievalIssue()
+        throws Exception
+    {
+        final String result = (String)execute("verifyServiceRetrieval", null, null) ;
+        if (result != null)
+        {
+            fail(result) ;
+        }
+    }
+    
+    /**
+     * Test for scout performance issue.
+     * @throws Exception For any failures.
+     */
+    public void testOrganizationalStructureIssue()
+        throws Exception
+    {
+        final String result = (String)execute("verifyOrganizationalStructure", null, null) ;
+        if (result != null)
+        {
+            fail(result) ;
+        }
+    }
+    
+    /**
      * Execute the specified method on the mbean.
      * @param method The method name.
      * @param values The parmeter values.




More information about the jboss-svn-commits mailing list