当前位置: 首页>>代码示例>>Java>>正文


Java ExpressionResolver类代码示例

本文整理汇总了Java中org.jboss.as.controller.ExpressionResolver的典型用法代码示例。如果您正苦于以下问题:Java ExpressionResolver类的具体用法?Java ExpressionResolver怎么用?Java ExpressionResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ExpressionResolver类属于org.jboss.as.controller包,在下文中一共展示了ExpressionResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testHttpSocketBinding

import org.jboss.as.controller.ExpressionResolver; //导入依赖的package包/类
@Test
public void testHttpSocketBinding() throws IOException, OperationFailedException {
    final ModelNode address = new ModelNode();
    address.add("socket-binding-group", "*");
    address.add("socket-binding", "management-http");
    address.protect();

    final ModelNode operation = new ModelNode();
    operation.get(OP).set(READ_RESOURCE_OPERATION);
    operation.get(OP_ADDR).set(address);

    final ModelNode result = managementClient.getControllerClient().execute(operation);
    assertTrue(result.hasDefined(RESULT));
    assertEquals(SUCCESS, result.get(OUTCOME).asString());
    final List<ModelNode> steps = getSteps(result.get(RESULT));
    assertEquals(1, steps.size());
    final ModelNode httpBinding = steps.get(0);
    assertEquals(9990, ExpressionResolver.TEST_RESOLVER.resolveExpressions(httpBinding.get(RESULT, "port")).asInt());

}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:21,代码来源:BasicOperationsUnitTestCase.java

示例2: fromModelNode

import org.jboss.as.controller.ExpressionResolver; //导入依赖的package包/类
@Override
public Object fromModelNode(final ModelNode node) {
    if (node == null || !node.isDefined() || node.asString().isEmpty()) {
        return null;
    }
    if (!expressions || valueAccessor == UndefinedValueAccessor.INSTANCE) {
        if (!expressions && node.getType() == ModelType.EXPRESSION) {
            if (!VAULT_PATTERN.matcher(node.asString()).matches()) {
                ModelNode resolved;
                try {
                    resolved = ExpressionResolver.SIMPLE.resolveExpressions(node);
                } catch (OperationFailedException e) {
                    throw new IllegalArgumentException(e);
                }
                return valueAccessor.fromModelNode(resolved);
            }
        }
        return valueAccessor.fromModelNode(node);

    } else {
        return node.asString();
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:24,代码来源:TypeConverters.java

示例3: testPropertyTypeExpressionConverter

import org.jboss.as.controller.ExpressionResolver; //导入依赖的package包/类
@Test
public void testPropertyTypeExpressionConverter() throws OperationFailedException {
    ModelNode description = createDescription(ModelType.PROPERTY);
    TypeConverter converter = getConverter(description);

    ModelNode node = new ModelNode();
    node.set("name", "${this.should.not.exist.!!!!!:value}");
    node.protect();

    ModelNode expected = ExpressionResolver.TEST_RESOLVER.resolveExpressions(node.clone());

    Assert.assertEquals(SimpleType.STRING, converter.getOpenType());
    String dmr = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(expected, ModelNode.fromString(dmr));
    Assert.assertEquals(dmr, assertCast(String.class, converter.fromModelNode(expected)));
    assertToArray(converter, dmr);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:LegacyTypeConverterUnitTestCase.java

示例4: testPropertyValueTypeExpressionConverter

import org.jboss.as.controller.ExpressionResolver; //导入依赖的package包/类
@Test
public void testPropertyValueTypeExpressionConverter() throws Exception {
    ModelNode description = createDescription(ModelType.PROPERTY, ModelType.INT);
    TypeConverter converter = getConverter(description);

    ModelNode node = new ModelNode();
    node.set("name", "${this.should.not.exist.!!!!!:1}");
    node.protect();

    ModelNode expected = ExpressionResolver.TEST_RESOLVER.resolveExpressions(node.clone());

    Assert.assertEquals(SimpleType.STRING, converter.getOpenType());
    String dmr = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(expected, ModelNode.fromString(dmr));
    Assert.assertEquals(dmr, assertCast(String.class, converter.fromModelNode(expected)));
    assertToArray(converter, dmr);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:LegacyTypeConverterUnitTestCase.java

示例5: createSSLContextSupplier

import org.jboss.as.controller.ExpressionResolver; //导入依赖的package包/类
private Supplier<SSLContext> createSSLContextSupplier(final ModelNode serverModel, final ExpressionResolver resolver) {
    if (serverModel.hasDefined(SSL, LOOPBACK) == false) {
        return null;
    }

    ModelNode ssl = serverModel.get(SSL, LOOPBACK);

    try {
        String sslProtocol = SslLoopbackResourceDefinition.SSL_PROTOCOCOL.resolveModelAttribute(resolver, ssl).asString();
        String trustManagerAlgorithm = asStringIfDefined(ssl, SslLoopbackResourceDefinition.TRUST_MANAGER_ALGORITHM, resolver);
        String trustStoreType = asStringIfDefined(ssl, SslLoopbackResourceDefinition.TRUSTSTORE_TYPE, resolver);
        String trustStorePath = asStringIfDefined(ssl, SslLoopbackResourceDefinition.TRUSTSTORE_PATH, resolver);
        ModelNode trustStorePasswordModel = SslLoopbackResourceDefinition.TRUSTSTORE_PASSWORD.resolveModelAttribute(resolver, ssl);
        char[] trustStorePassword = trustStorePasswordModel.isDefined() ? trustStorePasswordModel.asString().toCharArray() : null;

        return new SSLContextSupplier(sslProtocol, trustManagerAlgorithm, trustStoreType, trustStorePath, trustStorePassword);
    } catch (OperationFailedException e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:21,代码来源:ManagedServerBootCmdFactory.java

示例6: testGetServerLaunchCommand

import org.jboss.as.controller.ExpressionResolver; //导入依赖的package包/类
/**
 * Test of getServerLaunchCommand method, of class
 * ManagedServerBootCmdFactory.
 */
@Test
public void testGetServerLaunchCommand() throws UnknownHostException {
    System.out.println("getServerLaunchCommand");
    ManagedServerBootCmdFactory instance = new ManagedServerBootCmdFactory("test-server", getDomainModel(), getHostModel(), getTestHostEnvironment(), ExpressionResolver.TEST_RESOLVER, false);
    List<String> result = instance.getServerLaunchCommand(true);
    Assert.assertThat(result.size(), is(notNullValue()));
    Assert.assertThat(result.size(), is(16));
    boolean sawDServer = false;
    boolean sawDpcid = false;
    for (String arg : result) {
        if (arg.startsWith("-Djboss.server.log.dir")) {
            Assert.assertThat(arg, is(not("-Djboss.server.log.dir=/tmp/")));
        } else if (arg.startsWith("-Djboss.server.temp.dir")) {
            Assert.assertThat(arg, is(not("-Djboss.server.temp.dir=/tmp/")));
        } else if (arg.startsWith("-Djboss.domain.log.dir")) {
            Assert.assertThat(arg, is("-Djboss.domain.log.dir=/tmp/"));
        } else if (arg.equals("-D[" + ManagedServer.getServerProcessName("test-server") + "]")) {
            sawDServer = true;
        } else if (arg.startsWith("-D[pcid:") && arg.endsWith("]")) {
            sawDpcid = true;
        }
    }
    Assert.assertTrue(sawDServer);
    Assert.assertTrue(sawDpcid);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:30,代码来源:ManagedServerBootCmdFactoryTestCase.java

示例7: testRuntimeMapAttributeWrite

import org.jboss.as.controller.ExpressionResolver; //导入依赖的package包/类
@Test
public void testRuntimeMapAttributeWrite() throws Exception {
    // :write-attribute(name=runtime-map-attribute.map-key)
    ModelNode op = createOperation("write-attribute", TEST_ADDRESS);
    op.get("name").set(RUNTIME_MAP_ATTRIBUTE.getName() + ".map-key");
    op.get("value").set("map-value");
    executeCheckNoFailure(op);

    Map<String, String> map = PropertiesAttributeDefinition.unwrapModel(ExpressionResolver.TEST_RESOLVER, runtimeMapAttributeValue);
    Assert.assertEquals(1, map.size());
    Assert.assertEquals("map-value", map.get("map-key"));

    op = createOperation("write-attribute", TEST_ADDRESS);
    op.get("name").set(RUNTIME_MAP_ATTRIBUTE.getName() + ".map-key2");
    op.get("value").set("map-value2");
    executeCheckNoFailure(op);

    map = PropertiesAttributeDefinition.unwrapModel(ExpressionResolver.TEST_RESOLVER, runtimeMapAttributeValue);
    Assert.assertEquals(2, map.size());
    Assert.assertEquals("map-value", map.get("map-key"));
    Assert.assertEquals("map-value2", map.get("map-key2"));
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:23,代码来源:EnhancedSyntaxTestCase.java

示例8: activate

import org.jboss.as.controller.ExpressionResolver; //导入依赖的package包/类
@Override
public void activate(final ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException {
    final ServiceTarget serviceTarget = serviceActivatorContext.getServiceTarget();
    final ServiceName endpointName = managementSubsystemEndpoint ? RemotingServices.SUBSYSTEM_ENDPOINT : ManagementRemotingServices.MANAGEMENT_ENDPOINT;
    final EndpointService.EndpointType endpointType = managementSubsystemEndpoint ? EndpointService.EndpointType.SUBSYSTEM : EndpointService.EndpointType.MANAGEMENT;
    try {
        ManagementWorkerService.installService(serviceTarget);
        // TODO see if we can figure out a way to work in the vault resolver instead of having to use ExpressionResolver.SIMPLE
        @SuppressWarnings("deprecation")
        final OptionMap options = EndpointConfigFactory.create(ExpressionResolver.SIMPLE, endpointConfig, DEFAULTS);
        ManagementRemotingServices.installRemotingManagementEndpoint(serviceTarget, endpointName, WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.NODE_NAME, null), endpointType, options);

        // Install the communication services
        HostControllerConnectionService service = new HostControllerConnectionService(managementURI, serverName, serverProcessName, authKey, initialOperationID, managementSubsystemEndpoint, sslContextSupplier);
        Services.addServerExecutorDependency(serviceTarget.addService(HostControllerConnectionService.SERVICE_NAME, service), service.getExecutorInjector())
                .addDependency(ServerService.JBOSS_SERVER_SCHEDULED_EXECUTOR, ScheduledExecutorService.class, service.getScheduledExecutorInjector())
                .addDependency(endpointName, Endpoint.class, service.getEndpointInjector())
                .addDependency(ControlledProcessStateService.SERVICE_NAME, ControlledProcessStateService.class, service.getProcessStateServiceInjectedValue())
                .setInitialMode(ServiceController.Mode.ACTIVE).install();

    } catch (OperationFailedException e) {
        throw new ServiceRegistryException(e);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:25,代码来源:DomainServerCommunicationServices.java

示例9: ModelControllerService

import org.jboss.as.controller.ExpressionResolver; //导入依赖的package包/类
ModelControllerService(final ControlledProcessState processState, final StringConfigurationPersister persister, final ServerDelegatingResourceDefinition rootResourceDefinition) {
    super(ProcessType.EMBEDDED_SERVER, new RunningModeControl(RunningMode.ADMIN_ONLY), persister, processState, rootResourceDefinition, null, ExpressionResolver.TEST_RESOLVER,
            AuditLogger.NO_OP_LOGGER, new DelegatingConfigurableAuthorizer(), new ManagementSecurityIdentitySupplier(), new CapabilityRegistry(true));
    this.persister = persister;
    this.processState = processState;
    this.rootResourceDefinition = rootResourceDefinition;

    Properties properties = new Properties();
    properties.put("jboss.home.dir", System.getProperty("basedir", ".") + File.separatorChar + "target");

    final String hostControllerName = "hostControllerName"; // Host Controller name may not be null when in a managed domain
    environment = new ServerEnvironment(hostControllerName, properties, new HashMap<String, String>(), null, null,
            ServerEnvironment.LaunchType.DOMAIN, null, ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), ".", properties), false);
    extensionRegistry =
            new ExtensionRegistry(ProcessType.STANDALONE_SERVER, new RunningModeControl(RunningMode.NORMAL), null, null, null, RuntimeHostControllerInfoAccessor.SERVER);

    capabilityRegistry = new CapabilityRegistry(processType.isServer());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:InterfaceManagementUnitTestCase.java

示例10: resolveAllExpressions

import org.jboss.as.controller.ExpressionResolver; //导入依赖的package包/类
/**
 * Subsystem XML can contain expressions for simple XSD types (boolean, long, etc.) that
 * prevents to validate it against the schema.
 *
 * For XML validation, the XML is read and any expression is resolved (they must have a default value to
 * be properly resolved).
 */
private static String resolveAllExpressions(String xmlContent, Properties resolvedProperties) throws IOException {
    // We hack a bit here and use a variant of the management model expression resolver
    // to resolve expressions in the xml. XML strings aren't DMR model nodes but
    // pretending they are seems to work well enough.
    ExpressionResolver replacer = new Resolver(resolvedProperties);
    StringBuilder out = new StringBuilder();

    try( BufferedReader reader = new BufferedReader(new StringReader(xmlContent)) ) {
        String line;
        while ((line = reader.readLine()) != null) {
            String resolved = line;
            if (ExpressionResolver.EXPRESSION_PATTERN.matcher(line).matches()) {
                ModelNode input = new ModelNode(new ValueExpression(line));
                try {
                    resolved = replacer.resolveExpressions(input).asString();
                } catch (OperationFailedException e) {
                    // ignore, output the original line and see what happens ;)
                }
            }
            out.append(resolved);
            out.append('\n');
        }
    }
    return out.toString();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:33,代码来源:SchemaValidator.java

示例11: resolveOption

import org.jboss.as.controller.ExpressionResolver; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public OptionMap.Builder resolveOption(final ExpressionResolver context, final ModelNode model, OptionMap.Builder builder) throws OperationFailedException {
    ModelNode value = resolveModelAttribute(context, model);
    if (value.isDefined()) {
        if (getType() == ModelType.INT) {
            builder.set((Option<Integer>) option, value.asInt());
        } else if (getType() == ModelType.LONG) {
            builder.set(option, value.asLong());
        } else if (getType() == ModelType.BOOLEAN) {
            builder.set(option, value.asBoolean());
        } else if (optionType.isEnum()) {
            builder.set(option, option.parseValue(value.asString(), option.getClass().getClassLoader()));
        }else if (option.getClass().getSimpleName().equals("SequenceOption")) {
            builder.setSequence(option, value.asString().split("\\s*,\\s*"));
        } else if (getType() == ModelType.STRING) {
            builder.set(option, value.asString());
        } else {
            throw new OperationFailedException("Don't know how to handle: " + option + " with value: " + value);
        }
    }
    return builder;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:23,代码来源:OptionAttributeDefinition.java

示例12: isVaultExpression

import org.jboss.as.controller.ExpressionResolver; //导入依赖的package包/类
private boolean isVaultExpression(Object value) {
    if (value != null && value.getClass() == String.class){
        String valueString = (String)value;
        if (ExpressionResolver.EXPRESSION_PATTERN.matcher(valueString).matches()) {
            return TypeConverters.VAULT_PATTERN.matcher(valueString).matches();
        }

    }
    return false;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:11,代码来源:ModelControllerMBeanHelper.java

示例13: testUndefinedTypeEmptyConverter

import org.jboss.as.controller.ExpressionResolver; //导入依赖的package包/类
@Test
public void testUndefinedTypeEmptyConverter() throws OperationFailedException {
    TypeConverter converter = getConverter(new ModelNode());
    Assert.assertEquals(SimpleType.STRING, converter.getOpenType());

    ModelNode node = new ModelNode();
    node.get("abc");
    node.get("def");
    node.protect();

    String json = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(ExpressionResolver.TEST_RESOLVER.resolveExpressions(node), ModelNode.fromJSONString(json));
    Assert.assertEquals(json, assertCast(String.class, converter.fromModelNode(node)));
    assertToArray(converter, json);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:16,代码来源:ExpressionTypeConverterUnitTestCase.java

示例14: TestModelControllerService

import org.jboss.as.controller.ExpressionResolver; //导入依赖的package包/类
protected TestModelControllerService(final ProcessType processType, final ConfigurationPersister configurationPersister, final ControlledProcessState processState,
                                     final ResourceDefinition rootResourceDefinition, final ManagedAuditLogger auditLogger, final DelegatingConfigurableAuthorizer authorizer) {
    super(processType, new RunningModeControl(RunningMode.NORMAL), configurationPersister, processState, rootResourceDefinition,
            null, ExpressionResolver.TEST_RESOLVER, auditLogger, authorizer == null ? new DelegatingConfigurableAuthorizer() : authorizer,
                    new ManagementSecurityIdentitySupplier(), new CapabilityRegistry(true));
    this.processState = processState;
    this.processType = processType;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:9,代码来源:TestModelControllerService.java

示例15: findValidFileNames

import org.jboss.as.controller.ExpressionResolver; //导入依赖的package包/类
private static Collection<String> findValidFileNames(final ModelNode model) {
    final Collection<String> names = new ArrayList<>();
    final Set<String> unresolvableExpressions = new LinkedHashSet<>();
    // Get all the file names from the model
    for (Property resource : model.asPropertyList()) {
        final String name = resource.getName();
        if (FILE_RESOURCE_NAMES.contains(name)) {
            for (Property handlerResource : resource.getValue().asPropertyList()) {
                final ModelNode handlerModel = handlerResource.getValue();
                // This should always exist, but better to be safe
                if (handlerModel.hasDefined(CommonAttributes.FILE.getName())) {
                    final ModelNode fileModel = handlerModel.get(CommonAttributes.FILE.getName());
                    // Only allow from the jboss.server.log.dir
                    if (fileModel.hasDefined(PathResourceDefinition.RELATIVE_TO.getName())
                            && ServerEnvironment.SERVER_LOG_DIR.equals(fileModel.get(PathResourceDefinition.RELATIVE_TO.getName()).asString())
                            && fileModel.hasDefined(PathResourceDefinition.PATH.getName())) {
                        final ModelNode path;
                        try {
                            // Possible expressions need to be resolved for the path name. If not resolved the expression
                            // may contain invalid path characters.
                            path = ExpressionResolver.SIMPLE.resolveExpressions(fileModel.get(PathResourceDefinition.PATH.getName()));
                        } catch (OperationFailedException e) {
                            // The expression could not be resolved for some reason. Collect all the unresolvable paths
                            // and we'll log them once at the end
                            unresolvableExpressions.add(fileModel.get(PathResourceDefinition.PATH.getName()).asString());
                            continue;
                        }
                        names.add(path.asString());
                    }
                }
            }
        }
    }
    if (!unresolvableExpressions.isEmpty()) {
        LoggingLogger.ROOT_LOGGER.unresolvablePathExpressions(unresolvableExpressions);
    }
    return names;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:39,代码来源:LoggingResource.java


注:本文中的org.jboss.as.controller.ExpressionResolver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。