FileDocCategorySizeDatePackage
WorkManagerFactory.javaAPI DocGlassfish v2 API4554Fri May 04 22:34:26 BST 2007com.sun.enterprise.connectors.work

WorkManagerFactory

public final class WorkManagerFactory extends Object
WorkManagerFactory allows other customized WorkManager implementation to be plugged into the server. The name of the customized implementation class for the WorkManager has to be specified as a system property "workmanager.class".

It is assumed that the implementation for WorkManager also provides a public method called "getInstance" that returns a WorkManager object. This frees the WorkManagerFactory from deciding whether WorkManager is implemented as a Singleton in the server.

author
Qingqing Ouyang, Binod P.G.

Fields Summary
private static final String
DEFAULT
private static final String
WORK_MANAGER_CLASS
private static final Logger
logger
private static final com.sun.enterprise.util.i18n.StringManager
localStrings
Constructors Summary
Methods Summary
public static javax.resource.spi.work.WorkManagergetWorkManager(java.lang.String poolName)
This is called by the constructor of BootstrapContextImpl

   
                 
         
                                
        
        String className = null;
        String methodName = "getInstance";
        Class cls = null;
        WorkManager wm = null;
        
        try {
            className = System.getProperty(WORK_MANAGER_CLASS, DEFAULT);

            // Default work manager implementation is not a singleton.
            if (className.equals(DEFAULT)) {
                return new CommonWorkManager(poolName);
            }
            
            cls = Class.forName(className);
            if (cls != null) {
                Method method = cls.getMethod("getInstance", new Class[]{});
                wm = (WorkManager) method.invoke(cls, new Object[] {});
            }
        } catch (Exception e) {
            String msg = localStrings.getString("workmanager.instantiation_error");
            logger.log(Level.SEVERE, msg, e);
        }
        
        return wm;