[jboss-svn-commits] JBL Code SVN: r7323 - in labs/jbossesb/trunk/product: core/services/src/org/jboss/internal/soa/esb core/services/src/org/jboss/internal/soa/esb/services core/services/src/org/jboss/internal/soa/esb/services/registry core/services/src/org/jboss/internal/soa/esb/services/routing core/services/src/org/jboss/internal/soa/esb/services/routing/cbr core/services/src/org/jboss/soa/esb/services/registry core/services/src/org/jboss/soa/esb/services/routing/cbr core/services/tests/src/org/jboss core/services/tests/src/org/jboss/internal core/services/tests/src/org/jboss/internal/soa core/services/tests/src/org/jboss/internal/soa/esb core/services/tests/src/org/jboss/internal/soa/esb/services core/services/tests/src/org/jboss/internal/soa/esb/services/routing core/services/tests/src/org/jboss/internal/soa/esb/services/routing/cbr core/services/tests/src/org/jboss/soa/esb/services/registry core/services/tests/src/org/jboss/soa/esb/services/routing/cbr etc/test/resources install! /conf

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Nov 2 09:07:21 EST 2006


Author: kurt.stam at jboss.com
Date: 2006-11-02 09:07:16 -0500 (Thu, 02 Nov 2006)
New Revision: 7323

Added:
   labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/services/
   labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/services/registry/
   labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
   labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/services/routing/
   labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/
   labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouter.java
   labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/internal/
   labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/internal/soa/
   labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/internal/soa/esb/
   labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/internal/soa/esb/services/
   labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/internal/soa/esb/services/routing/
   labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/internal/soa/esb/services/routing/cbr/
   labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java
Removed:
   labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java
   labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/routing/cbr/JBossRulesRouter.java
   labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/JAXRRegistryUnitTest.java
   labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java
Modified:
   labs/jbossesb/trunk/product/etc/test/resources/jbossesb-unittest-properties.xml
   labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml
Log:
moving into an internal package

Copied: labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java (from rev 7321, labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java)
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java	2006-11-02 13:13:24 UTC (rev 7321)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java	2006-11-02 14:07:16 UTC (rev 7323)
@@ -0,0 +1,631 @@
+/*
+* 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.services.registry;
+
+import java.net.PasswordAuthentication;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.xml.registry.BulkResponse;
+import javax.xml.registry.BusinessLifeCycleManager;
+import javax.xml.registry.BusinessQueryManager;
+import javax.xml.registry.Connection;
+import javax.xml.registry.ConnectionFactory;
+import javax.xml.registry.FindQualifier;
+import javax.xml.registry.JAXRException;
+import javax.xml.registry.JAXRResponse;
+import javax.xml.registry.RegistryService;
+import javax.xml.registry.infomodel.EmailAddress;
+import javax.xml.registry.infomodel.Key;
+import javax.xml.registry.infomodel.Organization;
+import javax.xml.registry.infomodel.PersonName;
+import javax.xml.registry.infomodel.PostalAddress;
+import javax.xml.registry.infomodel.RegistryObject;
+import javax.xml.registry.infomodel.Service;
+import javax.xml.registry.infomodel.ServiceBinding;
+import javax.xml.registry.infomodel.TelephoneNumber;
+import javax.xml.registry.infomodel.User;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.common.Configuration;
+import org.jboss.soa.esb.services.registry.Registry;
+import org.jboss.soa.esb.services.registry.RegistryException;
+/**
+ * Utility class for the Registry.
+ * If need be we can extract the interface from here, add a factory and have JAXR as a plugin, allowing
+ * for other RegistryAPIs.
+ *
+ * @author Kurt Stam
+ */
+public class JAXRRegistryImpl implements Registry
+{
+	private static Logger logger = Logger.getLogger(JAXRRegistryImpl.class);
+	public static Set<PasswordAuthentication> creds = new HashSet<PasswordAuthentication>();
+	private static Properties props = new Properties();
+	private static Organization jbossESBOrganization;
+	
+	private static void init() 
+	{
+	    props = new Properties();
+	    props.setProperty("javax.xml.registry.queryManagerURL", Configuration.getRegistryQueryManageURI());
+	    props.setProperty("javax.xml.registry.lifeCycleManagerURL", Configuration.getRegistryLifecycleManagerURI());
+	    props.setProperty("javax.xml.registry.factoryClass", Configuration.getRegistryFactoryClass());
+	    props.setProperty("scout.proxy.transportClass", Configuration.getRegistryScoutTransportClass());
+	    String user = Configuration.getRegistryUser();
+	    String password = Configuration.getRegistryPassword();
+	    PasswordAuthentication passwdAuth = new PasswordAuthentication(user, password.toCharArray());
+        creds.add(passwdAuth);
+	}
+
+	/** 
+	 * Creates a connecton to a JAXR capable registy.
+	 * 
+	 * @return Connection to a Registry using JAXR. 
+	 */
+	protected static Connection getConnection() 
+	{
+		Connection connection = null;
+		init();
+	    try
+	    {   // Create the connection, passing it the configuration properties
+	        ConnectionFactory factory = ConnectionFactory.newInstance();
+	        factory.setProperties(props);
+	        connection = factory.createConnection();
+	    } catch (JAXRException e) {
+	        logger.log(Priority.ERROR, "Could not set up a connection to the Registry. " + e.getMessage(), e);
+	    }
+	    return connection;
+	}
+	/**
+	 * Closes the connection to the Registry
+	 */
+	protected static void closeConnection(Connection connection)
+	{
+		try {
+			if (connection!=null && !connection.isClosed()) {
+				connection.close();
+			}
+		} catch (JAXRException je) {
+			logger.log(Priority.ERROR, je.getMessage(), je);
+		}
+	}
+	/** 
+	 * 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 = JAXRRegistryImpl.getConnection();
+		try {
+			connection.setCredentials(JAXRRegistryImpl.creds);
+			RegistryService rs = connection.getRegistryService();
+			BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+		    //Adding the category as prefix for the name
+			service = blm.createService(blm.createInternationalString(category + ":" + serviceName));
+			service.setDescription(blm.createInternationalString(serviceDescription));
+//			ClassificationScheme cScheme = getClassificationScheme(blm, "uddi-org:general_keywords", "");
+//			Classification classification = blm.createClassification(cScheme, "JBossESB" + category, category);
+//			service.addClassification(classification);
+			organization.addService(service);
+			saveRegistryObject(service);
+		} finally {
+			closeConnection(connection);
+		}
+		return service;
+	}
+	/** 
+	 * Remove an EPR from the Registry
+	 */
+	public void unRegisterService(String category, String serviceName) throws RegistryException{
+		try {
+			Organization organization = getJBossESBOrganization();
+			for (Iterator i=organization.getServices().iterator(); i.hasNext();) {
+				Service service = (Service) i.next();
+				if (service.getName().getValue().equals(category + ":" + serviceName)) {
+					organization.removeService(service);
+					saveRegistryObject(organization);
+					return;
+				}
+			}
+		} catch (JAXRException je) {
+			throw new RegistryException(je.getLocalizedMessage(), je);
+		}
+	}
+	/** 
+	 * Publish an EPR to the Registry
+	 */
+	public void registerEPR(String category, String serviceName, String serviceDescription, EPR epr, String eprDescription) 
+		throws RegistryException
+	{
+		Connection connection = JAXRRegistryImpl.getConnection();
+		try {
+			//Find the service
+			Service service = findService(category,serviceName);
+			if (service==null) {
+				logger.log(Priority.INFO, "Service " + serviceName + " does not yet exist, creating now..");
+				service = registerService(category, serviceName, serviceDescription);
+			}
+			connection.setCredentials(JAXRRegistryImpl.creds);
+			RegistryService rs = connection.getRegistryService();
+			BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+//			BusinessQueryManager bqm = rs.getBusinessQueryManager();
+			ServiceBinding serviceBinding = blm.createServiceBinding();
+			serviceBinding.setDescription(blm.createInternationalString(eprDescription));
+			String xml = EPRHelper.toXMLString(epr);
+			serviceBinding.setAccessURI(URLEncoder.encode(xml,"UTF-8"));
+
+//			The following code would store the EPR xml as an ExtrinsicObject, but scout does not
+//          have an implementation for it.
+//			DataHandler repositoryItem = new DataHandler(xml,"text/xml");
+//			ExtrinsicObject eo = blm.createExtrinsicObject(repositoryItem);
+//			eo.setName(blm.createInternationalString("EPR"));
+//			eo.setMimeType("text/xml");
+//			String conceptId = "urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExtrinsicObject:XML";
+//			Concept objectTypeConcept = (Concept) bqm.getRegistryObject(conceptId);
+//				((ExtrinsicObjectImpl)eo).setObjectType(objectTypeConcept); 
+			
+//			Concept specConcept = blm.createConcept(null, "HelloConcept", "");
+//			String schemeName = "uddi-org:types";
+//			ClassificationScheme uddiOrgTypes =
+//			     bqm.findClassificationSchemeByName(null, schemeName);
+//			Classification wsdlSpecClassification = 
+//			     blm.createClassification(uddiOrgTypes,
+//			       "eprSpec", xml);
+//			   specConcept.addClassification(wsdlSpecClassification);
+//			Collection<Concept> concepts = new ArrayList<Concept>();
+//			concepts.add(specConcept);
+//			BulkResponse br=blm.saveConcepts(concepts);
+//			Key conceptKey = null;
+//			if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
+//				Collection keys = br.getCollection();
+//				for (Iterator i=keys.iterator();i.hasNext();){
+//					conceptKey = (Key) i.next();
+//					break;
+//				}
+//			} else {
+//				throw new RegistryException("Could not save the EPR as Concept");
+//			}
+//			//now adding this concept to the binding
+//			Concept specificationConcept = (Concept) bqm.getRegistryObject(conceptKey.getId(), LifeCycleManager.CONCEPT);
+//			SpecificationLink specificationLink = blm.createSpecificationLink();
+//			specificationLink.setSpecificationObject(specificationConcept);
+//			serviceBinding.addSpecificationLink(specificationLink);
+		
+		    ArrayList<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
+		    serviceBindings.add(serviceBinding);
+		    service.addServiceBindings(serviceBindings);
+			saveRegistryObject(serviceBinding);
+		} catch (Exception je) {
+			throw new RegistryException(je.getLocalizedMessage(), je);
+		} finally {
+			closeConnection(connection);
+		}
+	}
+	/** 
+	 * Remove an EPR from the Registry
+	 */
+	public void unRegisterEPR(String category, String serviceName, EPR toBeDeletedEPR) throws RegistryException{
+		//first find the ServiceBindings for this service
+		try {
+			Service service = findService(category, serviceName);
+			Collection<ServiceBinding> serviceBindings = findServiceBindings(service);
+			for (Iterator i=serviceBindings.iterator();i.hasNext();){
+				ServiceBinding serviceBinding = (ServiceBinding) i.next();
+				String xml = URLDecoder.decode(serviceBinding.getAccessURI(), "UTF-8");
+				if (xml.equals(EPRHelper.toXMLString(toBeDeletedEPR))) {
+					service.removeServiceBinding(serviceBinding);
+					service.setProvidingOrganization(getJBossESBOrganization());
+					saveRegistryObject(service);
+					return;
+				}
+			}
+			//We should not end up here or else we did not match any EPRs
+			throw new RegistryException("No such EPR found for service with name = " 
+					+ serviceName + " and EPR=" + toBeDeletedEPR);
+		} catch (Exception je) {
+			throw new RegistryException(je.getLocalizedMessage(), je);
+		}
+	}
+	
+	/** 
+	 * {@inheritDoc}
+	 * @return collection services
+	 */
+	public Collection<String> findAllServices() throws RegistryException
+	{
+		Collection<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").
+	 * 
+	 * @param serviceType
+	 * @return collection services
+	 */
+	public Collection<String> findServices(String category) throws RegistryException
+	{
+		Collection<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;
+	}
+	/**
+	 * 
+	 * @param service
+	 * @return
+	 */
+	public Collection<EPR> findEPRs(String category, String serviceName) throws RegistryException
+	{
+		Collection<EPR> eprs = new ArrayList<EPR>();
+		Connection connection = JAXRRegistryImpl.getConnection();
+		try {
+			Service service = findService(category, 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 = URLDecoder.decode(serviceBinding.getAccessURI(),"UTF-8");
+				//TODO use the XML to generate the EPR
+				EPR epr = EPRHelper.fromXMLString(eprXML);
+				eprs.add(epr);
+			}
+		} catch (Exception je) {
+			throw new RegistryException(je.getLocalizedMessage(), je);
+		} finally {
+			closeConnection(connection);
+		}
+		return eprs;
+	}
+	/**
+	 * Find all Organizations with a name mathing the queryString parameter.
+	 * 
+	 * @param organizationName used to match with the name of the organization.
+	 * @return the Organization.
+	 */
+	protected static Organization findOrganization(String organizationName) throws JAXRException
+	{
+	    if (organizationName==null) {
+	    	organizationName="";
+	    }
+		Connection connection = JAXRRegistryImpl.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
+			System.out.println("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(Priority.INFO, "Organization name: " + org.getName().getValue());
+					logger.log(Priority.INFO, "Description: " + org.getDescription().getValue());
+					logger.log(Priority.INFO, "Key id: " + org.getKey().getId());
+					User primaryContact = org.getPrimaryContact();
+					logger.log(Priority.INFO, "Primary Contact: " + primaryContact.getPersonName().getFullName());
+					if (orgIter.hasNext()) {
+						logger.log(Priority.ERROR, "Found " + response.getCollection().size() 
+								+ " Organization, while expecting only one of name " + organizationName);
+					}
+					return org;
+				}
+			}
+			return null;
+		} finally {
+			closeConnection(connection);
+		}
+	}
+	/**
+	 * 
+	 * @param category
+	 * @param serviceName
+	 * @return Service
+	 */
+	protected static Service findService(String category, String serviceName) throws JAXRException
+	{
+		if (category==null) {
+			category="";
+		}
+		if (serviceName==null) {
+			serviceName="";
+		}
+		Connection connection = JAXRRegistryImpl.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.AND_ALL_KEYS);
+			findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
+			Collection<String> namePatterns = new ArrayList<String>();
+			namePatterns.add("%" + category + "%");
+			namePatterns.add("%" + serviceName + "%");
+	        //Find based upon qualifier type and values
+			logger.log(Priority.DEBUG, "Going to query the registry for name pattern " + namePatterns);
+			BulkResponse response = bqm.findServices(null, findQualifiers,
+					namePatterns, null, null);
+			if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
+				for (Iterator servIter = response.getCollection().iterator(); servIter.hasNext();) 
+				{
+					Service service = (Service) servIter.next();
+					logger.log(Priority.INFO, "Service name: " + service.getName().getValue());
+					if (service.getDescription()!=null) {
+						logger.log(Priority.INFO, "Description: " + service.getDescription().getValue());
+					}
+					logger.log(Priority.INFO, "Key id: " + service.getKey().getId());
+					if (servIter.hasNext()) {
+						logger.log(Priority.ERROR, "Found " + response.getCollection().size() 
+								+ " Services, while expecting only one by the name of " 
+								+ serviceName + " in category " + category);
+					}
+					return service;
+				}
+			}
+			return null;
+		} finally {
+			closeConnection(connection);
+		}
+	}
+	/**
+	 * Finds all services for a given category.
+	 * @param category
+	 * @param serviceName
+	 * @return Service
+	 */
+	@SuppressWarnings("unchecked")
+	protected static Collection<Service> findServicesForCategory(String category) throws JAXRException
+	{
+		Collection<Service> services = new ArrayList<Service>();
+		if (category==null) {
+			category="";
+		}
+		Connection connection = JAXRRegistryImpl.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.AND_ALL_KEYS);
+			findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
+			Collection<String> namePatterns = new ArrayList<String>();
+			namePatterns.add("%" + category + "%");
+	        //Find based upon qualifier type and values
+			logger.log(Priority.DEBUG, "Going to query the registry for name pattern " + namePatterns);
+			BulkResponse response = bqm.findServices(null, findQualifiers,
+					namePatterns, null, null);
+			if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
+				services = response.getCollection();
+			}
+			return services;
+		} finally {
+			closeConnection(connection);
+		}
+	}
+	/**
+	 * Create a jbossesb organization under which we will register all our services.
+	 * 
+	 * @param blm
+	 * @return
+	 * @throws JAXRException
+	 */
+	protected static Organization createJBossESBOrganization()
+			throws JAXRException 
+	{
+//		Getting the connection to the Registry (reading config)
+		Connection connection = JAXRRegistryImpl.getConnection();
+		try {
+			//Logging in
+			connection.setCredentials(JAXRRegistryImpl.creds);
+			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);
+	
+			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);
+			
+			saveRegistryObject(organization);
+			return organization;
+		} finally {
+			closeConnection(connection);
+		}	
+	}
+	/**
+	 * Save Registry Object
+	 */
+	protected static void saveRegistryObject(RegistryObject registryObject) throws JAXRException
+	{
+//		Getting the connection to the Registry (reading config)
+		Connection connection = JAXRRegistryImpl.getConnection();
+		try {
+			Collection<RegistryObject> registryObjects = new ArrayList<RegistryObject>();
+			BulkResponse br = null;
+			//Logging in
+			connection.setCredentials(JAXRRegistryImpl.creds);
+			RegistryService rs = connection.getRegistryService();
+			//Building organization
+			BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+			registryObjects.add(registryObject);
+			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")) {
+					br = blm.saveOrganizations(registryObjects);
+					break;
+				} else if (interfaceName.equals("javax.xml.registry.infomodel.Service")) {
+					br = blm.saveServices(registryObjects);
+					break;
+				} else if (interfaceName.equals("javax.xml.registry.infomodel.ServiceBinding")) {
+					br = blm.saveServiceBindings(registryObjects);
+					break;
+				} else {
+					logger.log(Priority.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(Priority.INFO, interfaceName + " successfully saved");
+				Collection coll = br.getCollection();
+				Iterator iter = coll.iterator();
+				while (iter.hasNext()) {
+					Key key = (Key) iter.next();
+					registryObject.setKey(key);
+					logger.log(Priority.INFO, "Saved Key=" + key.getId());
+				}
+			} else {
+				logger.log(Priority.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(Priority.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 {
+			JAXRRegistryImpl.closeConnection(connection);
+		}	
+	}
+	/**
+	 * finds the JBossESB Organizationa and creates one if it is not there.
+	 * @return JBossESB Organization
+	 * @throws JAXRException
+	 */
+	private Organization getJBossESBOrganization() throws JAXRException
+	{
+		if (jbossESBOrganization==null) {
+			jbossESBOrganization = findOrganization("Red Hat/JBossESB");
+			if (jbossESBOrganization==null) {
+				jbossESBOrganization = createJBossESBOrganization();
+			}
+		}
+		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 = JAXRRegistryImpl.getConnection();
+		try {
+			RegistryService rs = connection.getRegistryService();
+			BusinessQueryManager bqm = rs.getBusinessQueryManager();
+			Collection<String> findQualifiers = new ArrayList<String>();
+			findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
+			BulkResponse bulkResponse = bqm.findServiceBindings(service.getKey(),findQualifiers,null,null);
+			if (bulkResponse.getStatus()==JAXRResponse.STATUS_SUCCESS){
+				serviceBindings = bulkResponse.getCollection();
+			}
+			return serviceBindings;
+		} catch (Exception je) {
+			throw new RegistryException(je.getLocalizedMessage(), je);
+		} finally {
+			closeConnection(connection);
+		}
+	}
+	
+}
+
+	

Copied: labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouter.java (from rev 7311, labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/routing/cbr/JBossRulesRouter.java)
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/routing/cbr/JBossRulesRouter.java	2006-11-02 02:30:11 UTC (rev 7311)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouter.java	2006-11-02 14:07:16 UTC (rev 7323)
@@ -0,0 +1,135 @@
+package org.jboss.internal.soa.esb.services.routing.cbr;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.WorkingMemory;
+import org.drools.compiler.PackageBuilder;
+import org.drools.rule.Package;
+import org.jboss.soa.esb.addressing.EPR;
+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.message.Message;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.registry.RegistryFactory;
+import org.jboss.soa.esb.services.registry.Registry;
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+import org.jboss.soa.esb.services.routing.cbr.ContentBasedRouter;
+
+
+public class JBossRulesRouter implements ContentBasedRouter 
+{
+	private static Map<String,WorkingMemory> workingMemories=new HashMap<String,WorkingMemory>();
+	private static Logger logger = Logger.getLogger(JBossRulesRouter.class);
+	
+	/**
+	 * Constructor.
+	 * @param ruleSet String
+	 * @throws MessageRouterException
+	 */
+	public JBossRulesRouter()
+	{
+		super();
+	}
+
+	public List<String> route(Message message){
+		logger.log(Priority.ERROR, "Do not use, this is not implemented");
+			//Route to /dev/null?
+		return null;
+	}
+
+	@SuppressWarnings("unchecked")
+	public List<String> route(String ruleSet, Message message) 
+	{
+		List<String> destinationServices = new ArrayList<String>();
+		try {
+			if (!workingMemories.containsKey(ruleSet)) {
+			    logger.log(Priority.INFO, "Reading ruleSet from file=" + ruleSet);
+				RuleBase ruleBase = readRuleBase(ruleSet);
+				WorkingMemory workingMemory = ruleBase.newWorkingMemory();
+				workingMemories.put(ruleSet, workingMemory);
+			}
+			logger.log(Priority.DEBUG, "Obtained message=" + message + " with ruleSet=" + ruleSet);
+			WorkingMemory workingMemory = workingMemories.get(ruleSet);
+			workingMemory.setGlobal("destinationServices", destinationServices);
+			workingMemory.assertObject(message);
+			logger.log(Priority.INFO, "Fire the rules engine");
+			workingMemory.fireAllRules();
+			//Now route there, later we will implement an option to place a callback.
+			destinationServices = (List) workingMemory.getGlobal("destinationServices");
+			logger.log(Priority.DEBUG, "Destination Services List: " + destinationServices);
+			for (Iterator<String> i=destinationServices.iterator();i.hasNext();) {
+				String destinationService = i.next();
+				String[] strArray = destinationService.split(":");
+				String category = strArray[0];
+				String serviceName = strArray[1];
+				boolean isSent=false;
+				try {
+					Registry registry = RegistryFactory.getRegistry();
+					logger.log(Priority.INFO, "Looking for EPRs for category=" + category +
+							" and serviceName=" + serviceName);
+					Collection<EPR> eprs = registry.findEPRs(category, serviceName);
+					for (Iterator<EPR> eprIter=eprs.iterator();eprIter.hasNext();) {
+						EPR epr = eprs.iterator().next();
+						logger.log(Priority.INFO, "Message=" + message + " -> Destination=" + destinationService);
+						try {
+							//Give the message to the courier
+							Courier courier = CourierFactory.getCourier(epr);
+							courier.deliver(message);
+							isSent=true;
+							break;
+						} catch (CourierException ce) {
+							logger.log(Priority.ERROR, "Could not send using epr:" + epr);
+							//if there are more eprs in the collection is will try the next one.
+						}
+					}
+					if (isSent==false) {
+						logger.log(Priority.ERROR, "Could not find any valid EPRs. Message is not routed");
+						//Route to /dev/null?
+					}
+				} catch (RegistryException re) {
+					logger.log(Priority.ERROR, "Could not obtain an EPR from the Registry. Message is not routed" + re.getLocalizedMessage(), re);
+					//Route to /dev/null?
+				}
+			}
+		} catch (Exception e) {
+			logger.log(Priority.ERROR, e.getMessage() + ". Message is not routed", e);
+			//Route to /dev/null?
+		}
+		return destinationServices;
+	}
+	
+    /**
+     * Reading the rules from a file, we may want to allow other ways to 
+     * set the rule.
+     */
+	private static RuleBase readRuleBase(String rulesFile) throws Exception
+	{
+		//read in the rules
+		InputStream inputStream = JBossRulesRouter.class.getResourceAsStream( "/" + rulesFile );
+		Reader source = new InputStreamReader(inputStream);
+		PackageBuilder builder = new PackageBuilder();
+		//this wil parse and compile in one step
+		//NOTE: There are 2 methods here, the one argument one is for normal DRL.
+		builder.addPackageFromDrl( source );;
+		//get the compiled package (which is serializable)
+		Package pkg = builder.getPackage();
+		//add the package to a rulebase (deploy the rule package).
+		RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+		ruleBase.addPackage(pkg);
+		return ruleBase;
+	}
+
+}

Deleted: labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java	2006-11-02 13:47:32 UTC (rev 7322)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java	2006-11-02 14:07:16 UTC (rev 7323)
@@ -1,629 +0,0 @@
-/*
-* 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.soa.esb.services.registry;
-
-import java.net.PasswordAuthentication;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.xml.registry.BulkResponse;
-import javax.xml.registry.BusinessLifeCycleManager;
-import javax.xml.registry.BusinessQueryManager;
-import javax.xml.registry.Connection;
-import javax.xml.registry.ConnectionFactory;
-import javax.xml.registry.FindQualifier;
-import javax.xml.registry.JAXRException;
-import javax.xml.registry.JAXRResponse;
-import javax.xml.registry.RegistryService;
-import javax.xml.registry.infomodel.EmailAddress;
-import javax.xml.registry.infomodel.Key;
-import javax.xml.registry.infomodel.Organization;
-import javax.xml.registry.infomodel.PersonName;
-import javax.xml.registry.infomodel.PostalAddress;
-import javax.xml.registry.infomodel.RegistryObject;
-import javax.xml.registry.infomodel.Service;
-import javax.xml.registry.infomodel.ServiceBinding;
-import javax.xml.registry.infomodel.TelephoneNumber;
-import javax.xml.registry.infomodel.User;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.common.Configuration;
-/**
- * Utility class for the Registry.
- * If need be we can extract the interface from here, add a factory and have JAXR as a plugin, allowing
- * for other RegistryAPIs.
- *
- * @author Kurt Stam
- */
-public class JAXRRegistryImpl implements Registry
-{
-	private static Logger logger = Logger.getLogger(JAXRRegistryImpl.class);
-	public static Set<PasswordAuthentication> creds = new HashSet<PasswordAuthentication>();
-	private static Properties props = new Properties();
-	private static Organization jbossESBOrganization;
-	
-	private static void init() 
-	{
-	    props = new Properties();
-	    props.setProperty("javax.xml.registry.queryManagerURL", Configuration.getRegistryQueryManageURI());
-	    props.setProperty("javax.xml.registry.lifeCycleManagerURL", Configuration.getRegistryLifecycleManagerURI());
-	    props.setProperty("javax.xml.registry.factoryClass", Configuration.getRegistryFactoryClass());
-	    props.setProperty("scout.proxy.transportClass", Configuration.getRegistryScoutTransportClass());
-	    String user = Configuration.getRegistryUser();
-	    String password = Configuration.getRegistryPassword();
-	    PasswordAuthentication passwdAuth = new PasswordAuthentication(user, password.toCharArray());
-        creds.add(passwdAuth);
-	}
-
-	/** 
-	 * Creates a connecton to a JAXR capable registy.
-	 * 
-	 * @return Connection to a Registry using JAXR. 
-	 */
-	protected static Connection getConnection() 
-	{
-		Connection connection = null;
-		init();
-	    try
-	    {   // Create the connection, passing it the configuration properties
-	        ConnectionFactory factory = ConnectionFactory.newInstance();
-	        factory.setProperties(props);
-	        connection = factory.createConnection();
-	    } catch (JAXRException e) {
-	        logger.log(Priority.ERROR, "Could not set up a connection to the Registry. " + e.getMessage(), e);
-	    }
-	    return connection;
-	}
-	/**
-	 * Closes the connection to the Registry
-	 */
-	protected static void closeConnection(Connection connection)
-	{
-		try {
-			if (connection!=null && !connection.isClosed()) {
-				connection.close();
-			}
-		} catch (JAXRException je) {
-			logger.log(Priority.ERROR, je.getMessage(), je);
-		}
-	}
-	/** 
-	 * 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 = JAXRRegistryImpl.getConnection();
-		try {
-			connection.setCredentials(JAXRRegistryImpl.creds);
-			RegistryService rs = connection.getRegistryService();
-			BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
-		    //Adding the category as prefix for the name
-			service = blm.createService(blm.createInternationalString(category + ":" + serviceName));
-			service.setDescription(blm.createInternationalString(serviceDescription));
-//			ClassificationScheme cScheme = getClassificationScheme(blm, "uddi-org:general_keywords", "");
-//			Classification classification = blm.createClassification(cScheme, "JBossESB" + category, category);
-//			service.addClassification(classification);
-			organization.addService(service);
-			saveRegistryObject(service);
-		} finally {
-			closeConnection(connection);
-		}
-		return service;
-	}
-	/** 
-	 * Remove an EPR from the Registry
-	 */
-	public void unRegisterService(String category, String serviceName) throws RegistryException{
-		try {
-			Organization organization = getJBossESBOrganization();
-			for (Iterator i=organization.getServices().iterator(); i.hasNext();) {
-				Service service = (Service) i.next();
-				if (service.getName().getValue().equals(category + ":" + serviceName)) {
-					organization.removeService(service);
-					saveRegistryObject(organization);
-					return;
-				}
-			}
-		} catch (JAXRException je) {
-			throw new RegistryException(je.getLocalizedMessage(), je);
-		}
-	}
-	/** 
-	 * Publish an EPR to the Registry
-	 */
-	public void registerEPR(String category, String serviceName, String serviceDescription, EPR epr, String eprDescription) 
-		throws RegistryException
-	{
-		Connection connection = JAXRRegistryImpl.getConnection();
-		try {
-			//Find the service
-			Service service = findService(category,serviceName);
-			if (service==null) {
-				logger.log(Priority.INFO, "Service " + serviceName + " does not yet exist, creating now..");
-				service = registerService(category, serviceName, serviceDescription);
-			}
-			connection.setCredentials(JAXRRegistryImpl.creds);
-			RegistryService rs = connection.getRegistryService();
-			BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
-//			BusinessQueryManager bqm = rs.getBusinessQueryManager();
-			ServiceBinding serviceBinding = blm.createServiceBinding();
-			serviceBinding.setDescription(blm.createInternationalString(eprDescription));
-			String xml = EPRHelper.toXMLString(epr);
-			serviceBinding.setAccessURI(URLEncoder.encode(xml,"UTF-8"));
-
-//			The following code would store the EPR xml as an ExtrinsicObject, but scout does not
-//          have an implementation for it.
-//			DataHandler repositoryItem = new DataHandler(xml,"text/xml");
-//			ExtrinsicObject eo = blm.createExtrinsicObject(repositoryItem);
-//			eo.setName(blm.createInternationalString("EPR"));
-//			eo.setMimeType("text/xml");
-//			String conceptId = "urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExtrinsicObject:XML";
-//			Concept objectTypeConcept = (Concept) bqm.getRegistryObject(conceptId);
-//				((ExtrinsicObjectImpl)eo).setObjectType(objectTypeConcept); 
-			
-//			Concept specConcept = blm.createConcept(null, "HelloConcept", "");
-//			String schemeName = "uddi-org:types";
-//			ClassificationScheme uddiOrgTypes =
-//			     bqm.findClassificationSchemeByName(null, schemeName);
-//			Classification wsdlSpecClassification = 
-//			     blm.createClassification(uddiOrgTypes,
-//			       "eprSpec", xml);
-//			   specConcept.addClassification(wsdlSpecClassification);
-//			Collection<Concept> concepts = new ArrayList<Concept>();
-//			concepts.add(specConcept);
-//			BulkResponse br=blm.saveConcepts(concepts);
-//			Key conceptKey = null;
-//			if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
-//				Collection keys = br.getCollection();
-//				for (Iterator i=keys.iterator();i.hasNext();){
-//					conceptKey = (Key) i.next();
-//					break;
-//				}
-//			} else {
-//				throw new RegistryException("Could not save the EPR as Concept");
-//			}
-//			//now adding this concept to the binding
-//			Concept specificationConcept = (Concept) bqm.getRegistryObject(conceptKey.getId(), LifeCycleManager.CONCEPT);
-//			SpecificationLink specificationLink = blm.createSpecificationLink();
-//			specificationLink.setSpecificationObject(specificationConcept);
-//			serviceBinding.addSpecificationLink(specificationLink);
-		
-		    ArrayList<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
-		    serviceBindings.add(serviceBinding);
-		    service.addServiceBindings(serviceBindings);
-			saveRegistryObject(serviceBinding);
-		} catch (Exception je) {
-			throw new RegistryException(je.getLocalizedMessage(), je);
-		} finally {
-			closeConnection(connection);
-		}
-	}
-	/** 
-	 * Remove an EPR from the Registry
-	 */
-	public void unRegisterEPR(String category, String serviceName, EPR toBeDeletedEPR) throws RegistryException{
-		//first find the ServiceBindings for this service
-		try {
-			Service service = findService(category, serviceName);
-			Collection<ServiceBinding> serviceBindings = findServiceBindings(service);
-			for (Iterator i=serviceBindings.iterator();i.hasNext();){
-				ServiceBinding serviceBinding = (ServiceBinding) i.next();
-				String xml = URLDecoder.decode(serviceBinding.getAccessURI(), "UTF-8");
-				if (xml.equals(EPRHelper.toXMLString(toBeDeletedEPR))) {
-					service.removeServiceBinding(serviceBinding);
-					service.setProvidingOrganization(getJBossESBOrganization());
-					saveRegistryObject(service);
-					return;
-				}
-			}
-			//We should not end up here or else we did not match any EPRs
-			throw new RegistryException("No such EPR found for service with name = " 
-					+ serviceName + " and EPR=" + toBeDeletedEPR);
-		} catch (Exception je) {
-			throw new RegistryException(je.getLocalizedMessage(), je);
-		}
-	}
-	
-	/** 
-	 * {@inheritDoc}
-	 * @return collection services
-	 */
-	public Collection<String> findAllServices() throws RegistryException
-	{
-		Collection<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").
-	 * 
-	 * @param serviceType
-	 * @return collection services
-	 */
-	public Collection<String> findServices(String category) throws RegistryException
-	{
-		Collection<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;
-	}
-	/**
-	 * 
-	 * @param service
-	 * @return
-	 */
-	public Collection<EPR> findEPRs(String category, String serviceName) throws RegistryException
-	{
-		Collection<EPR> eprs = new ArrayList<EPR>();
-		Connection connection = JAXRRegistryImpl.getConnection();
-		try {
-			Service service = findService(category, 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 = URLDecoder.decode(serviceBinding.getAccessURI(),"UTF-8");
-				//TODO use the XML to generate the EPR
-				EPR epr = EPRHelper.fromXMLString(eprXML);
-				eprs.add(epr);
-			}
-		} catch (Exception je) {
-			throw new RegistryException(je.getLocalizedMessage(), je);
-		} finally {
-			closeConnection(connection);
-		}
-		return eprs;
-	}
-	/**
-	 * Find all Organizations with a name mathing the queryString parameter.
-	 * 
-	 * @param organizationName used to match with the name of the organization.
-	 * @return the Organization.
-	 */
-	protected static Organization findOrganization(String organizationName) throws JAXRException
-	{
-	    if (organizationName==null) {
-	    	organizationName="";
-	    }
-		Connection connection = JAXRRegistryImpl.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
-			System.out.println("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(Priority.INFO, "Organization name: " + org.getName().getValue());
-					logger.log(Priority.INFO, "Description: " + org.getDescription().getValue());
-					logger.log(Priority.INFO, "Key id: " + org.getKey().getId());
-					User primaryContact = org.getPrimaryContact();
-					logger.log(Priority.INFO, "Primary Contact: " + primaryContact.getPersonName().getFullName());
-					if (orgIter.hasNext()) {
-						logger.log(Priority.ERROR, "Found " + response.getCollection().size() 
-								+ " Organization, while expecting only one of name " + organizationName);
-					}
-					return org;
-				}
-			}
-			return null;
-		} finally {
-			closeConnection(connection);
-		}
-	}
-	/**
-	 * 
-	 * @param category
-	 * @param serviceName
-	 * @return Service
-	 */
-	protected static Service findService(String category, String serviceName) throws JAXRException
-	{
-		if (category==null) {
-			category="";
-		}
-		if (serviceName==null) {
-			serviceName="";
-		}
-		Connection connection = JAXRRegistryImpl.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.AND_ALL_KEYS);
-			findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
-			Collection<String> namePatterns = new ArrayList<String>();
-			namePatterns.add("%" + category + "%");
-			namePatterns.add("%" + serviceName + "%");
-	        //Find based upon qualifier type and values
-			logger.log(Priority.DEBUG, "Going to query the registry for name pattern " + namePatterns);
-			BulkResponse response = bqm.findServices(null, findQualifiers,
-					namePatterns, null, null);
-			if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
-				for (Iterator servIter = response.getCollection().iterator(); servIter.hasNext();) 
-				{
-					Service service = (Service) servIter.next();
-					logger.log(Priority.INFO, "Service name: " + service.getName().getValue());
-					if (service.getDescription()!=null) {
-						logger.log(Priority.INFO, "Description: " + service.getDescription().getValue());
-					}
-					logger.log(Priority.INFO, "Key id: " + service.getKey().getId());
-					if (servIter.hasNext()) {
-						logger.log(Priority.ERROR, "Found " + response.getCollection().size() 
-								+ " Services, while expecting only one by the name of " 
-								+ serviceName + " in category " + category);
-					}
-					return service;
-				}
-			}
-			return null;
-		} finally {
-			closeConnection(connection);
-		}
-	}
-	/**
-	 * Finds all services for a given category.
-	 * @param category
-	 * @param serviceName
-	 * @return Service
-	 */
-	@SuppressWarnings("unchecked")
-	protected static Collection<Service> findServicesForCategory(String category) throws JAXRException
-	{
-		Collection<Service> services = new ArrayList<Service>();
-		if (category==null) {
-			category="";
-		}
-		Connection connection = JAXRRegistryImpl.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.AND_ALL_KEYS);
-			findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
-			Collection<String> namePatterns = new ArrayList<String>();
-			namePatterns.add("%" + category + "%");
-	        //Find based upon qualifier type and values
-			logger.log(Priority.DEBUG, "Going to query the registry for name pattern " + namePatterns);
-			BulkResponse response = bqm.findServices(null, findQualifiers,
-					namePatterns, null, null);
-			if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
-				services = response.getCollection();
-			}
-			return services;
-		} finally {
-			closeConnection(connection);
-		}
-	}
-	/**
-	 * Create a jbossesb organization under which we will register all our services.
-	 * 
-	 * @param blm
-	 * @return
-	 * @throws JAXRException
-	 */
-	protected static Organization createJBossESBOrganization()
-			throws JAXRException 
-	{
-//		Getting the connection to the Registry (reading config)
-		Connection connection = JAXRRegistryImpl.getConnection();
-		try {
-			//Logging in
-			connection.setCredentials(JAXRRegistryImpl.creds);
-			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);
-	
-			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);
-			
-			saveRegistryObject(organization);
-			return organization;
-		} finally {
-			closeConnection(connection);
-		}	
-	}
-	/**
-	 * Save Registry Object
-	 */
-	protected static void saveRegistryObject(RegistryObject registryObject) throws JAXRException
-	{
-//		Getting the connection to the Registry (reading config)
-		Connection connection = JAXRRegistryImpl.getConnection();
-		try {
-			Collection<RegistryObject> registryObjects = new ArrayList<RegistryObject>();
-			BulkResponse br = null;
-			//Logging in
-			connection.setCredentials(JAXRRegistryImpl.creds);
-			RegistryService rs = connection.getRegistryService();
-			//Building organization
-			BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
-			registryObjects.add(registryObject);
-			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")) {
-					br = blm.saveOrganizations(registryObjects);
-					break;
-				} else if (interfaceName.equals("javax.xml.registry.infomodel.Service")) {
-					br = blm.saveServices(registryObjects);
-					break;
-				} else if (interfaceName.equals("javax.xml.registry.infomodel.ServiceBinding")) {
-					br = blm.saveServiceBindings(registryObjects);
-					break;
-				} else {
-					logger.log(Priority.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(Priority.INFO, interfaceName + " successfully saved");
-				Collection coll = br.getCollection();
-				Iterator iter = coll.iterator();
-				while (iter.hasNext()) {
-					Key key = (Key) iter.next();
-					registryObject.setKey(key);
-					logger.log(Priority.INFO, "Saved Key=" + key.getId());
-				}
-			} else {
-				logger.log(Priority.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(Priority.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 {
-			JAXRRegistryImpl.closeConnection(connection);
-		}	
-	}
-	/**
-	 * finds the JBossESB Organizationa and creates one if it is not there.
-	 * @return JBossESB Organization
-	 * @throws JAXRException
-	 */
-	private Organization getJBossESBOrganization() throws JAXRException
-	{
-		if (jbossESBOrganization==null) {
-			jbossESBOrganization = findOrganization("Red Hat/JBossESB");
-			if (jbossESBOrganization==null) {
-				jbossESBOrganization = createJBossESBOrganization();
-			}
-		}
-		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 = JAXRRegistryImpl.getConnection();
-		try {
-			RegistryService rs = connection.getRegistryService();
-			BusinessQueryManager bqm = rs.getBusinessQueryManager();
-			Collection<String> findQualifiers = new ArrayList<String>();
-			findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
-			BulkResponse bulkResponse = bqm.findServiceBindings(service.getKey(),findQualifiers,null,null);
-			if (bulkResponse.getStatus()==JAXRResponse.STATUS_SUCCESS){
-				serviceBindings = bulkResponse.getCollection();
-			}
-			return serviceBindings;
-		} catch (Exception je) {
-			throw new RegistryException(je.getLocalizedMessage(), je);
-		} finally {
-			closeConnection(connection);
-		}
-	}
-	
-}
-
-	

Deleted: labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/routing/cbr/JBossRulesRouter.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/routing/cbr/JBossRulesRouter.java	2006-11-02 13:47:32 UTC (rev 7322)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/routing/cbr/JBossRulesRouter.java	2006-11-02 14:07:16 UTC (rev 7323)
@@ -1,134 +0,0 @@
-package org.jboss.soa.esb.services.routing.cbr;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
-import org.drools.WorkingMemory;
-import org.drools.compiler.PackageBuilder;
-import org.drools.rule.Package;
-import org.jboss.soa.esb.addressing.EPR;
-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.message.Message;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.registry.RegistryFactory;
-import org.jboss.soa.esb.services.registry.Registry;
-import org.jboss.soa.esb.services.routing.MessageRouterException;
-
-
-public class JBossRulesRouter implements ContentBasedRouter 
-{
-	private static Map<String,WorkingMemory> workingMemories=new HashMap<String,WorkingMemory>();
-	private static Logger logger = Logger.getLogger(JBossRulesRouter.class);
-	
-	/**
-	 * Constructor.
-	 * @param ruleSet String
-	 * @throws MessageRouterException
-	 */
-	public JBossRulesRouter()
-	{
-		super();
-	}
-
-	public List<String> route(Message message){
-		logger.log(Priority.ERROR, "Do not use, this is not implemented");
-			//Route to /dev/null?
-		return null;
-	}
-
-	@SuppressWarnings("unchecked")
-	public List<String> route(String ruleSet, Message message) 
-	{
-		List<String> destinationServices = new ArrayList<String>();
-		try {
-			if (!workingMemories.containsKey(ruleSet)) {
-			    logger.log(Priority.INFO, "Reading ruleSet from file=" + ruleSet);
-				RuleBase ruleBase = readRuleBase(ruleSet);
-				WorkingMemory workingMemory = ruleBase.newWorkingMemory();
-				workingMemories.put(ruleSet, workingMemory);
-			}
-			logger.log(Priority.DEBUG, "Obtained message=" + message + " with ruleSet=" + ruleSet);
-			WorkingMemory workingMemory = workingMemories.get(ruleSet);
-			workingMemory.setGlobal("destinationServices", destinationServices);
-			workingMemory.assertObject(message);
-			logger.log(Priority.INFO, "Fire the rules engine");
-			workingMemory.fireAllRules();
-			//Now route there, later we will implement an option to place a callback.
-			destinationServices = (List) workingMemory.getGlobal("destinationServices");
-			logger.log(Priority.DEBUG, "Destination Services List: " + destinationServices);
-			for (Iterator<String> i=destinationServices.iterator();i.hasNext();) {
-				String destinationService = i.next();
-				String[] strArray = destinationService.split(":");
-				String category = strArray[0];
-				String serviceName = strArray[1];
-				boolean isSent=false;
-				try {
-					Registry registry = RegistryFactory.getRegistry();
-					logger.log(Priority.INFO, "Looking for EPRs for category=" + category +
-							" and serviceName=" + serviceName);
-					Collection<EPR> eprs = registry.findEPRs(category, serviceName);
-					for (Iterator<EPR> eprIter=eprs.iterator();eprIter.hasNext();) {
-						EPR epr = eprs.iterator().next();
-						logger.log(Priority.INFO, "Message=" + message + " -> Destination=" + destinationService);
-						try {
-							//Give the message to the courier
-							Courier courier = CourierFactory.getCourier(epr);
-							courier.deliver(message);
-							isSent=true;
-							break;
-						} catch (CourierException ce) {
-							logger.log(Priority.ERROR, "Could not send using epr:" + epr);
-							//if there are more eprs in the collection is will try the next one.
-						}
-					}
-					if (isSent==false) {
-						logger.log(Priority.ERROR, "Could not find any valid EPRs. Message is not routed");
-						//Route to /dev/null?
-					}
-				} catch (RegistryException re) {
-					logger.log(Priority.ERROR, "Could not obtain an EPR from the Registry. Message is not routed" + re.getLocalizedMessage(), re);
-					//Route to /dev/null?
-				}
-			}
-		} catch (Exception e) {
-			logger.log(Priority.ERROR, e.getMessage() + ". Message is not routed", e);
-			//Route to /dev/null?
-		}
-		return destinationServices;
-	}
-	
-    /**
-     * Reading the rules from a file, we may want to allow other ways to 
-     * set the rule.
-     */
-	private static RuleBase readRuleBase(String rulesFile) throws Exception
-	{
-		//read in the rules
-		InputStream inputStream = JBossRulesRouter.class.getResourceAsStream( "/" + rulesFile );
-		Reader source = new InputStreamReader(inputStream);
-		PackageBuilder builder = new PackageBuilder();
-		//this wil parse and compile in one step
-		//NOTE: There are 2 methods here, the one argument one is for normal DRL.
-		builder.addPackageFromDrl( source );;
-		//get the compiled package (which is serializable)
-		Package pkg = builder.getPackage();
-		//add the package to a rulebase (deploy the rule package).
-		RuleBase ruleBase = RuleBaseFactory.newRuleBase();
-		ruleBase.addPackage(pkg);
-		return ruleBase;
-	}
-
-}

Copied: labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java (from rev 7311, labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java)
===================================================================
--- labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java	2006-11-02 02:30:11 UTC (rev 7311)
+++ labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java	2006-11-02 14:07:16 UTC (rev 7323)
@@ -0,0 +1,93 @@
+/*
+ * 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.services.routing.cbr;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.xml.DOMConfigurator;
+import org.jboss.soa.esb.common.tests.TestUtil;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * 
+ * @author kurt.stam at redhat.com
+ *
+ */
+public class JBossRulesRouterUnitTest
+{
+	@Test
+	public void routeSerializedMessage()
+	{
+        //new messages
+		Message message = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+		//set some properties inside the Message
+		message.getProperties().setProperty("prop1", "val1");
+		message.getProperties().setProperty("prop2", "val2");
+		//set the body inside the Message
+		message.getBody().setContents(("TEST BODY").getBytes());
+		//set some object attachments inside the Message
+		message.getAttachment().addItem(new String("TEST ATTACHMENT1"));
+		message.getAttachment().addItem(new String("TEST ATTACHMENT2"));
+		
+		JBossRulesRouter jbossRulesRouter = new JBossRulesRouter();
+		List<String> destinationServices = jbossRulesRouter.route("JBossESBRules.drl", message);
+		assertEquals(destinationServices.iterator().next(),"test_category:Serialized_ServiceDestination");
+	}
+	
+	@Test
+	public void routeXMLMessage()
+	{
+		//add new messages
+		Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+		//set some properties inside the Message
+		message.getProperties().setProperty("prop1", "val1");
+		message.getProperties().setProperty("prop2", "val2");
+		//set the body inside the Message
+		message.getBody().setContents(("TEST BODY").getBytes());
+		//set some object attachments inside the Message
+		message.getAttachment().addItem(new String("TEST ATTACHMENT1"));
+		message.getAttachment().addItem(new String("TEST ATTACHMENT2"));
+	
+		JBossRulesRouter jbossRulesRouter = new JBossRulesRouter();
+		List<String> destinationServices = jbossRulesRouter.route("JBossESBRules.drl", message);
+		assertEquals(destinationServices.iterator().next(),"test_category:JBOSS_XMLDestination");
+	}
+	
+	@BeforeClass
+	public static void runBeforeAllTests() throws Exception 
+	{
+		DOMConfigurator.configure(TestUtil.getPrefix() + "etc/test/resources/log4j.xml");
+	}
+	
+	public static junit.framework.Test suite() {
+		return new JUnit4TestAdapter(JBossRulesRouterUnitTest.class);
+	}
+
+}

Deleted: labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/JAXRRegistryUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/JAXRRegistryUnitTest.java	2006-11-02 13:47:32 UTC (rev 7322)
+++ labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/JAXRRegistryUnitTest.java	2006-11-02 14:07:16 UTC (rev 7323)
@@ -1,281 +0,0 @@
-/*
-* 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.soa.esb.services.registry;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.InputStream;
-import java.net.URLDecoder;
-import java.sql.DriverManager;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Properties;
-
-import javax.xml.registry.BulkResponse;
-import javax.xml.registry.BusinessLifeCycleManager;
-import javax.xml.registry.BusinessQueryManager;
-import javax.xml.registry.Connection;
-import javax.xml.registry.JAXRException;
-import javax.xml.registry.RegistryService;
-import javax.xml.registry.infomodel.Classification;
-import javax.xml.registry.infomodel.ClassificationScheme;
-import javax.xml.registry.infomodel.Organization;
-import javax.xml.registry.infomodel.Service;
-import javax.xml.registry.infomodel.ServiceBinding;
-import javax.xml.registry.infomodel.User;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.apache.log4j.xml.DOMConfigurator;
-import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.common.tests.HsqldbUtil;
-import org.jboss.soa.esb.common.tests.TestUtil;
-import org.jboss.soa.esb.services.util.FileUtil;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Testing the registry.
- * 
- * @author kstam
- *
- */
-public class JAXRRegistryUnitTest
-{
-	private static Logger logger = Logger.getLogger(JAXRRegistryUnitTest.class);
-    private static String mDbDriver;
-	private static String mDbUrl;
-	private static String mDbUsername;
-	private static String mDbPassword;
-	/**
-	 * Tests the successful creation of the RED HAT/JBossESB Organization.
-	 */
-	@Test
-	public void publishOrganization() 
-	{
-		try {
-			Organization org = JAXRRegistryImpl.createJBossESBOrganization();
-			logger.log(Priority.INFO, "Succesfully created organization: " + org.getName().getValue());
-			assertEquals("Red Hat/JBossESB", org.getName().getValue());
-		} catch (JAXRException je) {
-			logger.log(Priority.ERROR, je.getLocalizedMessage(), je);
-			assertTrue(false);
-		}
-	}
-	@Test
-	public void findOrganization() 
-	{
-		try {
-			Organization org = JAXRRegistryImpl.findOrganization("Red Hat/JBossESB");
-			logger.log(Priority.INFO, "Succesfully created organization: " + org.getName().getValue());
-			assertEquals("Red Hat/JBossESB", org.getName().getValue());
-		} catch (JAXRException je) {
-			logger.log(Priority.ERROR, je.getLocalizedMessage(), je);
-			assertTrue(false);
-		}
-		try {
-			Organization org = JAXRRegistryImpl.findOrganization("Not Existing Org");
-			logger.log(Priority.INFO, "Could not find non-existing organization.");
-			assertEquals(null, org);
-		} catch (JAXRException je) {
-			logger.log(Priority.ERROR, je.getLocalizedMessage(), je);
-			assertTrue(false);
-		}
-	}
-	/**
-	 * Tests the successful registration of a Service.
-	 *
-	 */
-	@Test
-	public void publishService()
-	{
-		try {
-			JAXRRegistryImpl registry = new JAXRRegistryImpl();
-			registry.registerService("registry", "Registry Test ServiceName", "Registry Test Service Description");
-		} catch (JAXRException je) {
-			logger.log(Priority.ERROR, je.getLocalizedMessage(), je);
-			assertTrue(false);
-		}
-	}
-	@Test
-	public void publishServiceBinding()
-	{
-		try {
-			EPR epr = new EPR();
-			JAXRRegistryImpl registry = new JAXRRegistryImpl();
-			registry.registerEPR("registry", "Registry Test ServiceName", "Registry Test Service Description",
-					epr, "EPR description");
-		} catch (RegistryException re) {
-			logger.log(Priority.ERROR, re.getLocalizedMessage(), re);
-			assertTrue(false);
-		}
-	}
-	/**
-	 * Queries the newly added information
-	 * @throws Exception
-	 */
-	@Test
-	public void findServicesForAnOrganization()
-    {
-		try {
-			Organization org = JAXRRegistryImpl.findOrganization("Red Hat/JBossESB");
-			//Listing out the services and their Bindings
-			logger.log(Priority.INFO, "-------------------------------------------------");
-			logger.log(Priority.INFO, "Organization name: " + org.getName().getValue());
-			logger.log(Priority.INFO, "Description: " + org.getDescription().getValue());
-			logger.log(Priority.INFO, "Key id: " + org.getKey().getId());
-			User primaryContact = org.getPrimaryContact();
-			logger.log(Priority.INFO, "Primary Contact: " + primaryContact.getPersonName().getFullName());
-			Collection services = org.getServices();
-			for (Iterator serviceIter = services.iterator();serviceIter.hasNext();) {
-				Service service = (Service) serviceIter.next();
-				logger.log(Priority.INFO, "- Service Name: " + service.getName().getValue());
-				logger.log(Priority.INFO, "  Service Key : " + service.getKey().getId());
-				Collection serviceBindings = service.getServiceBindings();
-				for (Iterator serviceBindingIter = serviceBindings.iterator();serviceBindingIter.hasNext();){
-					ServiceBinding serviceBinding = (ServiceBinding) serviceBindingIter.next();
-					logger.log(Priority.INFO, "  ServiceBinding Description: " + serviceBinding.getDescription().getValue());
-					String xml = URLDecoder.decode(serviceBinding.getAccessURI(),"UTF-8");
-					logger.log(Priority.INFO, "  ServiceBinding URI: " + xml);
-					assertEquals(EPRHelper.toXMLString(new EPR()),xml);
-				}
-			}
-			logger.log(Priority.INFO, "-------------------------------------------------");
-	    } catch (Exception je) {
-			je.printStackTrace();
-			assertTrue(false);
-		}
-    }
-	/**
-	 * This doesn't work because scout drops the classifications on the floor.
-	 * We're ignoring this test until I come up with a patch.
-	 *
-	 */
-	public void findServicesByClassification()
-	{
-		Connection connection = JAXRRegistryImpl.getConnection();
-		try {
-			// Get registry service and business query manager
-			RegistryService rs = connection.getRegistryService();
-			BusinessQueryManager bqm = rs.getBusinessQueryManager();
-			BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
-			ClassificationScheme classificationScheme = bqm.findClassificationSchemeByName(null, "uddi-org:general_keywords");
-			Classification classification = blm.createClassification(classificationScheme,
-					"Test transformation service", "transformation");
-			Collection<Classification> classifications = new ArrayList<Classification>();
-			classifications.add(classification);
-			//Here I'd like to test filtering by this classification, but scout ignored the classification
-			String name=classificationScheme.getName().getValue();
-			System.out.println("Name=" + name);
-			Collection<String> nameParams = new ArrayList<String>();
-			//The name of the service is wild
-			nameParams.add("%");
-			BulkResponse bs = bqm.findServices(null, null,nameParams,classifications, null);
-			int status = bs.getStatus();
-			System.out.println("status=" + status);
-		} catch (JAXRException je) {
-			je.printStackTrace();
-		}
-		finally{}
-	}
-	/**
-	 * Setup the database.
-	 * @throws Exception
-	 */
-	@BeforeClass
-	public static void runBeforeAllTests() throws Exception {
-		try {
-			DOMConfigurator.configure(TestUtil.getPrefix() + "etc/test/resources/log4j.xml");
-			TestUtil.setESBPropertiesFileToUse();
-			//Set the juddi properties file in System so juddi will pick it up later and use the test values.
-			String juddiPropertiesFile = "/org/jboss/soa/esb/services/registry/juddi-unittest.properties";
-			System.setProperty("juddi.propertiesFile", juddiPropertiesFile);
-			//Read this properties file to get the db connection string
-			Properties props = new Properties();
-			InputStream inStream = Class.class.getResourceAsStream(juddiPropertiesFile);
-			props.load(inStream);
-			mDbDriver    = props.getProperty("juddi.jdbcDriver");
-			mDbUrl       = props.getProperty("juddi.jdbcUrl");
-			mDbUsername  = props.getProperty("juddi.jdbcUsername");
-			mDbPassword  = props.getProperty("juddi.jdbcPassword");
-			
-			String database="not tested yet";
-			if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
-				database = "hsqldb";
-				//Bring up hsql on default port 9001
-				HsqldbUtil.startHsqldb(TestUtil.getPrefix() + "build/hsqltestdb", "juddi");
-			} else if ("com.mysql.jdbc.Driver".equals(mDbDriver)) {
-				database = "mysql";
-			} //add and test your own database..
-			
-			//Get the registry-schema create scripts
-			String sqlDir = TestUtil.getPrefix() + "install/jUDDI-registry/sql/" + database + "/";
-			//Drop what is there now, if exists. We want to start fresh.
-			String sqlDropCmd      = FileUtil.readTextFile(new File(sqlDir + "drop_database.sql"));
-			String sqlCreateCmd    = FileUtil.readTextFile(new File(sqlDir + "create_database.sql"));
-			String sqlInsertPubCmd = FileUtil.readTextFile(new File(sqlDir + "insert_publishers.sql"));
-			
-			try {
-				Class.forName(mDbDriver);
-			} catch (Exception e) {
-				System.out.println("ERROR: failed to load " + database + " JDBC driver.");
-				e.printStackTrace();
-				return;
-			}
-			java.sql.Connection con = DriverManager.getConnection(mDbUrl, mDbUsername, mDbPassword);
-			Statement stmnt = con.createStatement();
-			System.out.println("Dropping the schema if exist");
-			stmnt.execute(sqlDropCmd);
-			System.out.println("Creating the juddi-schema");
-			stmnt.execute(sqlCreateCmd);
-			System.out.println("Adding the jbossesb publisher");
-			stmnt.execute(sqlInsertPubCmd);
-		} catch (Exception e) {
-			e.printStackTrace();
-			System.out.println("We should stop testing, since we don't have a db.");
-			assertTrue(false);
-		}
-	}
-	/**
-	 * Shutdown the database
-	 * @throws Exception
-	 */
-	@AfterClass
-	public static void runAfterAllTests() throws Exception {
-		if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
-			HsqldbUtil.stopHsqldb(mDbUrl, mDbUsername, mDbPassword);
-		}
-	}
-
-	public static junit.framework.Test suite() {
-		return new JUnit4TestAdapter(JAXRRegistryUnitTest.class);
-	}
-
-}

Deleted: labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java	2006-11-02 13:47:32 UTC (rev 7322)
+++ labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java	2006-11-02 14:07:16 UTC (rev 7323)
@@ -1,93 +0,0 @@
-/*
- * 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.soa.esb.services.routing.cbr;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.xml.DOMConfigurator;
-import org.jboss.soa.esb.common.tests.TestUtil;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
-import org.jboss.soa.esb.message.format.MessageType;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * 
- * @author kurt.stam at redhat.com
- *
- */
-public class JBossRulesRouterUnitTest
-{
-	@Test
-	public void routeSerializedMessage()
-	{
-        //new messages
-		Message message = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
-		//set some properties inside the Message
-		message.getProperties().setProperty("prop1", "val1");
-		message.getProperties().setProperty("prop2", "val2");
-		//set the body inside the Message
-		message.getBody().setContents(("TEST BODY").getBytes());
-		//set some object attachments inside the Message
-		message.getAttachment().addItem(new String("TEST ATTACHMENT1"));
-		message.getAttachment().addItem(new String("TEST ATTACHMENT2"));
-		
-		JBossRulesRouter jbossRulesRouter = new JBossRulesRouter();
-		List<String> destinationServices = jbossRulesRouter.route("JBossESBRules.drl", message);
-		assertEquals(destinationServices.iterator().next(),"test_category:Serialized_ServiceDestination");
-	}
-	
-	@Test
-	public void routeXMLMessage()
-	{
-		//add new messages
-		Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
-		//set some properties inside the Message
-		message.getProperties().setProperty("prop1", "val1");
-		message.getProperties().setProperty("prop2", "val2");
-		//set the body inside the Message
-		message.getBody().setContents(("TEST BODY").getBytes());
-		//set some object attachments inside the Message
-		message.getAttachment().addItem(new String("TEST ATTACHMENT1"));
-		message.getAttachment().addItem(new String("TEST ATTACHMENT2"));
-	
-		JBossRulesRouter jbossRulesRouter = new JBossRulesRouter();
-		List<String> destinationServices = jbossRulesRouter.route("JBossESBRules.drl", message);
-		assertEquals(destinationServices.iterator().next(),"test_category:JBOSS_XMLDestination");
-	}
-	
-	@BeforeClass
-	public static void runBeforeAllTests() throws Exception 
-	{
-		DOMConfigurator.configure(TestUtil.getPrefix() + "etc/test/resources/log4j.xml");
-	}
-	
-	public static junit.framework.Test suite() {
-		return new JUnit4TestAdapter(JBossRulesRouterUnitTest.class);
-	}
-
-}

Modified: labs/jbossesb/trunk/product/etc/test/resources/jbossesb-unittest-properties.xml
===================================================================
--- labs/jbossesb/trunk/product/etc/test/resources/jbossesb-unittest-properties.xml	2006-11-02 13:47:32 UTC (rev 7322)
+++ labs/jbossesb/trunk/product/etc/test/resources/jbossesb-unittest-properties.xml	2006-11-02 14:07:16 UTC (rev 7323)
@@ -37,7 +37,7 @@
     <properties name="registry">
     	<property name="org.jboss.soa.esb.registry.queryManagerURI" value="org.apache.juddi.registry.local.InquiryService#inquire"/>
     	<property name="org.jboss.soa.esb.registry.lifeCycleManagerURI" value="org.apache.juddi.registry.local.PublishService#publish"/>
-    	<property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.soa.esb.services.registry.JAXRRegistryImpl"/>
+    	<property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/>
     	<property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
     	<property name="org.jboss.soa.esb.registry.user" value="jbossesb"/>
     	<property name="org.jboss.soa.esb.registry.password" value="password"/>
@@ -71,6 +71,6 @@
 		<property name="org.jboss.soa.esb.persistence.db.pool.timeout.millis"	value="5000"/> 
     </properties>
     <properties name="messagerouting">
-    	<property name="org.jboss.soa.esb.routing.cbrClass" value="org.jboss.soa.esb.services.routing.cbr.JBossRulesRouter"/>
+    	<property name="org.jboss.soa.esb.routing.cbrClass" value="org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter"/>
     </properties>
 </esb>

Modified: labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml
===================================================================
--- labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml	2006-11-02 13:47:32 UTC (rev 7322)
+++ labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml	2006-11-02 14:07:16 UTC (rev 7323)
@@ -37,7 +37,7 @@
     <properties name="registry">
     	<property name="org.jboss.soa.esb.registry.queryManagerURI" value="org.apache.juddi.registry.local.InquiryService#inquire"/>
     	<property name="org.jboss.soa.esb.registry.lifeCycleManagerURI" value="org.apache.juddi.registry.local.PublishService#publish"/>
-    	<property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.soa.esb.services.registry.JAXRRegistryImpl"/>
+    	<property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/>
     	<property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
     	<property name="org.jboss.soa.esb.registry.user" value="jbossesb"/>
     	<property name="org.jboss.soa.esb.registry.password" value="password"/>
@@ -71,6 +71,6 @@
 		<property name="org.jboss.soa.esb.persistence.db.pool.timeout.millis"	value="5000"/> 
     </properties>
     <properties name="messagerouting">
-    	<property name="org.jboss.soa.esb.routing.cbrClass" value="org.jboss.soa.esb.services.routing.cbr.JBossRulesRouter"/>
+    	<property name="org.jboss.soa.esb.routing.cbrClass" value="org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter"/>
     </properties>
 </esb>




More information about the jboss-svn-commits mailing list