org.jboss.as.server.parsing.StandaloneXml Java Examples

The following examples show how to use org.jboss.as.server.parsing.StandaloneXml. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BootstrapPersister.java    From thorntail with Apache License 2.0 6 votes vote down vote up
private XmlConfigurationPersister createDelegate(File configFile) {

        QName rootElement = new QName(Namespace.CURRENT.getUriString(), "server");
        ExtensionRegistry extensionRegistry = new ExtensionRegistry(
                ProcessType.SELF_CONTAINED,
                new RunningModeControl(RunningMode.NORMAL),
                null,
                null,
                null,
                RuntimeHostControllerInfoAccessor.SERVER
        );
        StandaloneXml parser = new StandaloneXml(Module.getBootModuleLoader(), Executors.newSingleThreadExecutor(), extensionRegistry);

        XmlConfigurationPersister persister = new XmlConfigurationPersister(
                configFile, rootElement, parser, parser, false
        );

        return persister;

    }
 
Example #2
Source File: StandaloneXmlParser.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
public StandaloneXmlParser() {

        parserDelegate = new StandaloneXml(new ExtensionHandler() {
            @Override
            public void parseExtensions(XMLExtendedStreamReader reader, ModelNode address, Namespace namespace, List<ModelNode> list) throws XMLStreamException {
                reader.discardRemainder(); // noop
            }

            @Override
            public Set<ProfileParsingCompletionHandler> getProfileParsingCompletionHandlers() {
                return Collections.EMPTY_SET;
            }

            @Override
            public void writeExtensions(XMLExtendedStreamWriter writer, ModelNode modelNode) throws XMLStreamException {
                // noop
            }
        }, ParsingOption.IGNORE_SUBSYSTEM_FAILURES);

        xmlMapper = XMLMapper.Factory.create();
        xmlMapper.registerRootElement(new QName("urn:jboss:domain:4.0", "server"), parserDelegate);

    }
 
Example #3
Source File: StandaloneXMLParser.java    From thorntail with Apache License 2.0 5 votes vote down vote up
public StandaloneXMLParser() {
    ExtensionRegistry extensionRegistry = new ExtensionRegistry(
            ProcessType.SELF_CONTAINED,
            new RunningModeControl(RunningMode.NORMAL),
            null,
            null,
            null,
            RuntimeHostControllerInfoAccessor.SERVER
    );
    DeferredExtensionContext deferredExtensionContext =
        new DeferredExtensionContext(new BootModuleLoader(), extensionRegistry, Executors.newSingleThreadExecutor());
    parserDelegate = new StandaloneXml(
        new ExtensionHandler() {
            @Override
            public void parseExtensions(XMLExtendedStreamReader reader, ModelNode address, Namespace namespace, List<ModelNode> list) throws XMLStreamException {
                reader.discardRemainder(); // noop
            }

            @Override
            public Set<ProfileParsingCompletionHandler> getProfileParsingCompletionHandlers() {
                return Collections.emptySet();
            }

            @Override
            public void writeExtensions(XMLExtendedStreamWriter writer, ModelNode modelNode) throws XMLStreamException {
                // noop
            }
        },
        deferredExtensionContext,
        ParsingOption.IGNORE_SUBSYSTEM_FAILURES);

    xmlMapper = XMLMapper.Factory.create();

    addDelegate(new QName(Namespace.CURRENT.getUriString(), SERVER), parserDelegate);
    addDelegate(new QName("urn:jboss:domain:4.1", SERVER), parserDelegate);
    addDelegate(new QName("urn:jboss:domain:4.0", SERVER), parserDelegate);
    addDelegate(new QName("urn:jboss:domain:2.0", SERVER), parserDelegate);
}
 
Example #4
Source File: Bootstrap.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Get the factory for the configuration persister to use.
 *
 * @return the configuration persister factory
 */
public synchronized ConfigurationPersisterFactory getConfigurationPersisterFactory() {
    if (configurationPersisterFactory == null) {
        configurationPersisterFactory = new ConfigurationPersisterFactory() {
            @Override
            public ExtensibleConfigurationPersister createConfigurationPersister(ServerEnvironment serverEnvironment, ExecutorService executorService) {
                ConfigurationFile configurationFile = serverEnvironment.getServerConfigurationFile();
                if (runningModeControl.isReloaded()) {
                    configurationFile.resetBootFile(runningModeControl.isUseCurrentConfig(), runningModeControl.getAndClearNewBootFileName());
                }
                QName rootElement = new QName(Namespace.CURRENT.getUriString(), "server");
                StandaloneXml parser = new StandaloneXml(Module.getBootModuleLoader(), executorService, extensionRegistry);
                XmlConfigurationPersister persister;
                if (configurationFile.useGit()) {
                    persister = new GitConfigurationPersister(serverEnvironment.getGitRepository(), configurationFile, rootElement, parser, parser,
                            runningModeControl.isReloaded());
                } else {
                    persister = new BackupXmlConfigurationPersister(configurationFile, rootElement, parser, parser,
                            runningModeControl.isReloaded(), serverEnvironment.getLaunchType() == ServerEnvironment.LaunchType.EMBEDDED);
                }
                for (Namespace namespace : Namespace.domainValues()) {
                    if (!namespace.equals(Namespace.CURRENT)) {
                        persister.registerAdditionalRootElement(new QName(namespace.getUriString(), "server"), parser);
                    }
                }
                extensionRegistry.setWriterRegistry(persister);
                return persister;
            }
        };
    }
    return configurationPersisterFactory;
}
 
Example #5
Source File: TestParser.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static TestParser create(ExtensionRegistry registry, XMLMapper xmlMapper, TestModelType type) {
    TestParser testParser;
    String root;
    if (type == TestModelType.STANDALONE) {
        StandaloneXml standaloneXml = new StandaloneXml(null, Executors.newCachedThreadPool(), registry);
        testParser = new TestParser(type, standaloneXml, standaloneXml);
        root = "server";
    } else if (type == TestModelType.DOMAIN) {
        DomainXml domainXml = new DomainXml(null, Executors.newCachedThreadPool(), registry);
        testParser = new TestParser(type, domainXml, domainXml);
        root = "domain";
    } else if (type == TestModelType.HOST) {
        HostXml hostXml = new HostXml("master", RunningMode.NORMAL, false, null, Executors.newCachedThreadPool(), registry);
        testParser = new TestParser(type, hostXml, hostXml);
        root = "host";
    } else {
        throw new IllegalArgumentException("Unknown type " + type);
    }


    try {
        for (Namespace ns : Namespace.ALL_NAMESPACES) {
            xmlMapper.registerRootElement(new QName(ns.getUriString(), root), testParser);
        }
    } catch (NoSuchFieldError e) {
        //7.1.2 does not have the ALL_NAMESPACES field
        xmlMapper.registerRootElement(new QName(Namespace.DOMAIN_1_0.getUriString(), root), testParser);
        xmlMapper.registerRootElement(new QName(Namespace.DOMAIN_1_1.getUriString(), root), testParser);
        xmlMapper.registerRootElement(new QName(Namespace.DOMAIN_1_2.getUriString(), root), testParser);
    }
    return testParser;
}
 
Example #6
Source File: ServerStartTask.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AsyncFuture<ServiceContainer> run(final List<ServiceActivator> runServices) {
    final Bootstrap bootstrap = Bootstrap.Factory.newInstance();
    final ProductConfig productConfig = ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), home, properties);
    // Create server environment on the server, so that the system properties are getting initialized on the right side
    final ServerEnvironment providedEnvironment = new ServerEnvironment(hostControllerName, properties,
            WildFlySecurityManager.getSystemEnvironmentPrivileged(), null, null, ServerEnvironment.LaunchType.DOMAIN,
            RunningMode.NORMAL, productConfig, Module.getStartTime(), suspend, null, null, null);
    DomainServerCommunicationServices.updateOperationID(initialOperationID);

    // TODO perhaps have ConfigurationPersisterFactory as a Service
    final List<ServiceActivator> services = new ArrayList<ServiceActivator>(startServices);
    final ServerBootOperationsService service = new ServerBootOperationsService();
    // ModelController.boot() will block on this future in order to get the boot updates.
    final Future<ModelNode> bootOperations = service.getFutureResult();
    final ServiceActivator activator = new ServiceActivator() {
        @Override
        public void activate(ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException {
            final ServiceTarget target = serviceActivatorContext.getServiceTarget();
            final ServiceBuilder sb = target.addService(ServiceName.JBOSS.append("server-boot-operations"), service);
            sb.requires(Services.JBOSS_AS);
            sb.addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.getServerController());
            sb.addDependency(HostControllerConnectionService.SERVICE_NAME, HostControllerClient.class, service.getClientInjector());
            sb.addDependency(Services.JBOSS_SERVER_EXECUTOR, Executor.class, service.getExecutorInjector());
            sb.install();
        }
    };
    services.add(activator);

    final Bootstrap.Configuration configuration = new Bootstrap.Configuration(providedEnvironment);
    final ExtensionRegistry extensionRegistry = configuration.getExtensionRegistry();
    final Bootstrap.ConfigurationPersisterFactory configurationPersisterFactory = new Bootstrap.ConfigurationPersisterFactory() {
        @Override
        public ExtensibleConfigurationPersister createConfigurationPersister(ServerEnvironment serverEnvironment, ExecutorService executorService) {
            ExtensibleConfigurationPersister persister = new AbstractConfigurationPersister(new StandaloneXml(configuration.getModuleLoader(), executorService, extensionRegistry)) {

                private final PersistenceResource pr = new PersistenceResource() {

                    @Override
                    public void commit() {
                    }

                    @Override
                    public void rollback() {
                    }
                };

                @Override
                public PersistenceResource store(final ModelNode model, Set<PathAddress> affectedAddresses) throws ConfigurationPersistenceException {
                    return pr;
                }

                @Override
                public List<ModelNode> load() throws ConfigurationPersistenceException {
                    try {
                        final ModelNode operations = bootOperations.get();
                        return operations.asList();
                    } catch (Exception e) {
                        throw new ConfigurationPersistenceException(e);
                    }
                }
            };
            extensionRegistry.setWriterRegistry(persister);
            return persister;
        }
    };
    configuration.setConfigurationPersisterFactory(configurationPersisterFactory);
    return bootstrap.bootstrap(configuration, services);
}