[jboss-svn-commits] JBL Code SVN: r25286 - in labs/jbossesb/trunk/product: rosetta/src/org/jboss/soa/esb/client and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Feb 15 23:12:08 EST 2009
Author: beve
Date: 2009-02-15 23:12:08 -0500 (Sun, 15 Feb 2009)
New Revision: 25286
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/RegistryUtil.java
labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingAsyncAction.java
labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingSyncAction.java
Log:
Attempting to fix the build and test. Addtional work for https://jira.jboss.org/jira/browse/JBESB-2097 "ServiceInvoker Exception details"
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java 2009-02-16 01:18:12 UTC (rev 25285)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java 2009-02-16 04:12:08 UTC (rev 25286)
@@ -68,47 +68,47 @@
*/
public class JAXRRegistryImpl implements Registry
{
- private static Logger logger = Logger.getLogger(JAXRRegistryImpl.class);
+ private static Logger logger = Logger.getLogger(JAXRRegistryImpl.class);
private JAXRConnectionFactory jaxrConnectionFactory;
- private static Organization jbossESBOrganization;
- public static final String JBOSS_ESB_CATEGORY = "org.jboss.soa.esb.:category";
-
+ private static Organization jbossESBOrganization;
+ public static final String JBOSS_ESB_CATEGORY = "org.jboss.soa.esb.:category";
+
public JAXRRegistryImpl() throws ConfigurationException {
jaxrConnectionFactory = new JAXRConnectionFactory();
}
/**
- * Publish an EPR to the Registry
- */
- protected Service registerService(String category, String serviceName, String serviceDescription) throws JAXRException
- {
- Service service =null;
- Organization organization = getJBossESBOrganization();
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
- RegistryService rs = connection.getRegistryService();
+ * Publish an EPR to the Registry
+ */
+ protected Service registerService(String category, String serviceName, String serviceDescription) throws JAXRException
+ {
+ Service service =null;
+ Organization organization = getJBossESBOrganization();
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+ RegistryService rs = connection.getRegistryService();
BusinessQueryManager bqm = rs.getBusinessQueryManager();
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
- //Adding the category as prefix for the name
- service = blm.createService(blm.createInternationalString(serviceName));
- service.setDescription(blm.createInternationalString(serviceDescription));
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ //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 = bqm.findClassificationSchemeByName(findQualifiers, JBOSS_ESB_CATEGORY);
Classification classification = blm.createClassification(cScheme, "category", category);
- service.addClassification(classification);
- organization.addService(service);
- saveRegistryObject(service, jaxrConnectionFactory);
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- return service;
- }
- /**
- * Remove an EPR from the Registry
- */
- @SuppressWarnings("unchecked")
+ service.addClassification(classification);
+ organization.addService(service);
+ saveRegistryObject(service, jaxrConnectionFactory);
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ return service;
+ }
+ /**
+ * Remove an EPR from the Registry
+ */
+ @SuppressWarnings("unchecked")
public void unRegisterService(String category, String serviceName) throws RegistryException, ServiceNotFoundException{
// first find the ServiceBindings for this service
Connection connection = jaxrConnectionFactory.getConnection();
@@ -128,13 +128,13 @@
} finally {
jaxrConnectionFactory.closeConnection(connection);
}
- }
- /**
- * Publish an EPR to the Registry
- */
- public void registerEPR(String category, String serviceName, String serviceDescription, EPR epr, String eprDescription)
- throws RegistryException
- {
+ }
+ /**
+ * Publish an EPR to the Registry
+ */
+ public void registerEPR(String category, String serviceName, String serviceDescription, EPR epr, String eprDescription)
+ throws RegistryException
+ {
Connection connection = jaxrConnectionFactory.getConnection();
try {
//Find the service
@@ -171,10 +171,10 @@
jaxrConnectionFactory.closeConnection(connection);
}
}
- /**
- * Remove an EPR from the Registry
- */
- public void unRegisterEPR(String category, String serviceName, EPR toBeDeletedEPR) throws RegistryException, ServiceNotFoundException{
+ /**
+ * Remove an EPR from the Registry
+ */
+ public void unRegisterEPR(String category, String serviceName, EPR toBeDeletedEPR) throws RegistryException, ServiceNotFoundException{
//first find the ServiceBindings for this service
Connection connection = jaxrConnectionFactory.getConnection();
Service service = null;
@@ -184,10 +184,8 @@
throw new ServiceNotFoundException("No such Service found for service with category= "
+ category + " and name = " + serviceName);
}
- boolean deleted = false;
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();
@@ -203,20 +201,18 @@
logger.error(ue.getMessage(), ue);
}
}
+ String toBeDeletedEPRXml = EPRHelper.toXMLString(toBeDeletedEPR).trim();
if (eprXML.equals(toBeDeletedEPRXml)) {
- logger.debug("Unregistering " + toBeDeletedEPR);
RegistryService rs = connection.getRegistryService();
BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
Collection<Key> serviceBindingKeys = new ArrayList<Key>();
serviceBindingKeys.add(serviceBinding.getKey());
blm.deleteServiceBindings(serviceBindingKeys);
- deleted = true;
+ return;
}
}
- if (!deleted) {
- throw new RegistryException("No such EPR found for service with name = "
+ throw new RegistryException("No such EPR found for service with name = "
+ serviceName + " and EPR=" + toBeDeletedEPR);
- }
} catch (JAXRException je) {
throw new RegistryException(je.getLocalizedMessage(), je);
} catch (MarshalException me) {
@@ -225,66 +221,66 @@
jaxrConnectionFactory.closeConnection(connection);
}
}
-
- /**
- * {@inheritDoc}
- * @return collection services
- */
- public List<String> findAllServices() throws RegistryException
- {
- 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();
- serviceNames.add(serviceName);
- }
- } catch (JAXRException je) {
- throw new RegistryException(je.getLocalizedMessage(), je);
- }
- return serviceNames;
- }
- /**
- * Find Services based on a category ("transformation").
- *
- * @return collection services
- */
- public List<String> findServices(String category) throws RegistryException
- {
- List<String>serviceNames = new ArrayList<String>();
+
+ /**
+ * {@inheritDoc}
+ * @return collection services
+ */
+ public List<String> findAllServices() throws RegistryException
+ {
+ 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();
+ serviceNames.add(serviceName);
+ }
+ } catch (JAXRException je) {
+ throw new RegistryException(je.getLocalizedMessage(), je);
+ }
+ return serviceNames;
+ }
+ /**
+ * Find Services based on a category ("transformation").
+ *
+ * @return collection services
+ */
+ public List<String> findServices(String category) throws RegistryException
+ {
+ List<String>serviceNames = new ArrayList<String>();
try {
- Collection<Service>services = findServicesForCategory(category);
- for (Iterator<Service> i=services.iterator();i.hasNext();) {
- String serviceName = i.next().getName().getValue();
- serviceNames.add(serviceName);
- }
- } catch (JAXRException je) {
- throw new RegistryException(je.getLocalizedMessage(), je);
- }
- return serviceNames;
- }
- /**
- *
- * @return
- */
- public List<EPR> findEPRs(String category, String serviceName) throws RegistryException, ServiceNotFoundException
- {
- List<EPR> eprs = new ArrayList<EPR>();
+ Collection<Service>services = findServicesForCategory(category);
+ for (Iterator<Service> i=services.iterator();i.hasNext();) {
+ String serviceName = i.next().getName().getValue();
+ serviceNames.add(serviceName);
+ }
+ } catch (JAXRException je) {
+ throw new RegistryException(je.getLocalizedMessage(), je);
+ }
+ return serviceNames;
+ }
+ /**
+ *
+ * @return
+ */
+ public List<EPR> findEPRs(String category, String serviceName) throws RegistryException, ServiceNotFoundException
+ {
+ List<EPR> eprs = new ArrayList<EPR>();
Connection connection = jaxrConnectionFactory.getConnection();
- try {
- Service service = findService(category, serviceName);
- if (service==null){
+ try {
+ Service service = findService(category, serviceName);
+ if (service==null){
throw new ServiceNotFoundException("Could not find service with category=" + category + " and serviceName=" + serviceName);
- }
- // Get registry service and business query manager
- Collection<ServiceBinding> serviceBindings = findServiceBindings(service);
- //Converting them to EPRs
- for (Iterator i=serviceBindings.iterator();i.hasNext();) {
- ServiceBinding serviceBinding = (ServiceBinding) i.next();
- @SuppressWarnings("unused")
- String eprXML = serviceBinding.getAccessURI();
+ }
+ // Get registry service and business query manager
+ Collection<ServiceBinding> serviceBindings = findServiceBindings(service);
+ //Converting them to EPRs
+ for (Iterator i=serviceBindings.iterator();i.hasNext();) {
+ ServiceBinding serviceBinding = (ServiceBinding) i.next();
+ @SuppressWarnings("unused")
+ String eprXML = serviceBinding.getAccessURI();
EPR epr = null;
//for backwards compatibility still have the decoder if
//unmarchalling fails
@@ -301,22 +297,22 @@
throw new UnmarshalException(ue.getMessage(), ue);
}
}
- }
- } catch (JAXRException je) {
- throw new RegistryException(je.getLocalizedMessage(), je);
+ }
+ } catch (JAXRException je) {
+ throw new RegistryException(je.getLocalizedMessage(), je);
} catch (UnmarshalException me) {
throw new RegistryException(me.getLocalizedMessage(), me);
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- return eprs;
- }
- /**
- *
- * @return
- */
- public EPR findEPR(String category, String serviceName) throws RegistryException, ServiceNotFoundException
- {
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ return eprs;
+ }
+ /**
+ *
+ * @return
+ */
+ public EPR findEPR(String category, String serviceName) throws RegistryException, ServiceNotFoundException
+ {
EPR epr = null ;
Connection connection = jaxrConnectionFactory.getConnection();
try {
@@ -352,75 +348,75 @@
}
return epr;
- }
+ }
/**
- * Find all Organizations with a name mathing the queryString parameter.
- *
- * @param organizationName used to match with the name of the organization.
- * @return the Organization.
- */
+ * Find all Organizations with a name mathing the queryString parameter.
+ *
+ * @param organizationName used to match with the name of the organization.
+ * @return the Organization.
+ */
public static Organization findOrganization(String organizationName, JAXRConnectionFactory jaxrConnectionFactory) throws JAXRException {
- if (organizationName==null) {
- organizationName="";
- }
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
- // Get registry service and business query manager
- RegistryService rs = connection.getRegistryService();
- BusinessQueryManager bqm = rs.getBusinessQueryManager();
- // Define find qualifiers and name patterns
- Collection<String> findQualifiers = new ArrayList<String>();
- findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
- Collection<String> namePatterns = new ArrayList<String>();
- namePatterns.add("%" + organizationName + "%");
- //Find based upon qualifier type and values
- logger.log(Level.DEBUG,"Going to query the registry for name pattern " + namePatterns);
- BulkResponse response = bqm.findOrganizations(findQualifiers,
- namePatterns, null, null, null, null);
- if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
- for (Iterator orgIter = response.getCollection().iterator(); orgIter.hasNext();)
- {
- Organization org = (Organization) orgIter.next();
- logger.log(Level.DEBUG, "Organization name: " + org.getName().getValue());
- logger.log(Level.DEBUG, "Description: " + org.getDescription().getValue());
- logger.log(Level.DEBUG, "Key id: " + org.getKey().getId());
- User primaryContact = org.getPrimaryContact();
- logger.log(Level.DEBUG, "Primary Contact: " + primaryContact.getPersonName().getFullName());
- if (orgIter.hasNext()) {
- logger.log(Level.ERROR, "Found " + response.getCollection().size()
- + " Organization, while expecting only one of name " + organizationName);
- }
- return org;
- }
- }
- return null;
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
+ if (organizationName==null) {
+ organizationName="";
+ }
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+ // Get registry service and business query manager
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ // Define find qualifiers and name patterns
+ Collection<String> findQualifiers = new ArrayList<String>();
+ findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
+ Collection<String> namePatterns = new ArrayList<String>();
+ namePatterns.add("%" + organizationName + "%");
+ //Find based upon qualifier type and values
+ logger.log(Level.DEBUG,"Going to query the registry for name pattern " + namePatterns);
+ BulkResponse response = bqm.findOrganizations(findQualifiers,
+ namePatterns, null, null, null, null);
+ if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
+ for (Iterator orgIter = response.getCollection().iterator(); orgIter.hasNext();)
+ {
+ Organization org = (Organization) orgIter.next();
+ logger.log(Level.DEBUG, "Organization name: " + org.getName().getValue());
+ logger.log(Level.DEBUG, "Description: " + org.getDescription().getValue());
+ logger.log(Level.DEBUG, "Key id: " + org.getKey().getId());
+ User primaryContact = org.getPrimaryContact();
+ logger.log(Level.DEBUG, "Primary Contact: " + primaryContact.getPersonName().getFullName());
+ if (orgIter.hasNext()) {
+ logger.log(Level.ERROR, "Found " + response.getCollection().size()
+ + " Organization, while expecting only one of name " + organizationName);
+ }
+ return org;
+ }
+ }
+ return null;
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ }
/**
- *
- * @param category
- * @param serviceName
- * @return Service
- */
- protected Service findService(String category, String serviceName) throws JAXRException
- {
- if (category==null) {
- category="";
- }
- if (serviceName==null) {
- serviceName="";
- }
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
- // Get registry service and business query manager
- RegistryService rs = connection.getRegistryService();
- BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ *
+ * @param category
+ * @param serviceName
+ * @return Service
+ */
+ protected Service findService(String category, String serviceName) throws JAXRException
+ {
+ if (category==null) {
+ category="";
+ }
+ if (serviceName==null) {
+ serviceName="";
+ }
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+ // Get registry service and business query manager
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
- // Define find qualifiers and name patterns
+ // Define find qualifiers and name patterns
Collection<String> findQualifiers = new ArrayList<String>();
findQualifiers.add(FindQualifier.AND_ALL_KEYS);
findQualifiers.add(FindQualifier.EXACT_NAME_MATCH);
@@ -429,67 +425,67 @@
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>();
+ 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);
+ } catch (Exception e) {
+ throw new JAXRException(e);
+ }
+ cScheme = bqm.findClassificationSchemeByName(findQualifiers, JBOSS_ESB_CATEGORY);
}
Classification classification =
blm.createClassification(
cScheme,
"category", category );
classifications.add(classification);
- Collection<String> namePatterns = new ArrayList<String>();
- namePatterns.add(serviceName);
- //Find based upon qualifier type and values
- logger.log(Level.DEBUG, "Going to query the registry for name pattern " + namePatterns);
- BulkResponse response = bqm.findServices(null, findQualifiers,
- namePatterns, classifications, null);
- if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
- for (Iterator servIter = response.getCollection().iterator(); servIter.hasNext();)
- {
- Service service = (Service) servIter.next();
- logger.log(Level.DEBUG, "Service name: " + service.getName().getValue());
- if (service.getDescription()!=null) {
- logger.log(Level.DEBUG, "Description: " + service.getDescription().getValue());
- }
- logger.log(Level.DEBUG, "Key id: " + service.getKey().getId());
- if (servIter.hasNext()) {
- logger.log(Level.ERROR, "Found " + response.getCollection().size()
- + " Services, while expecting only one by the name of "
- + serviceName + " in category " + category);
- }
- return service;
- }
- }
- return null;
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
+ Collection<String> namePatterns = new ArrayList<String>();
+ namePatterns.add(serviceName);
+ //Find based upon qualifier type and values
+ logger.log(Level.DEBUG, "Going to query the registry for name pattern " + namePatterns);
+ BulkResponse response = bqm.findServices(null, findQualifiers,
+ namePatterns, classifications, null);
+ if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
+ for (Iterator servIter = response.getCollection().iterator(); servIter.hasNext();)
+ {
+ Service service = (Service) servIter.next();
+ logger.log(Level.DEBUG, "Service name: " + service.getName().getValue());
+ if (service.getDescription()!=null) {
+ logger.log(Level.DEBUG, "Description: " + service.getDescription().getValue());
+ }
+ logger.log(Level.DEBUG, "Key id: " + service.getKey().getId());
+ if (servIter.hasNext()) {
+ logger.log(Level.ERROR, "Found " + response.getCollection().size()
+ + " Services, while expecting only one by the name of "
+ + serviceName + " in category " + category);
+ }
+ return service;
+ }
+ }
+ return null;
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ }
/**
- * Finds all services for a given category.
- * @param category
- * @return Service
- */
- @SuppressWarnings("unchecked")
- protected Collection<Service> findServicesForCategory(String category) throws JAXRException
- {
- Collection<Service> services = new ArrayList<Service>();
- if (category==null) {
- category="";
- }
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
- // Get registry service and business query manager
- RegistryService rs = connection.getRegistryService();
- BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ * Finds all services for a given category.
+ * @param category
+ * @return Service
+ */
+ @SuppressWarnings("unchecked")
+ protected Collection<Service> findServicesForCategory(String category) throws JAXRException
+ {
+ Collection<Service> services = new ArrayList<Service>();
+ if (category==null) {
+ category="";
+ }
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+ // Get registry service and business query manager
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
Collection<String> findQualifiers = new ArrayList<String>();
findQualifiers.add(FindQualifier.AND_ALL_KEYS);
@@ -501,197 +497,197 @@
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>();
+ // 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
- logger.log(Level.DEBUG, "Going to query the registry for classification " + classifications);
- BulkResponse response = bqm.findServices(null, findQualifiers,
- null, classifications, null);
- if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
- services = (Collection<Service>) response.getCollection();
- }
- return services;
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
+ //Find based upon qualifier type and values
+ logger.log(Level.DEBUG, "Going to query the registry for classification " + classifications);
+ BulkResponse response = bqm.findServices(null, findQualifiers,
+ null, classifications, 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
- * @throws JAXRException
- */
+ * Create a jbossesb organization under which we will register all our services.
+ *
+ * @return
+ * @throws JAXRException
+ */
protected static Organization createJBossESBOrganization(JAXRConnectionFactory jaxrConnectionFactory) throws JAXRException
- {
-// Getting the connection to the Registry (reading config)
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
- //Logging in
- RegistryService rs = connection.getRegistryService();
- //Building organization
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
- Organization organization = blm.createOrganization(blm.createInternationalString("Red Hat/JBossESB"));
- organization.setDescription(blm.createInternationalString("Red Hat/JBoss Professional Open Source, Services for the JBossESB"));
+ {
+// Getting the connection to the Registry (reading config)
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+ //Logging in
+ RegistryService rs = connection.getRegistryService();
+ //Building organization
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ Organization organization = blm.createOrganization(blm.createInternationalString("Red Hat/JBossESB"));
+ organization.setDescription(blm.createInternationalString("Red Hat/JBoss Professional Open Source, Services for the JBossESB"));
- User user = blm.createUser();
- organization.setPrimaryContact(user);
- PersonName personName = blm.createPersonName("JBossESB");
- TelephoneNumber telephoneNumber = blm.createTelephoneNumber();
- telephoneNumber.setNumber("404 467-8555");
- telephoneNumber.setType(null);
- PostalAddress address = blm.createPostalAddress("3340",
- "Peachtree Road, NE, Suite 1200", "Atlanta", "GA", "USA",
- "30326", "");
- Collection<PostalAddress> postalAddresses = new ArrayList<PostalAddress>();
- postalAddresses.add(address);
- Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
- EmailAddress emailAddress = blm
- .createEmailAddress("jbossesb at jboss.com");
- emailAddresses.add(emailAddress);
+ User user = blm.createUser();
+ organization.setPrimaryContact(user);
+ PersonName personName = blm.createPersonName("JBossESB");
+ TelephoneNumber telephoneNumber = blm.createTelephoneNumber();
+ telephoneNumber.setNumber("404 467-8555");
+ telephoneNumber.setType(null);
+ PostalAddress address = blm.createPostalAddress("3340",
+ "Peachtree Road, NE, Suite 1200", "Atlanta", "GA", "USA",
+ "30326", "");
+ Collection<PostalAddress> postalAddresses = new ArrayList<PostalAddress>();
+ postalAddresses.add(address);
+ Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
+ EmailAddress emailAddress = blm
+ .createEmailAddress("jbossesb at jboss.com");
+ emailAddresses.add(emailAddress);
- Collection<TelephoneNumber> numbers = new ArrayList<TelephoneNumber>();
- numbers.add(telephoneNumber);
- user.setPersonName(personName);
- user.setPostalAddresses(postalAddresses);
- user.setEmailAddresses(emailAddresses);
- user.setTelephoneNumbers(numbers);
+ Collection<TelephoneNumber> numbers = new ArrayList<TelephoneNumber>();
+ numbers.add(telephoneNumber);
+ user.setPersonName(personName);
+ user.setPostalAddresses(postalAddresses);
+ user.setEmailAddresses(emailAddresses);
+ user.setTelephoneNumbers(numbers);
- // Scout does not support this (yet), so leaving it out for now.
- // ClassificationScheme cScheme = getClassificationScheme(blm,
- // blm.createInternationalString("uddi-org:general_keywords"), blm.createInternationalString(""));
- // Classification classification = blm.createClassification(cScheme,
- // blm.createInternationalString("JBoss ESB"), blm.createInternationalString("JBESB"));
- // org.addClassification(classification);
+ // Scout does not support this (yet), so leaving it out for now.
+ // ClassificationScheme cScheme = getClassificationScheme(blm,
+ // blm.createInternationalString("uddi-org:general_keywords"), blm.createInternationalString(""));
+ // Classification classification = blm.createClassification(cScheme,
+ // blm.createInternationalString("JBoss ESB"), blm.createInternationalString("JBESB"));
+ // org.addClassification(classification);
- saveRegistryObject(organization, jaxrConnectionFactory);
- return organization;
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
+ saveRegistryObject(organization, jaxrConnectionFactory);
+ return organization;
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ }
/**
- * Save Registry Object
- */
- private static void saveRegistryObject(RegistryObject registryObject, JAXRConnectionFactory jaxrConnectionFactory) throws JAXRException
- {
-// Getting the connection to the Registry (reading config)
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
+ * Save Registry Object
+ */
+ private static void saveRegistryObject(RegistryObject registryObject, JAXRConnectionFactory jaxrConnectionFactory) throws JAXRException
+ {
+// Getting the connection to the Registry (reading config)
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
- BulkResponse br = null;
- //Logging in
- RegistryService rs = connection.getRegistryService();
- //Building organization
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ BulkResponse br = null;
+ //Logging in
+ RegistryService rs = connection.getRegistryService();
+ //Building organization
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
- Class[] interfaces = registryObject.getClass().getInterfaces();
- String interfaceName ="";
- for (int i=0; i<interfaces.length; i++) {
- interfaceName = interfaces[i].getName();
- if (interfaceName.equals("javax.xml.registry.infomodel.Organization")) {
+ Class[] interfaces = registryObject.getClass().getInterfaces();
+ String interfaceName ="";
+ for (int i=0; i<interfaces.length; i++) {
+ interfaceName = interfaces[i].getName();
+ if (interfaceName.equals("javax.xml.registry.infomodel.Organization")) {
Collection<Organization> orginations = new ArrayList<Organization>();
orginations.add((Organization) registryObject);
- br = blm.saveOrganizations(orginations);
- break;
- } else if (interfaceName.equals("javax.xml.registry.infomodel.Service")) {
+ br = blm.saveOrganizations(orginations);
+ break;
+ } else if (interfaceName.equals("javax.xml.registry.infomodel.Service")) {
Collection<Service> services = new ArrayList<Service>();
services.add((Service) registryObject);
- br = blm.saveServices(services);
- break;
- } else if (interfaceName.equals("javax.xml.registry.infomodel.ServiceBinding")) {
+ br = blm.saveServices(services);
+ break;
+ } else if (interfaceName.equals("javax.xml.registry.infomodel.ServiceBinding")) {
Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
serviceBindings.add((ServiceBinding) registryObject);
br = blm.saveServiceBindings(serviceBindings);
- break;
- } else {
- logger.log(Level.ERROR, "Trying to save an unsupported RegistryObject");
- throw new JAXRException("Trying to save an unsupported RegistryObject");
- }
- }
+ break;
+ } else {
+ logger.log(Level.ERROR, "Trying to save an unsupported RegistryObject");
+ throw new JAXRException("Trying to save an unsupported RegistryObject");
+ }
+ }
//Verify the return
- if (br!=null && br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
- logger.log(Level.DEBUG, interfaceName + " successfully saved");
- Collection coll = br.getCollection();
- Iterator iter = coll.iterator();
- while (iter.hasNext()) {
- Key key = (Key) iter.next();
- registryObject.setKey(key);
- logger.log(Level.DEBUG, "Saved Key=" + key.getId());
- }
- } else {
- logger.log(Level.ERROR, "Errors occurred during save.");
- if (br!=null) {
- Collection exceptions = br.getExceptions();
- Iterator iter = exceptions.iterator();
- String errors = "";
- JAXRException je = new JAXRException("JAXRExceptions occurred during save");
- while (iter.hasNext()) {
- Exception e = (Exception) iter.next();
- errors += e.getLocalizedMessage() + "\n";
- je.setStackTrace(e.getStackTrace());
- logger.log(Level.ERROR, e.getLocalizedMessage(), e);
- //if it's the last error, throw it now and set the current stacktrace
- if (!iter.hasNext()) {
- throw new JAXRException(errors, e);
- }
- }
- throw new JAXRException("Errors occurred during save. Response status=" + br.getStatus());
- }
- throw new JAXRException("Errors occurred during save");
- }
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
+ if (br!=null && br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
+ logger.log(Level.DEBUG, interfaceName + " successfully saved");
+ Collection coll = br.getCollection();
+ Iterator iter = coll.iterator();
+ while (iter.hasNext()) {
+ Key key = (Key) iter.next();
+ registryObject.setKey(key);
+ logger.log(Level.DEBUG, "Saved Key=" + key.getId());
+ }
+ } else {
+ logger.log(Level.ERROR, "Errors occurred during save.");
+ if (br!=null) {
+ Collection exceptions = br.getExceptions();
+ Iterator iter = exceptions.iterator();
+ String errors = "";
+ JAXRException je = new JAXRException("JAXRExceptions occurred during save");
+ while (iter.hasNext()) {
+ Exception e = (Exception) iter.next();
+ errors += e.getLocalizedMessage() + "\n";
+ je.setStackTrace(e.getStackTrace());
+ logger.log(Level.ERROR, e.getLocalizedMessage(), e);
+ //if it's the last error, throw it now and set the current stacktrace
+ if (!iter.hasNext()) {
+ throw new JAXRException(errors, e);
+ }
+ }
+ throw new JAXRException("Errors occurred during save. Response status=" + br.getStatus());
+ }
+ throw new JAXRException("Errors occurred during save");
+ }
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ }
/**
- * finds the JBossESB Organizationa and creates one if it is not there.
- * @return JBossESB Organization
- * @throws JAXRException
- */
- private Organization getJBossESBOrganization() throws JAXRException
- {
- jbossESBOrganization = findOrganization("Red Hat/JBossESB", jaxrConnectionFactory);
- if (jbossESBOrganization==null) {
- jbossESBOrganization = createJBossESBOrganization(jaxrConnectionFactory);
- }
- return jbossESBOrganization;
- }
+ * finds the JBossESB Organizationa and creates one if it is not there.
+ * @return JBossESB Organization
+ * @throws JAXRException
+ */
+ private Organization getJBossESBOrganization() throws JAXRException
+ {
+ jbossESBOrganization = findOrganization("Red Hat/JBossESB", jaxrConnectionFactory);
+ if (jbossESBOrganization==null) {
+ jbossESBOrganization = createJBossESBOrganization(jaxrConnectionFactory);
+ }
+ return jbossESBOrganization;
+ }
/**
- * Find the ServiceBindings for a given Service
- * @param service
- * @return
- * @throws RegistryException
- */
- @SuppressWarnings("unchecked")
- private Collection<ServiceBinding> findServiceBindings(Service service) throws RegistryException
- {
- Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
- RegistryService rs = connection.getRegistryService();
- BusinessQueryManager bqm = rs.getBusinessQueryManager();
- Collection<String> findQualifiers = null;
- //Collection<String> findQualifiers = new ArrayList<String>();
- //findQualifiers.add(FindQualifier.SORT_BY_DATE_ASC);
- BulkResponse bulkResponse = bqm.findServiceBindings(service.getKey(),findQualifiers,null,null);
- if (bulkResponse.getStatus()==JAXRResponse.STATUS_SUCCESS){
- serviceBindings = (Collection<ServiceBinding>)bulkResponse.getCollection();
- }
- return serviceBindings;
- } catch (Exception je) {
- throw new RegistryException(je.getLocalizedMessage(), je);
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
+ * Find the ServiceBindings for a given Service
+ * @param service
+ * @return
+ * @throws RegistryException
+ */
+ @SuppressWarnings("unchecked")
+ private Collection<ServiceBinding> findServiceBindings(Service service) throws RegistryException
+ {
+ Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ Collection<String> findQualifiers = null;
+ //Collection<String> findQualifiers = new ArrayList<String>();
+ //findQualifiers.add(FindQualifier.SORT_BY_DATE_ASC);
+ BulkResponse bulkResponse = bqm.findServiceBindings(service.getKey(),findQualifiers,null,null);
+ if (bulkResponse.getStatus()==JAXRResponse.STATUS_SUCCESS){
+ serviceBindings = (Collection<ServiceBinding>)bulkResponse.getCollection();
+ }
+ return serviceBindings;
+ } catch (Exception je) {
+ throw new RegistryException(je.getLocalizedMessage(), je);
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ }
}
-
+
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java 2009-02-16 01:18:12 UTC (rev 25285)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java 2009-02-16 04:12:08 UTC (rev 25286)
@@ -43,9 +43,9 @@
import org.jboss.soa.esb.couriers.Courier;
import org.jboss.soa.esb.couriers.CourierException;
import org.jboss.soa.esb.couriers.CourierFactory;
-import org.jboss.soa.esb.couriers.CourierTimeoutException;
import org.jboss.soa.esb.couriers.CourierMarshalUnmarshalException;
import org.jboss.soa.esb.couriers.CourierServiceBindException;
+import org.jboss.soa.esb.couriers.CourierTimeoutException;
import org.jboss.soa.esb.couriers.CourierTransportException;
import org.jboss.soa.esb.couriers.CourierUtil;
import org.jboss.soa.esb.couriers.FaultMessageException;
@@ -165,7 +165,7 @@
try {
Class c = ClassUtil.forName(lbClass, this.getClass());
loadBalancer = (LoadBalancePolicy) c.newInstance();
- loadServiceClusterInfoSilent();
+ tryLoadingServiceClusterInfoSilent();
} catch (ClassNotFoundException clf) {
logger.error("No such LoadBalancePolicy class = " + lbClass);
throw new MessageDeliverException(clf.getMessage(), clf);
@@ -513,16 +513,7 @@
public void loadServiceClusterInfo() throws MessageDeliverException {
List<EPR> serviceEprs = new ArrayList<EPR>();
try {
- serviceEprs = RegistryUtil.getEprs(service.getCategory(), service.getName());
- if (logger.isDebugEnabled()) {
- for (EPR epr : serviceEprs) {
- try {
- logger.debug("EPR=" + epr + " XML=" + EPRHelper.toXMLString(epr));
- } catch (Exception me) {
- logger.error(me.getMessage(), me);
- }
- }
- }
+ serviceEprs = getEPRs(service);
} catch (final ServiceNotFoundException snfe) {
logger.info("Service: " + service + " not found in the registry");
@@ -532,34 +523,48 @@
} catch (final Exception e) {
throw new MessageDeliverException(e.getMessage(), e);
}
- serviceClusterInfo = new ServiceClusterInfoImpl(service.getName(), serviceEprs);
- expirationDate = new Date(java.lang.System.currentTimeMillis() + registryCacheLife);
+ createClusterInfo(service, serviceEprs);
}
/*
* If doing a load at construction time it's possible the registry may not
* be set yet, so we ignore such faults.
*/
+ private final void tryLoadingServiceClusterInfoSilent () throws MessageDeliverException
+ {
+ List<EPR> serviceEprs = new ArrayList<EPR>();
+ try {
+ serviceEprs = getEPRs(service);
+ } catch (final ServiceNotFoundException snfe) {
+ logger.info("Service: " + service + " not found in the registry but service might come online at a later point.");
+ } catch (final Exception e) {
+ throw new MessageDeliverException(e.getMessage(), e);
+ }
+ createClusterInfo(service, serviceEprs);
+ }
- private final void loadServiceClusterInfoSilent () throws MessageDeliverException
+ private void createClusterInfo(final Service service, final List<EPR> eprs)
{
- try
- {
- loadServiceClusterInfo();
- }
- catch (final MessageDeliverException ex)
- {
- // we now throw MessageDeliverException from loadServiceClusterInfo if there's a registry problem ...
-
- if (ex.getCause() instanceof ServiceNotFoundException)
- {
- // assume service is there later
- logger.debug("Problem with registry but will ignore.");
- }
- else
- throw ex;
- }
+ serviceClusterInfo = new ServiceClusterInfoImpl(service.getName(), eprs);
+ expirationDate = new Date(java.lang.System.currentTimeMillis() + registryCacheLife);
}
+
+ private List<EPR> getEPRs(final Service service) throws RegistryException, ServiceNotFoundException
+ {
+ List<EPR> serviceEprs = new ArrayList<EPR>();
+ serviceEprs = RegistryUtil.getEprs(service.getCategory(), service.getName());
+ if (logger.isDebugEnabled()) {
+ for (EPR epr : serviceEprs) {
+ try {
+ logger.debug("EPR=" + epr + " XML=" + EPRHelper.toXMLString(epr));
+ } catch (Exception me) {
+ logger.error(me.getMessage(), me);
+ }
+ }
+ }
+ return serviceEprs;
+ }
+
/*
* Is redelivery overridden on a per message basis? If not, use the global setting.
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/RegistryUtil.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/RegistryUtil.java 2009-02-16 01:18:12 UTC (rev 25285)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/RegistryUtil.java 2009-02-16 04:12:08 UTC (rev 25286)
@@ -144,7 +144,7 @@
logger.debug("Unregistering any existing < " + name + ", " + epr + " >");
}
// https://jira.jboss.org/jira/browse/JBESB-866
- unregister(category, name, epr);
+ unregisterSilent(category, name, epr);
}
if (logger.isDebugEnabled()) {
@@ -198,6 +198,34 @@
}
}
}
+
+ private static void unregisterSilent(final String category, final String name, final EPR epr)
+ {
+ if ("eprManager".equalsIgnoreCase(category))
+ {
+ unregister(name) ;
+ }
+ else
+ {
+ registryLock.lock() ;
+ try
+ {
+ final Registry registry = RegistryFactory.getRegistry() ;
+ registry.unRegisterEPR(category, name, epr) ;
+ }
+ catch (final ServiceNotFoundException snfe) {
+ logger.debug("Failed to unregister service", snfe);
+ }
+ catch (final RegistryException re)
+ {
+ logger.debug("Failed to unregister service", re) ;
+ }
+ finally
+ {
+ registryLock.unlock() ;
+ }
+ }
+ }
/**
* Get the EPRs associated with the specified service.
Modified: labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingAsyncAction.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingAsyncAction.java 2009-02-16 01:18:12 UTC (rev 25285)
+++ labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingAsyncAction.java 2009-02-16 04:12:08 UTC (rev 25286)
@@ -78,7 +78,14 @@
}
Service noneExistingService = new Service("none-exising-category", "none-existing-service-name");
ServiceInvoker si = new ServiceInvoker(noneExistingService);
- si.deliverAsync(message);
+ try
+ {
+ si.deliverAsync(message);
+ }
+ catch (final Exception ignore)
+ {
+ System.out.println("Ignoreing Exception " + ignore.getMessage());
+ }
//Adding this control code to show where the message now is.
Map<URI, Message> rdlvrMessageMap = ms.getAllMessages(MessageStore.CLASSIFICATION_RDLVR);
Modified: labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingSyncAction.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingSyncAction.java 2009-02-16 01:18:12 UTC (rev 25285)
+++ labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingSyncAction.java 2009-02-16 04:12:08 UTC (rev 25286)
@@ -82,7 +82,7 @@
si.deliverSync(message, 1000);
} catch (MessageStoreException mse) {
throw new ActionProcessingException(mse.getMessage(), mse);
- } catch (MessageDeliverException mde) {
+ } catch (RegistryException e) {
//Adding this control code to show where the message now is.
//We should get here on and we should have a message in the DLQ.
try {
@@ -107,8 +107,8 @@
} catch (MessageStoreException mse) {
throw new ActionProcessingException(mse.getMessage(), mse);
}
- } catch (RegistryException re) {
- throw new ActionProcessingException(re.getMessage(), re);
+ } catch (MessageDeliverException e) {
+ throw new ActionProcessingException(e.getMessage(), e);
} catch (FaultMessageException fme) {
throw new ActionProcessingException(fme.getMessage(), fme);
}
More information about the jboss-svn-commits
mailing list