1 15 package org.apache.hivemind.annotations.internal; 16 17 import java.lang.reflect.Method ; 18 19 import org.apache.hivemind.ApplicationRuntimeException; 20 import org.apache.hivemind.Location; 21 import org.apache.hivemind.annotations.definition.Service; 22 import org.apache.hivemind.definition.ImplementationConstructionContext; 23 import org.apache.hivemind.definition.ImplementationConstructor; 24 import org.apache.hivemind.internal.AbstractServiceImplementationConstructor; 25 26 32 public class MethodCallImplementationConstructor extends AbstractServiceImplementationConstructor implements 33 ImplementationConstructor 34 { 35 private Method _factoryMethod; 36 37 private ModuleInstanceProvider _moduleInstanceProvider; 38 39 public MethodCallImplementationConstructor(Location location, Method factoryMethod, 40 ModuleInstanceProvider moduleInstanceProvider) 41 { 42 super(location); 43 _factoryMethod = factoryMethod; 44 _moduleInstanceProvider = moduleInstanceProvider; 45 } 46 47 public Object constructCoreServiceImplementation(ImplementationConstructionContext context) 48 { 49 try 50 { 51 Object result = _factoryMethod.invoke(_moduleInstanceProvider.getModuleInstance(), (Object []) null); 52 return result; 53 } 54 catch (Exception ex) 55 { 56 throw new ApplicationRuntimeException(ex.getMessage(), getLocation(), ex); 57 } 58 } 59 60 } 61 | Popular Tags |