/** * Defer creation of the delegate field unless actually needed. */ private PlasticField getDelegateField() { if (delegateField == null) delegateField = plasticClass.introduceField(PropertyConduitDelegate.class, "delegate").inject( sharedDelegate); return delegateField; } }
@Override public void transform(PlasticClass plasticClass) { PlasticField commandsField = plasticClass.introduceField(commandsArray.getClass(), "commands").inject( commandsArray); for (Method method : commandInterface.getMethods()) { implementMethod(plasticClass, method, commandsField); } plasticClass.addToString(String.format("<Command chain of %s>", commandInterface.getName())); } });
@Override public void transform(PlasticClass plasticClass) { PlasticField commandsField = plasticClass.introduceField(commandsArray.getClass(), "commands").inject( commandsArray); for (Method method : commandInterface.getMethods()) { implementMethod(plasticClass, method, commandsField); } plasticClass.addToString(String.format("<Command chain of %s>", commandInterface.getName())); } });
public boolean provideInjection(PlasticField field, ObjectLocator locator, MutableComponentModel componentModel) { Class fieldType = classCache.forName(field.getTypeName()); Object inject = this.locator.getService(fieldType); assert inject != null; field.inject(inject); // If we make it this far without an exception, then we were successful // and should claim the field. return true; }
.inject(registry); Class<?> interfaceSelectorType = null;
.inject(registry); Class<?> interfaceSelectorType = null;
public boolean provideInjection(PlasticField field, ObjectLocator locator, MutableComponentModel componentModel) { if (!field.hasAnnotation(Named.class)) { return false; } Named annotation = field.getAnnotation(Named.class); Class fieldType = cache.forName(field.getTypeName()); Object service = this.locator.getService(annotation.value(), fieldType); field.inject(service); return true; } }
public boolean provideInjection(final PlasticField field, ObjectLocator locator, MutableComponentModel componentModel) { Class fieldType = classCache.forName(field.getTypeName()); Object injectionValue = masterObjectProvider.provide(fieldType, new AnnotationProvider() { public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { return field.getAnnotation(annotationClass); } }, this.locator, false); // Null means that no ObjectProvider could provide the value. We have set up the chain of // command so that InjectResources can give it a try next. Later, we'll try to match against // a service. if (injectionValue != null) { field.inject(injectionValue); return true; } return false; } }
private void implementOtherMethods() "annotationProvider").inject(annotationProvider); final PlasticField propertyTypeField = plasticClass.introduceField(Class.class, "propertyType").inject( conduitPropertyType); final PlasticField propertyGenericTypeField = plasticClass.introduceField(Type.class, "propertyGenericType").inject( conduitPropertyGenericType);
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(); } }); }
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(); } }); }
@Override public void transform(PlasticClass plasticClass) final PlasticField sourceField = plasticClass.introduceField(sourceClass, "source").inject(source);
@Override public void transform(PlasticClass plasticClass) final PlasticField sourceField = plasticClass.introduceField(sourceClass, "source").inject(source);
.inject(creator);
@Override public void transform(PlasticClass plasticClass) { for (PlasticField f : plasticClass.getFieldsWithAnnotation(TestInject.class)) { if (f.getTypeName().equals(className)) { f.inject(fieldValue); f.claim(this); } } } }
public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model) { for (PlasticField field : plasticClass.getFieldsWithAnnotation(InjectService.class)) { InjectService annotation = field.getAnnotation(InjectService.class); field.claim(annotation); Class fieldType = cache.forName(field.getTypeName()); Object service = locator.getService(annotation.value(), fieldType); field.inject(service); } } }
: method.getPlasticClass().introduceField(EventHandlerMethodParameterSource.class, description.methodName + "$parameterSource").inject(parameterSource);