[jboss-svn-commits] JBL Code SVN: r28899 - labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Aug 11 06:36:30 EDT 2009
Author: kevin.conner at jboss.com
Date: 2009-08-11 06:36:30 -0400 (Tue, 11 Aug 2009)
New Revision: 28899
Removed:
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/RemoteHttpServlet.java
Modified:
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/InquiryService.java
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/JNDIRegistration.java
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/PublishService.java
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/RegistrationService.java
Log:
Fix up exception handling: JBESB-2782
Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/InquiryService.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/InquiryService.java 2009-08-11 10:32:03 UTC (rev 28898)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/InquiryService.java 2009-08-11 10:36:30 UTC (rev 28899)
@@ -116,7 +116,7 @@
rs.getServletConfig().getServletContext().getRequestDispatcher("/uddi/inquiry").forward(soaprequest,soapresponse);
} catch (Exception e) {
- e.printStackTrace();
+ throw new RemoteException("Unexpected error executing request", e);
}
Node node = null;
@@ -126,8 +126,7 @@
node = marshalResult(content);
}
} catch (Exception e) {
- e.printStackTrace();
- throw new RemoteException("", e.fillInStackTrace());
+ throw new RemoteException("Unexpected exception marshalling result", e);
}
return node;
}
Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/JNDIRegistration.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/JNDIRegistration.java 2009-08-11 10:32:03 UTC (rev 28898)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/JNDIRegistration.java 2009-08-11 10:36:30 UTC (rev 28899)
@@ -21,9 +21,11 @@
*/
package org.jboss.soa.esb.registry.rmi;
+import java.rmi.RemoteException;
import java.util.Properties;
import javax.naming.InitialContext;
+import javax.naming.NamingException;
/**
* @author Tom Cunningham (tcunning at redhat.com)
@@ -45,8 +47,8 @@
public static String PUBLISH_SERVICE="/PublishService";
public static void register(RegistrationService regService)
+ throws NamingException, RemoteException
{
- try {
String factoryInitial = System.getProperty(PROPNAME_JAVA_NAMING_FACTORY_INITIAL);
String providerURL = System.getProperty(PROPNAME_JAVA_NAMING_PROVIDER_URL);
String factoryURLPkgs = System.getProperty(PROPNAME_JAVA_NAMING_FACTORY_URL_PKGS);
@@ -68,18 +70,32 @@
env.setProperty(PROPNAME_JAVA_NAMING_FACTORY_URL_PKGS, factoryURLPkgs);
InitialContext context = new InitialContext(env);
- Inquiry inquiry = new InquiryService();
+ InquiryService inquiry = new InquiryService();
- ((InquiryService)inquiry).setRegistrationService(regService);
- inquiryReg = inquiry;
- context.rebind(INQUIRY_SERVICE, inquiry);
- Publish publish = new PublishService();
- ((PublishService)publish).setRegistrationService(regService);
+ inquiry.setRegistrationService(regService);
+ try {
+ context.rebind(INQUIRY_SERVICE, inquiry);
+ } catch (final NamingException ne) {
+ InquiryService.unexportObject(inquiry, true) ;
+ throw ne ;
+ }
+ PublishService publish ;
+ try {
+ publish = new PublishService();
+ } catch (final RemoteException re) {
+ InquiryService.unexportObject(inquiry, true) ;
+ throw re ;
+ }
+ publish.setRegistrationService(regService);
+ try {
+ context.rebind(PUBLISH_SERVICE, publish);
+ } catch (final NamingException ne) {
+ InquiryService.unexportObject(inquiry, true) ;
+ PublishService.unexportObject(publish, true) ;
+ throw ne ;
+ }
publishReg = publish;
- context.rebind(PUBLISH_SERVICE, publish);
- } catch (Exception e) {
- e.printStackTrace();
- }
+ inquiryReg = inquiry;
}
}
Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/PublishService.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/PublishService.java 2009-08-11 10:32:03 UTC (rev 28898)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/PublishService.java 2009-08-11 10:36:30 UTC (rev 28899)
@@ -115,7 +115,7 @@
rs.getServletConfig().getServletContext().getRequestDispatcher("/uddi/publishing").forward(soaprequest,soapresponse);
} catch (Exception e) {
- e.printStackTrace();
+ throw new RemoteException("Unexpected error executing request", e);
}
Node node = null;
@@ -125,8 +125,7 @@
node = marshalResult(content);
}
} catch (Exception e) {
- e.printStackTrace();
- throw new RemoteException("", e.fillInStackTrace());
+ throw new RemoteException("Unexpected exception marshalling result", e);
}
return node;
}
Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/RegistrationService.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/RegistrationService.java 2009-08-11 10:32:03 UTC (rev 28898)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/RegistrationService.java 2009-08-11 10:36:30 UTC (rev 28899)
@@ -39,7 +39,14 @@
public void init() throws ServletException
{
super.init();
- JNDIRegistration.register(this);
+ try
+ {
+ JNDIRegistration.register(this);
+ }
+ catch (final Exception ex)
+ {
+ throw new ServletException("Unexpected exception during registration", ex) ;
+ }
}
}
Deleted: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/RemoteHttpServlet.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/RemoteHttpServlet.java 2009-08-11 10:32:03 UTC (rev 28898)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/rmi/RemoteHttpServlet.java 2009-08-11 10:36:30 UTC (rev 28899)
@@ -1,148 +0,0 @@
-package org.jboss.soa.esb.registry.rmi;
-
-// Copyright (C) 1998 by Jason Hunter <jhunter at acm.org>. All rights reserved.
-// Use of this class is limited. Please see the LICENSE for more information.
-
-import java.io.*;
-import java.net.*;
-import java.rmi.*;
-import java.rmi.server.*;
-import java.rmi.registry.*;
-import java.util.*;
-import javax.servlet.*;
-import javax.servlet.http.*;
-
-
-/**
- * A superclass for any HTTP servlet that wishes to act as an RMI server.
- * RemoteHttpServlet begins listening for RMI calls in its
- * <tt>init()</tt> method and stops listening in its <tt>destroy()</tt>
- * method. To register itself it uses the registry on the local machine
- * on the port determined by <tt>getRegistryPort()</tt>. It registers
- * under the name determined by <tt>getRegistryName()</tt>.
- *
- * @see com.oreilly.servlet.RemoteDaemonHttpServlet
- *
- * @author <b>Jason Hunter</b>, Copyright © 1998
- * @version 1.0, 98/09/18
- */
-public abstract class RemoteHttpServlet extends HttpServlet
- implements Remote {
- /**
- * The registry for the servlet
- */
- protected Registry registry;
-
- /**
- * Begins the servlet's RMI operations. Causes the servlet to export
- * itself and then bind itself to the registry. Logs any errors.
- * Subclasses that override this method must be sure to first call
- * <tt>super.init(config)</tt>.
- *
- * @param config the servlet config
- * @exception ServletException if a servlet exception occurs
- */
- public void init(ServletConfig config) throws ServletException {
- super.init(config);
- try {
- UnicastRemoteObject.exportObject(this);
- bind();
- }
- catch (RemoteException e) {
- log("Problem binding to RMI registry: " + e.getMessage());
- }
- }
-
- /**
- * Halts the servlet's RMI operations. Causes the servlet to
- * unbind itself from the registry. Logs any errors. Subclasses that
- * override this method must be sure to first call <tt>super.destroy()</tt>.
- */
- public void destroy() {
- unbind();
- }
-
- /**
- * Returns the name under which the servlet should be bound in the
- * registry. By default the name is the servlet's class name. This
- * can be overridden with the <tt>registryName</tt> init parameter.
- *
- * @return the name under which the servlet should be bound in the registry
- */
- protected String getRegistryName() {
- // First name choice is the "registryName" init parameter
- String name = getInitParameter("registryName");
- if (name != null) return name;
-
- // Fallback choice is the name of this class
- return this.getClass().getName();
- }
-
- /**
- * Returns the port where the registry should be running. By default
- * the port is the default registry port (1099). This can be
- * overridden with the <tt>registryPort</tt> init parameter.
- *
- * @return the port for the registry
- */
- protected int getRegistryPort() {
- // First port choice is the "registryPort" init parameter
- try { return Integer.parseInt(getInitParameter("registryPort")); }
-
- // Fallback choice is the default registry port (1099)
- catch (NumberFormatException e) { return Registry.REGISTRY_PORT; }
- }
-
- /**
- * Binds the servlet to the registry. Creates the registry if necessary.
- * Logs any errors.
- */
- protected void bind() {
- // Try to find the appropriate registry already running
- try {
- registry = LocateRegistry.getRegistry(getRegistryPort());
- registry.list(); // Verify it's alive and well
- }
- catch (Exception e) {
- // Couldn't get a valid registry
- registry = null;
- }
-
- // If we couldn't find it, we need to create it.
- // (Equivalent to running "rmiregistry")
- if (registry == null) {
- try {
- registry = LocateRegistry.createRegistry(getRegistryPort());
- }
- catch (Exception e) {
- log("Could not get or create RMI registry on port " +
- getRegistryPort() + ": " + e.getMessage());
- return;
- }
- }
-
- // If we get here, we must have a valid registry.
- // Now register this servlet instance with that registry.
- try {
- registry.rebind(getRegistryName(), this);
- }
- catch (Exception e) {
- log("Could not bind to RMI registry: " + e.getMessage());
- return;
- }
- }
-
- /**
- * Unbinds the servlet from the registry.
- * Logs any errors.
- */
- protected void unbind() {
- try {
- if (registry != null) registry.unbind(getRegistryName());
- }
- catch (Exception e) {
- log("Problem unbinding from RMI registry: " + e.getMessage());
- }
- }
-}
-
More information about the jboss-svn-commits
mailing list