Skip to content

Commit

Permalink
Merge pull request #10457 from pferraro/ejb
Browse files Browse the repository at this point in the history
WFLY-6882 Backup singleton ejb deployments should still be included in ejb client cluster topology
  • Loading branch information
kabir committed Sep 11, 2017
2 parents adc2276 + 926a590 commit 4ed234b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 14 deletions.
Expand Up @@ -22,6 +22,7 @@

package org.wildfly.extension.clustering.singleton.deployment;

import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.server.deployment.AttachmentKey;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
Expand All @@ -48,9 +49,10 @@ public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessi
if (unit.getParent() == null) {
SingletonPolicy policy = context.getAttachment(POLICY_KEY);
if (policy != null) {
CapabilityServiceSupport support = unit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
// Ideally, we would just install the next phase using the singleton policy, however deployment unit phases do not currently support restarts
// Restart the deployment using the attached phase builder, but only if a builder was not already attached
if (unit.putAttachment(Attachments.DEPLOYMENT_UNIT_PHASE_BUILDER, new SingletonDeploymentUnitPhaseBuilder(policy)) == null) {
if (unit.putAttachment(Attachments.DEPLOYMENT_UNIT_PHASE_BUILDER, new SingletonDeploymentUnitPhaseBuilder(support, policy)) == null) {
SingletonLogger.ROOT_LOGGER.singletonDeploymentDetected(policy);
ServiceController<?> controller = context.getServiceRegistry().getRequiredService(unit.getServiceName());
controller.addListener(new AbstractServiceListener<Object>() {
Expand Down
Expand Up @@ -22,6 +22,7 @@

package org.wildfly.extension.clustering.singleton.deployment;

import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.server.deployment.DeploymentUnitPhaseBuilder;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceBuilder;
Expand All @@ -35,15 +36,22 @@
* @author Paul Ferraro
*/
public class SingletonDeploymentUnitPhaseBuilder implements DeploymentUnitPhaseBuilder {
private static final String EJB_REMOTE_CAPABILITY = "org.wildfly.ejb.remote";

private final CapabilityServiceSupport support;
private final SingletonPolicy policy;

public SingletonDeploymentUnitPhaseBuilder(SingletonPolicy policy) {
public SingletonDeploymentUnitPhaseBuilder(CapabilityServiceSupport support, SingletonPolicy policy) {
this.support = support;
this.policy = policy;
}

@Override
public <T> ServiceBuilder<T> build(ServiceTarget target, ServiceName name, Service<T> service) {
return this.policy.createSingletonServiceBuilder(name, service).build(target).setInitialMode(ServiceController.Mode.ACTIVE);
ServiceBuilder<T> builder = this.policy.createSingletonServiceBuilder(name, service).build(target).setInitialMode(ServiceController.Mode.ACTIVE);
if (this.support.hasCapability(EJB_REMOTE_CAPABILITY)) {
builder.addDependency(this.support.getCapabilityServiceName(EJB_REMOTE_CAPABILITY));
}
return builder;
}
}
Expand Up @@ -82,7 +82,6 @@
import org.jboss.as.ejb3.deployment.EjbJarDescription;
import org.jboss.as.ejb3.deployment.ModuleDeployment;
import org.jboss.as.ejb3.logging.EjbLogger;
import org.jboss.as.ejb3.remote.EJBRemoteConnectorService;
import org.jboss.as.ejb3.remote.EJBRemoteTransactionsViewConfigurator;
import org.jboss.as.ejb3.security.ApplicationSecurityDomainConfig;
import org.jboss.as.ejb3.security.EJBMethodSecurityAttribute;
Expand All @@ -96,6 +95,7 @@
import org.jboss.as.ejb3.security.SecurityRolesAddingInterceptor;
import org.jboss.as.ejb3.subsystem.ApplicationSecurityDomainDefinition;
import org.jboss.as.ejb3.subsystem.ApplicationSecurityDomainService.ApplicationSecurityDomain;
import org.jboss.as.ejb3.subsystem.EJB3RemoteResourceDefinition;
import org.jboss.as.ejb3.suspend.EJBSuspendHandlerService;
import org.jboss.as.ejb3.timerservice.AutoTimer;
import org.jboss.as.ejb3.timerservice.NonFunctionalTimerService;
Expand Down Expand Up @@ -823,7 +823,8 @@ public void configure(final DeploymentPhaseContext context, final ComponentConfi
configuration.getDependencies().add(new DependencyConfigurator<ViewService>() {
@Override
public void configureDependency(final ServiceBuilder<?> serviceBuilder, final ViewService service) throws DeploymentUnitProcessingException {
serviceBuilder.addDependency(EJBRemoteConnectorService.SERVICE_NAME);
CapabilityServiceSupport support = context.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
serviceBuilder.addDependency(support.getCapabilityServiceName(EJB3RemoteResourceDefinition.EJB_REMOTE_CAPABILITY_NAME));
}
});
}
Expand Down
Expand Up @@ -42,7 +42,7 @@
/**
* @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
*/
public class EJBRemoteConnectorService implements Service<EJBRemoteConnectorService> {
public class EJBRemoteConnectorService implements Service<Void> {

// TODO: Should this be exposed via the management APIs?
private static final String EJB_CHANNEL_NAME = "jboss.ejb";
Expand Down Expand Up @@ -94,13 +94,9 @@ public void stop(StopContext context) {
registration.close();
}

public String getProtocol() {
return remotingConnectorInfoInjectedValue.getValue().getProtocol();
}

@Override
public EJBRemoteConnectorService getValue() {
return this;
public Void getValue() {
return null;
}

public InjectedValue<Endpoint> getEndpointInjector() {
Expand Down
Expand Up @@ -32,6 +32,7 @@
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.OperationEntry;
Expand All @@ -47,6 +48,9 @@
public class EJB3RemoteResourceDefinition extends SimpleResourceDefinition {

public static final EJB3RemoteResourceDefinition INSTANCE = new EJB3RemoteResourceDefinition();
public static final String EJB_REMOTE_CAPABILITY_NAME = "org.wildfly.ejb.remote";

static final RuntimeCapability<Void> EJB_REMOTE_CAPABILITY = RuntimeCapability.Builder.of(EJB_REMOTE_CAPABILITY_NAME).setServiceType(Void.class).build();

static final SimpleAttributeDefinition CLIENT_MAPPINGS_CLUSTER_NAME =
new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.CLIENT_MAPPINGS_CLUSTER_NAME, ModelType.STRING, true)
Expand Down Expand Up @@ -109,4 +113,9 @@ public void registerChildren(ManagementResourceRegistration resourceRegistration
// register channel-creation-options as sub model for EJB remote service
resourceRegistration.registerSubModel(new RemoteConnectorChannelCreationOptionResource());
}

@Override
public void registerCapabilities(ManagementResourceRegistration registration) {
registration.registerCapability(EJB_REMOTE_CAPABILITY);
}
}
Expand Up @@ -113,8 +113,8 @@ void installRuntimeServices(final OperationContext context, final ModelNode mode
// Install the EJB remoting connector service which will listen for client connections on the remoting channel
// TODO: Externalize (expose via management API if needed) the version and the marshalling strategy
final EJBRemoteConnectorService ejbRemoteConnectorService = new EJBRemoteConnectorService(channelCreationOptions);
ServiceBuilder<EJBRemoteConnectorService> builder = target.addService(EJBRemoteConnectorService.SERVICE_NAME, ejbRemoteConnectorService);
builder
ServiceBuilder<?> builder = context.getCapabilityServiceTarget().addCapability(EJB3RemoteResourceDefinition.EJB_REMOTE_CAPABILITY, ejbRemoteConnectorService)
.addAliases(EJBRemoteConnectorService.SERVICE_NAME)
// add dependency on the Remoting subsystem endpoint
.addDependency(RemotingServices.SUBSYSTEM_ENDPOINT, Endpoint.class, ejbRemoteConnectorService.getEndpointInjector())
// add rest of the dependencies
Expand Down

0 comments on commit 4ed234b

Please sign in to comment.