use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class DefaultRemoveStepHandler method updateModel.
@Override
protected void updateModel(OperationContext context, ModelNode operation) throws OperationFailedException {
super.updateModel(context, operation);
PathAddress partitionManagerAddress = getParentAddress(PathAddress.pathAddress(operation.require(OP_ADDR)));
Resource partitionManagerResource = context.readResourceFromRoot(partitionManagerAddress);
ModelNode parentModel = Resource.Tools.readModel(partitionManagerResource);
PartitionManagerAddHandler.INSTANCE.validateModel(context, partitionManagerAddress.getLastElement().getValue(), parentModel);
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class IDMConfigWriteAttributeHandler method execute.
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final PathAddress address = getParentAddress(PathAddress.pathAddress(operation.require(OP_ADDR)));
Resource resource = context.readResourceFromRoot(address);
final ModelNode parentModel = Resource.Tools.readModel(resource);
PartitionManagerAddHandler.INSTANCE.validateModel(context, address.getLastElement().getValue(), parentModel);
context.stepCompleted();
}
}, OperationContext.Stage.MODEL);
super.execute(context, operation);
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class IdentityConfigurationRemoveStepHandler method updateModel.
@Override
protected void updateModel(OperationContext context, ModelNode operation) throws OperationFailedException {
PathAddress partitionManagerAddress = getParentAddress(context.getCurrentAddress());
Resource partitionManagerResource = context.readResourceFromRoot(partitionManagerAddress);
checkIfLastConfiguration(partitionManagerResource);
ModelNode originalParentModel = Resource.Tools.readModel(partitionManagerResource);
super.updateModel(context, operation);
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
PartitionManagerRemoveHandler.INSTANCE.removeIdentityStoreServices(context, originalParentModel, partitionManagerAddress.getLastElement().getValue(), context.getCurrentAddressValue());
context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER);
}
}, OperationContext.Stage.RUNTIME);
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class IdentityStoreRemoveStepHandler method checkIfLastIdentityStore.
private void checkIfLastIdentityStore(OperationContext context) throws OperationFailedException {
PathAddress parentAddress = Util.getParentAddressByKey(context.getCurrentAddress(), ModelElement.IDENTITY_CONFIGURATION.getName());
Resource resource = context.readResourceFromRoot(parentAddress);
if (resource.getChildTypes().size() == 1) {
throw ROOT_LOGGER.idmNoIdentityStoreProvided(parentAddress.getLastElement().getValue());
}
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class PersistenceUnitServiceHandler method addManagementConsole.
/**
* add to management console (if ManagementAdapter is supported for provider).
* <p/>
* full path to management data will be:
* <p/>
* /deployment=Deployment/subsystem=jpa/hibernate-persistence-unit=FullyAppQualifiedPath#PersistenceUnitName/cache=EntityClassName
* <p/>
* example of full path:
* <p/>
* /deployment=jpa_SecondLevelCacheTestCase.jar/subsystem=jpa/hibernate-persistence-unit=jpa_SecondLevelCacheTestCase.jar#mypc/
* cache=org.jboss.as.test.integration.jpa.hibernate.Employee
* @param deploymentUnit
* @param pu
* @param adaptor
* @param persistenceAdaptorRemoval
*/
private static void addManagementConsole(final DeploymentUnit deploymentUnit, final PersistenceUnitMetadata pu, final PersistenceProviderAdaptor adaptor, PersistenceAdaptorRemoval persistenceAdaptorRemoval) {
ManagementAdaptor managementAdaptor = adaptor.getManagementAdaptor();
// unit in management console.
if (managementAdaptor != null && adaptor.doesScopedPersistenceUnitNameIdentifyCacheRegionName(pu)) {
final String providerLabel = managementAdaptor.getIdentificationLabel();
final String scopedPersistenceUnitName = pu.getScopedPersistenceUnitName();
Resource providerResource = JPAService.createManagementStatisticsResource(managementAdaptor, scopedPersistenceUnitName, deploymentUnit);
// Resource providerResource = managementAdaptor.createPersistenceUnitResource(scopedPersistenceUnitName, providerLabel);
ModelNode perPuNode = providerResource.getModel();
perPuNode.get(SCOPED_UNIT_NAME.getName()).set(pu.getScopedPersistenceUnitName());
// TODO this is a temporary hack into internals until DeploymentUnit exposes a proper Resource-based API
final Resource deploymentResource = deploymentUnit.getAttachment(DeploymentModelUtils.DEPLOYMENT_RESOURCE);
Resource subsystemResource;
synchronized (deploymentResource) {
subsystemResource = getOrCreateResource(deploymentResource, PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "jpa"));
}
synchronized (subsystemResource) {
subsystemResource.registerChild(PathElement.pathElement(providerLabel, scopedPersistenceUnitName), providerResource);
// save the subsystemResource reference + path to scoped pu, so we can remove it during undeploy
persistenceAdaptorRemoval.registerManagementConsoleChild(subsystemResource, PathElement.pathElement(providerLabel, scopedPersistenceUnitName));
}
}
}
Aggregations