You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by ks...@apache.org on 2007/01/04 20:59:40 UTC

svn commit: r492708 - in /webservices/juddi/trunk: ./ src/java/org/apache/juddi/registry/rmi/ webapp/WEB-INF/

Author: kstam
Date: Thu Jan  4 11:59:39 2007
New Revision: 492708

URL: http://svn.apache.org/viewvc?view=rev&rev=492708
Log:
juddi-93. Enabling RMI access to JUDDI. This is not using any framework, to not introduce more dependencies
however this also means there is no connection pooling and we have to self register it to jndi. This
can be done by running a servlet load-on-startup, see the commented section in the web.xml.

Added:
    webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/
    webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/Inquiry.java
    webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/InquiryService.java
    webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/JNDIRegistration.java
    webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/Publish.java
    webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/PublishService.java
    webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/RegistrationService.java
Modified:
    webservices/juddi/trunk/build.xml
    webservices/juddi/trunk/webapp/WEB-INF/web.xml

Modified: webservices/juddi/trunk/build.xml
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/build.xml?view=diff&rev=492708&r1=492707&r2=492708
==============================================================================
--- webservices/juddi/trunk/build.xml (original)
+++ webservices/juddi/trunk/build.xml Thu Jan  4 11:59:39 2007
@@ -51,6 +51,7 @@
     <property name="owner"               value="Apache Software Foundation"/>
     <property name="title"               value="jUDDI ${version}"/>
     <property name="jar.file"            value="${name}.jar"/>
+  	<property name="client.jar.file"     value="${name}-client.jar"/>
     <property name="war.file"            value="${name}.war"/>
     <property name="ear.file"            value="${name}.ear"/>
     <property name="sql.dir"             value="${basedir}/sql"/>
@@ -123,6 +124,12 @@
       classname="javax.xml.rpc.Service"
       classpathref="project.classpath"/>
     <echo message="jaxrpc.present=${jaxrpc.present}" />
+  	
+  	<!-- Java API for XML Registries (jaxr-api.jar) 
+  	    <available property="jaxr.present"
+  	      classname="javax.xml.registry.RegistryException"
+  	      classpathref="project.classpath"/>
+  	    <echo message="jaxr.present=${jaxr.present}" /> -->
 
     <!-- SOAP with Attachments API for Java (saaj.jar) -->
     <available property="saaj.present"
@@ -142,10 +149,18 @@
       <src path="${java.dir}"/>
     </javac>
   </target>
+	
+  <target name="rmic" depends="compile">
+  	<rmic base="${classes.dir}"
+ 		includes="org/apache/juddi/registry/rmi/PublishService.class,
+  		org/apache/juddi/registry/rmi/InquiryService.class"/>
+  </target>
+	
+	
   <!-- =================================================================== -->
   <!-- Creates the Java libraries (juddi.jar)                              -->
   <!-- =================================================================== -->
-  <target name="jar" depends="compile">
+  <target name="jar" depends="rmic">
     <mkdir dir="${build.dir}"/>
     <jar
       destfile="${build.dir}/${jar.file}"
@@ -156,6 +171,11 @@
       update="true"
       basedir="${java.dir}"
       includes="org/apache/juddi/i18n/*.properties"/>
+  	<jar
+  	      destfile="${build.dir}/${client.jar.file}"
+  	      basedir="${classes.dir}"
+  		  includes="org/apache/juddi/registry/rmi/**"
+  	      excludes="org/apache/juddi/registry/rmi/*Service.class"/>
   </target>
   <!-- =================================================================== -->
   <!-- Build the jUDDI Web Application (juddi.war)                         -->

Added: webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/Inquiry.java
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/Inquiry.java?view=auto&rev=492708
==============================================================================
--- webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/Inquiry.java (added)
+++ webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/Inquiry.java Thu Jan  4 11:59:39 2007
@@ -0,0 +1,11 @@
+package org.apache.juddi.registry.rmi;
+
+import java.rmi.Remote;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public interface Inquiry extends Remote
+{
+	Node inquire (Element request) throws java.rmi.RemoteException;
+}

Added: webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/InquiryService.java
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/InquiryService.java?view=auto&rev=492708
==============================================================================
--- webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/InquiryService.java (added)
+++ webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/InquiryService.java Thu Jan  4 11:59:39 2007
@@ -0,0 +1,35 @@
+package org.apache.juddi.registry.rmi;
+
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+import javax.xml.registry.RegistryException;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class InquiryService extends UnicastRemoteObject
+	implements Inquiry
+{
+	private static final long serialVersionUID = 1L;
+
+	public InquiryService() throws RemoteException {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+
+	public Node inquire(Element request) throws RemoteException {
+		Node response = null;
+		org.apache.juddi.registry.local.InquiryService inquiryService =
+			new org.apache.juddi.registry.local.InquiryService();
+		try {
+			response = inquiryService.inquire(request);
+		} catch (RegistryException e) {
+			throw new RemoteException(e.getLocalizedMessage(), e);
+		}
+		return response;
+	}
+	
+
+
+}

Added: webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/JNDIRegistration.java
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/JNDIRegistration.java?view=auto&rev=492708
==============================================================================
--- webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/JNDIRegistration.java (added)
+++ webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/JNDIRegistration.java Thu Jan  4 11:59:39 2007
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juddi.registry.rmi;
+
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.registry.RegistryEngine;
+import org.apache.juddi.util.Config;
+
+/**
+ * @author Kurt Stam (kurt.stam@redhat.com)
+ */
+public class JNDIRegistration
+{
+	/** Instance of the InqueryService, so we have a running instance we 
+	 *  can remotely attach to it later. */
+	public static Inquiry mInquery=null;
+	/** Instance of the PublishService, so we have a running instance we
+	 *  can remotely attach to it later. */
+	public static Publish mPublish=null;
+	/** Name of the inquiry service in JNDI */
+	public static String INQUIRY_SERVICE="/InquiryService";
+	/** Name of the publish service in JNDI */
+	public static String PUBLISH_SERVICE="/PublishService";
+	/** Logger */
+	private static Log log = LogFactory.getLog(JNDIRegistration.class);
+	/**
+	 * Registers the Publish and Inquiry Services to JNDI and instantiates a
+	 * instance of each so we can remotely attach to it later.
+	 */
+	public static void register()
+	{
+		try {
+			//Getting the JNDI setting from the config
+			String factoryInitial = Config.getStringProperty(
+					  RegistryEngine.PROPNAME_JAVA_NAMING_FACTORY_INITIAL,
+					  RegistryEngine.DEFAULT_JAVA_NAMING_FACTORY_INITIAL);
+			String providerURL = Config.getStringProperty(
+					  RegistryEngine.PROPNAME_JAVA_NAMING_PROVIDER_URL,
+					  RegistryEngine.DEFAULT_JAVA_NAMING_PROVIDER_URL);
+			String factoryURLPkgs = Config.getStringProperty(
+					  RegistryEngine.PROPNAME_JAVA_NAMING_FACTORY_URL_PKGS,
+					  RegistryEngine.DEFAULT_JAVA_NAMING_FACTORY_URL_PKGS);
+			//Setting them in the properties for the Initial Context 
+			Properties env = new Properties();
+			env.setProperty(RegistryEngine.PROPNAME_JAVA_NAMING_FACTORY_INITIAL, factoryInitial);
+			env.setProperty(RegistryEngine.PROPNAME_JAVA_NAMING_PROVIDER_URL, providerURL);
+			env.setProperty(RegistryEngine.PROPNAME_JAVA_NAMING_FACTORY_URL_PKGS, factoryURLPkgs); 
+			log.info("Creating Initial Context using: \n" 
+				+ RegistryEngine.PROPNAME_JAVA_NAMING_FACTORY_INITIAL + "=" + factoryInitial + "\n"
+				+ RegistryEngine.PROPNAME_JAVA_NAMING_PROVIDER_URL    + "=" + providerURL + "\n"
+				+ RegistryEngine.PROPNAME_JAVA_NAMING_FACTORY_URL_PKGS + "=" + factoryURLPkgs + "\n");
+			InitialContext context = new InitialContext(env);
+			Inquiry inquiry = new InquiryService();
+			log.info("Setting " + INQUIRY_SERVICE + ", " + inquiry.getClass().getName());
+			mInquery = inquiry;
+			context.bind(INQUIRY_SERVICE, inquiry);
+			Publish publish = new PublishService();
+			log.info("Setting " + PUBLISH_SERVICE + ", " + publish.getClass().getName());
+			mPublish = publish;
+			context.bind(PUBLISH_SERVICE, publish);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+}

Added: webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/Publish.java
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/Publish.java?view=auto&rev=492708
==============================================================================
--- webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/Publish.java (added)
+++ webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/Publish.java Thu Jan  4 11:59:39 2007
@@ -0,0 +1,11 @@
+package org.apache.juddi.registry.rmi;
+
+import java.rmi.Remote;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public interface Publish extends Remote
+{
+	Node publish (Element request) throws java.rmi.RemoteException;
+}

Added: webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/PublishService.java
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/PublishService.java?view=auto&rev=492708
==============================================================================
--- webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/PublishService.java (added)
+++ webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/PublishService.java Thu Jan  4 11:59:39 2007
@@ -0,0 +1,36 @@
+package org.apache.juddi.registry.rmi;
+
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+import javax.xml.registry.RegistryException;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class PublishService extends UnicastRemoteObject
+	implements Publish
+{
+
+	private static final long serialVersionUID = 1L;
+
+	public PublishService() throws RemoteException {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+
+	public Node publish(Element request) throws RemoteException {
+		Node response = null;
+		org.apache.juddi.registry.local.PublishService publishService = 
+			new org.apache.juddi.registry.local.PublishService();
+		try {
+			response = publishService.publish(request);
+		} catch (RegistryException e) {
+			throw new RemoteException(e.getLocalizedMessage(), e);
+		}
+		return response;
+	}
+	
+
+
+}

Added: webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/RegistrationService.java
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/RegistrationService.java?view=auto&rev=492708
==============================================================================
--- webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/RegistrationService.java (added)
+++ webservices/juddi/trunk/src/java/org/apache/juddi/registry/rmi/RegistrationService.java Thu Jan  4 11:59:39 2007
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juddi.registry.rmi;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+
+/**
+ * @author Kurt Stam (kurt.stam@redhat.com)
+ */
+public class RegistrationService extends HttpServlet
+{
+	public static Inquiry mInquery=null;
+	public static Publish mPublish=null;
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	public void init() throws ServletException 
+	{
+		super.init();
+		JNDIRegistration.register();
+	}
+
+  
+}

Modified: webservices/juddi/trunk/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/webapp/WEB-INF/web.xml?view=diff&rev=492708&r1=492707&r2=492708
==============================================================================
--- webservices/juddi/trunk/webapp/WEB-INF/web.xml (original)
+++ webservices/juddi/trunk/webapp/WEB-INF/web.xml Thu Jan  4 11:59:39 2007
@@ -41,7 +41,14 @@
     <display-name>UDDI Version 2.0 Publish Service</display-name>
     <servlet-class>org.apache.juddi.registry.PublishService</servlet-class>
   </servlet>
-
+  <!--  uncomment if you want to enable making calls in juddi with rmi 
+  <servlet>
+  	<servlet-name>RegisterServicesWithJNDI</servlet-name>
+  	<servlet-class>org.apache.juddi.registry.rmi.RegistrationService</servlet-class>
+  	<load-on-startup>1</load-on-startup>
+  </servlet> -->
+ 
+   
   <servlet-mapping>
     <servlet-name>jUDDIAdminService</servlet-name>
     <url-pattern>/admin</url-pattern>



---------------------------------------------------------------------
To unsubscribe, e-mail: juddi-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: juddi-cvs-help@ws.apache.org