Refine search
private static Resource safeGetResource(OperationContext context, PathElement path) { try { return context.readResourceFromRoot(PathAddress.pathAddress(path), false); } catch (RuntimeException e) { // No such resource return null; } } }
/** * Resolves runtime name of model resource. * @param context - operation context in which handler is invoked * @param address - deployment address * @return runtime name of module. Value which is returned is never null. */ protected static String resolveRuntimeName(final OperationContext context, final PathElement address){ final ModelNode runtimeName = context.readResourceFromRoot(PathAddress.pathAddress(address),false).getModel() .get(ModelDescriptionConstants.RUNTIME_NAME); return runtimeName.asString(); } }
@Override public AttributeValueTranslator getWriteTranslator() { return (context, value) -> { String jndiName = value.asString(); PathAddress address = context.getCurrentAddress(); PathAddress rootAddress = address.subAddress(0, address.size() - 4); PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources")); Resource subsystem = context.readResourceFromRoot(subsystemAddress); for (String type : Arrays.asList("data-source", "xa-data-source")) { if (subsystem.hasChildren(type)) { for (Resource.ResourceEntry entry : subsystem.getChildren(type)) { ModelNode model = entry.getModel(); if (model.get("jndi-name").asString().equals(jndiName)) { return new ModelNode(entry.getName()); } } } } throw InfinispanLogger.ROOT_LOGGER.dataSourceJndiNameNotFound(jndiName); }; } };
public static void validateDefaultInterfaceReference(final OperationContext context, final ModelNode bindingGroup) throws OperationFailedException { ModelNode defaultInterfaceNode = bindingGroup.get(DEFAULT_INTERFACE.getName()); if (defaultInterfaceNode.getType() == ModelType.STRING) { // ignore UNDEFINED and EXPRESSION String defaultInterface = defaultInterfaceNode.asString(); PathAddress interfaceAddress = PathAddress.pathAddress(PathElement.pathElement(INTERFACE, defaultInterface)); try { context.readResourceFromRoot(interfaceAddress, false); } catch (RuntimeException e) { throw ControllerMessages.MESSAGES.nonexistentInterface(defaultInterface, DEFAULT_INTERFACE.getName()); } } }
/** * Resolves runtime name of model resource. * @param context - operation context in which handler is invoked * @param address - deployment address * @return runtime name of module. Value which is returned is never null. */ protected String resolveRuntimeName(final OperationContext context, final PathElement address){ final ModelNode runtimeName = context.readResourceFromRoot(PathAddress.pathAddress(address),false).getModel() .get(ModelDescriptionConstants.RUNTIME_NAME); return runtimeName.asString(); } }
private static Resource safeGetResource(OperationContext context, PathElement path) { try { return context.readResourceFromRoot(PathAddress.pathAddress(path), false); } catch (RuntimeException e) { // No such resource return null; } } }
public static void validateDefaultInterfaceReference(final OperationContext context, final ModelNode bindingGroup) throws OperationFailedException { ModelNode defaultInterfaceNode = bindingGroup.get(DEFAULT_INTERFACE.getName()); if (defaultInterfaceNode.getType() == ModelType.STRING) { // ignore UNDEFINED and EXPRESSION String defaultInterface = defaultInterfaceNode.asString(); PathAddress interfaceAddress = PathAddress.pathAddress(PathElement.pathElement(INTERFACE, defaultInterface)); try { context.readResourceFromRoot(interfaceAddress, false); } catch (RuntimeException e) { throw ControllerMessages.MESSAGES.nonexistentInterface(defaultInterface, DEFAULT_INTERFACE.getName()); } } }
@SuppressWarnings("deprecation") @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { // Handle recipe for version < 4.0 where stack was not required and the stack attribute would use default-stack for a default value if (!operation.hasDefined(Attribute.STACK.getName())) { ModelNode parentModel = context.readResourceFromRoot(context.getCurrentAddress().getParent(), false).getModel(); // If default-stack is not defined either, then recipe must be for version >= 4.0 and so this really is an invalid operation if (parentModel.hasDefined(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_STACK.getName())) { operation.get(Attribute.STACK.getName()).set(parentModel.get(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_STACK.getName())); } } handler.execute(context, operation); } };
private boolean checkJtsEnabled(final OperationContext context) { try { final ModelNode jtsNode = context.readResourceFromRoot(PathAddress.pathAddress("subsystem", "transactions"), false) .getModel().get("jts"); return jtsNode.isDefined() ? jtsNode.asBoolean() : false; } catch (NoSuchResourceException ex) { return false; } } }
static PathAddress translateProxyPath(OperationContext context, PathAddress address) throws OperationFailedException { Set<Resource.ResourceEntry> children = context.readResourceFromRoot(address, false).getChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey()); if (children.size() != 1) { throw new OperationFailedException(ModClusterLogger.ROOT_LOGGER.legacyOperationsWithMultipleProxies()); } PathAddress proxyPath = PathAddress.pathAddress(ProxyConfigurationResourceDefinition.pathElement(children.iterator().next().getName())); address = address.append(proxyPath); return address; }
static void validateInterfaceReference(final OperationContext context, final ModelNode binding) throws OperationFailedException { ModelNode interfaceNode = binding.get(INTERFACE.getName()); if (interfaceNode.getType() == ModelType.STRING) { // ignore UNDEFINED and EXPRESSION String interfaceName = interfaceNode.asString(); PathAddress interfaceAddress = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.INTERFACE, interfaceName)); try { context.readResourceFromRoot(interfaceAddress, false); } catch (RuntimeException e) { throw ControllerMessages.MESSAGES.nonexistentInterface(interfaceName, INTERFACE.getName()); } } } }
@Override public AttributeValueTranslator getReadTranslator() { return (context, value) -> { String poolName = value.asString(); PathAddress address = context.getCurrentAddress(); PathAddress rootAddress = address.subAddress(0, address.size() - 4); PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources")); Resource subsystem = context.readResourceFromRoot(subsystemAddress); for (String type : Arrays.asList("data-source", "xa-data-source")) { Resource resource = subsystem.getChild(PathElement.pathElement(type, poolName)); if (resource != null) { return resource.getModel().get("jndi-name"); } } throw InfinispanLogger.ROOT_LOGGER.dataSourceNotFound(poolName); }; }
private static String getRuntimeName(final OperationContext context, final PathElement element) { final ModelNode deploymentModel = context.readResourceFromRoot(PathAddress.pathAddress(element), false).getModel(); if (!deploymentModel.hasDefined(ModelDescriptionConstants.RUNTIME_NAME)) { throw BatchLogger.LOGGER.couldNotFindDeploymentName(context.getCurrentAddress().toString()); } return deploymentModel.get(ModelDescriptionConstants.RUNTIME_NAME).asString(); } }
private static Resource safeGetResource(OperationContext context, PathElement path) { try { return context.readResourceFromRoot(PathAddress.pathAddress(path), false); } catch (RuntimeException e) { // No such resource return null; } } }
static void validateInterfaceReference(final OperationContext context, final ModelNode binding) throws OperationFailedException { ModelNode interfaceNode = binding.get(INTERFACE.getName()); if (interfaceNode.getType() == ModelType.STRING) { // ignore UNDEFINED and EXPRESSION String interfaceName = interfaceNode.asString(); PathAddress interfaceAddress = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.INTERFACE, interfaceName)); try { context.readResourceFromRoot(interfaceAddress, false); } catch (RuntimeException e) { throw ControllerMessages.MESSAGES.nonexistentInterface(interfaceName, INTERFACE.getName()); } } } }
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(); String profile = rootModel.hasDefined("profile-name") ? rootModel.get("profile-name").asString() : null; driverNode.get(DRIVER_NAME.getName()).set(driver.getDriverName()); if (driver.isFromDeployment()) { driverNode.get(DEPLOYMENT_NAME.getName()).set(driver.getDriverName()); driverNode.get(DRIVER_MODULE_NAME.getName()); driverNode.get(MODULE_SLOT.getName());
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { // Cache the TransactionManager service name for use by our runtime services ConnectorServices.registerCapabilityServiceName(LOCAL_TRANSACTION_PROVIDER_CAPABILITY, context.getCapabilityServiceName(LOCAL_TRANSACTION_PROVIDER_CAPABILITY, null)); final Resource subsystemResource = context.readResourceFromRoot(PathAddress.pathAddress(ResourceAdaptersExtension.SUBSYSTEM_PATH)); ResourceAdaptersSubsystemService service = new ResourceAdaptersSubsystemService(); CopyOnWriteArrayListMultiMap<String, ServiceName> value = service.getValue(); for (Resource.ResourceEntry re : subsystemResource.getChildren(RESOURCEADAPTER_NAME)) { value.putIfAbsent(re.getModel().get(ARCHIVE.getName()).asString(), ConnectorServices.RA_SERVICE.append(re.getName())); } final ServiceBuilder<?> builder = context.getServiceTarget().addService(ConnectorServices.RESOURCEADAPTERS_SUBSYSTEM_SERVICE, service); builder.setInitialMode(ServiceController.Mode.ACTIVE).install(); } }
private String getExtension(OperationContext context, String subsystem) { for (String extensionName : context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getChildrenNames(EXTENSION)) { Resource extension = context.readResourceFromRoot(PathAddress.pathAddress(EXTENSION, extensionName), false); if (extension.getChildrenNames(SUBSYSTEM).contains(subsystem)) { return extensionName; } } return null; }
public void execute(final JndiViewExtensionContext context) throws OperationFailedException { final ModelNode applicationsNode = context.getResult().get("applications"); final Set<Resource.ResourceEntry> deploymentResource = context.getOperationContext().readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getChildren(DEPLOYMENT); for (final Resource.ResourceEntry entry : deploymentResource) { final ServiceController<?> deploymentUnitServiceController = serviceRegistry.getService(ServiceName.JBOSS.append("deployment", "unit", entry.getName())); if (deploymentUnitServiceController != null) { final ModelNode deploymentNode = applicationsNode.get(entry.getName()); final DeploymentUnit deploymentUnit = DeploymentUnit.class.cast(deploymentUnitServiceController.getValue()); final NamingStore appStore = NamingStore.class.cast(appContextController.getValue()); try { context.addEntries(deploymentNode.get("java:app"), new NamingContext(appStore, null)); } catch (NamingException e) { throw new OperationFailedException(e, new ModelNode().set(EeLogger.ROOT_LOGGER.failedToRead("java:app", appName)));
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)); final Resource web = context.readResourceFromRoot(address.subAddress(0, address.size() - 1), false); final ModelNode subModel = web.getModel(); final String host = DeploymentDefinition.VIRTUAL_HOST.resolveModelAttribute(context, subModel).asString(); final String path = DeploymentDefinition.CONTEXT_ROOT.resolveModelAttribute(context, subModel).asString(); final String server = DeploymentDefinition.SERVER.resolveModelAttribute(context, subModel).asString(); context.addStep(new OperationStepHandler() { @Override public void execute(final OperationContext context, final ModelNode operation) { final ServiceController<?> deploymentServiceController = context.getServiceRegistry(false).getService(UndertowService.deploymentServiceName(server, host, path)); if (deploymentServiceController == null) { return; } final UndertowDeploymentService deploymentService = (UndertowDeploymentService) deploymentServiceController.getService(); final DeploymentInfo deploymentInfo = deploymentService.getDeploymentInfoInjectedValue().getValue(); final UndertowMetricsCollector collector = (UndertowMetricsCollector)deploymentInfo.getMetricsCollector(); MetricsHandler.MetricResult result = collector != null ? collector.getMetrics(context.getCurrentAddressValue()) : null; if (result != null) { final ModelNode response = new ModelNode(); handle(response, result); context.getResult().set(response); } } }, OperationContext.Stage.RUNTIME); } }