[jbossws-commits] JBossWS SVN: r8451 - framework/trunk/src/main/java/org/jboss/wsf/framework/deployment.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Mon Oct 13 06:58:13 EDT 2008
Author: richard.opalka at jboss.com
Date: 2008-10-13 06:58:13 -0400 (Mon, 13 Oct 2008)
New Revision: 8451
Removed:
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/AbstractAspectizedEndpointServlet.java
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/AbstractEndpointServlet.java
Log:
[JBWS-2246][JBWS-2264][JBAS-5732] refactoring AbstractES + AbstractAspectizedES to common
Deleted: framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/AbstractAspectizedEndpointServlet.java
===================================================================
--- framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/AbstractAspectizedEndpointServlet.java 2008-10-13 10:55:09 UTC (rev 8450)
+++ framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/AbstractAspectizedEndpointServlet.java 2008-10-13 10:58:13 UTC (rev 8451)
@@ -1,141 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.framework.deployment;
-
-import org.jboss.wsf.spi.DeploymentAspectManagerLocator;
-import org.jboss.wsf.spi.deployment.Deployment;
-import org.jboss.wsf.spi.deployment.DeploymentAspectManager;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.deployment.Endpoint.EndpointState;
-
-/**
- * A cross stack aspectized webservice servlet that is installed for every web service endpoint on AS 5.x series
- * @author richard.opalka at jboss.com
- */
-public abstract class AbstractAspectizedEndpointServlet extends AbstractEndpointServlet
-{
-
- private static final String PROPERTY_NAME = "org.jboss.ws.webapp.ServletAspectManagerName";
- protected DeploymentAspectManager aspectsManager;
-
- /**
- * Constructor
- */
- protected AbstractAspectizedEndpointServlet() {}
-
- /**
- * Initializes aspect manager
- */
- @Override
- protected final void initAspectManager()
- {
- final String managerName = (String)this.endpoint.getService().getDeployment().getProperty(PROPERTY_NAME);
- if (managerName == null)
- throw new IllegalStateException("Endpoint servlet manager name must be specified with key: " + PROPERTY_NAME);
-
- final DeploymentAspectManagerLocator locator = this.spiProvider.getSPI(DeploymentAspectManagerLocator.class);
- this.aspectsManager = locator.locateDeploymentAspectManager(managerName);
- }
-
- /**
- * Starts servlet related aspects
- */
- @Override
- protected final void startAspectManager()
- {
- this.assertCorrectState();
-
- final Deployment dep = this.endpoint.getService().getDeployment();
-
- if (this.endpoint.getState() != EndpointState.STARTED) // [JBWS-2338] TODO fix this hack preventing exceptions
- {
- this.aspectsManager.create(dep, null);
- this.aspectsManager.start(dep, null);
- }
- }
-
- /**
- * Stops servlet related aspects
- */
- @Override
- protected final void stopAspectManager()
- {
- this.assertCorrectState();
-
- final Deployment dep = this.endpoint.getService().getDeployment();
-
- if (this.endpoint.getState() == EndpointState.STARTED) // [JBWS-2338] TODO fix this hack preventing exceptions
- {
- try
- {
- this.aspectsManager.stop(dep, null);
- this.aspectsManager.destroy(dep, null);
- }
- finally
- {
- this.aspectsManager = null;
- super.stopAspectManager();
- }
- }
- }
-
- /**
- * Fires endpoint start event
- */
- @Override
- protected final void startEndpoint()
- {
- Deployment dep = this.endpoint.getService().getDeployment();
- for (Endpoint ep : dep.getService().getEndpoints())
- {
- ep.getLifecycleHandler().start(ep); // [JBWS-2338] TODO fix this hack preventing exceptions
- }
- }
-
- /**
- * Fires endpoint stop event
- */
- @Override
- protected final void stopEndpoint()
- {
- if (this.endpoint.getState() == EndpointState.STARTED)
- {
- Deployment dep = this.endpoint.getService().getDeployment();
- for (Endpoint ep : dep.getService().getEndpoints())
- {
- ep.getLifecycleHandler().stop(ep); // [JBWS-2338] TODO fix this hack preventing exceptions
- }
- }
- }
-
- /**
- * Asserts this object correct state
- */
- private void assertCorrectState()
- {
- if (this.endpoint == null || this.aspectsManager == null)
- {
- throw new IllegalStateException();
- }
- }
-
-}
Deleted: framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/AbstractEndpointServlet.java
===================================================================
--- framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/AbstractEndpointServlet.java 2008-10-13 10:55:09 UTC (rev 8450)
+++ framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/AbstractEndpointServlet.java 2008-10-13 10:58:13 UTC (rev 8451)
@@ -1,223 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.framework.deployment;
-
-import java.io.IOException;
-
-import javax.management.ObjectName;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.jboss.wsf.common.ObjectNameFactory;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.SPIProviderResolver;
-import org.jboss.wsf.spi.deployment.Deployment;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.invocation.EndpointAssociation;
-import org.jboss.wsf.spi.invocation.RequestHandler;
-import org.jboss.wsf.spi.management.EndpointRegistry;
-import org.jboss.wsf.spi.management.EndpointRegistryFactory;
-import org.jboss.wsf.spi.management.EndpointResolver;
-
-import javax.xml.ws.WebServiceException;
-
-/**
- * A cross stack webservice servlet that is installed for every web service endpoint on AS 4.2.x series
- * @author thomas.diesler at jboss.org
- * @author heiko.braun at jboss.com
- * @author richard.opalka at jboss.com
- */
-public abstract class AbstractEndpointServlet extends HttpServlet
-{
-
- protected final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
- protected Endpoint endpoint;
- protected EndpointRegistry epRegistry;
-
- /**
- * Constructor
- */
- protected AbstractEndpointServlet() {}
-
- /**
- * Servlet lifecycle init method
- * @param servletConfig servlet configuration
- */
- public final void init(ServletConfig servletConfig) throws ServletException
- {
- super.init(servletConfig);
- this.initRegistry();
- this.initServiceEndpoint(servletConfig);
- }
-
- /**
- * Servlet lifecycle destroy method
- */
- public final void destroy()
- {
- try
- {
- this.stopAspectManager();
- this.stopEndpoint();
- }
- finally
- {
- super.destroy();
- }
- }
-
- /**
- * Serves the requests
- */
- public final void service(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException
- {
- try
- {
- EndpointAssociation.setEndpoint(endpoint);
- RequestHandler requestHandler = endpoint.getRequestHandler();
- requestHandler.handleHttpRequest(endpoint, req, res, getServletContext());
- }
- finally
- {
- EndpointAssociation.removeEndpoint();
- }
- }
-
- /**
- * Template method
- * @param cfg servlet config
- */
- protected void postInit(ServletConfig cfg)
- {
- // does nothing (because of BC)
- }
-
- /**
- * Template method for initializing aspect manager
- */
- protected void initAspectManager()
- {
- // does nothing (because of BC)
- }
-
- /**
- * Template method for starting aspect manager
- */
- protected void startAspectManager()
- {
- // does nothing (because of BC)
- }
-
- /**
- * Template method for stopping aspect manager
- */
- protected void stopAspectManager()
- {
- // does nothing (because of BC)
- }
-
- /**
- * Template method to fire endpoint start event
- */
- protected void startEndpoint()
- {
- // does nothing (because of BC)
- }
-
- /**
- * Template method to fire endpoint stop event
- */
- protected void stopEndpoint()
- {
- // does nothing (because of BC)
- }
-
- /**
- * Abstract method that must be overriden by each stack servlet endpoint
- * @param servletContext servlet context
- * @param servletName servlet name
- * @return new stack specific endpoint resolver
- */
- protected abstract EndpointResolver newEndpointResolver(String servletContext, String servletName);
-
- /**
- * Initialize the service endpoint
- */
- private void initServiceEndpoint(ServletConfig servletConfig)
- {
- this.initEndpoint(servletConfig.getServletContext().getContextPath(), getServletName());
- this.initAspectManager();
- this.setRuntimeLoader();
- this.startAspectManager();
- this.postInit(servletConfig);
- this.startEndpoint();
- }
-
- /**
- * Initializes endpoint registry
- */
- private void initRegistry()
- {
- epRegistry = spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
- }
-
- /**
- * Initialize the service endpoint
- * @param contextPath context path
- * @param servletName servlet name
- */
- private void initEndpoint(String contextPath, String servletName)
- {
- final EndpointResolver resolver = newEndpointResolver(contextPath, servletName);
- this.endpoint = epRegistry.resolve(resolver);
-
- if (this.endpoint == null)
- {
- ObjectName oname = ObjectNameFactory.create(Endpoint.SEPID_DOMAIN + ":" +
- Endpoint.SEPID_PROPERTY_CONTEXT + "=" + contextPath + "," +
- Endpoint.SEPID_PROPERTY_ENDPOINT + "=" + servletName
- );
- throw new WebServiceException("Cannot obtain endpoint for: " + oname);
- }
- }
-
- /**
- * Sets runtime classloader for JSE endpoints
- */
- private void setRuntimeLoader()
- {
- final Deployment dep = endpoint.getService().getDeployment();
- final boolean isJaxrpcJse = dep.getType() == Deployment.DeploymentType.JAXRPC_JSE;
- final boolean isJaxwsJse = dep.getType() == Deployment.DeploymentType.JAXWS_JSE;
-
- if (isJaxrpcJse || isJaxwsJse)
- {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- dep.setRuntimeClassLoader(classLoader);
- }
- }
-
-}
More information about the jbossws-commits
mailing list