private void createInstantiator() { instantiator = proxyFactory.createProxy(serviceInterface, new PlasticClassTransformer() { @Override public void transform(PlasticClass plasticClass) { PlasticField filterField = plasticClass.introduceField(filterInterface, "filter") .injectFromInstanceContext(); PlasticField nextField = plasticClass.introduceField(serviceInterface, "next") .injectFromInstanceContext(); processMethods(plasticClass, filterField, nextField); plasticClass.addToString(String.format("<PipelineBridge from %s to %s>", serviceInterface.getName(), filterInterface.getName())); } }); }
public void run() { proxyFactory.clearCache(); } });
private Class lookupClassForType(String className) { ClassLoader componentLoader = plasticFactory.getClassLoader(); try { return PlasticInternalUtils.toClass(componentLoader, className); } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } } }
@Override public String getDescription() { return String.format("%s via %s", proxyFactory.getConstructorLocation(constructor), proxyFactory.getMethodLocation(bindMethod)); } };
private Object createReloadableProxy(ServiceBuilderResources resources) { ReloadableServiceImplementationObjectCreator reloadableCreator = new ReloadableServiceImplementationObjectCreator(proxyFactory, resources, proxyFactory.getClassLoader(), serviceImplementationClass.getName()); resources.getService(UpdateListenerHub.class).addUpdateListener(reloadableCreator); if (eagerLoad) { reloadableCreator.createObject(); } return proxyFactory.createProxy(serviceInterfaceClass, resources.getServiceImplementation(), reloadableCreator, getDescription()); } }
@Override public String toString() { return proxyFactory.getMethodLocation(bindMethod).toString(); } };
@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()); } });
public AspectInterceptorBuilderImpl(AnnotationAccess annotationAccess, PlasticProxyFactory plasticProxyFactory, Class<T> serviceInterface, T delegate, String description) { super(annotationAccess); this.serviceInterface = serviceInterface; final Class<? extends Object> delegateType = delegate.getClass(); transformation = plasticProxyFactory.createProxyTransformation(serviceInterface, (Class<? extends T>) delegateType); plasticClass = transformation.getPlasticClass(); plasticClass.addToString(description); allMethods.addAll(Arrays.asList(serviceInterface.getMethods())); final PlasticField delegateField = plasticClass.introduceField(serviceInterface, "delegate").inject(delegate); for (Method method : allMethods) { plasticClass.introduceMethod(method).delegateTo(delegateField); } // TAP5-2235 final String delegateTypeName = delegateType.getName(); MethodDescription getDelegateMethodDescription = new MethodDescription(delegateTypeName, PlasticProxyFactoryImpl.INTERNAL_GET_DELEGATE); plasticClass.introduceMethod(getDelegateMethodDescription, new InstructionBuilderCallback() { @Override public void doBuild(InstructionBuilder builder) { builder.loadThis().getField(delegateField); builder.checkcast(delegateType).returnResult(); } }); }
private Object createReloadableProxy(ServiceBuilderResources resources) { ReloadableServiceImplementationObjectCreator reloadableCreator = new ReloadableServiceImplementationObjectCreator(proxyFactory, resources, proxyFactory.getClassLoader(), serviceImplementationClass.getName()); resources.getService(UpdateListenerHub.class).addUpdateListener(reloadableCreator); if (eagerLoad) { reloadableCreator.createObject(); } return proxyFactory.createProxy(serviceInterfaceClass, resources.getServiceImplementation(), reloadableCreator, getDescription()); } }
@Override public String getDescription() { return proxyFactory.getMethodLocation(bindMethod).toString(); } };
@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()); } });
public AspectInterceptorBuilderImpl(AnnotationAccess annotationAccess, PlasticProxyFactory plasticProxyFactory, Class<T> serviceInterface, T delegate, String description) { super(annotationAccess); this.serviceInterface = serviceInterface; final Class<? extends Object> delegateType = delegate.getClass(); transformation = plasticProxyFactory.createProxyTransformation(serviceInterface, (Class<? extends T>) delegateType); plasticClass = transformation.getPlasticClass(); plasticClass.addToString(description); allMethods.addAll(Arrays.asList(serviceInterface.getMethods())); final PlasticField delegateField = plasticClass.introduceField(serviceInterface, "delegate").inject(delegate); for (Method method : allMethods) { plasticClass.introduceMethod(method).delegateTo(delegateField); } // TAP5-2235 final String delegateTypeName = delegateType.getName(); MethodDescription getDelegateMethodDescription = new MethodDescription(delegateTypeName, PlasticProxyFactoryImpl.INTERNAL_GET_DELEGATE); plasticClass.introduceMethod(getDelegateMethodDescription, new InstructionBuilderCallback() { @Override public void doBuild(InstructionBuilder builder) { builder.loadThis().getField(delegateField); builder.checkcast(delegateType).returnResult(); } }); }
private void createInstantiator() { instantiator = proxyFactory.createProxy(serviceInterface, new PlasticClassTransformer() { @Override public void transform(PlasticClass plasticClass) { PlasticField filterField = plasticClass.introduceField(filterInterface, "filter") .injectFromInstanceContext(); PlasticField nextField = plasticClass.introduceField(serviceInterface, "next") .injectFromInstanceContext(); processMethods(plasticClass, filterField, nextField); plasticClass.addToString(String.format("<PipelineBridge from %s to %s>", serviceInterface.getName(), filterInterface.getName())); } }); }
@Override public String toString() { return proxyFactory.getMethodLocation(bindMethod).toString(); } };
public void run() { changeTracker.clear(); classToInstantiator.clear(); proxyFactory.clearCache(); // Release the existing class pool, loader and so forth. // Create a new one. initializeService(); }
@Override @SuppressWarnings("unchecked") public <T> ServiceBindingOptions bind(Class<T> serviceClass) { if (serviceClass.isInterface()) { try { String expectedImplName = serviceClass.getName() + "Impl"; ClassLoader classLoader = proxyFactory.getClassLoader(); Class<T> implementationClass = (Class<T>) classLoader.loadClass(expectedImplName); if (!implementationClass.isInterface() && serviceClass.isAssignableFrom(implementationClass)) { return bind( serviceClass, implementationClass); } throw new RuntimeException(IOCMessages.noServiceMatchesType(serviceClass)); } catch (ClassNotFoundException ex) { throw new RuntimeException(String.format("Could not find default implementation class %sImpl. Please provide this class, or bind the service interface to a specific implementation class.", serviceClass.getName())); } } return bind(serviceClass, serviceClass); }
@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(); }
private <T> ClassInstantiator<T> createInstantiator(final Class<T> interfaceType) return proxyFactory.createProxy(interfaceType, new PlasticClassTransformer()
@Override public String toString() { Location location = proxyFactory.getMethodLocation(method); return location.toString(); }