org.jboss.as.controller.ProcessType Java Examples

The following examples show how to use org.jboss.as.controller.ProcessType. 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: DetailedOperationsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected void initModel(ManagementModel managementModel) {
    ManagementResourceRegistration registration = managementModel.getRootResourceRegistration();
    GlobalOperationHandlers.registerGlobalOperations(registration, ProcessType.EMBEDDED_SERVER);

    GlobalNotifications.registerGlobalNotifications(registration, ProcessType.EMBEDDED_SERVER);

    registration.registerSubModel(new TestResourceDefinition(UNCONSTRAINED_RESOURCE));
    registration.registerSubModel(new TestResourceDefinition(SENSITIVE_CONSTRAINED_RESOURCE,
            MY_SENSITIVE_CONSTRAINT));
    registration.registerSubModel(new TestResourceDefinition(APPLICATION_CONSTRAINED_RESOURCE,
            MY_APPLICATION_CONSTRAINT));

    ManagementResourceRegistration mgmt = registration.registerSubModel(new TestResourceDefinition(CORE_MANAGEMENT));
    mgmt.registerSubModel(new TestResourceDefinition(ACCESS_AUDIT));

}
 
Example #2
Source File: HostControllerConfigurationPersister.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public List<ModelNode> load() throws ConfigurationPersistenceException {
    // TODO investigate replacing all this with something more like BackupXmlConfigurationPersister.isSuppressLoad
    if (environment.getProcessType() == ProcessType.EMBEDDED_HOST_CONTROLLER) {
        final ConfigurationFile configurationFile = environment.getHostConfigurationFile();
        final File bootFile = configurationFile.getBootFile();
        final ConfigurationFile.InteractionPolicy policy = configurationFile.getInteractionPolicy();
        final HostRunningModeControl runningModeControl = environment.getRunningModeControl();

        if (bootFile.exists() && bootFile.length() == 0) { // empty config, by definition
            return new ArrayList<>();
        }

        if (policy == ConfigurationFile.InteractionPolicy.NEW && (bootFile.exists() && bootFile.length() != 0)) {
            throw HostControllerLogger.ROOT_LOGGER.cannotOverwriteHostXmlWithEmpty(bootFile.getName());
        }

        // if we started with new / discard but now we're reloading, ignore it. Otherwise on a reload, we have no way to drop the --empty-host-config
        // if we're loading a 0 byte file, treat this the same as booting with an emoty config
        if (bootFile.length() == 0 || (!runningModeControl.isReloaded() && (policy == ConfigurationFile.InteractionPolicy.NEW || policy == ConfigurationFile.InteractionPolicy.DISCARD))) {
            return new ArrayList<>();
        }
    }
    return hostPersister.load();
}
 
Example #3
Source File: ExtensionRegistry.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private SubsystemRegistrationImpl(String name, ModelVersion version,
                                  ManagementResourceRegistration profileRegistration,
                                  ManagementResourceRegistration deploymentsRegistration,
                                  ExtensionRegistryType extensionRegistryType,
                                  String extensionModuleName,
                                  ProcessType processType) {
    assert profileRegistration != null;
    this.name = name;
    this.profileRegistration = profileRegistration;
    if (deploymentsRegistration == null){
        this.deploymentsRegistration = ManagementResourceRegistration.Factory.forProcessType(processType).createRegistration(new SimpleResourceDefinition(null, NonResolvingResourceDescriptionResolver.INSTANCE));
    }else {
        this.deploymentsRegistration = deploymentsRegistration;
    }
    this.version = version;
    this.extensionRegistryType = extensionRegistryType;
    this.extensionModuleName = extensionModuleName;
}
 
Example #4
Source File: ModelTestModelControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * This is the constructor to use for 18.0.x subsystem tests.
 */
protected ModelTestModelControllerService(final ProcessType processType, final RunningModeControl runningModeControl, final TransformerRegistry transformerRegistry,
                                          final StringConfigurationPersister persister, final ModelTestOperationValidatorFilter validateOpsFilter,
                                          final ResourceDefinition resourceDefinition, final ControlledProcessState processState,
                                          final CapabilityRegistry capabilityRegistry, final Controller18x version) {
    super(processType,
            runningModeControl,
            persister,
            processState == null ? new ControlledProcessState(true) : processState,
            resourceDefinition,
            null,
            ExpressionResolver.TEST_RESOLVER,
            AuditLogger.NO_OP_LOGGER,
            new DelegatingConfigurableAuthorizer(),
            new ManagementSecurityIdentitySupplier(),
            capabilityRegistry
    );

    this.persister = persister;
    this.transformerRegistry = transformerRegistry;
    this.validateOpsFilter = validateOpsFilter;
    this.runningModeControl = runningModeControl;
}
 
Example #5
Source File: ChildRedirectTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Before
public void setUp() {
    // Cleanup
    resourceRoot = Resource.Factory.create();
    registry = TransformerRegistry.Factory.create();
    resourceRegistration = ManagementResourceRegistration.Factory.forProcessType(ProcessType.EMBEDDED_SERVER).createRegistration(ROOT);
    // test
    final Resource toto = Resource.Factory.create();
    resourceRoot.registerChild(PATH, toto);
    //resourceModel = toto.getModel();

    final Resource childOne = Resource.Factory.create();
    toto.registerChild(CHILD_ONE, childOne);
    toto.getModel().setEmptyObject();

    final Resource childTwo = Resource.Factory.create();
    toto.registerChild(CHILD_TWO, childTwo);
    toto.getModel().setEmptyObject();

    // Register the description
    transformersSubRegistration = registry.getServerRegistration(ModelVersion.create(1));
}
 
Example #6
Source File: AbstractGlobalOperationsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected void checkType2Description(ModelNode result) {
    assertNotNull(result);
    assertEquals("description", result.require(DESCRIPTION).asString());
    assertEquals(ModelType.STRING, result.require(ATTRIBUTES).require("name").require(TYPE).asType());
    assertEquals("name", result.require(ATTRIBUTES).require("name").require(DESCRIPTION).asString());
    assertFalse(result.require(ATTRIBUTES).require("name").require(NILLABLE).asBoolean());
    if (result.hasDefined(OPERATIONS)) {
        assertTrue(result.require(OPERATIONS).isDefined());
        Set<String> ops = result.require(OPERATIONS).keys();
        assertEquals(processType == ProcessType.DOMAIN_SERVER ? 13 : 21, ops.size());
        assertGlobalOperations(ops);
    }

    if (result.hasDefined(NOTIFICATIONS)) {
        assertTrue(result.require(NOTIFICATIONS).isDefined());
        Set<String> notifs = result.require(NOTIFICATIONS).keys();
        assertEquals(processType == ProcessType.DOMAIN_SERVER ? 2 : 3, notifs.size());
        assertTrue(notifs.contains(RESOURCE_ADDED_NOTIFICATION));
        assertTrue(notifs.contains(RESOURCE_REMOVED_NOTIFICATION));
        assertEquals(processType != ProcessType.DOMAIN_SERVER, notifs.contains(ATTRIBUTE_VALUE_WRITTEN_NOTIFICATION));
    }
}
 
Example #7
Source File: SensitiveTargetConstraintUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void setupResources() {
    ResourceDefinition rootRd = new SimpleResourceDefinition(null, new NonResolvingResourceDescriptionResolver()) {
        @Override
        public List<AccessConstraintDefinition> getAccessConstraints() {
            return rootResourceConstraints;
        }
    };
    ManagementResourceRegistration rootRegistration = ManagementResourceRegistration.Factory.forProcessType(ProcessType.EMBEDDED_SERVER).createRegistration(rootRd);
    rootRegistration.registerOperationHandler(READ_CONFIG_DEF, NoopOperationStepHandler.WITH_RESULT, true);
    PathElement childPE = PathElement.pathElement("child");
    ResourceDefinition childRd = new SimpleResourceDefinition(childPE, new NonResolvingResourceDescriptionResolver()) {
        @Override
        public List<AccessConstraintDefinition> getAccessConstraints() {
            return childResourceConstraints;
        }
    };
    ManagementResourceRegistration childRegistration = rootRegistration.registerSubModel(childRd);

    rootTarget = TargetResource.forStandalone(PathAddress.EMPTY_ADDRESS, rootRegistration, Resource.Factory.create());
    childTarget = TargetResource.forStandalone(PathAddress.pathAddress(childPE), childRegistration, Resource.Factory.create());
}
 
Example #8
Source File: MBeanServerService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private MBeanServerService(final String resolvedDomainName, final String expressionsDomainName, final boolean legacyWithProperPropertyFormat,
                           final boolean coreMBeanSensitivity,
                           final ManagedAuditLogger auditLoggerInfo, final JmxAuthorizer authorizer, final Supplier<SecurityIdentity> securityIdentitySupplier,
                           final JmxEffect jmxEffect,
                           final ProcessType processType, final boolean isMasterHc) {
    this.resolvedDomainName = resolvedDomainName;
    this.expressionsDomainName = expressionsDomainName;
    this.legacyWithProperPropertyFormat = legacyWithProperPropertyFormat;
    this.coreMBeanSensitivity = coreMBeanSensitivity;
    this.auditLoggerInfo = auditLoggerInfo;
    this.authorizer = authorizer;
    this.securityIdentitySupplier = securityIdentitySupplier;
    this.jmxEffect = jmxEffect;
    this.processType = processType;
    this.isMasterHc = isMasterHc;
}
 
Example #9
Source File: RegistryProxyControllerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Before
public void setup() {
    root = ManagementResourceRegistration.Factory.forProcessType(ProcessType.EMBEDDED_SERVER).createRegistration(rootResource);
    assertNotNull(root);

    profileAReg = registerSubModel(root, profileA);
    assertNotNull(profileAReg);

    profileBReg = registerSubModel(root, profileB);
    assertNotNull(profileBReg);

    root.registerProxyController(proxyA, new TestProxyController(proxyA));
    root.registerProxyController(proxyB, new TestProxyController(proxyB));

    profileBReg.registerProxyController(proxyA, new TestProxyController(profileB, proxyA));
    profileBReg.registerProxyController(proxyB, new TestProxyController(profileB, proxyB));
}
 
Example #10
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 #11
Source File: FilteredReadChildrenResourcesTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected void initModel(ManagementModel managementModel) {
    ManagementResourceRegistration registration = managementModel.getRootResourceRegistration();
    GlobalOperationHandlers.registerGlobalOperations(registration, ProcessType.EMBEDDED_SERVER);

    GlobalNotifications.registerGlobalNotifications(registration, ProcessType.EMBEDDED_SERVER);

    registration.registerSubModel(new SimpleResourceDefinition(
            new Parameters(pathElement(UNCONSTRAINED_RESOURCE), new NonResolvingResourceDescriptionResolver())
                .setAddHandler(new AbstractAddStepHandler() {})
                .setRemoveHandler(new AbstractRemoveStepHandler() {})));
    registration.registerSubModel(new SimpleResourceDefinition(
            new Parameters(pathElement(SENSITIVE_CONSTRAINED_RESOURCE), new NonResolvingResourceDescriptionResolver())
                .setAddHandler(new AbstractAddStepHandler() {})
                .setRemoveHandler(new AbstractRemoveStepHandler() {})
                .setAccessConstraints(MY_SENSITIVE_CONSTRAINT)));
}
 
Example #12
Source File: ManagedDeploymentReadContentHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    if (context.getProcessType() == ProcessType.SELF_CONTAINED) {
        throw DomainControllerLogger.ROOT_LOGGER.cannotReadContentFromSelfContainedServer();
    }
    final Resource deploymentResource = context.readResource(PathAddress.EMPTY_ADDRESS);
    ModelNode contentItemNode = getContentItem(deploymentResource);
    // Validate this op is available
    if (!isManaged(contentItemNode)) {
        throw DomainControllerLogger.ROOT_LOGGER.cannotReadContentFromUnmanagedDeployment();
    }
    final byte[] deploymentHash = CONTENT_HASH.resolveModelAttribute(context, contentItemNode).asBytes();
    final ModelNode contentPath = CONTENT_PATH.resolveModelAttribute(context, operation);
    final String path = contentPath.isDefined() ? contentPath.asString() : "";
    try {
        TypedInputStream inputStream = contentRepository.readContent(deploymentHash, path);
        String uuid = context.attachResultStream(inputStream.getContentType(), inputStream);
        context.getResult().get(UUID).set(uuid);
    } catch (ExplodedContentException ex) {
        throw new OperationFailedException(ex.getMessage());
    }
}
 
Example #13
Source File: FilteredReadChildrenNamesTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected void initModel(ManagementModel managementModel) {
    ManagementResourceRegistration registration = managementModel.getRootResourceRegistration();
    GlobalOperationHandlers.registerGlobalOperations(registration, ProcessType.EMBEDDED_SERVER);
    GlobalNotifications.registerGlobalNotifications(registration, ProcessType.EMBEDDED_SERVER);

    registration.registerSubModel(new SimpleResourceDefinition(
            new Parameters(pathElement(UNCONSTRAINED_RESOURCE), new NonResolvingResourceDescriptionResolver())
                .setAddHandler(new AbstractAddStepHandler() {})
                .setRemoveHandler(new AbstractRemoveStepHandler() {})));
    registration.registerSubModel(new SimpleResourceDefinition(
            new Parameters(pathElement(SENSITIVE_CONSTRAINED_RESOURCE), new NonResolvingResourceDescriptionResolver())
                .setAddHandler(new AbstractAddStepHandler() {})
                .setRemoveHandler(new AbstractRemoveStepHandler() {})
                .setAccessConstraints(MY_SENSITIVE_CONSTRAINT)));
}
 
Example #14
Source File: TestModelControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
TestModelControllerService(ProcessType processType, RunningModeControl runningModeControl, StringConfigurationPersister persister, ModelTestOperationValidatorFilter validateOpsFilter,
        TestModelType type, ModelInitializer modelInitializer, TestDelegatingResourceDefinition rootResourceDefinition, ControlledProcessState processState, ExtensionRegistry extensionRegistry,
        AbstractVaultReader vaultReader, CapabilityRegistry capabilityRegistry) {
    super(processType, runningModeControl, null, persister, validateOpsFilter, rootResourceDefinition, processState,
            new RuntimeExpressionResolver(vaultReader), capabilityRegistry);
    this.type = type;
    this.runningModeControl = runningModeControl;
    this.pathManagerService = type == TestModelType.STANDALONE ? new ServerPathManagerService(capabilityRegistry) : new HostPathManagerService(capabilityRegistry);
    this.modelInitializer = modelInitializer;
    this.rootResourceDefinition = rootResourceDefinition;
    this.processState = processState;
    this.extensionRegistry = extensionRegistry;
    this.capabilityRegistry = capabilityRegistry;
    this.vaultReader = vaultReader;

    if (type == TestModelType.STANDALONE) {
        initializer = new ServerInitializer();
    } else if (type == TestModelType.HOST) {
        initializer = new HostInitializer();
    } else if (type == TestModelType.DOMAIN) {
        initializer = new DomainInitializer();
    }
}
 
Example #15
Source File: ModelTestModelControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * This is the constructor to use for 11.0.x subsystem tests
 */
protected ModelTestModelControllerService(final ProcessType processType, final RunningModeControl runningModeControl, final TransformerRegistry transformerRegistry,
                                          final StringConfigurationPersister persister, final ModelTestOperationValidatorFilter validateOpsFilter,
                                          final ResourceDefinition resourceDefinition, ControlledProcessState processState, Controller11x version) {
    super(processType, runningModeControl, persister,
            processState == null ? new ControlledProcessState(true) : processState, resourceDefinition, null, ExpressionResolver.TEST_RESOLVER);
    this.persister = persister;
    this.transformerRegistry = transformerRegistry;
    this.validateOpsFilter = validateOpsFilter;
    this.runningModeControl = runningModeControl;
}
 
Example #16
Source File: SyncModelServerStateTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public SyncModelServerStateTestCase() {
    super("slave", ProcessType.HOST_CONTROLLER, true);
    ignoredDomainResourceRegistry = new IgnoredDomainResourceRegistry(hostControllerInfo);
    serverProxies = new HashMap<>();
    serverProxies.put("server-one", new MockServerProxy("server-one"));
    serverProxies.put("server-two", new MockServerProxy("server-two"));
    serverProxies.put("server-three", new MockServerProxy("server-three"));
}
 
Example #17
Source File: ProductInfoUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void checkMaster(ModelNode result) {
    List<Property> response = validateResponse(result, true).asPropertyList();
    assertThat(response.size(), is(5));
    for (Property serverSummary : response) {
        assertThat(serverSummary.getName(), is(SUMMARY));
        final ModelNode report = serverSummary.getValue();
        assertThat(report.isDefined(), is(true));
        assertThat(report.hasDefined(NODE_NAME), is(true));
        String nodeName = report.get(NODE_NAME).asString();
        assertThat(nodeName, anyOf(is("master:main-one"), is("master:main-two"), is("master"), is("master:reload-one"), is("master:other-one")));
        boolean isRunning = "master".equals(nodeName) || "master:main-one".equals(nodeName);
        if (isRunning) {
            assertThat(report.get(ORGANIZATION).asString(), is("core-master"));
            assertThat(report.hasDefined(HOSTNAME), is(true));
            assertThat(report.hasDefined(INSTANCE_ID), is(true));
            assertThat(report.hasDefined(PRODUCT_COMMUNITY_IDENTIFIER), is(true));
            assertThat(report.get(PRODUCT_COMMUNITY_IDENTIFIER).asString(), is(PROJECT_TYPE));
            assertThat(report.hasDefined(STANDALONE_DOMAIN_IDENTIFIER), is(true));
            if ("master".equals(nodeName)) {
                assertThat(report.get(STANDALONE_DOMAIN_IDENTIFIER).asString(), is(ProcessType.HOST_CONTROLLER.name()));
            } else {
                assertThat(report.get(STANDALONE_DOMAIN_IDENTIFIER).asString(), is(ProcessType.DOMAIN_SERVER.name()));
            }
            assertThat(report.hasDefined(OS), is(true));
            assertThat(report.hasDefined(CPU), is(true));
            assertThat(report.hasDefined(CPU, ARCH), is(true));
            assertThat(report.hasDefined(CPU,AVAILABLE_PROCESSORS), is(true));
            assertThat(report.hasDefined(JVM), is(true));
            assertThat(report.hasDefined(JVM, NAME), is(true));
            assertThat(report.hasDefined(JVM, JVM_VENDOR), is(true));
            assertThat(report.hasDefined(JVM, JVM_VERSION), is(true));
            assertThat(report.hasDefined(JVM, JVM_HOME), is(true));
        }
    }
}
 
Example #18
Source File: ModelTestModelControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** @deprecated only for legacy version support */
@Deprecated
protected void initCoreModel(Resource rootResource, ManagementResourceRegistration rootRegistration, Resource modelControllerResource) {
    GlobalOperationHandlers.registerGlobalOperations(rootRegistration, ProcessType.STANDALONE_SERVER);

    rootRegistration.registerOperationHandler(CompositeOperationHandler.DEFINITION, CompositeOperationHandler.INSTANCE);
    //we don't register notifications as eap 6.2 and 6.3 dont support it, this is done in each legacy controller separatly
}
 
Example #19
Source File: EmbeddedHostControllerFactory.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static HostControllerEnvironment createHostControllerEnvironment(File jbossHome, String[] cmdargs, long startTime) {
    SecurityActions.setPropertyPrivileged(HostControllerEnvironment.HOME_DIR, jbossHome.getAbsolutePath());

    List<String> cmds = new ArrayList<String>(Arrays.asList(cmdargs));

    // these are for compatibility with Main.determineEnvironment / HostControllerEnvironment
    // Once WFCORE-938 is resolved, --admin-only will allow a connection back to the DC for slaves,
    // and support a method for setting the domain master address outside of -Djboss.domain.master.address
    // so we'll probably need a command line argument for this if its not specified as a system prop
    if (SecurityActions.getPropertyPrivileged(HostControllerEnvironment.JBOSS_DOMAIN_MASTER_ADDRESS, null) == null) {
        SecurityActions.setPropertyPrivileged(HostControllerEnvironment.JBOSS_DOMAIN_MASTER_ADDRESS, "127.0.0.1");
    }
    cmds.add(MODULE_PATH);
    cmds.add(SecurityActions.getPropertyPrivileged("module.path", ""));
    cmds.add(PC_ADDRESS);
    cmds.add("0");
    cmds.add(PC_PORT);
    cmds.add("0");
    // this used to be set in the embedded-hc specific env setup, WFCORE-938 will add support for --admin-only=false
    cmds.add("--admin-only");

    for (final String prop : EmbeddedProcessFactory.DOMAIN_KEYS) {
        // if we've started with any jboss.domain.base.dir etc, copy those in here.
        String value = SecurityActions.getPropertyPrivileged(prop, null);
        if (value != null)
            cmds.add("-D" + prop + "=" + value);
    }
    return Main.determineEnvironment(cmds.toArray(new String[cmds.size()]), startTime, ProcessType.EMBEDDED_HOST_CONTROLLER).getHostControllerEnvironment();
}
 
Example #20
Source File: JMXSubsystemAdd.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static void launchServices(OperationContext context, ModelNode model, ManagedAuditLogger auditLoggerInfo,
                           JmxAuthorizer authorizer, Supplier<SecurityIdentity> securityIdentitySupplier, RuntimeHostControllerInfoAccessor hostInfoAccessor) throws OperationFailedException {

    // Add the MBean service
    String resolvedDomain = getDomainName(context, model, CommonAttributes.RESOLVED);
    String expressionsDomain = getDomainName(context, model, CommonAttributes.EXPRESSION);
    boolean legacyWithProperPropertyFormat = false;
    if (model.hasDefined(CommonAttributes.PROPER_PROPERTY_FORMAT)) {
        legacyWithProperPropertyFormat = ExposeModelResourceExpression.DOMAIN_NAME.resolveModelAttribute(context, model).asBoolean();
    }
    boolean coreMBeanSensitivity = JMXSubsystemRootResource.CORE_MBEAN_SENSITIVITY.resolveModelAttribute(context, model).asBoolean();
    final boolean isMasterHc;
    if (context.getProcessType().isHostController()) {
        isMasterHc = hostInfoAccessor.getHostControllerInfo(context).isMasterHc();
    } else {
        isMasterHc = false;
    }
    JmxEffect jmxEffect = null;
    if (context.getProcessType() == ProcessType.DOMAIN_SERVER) {
        ModelNode rootModel = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getModel();
        String hostName = null;
        if(rootModel.hasDefined(HOST)) {
            hostName = rootModel.get(HOST).asString();
        }
        String serverGroup = null;
        if(rootModel.hasDefined(SERVER_GROUP)) {
            serverGroup = rootModel.get(SERVER_GROUP).asString();
        }
        jmxEffect = new JmxEffect(hostName, serverGroup);
    }
    MBeanServerService.addService(context, resolvedDomain, expressionsDomain, legacyWithProperPropertyFormat,
                        coreMBeanSensitivity, auditLoggerInfo, authorizer, securityIdentitySupplier, jmxEffect, context.getProcessType(), isMasterHc);
}
 
Example #21
Source File: ProductInfoUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testProductInfo() throws Exception {
    final ModelNode setOrganizationOp = Util.getWriteAttributeOperation(PathAddress.EMPTY_ADDRESS, ORGANIZATION, "wildfly-core");
    executeOperation(setOrganizationOp, true);
    final ModelNode operation = new ModelNode();
    operation.get(OP_ADDR).set(PathAddress.EMPTY_ADDRESS.toModelNode());
    operation.get(OP).set(OPERATION_NAME);

    final List<Property> result = executeOperation(operation, true).asPropertyList();
    assertThat(result.size(), is(1));
    assertThat(result.get(0).getName(), is(SUMMARY));
    final ModelNode report = result.get(0).getValue();
    assertThat(report.isDefined(), is(true));
    assertThat(report.hasDefined(NODE_NAME), is(false));
    assertThat(report.hasDefined(HOSTNAME), is(true));
    assertThat(report.hasDefined(HOSTNAME), is(true));
    assertThat(report.hasDefined(ORGANIZATION), is(true));
    assertThat(report.get(ORGANIZATION).asString(), is("wildfly-core"));
    assertThat(report.hasDefined(PRODUCT_COMMUNITY_IDENTIFIER), is(true));
    assertThat(report.get(PRODUCT_COMMUNITY_IDENTIFIER).asString(), is(PROJECT_TYPE));
    assertThat(report.hasDefined(STANDALONE_DOMAIN_IDENTIFIER), is(true));
    assertThat(report.get(STANDALONE_DOMAIN_IDENTIFIER).asString(), is(ProcessType.STANDALONE_SERVER.name()));
    assertThat(report.hasDefined(OS), is(true));
    assertThat(report.hasDefined(CPU), is(true));
    assertThat(report.get(CPU).hasDefined(ARCH), is(true));
    assertThat(report.get(CPU).hasDefined(AVAILABLE_PROCESSORS), is(true));
    assertThat(report.hasDefined(JVM), is(true));
    assertThat(report.get(JVM).hasDefined(NAME), is(true));
    assertThat(report.get(JVM).hasDefined(JVM_VENDOR), is(true));
    assertThat(report.get(JVM).hasDefined(JVM_VERSION), is(true));
    assertThat(report.get(JVM).hasDefined(JVM_HOME), is(true));
}
 
Example #22
Source File: ModelControllerMBeanTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testAttributeChangeNotificationUsingMSc() throws Exception {
    KernelServices kernelServices = setup(new MBeanInfoAdditionalInitialization(ProcessType.STANDALONE_SERVER, new TestExtension()));
    ServiceController<?> service = kernelServices.getContainer().getService(MBeanServerService.SERVICE_NAME);
    MBeanServer mbeanServer = MBeanServer.class.cast(service.getValue());

    doTestAttributeChangeNotification(mbeanServer, true);
}
 
Example #23
Source File: SecurityRealmAddHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    // Install another RUNTIME handler to actually install the services. This will run after the
    // RUNTIME handler for any child resources. Doing this will ensure that child resource handlers don't
    // see the installed services and can just ignore doing any RUNTIME stage work
    if(!context.isBooting() && context.getProcessType() == ProcessType.EMBEDDED_SERVER && context.getRunningMode() == RunningMode.ADMIN_ONLY) {
        context.reloadRequired();
    } else {
        context.addStep(ServiceInstallStepHandler.INSTANCE, OperationContext.Stage.RUNTIME);
    }
}
 
Example #24
Source File: ModelControllerMBeanTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testResolveExpressions() throws Exception {
    MBeanServerConnection connection = setupAndGetConnection(new BaseAdditionalInitialization(ProcessType.STANDALONE_SERVER));
    System.clearProperty("jboss.test.resolve.expressions.test");
    Assert.assertEquals("123", connection.invoke(LEGACY_ROOT_NAME, "resolveExpression", new String[]{"${jboss.test.resolve.expressions.test:123}"}, new String[]{String.class.getName()}));

    try {
        connection.invoke(LEGACY_ROOT_NAME, "resolveExpression", new String[]{"${jboss.test.resolve.expressions.test}"}, new String[]{String.class.getName()});
        Assert.fail("Should not have been able to resolve non-existent property");
    } catch (Exception expected) {
        //expected
    }

}
 
Example #25
Source File: ManagementPermissionAuthorizerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Before
public void setUp() {
    caller = Caller.createCaller(null);
    ControlledProcessState processState = new ControlledProcessState(false);
    processState.setRunning();
    environment = new Environment(processState, ProcessType.EMBEDDED_SERVER);
    TestPermissionFactory testPermissionFactory = new TestPermissionFactory();
    authorizer = new ManagementPermissionAuthorizer(testPermissionFactory);
}
 
Example #26
Source File: ModelControllerMBeanTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testAttributeChangeNotificationUsingManagementFactory() throws Exception {
    setup(new MBeanInfoAdditionalInitialization(ProcessType.STANDALONE_SERVER, new TestExtension()));
    MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();

    doTestAttributeChangeNotification(mbeanServer, true);
}
 
Example #27
Source File: RemotingSubsystemRootResource.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Attributes(ProcessType processType, boolean forDomain) {
    this.forDomain = forDomain;
    this.options = OPTIONS;
    if (processType.isServer()) {
        this.worker = WORKER;
        this.legacy = new AttributeDefinition[LEGACY_ATTRIBUTES.length];
        for (int i = 0; i < LEGACY_ATTRIBUTES.length; i++) {
            // Reject any defined value, but that means there can't be a default (as that gets validated)
            // Also, a default is incorrect on a server, as there really is no value
            this.legacy[i] = SimpleAttributeDefinitionBuilder.create(LEGACY_ATTRIBUTES[i])
                    .setValidator(WorkerThreadValidator.INSTANCE)
                    .setDefaultValue(null)
                    .build();
        }
    } else if (forDomain) {
        this.worker = SimpleAttributeDefinitionBuilder.create(WORKER).setCapabilityReference((CapabilityReferenceRecorder) null).build();
        this.legacy = LEGACY_ATTRIBUTES;
    } else {
        this.worker = WORKER;
        this.legacy = null;
    }
    int count = options.length + 1 + (legacy == null ? 0 : legacy.length);
    all = new AttributeDefinition[count];
    int idx = 0;
    if (legacy != null) {
        System.arraycopy(legacy, 0, all, 0, legacy.length);
        idx += legacy.length;
    }
    all[idx] = worker;
    System.arraycopy(options, 0, all, idx + 1, options.length);
}
 
Example #28
Source File: GlobalNotifications.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void registerGlobalNotifications(ManagementResourceRegistration root, ProcessType processType) {
    root.registerNotification(RESOURCE_ADDED, true);
    root.registerNotification(RESOURCE_REMOVED, true);

    if (processType != ProcessType.DOMAIN_SERVER) {
        root.registerNotification(ATTRIBUTE_VALUE_WRITTEN, true);
    }
}
 
Example #29
Source File: ModelControllerMBeanTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testMBeanServerNotification_UNREGISTRATION_NOTIFICATIONUsingManagementFactory() throws Exception {
    setup(new MBeanInfoAdditionalInitialization(ProcessType.STANDALONE_SERVER, new SubystemWithSingleFixedChildExtension()));
    MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();

    doTestMBeanServerNotification_UNREGISTRATION_NOTIFICATION(mbeanServer, true);
}
 
Example #30
Source File: ModelTestModelControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * This is the constructor to use for subsystem-test/test-controller-7.4.x
 */
protected ModelTestModelControllerService(final ProcessType processType, final RunningModeControl runningModeControl, final TransformerRegistry transformerRegistry,
                                          final StringConfigurationPersister persister, final ModelTestOperationValidatorFilter validateOpsFilter,
                                          final DescriptionProvider rootDescriptionProvider, ControlledProcessState processState, Controller74x version) {
    super(processType, runningModeControl, persister,
            processState == null ? new ControlledProcessState(true) : processState, rootDescriptionProvider, null, ExpressionResolver.TEST_RESOLVER);
    this.persister = persister;
    this.transformerRegistry = transformerRegistry;
    this.validateOpsFilter = validateOpsFilter;
    this.runningModeControl = runningModeControl;
}