[jboss-svn-commits] JBL Code SVN: r6967 - in labs/jbossesb/trunk/product/core/services: src/org/jboss/soa/esb/services/registry tests/src/org/jboss/soa/esb/services/registry

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Oct 20 13:23:16 EDT 2006


Author: kurt.stam at jboss.com
Date: 2006-10-20 13:23:14 -0400 (Fri, 20 Oct 2006)
New Revision: 6967

Added:
   labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java
Removed:
   labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java
Modified:
   labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/RegistryUnitTest.java
Log:
Working on Registry

Copied: labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java (from rev 6896, labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java)
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java	2006-10-18 17:28:32 UTC (rev 6896)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java	2006-10-20 17:23:14 UTC (rev 6967)
@@ -0,0 +1,140 @@
+/*
+* 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.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.xml.registry.Connection;
+import javax.xml.registry.ConnectionFactory;
+import javax.xml.registry.JAXRException;
+import javax.xml.registry.infomodel.Service;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+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 
+{
+	private static Logger logger = Logger.getLogger(JAXRRegistryImpl.class);
+	public static Set<PasswordAuthentication> creds = new HashSet<PasswordAuthentication>();
+	
+	private static Properties props = new Properties();
+	
+	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
+	 */
+	public void publish(String serviceName, EPR epr) {
+		
+	}
+	/** 
+	 * Remove an EPR from the Registry
+	 */
+	public void unPublish(EPR epr) {
+		
+	}
+	/** 
+	 * Find all ESB Services
+	 * @return collection services
+	 */
+	public Collection<Service> findServices() 
+	{
+		Collection<Service> services = new ArrayList<Service>();
+		return services;
+	}
+	/**
+	 * Find Services based on a type ("transformation"
+	 * 
+	 * @param serviceType
+	 * @return collection services
+	 */
+	public Collection<Service> findServices(String serviceType){
+		Collection<Service> services = new ArrayList<Service>();
+		return services;
+	}
+	/**
+	 * 
+	 * @param service
+	 * @return
+	 */
+	Collection<EPR> findEPR(Service service){
+		Collection<EPR> eprs = new ArrayList<EPR>();
+		return eprs;
+	}
+}

Deleted: labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java	2006-10-20 16:45:31 UTC (rev 6966)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java	2006-10-20 17:23:14 UTC (rev 6967)
@@ -1,95 +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.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.xml.registry.Connection;
-import javax.xml.registry.ConnectionFactory;
-import javax.xml.registry.JAXRException;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.jboss.soa.esb.common.Configuration;
-/**
- * Utility class for the Registry.
- * Right now the connection properties are static. We'll have to see if we need to make this dynamic.
- *
- * @author Kurt Stam
- */
-public class Registry 
-{
-	private static Logger logger = Logger.getLogger(Registry.class);
-	public static Set<PasswordAuthentication> creds = new HashSet<PasswordAuthentication>();
-	
-	private static Properties props = new Properties();
-	
-	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. 
-	 */
-	public 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
-	 */
-	public static void closeConnection(Connection connection)
-	{
-		try {
-			if (connection!=null && !connection.isClosed()) {
-				connection.close();
-			}
-		} catch (JAXRException je) {
-			logger.log(Priority.ERROR, je.getMessage(), je);
-		}
-	}
-}

Modified: labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/RegistryUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/RegistryUnitTest.java	2006-10-20 16:45:31 UTC (rev 6966)
+++ labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/RegistryUnitTest.java	2006-10-20 17:23:14 UTC (rev 6967)
@@ -21,6 +21,7 @@
 */
 package org.jboss.soa.esb.services.registry;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -61,7 +62,6 @@
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.assertEquals;
 /**
  * Testing the registry.
  * 
@@ -80,10 +80,10 @@
 	public void publishOrganization() 
 	{
 		//Getting the connection to the Registry (reading config)
-		Connection connection = Registry.getConnection();
+		Connection connection = JAXRRegistryImpl.getConnection();
 		try {
 			//Logging in
-			connection.setCredentials(Registry.creds);
+			connection.setCredentials(JAXRRegistryImpl.creds);
 			RegistryService rs = connection.getRegistryService();
 			//Building organization
 			BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
@@ -175,7 +175,7 @@
 			e.printStackTrace();
 			assertTrue(false);
 		} finally {
-			Registry.closeConnection(connection);
+			JAXRRegistryImpl.closeConnection(connection);
 		}
 	}
 	/**
@@ -186,7 +186,7 @@
 	public void queryForOrganizations()
     {
 		String queryString = "JBOSS"; //All organization with JBOSS in the name.
-		Connection connection = Registry.getConnection();
+		Connection connection = JAXRRegistryImpl.getConnection();
 		try {
 			// Get registry service and business query manager
 			RegistryService rs = connection.getRegistryService();
@@ -217,11 +217,11 @@
 					Collection serviceBindings = service.getServiceBindings();
 					for (Iterator serviceBindingIter = serviceBindings.iterator();serviceBindingIter.hasNext();){
 						ServiceBinding serviceBinding = (ServiceBinding) serviceBindingIter.next();
+						System.out.println("ServiceBinding Name: " + serviceBinding.getName().getValue());
 						System.out.println("ServiceBinding Description: " + serviceBinding.getDescription().getValue());
 						System.out.println("ServiceBinding URI: " + serviceBinding.getAccessURI());
 						assertEquals("http://www.jboss.com/services/TestService",serviceBinding.getAccessURI());
 					}
-					
 				}
 			}
 			
@@ -229,11 +229,73 @@
 			e.printStackTrace();
 			assertTrue(false);
 		} finally {
-			Registry.closeConnection(connection);
+			JAXRRegistryImpl.closeConnection(connection);
 		}
+    }
+	/**
+	 * 
+	 */
+	@SuppressWarnings("unchecked")
+	@Test
+	public void publishAnEPR() {
+//		String EPR_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+//			+ "<EPR>"
+//			+ "	<wsa:Address>jms://queue</wsa:Address>"
+//			+ "	<wsa:ReferenceProperties>"
+//	        + "		<wsarjaddr:specification-version xmlns:wsarjaddr=\"http://schemas.arjuna.com/ws/2004/06/wsarjaddr\">1.1</wsarjaddr:specification-version>"
+//	        + "		<wsarjaddr:destination-name xmlns:wsarjaddr=\"http://schemas.arjuna.com/ws/2004/06/wsarjaddr\">queue/A</wsarjaddr:destination-name>"
+//	        + "		<wsarjaddr:connection-factory xmlns:wsarjaddr=\"http://schemas.arjuna.com/ws/2004/06/wsarjaddr\">ConnectionFactory</wsarjaddr:connection-factory>"
+//	        + "		<wsarjaddr:jndi-type xmlns:wsarjaddr=\"http://schemas.arjuna.com/ws/2004/06/wsarjaddr\">jboss</wsarjaddr:jndi-type>"
+//	        + "		<wsarjaddr:jndi-URL xmlns:wsarjaddr=\"http://schemas.arjuna.com/ws/2004/06/wsarjaddr\">localhost</wsarjaddr:jndi-URL>"
+//	        + "		<wsarjaddr:message-selector xmlns:wsarjaddr=\"http://schemas.arjuna.com/ws/2004/06/wsarjaddr\">listener='maradona'</wsarjaddr:message-selector>"
+//	        + "	</wsa:ReferenceProperties>"
+//	        + "</EPR>";
+//		String serviceName="Kurt's Travel Agency";
+//		String serviceURI="epr:jbossesb:version:1.0:logicalname:KurtsTravelAgency";
+		
+		Connection connection = JAXRRegistryImpl.getConnection();
+		try {
+			//Logging in
+			connection.setCredentials(JAXRRegistryImpl.creds);
+			RegistryService rs = connection.getRegistryService();
+			BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+			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("%JBOSS%");
+//			 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);
 
-}
-
+			System.out.println("Found " + response.getCollection().size() + " organization.");
+			for (Iterator orgIter = response.getCollection().iterator(); orgIter.hasNext();) 
+			{
+				Organization org = (Organization) orgIter.next();
+				Service service = blm.createService(blm.createInternationalString("JBossESB TEST Service"));
+				service.setDescription(blm.createInternationalString("Services of the ESB UDDI Registry"));
+				org.addService(service);
+				Collection services = new ArrayList();
+				services.add(service);
+				BulkResponse br=blm.saveServices(services);
+				if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
+					br.getCollection();
+					//ServiceBinding serviceBinding = 
+					//service.addServiceBinding(serviceBinding);
+				}
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			assertTrue(false);
+		} finally {
+			JAXRRegistryImpl.closeConnection(connection);
+		}
+		
+		
+		
+	}
 	/**
 	 * Creates a Jaxr Organization with 1 or more services
 	 * 




More information about the jboss-svn-commits mailing list