Refine search
private void loadBeanInstance(ClassFile file, MethodInformation methodInfo, CodeAttribute b) { b.aload(0); getMethodHandlerField(file, b); // lets invoke the method b.invokevirtual(ProxyMethodHandler.class.getName(), "getInstance", EMPTY_PARENTHESES + LJAVA_LANG_OBJECT); b.checkcast(methodInfo.getDeclaringClass()); }
private void generateWeldClientProxyMethod(ClassFile proxyClassType) { try { Method getContextualMetadata = WeldClientProxy.class.getMethod("getMetadata"); generateBodyForWeldClientProxyMethod(proxyClassType.addMethod(getContextualMetadata)); } catch (Exception e) { throw new WeldException(e); } }
@Override protected void addMethods(ClassFile proxyClassType, ClassMethod staticConstructor) { // delegate to ProxyFactory#addMethods super.addMethods(proxyClassType, staticConstructor); // add method from WeldClientProxy generateWeldClientProxyMethod(proxyClassType); }
private void generateBodyForWeldClientProxyMethod(ClassMethod method) throws Exception { // ProxyMethodHandler implements ContextualMetadata, so let's just return reference to it final CodeAttribute b = method.getCodeAttribute(); b.aload(0); getMethodHandlerField(method.getClassFile(), b); b.returnInstruction(); }
private <T> T createClientProxy(Bean<T> bean, Set<Type> types) { BeanIdentifier id = Container.instance(contextId).services().get(ContextualStore.class).putIfAbsent(bean); if (id == null) { throw BeanLogger.LOG.beanIdCreationFailed(bean); } BeanInstance beanInstance = new ContextBeanInstance<T>(bean, id, contextId); TypeInfo typeInfo = TypeInfo.of(types); T proxy = new ClientProxyFactory<T>(contextId, typeInfo.getSuperClass(), types, bean).create(beanInstance); BeanLogger.LOG.createdNewClientProxyType(proxy.getClass(), bean, id); return proxy; }
final Method method = methodInfo.getMethod(); createInterceptorBody(classMethod, methodInfo, staticConstructor); return;
@Override public T create(BeanInstance beanInstance) { try { final T instance = super.create(beanInstance); if (beanIdField == null) { final Field f = SecurityActions.getDeclaredField(instance.getClass(), BEAN_ID_FIELD); SecurityActions.ensureAccessible(f); beanIdField = f; } if (contextIdField == null) { final Field f = SecurityActions.getDeclaredField(instance.getClass(), CONTEXT_ID_FIELD); SecurityActions.ensureAccessible(f); contextIdField = f; } beanIdField.set(instance, beanId); contextIdField.set(instance, getContextId()); return instance; } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (NoSuchFieldException e) { throw new RuntimeException(e.getCause()); } }
private void generateBodyForWeldClientProxyMethod(ClassMethod method) throws Exception { // ProxyMethodHandler implements ContextualMetadata, so let's just return reference to it final CodeAttribute b = method.getCodeAttribute(); b.aload(0); getMethodHandlerField(method.getClassFile(), b); b.returnInstruction(); }
private <T> T createClientProxy(Bean<T> bean, Set<Type> types) { BeanIdentifier id = Container.instance(contextId).services().get(ContextualStore.class).putIfAbsent(bean); if (id == null) { throw BeanLogger.LOG.beanIdCreationFailed(bean); } BeanInstance beanInstance = new ContextBeanInstance<T>(bean, id, contextId); TypeInfo typeInfo = TypeInfo.of(types); T proxy = new ClientProxyFactory<T>(contextId, typeInfo.getSuperClass(), types, bean).create(beanInstance); BeanLogger.LOG.createdNewClientProxyType(proxy.getClass(), bean, id); return proxy; }
final Method method = methodInfo.getMethod(); createInterceptorBody(classMethod, methodInfo, staticConstructor); return;
@Override public T create(BeanInstance beanInstance) { try { final T instance = super.create(beanInstance); if (beanIdField == null) { final Field f = SecurityActions.getDeclaredField(instance.getClass(), BEAN_ID_FIELD); SecurityActions.ensureAccessible(f); beanIdField = f; } if (contextIdField == null) { final Field f = SecurityActions.getDeclaredField(instance.getClass(), CONTEXT_ID_FIELD); SecurityActions.ensureAccessible(f); contextIdField = f; } beanIdField.set(instance, beanId); contextIdField.set(instance, getContextId()); return instance; } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (NoSuchFieldException e) { throw new RuntimeException(e.getCause()); } }
private void loadBeanInstance(ClassFile file, MethodInformation methodInfo, CodeAttribute b) { b.aload(0); getMethodHandlerField(file, b); // lets invoke the method b.invokevirtual(ProxyMethodHandler.class.getName(), "getInstance", EMPTY_PARENTHESES + LJAVA_LANG_OBJECT); b.checkcast(methodInfo.getDeclaringClass()); }
private void generateBodyForWeldClientProxyMethod(ClassMethod method) throws Exception { // ProxyMethodHandler implements ContextualMetadata, so let's just return reference to it final CodeAttribute b = method.getCodeAttribute(); b.aload(0); getMethodHandlerField(method.getClassFile(), b); b.returnInstruction(); }
private <T> T createClientProxy(Bean<T> bean, Set<Type> types) { BeanIdentifier id = Container.instance(contextId).services().get(ContextualStore.class).putIfAbsent(bean); if (id == null) { throw BeanLogger.LOG.beanIdCreationFailed(bean); } BeanInstance beanInstance = new ContextBeanInstance<T>(bean, id, contextId); TypeInfo typeInfo = TypeInfo.of(types); T proxy = new ClientProxyFactory<T>(contextId, typeInfo.getSuperClass(), types, bean).create(beanInstance); BeanLogger.LOG.createdNewClientProxyType(proxy.getClass(), bean, id); return proxy; }
final Method method = methodInfo.getMethod(); createInterceptorBody(classMethod, methodInfo, staticConstructor); return;
@Override public T create(BeanInstance beanInstance) { try { final T instance = super.create(beanInstance); if (beanIdField == null) { final Field f = SecurityActions.getDeclaredField(instance.getClass(), BEAN_ID_FIELD); SecurityActions.ensureAccessible(f); beanIdField = f; } if (contextIdField == null) { final Field f = SecurityActions.getDeclaredField(instance.getClass(), CONTEXT_ID_FIELD); SecurityActions.ensureAccessible(f); contextIdField = f; } beanIdField.set(instance, beanId); contextIdField.set(instance, getContextId()); return instance; } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (NoSuchFieldException e) { throw new RuntimeException(e.getCause()); } }
@Override protected void addMethods(ClassFile proxyClassType, ClassMethod staticConstructor) { // delegate to ProxyFactory#addMethods super.addMethods(proxyClassType, staticConstructor); // add method from WeldClientProxy generateWeldClientProxyMethod(proxyClassType); }
private void generateWeldClientProxyMethod(ClassFile proxyClassType) { try { Method getContextualMetadata = WeldClientProxy.class.getMethod("getMetadata"); generateBodyForWeldClientProxyMethod(proxyClassType.addMethod(getContextualMetadata)); } catch (Exception e) { throw new WeldException(e); } }
private void loadBeanInstance(ClassFile file, MethodInformation methodInfo, CodeAttribute b) { b.aload(0); getMethodHandlerField(file, b); // lets invoke the method b.invokevirtual(ProxyMethodHandler.class.getName(), "getInstance", EMPTY_PARENTHESES + LJAVA_LANG_OBJECT); b.checkcast(methodInfo.getDeclaringClass()); }
private void generateBodyForWeldClientProxyMethod(ClassMethod method) throws Exception { // ProxyMethodHandler implements ContextualMetadata, so let's just return reference to it final CodeAttribute b = method.getCodeAttribute(); b.aload(0); getMethodHandlerField(method.getClassFile(), b); b.returnInstruction(); }