1 24 package org.objectweb.jalisto.se; 25 26 import org.objectweb.jalisto.se.api.*; 27 import org.objectweb.jalisto.se.api.internal.Constants; 28 import org.objectweb.jalisto.se.api.internal.InternalFactory; 29 import org.objectweb.jalisto.se.api.query.FieldDescription; 30 import org.objectweb.jalisto.se.exception.JalistoException; 31 import org.objectweb.jalisto.se.impl.meta.ClassDescriptionImpl; 32 import org.objectweb.jalisto.se.impl.meta.FieldDescriptionImpl; 33 import org.objectweb.jalisto.se.impl.util.JalistoUtils; 34 35 import java.io.IOException ; 36 import java.util.Properties ; 37 38 42 public class JalistoFactory { 43 44 private static InternalFactory internalFactory; 45 private static String internalFactoryClass; 46 47 public static synchronized InternalFactory getInternalFactory(String propertiesFilePath) { 48 if (internalFactory == null) { 49 try { 50 Properties props = new Properties (); 51 JalistoUtils.loadPropertiesFileIn(propertiesFilePath, props); 52 internalFactoryClass = props.getProperty(JalistoProperties.INTERNAL_FACTORY_CLASS_KEY, 53 Constants.INTERNALFACTORYCLASS_DIC); 54 } catch (IOException ioe) { 55 throw new JalistoException("error during initial loading of "+propertiesFilePath, ioe); 56 } 57 } 58 return getInternalFactory(); 59 } 60 61 public static synchronized InternalFactory getInternalFactory() { 62 if (internalFactory == null) { 63 try { 64 internalFactory = (InternalFactory) Class.forName(internalFactoryClass).newInstance(); 65 internalFactory.init(); 66 internalFactory.setSelfInstance(); 67 } catch (InstantiationException e) { 68 throw new JalistoException("cannot instanciate "+internalFactoryClass, e); 69 } catch (IllegalAccessException e) { 70 throw new JalistoException("cannot initialize "+internalFactoryClass, e); 71 } catch (ClassNotFoundException e) { 72 throw new JalistoException("cannot find "+internalFactoryClass, e); 73 } 74 } 75 return internalFactory; 76 } 77 78 86 public static synchronized Session getSession(String propertiesFilePath) { 87 return getInternalFactory(propertiesFilePath).getSession(propertiesFilePath); 88 } 89 90 public static ClassDescription createClassDescription(String fullClassName) { 91 return new ClassDescriptionImpl(fullClassName); 92 } 93 94 public static FieldDescription createFieldDescription(String fieldName, MetaType type) { 95 return new FieldDescriptionImpl(fieldName, type); 96 } 97 98 public static void launchJMXServer(Session session) { 99 getInternalFactory().launchMBeanHtmlServer(session.getInternalSession().getProperties()); 100 } 101 102 public static void launchJMXServer(String jalistoPropertiesPath) { 103 JalistoProperties properties = getInternalFactory(jalistoPropertiesPath).getProperties(jalistoPropertiesPath); 104 getInternalFactory().launchMBeanHtmlServer(properties); 105 } 106 } 107 | Popular Tags |