Search in sources :

Example 71 with ServiceRegistry

use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.

the class RaOperationUtil method activate.

public static void activate(OperationContext context, String raName, String archiveName) throws OperationFailedException {
    ServiceRegistry registry = context.getServiceRegistry(true);
    ServiceController<?> inactiveRaController = registry.getService(ConnectorServices.INACTIVE_RESOURCE_ADAPTER_SERVICE.append(archiveName));
    final CapabilityServiceSupport support = context.getCapabilityServiceSupport();
    if (inactiveRaController == null) {
        inactiveRaController = registry.getService(ConnectorServices.INACTIVE_RESOURCE_ADAPTER_SERVICE.append(raName));
        if (inactiveRaController == null) {
            throw ConnectorLogger.ROOT_LOGGER.RARNotYetDeployed(raName);
        }
    }
    InactiveResourceAdapterDeploymentService.InactiveResourceAdapterDeployment inactive = (InactiveResourceAdapterDeploymentService.InactiveResourceAdapterDeployment) inactiveRaController.getValue();
    final ServiceController<?> RaxmlController = registry.getService(ServiceName.of(ConnectorServices.RA_SERVICE, raName));
    Activation raxml = (Activation) RaxmlController.getValue();
    RaServicesFactory.createDeploymentService(inactive.getRegistration(), inactive.getConnectorXmlDescriptor(), inactive.getModule(), inactive.getServiceTarget(), archiveName, inactive.getDeploymentUnitServiceName(), inactive.getDeployment(), raxml, inactive.getResource(), registry, support);
}
Also used : InactiveResourceAdapterDeploymentService(org.jboss.as.connector.services.resourceadapters.deployment.InactiveResourceAdapterDeploymentService) Activation(org.jboss.jca.common.api.metadata.resourceadapter.Activation) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport)

Example 72 with ServiceRegistry

use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.

the class MdbDeliveryDependenciesProcessor method undeploy.

@Override
public void undeploy(DeploymentUnit deploymentUnit) {
    final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION);
    if (moduleConfiguration == null) {
        return;
    }
    final ServiceRegistry serviceRegistry = deploymentUnit.getServiceRegistry();
    boolean clusteredSingletonFound = false;
    for (final ComponentConfiguration configuration : moduleConfiguration.getComponentConfigurations()) {
        final ComponentDescription description = configuration.getComponentDescription();
        if (description instanceof MessageDrivenComponentDescription) {
            MessageDrivenComponentDescription mdbDescription = (MessageDrivenComponentDescription) description;
            clusteredSingletonFound = clusteredSingletonFound || mdbDescription.isClusteredSingleton();
            if (mdbDescription.isDeliveryControlled()) {
                serviceRegistry.getRequiredService(mdbDescription.getDeliveryControllerName()).setMode(Mode.REMOVE);
            }
        }
    }
}
Also used : ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) EEModuleConfiguration(org.jboss.as.ee.component.EEModuleConfiguration) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 73 with ServiceRegistry

use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.

the class NamingStoreService method start.

/**
 * Creates the naming store if not provided by the constructor.
 *
 * @param context The start context
 * @throws StartException If any problems occur creating the context
 */
public void start(final StartContext context) throws StartException {
    if (store == null) {
        final ServiceRegistry serviceRegistry = context.getController().getServiceContainer();
        final ServiceName serviceNameBase = context.getController().getName();
        final ServiceTarget serviceTarget = context.getChildTarget();
        store = readOnly ? new ServiceBasedNamingStore(serviceRegistry, serviceNameBase) : new WritableServiceBasedNamingStore(serviceRegistry, serviceNameBase, serviceTarget);
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) WritableServiceBasedNamingStore(org.jboss.as.naming.WritableServiceBasedNamingStore) ServiceBasedNamingStore(org.jboss.as.naming.ServiceBasedNamingStore) ServiceTarget(org.jboss.msc.service.ServiceTarget) WritableServiceBasedNamingStore(org.jboss.as.naming.WritableServiceBasedNamingStore) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 74 with ServiceRegistry

use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.

the class ReadCredentialServlet method doGet.

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    resp.setContentType("text/plain");
    resp.setCharacterEncoding("UTF-8");
    final PrintWriter writer = resp.getWriter();
    final String credentialStore = req.getParameter(PARAM_CREDENTIAL_STORE);
    final String alias = req.getParameter(PARAM_ALIAS);
    String separator = req.getParameter(PARAM_SEPARATOR);
    if (separator == null) {
        separator = PARAM_SEPARATOR_DEFAULT;
    }
    ServiceRegistry registry = CurrentServiceContainer.getServiceContainer();
    if (credentialStore == null || credentialStore.length() == 0) {
        for (ServiceName name : registry.getServiceNames()) {
            if (SERVICE_NAME_CRED_STORE.equals(name.getParent())) {
                writer.print(name.getSimpleName());
                writer.print(separator);
            }
        }
        return;
    }
    ServiceController<?> credStoreService = registry.getService(ServiceName.of(SERVICE_NAME_CRED_STORE, credentialStore));
    if (credStoreService == null) {
        resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
        writer.print(credentialStore + " not found");
        return;
    }
    CredentialStore cs = (CredentialStore) credStoreService.getValue();
    if (alias == null || alias.length() == 0) {
        try {
            for (String csAlias : cs.getAliases()) {
                writer.print(csAlias);
                writer.print(separator);
            }
        } catch (UnsupportedOperationException | CredentialStoreException e) {
            throw new ServletException("Unable to list aliases", e);
        }
        return;
    }
    String clearPassword = null;
    try {
        if (cs.exists(alias, PasswordCredential.class)) {
            Password password = cs.retrieve(alias, PasswordCredential.class).getPassword();
            if (password instanceof ClearPassword) {
                clearPassword = new String(((ClearPassword) password).getPassword());
            }
        }
    } catch (CredentialStoreException | IllegalStateException e) {
        throw new ServletException("Unable to retrieve password  from credential store", e);
    }
    if (clearPassword == null) {
        resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
        writer.print(alias + " password not found in " + credentialStore);
    } else {
        writer.print(clearPassword);
    }
}
Also used : ClearPassword(org.wildfly.security.password.interfaces.ClearPassword) PasswordCredential(org.wildfly.security.credential.PasswordCredential) CredentialStoreException(org.wildfly.security.credential.store.CredentialStoreException) ServletException(javax.servlet.ServletException) ServiceName(org.jboss.msc.service.ServiceName) CredentialStore(org.wildfly.security.credential.store.CredentialStore) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) PrintWriter(java.io.PrintWriter) Password(org.wildfly.security.password.Password) ClearPassword(org.wildfly.security.password.interfaces.ClearPassword)

Aggregations

ServiceRegistry (org.jboss.msc.service.ServiceRegistry)74 ServiceName (org.jboss.msc.service.ServiceName)51 ModelNode (org.jboss.dmr.ModelNode)22 PathAddress (org.jboss.as.controller.PathAddress)15 ServiceTarget (org.jboss.msc.service.ServiceTarget)15 OperationFailedException (org.jboss.as.controller.OperationFailedException)13 ServiceController (org.jboss.msc.service.ServiceController)12 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)8 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)8 OperationContext (org.jboss.as.controller.OperationContext)6 Resource (org.jboss.as.controller.registry.Resource)6 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)5 Activation (org.jboss.jca.common.api.metadata.resourceadapter.Activation)5 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)4 PathElement (org.jboss.as.controller.PathElement)4 DefaultAccessTimeoutService (org.jboss.as.ejb3.component.DefaultAccessTimeoutService)3 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)3 ArrayList (java.util.ArrayList)2 BridgeConfiguration (org.apache.activemq.artemis.core.config.BridgeConfiguration)2 DivertConfiguration (org.apache.activemq.artemis.core.config.DivertConfiguration)2