@Override public final OperationFailedException jndiNameInvalidFormat() { final OperationFailedException result = new OperationFailedException(String.format(getLoggingLocale(), jndiNameInvalidFormat$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String jndiNameShouldValidate = "WFLYAG0304: JNDI name shouldn't include '//' or end with '/'";
@Override public ModelNode execute(ExpressionResolver expressionResolver, ModelNode operation, ModClusterServiceMBean service) throws OperationFailedException { String virtualHost = VIRTUAL_HOST.resolveModelAttribute(expressionResolver, operation).asString(); String webContext = CONTEXT.resolveModelAttribute(expressionResolver, operation).asString(); try { boolean enabled = service.enableContext(virtualHost, webContext); return new ModelNode(enabled); } catch (IllegalArgumentException e) { throw new OperationFailedException(ModClusterLogger.ROOT_LOGGER.contextOrHostNotFound(virtualHost, webContext)); } } },
@SuppressWarnings("deprecation") @Override public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); if (value.isDefined()) { String module = value.asString(); try { org.jboss.modules.ModuleIdentifier.fromString(module); } catch (IllegalArgumentException e) { throw new OperationFailedException(e.getMessage() + ": " + module, e); } } } }
archiveOrModuleName = ARCHIVE.resolveModelAttribute(context, raModel).asString(); } else { archiveOrModuleName = MODULE.resolveModelAttribute(context, raModel).asString(); adminObjectValue = RaOperationUtil.buildAdminObjects(context, operation, poolName); } catch (ValidateException e) { throw new OperationFailedException(e, new ModelNode().set(ConnectorLogger.ROOT_LOGGER.failedToCreate("AdminObject", operation, e.getLocalizedMessage())));
addEntries(contextsNode.get("java:"), new NamingContext(javaContextNamingStore, null)); } catch (NamingException e) { throw new OperationFailedException(e, new ModelNode().set(NamingLogger.ROOT_LOGGER.failedToReadContextEntries("java:"))); addEntries(contextsNode.get("java:jboss"), new NamingContext(jbossContextNamingStore, null)); } catch (NamingException e) { throw new OperationFailedException(e, new ModelNode().set(NamingLogger.ROOT_LOGGER.failedToReadContextEntries("java:jboss"))); addEntries(contextsNode.get("java:jboss/exported"), new NamingContext(exportedContextNamingStore, null)); } catch (NamingException e) { throw new OperationFailedException(e, new ModelNode().set(NamingLogger.ROOT_LOGGER.failedToReadContextEntries("java:jboss/exported"))); addEntries(contextsNode.get("java:global"), new NamingContext(globalContextNamingStore, null)); } catch (NamingException e) { throw new OperationFailedException(e, new ModelNode().set(NamingLogger.ROOT_LOGGER.failedToReadContextEntries("java:global")));
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final String attributeName = operation.require(NAME).asString(); try { final ModelNode result = context.getResult(); switch (attributeName) { case ModelDescriptionConstants.STATISTICS_ENABLED: { result.set(stats.isEnabled()); break; } } } catch (Exception e) { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToGetMetrics(e.getLocalizedMessage())); } } }, OperationContext.Stage.RUNTIME);
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { super.performRuntime(context, operation, model); String name = context.getCurrentAddressValue(); int ordinal = ORDINAL.resolveModelAttribute(context, model).asInt(); ModelNode props = PROPERTIES.resolveModelAttribute(context, model); ModelNode classModel = CLASS.resolveModelAttribute(context, model); ModelNode dirModel = DIR.resolveModelAttribute(context, model); final ConfigSource configSource; if (classModel.isDefined()) { Class configSourceClass = unwrapClass(classModel); try { configSource = ConfigSource.class.cast(configSourceClass.newInstance()); MicroProfileConfigLogger.ROOT_LOGGER.loadConfigSourceFromClass(configSourceClass); ConfigSourceService.install(context, name, configSource); } catch (Exception e) { throw new OperationFailedException(e); } } else if (dirModel.isDefined()) { String path = PATH.resolveModelAttribute(context, dirModel).asString(); String relativeTo = RELATIVE_TO.resolveModelAttribute(context, dirModel).asStringOrNull(); DirConfigSourceService.install(context, name, path, relativeTo, ordinal); } else { Map<String, String> properties = PropertiesAttributeDefinition.unwrapModel(context, props); configSource = new PropertiesConfigSource(properties, name, ordinal); ConfigSourceService.install(context, name, configSource); } } }, new AbstractRemoveStepHandler() {
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { MBeanServer mbs = TransactionExtension.getMBeanServer(context); final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); try { final ObjectName on = LogStoreResource.getObjectName(resource); final ModelNode model = resource.getModel().clone(); AttributeList attributes = mbs.getAttributes(on, LogStoreConstants.PARTICIPANT_JMX_NAMES); for (javax.management.Attribute attribute : attributes.asList()) { String modelName = LogStoreConstants.jmxNameToModelName(LogStoreConstants.MODEL_TO_JMX_PARTICIPANT_NAMES, attribute.getName()); if (modelName != null) { ModelNode aNode = model.get(modelName); Object value = attribute.getValue(); if (aNode != null) aNode.set(value == null ? "" : value.toString()); } } // Replace the model resource.writeModel(model); } catch (Exception e) { throw new OperationFailedException("JMX error: " + e.getMessage()); } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }
@Override public final OperationFailedException dataSourceJndiNameNotFound(final String jndiName) { final OperationFailedException result = new OperationFailedException(String.format(getLoggingLocale(), dataSourceJndiNameNotFound$str(), jndiName)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String dataSourceNotFound = "WFLYCLINF0007: Failed to locate data source %s";
final String jndiName = JNDINAME.resolveModelAttribute(context, operation).asString(); final String raName = path.getParent().getLastElement().getValue(); archiveOrModuleName = ARCHIVE.resolveModelAttribute(context, raModel).asString(); } else { archiveOrModuleName = MODULE.resolveModelAttribute(context, raModel).asString(); throw new OperationFailedException(e, new ModelNode().set(ConnectorLogger.ROOT_LOGGER.failedToCreate("ConnectionDefinition", operation, e.getLocalizedMessage())));
/** * {@inheritDoc} */ @Override public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); if (value.isDefined() && value.getType() != ModelType.EXPRESSION) { String val = value.asString(); try { PredicateParser.parse(val, getClass().getClassLoader()); } catch (Exception e) { throw new OperationFailedException(UndertowLogger.ROOT_LOGGER.predicateNotValid(val, e.getMessage()), e); } } } }
context.addEntries(moduleNode.get("java:module"), new NamingContext(moduleStore, null)); } catch (NamingException e) { throw new OperationFailedException(e, new ModelNode().set(EeLogger.ROOT_LOGGER.failedToRead("java:module", appName, moduleName))); context.addEntries(componentNode.get("java:comp"), new NamingContext(compStore, null)); } catch (NamingException e) { throw new OperationFailedException(e, new ModelNode().set(EeLogger.ROOT_LOGGER.failedToRead("java:comp", appName, moduleName, componentName)));
@Override public ModelNode execute(ExpressionResolver expressionResolver, ModelNode operation, ModClusterServiceMBean service) throws OperationFailedException { String virtualHost = VIRTUAL_HOST.resolveModelAttribute(expressionResolver, operation).asString(); String webContext = CONTEXT.resolveModelAttribute(expressionResolver, operation).asString(); try { boolean disabled = service.disableContext(virtualHost, webContext); return new ModelNode(disabled); } catch (IllegalArgumentException e) { throw new OperationFailedException(ModClusterLogger.ROOT_LOGGER.contextOrHostNotFound(virtualHost, webContext)); } } },
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final String attributeName = operation.require(NAME).asString(); try { final ModelNode result = context.getResult(); result.set(wmStat.getWorkActive()); break; result.set(wmStat.getWorkFailed()); break; result.set(wmStat.getWorkSuccessful()); break; throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToGetMetrics(e.getLocalizedMessage()));
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final ServiceController<?> managementRepoService = context.getServiceRegistry(disallowMonitor).getService( ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE); if (managementRepoService != null) { ModelNode operationResult = null; try { final ManagementRepository repository = (ManagementRepository) managementRepoService.getValue(); final List<Pool> pools = matcher.match(jndiName, repository); if (pools.isEmpty()) { throw ConnectorLogger.ROOT_LOGGER.failedToMatchPool(jndiName); } for (Pool pool : pools) { operationResult = invokeCommandOn(pool, parameters); } } catch (Exception e) { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToInvokeOperation(e.getLocalizedMessage())); } if (operationResult != null) { context.getResult().set(operationResult); } } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }, OperationContext.Stage.RUNTIME);
@Override public final OperationFailedException jndiNameInvalidFormat() { final OperationFailedException result = new OperationFailedException(String.format(getLoggingLocale(), jndiNameInvalidFormat$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } @Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final String attributeName = operation.require(NAME).asString(); final ServiceController<?> managementRepoService = context.getServiceRegistry(false).getService( ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE); if (managementRepoService != null) { try { setModelValue(context.getResult(), attributeName); } catch (Exception e) { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToGetMetrics(e.getLocalizedMessage())); } } } }, OperationContext.Stage.RUNTIME);
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 ModelNode execute(ExpressionResolver expressionResolver, ModelNode operation, ModClusterServiceMBean service) throws OperationFailedException { String virtualHost = VIRTUAL_HOST.resolveModelAttribute(expressionResolver, operation).asString(); String webContext = CONTEXT.resolveModelAttribute(expressionResolver, operation).asString(); int waitTime = WAIT_TIME.resolveModelAttribute(expressionResolver, operation).asInt(); try { boolean success = service.stopContext(virtualHost, webContext, waitTime, TimeUnit.SECONDS); return new ModelNode(success); } catch (IllegalArgumentException e) { throw new OperationFailedException(ModClusterLogger.ROOT_LOGGER.contextOrHostNotFound(virtualHost, webContext)); } } },
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);