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);
}
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);
}
}
}
}
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);
}
}
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);
}
}
Aggregations