Search in sources :

Example 1 with ManagementAdaptor

use of org.jipijapa.plugin.spi.ManagementAdaptor 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));
        }
    }
}
Also used : ManagementAdaptor(org.jipijapa.plugin.spi.ManagementAdaptor) Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

Resource (org.jboss.as.controller.registry.Resource)1 ModelNode (org.jboss.dmr.ModelNode)1 ManagementAdaptor (org.jipijapa.plugin.spi.ManagementAdaptor)1