Author: heiko.braun(a)jboss.com
Date: 2008-03-25 08:20:48 -0400 (Tue, 25 Mar 2008)
New Revision: 6093
Added:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/RegisterEndpointDeploymentAspect.java
Removed:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/EndpointRegistryDeploymentAspect.java
Modified:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/DeploymentAspectManagerImpl.java
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java
Log:
DAM lifecycle
Modified:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/DeploymentAspectManagerImpl.java
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/DeploymentAspectManagerImpl.java 2008-03-25
12:20:07 UTC (rev 6092)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/DeploymentAspectManagerImpl.java 2008-03-25
12:20:48 UTC (rev 6093)
@@ -96,13 +96,8 @@
log.debug(builder);
}
- /**
- * Iterate over the registered deployers calls create on each.
- * Iterate over the registered deployers again and calls start on each.
- * If start fails it automaticall calls destroy in the reverse order
- * starting with the deployer that failed
- */
- public void deploy(Deployment dep, WSFRuntime runtime)
+
+ public void create(Deployment dep, WSFRuntime runtime)
{
// create the deployment
Set<String> providedConditions = new HashSet<String>();
@@ -110,11 +105,11 @@
{
DeploymentAspect aspect = getDeploymentAspects().get(i);
- // Check that all required aspects are met
+ // Check that all required aspects are met
/*
TODO: This should done by adding all provided conditions to the Deployment
when being executed. Otherwise we will miss the parent provided conditions
here
-
+
Set<String> requiredSet = aspect.getRequiresAsSet();
requiredSet.remove(DeploymentAspect.LAST_DEPLOYMENT_ASPECT);
if (providedConditions.containsAll(requiredSet) == false)
@@ -129,7 +124,16 @@
}
dep.setState(DeploymentState.CREATED);
+ }
+ /**
+ * Iterate over the registered deployers calls create on each.
+ * Iterate over the registered deployers again and calls start on each.
+ * If start fails it automaticall calls destroy in the reverse order
+ * starting with the deployer that failed
+ */
+ public void start(Deployment dep, WSFRuntime runtime)
+ {
// start the deployment
for (int i = 0; i < getDeploymentAspects().size(); i++)
{
@@ -153,17 +157,21 @@
dep.setState(DeploymentState.STARTED);
}
- public void undeploy(Deployment dep, WSFRuntime runtime)
+ public void stop(Deployment dep, WSFRuntime runtime)
{
// stop the deployment
for (int i = getDeploymentAspects().size(); 0 < i; i--)
{
- DeploymentAspect aspect = getDeploymentAspects().get(i - 1);
+ DeploymentAspect aspect = getDeploymentAspects().get(i - 1);
failsafeStop(aspect, dep);
}
dep.setState(DeploymentState.STOPPED);
+ }
+
+ public void destroy(Deployment dep, WSFRuntime runtime)
+ {
// destroy the deployment
for (int i = getDeploymentAspects().size(); 0 < i; i--)
{
@@ -173,7 +181,7 @@
dep.setState(DeploymentState.DESTROYED);
}
-
+
private void failsafeStop(DeploymentAspect aspect, Deployment dep)
{
try
Modified:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java 2008-03-25
12:20:07 UTC (rev 6092)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java 2008-03-25
12:20:48 UTC (rev 6093)
@@ -53,7 +53,7 @@
}
@Override
- public void create(Deployment dep)
+ public void start(Deployment dep)
{
for (Endpoint ep : dep.getService().getEndpoints())
{
Deleted:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/EndpointRegistryDeploymentAspect.java
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/EndpointRegistryDeploymentAspect.java 2008-03-25
12:20:07 UTC (rev 6092)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/EndpointRegistryDeploymentAspect.java 2008-03-25
12:20:48 UTC (rev 6093)
@@ -1,60 +0,0 @@
-/*
- * 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.framework.deployment;
-
-import org.jboss.wsf.spi.management.EndpointRegistry;
-import org.jboss.wsf.spi.management.EndpointRegistryFactory;
-import org.jboss.wsf.spi.deployment.DeploymentAspect;
-import org.jboss.wsf.spi.deployment.Deployment;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.SPIProviderResolver;
-
-/**
- * A deployer that registers the endpoints
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 20-Apr-2007
- */
-public class EndpointRegistryDeploymentAspect extends DeploymentAspect
-{
- public void create(Deployment dep)
- {
- SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
- EndpointRegistry registry =
spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
- for (Endpoint ep : dep.getService().getEndpoints())
- {
- registry.register(ep);
- }
- }
-
- public void destroy(Deployment dep)
- {
- SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
- EndpointRegistry registry =
spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
-
- for (Endpoint ep : dep.getService().getEndpoints())
- {
- registry.unregister(ep);
- }
- }
-}
\ No newline at end of file
Copied:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/RegisterEndpointDeploymentAspect.java
(from rev 5888,
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/EndpointRegistryDeploymentAspect.java)
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/RegisterEndpointDeploymentAspect.java
(rev 0)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/RegisterEndpointDeploymentAspect.java 2008-03-25
12:20:48 UTC (rev 6093)
@@ -0,0 +1,60 @@
+/*
+ * 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.framework.deployment;
+
+import org.jboss.wsf.spi.management.EndpointRegistry;
+import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+
+/**
+ * A deployer that registers the endpoints
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 20-Apr-2007
+ */
+public class EndpointRegistryDeploymentAspect extends DeploymentAspect
+{
+ public void create(Deployment dep)
+ {
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ EndpointRegistry registry =
spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ registry.register(ep);
+ }
+ }
+
+ public void destroy(Deployment dep)
+ {
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ EndpointRegistry registry =
spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
+
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ registry.unregister(ep);
+ }
+ }
+}
\ No newline at end of file
Property changes on:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/RegisterEndpointDeploymentAspect.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java 2008-03-25
12:20:07 UTC (rev 6092)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java 2008-03-25
12:20:48 UTC (rev 6093)
@@ -22,13 +22,15 @@
package org.jboss.wsf.framework.transport;
import org.jboss.logging.Logger;
+import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Server;
-import org.mortbay.jetty.Handler;
import org.mortbay.jetty.handler.ContextHandlerCollection;
import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHandler;
import org.mortbay.jetty.servlet.ServletHolder;
import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -108,6 +110,8 @@
context.addServlet(holder, urlPattern);
context.start();
this.contexts.addHandler(context);
+
+ LOG.info("Added web context " + contextPath + "/" +
urlPattern);
} catch (Exception e)
{
@@ -117,7 +121,48 @@
public void removeServletContext(String contextPath, String urlPattern)
{
- LOG.warn("Cannot remove context: " + contextPath + "/" +
urlPattern + "(Not implemented)");
+
+ Handler match = null;
+
+ for(Handler h : this.contexts.getHandlers())
+ {
+ if(h instanceof Context)
+ {
+ Context c = (Context)h;
+ ServletHandler sh = c.getServletHandler();
+
+ if(sh!=null)
+ {
+ ServletContext servletContext = sh.getServletContext();
+ String ctxPath = servletContext.getContextPath();
+ if(contextPath.equals(ctxPath))
+ {
+ // undeploy _any_ endpoint under this context
+ // TODO: Verify if that's really applicable
+ LOG.info("Remove web context " + ctxPath);
+ try
+ {
+ sh.stop();
+ c.stop();
+ } catch (Exception e)
+ {
+ LOG.error("Failed to stop context", e);
+ }
+
+ break;
+ }
+ }
+ }
+ }
+
+ if(null==match)
+ {
+ LOG.warn("No such context " + contextPath + "/" +
urlPattern);
+ }
+ else
+ {
+ this.contexts.removeHandler(match);
+ }
}
public static HttpDeamon getInstance(int port)