/** * 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 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 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 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())); } });
@Override public void transform(PlasticClass plasticClass) final PlasticField registryField = plasticClass.introduceField(StrategyRegistry.class, "registry") .inject(registry); Class<?> interfaceSelectorType = null;
private void implementComponentInterface(PlasticClass plasticClass) { plasticClass.introduceInterface(Component.class); final PlasticField resourcesField = plasticClass.introduceField(InternalComponentResources.class, "internalComponentResources").injectFromInstanceContext(); plasticClass.introduceMethod(GET_COMPONENT_RESOURCES, new InstructionBuilderCallback() { public void doBuild(InstructionBuilder builder) { builder.loadThis().getField(resourcesField).returnResult(); } }); }
private void implementOtherMethods() PlasticField annotationProviderField = plasticClass.introduceField(AnnotationProvider.class, "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 objectCreatorField = plasticClass.introduceField(ObjectCreator.class, "creator") .injectFromInstanceContext(); final PlasticField descriptionField = plasticClass.introduceField(String.class, "description") .injectFromInstanceContext();
@Override public void transform(PlasticClass plasticClass) final PlasticField objectCreatorField = plasticClass.introduceField(ObjectCreator.class, "creator") .injectFromInstanceContext(); final PlasticField descriptionField = plasticClass.introduceField(String.class, "description") .injectFromInstanceContext();
@Override public void transform(PlasticClass plasticClass) final PlasticField objectCreatorField = plasticClass.introduceField(ObjectCreator.class, "creator") .inject(creator);
final FieldHandle bindingFieldHandle = plasticClass.introduceField(Binding.class, "cache$watchBinding$" + method.getDescription().methodName).getHandle();
final PlasticField creatorField = plasticClass.introduceField(ObjectCreator.class, "creator").inject( creator); final PlasticField tokenField = plasticClass.introduceField(ServiceProxyToken.class, "token").inject( token);
private void decorateMethodWithOperation(PlasticClass componentClass, MutableComponentModel model, PlasticMethod method, String[] paths, Worker<Asset> operation) { if (paths.length == 0) { return; } String[] expandedPaths = expandPaths(paths); PlasticField assetListField = componentClass.introduceField(Asset[].class, "importedAssets_" + method.getDescription().methodName); initializeAssetsFromPaths(expandedPaths, assetListField, model.getLibraryName()); addMethodAssetOperationAdvice(method, assetListField.getHandle(), operation); }
final PlasticField creatorField = plasticClass.introduceField(ObjectCreator.class, "creator").inject( creator); final PlasticField tokenField = plasticClass.introduceField(ServiceProxyToken.class, "token").inject( token);
public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model) { // Subclasses don't need to bother, they'll inherit from super-classes. if (!support.isRootTransformation()) { return; } plasticClass.introduceInterface(RenderCommand.class); PlasticField resourcesField = plasticClass.introduceField(InternalComponentResources.class, "resources").injectFromInstanceContext(); plasticClass.introduceMethod(RENDER_DESCRIPTION).delegateTo(resourcesField); plasticClass.introduceMethod(TransformConstants.POST_RENDER_CLEANUP_DESCRIPTION).delegateTo(resourcesField); } }
private void adviseMethod(PlasticClass plasticClass, PlasticMethod method) { // Every instance of the clas srequires its own per-thread value. This handles the case of multiple // pages containing the component, or the same page containing the component multiple times. PlasticField cacheField = plasticClass.introduceField(PerThreadValue.class, "cache$" + method.getDescription().methodName); cacheField.injectComputed(new ComputedValue<PerThreadValue>() { public PerThreadValue get(InstanceContext context) { // Each instance will get a new PerThreadValue return perThreadManager.createValue(); } }); Cached annotation = method.getAnnotation(Cached.class); MethodResultCacheFactory factory = createFactory(plasticClass, annotation.watch(), method); MethodAdvice advice = createAdvice(cacheField, factory); method.addAdvice(advice); }
: method.getPlasticClass().introduceField(EventHandlerMethodParameterSource.class, description.methodName + "$parameterSource").inject(parameterSource);