1 26 27 package org.objectweb.jonas.ws; 28 29 import org.objectweb.jonas.common.JProp; 30 31 37 public class JServiceFactoryFinder { 38 41 private static JProp props = null; 42 43 46 private static ClassLoader jonasCL = 47 Thread.currentThread().getContextClassLoader(); 48 49 52 private static final String JONAS_SERVICE_FACTORY = 53 "jonas.service.ws.factory.class"; 54 55 58 private JServiceFactoryFinder() { } 59 60 63 private static String factoryClassName = null; 64 65 72 public static JServiceFactory getJOnASServiceFactory() 73 throws WSServiceException { 74 JServiceFactory factory = null; 75 76 if (props == null) { 77 try { 78 props = JProp.getInstance(); 79 factoryClassName = props.getValue(JONAS_SERVICE_FACTORY); 80 } catch (Exception e) { 81 String err = 82 "Error when trying to get jonas property '" 83 + JONAS_SERVICE_FACTORY + "'"; 84 throw new WSServiceException(err, e); 85 } 86 } 87 88 if (factoryClassName == null) { 89 String err = 90 "jonas property '" + JONAS_SERVICE_FACTORY + "' must be set!"; 91 throw new WSServiceException(err); 92 } 93 94 try { 96 factory = 97 (JServiceFactory) jonasCL.loadClass(factoryClassName) 98 .newInstance(); 99 } catch (ClassNotFoundException cnfe) { 100 String err = 101 "ClassNotFound '" + factoryClassName + "' in JOnAS ClassLoader"; 102 throw new WSServiceException(err); 103 } catch (InstantiationException ie) { 104 String err = 105 "Instantiation error for new '" + factoryClassName + "'"; 106 throw new WSServiceException(err); 107 } catch (IllegalAccessException ie) { 108 String err = "Illegal Access for new '" + factoryClassName + "'"; 109 throw new WSServiceException(err); 110 } 111 112 return factory; 113 114 } 115 } 116 | Popular Tags |