[jboss-svn-commits] JBL Code SVN: r32986 - labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/services/registry.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu May 20 12:53:50 EDT 2010


Author: kevin.conner at jboss.com
Date: 2010-05-20 12:53:49 -0400 (Thu, 20 May 2010)
New Revision: 32986

Modified:
   labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
Log:
Performance changes: JBESB-3326

Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java	2010-05-20 14:34:14 UTC (rev 32985)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java	2010-05-20 16:53:49 UTC (rev 32986)
@@ -77,6 +77,7 @@
 {
 	private static Logger logger = Logger.getLogger(JAXRRegistryImpl.class);
     private JAXRConnectionFactory jaxrConnectionFactory;
+	private ClassificationScheme jbossESBScheme;
 	private static Concept jbossTModelXXX;
 	public static final String JBOSS_ESB_CATEGORY = "org.jboss.soa.esb.:category";
     private static final String REGISTERED_BY_JBOSSESB = "Registered by JBoss ESB";
@@ -103,10 +104,7 @@
 		    //Adding the category as prefix for the name
 			service = blm.createService(blm.createInternationalString(serviceName));
 			service.setDescription(blm.createInternationalString(serviceDescription));
-            Collection<String> findQualifiers = new ArrayList<String>();
-            findQualifiers.add(FindQualifier.AND_ALL_KEYS);
-            findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
-			ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, orgCategory);
+			ClassificationScheme cScheme = getClassificationScheme(bqm, blm);
             Classification classification = blm.createClassification(cScheme, "category", category);
 			service.addClassification(classification);
 			organization.addService(service);
@@ -189,10 +187,7 @@
             serviceBindings.add(serviceBinding);
             
             service.addServiceBindings(serviceBindings);
-            Collection<String> findQualifiers = new ArrayList<String>();
-            findQualifiers.add(FindQualifier.AND_ALL_KEYS);
-            findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
-            ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, orgCategory);
+            ClassificationScheme cScheme = getClassificationScheme(bqm, blm);
             Classification classification = blm.createClassification(cScheme, "category", category);
             service.addClassification(classification);
             
@@ -219,7 +214,7 @@
                         + category + " and name = " + serviceName);
             }
             Collection serviceBindings = findServiceBindings(service);
-            service.addServiceBindings(serviceBindings);
+            String toBeDeletedEPRXml = EPRHelper.toXMLString(toBeDeletedEPR).trim();
             for (Iterator i=serviceBindings.iterator();i.hasNext();){
                 ServiceBinding serviceBinding = (ServiceBinding) i.next();
                 String eprXML = serviceBinding.getAccessURI().trim();
@@ -235,7 +230,6 @@
                         logger.error(ue.getMessage(), ue);
                     }
                 }
-                String toBeDeletedEPRXml = EPRHelper.toXMLString(toBeDeletedEPR).trim();
                 if (eprXML.equals(toBeDeletedEPRXml)) {
                     RegistryService rs = connection.getRegistryService();
                     BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
@@ -317,14 +311,6 @@
 			//Converting them to EPRs
 			for (Iterator i=serviceBindings.iterator();i.hasNext();) {
 				ServiceBinding serviceBinding = (ServiceBinding) i.next();
-				
-	            Collection<String> findQualifiers = new ArrayList<String>();
-	            findQualifiers.add(FindQualifier.AND_ALL_KEYS);
-	            findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
-				
-	            SpecificationLink sl = new SpecificationLinkImpl(blm);
-	            sl.setSpecificationObject(jbossTModel);
-	            serviceBinding.getSpecificationLinks().add(sl);
 
 				String eprXML = serviceBinding.getAccessURI();
                 EPR epr = null;
@@ -374,9 +360,6 @@
             Collection<ServiceBinding> serviceBindings = findServiceBindings(service);
             if (serviceBindings.iterator().hasNext()) {
                 ServiceBinding serviceBinding = (ServiceBinding) serviceBindings.iterator().next();
-                SpecificationLink sl = new SpecificationLinkImpl(blm);
-	            sl.setSpecificationObject(jbossTModel);
-	            serviceBinding.getSpecificationLinks().add(sl);
 
                 String eprXML = serviceBinding.getAccessURI();
                 // for backwards compatibility still have the decoder if
@@ -473,25 +456,8 @@
 			RegistryService rs = connection.getRegistryService();
 			BusinessQueryManager bqm = rs.getBusinessQueryManager();
             BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
-			// Define find qualifiers and name patterns
-            Collection<String> findQualifiers = new ArrayList<String>();
-            findQualifiers.add(FindQualifier.AND_ALL_KEYS);
-            findQualifiers.add(FindQualifier.EXACT_NAME_MATCH);
-            findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
-            ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, orgCategory);
+            final ClassificationScheme cScheme = getClassificationScheme(bqm, blm) ;
             Collection<Classification> classifications = new ArrayList<Classification>();
-            // If the scheme returned null, then we have to create a org.jboss.soa.esb.:category scheme to use
-            if (cScheme == null) {
-            	try {
-            		ClassificationScheme scheme = blm.createClassificationScheme(orgCategory, orgCategory);
-            		ArrayList<ClassificationScheme> cSchemes = new ArrayList<ClassificationScheme>();
-                    cSchemes.add(scheme);
-                    BulkResponse br = blm.saveClassificationSchemes(cSchemes);
-            	} catch (Exception e) {
-            		throw new JAXRException(e);
-            	}
-            	cScheme = bqm.findClassificationSchemeByName(findQualifiers, orgCategory);
-            }
             Classification classification =
                 blm.createClassification(
                   cScheme,
@@ -506,6 +472,10 @@
 			specifications.add(sl);
             
 	        //Find based upon qualifier type and values
+			Collection<String> findQualifiers = new ArrayList<String>();
+			findQualifiers.add(FindQualifier.AND_ALL_KEYS);
+			findQualifiers.add(FindQualifier.EXACT_NAME_MATCH);
+			findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
 			logger.log(Level.DEBUG, "Going to query the registry for name pattern " + namePatterns);
 			BulkResponse response = bqm.findServices(null, findQualifiers,
 					namePatterns, classifications, specifications);
@@ -550,15 +520,17 @@
 			RegistryService rs = connection.getRegistryService();
 			BusinessQueryManager bqm = rs.getBusinessQueryManager();
             BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
-            Collection<String> findQualifiers = new ArrayList<String>();
-            findQualifiers.add(FindQualifier.AND_ALL_KEYS);
-            findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
-            ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, orgCategory);
+            ClassificationScheme cScheme = getClassificationScheme(bqm, blm);
             //Create classification
             Classification classification =
                 blm.createClassification(
                   cScheme,
                   "category", category );
+
+			// Define find qualifiers and name patterns
+            Collection<String> findQualifiers = new ArrayList<String>();
+            findQualifiers.add(FindQualifier.AND_ALL_KEYS);
+			findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
 			Collection<Classification> classifications = new ArrayList<Classification>();
             classifications.add(classification);
 	        //Find based upon qualifier type and values
@@ -751,6 +723,38 @@
 		
 		return jbossESBOrganization;
 	}
+	
+	/**
+	 * finds the JBossESB category classification scheme and creates one if it is not there.
+	 * 
+	 * @return JBossESB category classification scheme
+	 * @throws JAXRException For errors during querying/creating.
+	 */
+	private synchronized ClassificationScheme getClassificationScheme(final BusinessQueryManager bqm, final BusinessLifeCycleManager blm) throws JAXRException
+	{
+		if (jbossESBScheme == null) {
+			// Define find qualifiers and name patterns
+			Collection<String> findQualifiers = new ArrayList<String>();
+			findQualifiers.add(FindQualifier.AND_ALL_KEYS);
+			findQualifiers.add(FindQualifier.EXACT_NAME_MATCH);
+			findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
+			ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, JBOSS_ESB_CATEGORY);
+			// If the scheme returned null, then we have to create a org.jboss.soa.esb.:category scheme to use
+			if (cScheme == null) {
+				try {
+					ClassificationScheme scheme = blm.createClassificationScheme(JBOSS_ESB_CATEGORY, JBOSS_ESB_CATEGORY);
+					ArrayList<ClassificationScheme> cSchemes = new ArrayList<ClassificationScheme>();
+					cSchemes.add(scheme);
+					BulkResponse br = blm.saveClassificationSchemes(cSchemes);
+				} catch (Exception e) {
+					throw new JAXRException(e);
+				}
+				cScheme = bqm.findClassificationSchemeByName(findQualifiers, JBOSS_ESB_CATEGORY);
+			}
+			jbossESBScheme = cScheme ;
+		}
+		return jbossESBScheme ;
+	}
 
     /**
 	 * Find the ServiceBindings for a given Service
@@ -761,6 +765,16 @@
 	@SuppressWarnings("unchecked")
 	private Collection<ServiceBinding> findServiceBindings(Service service) throws RegistryException
 	{
+		final Collection currentBindings ;
+		try {
+			currentBindings = service.getServiceBindings() ;
+		} catch (final JAXRException jaxre) {
+			throw new RegistryException(jaxre.getLocalizedMessage(), jaxre);
+		}
+		if ((currentBindings != null) && (currentBindings.size() > 0)) {
+			return currentBindings;
+		}
+		
 		Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
 		Connection connection = jaxrConnectionFactory.getConnection();
 		try {



More information about the jboss-svn-commits mailing list