Search in sources :

Example 71 with OperationFailedException

use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.

the class ServerAdd method processOutgoingInterceptors.

private void processOutgoingInterceptors(ModelNode model, ActiveMQServerService serverService) throws OperationFailedException {
    if (!model.isDefined()) {
        return;
    }
    List<ModelNode> interceptors = model.asList();
    for (Class clazz : unwrapClasses(interceptors)) {
        try {
            Interceptor interceptor = Interceptor.class.cast(clazz.newInstance());
            serverService.getOutgoingInterceptors().add(interceptor);
        } catch (Exception e) {
            throw new OperationFailedException(e);
        }
    }
}
Also used : OperationFailedException(org.jboss.as.controller.OperationFailedException) ModelNode(org.jboss.dmr.ModelNode) Interceptor(org.apache.activemq.artemis.api.core.Interceptor) IOException(java.io.IOException) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Example 72 with OperationFailedException

use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.

the class ServerAdd method unwrapClass.

private static Class unwrapClass(ModelNode classModel) throws OperationFailedException {
    String className = classModel.get(NAME).asString();
    String moduleName = classModel.get(MODULE).asString();
    try {
        ModuleIdentifier moduleID = ModuleIdentifier.fromString(moduleName);
        Module module = Module.getCallerModuleLoader().loadModule(moduleID);
        Class<?> clazz = module.getClassLoader().loadClass(className);
        return clazz;
    } catch (Exception e) {
        throw MessagingLogger.ROOT_LOGGER.unableToLoadClassFromModule(className, moduleName);
    }
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) Module(org.jboss.modules.Module) IOException(java.io.IOException) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Example 73 with OperationFailedException

use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.

the class ServerAdd method processIncomingInterceptors.

private void processIncomingInterceptors(ModelNode model, ActiveMQServerService serverService) throws OperationFailedException {
    if (!model.isDefined()) {
        return;
    }
    List<ModelNode> interceptors = model.asList();
    for (Class clazz : unwrapClasses(interceptors)) {
        try {
            Interceptor interceptor = Interceptor.class.cast(clazz.newInstance());
            serverService.getIncomingInterceptors().add(interceptor);
        } catch (Exception e) {
            throw new OperationFailedException(e);
        }
    }
}
Also used : OperationFailedException(org.jboss.as.controller.OperationFailedException) ModelNode(org.jboss.dmr.ModelNode) Interceptor(org.apache.activemq.artemis.api.core.Interceptor) IOException(java.io.IOException) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Example 74 with OperationFailedException

use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.

the class ServerAdd method populateModel.

@Override
protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    super.populateModel(context, operation, resource);
    // add an operation to create all the messaging paths resources that have not been already been created
    // prior to adding the ActiveMQ server
    context.addStep(new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            final ModelNode model = Resource.Tools.readModel(resource);
            for (String path : PathDefinition.PATHS.keySet()) {
                if (!model.get(ModelDescriptionConstants.PATH).hasDefined(path)) {
                    PathAddress pathAddress = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.PATH, path));
                    context.createResource(pathAddress);
                }
            }
        }
    }, OperationContext.Stage.MODEL);
    context.addStep((operationContext, model) -> {
        // check that if journal-datasource is defined, no other attributes related to file-system journal are set.
        if (ServerDefinition.JOURNAL_DATASOURCE.resolveModelAttribute(context, model).isDefined()) {
            checkNoAttributesIsDefined(ServerDefinition.JOURNAL_DATASOURCE.getName(), operationContext.getCurrentAddress(), model, ServerDefinition.JOURNAL_TYPE, ServerDefinition.JOURNAL_BUFFER_TIMEOUT, ServerDefinition.JOURNAL_BUFFER_SIZE, ServerDefinition.JOURNAL_SYNC_TRANSACTIONAL, ServerDefinition.JOURNAL_SYNC_NON_TRANSACTIONAL, ServerDefinition.LOG_JOURNAL_WRITE_RATE, ServerDefinition.JOURNAL_FILE_SIZE, ServerDefinition.JOURNAL_MIN_FILES, ServerDefinition.JOURNAL_POOL_FILES, ServerDefinition.JOURNAL_COMPACT_PERCENTAGE, ServerDefinition.JOURNAL_COMPACT_MIN_FILES, ServerDefinition.JOURNAL_MAX_IO, ServerDefinition.CREATE_BINDINGS_DIR, ServerDefinition.CREATE_JOURNAL_DIR);
        }
    }, OperationContext.Stage.MODEL);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) PathAddress(org.jboss.as.controller.PathAddress) OperationFailedException(org.jboss.as.controller.OperationFailedException) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ModelNode(org.jboss.dmr.ModelNode)

Example 75 with OperationFailedException

use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.

the class ServerRemove method performRemove.

@Override
protected void performRemove(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
    // add a runtime step to remove services related to broadcast-group/discovery-group that are started
    // when the server is added.
    context.addStep(new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            final String serverName = context.getCurrentAddressValue();
            final ServiceName serviceName = MessagingServices.getActiveMQServiceName(serverName);
            for (final Resource.ResourceEntry broadcastGroup : resource.getChildren(CommonAttributes.BROADCAST_GROUP)) {
                context.removeService(GroupBindingService.getBroadcastBaseServiceName(serviceName).append(broadcastGroup.getName()));
            }
            for (final Resource.ResourceEntry divertGroup : resource.getChildren(CommonAttributes.DISCOVERY_GROUP)) {
                context.removeService(GroupBindingService.getDiscoveryBaseServiceName(serviceName).append(divertGroup.getName()));
            }
        }
    }, OperationContext.Stage.RUNTIME);
    super.performRemove(context, operation, model);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) ServiceName(org.jboss.msc.service.ServiceName) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) Resource(org.jboss.as.controller.registry.Resource) OperationFailedException(org.jboss.as.controller.OperationFailedException) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

OperationFailedException (org.jboss.as.controller.OperationFailedException)113 ModelNode (org.jboss.dmr.ModelNode)86 PathAddress (org.jboss.as.controller.PathAddress)51 OperationContext (org.jboss.as.controller.OperationContext)49 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)34 ServiceName (org.jboss.msc.service.ServiceName)33 Resource (org.jboss.as.controller.registry.Resource)26 ServiceController (org.jboss.msc.service.ServiceController)19 ServiceTarget (org.jboss.msc.service.ServiceTarget)15 PathElement (org.jboss.as.controller.PathElement)13 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)12 IOException (java.io.IOException)11 Map (java.util.Map)11 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)11 ArrayList (java.util.ArrayList)9 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)9 ContextNames (org.jboss.as.naming.deployment.ContextNames)7 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)7 List (java.util.List)6 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)6