Author: asoldano
Date: 2014-03-04 13:36:52 -0500 (Tue, 04 Mar 2014)
New Revision: 18460
Modified:
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointService.java
container/wildfly80/branches/jbossws-wildfly800/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/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java
===================================================================
---
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java 2014-03-04
11:07:33 UTC (rev 18459)
+++
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSSubsystemAdd.java 2014-03-04
18:36:52 UTC (rev 18460)
@@ -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;
@@ -35,10 +36,12 @@
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
+import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ProcessType;
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.web.host.CommonWebServer;
@@ -80,13 +83,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, appclient)));
+ newControllers.add(ServerConfigService.install(serviceTarget, serverConfig,
verificationHandler, getServerConfigDependencies(context, appclient), jmxAvailable));
}
if (!appclient) {
ServerConfigImpl serverConfig = createServerConfig(model, false, context);
- newControllers.add(ServerConfigService.install(serviceTarget, serverConfig,
verificationHandler, getServerConfigDependencies(context, appclient)));
+ newControllers.add(ServerConfigService.install(serviceTarget, serverConfig,
verificationHandler, getServerConfigDependencies(context, appclient), jmxAvailable));
}
newControllers.add(XTSClientIntegrationService.install(serviceTarget,
verificationHandler));
}
@@ -134,4 +138,9 @@
}
}
+ private static boolean isJMXSubsystemAvailable(final OperationContext context) {
+
//context.readResourceFromRoot(PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM,
JMXExtension.SUBSYSTEM_NAME))) != null
+ Resource root =
context.readResourceFromRoot(PathAddress.pathAddress(PathAddress.EMPTY_ADDRESS));
+ return root.hasChild(PathElement.pathElement(SUBSYSTEM,
JMXExtension.SUBSYSTEM_NAME));
+ }
}
Modified:
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointService.java
===================================================================
---
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointService.java 2014-03-04
11:07:33 UTC (rev 18459)
+++
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/service/EndpointService.java 2014-03-04
18:36:52 UTC (rev 18460)
@@ -60,6 +60,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;
@@ -77,11 +78,10 @@
*/
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<MBeanServer> mBeanServerValue = new
InjectedValue<MBeanServer>();
+ private final InjectedValue<AbstractServerConfig> serverConfigServiceValue =
new InjectedValue<AbstractServerConfig>();
private final InjectedValue<EJBViewMethodSecurityAttributesService>
ejbMethodSecurityAttributeServiceValue = new
InjectedValue<EJBViewMethodSecurityAttributesService>();
private EndpointService(final Endpoint endpoint, final ServiceName name) {
@@ -131,7 +131,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);
@@ -146,7 +146,7 @@
}
private void unregisterEndpoint(final Endpoint ep) {
- MBeanServer mbeanServer = mBeanServerValue.getValue();
+ MBeanServer mbeanServer = serverConfigServiceValue.getValue().getMbeanServer();
if (mbeanServer != null) {
try {
mbeanServer.unregisterMBean(endpoint.getName());
@@ -160,7 +160,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,
@@ -180,7 +180,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()));
@@ -196,8 +196,8 @@
return securityDomainContextValue;
}
- public Injector<MBeanServer> getMBeanServerInjector() {
- return mBeanServerValue;
+ public Injector<AbstractServerConfig> getAbstractServerConfigInjector() {
+ return serverConfigServiceValue;
}
public Injector<EJBViewMethodSecurityAttributesService>
getEJBMethodSecurityAttributeServiceInjector() {
@@ -216,8 +216,8 @@
builder.addDependency(DependencyType.REQUIRED,
SecurityDomainService.SERVICE_NAME.append(getDeploymentSecurityDomainName(endpoint)),
SecurityDomainContext.class,
service.getSecurityDomainContextInjector());
- builder.addDependency(DependencyType.REQUIRED, WSServices.CONFIG_SERVICE);
- builder.addDependency(DependencyType.OPTIONAL, MBEAN_SERVER_NAME,
MBeanServer.class, service.getMBeanServerInjector());
+ builder.addDependency(DependencyType.REQUIRED, WSServices.CONFIG_SERVICE,
AbstractServerConfig.class,
+ service.getAbstractServerConfigInjector());
if (EndpointType.JAXWS_EJB3.equals(endpoint.getType())) {
builder.addDependency(DependencyType.OPTIONAL,
getEJBViewMethodSecurityAttributesServiceName(unit, endpoint),
EJBViewMethodSecurityAttributesService.class,
service.getEJBMethodSecurityAttributeServiceInjector());
Modified:
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/service/ServerConfigService.java
===================================================================
---
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/service/ServerConfigService.java 2014-03-04
11:07:33 UTC (rev 18459)
+++
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/service/ServerConfigService.java 2014-03-04
18:36:52 UTC (rev 18460)
@@ -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;
@@ -85,9 +86,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);