本文整理汇总了Java中org.jboss.as.controller.registry.Resource类的典型用法代码示例。如果您正苦于以下问题:Java Resource类的具体用法?Java Resource怎么用?Java Resource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Resource类属于org.jboss.as.controller.registry包,在下文中一共展示了Resource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performBoottime
import org.jboss.as.controller.registry.Resource; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void performBoottime(OperationContext context, ModelNode operation, ModelNode model,
ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers)
throws OperationFailedException {
ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
SmppService service = SmppService.INSTANCE;
service.setModel(fullModel);
ServiceName name = SmppService.getServiceName();
ServiceController<SmppServiceInterface> controller = context.getServiceTarget()
.addService(name, service)
.addDependency(PathManagerService.SERVICE_NAME, PathManager.class, service.getPathManagerInjector())
.addDependency(MBeanServerService.SERVICE_NAME, MBeanServer.class, service.getMbeanServer())
.addListener(verificationHandler)
.setInitialMode(ServiceController.Mode.ACTIVE)
.install();
newControllers.add(controller);
}
示例2: testRemoveWithWriteAttributeSensitivity
import org.jboss.as.controller.registry.Resource; //导入依赖的package包/类
private void testRemoveWithWriteAttributeSensitivity(StandardRole role, boolean success) throws Exception {
ChildResourceDefinition def = new ChildResourceDefinition(ONE);
def.addAttribute("test", WRITE_CONSTRAINT);
rootRegistration.registerSubModel(def);
Resource resourceA = Resource.Factory.create();
resourceA.getModel().get("test").set("a");
rootResource.registerChild(ONE_A, resourceA);
Resource resourceB = Resource.Factory.create();
resourceB.getModel().get("test").set("b");
rootResource.registerChild(ONE_B, resourceB);
ModelNode op = Util.createRemoveOperation(ONE_B_ADDR);
op.get(OPERATION_HEADERS, "roles").set(role.toString());
if (success) {
executeForResult(op);
} else {
executeForFailure(op);
}
}
示例3: removeContent
import org.jboss.as.controller.registry.Resource; //导入依赖的package包/类
private void removeContent(OperationContext context, List<byte[]> removedHashes, String name) {
Set<String> newHash;
try {
newHash = DeploymentUtils.getDeploymentHexHash(context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel());
} catch (Resource.NoSuchResourceException ex) {
newHash = Collections.emptySet();
}
for (byte[] hash : removedHashes) {
try {
if (newHash.isEmpty() || !newHash.contains(HashUtil.bytesToHexString(hash))) {
contentRepository.removeContent(ModelContentReference.fromDeploymentName(name, hash));
} else {
ServerLogger.ROOT_LOGGER.undeployingDeploymentHasBeenRedeployed(name);
}
} catch (Exception e) {
//TODO
ServerLogger.ROOT_LOGGER.failedToRemoveDeploymentContent(e, HashUtil.bytesToHexString(hash));
}
}
}
示例4: updateOptionsAttribute
import org.jboss.as.controller.registry.Resource; //导入依赖的package包/类
protected void updateOptionsAttribute(OperationContext context, ModelNode operation, String type) {
final PathAddress operationAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
final PathAddress discoveryOptionsAddress = operationAddress.subAddress(0, operationAddress.size() - 1);
final ModelNode discoveryOptions = Resource.Tools.readModel(context.readResourceFromRoot(discoveryOptionsAddress));
// Get the current list of discovery options and remove the given discovery option
// from the list to maintain the order
final ModelNode currentList = discoveryOptions.get(ModelDescriptionConstants.OPTIONS);
final String name = operationAddress.getLastElement().getValue();
final ModelNode newList = new ModelNode().setEmptyList();
for (ModelNode e : currentList.asList()) {
final Property prop = e.asProperty();
final String discoveryOptionType = prop.getName();
final String discoveryOptionName = prop.getValue().get(ModelDescriptionConstants.NAME).asString();
if (!(discoveryOptionType.equals(type) && discoveryOptionName.equals(name))) {
newList.add(e);
}
}
final ModelNode writeOp = Util.getWriteAttributeOperation(discoveryOptionsAddress, ModelDescriptionConstants.OPTIONS, newList);
final OperationStepHandler writeHandler = context.getRootResourceRegistration().getSubModel(discoveryOptionsAddress).getOperationHandler(PathAddress.EMPTY_ADDRESS, WRITE_ATTRIBUTE_OPERATION);
context.addStep(writeOp, writeHandler, OperationContext.Stage.MODEL);
}
示例5: initModel
import org.jboss.as.controller.registry.Resource; //导入依赖的package包/类
@Override
protected void initModel(ManagementModel managementModel) {
ManagementResourceRegistration registration = managementModel.getRootResourceRegistration();
GlobalOperationHandlers.registerGlobalOperations(registration, processType);
registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
GlobalNotifications.registerGlobalNotifications(registration, processType);
ManagementResourceRegistration coreResourceRegistration = registration.registerSubModel(new CoreResourceDefinition());
coreResourceRegistration.registerSubModel(new ChildResourceDefinition(CHILD));
coreResourceRegistration.registerSubModel(new SingletonResourceDefinition(SERVICE, ASYNC));
coreResourceRegistration.registerSubModel(new SingletonResourceDefinition(SERVICE, REMOTE));
coreResourceRegistration.registerSubModel(new ChildResourceDefinition(DATASOURCE));
coreResourceRegistration.registerSubModel(new SingletonResourceDefinition(DATASOURCE, DS));
Resource model = Resource.Factory.create();
Resource rootResource = managementModel.getRootResource();
rootResource.registerChild(PathElement.pathElement(CORE, MODEL), model);
model.registerChild(PathElement.pathElement(CHILD, "myChild"), Resource.Factory.create());
}
示例6: getHostEffect
import org.jboss.as.controller.registry.Resource; //导入依赖的package包/类
/** Creates an appropriate HSGE for resources in the host tree, excluding the server and server-config subtrees */
private synchronized HostServerGroupEffect getHostEffect(PathAddress address, String host, Resource root) {
if (requiresMapping) {
map(root);
requiresMapping = false;
}
Set<String> mapped = hostsToGroups.get(host);
if (mapped == null) {
// Unassigned host. Treat like an unassigned profile or socket-binding-group;
// i.e. available to all server group scoped roles.
// Except -- WFLY-2085 -- the master HC is not open to all s-g-s-rs
Resource hostResource = root.getChild(PathElement.pathElement(HOST, host));
if (hostResource != null) {
ModelNode dcModel = hostResource.getModel().get(DOMAIN_CONTROLLER);
if (!dcModel.hasDefined(REMOTE)) {
mapped = Collections.emptySet(); // prevents returning HostServerGroupEffect.forUnassignedHost(address, host)
}
}
}
return mapped == null ? HostServerGroupEffect.forUnassignedHost(address, host)
: HostServerGroupEffect.forMappedHost(address, mapped, host);
}
示例7: performBoottime
import org.jboss.as.controller.registry.Resource; //导入依赖的package包/类
@Override
protected void performBoottime(final OperationContext context, final ModelNode operation, final ModelNode model)
throws OperationFailedException {
final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
final ModelNode node = Resource.Tools.readModel(resource);
// get the minimum set of deployment permissions.
final ModelNode deploymentPermissionsModel = node.get(DEPLOYMENT_PERMISSIONS_PATH.getKeyValuePair());
final ModelNode minimumPermissionsNode = MINIMUM_PERMISSIONS.resolveModelAttribute(context, deploymentPermissionsModel);
final List<PermissionFactory> minimumSet = this.retrievePermissionSet(context, minimumPermissionsNode);
// get the maximum set of deployment permissions.
ModelNode maximumPermissionsNode = MAXIMUM_PERMISSIONS.resolveModelAttribute(context, deploymentPermissionsModel);
if (!maximumPermissionsNode.isDefined())
maximumPermissionsNode = DEFAULT_MAXIMUM_SET;
final List<PermissionFactory> maximumSet = this.retrievePermissionSet(context, maximumPermissionsNode);
// validate the configured permissions - the minimum set must be implied by the maximum set.
final FactoryPermissionCollection maxPermissionCollection = new FactoryPermissionCollection(maximumSet.toArray(new PermissionFactory[maximumSet.size()]));
final StringBuilder failedPermissions = new StringBuilder();
for (PermissionFactory factory : minimumSet) {
Permission permission = factory.construct();
if (!maxPermissionCollection.implies(permission)) {
failedPermissions.append("\n\t\t").append(permission);
}
}
if (failedPermissions.length() > 0) {
throw SecurityManagerLogger.ROOT_LOGGER.invalidSubsystemConfiguration(failedPermissions);
}
// install the DUPs responsible for parsing and validating security permissions found in META-INF/permissions.xml.
context.addStep(new AbstractDeploymentChainStep() {
protected void execute(DeploymentProcessorTarget processorTarget) {
processorTarget.addDeploymentProcessor(Constants.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_PERMISSIONS,
new PermissionsParserProcessor(minimumSet));
processorTarget.addDeploymentProcessor(Constants.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_PERMISSIONS_VALIDATION,
new PermissionsValidationProcessor(maximumSet));
}
}, OperationContext.Stage.RUNTIME);
}
示例8: populateModel
import org.jboss.as.controller.registry.Resource; //导入依赖的package包/类
@Override
protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
// For any attribute where the value in 'operation' differs from the model in the
// parent resource, add an immediate 'write-attribute' step against the parent
PathAddress parentAddress = context.getCurrentAddress().getParent();
ModelNode parentModel = context.readResourceFromRoot(parentAddress, false).getModel();
OperationStepHandler writeHandler = null;
ModelNode baseWriteOp = null;
for (AttributeDefinition ad : RemotingEndpointResource.ATTRIBUTES.values()) {
String attr = ad.getName();
ModelNode parentVal = parentModel.get(attr);
ModelNode opVal = operation.has(attr) ? operation.get(attr) : new ModelNode();
if (!parentVal.equals(opVal)) {
if (writeHandler == null) {
writeHandler = context.getRootResourceRegistration().getOperationHandler(parentAddress, WRITE_ATTRIBUTE_OPERATION);
baseWriteOp = Util.createEmptyOperation(WRITE_ATTRIBUTE_OPERATION, parentAddress);
}
ModelNode writeOp = baseWriteOp.clone();
writeOp.get(NAME).set(attr);
writeOp.get(VALUE).set(opVal);
context.addStep(writeOp, writeHandler, OperationContext.Stage.MODEL, true);
}
}
}
示例9: performRuntime
import org.jboss.as.controller.registry.Resource; //导入依赖的package包/类
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) throws OperationFailedException {
ModelNode subsystemConfig = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
// TODO: the root resource doesn't inlcude the runtime paramters, hence we cannot depict the host/server name & launch-type from it.
//ModelNode systemConfig = Resource.Tools.readModel(context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false));
// Add the service
newControllers.add(
RhqMetricsService.createService(
context.getServiceTarget(),
verificationHandler,
subsystemConfig
)
);
}
示例10: removeContentFromExplodedAndTransformOperation
import org.jboss.as.controller.registry.Resource; //导入依赖的package包/类
/**
* Remove contents from the deployment and attach a "transformed" slave operation to the operation context.
*
* @param context the operation context
* @param operation the original operation
* @param contentRepository the content repository
* @return the hash of the uploaded deployment content
* @throws IOException
* @throws OperationFailedException
*/
public static byte[] removeContentFromExplodedAndTransformOperation(OperationContext context, ModelNode operation, ContentRepository contentRepository) throws OperationFailedException, ExplodedContentException {
final Resource deploymentResource = context.readResource(PathAddress.EMPTY_ADDRESS);
ModelNode contentItemNode = getContentItem(deploymentResource);
final byte[] oldHash = CONTENT_HASH.resolveModelAttribute(context, contentItemNode).asBytes();
final List<String> paths = REMOVED_PATHS.unwrap(context, operation);
final byte[] hash = contentRepository.removeContentFromExploded(oldHash, paths);
// Clear the contents and update with the hash
final ModelNode slave = operation.clone();
slave.get(CONTENT).setEmptyList().add().get(HASH).set(hash);
slave.get(CONTENT).add().get(ARCHIVE).set(false);
// Add the domain op transformer
List<DomainOperationTransmuter> transformers = context.getAttachment(OperationAttachments.SLAVE_SERVER_OPERATION_TRANSMUTERS);
if (transformers == null) {
context.attach(OperationAttachments.SLAVE_SERVER_OPERATION_TRANSMUTERS, transformers = new ArrayList<>());
}
transformers.add(new CompositeOperationAwareTransmuter(slave));
return hash;
}
示例11: log
import org.jboss.as.controller.registry.Resource; //导入依赖的package包/类
@Override
public void log(boolean readOnly, ResultAction resultAction, String userId, String domainUUID, AccessMechanism accessMechanism,
InetAddress remoteAddress, Resource resultantModel, List<ModelNode> operations) {
if (runDisabledFastPath.get())
return;
config.lock();
try {
if (skipLogging(readOnly)) {
return;
}
storeLogItem(
AuditLogItem.createModelControllerItem(config.getAsVersion(), readOnly, config.isBooting(), resultAction, userId, domainUUID,
accessMechanism, remoteAddress, resultantModel, operations));
} catch (Exception e) {
handleLoggingException(e);
} finally {
applyHandlerUpdates();
config.unlock();
}
}
示例12: recordCapabilitiesAndRequirements
import org.jboss.as.controller.registry.Resource; //导入依赖的package包/类
protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
Set<RuntimeCapability> capabilitySet = capabilities.isEmpty() ? context.getResourceRegistration().getCapabilities() : capabilities;
for (RuntimeCapability capability : capabilitySet) {
if (capability.isDynamicallyNamed()) {
context.registerCapability(capability.fromBaseCapability(context.getCurrentAddress()));
} else {
context.registerCapability(capability);
}
}
ModelNode model = resource.getModel();
for (AttributeDefinition ad : attributeDefinitions) {
if (model.hasDefined(ad.getName()) || ad.hasCapabilityRequirements()) {
ad.addCapabilityRequirements(context, resource, model.get(ad.getName()));
}
}
}
示例13: execute
import org.jboss.as.controller.registry.Resource; //导入依赖的package包/类
@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
final ModelNode address;
final PathAddress pa = context.getCurrentAddress();
AuthorizationResult authResult = context.authorize(operation, DESCRIBE_EFFECTS);
if (authResult.getDecision() != AuthorizationResult.Decision.PERMIT) {
throw ControllerLogger.ROOT_LOGGER.unauthorized(operation.require(OP).asString(), pa, authResult.getExplanation());
}
if (pa.size() > 0) {
address = new ModelNode().add(pa.getLastElement().getKey(), pa.getLastElement().getValue());
} else {
address = new ModelNode().setEmptyList();
}
final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
final ModelNode result = context.getResult();
describe(context.getAttachment(OrderedChildTypesAttachment.KEY), resource,
address, result, context.getResourceRegistration());
}
示例14: testInsertedOrderedChildrenModelSync
import org.jboss.as.controller.registry.Resource; //导入依赖的package包/类
@Test
public void testInsertedOrderedChildrenModelSync() throws Exception {
//Inserts a child to the beginning
ModelNode originalModel = readResourceRecursive();
Resource rootResource = createMasterDcResources();
createAndRegisterSubsystemChildFromRoot(rootResource, ORDERED_CHILD.getKey(), "pear", 0);
ModelNode master = Resource.Tools.readModel(rootResource);
executeTriggerSyncOperation(rootResource);
ModelNode currentModel = readResourceRecursive();
Assert.assertNotEquals(originalModel, currentModel);
compare(findSubsystemResource(currentModel).get(ORDERED_CHILD.getKey()).keys(), "pear", "apple", "orange");
compareSubsystemModels(master, currentModel);
}
示例15: recordCapabilitiesAndRequirements
import org.jboss.as.controller.registry.Resource; //导入依赖的package包/类
/**
* Record any new {@link org.jboss.as.controller.capability.RuntimeCapability capabilities} that are no longer available as
* a result of this operation, as well as any requirements for other capabilities that no longer exist. This method is
* invoked during {@link org.jboss.as.controller.OperationContext.Stage#MODEL}.
* <p>
* Any changes made by this method will automatically be discarded if the operation rolls back.
* </p>
* <p>
* This default implementation deregisters any capabilities passed to the constructor.
* </p>
*
* @param context the context. Will not be {@code null}
* @param operation the operation that is executing Will not be {@code null}
* @param resource the resource that will be removed. Will <strong>not</strong> reflect any updates made by
* {@link #performRemove(OperationContext, org.jboss.dmr.ModelNode, org.jboss.dmr.ModelNode)} as this method
* is invoked before that method is. Will not be {@code null}
*/
protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
Set<RuntimeCapability> capabilitySet = capabilities.isEmpty() ? context.getResourceRegistration().getCapabilities() : capabilities;
for (RuntimeCapability capability : capabilitySet) {
if (capability.isDynamicallyNamed()) {
context.deregisterCapability(capability.getDynamicName(context.getCurrentAddress()));
} else {
context.deregisterCapability(capability.getName());
}
}
ModelNode model = resource.getModel();
ImmutableManagementResourceRegistration mrr = context.getResourceRegistration();
for (String attr : mrr.getAttributeNames(PathAddress.EMPTY_ADDRESS)) {
AttributeAccess aa = mrr.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attr);
if (aa != null) {
AttributeDefinition ad = aa.getAttributeDefinition();
if (ad != null && (model.hasDefined(ad.getName()) || ad.hasCapabilityRequirements())) {
ad.removeCapabilityRequirements(context, resource, model.get(ad.getName()));
}
}
}
}