@Override protected Object createInstance(Class clazz) { final Constructor constructor = InternalUtils.findAutobuildConstructor(clazz); if (constructor == null) throw new RuntimeException(String.format( "Service implementation class %s does not have a suitable public constructor.", clazz.getName())); ObjectCreator constructorServiceCreator = new ConstructorServiceCreator(resources, constructor.toString(), constructor); return constructorServiceCreator.createObject(); } }
@Override protected Object createInstance(Class clazz) { final Constructor constructor = InternalUtils.findAutobuildConstructor(clazz); if (constructor == null) throw new RuntimeException(String.format( "Service implementation class %s does not have a suitable public constructor.", clazz.getName())); ObjectCreator constructorServiceCreator = new ConstructorServiceCreator(resources, constructor.toString(), constructor); return constructorServiceCreator.createObject(); } }
private ObjectCreatorSource createStandardConstructorBasedObjectCreatorSource() { if (Modifier.isAbstract(serviceImplementation.getModifiers())) throw new RuntimeException(IOCMessages.abstractServiceImplementation(serviceImplementation, serviceId)); final Constructor constructor = InternalUtils.findAutobuildConstructor(serviceImplementation); if (constructor == null) throw new RuntimeException(IOCMessages.noConstructor(serviceImplementation, serviceId)); return new ObjectCreatorSource() { @Override public ObjectCreator constructCreator(ServiceBuilderResources resources) { return new ConstructorServiceCreator(resources, getDescription(), constructor); } @Override public String getDescription() { return String.format("%s via %s", proxyFactory.getConstructorLocation(constructor), proxyFactory.getMethodLocation(bindMethod)); } }; }
private ObjectCreatorSource createStandardConstructorBasedObjectCreatorSource() { if (Modifier.isAbstract(serviceImplementation.getModifiers())) throw new RuntimeException(IOCMessages.abstractServiceImplementation(serviceImplementation, serviceId)); final Constructor constructor = InternalUtils.findAutobuildConstructor(serviceImplementation); if (constructor == null) throw new RuntimeException(IOCMessages.noConstructor(serviceImplementation, serviceId)); return new ObjectCreatorSource() { @Override public ObjectCreator constructCreator(ServiceBuilderResources resources) { return new ConstructorServiceCreator(resources, getDescription(), constructor); } @Override public String getDescription() { return String.format("%s via %s", proxyFactory.getConstructorLocation(constructor), proxyFactory.getMethodLocation(bindMethod)); } }; }
@Override public T invoke() { Constructor constructor = InternalUtils.findAutobuildConstructor(clazz); if (constructor == null) throw new RuntimeException(IOCMessages.noAutobuildConstructor(clazz)); String description = proxyFactory.getConstructorLocation(constructor).toString(); ObjectCreator creator = new ConstructorServiceCreator(ServiceResourcesImpl.this, description, constructor); return clazz.cast(creator.createObject()); } });
@Override public T invoke() { Constructor constructor = InternalUtils.findAutobuildConstructor(clazz); if (constructor == null) throw new RuntimeException(IOCMessages.noAutobuildConstructor(clazz)); String description = proxyFactory.getConstructorLocation(constructor).toString(); ObjectCreator creator = new ConstructorServiceCreator(ServiceResourcesImpl.this, description, constructor); return clazz.cast(creator.createObject()); } });
@Override public <T> T autobuild(final Class<T> clazz) { assert clazz != null; final Constructor constructor = InternalUtils.findAutobuildConstructor(clazz); if (constructor == null) { throw new RuntimeException(IOCMessages.noAutobuildConstructor(clazz)); } Map<Class, Object> resourcesMap = CollectionFactory.newMap(); resourcesMap.put(OperationTracker.class, RegistryImpl.this); InjectionResources resources = new MapInjectionResources(resourcesMap); ObjectCreator<T> plan = InternalUtils.createConstructorConstructionPlan(this, this, resources, null, "Invoking " + proxyFactory.getConstructorLocation(constructor).toString(), constructor); return plan.createObject(); }
@Override public <T> T autobuild(final Class<T> clazz) { assert clazz != null; final Constructor constructor = InternalUtils.findAutobuildConstructor(clazz); if (constructor == null) { throw new RuntimeException(IOCMessages.noAutobuildConstructor(clazz)); } Map<Class, Object> resourcesMap = CollectionFactory.newMap(); resourcesMap.put(OperationTracker.class, RegistryImpl.this); InjectionResources resources = new MapInjectionResources(resourcesMap); ObjectCreator<T> plan = InternalUtils.createConstructorConstructionPlan(this, this, resources, null, "Invoking " + proxyFactory.getConstructorLocation(constructor).toString(), constructor); return plan.createObject(); }