Java Code Examples for org.jboss.as.controller.OperationContext#getServiceRegistry()
The following examples show how to use
org.jboss.as.controller.OperationContext#getServiceRegistry() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MemoryMXBeanAttributeHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void executeWriteAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = operation.require(ModelDescriptionConstants.NAME).asString(); if (PlatformMBeanConstants.VERBOSE.equals(name)) { context.getServiceRegistry(true); //to trigger auth ManagementFactory.getMemoryMXBean().setVerbose(operation.require(ModelDescriptionConstants.VALUE).asBoolean()); } else if (MemoryResourceDefinition.MEMORY_READ_WRITE_ATTRIBUTES.contains(name)) { // Bug throw PlatformMBeanLogger.ROOT_LOGGER.badWriteAttributeImpl(name); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } }
Example 2
Source File: BindingRemoveHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { String name = context.getCurrentAddressValue(); ServiceName svcName = SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(name); ServiceRegistry registry = context.getServiceRegistry(true); ServiceController<?> controller = registry.getService(svcName); if (controller != null) { // We didn't remove it, we just set reloadRequired context.revertReloadRequired(); } else { try { BindingAddHandler.installBindingService(context, model, name); }catch (UnknownHostException e) { throw new OperationFailedException(e.toString()); } } }
Example 3
Source File: RemoteOutboundConnectionWriteHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private boolean applyModelToRuntime(OperationContext context, ModelNode operation, ModelNode fullModel) throws OperationFailedException { boolean reloadRequired = false; final String connectionName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); final ServiceName serviceName = RemoteOutboundConnectionResourceDefinition.OUTBOUND_CONNECTION_CAPABILITY.getCapabilityServiceName(connectionName); final ServiceRegistry registry = context.getServiceRegistry(true); ServiceController sc = registry.getService(serviceName); if (sc != null && sc.getState() == ServiceController.State.UP) { reloadRequired = true; } else { // Service isn't up so we can bounce it context.removeService(serviceName); // safe even if the service doesn't exist // install the service with new values RemoteOutboundConnectionAdd.INSTANCE.installRuntimeService(context, operation, fullModel); } return reloadRequired; }
Example 4
Source File: ManagementInterfaceAddStepHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { List<ServiceName> failures = new ArrayList<>(); ServiceRegistry registry = context.getServiceRegistry(false); for (ServiceName serviceName : requiredServices) { try { ServiceController<?> controller = registry.getService(serviceName); if (controller == null || State.UP != controller.getState()) { failures.add(serviceName); } } catch (ServiceNotFoundException ex) { failures.add(serviceName); } } if (!failures.isEmpty()) { Boolean attachment = context.getAttachment(MANAGEMENT_INTERFACE_KEY); if (attachment == null || !context.getAttachment(MANAGEMENT_INTERFACE_KEY)) { context.attach(MANAGEMENT_INTERFACE_KEY, false); context.addStep(new VerifyInstallationStep(), OperationContext.Stage.VERIFY); } } else { context.attach(MANAGEMENT_INTERFACE_KEY, true); } }
Example 5
Source File: LocalOutboundConnectionWriteHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private boolean applyModelToRuntime(OperationContext context, ModelNode operation) throws OperationFailedException { boolean reloadRequired = false; final String connectionName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); final ServiceName serviceName = LocalOutboundConnectionResourceDefinition.OUTBOUND_CONNECTION_CAPABILITY.getCapabilityServiceName(connectionName); final ServiceRegistry registry = context.getServiceRegistry(true); ServiceController sc = registry.getService(serviceName); if (sc != null && sc.getState() == ServiceController.State.UP) { reloadRequired = true; } else { // Service isn't up so we can bounce it context.removeService(serviceName); // safe even if the service doesn't exist // install the service with new values LocalOutboundConnectionAdd.INSTANCE.installRuntimeService(context, operation); } return reloadRequired; }
Example 6
Source File: GenericOutboundConnectionWriteHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void applyModelToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode fullModel) throws OperationFailedException { final String connectionName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); final ServiceName serviceName = GenericOutboundConnectionResourceDefinition.OUTBOUND_CONNECTION_CAPABILITY.getCapabilityServiceName(connectionName); final ServiceRegistry registry = context.getServiceRegistry(true); ServiceController sc = registry.getService(serviceName); if (sc != null && sc.getState() == ServiceController.State.UP) { GenericOutboundConnectionService svc = GenericOutboundConnectionService.class.cast(sc.getValue()); if (GenericOutboundConnectionResourceDefinition.URI.getName().equals(attributeName)) { svc.setDestination(GenericOutboundConnectionAdd.INSTANCE.getDestinationURI(context, fullModel)); } } else { // Service isn't up so we can bounce it context.removeService(serviceName); // safe even if the service doesn't exist // install the service with new values GenericOutboundConnectionAdd.INSTANCE.installRuntimeService(context, operation, fullModel); } }
Example 7
Source File: BindingRemoveHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) { String name = context.getCurrentAddressValue(); ServiceName svcName = SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(name); ServiceRegistry registry = context.getServiceRegistry(true); ServiceController<?> controller = registry.getService(svcName); ServiceController.State state = controller == null ? null : controller.getState(); if (!context.isResourceServiceRestartAllowed() || (state == ServiceController.State.UP)) { context.reloadRequired(); } else { context.removeService(svcName); } }
Example 8
Source File: SecurityPropertiesWriteHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static SecurityPropertyService getService(OperationContext context) { ServiceRegistry serviceRegistry = context.getServiceRegistry(true); ServiceController<?> service = serviceRegistry.getService(SecurityPropertyService.SERVICE_NAME); if (service != null) { Object serviceImplementation = service.getService(); if (serviceImplementation != null && serviceImplementation instanceof SecurityPropertyService) { return (SecurityPropertyService) serviceImplementation; } } // Again should not be reachable. throw new IllegalStateException("Requires service not available or wrong type."); }
Example 9
Source File: OutboundBindAddressUtils.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static WorkerService getWorkerService(final OperationContext context) { final ServiceRegistry serviceRegistry = context.getServiceRegistry(false); final String workerName = context.getCurrentAddress().getParent().getLastElement().getValue(); final ServiceName workerServiceName = WorkerResourceDefinition.IO_WORKER_RUNTIME_CAPABILITY.getCapabilityServiceName(workerName, XnioWorker.class); final ServiceController<?> workerServiceController = serviceRegistry.getRequiredService(workerServiceName); return (WorkerService) workerServiceController.getService(); }
Example 10
Source File: ManagementUtil.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static UserDomainCallbackHandler getUserDomainCallbackHandler(final OperationContext context, final ModelNode operation) { final String realmName = getSecurityRealmName(operation); ServiceRegistry registry = context.getServiceRegistry(true); ServiceName svcName = UserDomainCallbackHandler.ServiceUtil.createServiceName(realmName); ServiceController<?> sc = registry.getService(svcName); return sc == null ? null : UserDomainCallbackHandler.class.cast(sc.getValue()); }
Example 11
Source File: LdapCacheResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
protected LdapSearcherCache<?, K> lookupService(final OperationContext context, final ModelNode operation) throws OperationFailedException { String realmName = null; boolean forAuthentication = false; boolean forUserSearch = false; PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); for (PathElement current : address) { String key = current.getKey(); if (SECURITY_REALM.equals(key)) { realmName = current.getValue(); } else if (AUTHENTICATION.equals(key)) { forAuthentication = true; forUserSearch = true; } else if (AUTHORIZATION .equals(key)) { forAuthentication = false; } else if (USERNAME_TO_DN.equals(key)) { forUserSearch = true; } else if (GROUP_SEARCH.equals(key)) { forUserSearch = false; } } ServiceName serviceName = LdapSearcherCache.ServiceUtil.createServiceName(forAuthentication, forUserSearch, realmName); ServiceRegistry registry = context.getServiceRegistry(true); ServiceController<LdapSearcherCache<?, K>> service = (ServiceController<LdapSearcherCache<?, K>>) registry.getRequiredService(serviceName); try { return service.awaitValue(); } catch (InterruptedException e) { throw new OperationFailedException(e); } }
Example 12
Source File: SecurityRealmAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private Supplier<CallbackHandlerService> addDomainManagedServersService(final OperationContext context, final ServiceBuilder<?> realmBuilder) { final ServiceRegistry registry = context.getServiceRegistry(false); ServiceController serviceController = registry.getService(DomainManagedServerCallbackHandler.SERVICE_NAME); if (serviceController != null) { return CallbackHandlerService.ServiceUtil.requires(realmBuilder, DomainManagedServerCallbackHandler.SERVICE_NAME); } else { return null; } }
Example 13
Source File: ClassLoadingMXBeanAttributeHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void executeWriteAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = operation.require(ModelDescriptionConstants.NAME).asString(); if (PlatformMBeanConstants.VERBOSE.equals(name)) { context.getServiceRegistry(true); //to trigger auth ManagementFactory.getClassLoadingMXBean().setVerbose(operation.require(ModelDescriptionConstants.VALUE).asBoolean()); } else if (CLASSLOADING_READ_WRITE_ATTRIBUTES.contains(name)) { // Bug throw PlatformMBeanLogger.ROOT_LOGGER.badWriteAttributeImpl(name); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } }
Example 14
Source File: CachingRealmDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void executeRuntimeStep(final OperationContext context, final ModelNode operation) throws OperationFailedException { ServiceRegistry serviceRegistry = context.getServiceRegistry(true); PathAddress currentAddress = context.getCurrentAddress(); RuntimeCapability<Void> runtimeCapability = SECURITY_REALM_RUNTIME_CAPABILITY.fromBaseCapability(currentAddress.getLastElement().getValue()); ServiceName realmName = runtimeCapability.getCapabilityServiceName(); ServiceController<SecurityRealm> serviceController = getRequiredService(serviceRegistry, realmName, SecurityRealm.class); CachingSecurityRealm securityRealm = CachingSecurityRealm.class.cast(serviceController.getValue()); securityRealm.removeAllFromCache(); }
Example 15
Source File: ModifiableKeyStoreDecorator.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Try to obtain a modifiable {@link KeyStoreService} based on the given {@link OperationContext}. * * @param context the current context * @return the modifiable KeyStore service * @throws OperationFailedException if an error occurs while attempting to obtain the modifiable KeyStore service */ static ModifiableKeyStoreService getModifiableKeyStoreService(OperationContext context) throws OperationFailedException { ServiceRegistry serviceRegistry = context.getServiceRegistry(true); PathAddress currentAddress = context.getCurrentAddress(); RuntimeCapability<Void> runtimeCapability = KEY_STORE_RUNTIME_CAPABILITY.fromBaseCapability(currentAddress.getLastElement().getValue()); ServiceName serviceName = runtimeCapability.getCapabilityServiceName(); ServiceController<KeyStore> serviceContainer = getRequiredService(serviceRegistry, serviceName, KeyStore.class); ServiceController.State serviceState = serviceContainer.getState(); if (serviceState != ServiceController.State.UP) { throw ROOT_LOGGER.requiredServiceNotUp(serviceName, serviceState); } return (ModifiableKeyStoreService) serviceContainer.getService(); }
Example 16
Source File: ModifiableKeyStoreDecorator.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Try to obtain a {@link KeyStore} based on the given {@link OperationContext}. * * @param context the current context * @return the unmodifiable KeyStore * @throws OperationFailedException if any error occurs while obtaining. */ static KeyStore getKeyStore(OperationContext context) throws OperationFailedException { ServiceRegistry serviceRegistry = context.getServiceRegistry(true); PathAddress currentAddress = context.getCurrentAddress(); RuntimeCapability<Void> runtimeCapability = KEY_STORE_RUNTIME_CAPABILITY.fromBaseCapability(currentAddress.getLastElement().getValue()); ServiceName serviceName = runtimeCapability.getCapabilityServiceName(); ServiceController<KeyStore> serviceController = getRequiredService(serviceRegistry, serviceName, KeyStore.class); return Assert.assertNotNull(serviceController.getValue()); }
Example 17
Source File: ElytronDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static SecurityPropertyService uninstallSecurityPropertyService(OperationContext context) { ServiceRegistry serviceRegistry = context.getServiceRegistry(true); ServiceController<?> service = serviceRegistry.getService(SecurityPropertyService.SERVICE_NAME); if (service != null) { Object serviceImplementation = service.getService(); context.removeService(service); if (serviceImplementation != null && serviceImplementation instanceof SecurityPropertyService) { return (SecurityPropertyService) serviceImplementation; } } return null; }
Example 18
Source File: ManagementUtil.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
static ServiceController<?> getSecurityRealmService(final OperationContext context, final ModelNode operation, final boolean forUpdate) { final String realmName = getSecurityRealmName(operation); ServiceRegistry registry = context.getServiceRegistry(forUpdate); ServiceName svcName = SecurityRealm.ServiceUtil.createServiceName(realmName); return registry.getService(svcName); }
Example 19
Source File: ManagementUtil.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
static ServiceController<KeytabService> getKeytabService(final OperationContext context, final ModelNode operation) { ServiceRegistry registry = context.getServiceRegistry(false); return (ServiceController<KeytabService>) registry.getRequiredService(getKeytabServiceName(operation)); }
Example 20
Source File: CertificateAuthorityAccountDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
static ModifiableKeyStoreService getModifiableKeyStoreService(OperationContext context, String keyStoreName) throws OperationFailedException { ServiceRegistry serviceRegistry = context.getServiceRegistry(true); return getModifiableKeyStoreService(serviceRegistry, keyStoreName); }