FileDocCategorySizeDatePackage
PersistenceManagerFactoryResourceDeployer.javaAPI DocGlassfish v2 API7205Fri May 04 22:35:14 BST 2007com.sun.enterprise.resource

PersistenceManagerFactoryResourceDeployer

public class PersistenceManagerFactoryResourceDeployer extends Object implements com.sun.enterprise.server.ResourceDeployer
Handles PersistenceManagerFactory resource evnets in the server instance. When user adds a pmf resource, the admin instance fires a resource event. And the event is propagated to this object. The methods may be invoked concurrently, therefore synchronized is used.
author
Shing Wai Chan

Fields Summary
private static final com.sun.enterprise.util.i18n.StringManager
localStrings
StringManager for this deployer
private static Logger
_logger
logger for this deployer
Constructors Summary
Methods Summary
public synchronized voiddeployResource(java.lang.Object resource)


    //---- begin implements ResourceDeployer ----
    
           
        PersistenceManagerFactoryResource configPMFRes = 
                (PersistenceManagerFactoryResource)resource;

        if (configPMFRes.isEnabled()) {
            // load associated jdbc resource with PMF
            loadJdbcResource(configPMFRes);

            PMFResource j2eeResource = (PMFResource)
                IASJ2EEResourceFactoryImpl.toPMFJ2EEResource(configPMFRes);

            ResourceInstaller installer = 
                Switch.getSwitch().getResourceInstaller();
            installer.installPersistenceManagerResource(j2eeResource);

            installer.addResource(j2eeResource);
        } else {
            _logger.log(Level.INFO, "core.resource_disabled", 
                new Object[] {configPMFRes.getJndiName(), 
                              IASJ2EEResourceFactoryImpl.PMF_RES_TYPE});
        }
    
public synchronized voiddisableResource(java.lang.Object resource)

        undeployResource(resource);
    
public synchronized voidenableResource(java.lang.Object resource)

        deployResource(resource);
    
public java.lang.ObjectgetResource(java.lang.String name, com.sun.enterprise.config.serverbeans.Resources rbeans)
Utility method to find a resource from a Resource bean and convert it to a resource object to be used by ResourceDeployer implementation

param
name resource name (normally the jndi-name)
param
rbeans Resources config-beans
exception
Exception thrown if fail

        Object res = rbeans.getPersistenceManagerFactoryResourceByJndiName(name);
        if (res == null) {
            String msg = localStrings.getString("resource.no_resource",name);
            throw new Exception(msg);
        }
        return res;
    
private voidloadJdbcResource(com.sun.enterprise.config.serverbeans.PersistenceManagerFactoryResource cr)


        String resName = cr.getJdbcResourceJndiName();
        Resources resources = (Resources) cr.parent();
        ConfigBean cb = resources.getJdbcResourceByJndiName(resName);
        if (cb != null) {
            try {
                InitialContext ic = new InitialContext();
                ic.lookup(resName);
            } catch (Exception e) {
                // resource is not loaded 
                JdbcResourceDeployer deployer =
                    new JdbcResourceDeployer();
                deployer.deployResource(cb);
            }
        }
    
public synchronized voidredeployResource(java.lang.Object resource)

        undeployResource(resource);
        deployResource(resource);
    
public synchronized voidundeployResource(java.lang.Object resource)

        NamingManager namingMgr = Switch.getSwitch().getNamingManager();
        PersistenceManagerFactoryResource configPMFRes = 
                (PersistenceManagerFactoryResource)resource;
        namingMgr.unpublishObject(configPMFRes.getJndiName());

        ResourceInstaller installer = Switch.getSwitch().getResourceInstaller();
        installer.removeResource(
                IASJ2EEResourceFactoryImpl.toPMFJ2EEResource(configPMFRes));