[jbossws-commits] JBossWS SVN: r3901 - branches/tdiesler/trunk/integration/native/src/main/java/org/jboss/wsf/stack/jbws.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Mon Jul 16 16:47:17 EDT 2007


Author: thomas.diesler at jboss.com
Date: 2007-07-16 16:47:16 -0400 (Mon, 16 Jul 2007)
New Revision: 3901

Added:
   branches/tdiesler/trunk/integration/native/src/main/java/org/jboss/wsf/stack/jbws/ServiceEndpointContextListener.java
Log:
partial

Added: branches/tdiesler/trunk/integration/native/src/main/java/org/jboss/wsf/stack/jbws/ServiceEndpointContextListener.java
===================================================================
--- branches/tdiesler/trunk/integration/native/src/main/java/org/jboss/wsf/stack/jbws/ServiceEndpointContextListener.java	                        (rev 0)
+++ branches/tdiesler/trunk/integration/native/src/main/java/org/jboss/wsf/stack/jbws/ServiceEndpointContextListener.java	2007-07-16 20:47:16 UTC (rev 3901)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.wsf.stack.jbws;
+
+// $Id: ServiceEndpointServlet.java 3395 2007-06-02 20:38:33Z thomas.diesler at jboss.com $
+
+import javax.management.ObjectName;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.jboss.ws.metadata.umdm.UnifiedMetaData;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+import org.jboss.wsf.spi.deployment.Endpoint.EndpointState;
+import org.jboss.wsf.spi.management.EndpointRegistry;
+import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+
+/**
+ * A listener that initializes the UnifiedMetaDataModel
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Apr-2007
+ */
+public class ServiceEndpointContextListener implements ServletContextListener
+{
+   public void contextInitialized(ServletContextEvent event)
+   {
+      EndpointRegistry epRegistry = EndpointRegistryFactory.getEndpointRegistry();
+      ServletContext ctx = event.getServletContext();
+      String contextPath = ctx.getContextPath();
+
+      for (ObjectName sepId : epRegistry.getEndpoints())
+      {
+         String propContext = sepId.getKeyProperty(Endpoint.SEPID_PROPERTY_CONTEXT);
+         if (contextPath.equals("/" + propContext))
+         {
+            Endpoint ep = epRegistry.getEndpoint(sepId);
+
+            Deployment dep = ep.getService().getDeployment();
+            ClassLoader classLoader = dep.getClassLoader();
+
+            // For JSE endpoints, this should be the tomcat classloader
+            if (dep.getType() == DeploymentType.JAXRPC_JSE || dep.getType() == DeploymentType.JAXWS_JSE)
+               classLoader = Thread.currentThread().getContextClassLoader();
+
+            UnifiedMetaData umd = dep.getContext().getAttachment(UnifiedMetaData.class);
+            if (umd.isEagerInitialized() == false)
+            {
+               umd.setClassLoader(classLoader);
+               umd.eagerInitialize();
+            }
+
+            // start the endpoint
+            if (ep.getState() == EndpointState.CREATED)
+               ep.getLifecycleHandler().start(ep);
+         }
+      }
+   }
+
+   public void contextDestroyed(ServletContextEvent event)
+   {
+      EndpointRegistry epRegistry = EndpointRegistryFactory.getEndpointRegistry();
+      ServletContext ctx = event.getServletContext();
+      String contextPath = ctx.getContextPath();
+
+      for (ObjectName sepId : epRegistry.getEndpoints())
+      {
+         String propContext = sepId.getKeyProperty(Endpoint.SEPID_PROPERTY_CONTEXT);
+         if (contextPath.equals(propContext))
+         {
+            Endpoint ep = epRegistry.getEndpoint(sepId);
+            
+            // stop the endpoint
+            if (ep.getState() == EndpointState.STARTED)
+               ep.getLifecycleHandler().stop(ep);
+         }
+      }
+   }
+}




More information about the jbossws-commits mailing list