1 23 24 package com.sun.enterprise.connectors.work; 25 26 import com.sun.enterprise.util.Utility; 27 import com.sun.enterprise.connectors.ConnectorRuntimeException; 28 import com.sun.logging.LogDomains; 29 import java.io.IOException ; 30 import java.lang.reflect.InvocationTargetException ; 31 import java.lang.reflect.Method ; 32 import java.util.Properties ; 33 import java.util.logging.Level ; 34 import java.util.logging.Logger ; 35 import javax.resource.spi.work.WorkManager ; 36 import com.sun.enterprise.util.i18n.StringManager; 37 38 51 public class WorkManagerFactory { 52 53 private static final String DEFAULT = 54 "com.sun.enterprise.connectors.work.CommonWorkManager"; 55 56 private static final String WORK_MANAGER_CLASS = "workmanager.class"; 57 58 private static Logger logger = 59 LogDomains.getLogger(LogDomains.RSR_LOGGER); 60 61 private static StringManager localStrings = 62 StringManager.getManager(WorkManagerFactory.class); 63 64 67 public static WorkManager getWorkManager(String poolName) 68 throws ConnectorRuntimeException { 69 70 String className = null; 71 String methodName = "getInstance"; 72 Class cls = null; 73 WorkManager wm = null; 74 75 try { 76 className = System.getProperty(WORK_MANAGER_CLASS, DEFAULT); 77 78 if (className.equals(DEFAULT)) { 80 return new CommonWorkManager(poolName); 81 } 82 83 cls = Class.forName(className); 84 if (cls != null) { 85 Method method = cls.getMethod("getInstance", new Class []{}); 86 wm = (WorkManager ) method.invoke(cls, new Object [] {}); 87 } 88 } catch (Exception e) { 89 String msg = localStrings.getString("workmanager.instantiation_error"); 90 logger.log(Level.SEVERE, msg, e); 91 } 92 93 return wm; 94 } 95 96 } 97 | Popular Tags |