static MBeanServer getMBeanServer(OperationContext context) { final ServiceRegistry serviceRegistry = context.getServiceRegistry(false); final ServiceController<?> serviceController = serviceRegistry.getService(MBEAN_SERVER_SERVICE_NAME); if (serviceController == null) { throw TransactionLogger.ROOT_LOGGER.jmxSubsystemNotInstalled(); } return (MBeanServer) serviceController.getValue(); }
public ManagedReference getReference(final Object instance) { if (component == null) { synchronized (this) { if (component == null) { component = (ServiceController<Component>) serviceRegistry.getService(serviceName); } } } if (component == null) { return null; } return new ComponentManagedReference(component.getValue().createInstance(instance)); }
private void addConfigSourcesFromServices(ConfigBuilder builder, ServiceRegistry serviceRegistry, ClassLoader classloader) { List<ServiceName> serviceNames = serviceRegistry.getServiceNames(); for (ServiceName serviceName: serviceNames) { if (ServiceNames.CONFIG_SOURCE.isParentOf(serviceName)) { ServiceController<?> service = serviceRegistry.getService(serviceName); ConfigSource configSource = ConfigSource.class.cast(service.getValue()); builder.withSources(configSource); } else if (ServiceNames.CONFIG_SOURCE_PROVIDER.isParentOf(serviceName)) { ServiceController<?> service = serviceRegistry.getService(serviceName); ConfigSourceProvider configSourceProvider = ConfigSourceProvider.class.cast(service.getValue()); for (ConfigSource configSource : configSourceProvider.getConfigSources(classloader)) { builder.withSources(configSource); } } } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode recoveryEnvModel) throws OperationFailedException { final String configPropertyValue = CONNECTION_PROPERTY_VALUE.resolveModelAttribute(context, recoveryEnvModel).asString(); final ModelNode address = operation.require(OP_ADDR); PathAddress path = PathAddress.pathAddress(address); final String jndiName = path.getElement(path.size() - 2).getValue(); final String configPropertyName = PathAddress.pathAddress(address).getLastElement().getValue(); ServiceName serviceName = DataSourceConfigService.SERVICE_NAME_BASE.append(jndiName).append("connection-properties").append(configPropertyName); final ServiceRegistry registry = context.getServiceRegistry(true); final ServiceName dataSourceConfigServiceName = DataSourceConfigService.SERVICE_NAME_BASE .append(jndiName); final ServiceController<?> dataSourceConfigController = registry .getService(dataSourceConfigServiceName); if (dataSourceConfigController == null || !((DataSource) dataSourceConfigController.getValue()).isEnabled()) { final ServiceTarget serviceTarget = context.getServiceTarget(); final ConnectionPropertiesService service = new ConnectionPropertiesService(configPropertyName, configPropertyValue); serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.NEVER) .install(); } else { context.reloadRequired(); } }
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 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); }
registration = baseRegistration.getSubModel(PathAddress.pathAddress(PathElement.pathElement("subdeployment"))); } else { registration = baseRegistration; final ServiceController<?> raService = phaseContext.getServiceRegistry().getService( ConnectorServices.RESOURCEADAPTERS_SERVICE); if (raService != null) raxmls = ((ResourceAdaptersService.ModifiableResourceAdaptors) raService.getValue());
@Override protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode opAddr = operation.require(OP_ADDR); PathAddress address = PathAddress.pathAddress(opAddr); final String securityDomain = address.getLastElement().getValue(); ServiceController<SecurityDomainContext> controller = getSecurityDomainService(context, securityDomain); if (controller != null) { // FIXME this is nasty. waitForService(controller); SecurityDomainContext sdc = controller.getValue(); @SuppressWarnings("unchecked") CacheableManager<?, Principal> manager = (CacheableManager<?, Principal>) sdc .getAuthenticationManager(); Set<Principal> cachedPrincipals = manager.getCachedKeys(); ModelNode result = context.getResult(); for (Principal principal : cachedPrincipals) { result.add(principal.getName()); } if (!result.isDefined()) result.setEmptyList(); } else { throw SecurityLogger.ROOT_LOGGER.noAuthenticationCacheAvailable(securityDomain); } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }
ServiceController<?> serviceController = context.getServiceRegistry(false).getService(raServiceName); final ModifiableResourceAdapter resourceAdapter; if (serviceController != null) { resourceAdapter = (ModifiableResourceAdapter) serviceController.getValue(); } else { resourceAdapter = null; final List<ServiceName> serviceNameList = context.getServiceRegistry(false).getServiceNames(); for (ServiceName name : serviceNameList) { if (raServiceName.isParentOf(name)) {
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode recoveryEnvModel) throws OperationFailedException { final String configPropertyValue = XADATASOURCE_PROPERTY_VALUE.resolveModelAttribute(context, recoveryEnvModel).asString(); final ModelNode address = operation.require(OP_ADDR); PathAddress path = PathAddress.pathAddress(address); final String dsName = path.getElement(path.size() - 2).getValue(); final String configPropertyName = PathAddress.pathAddress(address).getLastElement().getValue(); ServiceName serviceName = XADataSourceConfigService.SERVICE_NAME_BASE.append(dsName).append("xa-datasource-properties").append(configPropertyName); final ServiceRegistry registry = context.getServiceRegistry(true); final ServiceName dataSourceConfigServiceName = XADataSourceConfigService.SERVICE_NAME_BASE .append(dsName); final ServiceController<?> dataSourceConfigController = registry .getService(dataSourceConfigServiceName); if (dataSourceConfigController == null || !((XaDataSource) dataSourceConfigController.getValue()).isEnabled()) { final ServiceTarget serviceTarget = context.getServiceTarget(); final XaDataSourcePropertiesService service = new XaDataSourcePropertiesService(configPropertyName, configPropertyValue); ServiceController<?> controller = serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.NEVER) .install(); } else { context.reloadRequired(); } }
private void applyModelToRuntime(OperationContext context, final ModelNode model) throws OperationFailedException { final ServiceRegistry serviceRegistry = context.getServiceRegistry(true); ServiceController<IIOPSettingsService> controller = (ServiceController<IIOPSettingsService>) serviceRegistry.getService(IIOPSettingsService.SERVICE_NAME); if (controller != null) { IIOPSettingsService service = controller.getValue(); applySetting(service, context, model); } }
private CallbackHandler getCallbackHandler(final ServiceRegistry serviceRegistry, final String userName, final String securityRealmName) { if (securityRealmName != null && ! securityRealmName.trim().isEmpty()) { final ServiceName securityRealmServiceName = SecurityRealm.ServiceUtil.createServiceName(securityRealmName); final ServiceController<SecurityRealm> securityRealmController = (ServiceController<SecurityRealm>) serviceRegistry.getService(securityRealmServiceName); if (securityRealmController != null) { final SecurityRealm securityRealm = securityRealmController.getValue(); final CallbackHandlerFactory cbhFactory; if (securityRealm != null && (cbhFactory = securityRealm.getSecretCallbackHandlerFactory()) != null && userName != null) { return cbhFactory.getCallbackHandler(userName); } } } return null; }
private CacheIgnoreAware getCacheDisablingAware(ModelNode operation, OperationContext context) { final PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)); PathElement lastElement = address.getLastElement(); String connectorType = lastElement.getKey().split("-")[0]; String connectorName = lastElement.getValue(); ServiceName serviceName = Constants.DATAGRID.append(connectorType, connectorName); ServiceController<ProtocolServer> service = ServiceContainerHelper.findService(context.getServiceRegistry(true), serviceName); return service.getValue(); }
@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 protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode opAddr = operation.require(OP_ADDR); PathAddress address = PathAddress.pathAddress(opAddr); final String securityDomain = address.getLastElement().getValue(); String principal = null; if (operation.hasDefined(Constants.PRINCIPAL_ARGUMENT)) principal = operation.get(Constants.PRINCIPAL_ARGUMENT).asString(); ServiceController<SecurityDomainContext> controller = getSecurityDomainService(context, securityDomain); if (controller != null) { // FIXME this is nasty. waitForService(controller); SecurityDomainContext sdc = controller.getValue(); @SuppressWarnings("unchecked") CacheableManager<?, Principal> manager = (CacheableManager<?, Principal>) sdc.getAuthenticationManager(); if (principal != null) manager.flushCache(new SimplePrincipal(principal)); else manager.flushCache(); } else { throw SecurityLogger.ROOT_LOGGER.noAuthenticationCacheAvailable(securityDomain); } // Can't rollback context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); final String jndiName = address.getLastElement().getValue(); final String attributeName = operation.require(NAME).asString(); final ServiceController<?> managementRepoService = context.getServiceRegistry(false).getService( ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE); if (managementRepoService != null) { try { final ManagementRepository repository = (ManagementRepository) managementRepoService.getValue(); final ModelNode result = context.getResult(); List<StatisticsPlugin> stats = getMatchingStats(jndiName, repository); for (StatisticsPlugin stat : stats) { result.set("" + stat.getValue(attributeName)); } } catch (Exception e) { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToGetMetrics(e.getLocalizedMessage())); } } } }, OperationContext.Stage.RUNTIME);
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { ModelNode result = new ModelNode(); CachedConnectionManager ccm = (CachedConnectionManager) context.getServiceRegistry(false).getService(ConnectorServices.CCM_SERVICE).getValue(); ModelNode txResult = new ModelNode().set(ccm.getNumberOfConnections()); ccm = (CachedConnectionManager) context.getServiceRegistry(false).getService(ConnectorServices.NON_TX_CCM_SERVICE).getValue(); ModelNode nonTxResult = new ModelNode().set(ccm.getNumberOfConnections()); result.get(Constants.TX).set(txResult); result.get(Constants.NON_TX).set(nonTxResult); context.getResult().set(result); } }, OperationContext.Stage.RUNTIME);
@Override public ManagedReference getReference() { if (component == null) { synchronized (this) { if (component == null) { component = (ServiceController<Component>) serviceRegistry.getService(serviceName); } } } if (view == null && viewServiceName != null) { synchronized (this) { if (view == null) { view = (ServiceController<ViewService.View>) serviceRegistry.getService(viewServiceName); } } } if (component == null) { return null; } if(view == null) { return new ComponentManagedReference(component.getValue().createInstance()); } else { try { return view.getValue().createInstance(); } catch (Exception e) { throw new RuntimeException(e); } } }
@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 protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String parameterName, final ModelNode newValue, final ModelNode currentValue, final HandbackHolder<List<PoolConfiguration>> handbackHolder) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); final String poolName = address.getLastElement().getValue(); final ServiceController<?> managementRepoService = context.getServiceRegistry(false).getService( ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE); List<PoolConfiguration> poolConfigs = null; if (managementRepoService != null) { try { final ManagementRepository repository = (ManagementRepository) managementRepoService.getValue(); poolConfigs = getMatchingPoolConfigs(poolName, repository); updatePoolConfigs(poolConfigs, parameterName, newValue); handbackHolder.setHandback(poolConfigs); } catch (Exception e) { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToSetAttribute(e.getLocalizedMessage())); } } return (IDLETIMEOUTMINUTES.getName().equals(parameterName) || BACKGROUNDVALIDATION.getName().equals(parameterName) || BACKGROUNDVALIDATIONMILLIS.getName().equals(parameterName) || POOL_PREFILL.getName().equals(parameterName) || POOL_FLUSH_STRATEGY.getName().equals(parameterName) || MAX_POOL_SIZE.getName().equals(parameterName) || MIN_POOL_SIZE.getName().equals(parameterName)); }