From 1d502eda5a49daf9fd08baa59d8a2c7f4dd32623 Mon Sep 17 00:00:00 2001 From: lresende Date: Sat, 20 Feb 2010 08:38:29 +0000 Subject: Adding try/catch to display warning when dojo or tuscany dojo extensions are already registered git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@912088 13f79535-47bb-0310-9956-ffa450edef68 --- .../web/javascript/dojo/DojoModuleActivator.java | 28 +++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'sca-java-2.x/trunk/modules/web-javascript-dojo/src/main') diff --git a/sca-java-2.x/trunk/modules/web-javascript-dojo/src/main/java/org/apache/tuscany/sca/web/javascript/dojo/DojoModuleActivator.java b/sca-java-2.x/trunk/modules/web-javascript-dojo/src/main/java/org/apache/tuscany/sca/web/javascript/dojo/DojoModuleActivator.java index fa1a46b384..f9fdd96e1f 100644 --- a/sca-java-2.x/trunk/modules/web-javascript-dojo/src/main/java/org/apache/tuscany/sca/web/javascript/dojo/DojoModuleActivator.java +++ b/sca-java-2.x/trunk/modules/web-javascript-dojo/src/main/java/org/apache/tuscany/sca/web/javascript/dojo/DojoModuleActivator.java @@ -20,6 +20,7 @@ package org.apache.tuscany.sca.web.javascript.dojo; import java.net.URI; +import java.util.logging.Logger; import javax.servlet.Servlet; @@ -27,8 +28,11 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.ModuleActivator; import org.apache.tuscany.sca.host.http.ServletHost; import org.apache.tuscany.sca.host.http.ServletHostHelper; +import org.apache.tuscany.sca.host.http.ServletMappingException; public class DojoModuleActivator implements ModuleActivator { + private final static Logger logger = Logger.getLogger(DojoModuleActivator.class.getName()); + private static final String dojoBaseUri = URI.create("/dojo").toString(); private static final String dojoUri = URI.create("/dojo/*").toString(); @@ -51,20 +55,28 @@ public class DojoModuleActivator implements ModuleActivator { servlet = servletHost.getServletMapping(dojoBaseUri); if(servlet == null) { - DojoResourceServlet baseResourceServlet = new DojoResourceServlet(); - servletHost.addServletMapping(dojoBaseUri, baseResourceServlet); + try { + DojoResourceServlet baseResourceServlet = new DojoResourceServlet(); + servletHost.addServletMapping(dojoBaseUri, baseResourceServlet); - DojoResourceServlet resourceServlet = new DojoResourceServlet(); - servletHost.addServletMapping(dojoUri, resourceServlet); + DojoResourceServlet resourceServlet = new DojoResourceServlet(); + servletHost.addServletMapping(dojoUri, resourceServlet); + } catch (ServletMappingException me ) { + logger.warning("Dojo already registered at :" + dojoBaseUri); + } } servlet = servletHost.getServletMapping(tuscanyBaseUri); if(servlet == null) { - DojoResourceServlet baseResourceServlet = new DojoResourceServlet(); - servletHost.addServletMapping(tuscanyBaseUri, baseResourceServlet); + try { + DojoResourceServlet baseResourceServlet = new DojoResourceServlet(); + servletHost.addServletMapping(tuscanyBaseUri, baseResourceServlet); - DojoResourceServlet resourceServlet = new DojoResourceServlet(); - servletHost.addServletMapping(tuscanyUri, resourceServlet); + DojoResourceServlet resourceServlet = new DojoResourceServlet(); + servletHost.addServletMapping(tuscanyUri, resourceServlet); + } catch (ServletMappingException me ) { + logger.warning("Tuscany dojo extensions already registered at :" + tuscanyBaseUri); + } } } -- cgit v1.2.3