Skip to content

Commit

Permalink
[resolves wildfly-extras#781] Migrate away from deprecated subsystem API
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Diesler committed Jul 24, 2015
1 parent b910bc0 commit 81fb37a
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 64 deletions.
6 changes: 3 additions & 3 deletions modules/etc/baseline/module-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@
/org/fusesource/hawtdispatch/main/hawtdispatch-1.21.jar
/org/fusesource/hawtdispatch/main/hawtdispatch-transport-1.21.jar
/org/fusesource/mqtt/main/mqtt-client-1.10.jar
/org/jboss/gravia/main/gravia-resource-1.1.3.jar
/org/jboss/gravia/main/gravia-runtime-api-1.1.3.jar
/org/jboss/gravia/main/gravia-runtime-embedded-1.1.3.jar
/org/jboss/gravia/main/gravia-resource-1.1.4.jar
/org/jboss/gravia/main/gravia-runtime-api-1.1.4.jar
/org/jboss/gravia/main/gravia-runtime-embedded-1.1.4.jar
/org/joda/convert/main/joda-convert-1.6.jar
/org/json4s/main/json4s-ast_2.10-3.2.11.jar
/org/json4s/main/json4s-core_2.10-3.2.11.jar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.jboss.gravia">
<resources>
<resource-root path="gravia-resource-1.1.3.jar" />
<resource-root path="gravia-runtime-api-1.1.3.jar" />
<resource-root path="gravia-runtime-embedded-1.1.3.jar" />
<resource-root path="gravia-resource-1.1.4.jar" />
<resource-root path="gravia-runtime-api-1.1.4.jar" />
<resource-root path="gravia-runtime-embedded-1.1.4.jar" />
</resources>
<dependencies>
<module name="javax.api" />
Expand Down
22 changes: 11 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<version.jboss.arquillian.core>1.1.8.Final</version.jboss.arquillian.core>
<version.jboss.dmr>1.2.1.Final</version.jboss.dmr>
<version.jboss.ejb3.ext.api>2.1.0</version.jboss.ejb3.ext.api>
<version.jboss.gravia>1.1.3</version.jboss.gravia>
<version.jboss.gravia>1.1.4</version.jboss.gravia>
<version.jboss.jbossws.api>1.0.2.Final</version.jboss.jbossws.api>
<version.jboss.modules>1.4.3.Final</version.jboss.modules>
<version.jboss.shrinkwrap>1.2.1</version.jboss.shrinkwrap>
Expand Down Expand Up @@ -387,16 +387,6 @@
<artifactId>wildfly-controller-client</artifactId>
<version>${version.wildfly.core}</version>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-ee</artifactId>
<version>${version.wildfly}</version>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-naming</artifactId>
<version>${version.wildfly}</version>
</dependency>
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-server</artifactId>
Expand All @@ -408,6 +398,16 @@
<version>${version.wildfly.core}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-ee</artifactId>
<version>${version.wildfly}</version>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-naming</artifactId>
<version>${version.wildfly}</version>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-testsuite-shared</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -25,7 +25,6 @@
import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
Expand All @@ -51,8 +50,7 @@ protected void populateModel(ModelNode operation, ModelNode model) throws Operat
}

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model, ServiceVerificationHandler verificationHandler,
List<ServiceController<?>> newControllers) throws OperationFailedException {
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {

String propName = operation.get(ModelDescriptionConstants.OP_ADDR).asObject().get(ModelConstants.CONTEXT).asString();
String propValue = CamelContextResource.VALUE.resolveModelAttribute(context, model).asString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@

import org.jboss.as.controller.AbstractBoottimeAddStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.server.AbstractDeploymentChainStep;
import org.jboss.as.server.DeploymentProcessorTarget;
import org.jboss.as.server.deployment.Phase;
Expand Down Expand Up @@ -82,27 +79,19 @@ protected void populateModel(ModelNode operation, ModelNode model) {
}

@Override
protected void performBoottime(final OperationContext context, final ModelNode operation, final ModelNode model,
final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) {
protected void performBoottime(final OperationContext context, final ModelNode operation, final ModelNode model) {

final GraviaSubsystemBootstrap graviaSubsystem = new ReducedGraviaSubsystemBootstrap();
final JBossAllXmlParserRegisteringProcessor<CamelDeploymentSettings> parser =
new JBossAllXmlParserRegisteringProcessor<>(CamelIntegrationParser.ROOT_ELEMENT, CamelDeploymentSettings.ATTACHMENT_KEY, new CamelIntegrationParser());

// Register subsystem services
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
newControllers.addAll(graviaSubsystem.getSubsystemServices(context, verificationHandler));
newControllers.add(CamelBootstrapService.addService(context.getServiceTarget(), verificationHandler));
newControllers.add(CamelContextFactoryService.addService(context.getServiceTarget(), verificationHandler));
newControllers.add(CamelContextFactoryBindingService.addService(context.getServiceTarget(), verificationHandler));
newControllers.add(CamelContextRegistryService.addService(context.getServiceTarget(), subsystemState, verificationHandler));
newControllers.add(CamelContextRegistryBindingService.addService(context.getServiceTarget(), verificationHandler));
newControllers.add(ContextCreateHandlerRegistryService.addService(context.getServiceTarget(), verificationHandler));
context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
}
}, OperationContext.Stage.RUNTIME);
graviaSubsystem.getSubsystemServices(context);
CamelBootstrapService.addService(context.getServiceTarget());
CamelContextFactoryService.addService(context.getServiceTarget());
CamelContextFactoryBindingService.addService(context.getServiceTarget());
CamelContextRegistryService.addService(context.getServiceTarget(), subsystemState);
CamelContextRegistryBindingService.addService(context.getServiceTarget());
ContextCreateHandlerRegistryService.addService(context.getServiceTarget());

// Register deployment unit processors
context.addStep(new AbstractDeploymentChainStep() {
Expand All @@ -126,10 +115,10 @@ protected boolean requiresRuntimeVerification() {

final class ReducedGraviaSubsystemBootstrap extends GraviaSubsystemBootstrap {

public List<ServiceController<?>> getSubsystemServices(OperationContext context, ServiceVerificationHandler verificationHandler) {
public List<ServiceController<?>> getSubsystemServices(OperationContext context) {
List<ServiceController<?>> controllers = new ArrayList<ServiceController<?>>();
controllers.add(getRuntimeService(context, verificationHandler));
controllers.add(getSystemContextService(context, verificationHandler));
controllers.add(getRuntimeService(context));
controllers.add(getSystemContextService(context));
return controllers;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

import static org.wildfly.extension.camel.CamelLogger.LOGGER;

import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.gravia.runtime.Runtime;
import org.jboss.msc.service.AbstractService;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.msc.service.StartContext;
Expand All @@ -45,11 +45,10 @@ public final class CamelBootstrapService extends AbstractService<Void> {

private final InjectedValue<Runtime> injectedRuntime = new InjectedValue<Runtime>();

public static ServiceController<Void> addService(ServiceTarget serviceTarget, ServiceVerificationHandler verificationHandler) {
public static ServiceController<Void> addService(ServiceTarget serviceTarget) {
CamelBootstrapService service = new CamelBootstrapService();
ServiceBuilder<Void> builder = serviceTarget.addService(CamelConstants.CAMEL_SUBSYSTEM_SERVICE_NAME, service);
builder.addDependency(GraviaConstants.RUNTIME_SERVICE_NAME, Runtime.class, service.injectedRuntime);
builder.addListener(verificationHandler);
return builder.install();
}

Expand All @@ -60,5 +59,10 @@ private CamelBootstrapService() {
@Override
public void start(StartContext startContext) throws StartException {
LOGGER.info("Activating Camel Subsystem");

// Register the jboss-msc service container
Runtime runtime = injectedRuntime.getValue();
ServiceContainer service = startContext.getController().getServiceContainer();
runtime.getModuleContext().registerService(ServiceContainer.class, service, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -22,7 +22,6 @@

import static org.wildfly.extension.camel.CamelLogger.LOGGER;

import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.naming.ManagedReferenceFactory;
import org.jboss.as.naming.ManagedReferenceInjector;
import org.jboss.as.naming.ServiceBasedNamingStore;
Expand All @@ -46,7 +45,7 @@
*/
public final class CamelContextFactoryBindingService {

public static ServiceController<?> addService(final ServiceTarget serviceTarget, ServiceVerificationHandler verificationHandler) {
public static ServiceController<?> addService(final ServiceTarget serviceTarget) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(CamelConstants.CAMEL_CONTEXT_FACTORY_BINDING_NAME);
BinderService binderService = new BinderService(bindInfo.getBindName()) {
@Override
Expand All @@ -65,7 +64,6 @@ public synchronized void stop(StopContext context) {
ServiceBuilder<?> builder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService);
builder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector());
builder.addDependency(CamelConstants.CAMEL_CONTEXT_FACTORY_SERVICE_NAME, CamelContextFactory.class, new ManagedReferenceInjector<CamelContextFactory>(injector));
builder.addListener(verificationHandler);
return builder.install();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

package org.wildfly.extension.camel.service;

import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.gravia.runtime.ModuleContext;
import org.jboss.gravia.runtime.Runtime;
import org.jboss.gravia.runtime.ServiceRegistration;
Expand Down Expand Up @@ -51,11 +50,10 @@ public class CamelContextFactoryService extends AbstractService<CamelContextFact
private ServiceRegistration<CamelContextFactory> registration;
private CamelContextFactory contextFactory;

public static ServiceController<CamelContextFactory> addService(ServiceTarget serviceTarget, ServiceVerificationHandler verificationHandler) {
public static ServiceController<CamelContextFactory> addService(ServiceTarget serviceTarget) {
CamelContextFactoryService service = new CamelContextFactoryService();
ServiceBuilder<CamelContextFactory> builder = serviceTarget.addService(CamelConstants.CAMEL_CONTEXT_FACTORY_SERVICE_NAME, service);
builder.addDependency(GraviaConstants.RUNTIME_SERVICE_NAME, Runtime.class, service.injectedRuntime);
builder.addListener(verificationHandler);
return builder.install();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import static org.wildfly.extension.camel.CamelLogger.LOGGER;

import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.naming.ManagedReferenceFactory;
import org.jboss.as.naming.ManagedReferenceInjector;
import org.jboss.as.naming.ServiceBasedNamingStore;
Expand All @@ -46,7 +45,7 @@
*/
public final class CamelContextRegistryBindingService {

public static ServiceController<?> addService(ServiceTarget serviceTarget, ServiceVerificationHandler verificationHandler) {
public static ServiceController<?> addService(ServiceTarget serviceTarget) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(CamelConstants.CAMEL_CONTEXT_REGISTRY_BINDING_NAME);
BinderService binderService = new BinderService(bindInfo.getBindName()) {
@Override
Expand All @@ -65,7 +64,6 @@ public synchronized void stop(StopContext context) {
ServiceBuilder<?> builder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService);
builder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector());
builder.addDependency(CamelConstants.CAMEL_CONTEXT_REGISTRY_SERVICE_NAME, CamelContextRegistry.class, new ManagedReferenceInjector<CamelContextRegistry>(injector));
builder.addListener(verificationHandler);
return builder.install();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.apache.camel.spi.CamelContextTracker;
import org.apache.camel.spi.ManagementStrategy;
import org.apache.camel.support.EventNotifierSupport;
import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.gravia.runtime.ModuleContext;
import org.jboss.gravia.runtime.Runtime;
import org.jboss.gravia.runtime.ServiceRegistration;
Expand Down Expand Up @@ -82,12 +81,11 @@ public class CamelContextRegistryService extends AbstractService<CamelContextReg
private CamelContextRegistry contextRegistry;
private ServiceRegistration<CamelContextRegistry> registration;

public static ServiceController<CamelContextRegistry> addService(ServiceTarget serviceTarget, SubsystemState subsystemState, ServiceVerificationHandler verificationHandler) {
public static ServiceController<CamelContextRegistry> addService(ServiceTarget serviceTarget, SubsystemState subsystemState) {
CamelContextRegistryService service = new CamelContextRegistryService(subsystemState);
ServiceBuilder<CamelContextRegistry> builder = serviceTarget.addService(CamelConstants.CAMEL_CONTEXT_REGISTRY_SERVICE_NAME, service);
builder.addDependency(GraviaConstants.RUNTIME_SERVICE_NAME, Runtime.class, service.injectedRuntime);
builder.addDependency(CamelConstants.CONTEXT_CREATE_HANDLER_REGISTRY_SERVICE_NAME, ContextCreateHandlerRegistry.class, service.injectedHandlerRegistry);
builder.addListener(verificationHandler);
return builder.install();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.List;
import java.util.Map;

import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.msc.service.AbstractService;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceController;
Expand All @@ -53,10 +52,9 @@ public class ContextCreateHandlerRegistryService extends AbstractService<Context

private ContextCreateHandlerRegistry createHandlerRegistry;

public static ServiceController<ContextCreateHandlerRegistry> addService(ServiceTarget serviceTarget, ServiceVerificationHandler verificationHandler) {
public static ServiceController<ContextCreateHandlerRegistry> addService(ServiceTarget serviceTarget) {
ContextCreateHandlerRegistryService service = new ContextCreateHandlerRegistryService();
ServiceBuilder<ContextCreateHandlerRegistry> builder = serviceTarget.addService(CamelConstants.CONTEXT_CREATE_HANDLER_REGISTRY_SERVICE_NAME, service);
builder.addListener(verificationHandler);
return builder.install();
}

Expand Down

0 comments on commit 81fb37a

Please sign in to comment.