1 15 package org.apache.hivemind.lib.factory; 16 17 import org.apache.hivemind.ApplicationRuntimeException; 18 import org.apache.hivemind.HiveMind; 19 import org.apache.hivemind.Location; 20 import org.apache.hivemind.internal.Module; 21 import org.apache.hivemind.lib.BeanFactory; 22 import org.apache.hivemind.service.ObjectProvider; 23 24 33 public class BeanFactoryObjectProvider implements ObjectProvider 34 { 35 public Object provideObject( 36 Module contributingModule, 37 Class propertyType, 38 String inputValue, 39 Location location) 40 { 41 if (HiveMind.isBlank(inputValue)) 42 return null; 43 44 int colonx = inputValue.indexOf(':'); 45 46 if (colonx < 0) 47 throw new ApplicationRuntimeException( 48 FactoryMessages.invalidBeanTranslatorFormat(inputValue), 49 location, 50 null); 51 52 String serviceId = inputValue.substring(0, colonx); 53 54 if (serviceId.length() == 0) 55 throw new ApplicationRuntimeException( 56 FactoryMessages.invalidBeanTranslatorFormat(inputValue), 57 location, 58 null); 59 60 String locator = inputValue.substring(colonx + 1); 61 62 if (locator.length() == 0) 63 throw new ApplicationRuntimeException( 64 FactoryMessages.invalidBeanTranslatorFormat(inputValue), 65 location, 66 null); 67 68 BeanFactory f = (BeanFactory) contributingModule.getService(serviceId, BeanFactory.class); 69 70 return f.get(locator); 71 } 72 73 } 74 | Popular Tags |