[jboss-svn-commits] JBL Code SVN: r32774 - labs/jbossesb/branches/JBESB_4_4_GA_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
Fri May 7 05:20:03 EDT 2010
Author: kevin.conner at jboss.com
Date: 2010-05-07 05:20:02 -0400 (Fri, 07 May 2010)
New Revision: 32774
Modified:
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
Log:
Performance improvements for JAXRRegistryImpl: JBESB-3306
Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java 2010-05-06 21:27:24 UTC (rev 32773)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java 2010-05-07 09:20:02 UTC (rev 32774)
@@ -75,6 +75,7 @@
private static Logger logger = Logger.getLogger(JAXRRegistryImpl.class);
private JAXRConnectionFactory jaxrConnectionFactory;
private Organization jbossESBOrganization;
+ private ClassificationScheme jbossESBScheme;
private static Concept jbossTModel;
public static final String JBOSS_ESB_CATEGORY = "org.jboss.soa.esb.:category";
@@ -97,10 +98,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, JBOSS_ESB_CATEGORY);
+ ClassificationScheme cScheme = getClassificationScheme(bqm, blm);
Classification classification = blm.createClassification(cScheme, "category", category);
service.addClassification(classification);
service.setProvidingOrganization(organization);
@@ -172,10 +170,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, JBOSS_ESB_CATEGORY);
+ ClassificationScheme cScheme = getClassificationScheme(bqm, blm);
Classification classification = blm.createClassification(cScheme, "category", category);
service.addClassification(classification);
@@ -202,7 +197,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();
@@ -218,7 +213,6 @@
logger.error(ue.getMessage(), ue);
}
}
- String toBeDeletedEPRXml = EPRHelper.toXMLString(toBeDeletedEPR).trim();
if (eprXML.equals(toBeDeletedEPRXml)) {
RegistryService rs = connection.getRegistryService();
BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
@@ -300,18 +294,7 @@
//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);
- ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, JBOSS_ESB_CATEGORY);
- Classification classification = blm.createClassification(cScheme, "category", category);
-
- SpecificationLink sl = new SpecificationLinkImpl(blm);
- sl.setSpecificationObject(jbossTModel);
- serviceBinding.getSpecificationLinks().add(sl);
- @SuppressWarnings("unused")
String eprXML = serviceBinding.getAccessURI();
EPR epr = null;
//for backwards compatibility still have the decoder if
@@ -360,9 +343,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
@@ -456,25 +436,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, JBOSS_ESB_CATEGORY);
+ 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(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);
- }
Classification classification =
blm.createClassification(
cScheme,
@@ -483,6 +446,10 @@
Collection<String> namePatterns = new ArrayList<String>();
namePatterns.add(serviceName);
//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, null);
@@ -527,10 +494,7 @@
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, JBOSS_ESB_CATEGORY);
+ ClassificationScheme cScheme = getClassificationScheme(bqm, blm);
//Create classification
Classification classification =
blm.createClassification(
@@ -538,8 +502,8 @@
"category", category );
// Define find qualifiers and name patterns
- //Collection<String> findQualifiers = new ArrayList<String>();
- //findQualifiers.add(FindQualifier.AND_ALL_KEYS);
+ 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);
@@ -765,6 +729,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
@@ -775,6 +771,15 @@
@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;
+ }
if (jbossTModel == null) {
try {
jbossTModel = getJBossESBTModel(jaxrConnectionFactory);
More information about the jboss-svn-commits
mailing list