本文整理了Java中org.jboss.as.controller.registry.Resource.getModel
方法的一些代码示例,展示了Resource.getModel
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resource.getModel
方法的具体详情如下:
包路径:org.jboss.as.controller.registry.Resource
类名称:Resource
方法名:getModel
[英]Get the local model.
[中]买本地的模型。
代码示例来源:origin: wildfly/wildfly
/**
* Resolves runtime name of model resource.
* @param context - operation context in which handler is invoked
* @param address - deployment address
* @return runtime name of module. Value which is returned is never null.
*/
protected static String resolveRuntimeName(final OperationContext context, final PathElement address){
final ModelNode runtimeName = context.readResourceFromRoot(PathAddress.pathAddress(address),false).getModel()
.get(ModelDescriptionConstants.RUNTIME_NAME);
return runtimeName.asString();
}
}
代码示例来源:origin: wildfly/wildfly
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName,
ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException {
final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();
updateDefaultMethodPermissionsDenyAccess(context, model);
return false;
}
代码示例来源:origin: wildfly/wildfly
private void addConfigProperties(final Resource parent, String name, String value) {
final Resource config = new IronJacamarResource.IronJacamarRuntimeResource();
final ModelNode model = config.getModel();
model.get(Constants.CONFIG_PROPERTY_VALUE.getName()).set(value);
final PathElement element = PathElement.pathElement(Constants.CONFIG_PROPERTIES.getName(), name);
parent.registerChild(element, config);
}
代码示例来源:origin: org.wildfly/wildfly-server
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
ModelNode model = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel();
final String deploymentUnitName = RUNTIME_NAME.resolveModelAttribute(context, model).asString();
model.get(ENABLED.getName()).set(false);
final ModelNode opAddr = operation.get(OP_ADDR);
PathAddress address = PathAddress.pathAddress(opAddr);
final String managementName = address.getLastElement().getValue();
DeploymentHandlerUtil.undeploy(context, managementName, deploymentUnitName, vaultReader);
context.stepCompleted();
}
}
代码示例来源:origin: wildfly/wildfly
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final String idName = PathAddress.pathAddress(address).getLastElement().getValue();
ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();
final String archiveOrModuleName;
if (!model.hasDefined(ARCHIVE.getName()) && !model.hasDefined(MODULE.getName())) {
throw ConnectorLogger.ROOT_LOGGER.archiveOrModuleRequired();
if (model.get(ARCHIVE.getName()).isDefined()) {
archiveOrModuleName = model.get(ARCHIVE.getName()).asString();
} else {
archiveOrModuleName = model.get(MODULE.getName()).asString();
代码示例来源:origin: org.jboss.as/jboss-as-server
@Override
protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName,
ModelNode valueToRestore, ModelNode valueToRevert, Boolean handback) throws OperationFailedException {
if (handback != null && handback.booleanValue()) {
final String bindingName = PathAddress.pathAddress(operation.get(OP_ADDR)).getLastElement().getValue();
final ModelNode bindingModel = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();
// Back to the old service
revertBindingReinstall(context, bindingName, bindingModel, attributeName, valueToRestore);
} else {
context.revertReloadRequired();
}
}
代码示例来源:origin: wildfly/wildfly
@Override
protected void validateUpdatedModel(final OperationContext context, final Resource resource)
throws OperationFailedException {
final ModelNode model = resource.getModel();
if (!context.getProcessType().equals(ProcessType.HOST_CONTROLLER)) {
final List<String> propertiesToReject = new LinkedList<String>();
for (final AttributeDefinition attribute : JacORBSubsystemDefinitions.ON_OFF_ATTRIBUTES_TO_REJECT) {
if (model.hasDefined(attribute.getName())
&& model.get(attribute.getName()).equals(JacORBSubsystemDefinitions.DEFAULT_ENABLED_PROPERTY)) {
propertiesToReject.add(attribute.getName());
}
}
for (final AttributeDefinition attribute : JacORBSubsystemDefinitions.ATTRIBUTES_TO_REJECT) {
if (model.hasDefined(attribute.getName())) {
propertiesToReject.add(attribute.getName());
}
}
if (!propertiesToReject.isEmpty()) {
throw JacORBLogger.ROOT_LOGGER.cannotEmulateProperties(propertiesToReject);
}
}
}
代码示例来源:origin: wildfly/wildfly
@Override
protected void performBoottime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
ModelNode model = resource.getModel();
if(model.hasDefined(DefaultBindingsResourceDefinition.CONTEXT_SERVICE)) {
final String contextService = DefaultBindingsResourceDefinition.CONTEXT_SERVICE_AD.resolveModelAttribute(context, model).asString();
defaultBindingsConfigurationProcessor.setContextService(contextService);
if(model.hasDefined(DefaultBindingsResourceDefinition.DATASOURCE)) {
final String dataSource = DefaultBindingsResourceDefinition.DATASOURCE_AD.resolveModelAttribute(context, model).asString();
defaultBindingsConfigurationProcessor.setDataSource(dataSource);
if(model.hasDefined(DefaultBindingsResourceDefinition.JMS_CONNECTION_FACTORY)) {
final String jmsConnectionFactory = DefaultBindingsResourceDefinition.JMS_CONNECTION_FACTORY_AD.resolveModelAttribute(context, model).asString();
defaultBindingsConfigurationProcessor.setJmsConnectionFactory(jmsConnectionFactory);
代码示例来源:origin: org.wildfly.core/wildfly-domain-management
private static FileAuditLogHandler createFileAuditLogHandler(final PathManagerService pathManager,
final OperationContext context, final ModelNode operation) throws OperationFailedException {
final String name = Util.getNameFromAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();
final String relativeTo = model.hasDefined(RELATIVE_TO.getName()) ? RELATIVE_TO.resolveModelAttribute(context, model).asString() : null;
final String path = PATH.resolveModelAttribute(context, model).asString();
final String formatterName = FORMATTER.resolveModelAttribute(context, model).asString();
final int maxFailureCount = MAX_FAILURE_COUNT.resolveModelAttribute(context, model).asInt();
final boolean rotateAtStartup = ROTATE_AT_STARTUP.resolveModelAttribute(context, model).asBoolean();
return new FileAuditLogHandler(name, formatterName, maxFailureCount, pathManager, path, relativeTo, rotateAtStartup);
}
代码示例来源:origin: wildfly/wildfly
@Override
public void unregister(OperationContext context) throws OperationFailedException {
Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
ManagementResourceRegistration registration = context.getResourceRegistrationForUpdate();
String protocolName = context.getCurrentAddressValue();
String moduleName = ProtocolResourceDefinition.Attribute.MODULE.resolveModelAttribute(context, resource.getModel()).asString();
Class<? extends Protocol> protocolClass = ChannelRuntimeResourceRegistration.findProtocolClass(context, protocolName, moduleName);
for (String attribute : ProtocolMetricsHandler.findProtocolAttributes(protocolClass).keySet()) {
registration.unregisterAttribute(attribute);
}
}
}
代码示例来源:origin: wildfly/wildfly
@Override
protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
super.recordCapabilitiesAndRequirements(context, operation, resource);
ModelNode parentModel = context.readResourceFromRoot(context.getCurrentAddress().getParent(), false).getModel();
final String defaultServerName = UndertowRootDefinition.DEFAULT_SERVER.resolveModelAttribute(context, parentModel).asString();
boolean isDefaultServer = context.getCurrentAddressValue().equals(defaultServerName);
if (isDefaultServer) {
context.registerCapability(CommonWebServer.CAPABILITY);
}
}
代码示例来源:origin: wildfly/wildfly
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException {
String name = JcaWorkManagerDefinition.WmParameters.NAME.getAttribute().resolveModelAttribute(context, resource.getModel()).asString();
boolean elytronEnabled = JcaWorkManagerDefinition.WmParameters.ELYTRON_ENABLED.getAttribute().resolveModelAttribute(context, resource.getModel()).asBoolean();
代码示例来源:origin: wildfly/wildfly
@Override
protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
super.populateModel(context, operation, resource);
ModelNode model = resource.getModel();
boolean enableJacc = false;
if (model.hasDefined(ENABLE_JACC.getName())) {
enableJacc = ENABLE_JACC.resolveModelAttribute(context, model).asBoolean();
}
knownApplicationSecurityDomains.add(new ApplicationSecurityDomainConfig(context.getCurrentAddressValue(), enableJacc));
}
代码示例来源:origin: wildfly/wildfly
/**
* Resolves runtime name of model resource.
* @param context - operation context in which handler is invoked
* @param address - deployment address
* @return runtime name of module. Value which is returned is never null.
*/
protected String resolveRuntimeName(final OperationContext context, final PathElement address){
final ModelNode runtimeName = context.readResourceFromRoot(PathAddress.pathAddress(address),false).getModel()
.get(ModelDescriptionConstants.RUNTIME_NAME);
return runtimeName.asString();
}
}
代码示例来源:origin: org.wildfly.core/wildfly-host-controller
@Override
public void execute(OperationContext context, ModelNode operation) {
final ModelNode opAddr = operation.get(OP_ADDR);
final PathAddress address = PathAddress.pathAddress(opAddr);
final String name = address.getLastElement().getValue();
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
ServerGroupDeploymentAddHandler.validateRuntimeNames(name, context, address);
}
}, OperationContext.Stage.MODEL);
context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel().get(ENABLED.getName()).set(true);
}
}
代码示例来源:origin: wildfly/wildfly
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final String idName = PathAddress.pathAddress(opAddr).getLastElement().getValue();
final boolean isModule;
final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel();
final String archiveOrModuleName;
if (!model.hasDefined(ARCHIVE.getName()) && !model.hasDefined(MODULE.getName())) {
throw ConnectorLogger.ROOT_LOGGER.archiveOrModuleRequired();
if (model.get(ARCHIVE.getName()).isDefined()) {
isModule = false;
archiveOrModuleName = model.get(ARCHIVE.getName()).asString();
} else {
isModule = true;
archiveOrModuleName = model.get(MODULE.getName()).asString();
if (model.hasDefined(RESOURCEADAPTERS_NAME)) {
for (ModelNode raNode : model.get(RESOURCEADAPTERS_NAME).asList()) {
ModelNode raCompensatingNode = raNode.clone();
代码示例来源:origin: wildfly/wildfly
@Override
public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException {
if (resource.hasChild(SimpleLoadProviderResourceDefinition.PATH)) {
ModelNode model = resource.getModel();
ModelNode simpleModel = Resource.Tools.readModel(resource.removeChild(SimpleLoadProviderResourceDefinition.PATH));
model.get(DeprecatedAttribute.SIMPLE_LOAD_PROVIDER.getName()).set(simpleModel.get(SimpleLoadProviderResourceDefinition.Attribute.FACTOR.getName()));
}
context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource).processChildren(resource);
}
});
代码示例来源:origin: org.wildfly/wildfly-server
@Override
protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName,
ModelNode valueToRestore, ModelNode valueToRevert, Boolean handback) throws OperationFailedException {
if (handback != null && handback.booleanValue()) {
final String bindingName = PathAddress.pathAddress(operation.get(OP_ADDR)).getLastElement().getValue();
final ModelNode bindingModel = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();
// Back to the old service
revertBindingReinstall(context, bindingName, bindingModel, attributeName, valueToRestore);
} else {
context.revertReloadRequired();
}
}
代码示例来源:origin: wildfly/wildfly
private void recordCapabilitiesAndRequirements(OperationContext context, Resource resource) throws OperationFailedException {
context.deregisterCapability(MailServerDefinition.SERVER_CAPABILITY.getDynamicName(context.getCurrentAddress()));
ModelNode model = resource.getModel();
for (AttributeDefinition ad : attributes) {
if (ad != null && (model.hasDefined(ad.getName()) || ad.hasCapabilityRequirements())) {
ad.removeCapabilityRequirements(context, resource, model.get(ad.getName()));
}
}
}
代码示例来源:origin: wildfly/wildfly
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException {
ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();
this.applyModelToRuntime(context, operation, attributeName, model);
return false;
}
内容来源于网络,如有侵权,请联系作者删除!