@Override public PlasticClass proxyInterface(Class interfaceType, PlasticMethod method) { check(); assert method != null; introduceInterface(interfaceType); // TAP5-2582: avoiding adding/delegating the same method more than once Map<MethodSignature, MethodDescription> map = createMethodSignatureMap(interfaceType); for (MethodSignature methodSignature : map.keySet()) { introduceMethod(map.get(methodSignature)).delegateTo(method); } return this; }
@Override public PlasticClass proxyInterface(Class interfaceType, PlasticMethod method) { check(); assert method != null; introduceInterface(interfaceType); // TAP5-2582: avoiding adding/delegating the same method more than once Map<MethodSignature, MethodDescription> map = createMethodSignatureMap(interfaceType); for (MethodSignature methodSignature : map.keySet()) { final MethodDescription description = map.get(methodSignature); if(Modifier.isStatic(description.modifiers)) { continue; } introduceMethod(map.get(methodSignature)).delegateTo(method); } return this; }
@Override public PlasticClass proxyInterface(Class interfaceType, PlasticField field) { check(); assert field != null; introduceInterface(interfaceType); // TAP5-2582: avoiding adding/delegating the same method more than once Map<MethodSignature, MethodDescription> map = createMethodSignatureMap(interfaceType); for (MethodSignature methodSignature : map.keySet()) { final MethodDescription description = map.get(methodSignature); if(Modifier.isStatic(description.modifiers)) { continue; } introduceMethod(description).delegateTo(field); } return this; }
@Override public PlasticClass proxyInterface(Class interfaceType, PlasticField field) { check(); assert field != null; introduceInterface(interfaceType); // TAP5-2582: avoiding adding/delegating the same method more than once // for (Method m : interfaceType.getMethods()) // { // introduceMethod(m).delegateTo(field); // } Map<MethodSignature, MethodDescription> map = createMethodSignatureMap(interfaceType); for (MethodSignature methodSignature : map.keySet()) { introduceMethod(map.get(methodSignature)).delegateTo(field); } return this; }
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); } }
public void transform(PlasticClass plasticClass) { PlasticMethod delegateMethod = plasticClass.introducePrivateMethod( PlasticUtils.toTypeName(serviceType), "delegate", null, null); delegateMethod.addAdvice(new MethodAdvice() { public void advise(MethodInvocation invocation) { invocation.setReturnValue(environment.peekRequired(serviceType)); } }); for (Method method : serviceType.getMethods()) { plasticClass.introduceMethod(method).delegateTo(delegateMethod); } plasticClass.addToString(String.format("<EnvironmentalProxy for %s>", serviceType.getName())); } });
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(); } }); }
plasticClass.introduceMethod(m).delegateTo(delegateMethod);
plasticClass.introduceMethod(m).delegateTo(delegateMethod);
plasticClass.introduceMethod(method).delegateTo(delegateMethod);
plasticClass.introduceMethod(method).delegateTo(delegateMethod);
plasticClass.introduceMethod(method).delegateTo(delegateMethod);
"annotationProvider").inject(annotationProvider); plasticClass.introduceMethod(ConduitMethods.GET_ANNOTATION).delegateTo(annotationProviderField);