Search in sources :

Example 1 with ExtensionRegistry

use of org.jboss.as.controller.extension.ExtensionRegistry in project wildfly by wildfly.

the class JSSEParsingUnitTestCase method initializeParser.

@Before
public void initializeParser() throws Exception {
    //Initialize the parser
    xmlMapper = XMLMapper.Factory.create();
    extensionParsingRegistry = new ExtensionRegistry(ProcessType.EMBEDDED_SERVER, new RunningModeControl(RunningMode.NORMAL), null, null, null, null);
    testParser = new TestParser(mainSubsystemName, extensionParsingRegistry);
    xmlMapper.registerRootElement(new QName(TEST_NAMESPACE, "test"), testParser);
    mainExtension.initializeParsers(extensionParsingRegistry.getExtensionParsingContext("Test", xmlMapper));
}
Also used : ModelTestParser(org.jboss.as.model.test.ModelTestParser) TestParser(org.jboss.as.subsystem.test.TestParser) QName(javax.xml.namespace.QName) RunningModeControl(org.jboss.as.controller.RunningModeControl) ExtensionRegistry(org.jboss.as.controller.extension.ExtensionRegistry) Before(org.junit.Before)

Example 2 with ExtensionRegistry

use of org.jboss.as.controller.extension.ExtensionRegistry in project wildfly by wildfly.

the class Main method main.

/**
     * The main method.
     *
     * @param args the command-line arguments
     */
public static void main(String[] args) {
    if (java.util.logging.LogManager.getLogManager().getClass().getName().equals("org.jboss.logmanager.LogManager")) {
        // Make sure our original stdio is properly captured.
        try {
            Class.forName(org.jboss.logmanager.handlers.ConsoleHandler.class.getName(), true, org.jboss.logmanager.handlers.ConsoleHandler.class.getClassLoader());
        } catch (Throwable ignored) {
        }
        // Install JBoss Stdio to avoid any nasty crosstalk, after command line arguments are processed.
        StdioContext.install();
        final StdioContext context = StdioContext.create(new NullInputStream(), new LoggingOutputStream(org.jboss.logmanager.Logger.getLogger("stdout"), org.jboss.logmanager.Level.INFO), new LoggingOutputStream(org.jboss.logmanager.Logger.getLogger("stderr"), org.jboss.logmanager.Level.ERROR));
        StdioContext.setStdioContextSelector(new SimpleStdioContextSelector(context));
    }
    try {
        Module.registerURLStreamHandlerFactoryModule(Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("org.jboss.vfs")));
        final ParsedOptions options = determineEnvironment(args, new Properties(WildFlySecurityManager.getSystemPropertiesPrivileged()), WildFlySecurityManager.getSystemEnvironmentPrivileged(), ServerEnvironment.LaunchType.APPCLIENT);
        if (options == null) {
            //this happens if --version was specified
            return;
        }
        ServerEnvironment serverEnvironment = options.environment;
        final List<String> clientArgs = options.clientArguments;
        if (clientArgs.isEmpty()) {
            STDERR.println(AppClientLogger.ROOT_LOGGER.appClientNotSpecified());
            usage();
            abort(null);
        } else {
            final QName rootElement = new QName(Namespace.CURRENT.getUriString(), "server");
            final String file = clientArgs.get(0);
            final List<String> params = clientArgs.subList(1, clientArgs.size());
            final String deploymentName;
            final String earPath;
            int pos = file.lastIndexOf("#");
            if (pos == -1) {
                earPath = file;
                deploymentName = null;
            } else {
                deploymentName = file.substring(pos + 1);
                earPath = file.substring(0, pos);
            }
            File realFile = new File(earPath);
            if (!realFile.exists()) {
                throw AppClientLogger.ROOT_LOGGER.cannotFindAppClientFile(realFile.getAbsoluteFile());
            }
            final Bootstrap bootstrap = Bootstrap.Factory.newInstance();
            final Bootstrap.Configuration configuration = new Bootstrap.Configuration(serverEnvironment);
            configuration.setModuleLoader(Module.getBootModuleLoader());
            final ExtensionRegistry extensionRegistry = configuration.getExtensionRegistry();
            final AppClientXml parser = new AppClientXml(Module.getBootModuleLoader(), extensionRegistry);
            final Bootstrap.ConfigurationPersisterFactory configurationPersisterFactory = new Bootstrap.ConfigurationPersisterFactory() {

                @Override
                public ExtensibleConfigurationPersister createConfigurationPersister(ServerEnvironment serverEnvironment, ExecutorService executorService) {
                    ApplicationClientConfigurationPersister persister = new ApplicationClientConfigurationPersister(earPath, deploymentName, options.hostUrl, options.propertiesFile, params, serverEnvironment.getServerConfigurationFile().getBootFile(), rootElement, parser);
                    for (Namespace namespace : Namespace.domainValues()) {
                        if (!namespace.equals(Namespace.CURRENT)) {
                            persister.registerAdditionalRootElement(new QName(namespace.getUriString(), "server"), parser);
                        }
                    }
                    extensionRegistry.setWriterRegistry(persister);
                    return persister;
                }
            };
            configuration.setConfigurationPersisterFactory(configurationPersisterFactory);
            bootstrap.bootstrap(configuration, Collections.<ServiceActivator>emptyList()).get();
        }
    } catch (Throwable t) {
        abort(t);
    }
}
Also used : StdioContext(org.jboss.stdio.StdioContext) Properties(java.util.Properties) ExtensionRegistry(org.jboss.as.controller.extension.ExtensionRegistry) ServerEnvironment(org.jboss.as.server.ServerEnvironment) Bootstrap(org.jboss.as.server.Bootstrap) NullInputStream(org.jboss.stdio.NullInputStream) QName(javax.xml.namespace.QName) LoggingOutputStream(org.jboss.stdio.LoggingOutputStream) ServiceActivator(org.jboss.msc.service.ServiceActivator) Namespace(org.jboss.as.controller.parsing.Namespace) SimpleStdioContextSelector(org.jboss.stdio.SimpleStdioContextSelector) AppClientXml(org.jboss.as.appclient.subsystem.parsing.AppClientXml) ExecutorService(java.util.concurrent.ExecutorService) File(java.io.File)

Example 3 with ExtensionRegistry

use of org.jboss.as.controller.extension.ExtensionRegistry in project wildfly by wildfly.

the class EeLegacySubsystemTestCase method createAdditionalInitialization.

@Override
protected AdditionalInitialization createAdditionalInitialization() {
    return new AdditionalInitialization() {

        @Override
        protected RunningMode getRunningMode() {
            return RunningMode.ADMIN_ONLY;
        }

        @Override
        protected void initializeExtraSubystemsAndModel(ExtensionRegistry extensionRegistry, Resource rootResource, ManagementResourceRegistration rootRegistration, RuntimeCapabilityRegistry capabilityRegistry) {
            if (!extensionAdded) {
                //extensionAdded = true;
                //bean validation depends on EE, so we can't use the real subsystem here
                final OperationDefinition removeExtension = new SimpleOperationDefinitionBuilder("remove", NonResolvingResourceDescriptionResolver.INSTANCE).build();
                final OperationDefinition addExtension = new SimpleOperationDefinitionBuilder("add", NonResolvingResourceDescriptionResolver.INSTANCE).addParameter(new SimpleAttributeDefinition("module", ModelType.STRING, false)).build();
                PathElement bvExtension = PathElement.pathElement(EXTENSION, "org.wildfly.extension.bean-validation");
                ManagementResourceRegistration extensionRegistration = rootRegistration.registerSubModel(new SimpleResourceDefinition(bvExtension, NonResolvingResourceDescriptionResolver.INSTANCE));
                extensionRegistration.registerReadOnlyAttribute(new SimpleAttributeDefinition("module", ModelType.STRING, false), new ReloadRequiredWriteAttributeHandler());
                extensionRegistration.registerOperationHandler(removeExtension, new ReloadRequiredRemoveStepHandler());
                extensionRegistration.registerOperationHandler(addExtension, new ReloadRequiredAddStepHandler(new SimpleAttributeDefinition("module", ModelType.STRING, false)));
                final OperationDefinition removeSubsystem = new SimpleOperationDefinitionBuilder("remove", NonResolvingResourceDescriptionResolver.INSTANCE).build();
                final OperationDefinition addSubsystem = new SimpleOperationDefinitionBuilder("add", NonResolvingResourceDescriptionResolver.INSTANCE).build();
                PathElement bvSubsystem = PathElement.pathElement(SUBSYSTEM, "bean-validation");
                ManagementResourceRegistration subsystemRegistration = rootRegistration.registerSubModel(new SimpleResourceDefinition(bvSubsystem, NonResolvingResourceDescriptionResolver.INSTANCE));
                subsystemRegistration.registerOperationHandler(removeSubsystem, new ReloadRequiredRemoveStepHandler());
                subsystemRegistration.registerOperationHandler(addSubsystem, new ReloadRequiredAddStepHandler());
            }
        }
    };
}
Also used : RuntimeCapabilityRegistry(org.jboss.as.controller.capability.registry.RuntimeCapabilityRegistry) SimpleOperationDefinitionBuilder(org.jboss.as.controller.SimpleOperationDefinitionBuilder) Resource(org.jboss.as.controller.registry.Resource) SimpleResourceDefinition(org.jboss.as.controller.SimpleResourceDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) AdditionalInitialization(org.jboss.as.subsystem.test.AdditionalInitialization) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler) ReloadRequiredAddStepHandler(org.jboss.as.controller.ReloadRequiredAddStepHandler) ExtensionRegistry(org.jboss.as.controller.extension.ExtensionRegistry) PathElement(org.jboss.as.controller.PathElement) ReloadRequiredRemoveStepHandler(org.jboss.as.controller.ReloadRequiredRemoveStepHandler) OperationDefinition(org.jboss.as.controller.OperationDefinition)

Aggregations

ExtensionRegistry (org.jboss.as.controller.extension.ExtensionRegistry)3 QName (javax.xml.namespace.QName)2 File (java.io.File)1 Properties (java.util.Properties)1 ExecutorService (java.util.concurrent.ExecutorService)1 AppClientXml (org.jboss.as.appclient.subsystem.parsing.AppClientXml)1 OperationDefinition (org.jboss.as.controller.OperationDefinition)1 PathElement (org.jboss.as.controller.PathElement)1 ReloadRequiredAddStepHandler (org.jboss.as.controller.ReloadRequiredAddStepHandler)1 ReloadRequiredRemoveStepHandler (org.jboss.as.controller.ReloadRequiredRemoveStepHandler)1 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)1 RunningModeControl (org.jboss.as.controller.RunningModeControl)1 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)1 SimpleOperationDefinitionBuilder (org.jboss.as.controller.SimpleOperationDefinitionBuilder)1 SimpleResourceDefinition (org.jboss.as.controller.SimpleResourceDefinition)1 RuntimeCapabilityRegistry (org.jboss.as.controller.capability.registry.RuntimeCapabilityRegistry)1 Namespace (org.jboss.as.controller.parsing.Namespace)1 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)1 Resource (org.jboss.as.controller.registry.Resource)1 ModelTestParser (org.jboss.as.model.test.ModelTestParser)1