Author: alessio.soldano(a)jboss.com
Date: 2012-10-30 05:37:44 -0400 (Tue, 30 Oct 2012)
New Revision: 16954
Modified:
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/deployers/EndpointServiceDeploymentAspect.java
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/publish/EndpointPublisherImpl.java
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointPublishService.java
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointService.java
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/service/ServerConfigService.java
Log:
[JBWS-3426] Fixing ASIL 711
Modified:
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/deployers/EndpointServiceDeploymentAspect.java
===================================================================
---
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/deployers/EndpointServiceDeploymentAspect.java 2012-10-30
09:21:12 UTC (rev 16953)
+++
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/deployers/EndpointServiceDeploymentAspect.java 2012-10-30
09:37:44 UTC (rev 16954)
@@ -30,6 +30,7 @@
import org.jboss.ws.common.deployment.EndpointLifecycleDeploymentAspect;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.LifecycleHandler;
/**
* Creates Endpoint Service instance when starting the Endpoint
@@ -37,18 +38,49 @@
* @author alessio.soldano(a)jboss.com
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
-public final class EndpointServiceDeploymentAspect extends
EndpointLifecycleDeploymentAspect {
+public final class EndpointServiceDeploymentAspect extends
EndpointLifecycleDeploymentAspect implements Cloneable {
+ private boolean stopServices = false;
+
@Override
public void start(final Deployment dep) {
- super.start(dep);
final ServiceTarget target = getOptionalAttachment(dep, ServiceTarget.class);
- if (target != null) {
+ final DeploymentUnit unit = getRequiredAttachment(dep, DeploymentUnit.class);
+ for (final Endpoint ep : dep.getService().getEndpoints()) {
+ EndpointService.install(target, ep, unit);
+ getLifecycleHandler(ep, true).start(ep);
+ }
+ }
+
+ @Override
+ public void stop(Deployment dep)
+ {
+ if (stopServices) {
final DeploymentUnit unit = getRequiredAttachment(dep,
DeploymentUnit.class);
for (final Endpoint ep : dep.getService().getEndpoints()) {
- EndpointService.install(target, ep, unit);
+ LifecycleHandler lifecycleHandler = getLifecycleHandler(ep, false);
+ if (lifecycleHandler != null)
+ lifecycleHandler.stop(ep);
+ EndpointService.uninstall(ep, unit);
}
+ } else {
+ super.stop(dep);
}
}
-
+
+ public void setStopServices(boolean stopServices) {
+ this.stopServices = stopServices;
+ }
+
+ public Object clone() {
+ EndpointServiceDeploymentAspect clone = new EndpointServiceDeploymentAspect();
+ clone.setForJaxRpc(isForJaxRpc());
+ clone.setForJaxWs(isForJaxWs());
+ clone.setLast(isLast());
+ clone.setProvides(getProvides());
+ clone.setRelativeOrder(getRelativeOrder());
+ clone.setRequires(getRequires());
+ clone.setStopServices(stopServices);
+ return clone;
+ }
}
Modified:
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java
===================================================================
---
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java 2012-10-30
09:21:12 UTC (rev 16953)
+++
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java 2012-10-30
09:37:44 UTC (rev 16954)
@@ -119,14 +119,13 @@
}
}, OperationContext.Stage.RUNTIME);
- WSServices.saveContainerRegistry(context.getServiceRegistry(false));
ServiceTarget serviceTarget = context.getServiceTarget();
if (appclient && model.hasDefined(WSDL_HOST)) {
- ServerConfigImpl serverConfig = createServerConfig(model, true);
+ ServerConfigImpl serverConfig = createServerConfig(model, appclient);
newControllers.add(ServerConfigService.install(serviceTarget, serverConfig,
verificationHandler));
}
if (!appclient) {
- ServerConfigImpl serverConfig = createServerConfig(model, false);
+ ServerConfigImpl serverConfig = createServerConfig(model, appclient);
newControllers.add(ServerConfigService.install(serviceTarget, serverConfig,
verificationHandler));
newControllers.add(EndpointRegistryService.install(serviceTarget,
verificationHandler));
Modified:
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/publish/EndpointPublisherImpl.java
===================================================================
---
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/publish/EndpointPublisherImpl.java 2012-10-30
09:21:12 UTC (rev 16953)
+++
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/publish/EndpointPublisherImpl.java 2012-10-30
09:37:44 UTC (rev 16954)
@@ -25,6 +25,7 @@
import java.io.File;
import java.lang.reflect.InvocationTargetException;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -39,6 +40,7 @@
import org.apache.catalina.startup.ContextConfig;
import org.apache.tomcat.InstanceManager;
import org.jboss.as.web.deployment.WebCtxLoader;
+import org.jboss.as.webservices.deployers.EndpointServiceDeploymentAspect;
import org.jboss.as.webservices.deployers.deployment.DeploymentAspectsProvider;
import org.jboss.as.webservices.deployers.deployment.WSDeploymentBuilder;
import org.jboss.as.webservices.service.ServerConfigService;
@@ -50,16 +52,12 @@
import org.jboss.metadata.web.spec.ServletMappingMetaData;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.ws.common.deployment.DeploymentAspectManagerImpl;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.SPIProviderResolver;
import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
import org.jboss.wsf.spi.deployment.DeploymentAspectManager;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.WSFServlet;
-import org.jboss.wsf.spi.management.EndpointRegistry;
-import org.jboss.wsf.spi.management.EndpointRegistryFactory;
import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
import org.jboss.wsf.spi.publish.Context;
import org.jboss.wsf.spi.publish.EndpointPublisher;
@@ -73,30 +71,41 @@
public final class EndpointPublisherImpl implements EndpointPublisher {
private Host host;
+ private boolean runningInService = false;
+ private static List<DeploymentAspect> depAspects = null;
public EndpointPublisherImpl(Host host) {
this.host = host;
}
+
+ public EndpointPublisherImpl(Host host, boolean runningInService) {
+ this(host);
+ this.runningInService = runningInService;
+ }
@Override
public Context publish(String context, ClassLoader loader, Map<String, String>
urlPatternToClassNameMap) throws Exception {
- return publish(null, context, loader, urlPatternToClassNameMap, null);
+ return publish(getBaseTarget(), context, loader, urlPatternToClassNameMap,
null);
}
public Context publish(String context, ClassLoader loader, Map<String, String>
urlPatternToClassNameMap, WebservicesMetaData metadata) throws Exception {
- return publish(null, context, loader, urlPatternToClassNameMap, metadata);
+ return publish(getBaseTarget(), context, loader, urlPatternToClassNameMap,
metadata);
}
public Context publish(ServiceTarget target, String context, ClassLoader loader,
Map<String, String> urlPatternToClassNameMap, WebservicesMetaData metadata) throws
Exception {
WSEndpointDeploymentUnit unit = new WSEndpointDeploymentUnit(loader, context,
urlPatternToClassNameMap, metadata);
return new Context(context, publish(target, unit));
}
+
+ private static ServiceTarget getBaseTarget() {
+ return
WSServices.getContainerRegistry().getService(WSServices.CONFIG_SERVICE).getServiceContainer();
+ }
/**
* Publishes the endpoints declared to the provided WSEndpointDeploymentUnit
*/
public List<Endpoint> publish(ServiceTarget target, WSEndpointDeploymentUnit
unit) throws Exception {
- List<DeploymentAspect> aspects =
DeploymentAspectsProvider.getSortedDeploymentAspects();
+ List<DeploymentAspect> aspects = getDeploymentAspects();
ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
Deployment dep = null;
try {
@@ -107,16 +116,6 @@
DeploymentAspectManager dam = new DeploymentAspectManagerImpl();
dam.setDeploymentAspects(aspects);
dam.deploy(dep);
- // TODO: [JBWS-3426] fix this. START workaround
- if (target == null) {
- SPIProvider spiProvider =
SPIProviderResolver.getInstance().getProvider();
- EndpointRegistryFactory factory =
spiProvider.getSPI(EndpointRegistryFactory.class);
- EndpointRegistry registry = factory.getEndpointRegistry();
- for (final Endpoint endpoint : dep.getService().getEndpoints()) {
- registry.register(endpoint);
- }
- }
- // END workaround
} finally {
if (dep != null) {
dep.removeAttachment(ServiceTarget.class);
@@ -198,24 +197,13 @@
return;
}
Deployment deployment = eps.get(0).getService().getDeployment();
- List<DeploymentAspect> aspects =
DeploymentAspectsProvider.getSortedDeploymentAspects();
+ List<DeploymentAspect> aspects = getDeploymentAspects();
try {
stopWebApp(deployment.getAttachment(StandardContext.class));
} finally {
ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
try {
SecurityActions.setContextClassLoader(ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader());
- final ServiceTarget target =
deployment.getAttachment(ServiceTarget.class);
- // TODO: [JBWS-3426] fix this. START workaround
- if (target == null) {
- SPIProvider spiProvider =
SPIProviderResolver.getInstance().getProvider();
- EndpointRegistryFactory factory =
spiProvider.getSPI(EndpointRegistryFactory.class);
- EndpointRegistry registry = factory.getEndpointRegistry();
- for (final Endpoint endpoint :
deployment.getService().getEndpoints()) {
- registry.unregister(endpoint);
- }
- }
- // END workaround
DeploymentAspectManager dam = new DeploymentAspectManagerImpl();
dam.setDeploymentAspects(aspects);
dam.undeploy(deployment);
@@ -239,6 +227,29 @@
throw MESSAGES.destroyContextPhaseFailed(e);
}
}
+
+ private List<DeploymentAspect> getDeploymentAspects() {
+ return runningInService ? DeploymentAspectsProvider.getSortedDeploymentAspects()
: getPublisherDeploymentAspects();
+ }
+
+ private static synchronized List<DeploymentAspect>
getPublisherDeploymentAspects() {
+ if (depAspects == null) {
+ depAspects = new LinkedList<DeploymentAspect>();
+ final List<DeploymentAspect> serverAspects =
DeploymentAspectsProvider.getSortedDeploymentAspects();
+ //copy to replace the EndpointServiceDeploymentAspect
+ for (DeploymentAspect aspect : serverAspects) {
+ if (aspect instanceof EndpointServiceDeploymentAspect) {
+ final EndpointServiceDeploymentAspect a =
(EndpointServiceDeploymentAspect)aspect;
+ EndpointServiceDeploymentAspect clone =
(EndpointServiceDeploymentAspect)(a.clone());
+ clone.setStopServices(true);
+ depAspects.add(clone);
+ } else {
+ depAspects.add(aspect);
+ }
+ }
+ }
+ return depAspects;
+ }
private static class LocalInstanceManager implements InstanceManager {
LocalInstanceManager() {
Modified:
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointPublishService.java
===================================================================
---
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointPublishService.java 2012-10-30
09:21:12 UTC (rev 16953)
+++
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointPublishService.java 2012-10-30
09:37:44 UTC (rev 16954)
@@ -83,8 +83,8 @@
public void start(final StartContext ctx) throws StartException {
ROOT_LOGGER.starting(name);
try {
- EndpointPublisherImpl publisher = new
EndpointPublisherImpl(hostInjector.getValue().getHost());
- wsctx = publisher.publish(context, loader, urlPatternToClassName);
+ EndpointPublisherImpl publisher = new
EndpointPublisherImpl(hostInjector.getValue().getHost(), true);
+ wsctx = publisher.publish(ctx.getChildTarget(), context, loader,
urlPatternToClassName, null);
} catch (Exception e) {
throw new StartException(e);
}
@@ -94,7 +94,7 @@
public void stop(final StopContext ctx) {
ROOT_LOGGER.stopping(name);
try {
- EndpointPublisherImpl publisher = new
EndpointPublisherImpl(hostInjector.getValue().getHost());
+ EndpointPublisherImpl publisher = new
EndpointPublisherImpl(hostInjector.getValue().getHost(), true);
publisher.destroy(wsctx);
} catch (Exception e) {
throw new RuntimeException(e);
Modified:
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointService.java
===================================================================
---
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointService.java 2012-10-30
09:21:12 UTC (rev 16953)
+++
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointService.java 2012-10-30
09:37:44 UTC (rev 16954)
@@ -183,6 +183,11 @@
builder.setInitialMode(Mode.ACTIVE);
builder.install();
}
+
+ public static void uninstall(final Endpoint endpoint, final DeploymentUnit unit) {
+ final ServiceName serviceName = getServiceName(unit, endpoint.getShortName());
+
WSServices.getContainerRegistry().getRequiredService(serviceName).setMode(Mode.REMOVE);
+ }
private static String getDeploymentSecurityDomainName(final Endpoint ep) {
JBossWebMetaData metadata =
ep.getService().getDeployment().getAttachment(JBossWebMetaData.class);
Modified:
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/service/ServerConfigService.java
===================================================================
---
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/service/ServerConfigService.java 2012-10-30
09:21:12 UTC (rev 16953)
+++
container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/service/ServerConfigService.java 2012-10-30
09:37:44 UTC (rev 16954)
@@ -88,7 +88,9 @@
builder.addDependency(ServerEnvironmentService.SERVICE_NAME,
ServerEnvironment.class, serverConfig.getServerEnvironmentInjector());
builder.addListener(listener);
builder.setInitialMode(Mode.ACTIVE);
- return builder.install();
+ ServiceController<?> sc = builder.install();
+ WSServices.saveContainerRegistry(sc.getServiceContainer());
+ return sc;
}
}