Java Code Examples for org.jboss.as.controller.ProcessType#STANDALONE_SERVER

The following examples show how to use org.jboss.as.controller.ProcessType#STANDALONE_SERVER . 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: AbstractLegacyExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void initialize(ExtensionContext context) {

    if (context.getProcessType() == ProcessType.DOMAIN_SERVER) {
        // Do nothing. This allows an extension=cmp:add op that's really targeted
        // to legacy servers to work
        ControllerLogger.MGMT_OP_LOGGER.ignoringUnsupportedLegacyExtension(subsystemNames, extensionName);
        return;
    } else if (context.getProcessType() == ProcessType.STANDALONE_SERVER) {
        if (context.getRunningMode() == RunningMode.ADMIN_ONLY) {
            //log a message, but fall through and register the model
            ControllerLogger.MGMT_OP_LOGGER.removeUnsupportedLegacyExtension(subsystemNames, extensionName);
        } else {
            throw new UnsupportedOperationException(ControllerLogger.ROOT_LOGGER.unsupportedLegacyExtension(extensionName));
        }
    }

    Set<ManagementResourceRegistration> subsystemRoots = initializeLegacyModel(context);
    for (ManagementResourceRegistration subsystemRoot : subsystemRoots) {
        subsystemRoot.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION,
            new UnsupportedSubsystemDescribeHandler(extensionName));
    }
}
 
Example 2
Source File: InterfaceManagementUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
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());
}
 
Example 3
Source File: MutabilityChecker.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static MutabilityChecker create(ProcessType processType, boolean isMasterHc) {
    if (processType == ProcessType.STANDALONE_SERVER) {
        return new StandaloneServerChecker();
    } else if (processType.isHostController()) {
        return new HostControllerChecker(isMasterHc);
    }
    return new NonMutableChecker();
}
 
Example 4
Source File: AbstractLegacyExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void initializeParsers(ExtensionParsingContext context) {

    if (context.getProcessType() == ProcessType.DOMAIN_SERVER) {
        // Do nothing. This allows the extension=cmp:add op that's really targeted
        // to legacy servers to work
        return;
    } else if (context.getProcessType() == ProcessType.STANDALONE_SERVER && context.getRunningMode() != RunningMode.ADMIN_ONLY) {
        throw new UnsupportedOperationException(ControllerLogger.ROOT_LOGGER.unsupportedLegacyExtension(extensionName));
    }

    initializeLegacyParsers(context);
}
 
Example 5
Source File: SystemPropertiesParsingTest.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testSystemPropertyAlreadyExistIsCalled() throws Exception {
    // assign two properties in the system
    System.setProperty("org.jboss.as.server.parsing.test", "test-value");
    System.setProperty("org.jboss.as.server.parsing.secret", "super-secret-value");
    System.setProperty("org.jboss.as.server.parsing.secret-nested", "super-secret-value");
    try {
        final String xml = "<?xml version='1.0' encoding='UTF-8'?>"
                + "<server name=\"example\" xmlns=\"urn:jboss:domain:8.0\">"
                + "    <system-properties>\n"
                + "        <property name=\"org.jboss.as.server.parsing.secret\" value=\"${VAULT::vb::password::1}\"/>\n"
                + "        <property name=\"org.jboss.as.server.parsing.secret-nested\" value=\"${VAULT::vb::${not-found:password}::1}\"/>\n"
                + "        <property name=\"org.jboss.as.server.parsing.test\" value=\"other-value\"/>\n"
                + "    </system-properties>\n"
                + "</server>";
        final XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml));
        final ExtensionRegistry extensionRegistry = new ExtensionRegistry(ProcessType.STANDALONE_SERVER,
                new RunningModeControl(RunningMode.NORMAL), null, null, null, RuntimeHostControllerInfoAccessor.SERVER);
        final StandaloneXml parser = new StandaloneXml(null, null, extensionRegistry);
        final List<ModelNode> operationList = new ArrayList<>();
        final XMLMapper mapper = XMLMapper.Factory.create();
        mapper.registerRootElement(new QName(namespace, "server"), parser);
        mapper.parseDocument(operationList, reader);
        // assert the method is called only once for test
        Mockito.verify(mockedLogger, Mockito.times(1)).systemPropertyAlreadyExist(Mockito.anyString());
        Mockito.verify(mockedLogger, Mockito.times(1)).systemPropertyAlreadyExist(Mockito.eq("org.jboss.as.server.parsing.test"));
    } finally {
        System.clearProperty("org.jboss.as.server.parsing.test");
        System.clearProperty("org.jboss.as.server.parsing.secret");
        System.clearProperty("org.jboss.as.server.parsing.secret-nested");
    }
}
 
Example 6
Source File: CoreModelTestDelegate.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public KernelServicesBuilderImpl(TestModelType type) {
    this.type = type;
    this.processType = type == TestModelType.HOST || type == TestModelType.DOMAIN ? ProcessType.HOST_CONTROLLER : ProcessType.STANDALONE_SERVER;
    runningModeControl = type == TestModelType.HOST ? new HostRunningModeControl(RunningMode.ADMIN_ONLY, RestartMode.HC_ONLY) : new RunningModeControl(RunningMode.ADMIN_ONLY);
    extensionRegistry = new ExtensionRegistry(processType, runningModeControl, null, null, null, RuntimeHostControllerInfoAccessor.SERVER);
    testParser = TestParser.create(extensionRegistry, xmlMapper, type);
}
 
Example 7
Source File: StandaloneXMLParserProducer.java    From thorntail with Apache License 2.0 4 votes vote down vote up
@Override
public ProcessType getProcessType() {
    return ProcessType.STANDALONE_SERVER;
}
 
Example 8
Source File: AbstractParserFactory.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 4 votes vote down vote up
@Override
public ProcessType getProcessType() {
    return ProcessType.STANDALONE_SERVER;
}
 
Example 9
Source File: JmxFacadeRbacEnabledTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public JmxFacadeRbacEnabledTestCase(){
    super(ProcessType.STANDALONE_SERVER);
}
 
Example 10
Source File: JmxFacadeRbacEnabledTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void initModel(ManagementModel managementModel) {
    this.rootResource = managementModel.getRootResource();
    this.rootRegistration = managementModel.getRootResourceRegistration();
    PathManagerService pathManagerService = new PathManagerService() {
    };
    GlobalOperationHandlers.registerGlobalOperations(rootRegistration, processType);
    rootRegistration.registerOperationHandler(CompositeOperationHandler.DEFINITION, CompositeOperationHandler.INSTANCE);

    GlobalNotifications.registerGlobalNotifications(rootRegistration, processType);

    StabilityMonitor monitor = new StabilityMonitor();
    getContainer().addService(AbstractControllerService.PATH_MANAGER_CAPABILITY.getCapabilityServiceName(), pathManagerService)
            .addMonitor(monitor)
            .install();

    try {
        monitor.awaitStability(10, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new RuntimeException(e);
    }

    rootRegistration.registerSubModel(PathResourceDefinition.createSpecified(pathManagerService));
    rootRegistration.registerSubModel(CoreManagementResourceDefinition.forStandaloneServer(getAuthorizer(), getSecurityIdentitySupplier(),
            getAuditLogger(), pathManagerService, new EnvironmentNameReader() {
        public boolean isServer() {
            return true;
        }

        public String getServerName() {
            return "Test";
        }

        public String getHostName() {
            return null;
        }

        public String getProductName() {
            return null;
        }
    }, null, new ResourceDefinition[0]));


    pathManagerService.addPathManagerResources(rootResource);


    ExtensionRegistry extensionRegistry = new ExtensionRegistry(ProcessType.STANDALONE_SERVER, new RunningModeControl(RunningMode.NORMAL), AuditLogger.NO_OP_LOGGER,
            getAuthorizer(), getSecurityIdentitySupplier(), RuntimeHostControllerInfoAccessor.SERVER);
    extensionRegistry.setPathManager(pathManagerService);
    extensionRegistry.setWriterRegistry(new NullConfigurationPersister());
    JMXExtension extension = new JMXExtension();
    extension.initialize(extensionRegistry.getExtensionContext("org.jboss.as.jmx", rootRegistration, ExtensionRegistryType.SLAVE));

    Resource coreManagementResource = Resource.Factory.create();
    rootResource.registerChild(CoreManagementResourceDefinition.PATH_ELEMENT, coreManagementResource);

    Resource accessAuthorizationResource = Resource.Factory.create();
    accessAuthorizationResource.getModel().get(AccessAuthorizationResourceDefinition.PROVIDER.getName()).set(AccessAuthorizationResourceDefinition.Provider.SIMPLE.toString());
    coreManagementResource.registerChild(AccessAuthorizationResourceDefinition.PATH_ELEMENT, accessAuthorizationResource);
}
 
Example 11
Source File: JmxRbacTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void initModel(ManagementModel managementModel) {
    ManagementResourceRegistration registration = managementModel.getRootResourceRegistration();
    PathManagerService pathManagerService = new PathManagerService() {
    };
    GlobalOperationHandlers.registerGlobalOperations(registration, processType);
    registration.registerOperationHandler(CompositeOperationHandler.DEFINITION, CompositeOperationHandler.INSTANCE);

    GlobalNotifications.registerGlobalNotifications(registration, processType);

    registration.registerReadOnlyAttribute(LAUNCH_TYPE, new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            context.getResult().set(TYPE_STANDALONE);
        }
    });

    StabilityMonitor monitor = new StabilityMonitor();
    getContainer().addService(AbstractControllerService.PATH_MANAGER_CAPABILITY.getCapabilityServiceName(), pathManagerService)
            .addMonitor(monitor)
            .install();

    try {
        monitor.awaitStability(10, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new RuntimeException(e);
    }

    registration.registerSubModel(PathResourceDefinition.createSpecified(pathManagerService));
    registration.registerSubModel(CoreManagementResourceDefinition.forStandaloneServer(getAuthorizer(), getSecurityIdentitySupplier(),
            getAuditLogger(), pathManagerService, new EnvironmentNameReader() {
        public boolean isServer() {
            return true;
        }

        public String getServerName() {
            return "Test";
        }

        public String getHostName() {
            return null;
        }

        public String getProductName() {
            return null;
        }
    }, null, new ResourceDefinition[0]));

    Resource rootResource = managementModel.getRootResource();
    pathManagerService.addPathManagerResources(rootResource);


    ExtensionRegistry extensionRegistry = new ExtensionRegistry(ProcessType.STANDALONE_SERVER, new RunningModeControl(RunningMode.NORMAL),
            AuditLogger.NO_OP_LOGGER, getAuthorizer(), getSecurityIdentitySupplier(), RuntimeHostControllerInfoAccessor.SERVER);
    extensionRegistry.setPathManager(pathManagerService);
    extensionRegistry.setWriterRegistry(new NullConfigurationPersister());
    JMXExtension extension = new JMXExtension();
    extension.initialize(extensionRegistry.getExtensionContext("org.jboss.as.jmx", registration, ExtensionRegistryType.SLAVE));

    Resource coreManagementResource = Resource.Factory.create();
    rootResource.registerChild(CoreManagementResourceDefinition.PATH_ELEMENT, coreManagementResource);

    Resource accessAuthorizationResource = Resource.Factory.create();
    accessAuthorizationResource.getModel().get(AccessAuthorizationResourceDefinition.PROVIDER.getName()).set(AccessAuthorizationResourceDefinition.Provider.SIMPLE.toString());
    coreManagementResource.registerChild(AccessAuthorizationResourceDefinition.PATH_ELEMENT, accessAuthorizationResource);
}
 
Example 12
Source File: BootCliHookTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public BootCliHookTestCase() {
    super(ProcessType.STANDALONE_SERVER);
}
 
Example 13
Source File: SubsystemTestDelegate.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public ProcessType getProcessType() {
    return ProcessType.STANDALONE_SERVER;
}
 
Example 14
Source File: AdditionalInitialization.java    From wildfly-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * The process type to be used for the installed controller
 *
 * @return the process type
 */
protected ProcessType getProcessType() {
    return ProcessType.STANDALONE_SERVER;
}