@SuppressWarnings("unchecked") private static ServiceController<SecurityDomainContext> getSecurityDomainService(OperationContext context, String securityDomain) { return (ServiceController<SecurityDomainContext>) context .getServiceRegistry(false) .getRequiredService(SecurityDomainService.SERVICE_NAME.append(securityDomain)); }
@SuppressWarnings("unchecked") private synchronized void setupComponent() { if (component == null) { component = ((ServiceController<BasicComponent>) serviceRegistry.getRequiredService(componentStartServiceName)) .getValue(); } }
protected ManagedReferenceFactory getManagedReferenceFactory(ContextNames.BindInfo ejbBindInfo) { try { ServiceController<?> controller = serviceRegistry.getRequiredService(ejbBindInfo.getBinderServiceName()); return (ManagedReferenceFactory) controller.getValue(); } catch (Exception e) { return null; } }
/** * Returns the name of the resource adapter which will be used as the default RA for MDBs (unless overridden by * the MDBs). * * @param serviceRegistry * @return */ private String getDefaultResourceAdapterName(final ServiceRegistry serviceRegistry) { if (appclient) { // we must report the MDB, but we can't use any MDB/JCA facilities return "n/a"; } final ServiceController<DefaultResourceAdapterService> serviceController = (ServiceController<DefaultResourceAdapterService>) serviceRegistry.getRequiredService(DefaultResourceAdapterService.DEFAULT_RA_NAME_SERVICE_NAME); return serviceController.getValue().getDefaultResourceAdapterName(); }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { ServiceRegistry registry = context.getServiceRegistry(false); JdrReportCollector jdrCollector = JdrReportCollector.class.cast(registry.getRequiredService(JdrReportService.SERVICE_NAME).getValue()); ModelNode response = context.getResult(); JdrReport report = jdrCollector.collect(); if (report.getStartTime() != null) { response.get("start-time").set(report.getStartTime()); } if (report.getEndTime() != null) { response.get("end-time").set(report.getEndTime()); } response.get("report-location").set(report.getLocation()); context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }, OperationContext.Stage.RUNTIME);
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { ServiceRegistry registry = context.getServiceRegistry(false); DriverRegistry driverRegistry = (DriverRegistry)registry.getRequiredService(ConnectorServices.JDBC_DRIVER_REGISTRY_SERVICE).getValue(); ServiceModuleLoader serviceModuleLoader = (ServiceModuleLoader)registry.getRequiredService(Services.JBOSS_SERVICE_MODULE_LOADER).getValue(); InstalledDriver driver = driverRegistry.getInstalledDriver(driverName); if (driver == null) { context.getResult().set(new ModelNode()); return; } ModelNode result = dsClsInfoNode(serviceModuleLoader, driver.getModuleName(), driver.getDataSourceClassName(), driver.getXaDataSourceClassName()); context.getResult().set(result); }
@Override public T get() { ServiceTarget target = this.registry.getRequiredService(this.name).getServiceContainer();
@Override protected void executeRuntimeStep(final OperationContext context, final ModelNode operation) throws OperationFailedException { final ServiceName componentServiceName = componentServiceName(context,operation); final EJBComponent component = (EJBComponent) context.getServiceRegistry(false).getRequiredService(componentServiceName).getValue(); executeReadMetricStep(context, operation, component); }
private void applyModelToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode model) throws OperationFailedException { String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); ServiceRegistry registry = context.getServiceRegistry(true); EJBSuspendHandlerService service = (EJBSuspendHandlerService) registry.getRequiredService(EJBSuspendHandlerService.SERVICE_NAME).getValue(); if (service!= null && this.gracefulTxnShutdownAttribute.getName().equals(attributeName)) { boolean enableGracefulTxnShutdown = this.gracefulTxnShutdownAttribute.resolveModelAttribute(context, model) .asBoolean(); service.enableGracefulTxnShutdown(enableGracefulTxnShutdown); } }
@Override public void undeploy(final DeploymentUnit context) { final Module module = context.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE); ServiceName deploymentService = context.getServiceName(); ServiceController<?> controller = context.getServiceRegistry().getRequiredService(deploymentService); //WFLY-9666 we do this cleanup at the end of undeploy //if we do it now any code in the undeploy sequence that attempts to use EL can cause it to be re-added controller.addListener(new LifecycleListener() { @Override public void handleEvent(ServiceController<?> serviceController, LifecycleEvent lifecycleEvent) { if(lifecycleEvent == LifecycleEvent.DOWN) { FactoryFinderCache.clearClassLoader(module.getClassLoader()); controller.removeListener(this); } } }); } }
@Override protected void executeAgainstComponent(OperationContext context, ModelNode operation, MessageDrivenComponent component, String opName, PathAddress address) throws OperationFailedException { if (START_DELIVERY.equals(opName)) { if (component.isDeliveryControlled()) { context.getServiceRegistry(true).getRequiredService(component.getDeliveryControllerName()).setMode(ServiceController.Mode.PASSIVE); } else { component.startDelivery(); } } else if (STOP_DELIVERY.equals(opName)) { if (component.isDeliveryControlled()) { context.getServiceRegistry(true).getRequiredService(component.getDeliveryControllerName()).setMode( ServiceController.Mode.NEVER); } else { component.stopDelivery(); } } else { super.executeAgainstComponent(context, operation, component, opName, address); } } }
DriverRegistry driverRegistry = (DriverRegistry)registry.getRequiredService(ConnectorServices.JDBC_DRIVER_REGISTRY_SERVICE).getValue(); ServiceModuleLoader serviceModuleLoader = (ServiceModuleLoader)registry.getRequiredService(Services.JBOSS_SERVICE_MODULE_LOADER).getValue(); ModelNode result = new ModelNode(); InstalledDriver driver = driverRegistry.getInstalledDriver(name);
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { ServiceRegistry registry = context.getServiceRegistry(false); DriverRegistry driverRegistry = (DriverRegistry)registry.getRequiredService(ConnectorServices.JDBC_DRIVER_REGISTRY_SERVICE).getValue(); ServiceModuleLoader serviceModuleLoader = (ServiceModuleLoader)registry.getRequiredService(Services.JBOSS_SERVICE_MODULE_LOADER).getValue(); Resource rootNode = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false); ModelNode rootModel = rootNode.getModel();
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (context.isDefaultRequiresRuntime()) { context.addStep((ctx, op) -> { RuntimeCapability<Void> runtimeCapability = APPLICATION_SECURITY_DOMAIN_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue()); ServiceName serviceName = runtimeCapability.getCapabilityServiceName(ApplicationSecurityDomain.class); ServiceRegistry serviceRegistry = context.getServiceRegistry(false); ServiceController<?> controller = serviceRegistry.getRequiredService(serviceName); ModelNode deploymentList = new ModelNode(); if (controller.getState() == State.UP) { Service service = controller.getService(); if (service instanceof ApplicationSecurityDomainService) { for (String current : ((ApplicationSecurityDomainService) service).getDeployments()) { deploymentList.add(current); } } } context.getResult().set(deploymentList); }, OperationContext.Stage.RUNTIME); } } }
private static AgroalDataSource getDataSource(OperationContext context) throws OperationFailedException { ServiceRegistry registry = context.getServiceRegistry(false); String dataSourceName = context.getCurrentAddressValue(); switch (context.getCurrentAddress().getLastElement().getKey()) { case DataSourceOperations.DATASOURCE_SERVICE_NAME: ServiceController<?> controller = registry.getRequiredService(AbstractDataSourceDefinition.DATA_SOURCE_CAPABILITY.getCapabilityServiceName(dataSourceName)); return ((AgroalDataSource) controller.getValue()); case XADataSourceOperations.XADATASOURCE_SERVICE_NAME: ServiceController<?> xaController = registry.getRequiredService(AbstractDataSourceDefinition.DATA_SOURCE_CAPABILITY.getCapabilityServiceName(dataSourceName)); return ((AgroalDataSource) xaController.getValue()); default: throw AgroalLogger.SERVICE_LOGGER.unknownDatasourceServiceType(context.getCurrentAddress().getLastElement().getKey()); } }
final ServiceController<?> controller; try { controller = serviceRegistry.getRequiredService(serviceName); } catch (ServiceNotFoundException e) { throw NamingLogger.ROOT_LOGGER.cannotResolveService(serviceName);
protected void updateDeliveryGroup(OperationContext context, ModelNode currentValue, ModelNode resolvedValue) throws OperationFailedException { if (currentValue.equals(resolvedValue)) { return; } String groupName = context.getCurrentAddress().getLastElement().getValue(); context.getServiceRegistry(true).getRequiredService(getDeliveryGroupServiceName(groupName)).setMode( resolvedValue.asBoolean() ? ServiceController.Mode.ACTIVE : ServiceController.Mode.NEVER); } });
@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.isClusteredSingleton() || mdbDescription.getDeliveryGroup() != null) { serviceRegistry.getRequiredService(mdbDescription.getDeliveryControllerName()).setMode(Mode.REMOVE); } } } } }
@Override public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException { DeploymentUnit unit = context.getDeploymentUnit(); if (unit.getParent() == null) { SingletonPolicy policy = context.getAttachment(POLICY_KEY); if (policy != null) { CapabilityServiceSupport support = unit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT); // Ideally, we would just install the next phase using the singleton policy, however deployment unit phases do not currently support restarts // Restart the deployment using the attached phase builder, but only if a builder was not already attached if (unit.putAttachment(Attachments.DEPLOYMENT_UNIT_PHASE_BUILDER, new SingletonDeploymentUnitPhaseBuilder(support, policy)) == null) { SingletonLogger.ROOT_LOGGER.singletonDeploymentDetected(policy); ServiceController<?> controller = context.getServiceRegistry().getRequiredService(unit.getServiceName()); controller.addListener(this); controller.setMode(Mode.NEVER); } } } }
@SuppressWarnings("unchecked") protected ProcessEngine getProcessEngineForArchive(ServiceName serviceName, ServiceRegistry serviceRegistry) { ServiceController<ProcessEngine> processEngineServiceController = (ServiceController<ProcessEngine>) serviceRegistry.getRequiredService(serviceName); return processEngineServiceController.getValue(); }