1 package com.coldcore.coloradoftp.factory; 2 3 16 public class ObjectFactory { 17 18 protected static InternalFactory internalFactory; 19 20 21 private ObjectFactory() {} 22 23 24 27 public static InternalFactory getInternalFactory() { 28 return internalFactory; 29 } 30 31 32 35 public static void setInternalFactory(InternalFactory internalFactory) { 36 ObjectFactory.internalFactory = internalFactory; 37 } 38 39 40 44 public static Object getObject(String name) { 45 if (internalFactory == null) throw new IllegalStateException ("Internal factory is not set"); 46 Object o = internalFactory.getBean(name); 47 if (o == null) throw new IllegalArgumentException ("Object "+name+" cannot be loaded"); 48 return o; 49 } 50 } 51 | Popular Tags |