Author: asoldano
Date: 2014-03-05 05:14:36 -0500 (Wed, 05 Mar 2014)
New Revision: 18461
Modified:
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointService.java
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/service/ServerConfigService.java
Log:
[WFLY-3061] Prevent transient failures (JBWS1178TestCase, JBWS2150TestCase) due to JMX
MBean server not being available when the OPTIONAL dependency to it is set
Modified:
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java
===================================================================
---
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java 2014-03-04
18:36:52 UTC (rev 18460)
+++
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java 2014-03-05
10:14:36 UTC (rev 18461)
@@ -21,6 +21,7 @@
*/
package org.jboss.as.webservices.dmr;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
import static org.jboss.as.webservices.WSLogger.ROOT_LOGGER;
import static org.jboss.as.webservices.dmr.Constants.WSDL_HOST;
import static org.jboss.as.webservices.dmr.Constants.WSDL_PORT;
@@ -40,6 +41,7 @@
import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.controller.registry.Resource.ResourceEntry;
+import org.jboss.as.jmx.JMXExtension;
import org.jboss.as.server.AbstractDeploymentChainStep;
import org.jboss.as.server.DeploymentProcessorTarget;
import org.jboss.as.webservices.config.ServerConfigImpl;
@@ -80,13 +82,14 @@
}, OperationContext.Stage.RUNTIME);
ServiceTarget serviceTarget = context.getServiceTarget();
+ final boolean jmxAvailable = isJMXSubsystemAvailable(context);
if (appclient && model.hasDefined(WSDL_HOST)) {
ServerConfigImpl serverConfig = createServerConfig(model, true, context);
- newControllers.add(ServerConfigService.install(serviceTarget, serverConfig,
verificationHandler, getServerConfigDependencies(context)));
+ newControllers.add(ServerConfigService.install(serviceTarget, serverConfig,
verificationHandler, getServerConfigDependencies(context), jmxAvailable));
}
if (!appclient) {
ServerConfigImpl serverConfig = createServerConfig(model, false, context);
- newControllers.add(ServerConfigService.install(serviceTarget, serverConfig,
verificationHandler, getServerConfigDependencies(context)));
+ newControllers.add(ServerConfigService.install(serviceTarget, serverConfig,
verificationHandler, getServerConfigDependencies(context), jmxAvailable));
final Resource webSubsystem =
context.readResourceFromRoot(PathAddress.pathAddress(PathElement.pathElement("subsystem",
"web")));
String defaultHost =
webSubsystem.getModel().get("default-virtual-server").asString();
newControllers.add(PortComponentLinkService.install(serviceTarget,
defaultHost, verificationHandler));
@@ -133,4 +136,8 @@
}
}
+ private static boolean isJMXSubsystemAvailable(final OperationContext context) {
+ Resource root =
context.readResourceFromRoot(PathAddress.pathAddress(PathAddress.EMPTY_ADDRESS));
+ return root.hasChild(PathElement.pathElement(SUBSYSTEM,
JMXExtension.SUBSYSTEM_NAME));
+ }
}
Modified:
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointService.java
===================================================================
---
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointService.java 2014-03-04
18:36:52 UTC (rev 18460)
+++
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointService.java 2014-03-05
10:14:36 UTC (rev 18461)
@@ -52,6 +52,7 @@
import org.jboss.security.SecurityUtil;
import org.jboss.ws.api.monitoring.RecordProcessor;
import org.jboss.ws.common.ObjectNameFactory;
+import org.jboss.ws.common.management.AbstractServerConfig;
import org.jboss.ws.common.management.ManagedEndpoint;
import org.jboss.ws.common.monitoring.ManagedRecordProcessor;
import org.jboss.wsf.spi.deployment.Deployment;
@@ -69,13 +70,12 @@
*/
public final class EndpointService implements Service<Endpoint> {
- private static final ServiceName MBEAN_SERVER_NAME =
ServiceName.JBOSS.append("mbean", "server");
private final Endpoint endpoint;
private final ServiceName name;
private final InjectedValue<SecurityDomainContext> securityDomainContextValue =
new InjectedValue<SecurityDomainContext>();
private final InjectedValue<WebAppController> pclWebAppControllerValue = new
InjectedValue<WebAppController>();
private final InjectedValue<EndpointRegistry> endpointRegistryValue = new
InjectedValue<EndpointRegistry>();
- private final InjectedValue<MBeanServer> mBeanServerValue = new
InjectedValue<MBeanServer>();
+ private final InjectedValue<AbstractServerConfig> serverConfigServiceValue =
new InjectedValue<AbstractServerConfig>();
private EndpointService(final Endpoint endpoint, final ServiceName name) {
this.endpoint = endpoint;
@@ -126,7 +126,7 @@
}
private void registerRecordProcessor(final RecordProcessor processor, final Endpoint
ep) {
- MBeanServer mbeanServer = mBeanServerValue.getValue();
+ MBeanServer mbeanServer = serverConfigServiceValue.getValue().getMbeanServer();
if (mbeanServer != null) {
try {
mbeanServer.registerMBean(processor,
ObjectNameFactory.create(ep.getName() + ",recordProcessor=" +
processor.getName()));
@@ -146,7 +146,7 @@
}
private void unregisterRecordProcessor(final RecordProcessor processor, final
Endpoint ep) {
- MBeanServer mbeanServer = mBeanServerValue.getValue();
+ MBeanServer mbeanServer = serverConfigServiceValue.getValue().getMbeanServer();
if (mbeanServer != null) {
try {
mbeanServer.unregisterMBean(ObjectNameFactory.create(ep.getName() +
",recordProcessor=" + processor.getName()));
@@ -159,7 +159,7 @@
}
private void registerEndpoint(final Endpoint ep) {
- MBeanServer mbeanServer = mBeanServerValue.getValue();
+ MBeanServer mbeanServer = serverConfigServiceValue.getValue().getMbeanServer();
if (mbeanServer != null) {
try {
ManagedEndpoint jmxEndpoint = new ManagedEndpoint(endpoint,
mbeanServer);
@@ -174,7 +174,7 @@
}
private void unregisterEndpoint(final Endpoint ep) {
- MBeanServer mbeanServer = mBeanServerValue.getValue();
+ MBeanServer mbeanServer = serverConfigServiceValue.getValue().getMbeanServer();
if (mbeanServer != null) {
try {
mbeanServer.unregisterMBean(endpoint.getName());
@@ -205,8 +205,8 @@
return endpointRegistryValue;
}
- public Injector<MBeanServer> getMBeanServerInjector() {
- return mBeanServerValue;
+ public Injector<AbstractServerConfig> getAbstractServerConfigInjector() {
+ return serverConfigServiceValue;
}
public static void install(final ServiceTarget serviceTarget, final Endpoint
endpoint, final DeploymentUnit unit) {
@@ -225,10 +225,8 @@
builder.addDependency(DependencyType.REQUIRED,
WSServices.PORT_COMPONENT_LINK_SERVICE,
WebAppController.class, service.getPclWebAppControllerInjector());
- builder.addDependency(DependencyType.OPTIONAL, MBEAN_SERVER_NAME,
- MBeanServer.class,
- service.getMBeanServerInjector());
- builder.addDependency(DependencyType.REQUIRED, WSServices.CONFIG_SERVICE);
+ builder.addDependency(DependencyType.REQUIRED, WSServices.CONFIG_SERVICE,
AbstractServerConfig.class,
+ service.getAbstractServerConfigInjector());
builder.setInitialMode(Mode.ACTIVE);
builder.install();
//add a dependency on the endpoint service to web deployments, so that the
Modified:
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/service/ServerConfigService.java
===================================================================
---
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/service/ServerConfigService.java 2014-03-04
18:36:52 UTC (rev 18460)
+++
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/service/ServerConfigService.java 2014-03-05
10:14:36 UTC (rev 18461)
@@ -42,6 +42,7 @@
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
+import org.jboss.msc.value.ImmediateValue;
import org.jboss.ws.common.management.AbstractServerConfig;
import org.jboss.wsf.spi.management.ServerConfig;
@@ -86,9 +87,13 @@
}
public static ServiceController<?> install(final ServiceTarget serviceTarget,
final ServerConfigImpl serverConfig,
- final ServiceListener<Object> listener, final List<ServiceName>
dependencies) {
+ final ServiceListener<Object> listener, final List<ServiceName>
dependencies, final boolean jmxSubsystemAvailable) {
final ServiceBuilder<ServerConfig> builder =
serviceTarget.addService(WSServices.CONFIG_SERVICE, new
ServerConfigService(serverConfig));
- builder.addDependency(DependencyType.OPTIONAL, MBEAN_SERVER_NAME,
MBeanServer.class, serverConfig.getMBeanServerInjector());
+ if (jmxSubsystemAvailable) {
+ builder.addDependency(DependencyType.REQUIRED, MBEAN_SERVER_NAME,
MBeanServer.class, serverConfig.getMBeanServerInjector());
+ } else {
+ serverConfig.getMBeanServerInjector().setValue(new
ImmediateValue<MBeanServer>(null));
+ }
builder.addDependency(ServerEnvironmentService.SERVICE_NAME,
ServerEnvironment.class, serverConfig.getServerEnvironmentInjector());
for (ServiceName dep : dependencies) {
builder.addDependency(dep);