use of org.wildfly.extension.camel.CamelContextRegistry in project wildfly-camel by wildfly-extras.
the class CamelContextRegistryProvider method lookup.
@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
if (serviceInstance.get() == null) {
CamelContextRegistry service = ServiceLocator.getRequiredService(CamelContextRegistry.class);
serviceProducer.set(service);
}
return serviceInstance.get();
}
use of org.wildfly.extension.camel.CamelContextRegistry in project wildfly-camel by wildfly-extras.
the class CamelContextAdd method performRuntime.
@Override
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();
subsystemState.putContextDefinition(propName, propValue.trim());
ServiceController<?> container = context.getServiceRegistry(false).getService(CamelConstants.CAMEL_CONTEXT_REGISTRY_SERVICE_NAME);
if (container != null) {
CamelContextRegistryService serviceRegistry = CamelContextRegistryService.class.cast(container.getService());
CamelContextRegistry camelContextRegistry = serviceRegistry.getValue();
if (camelContextRegistry != null) {
if (camelContextRegistry.getCamelContext(propName) == null) {
serviceRegistry.createCamelContext(propName, propValue);
}
}
}
}
use of org.wildfly.extension.camel.CamelContextRegistry in project wildfly-camel by wildfly-extras.
the class CamelContextRemove method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final String propName = operation.get(ModelDescriptionConstants.OP_ADDR).asObject().get(ModelConstants.CONTEXT).asString();
final String oldContextDefinition = subsystemState.removeContextDefinition(propName);
context.completeStep(new OperationContext.RollbackHandler() {
@Override
public void handleRollback(OperationContext context, ModelNode operation) {
subsystemState.putContextDefinition(propName, oldContextDefinition);
}
});
ServiceController<?> container = context.getServiceRegistry(false).getService(CamelConstants.CAMEL_CONTEXT_REGISTRY_SERVICE_NAME);
if (container != null) {
CamelContextRegistryService serviceRegistry = CamelContextRegistryService.class.cast(container.getService());
CamelContextRegistry camelContextRegistry = serviceRegistry.getValue();
if (camelContextRegistry != null) {
CamelContext camelctx = camelContextRegistry.getCamelContext(propName);
try {
if (camelctx != null) {
camelctx.stop();
}
} catch (Exception e) {
LOGGER.warn("Cannot stop camel context: " + camelctx.getName(), e);
throw new OperationFailedException(e);
}
}
}
}
Aggregations