public JDKInvocationHandler(MessageFactory messageFactory, ServiceReference<?> callableReference) { this.messageFactory = messageFactory; this.callableReference = (ServiceReferenceExt<?>)callableReference; if (callableReference != null) { this.businessInterface = callableReference.getBusinessInterface(); this.source = (RuntimeEndpointReference) this.callableReference.getEndpointReference(); } }
public <B> ServiceReference<B> cast( B target ) throws IllegalArgumentException { if( !(target instanceof ServiceReference<?>) ) { String msg = "Not a reference: "+target; throw new IllegalArgumentException(msg); } ServiceReference<?> ci = (ServiceReference<?>) target; Class<?> businessInterface = ci.getBusinessInterface(); Object service = ci.getService(); // Create a ServiceReference String signature = businessInterface.getName(); String clname = signature+"FcSR"; try { Class<?> cl = Class.forName(clname); Constructor<?>[] ctrs = cl.getConstructors(); Constructor<?> ctr = ctrs[0]; Object sr = ctr.newInstance(businessInterface,service); @SuppressWarnings("unchecked") ServiceReference<B> ret = (ServiceReference<B>) sr; return ret; } catch (Exception e) { throw new IllegalArgumentException(e); } }
/** * @see org.ow2.frascati.tinfi.control.component.ComponentContextMixin#cast(B) */ public <B> ServiceReference<B> cast(B target) throws IllegalArgumentException { if (!(target instanceof ServiceReference<?> )) { String msg = "Not a reference: " + target; throw new IllegalArgumentException(msg); } ServiceReference<?> ci = ((ServiceReference<?> )(target)); Class<?> businessInterface = ci.getBusinessInterface(); Object service = ci.getService(); String signature = businessInterface.getName(); String clname = signature + "FcSR"; try { Class<?> cl = Class.forName(clname); Constructor<?> [] ctrs = cl.getConstructors(); Constructor<?> ctr = ctrs[0]; Object sr = ctr.newInstance(businessInterface ,service); @SuppressWarnings(value = "unchecked") ServiceReference<B> ret = ((ServiceReference<B> )(sr)); return ret; } catch (Exception e) { throw new IllegalArgumentException(e); } }
/** * create the proxy with cglib. use the same JDKInvocationHandler as * JDKProxyService. */ public <T> T createProxy(ServiceReference<T> callableReference) throws ProxyCreationException { Enhancer enhancer = new Enhancer(); Class<T> interfaze = callableReference.getBusinessInterface(); enhancer.setSuperclass(interfaze); enhancer.setCallback(new CglibMethodInterceptor<T>(callableReference)); Object proxy = enhancer.create(); ((ServiceReferenceImpl)callableReference).setProxy(proxy); return interfaze.cast(proxy); }
/** * @see org.ow2.frascati.tinfi.control.component.ComponentContextMixin#cast(B) */ public <B> org.oasisopen.sca.ServiceReference<B> cast(B target) throws java.lang.IllegalArgumentException { if (!(target instanceof org.oasisopen.sca.ServiceReference<?>)) { java.lang.String msg = "Not a reference: " + target; throw new java.lang.IllegalArgumentException(msg); } org.oasisopen.sca.ServiceReference<?> ci = ((org.oasisopen.sca.ServiceReference<?>) (target)); java.lang.Class<?> businessInterface = ci.getBusinessInterface(); java.lang.Object service = ci.getService(); java.lang.String signature = businessInterface.getName(); java.lang.String clname = signature + "FcSR"; try { java.lang.Class<?> cl = java.lang.Class.forName(clname); java.lang.reflect.Constructor<?>[] ctrs = cl.getConstructors(); java.lang.reflect.Constructor<?> ctr = ctrs[0]; java.lang.Object sr = ctr.newInstance(businessInterface, service); @java.lang.SuppressWarnings("unchecked") org.oasisopen.sca.ServiceReference<B> ret = ((org.oasisopen.sca.ServiceReference<B>) (sr)); return ret; } catch (java.lang.Exception e) { throw new java.lang.IllegalArgumentException(e); } }
/** * create the callback proxy with cglib. use the same * JDKCallbackInvocationHandler as JDKProxyService. */ public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException { Enhancer enhancer = new Enhancer(); Class<T> interfaze = callbackReference.getBusinessInterface(); enhancer.setSuperclass(interfaze); enhancer.setCallback(new CglibMethodInterceptor<T>(callbackReference)); Object object = enhancer.create(); T proxy = interfaze.cast(object); ((ServiceReferenceExt<T>)callbackReference).setProxy(proxy); return proxy; }
public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException { assert callbackReference != null; final Class<T> interfaze = callbackReference.getBusinessInterface(); InvocationHandler handler = new JDKCallbackInvocationHandler(messageFactory, callbackReference); ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { public ClassLoader run() { return interfaze.getClassLoader(); } }); T proxy = interfaze.cast(newProxyInstance(cl, new Class[] {interfaze}, handler)); ((ServiceReferenceExt<T>)callbackReference).setProxy(proxy); return proxy; }
public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException { ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory(); ProxyFactory classFactory = proxyFactories.getClassProxyFactory(); if (callbackReference.getBusinessInterface().isInterface()) { return interfaceFactory.createCallbackProxy(callbackReference); } else { return classFactory.createCallbackProxy(callbackReference); } }
public <T> T createProxy(ServiceReference<T> callableReference) throws ProxyCreationException { assert callableReference != null; final Class<T> interfaze = callableReference.getBusinessInterface(); InvocationHandler handler; // TUSCANY-3659 - Always install a asynch handler regardless of whether ref is sync or async // needs tidying // if (isAsync(interfaze)) { handler = new AsyncJDKInvocationHandler(registry, messageFactory, callableReference); // } else { // handler = new JDKInvocationHandler(messageFactory, callableReference); // } // Allow privileged access to class loader. Requires RuntimePermission in security policy. ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { public ClassLoader run() { return interfaze.getClassLoader(); } }); T proxy = interfaze.cast(newProxyInstance(cl, new Class[] {interfaze}, handler)); ((ServiceReferenceExt<T>)callableReference).setProxy(proxy); return proxy; }
public <T> T createProxy(ServiceReference<T> callableReference) throws ProxyCreationException { ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory(); ProxyFactory classFactory = proxyFactories.getClassProxyFactory(); if (callableReference.getBusinessInterface().isInterface()) { return interfaceFactory.createProxy(callableReference); } else { return classFactory.createProxy(callableReference); } }
if( ! cm.isEmpty() ) { ServiceReference<?> cr = cm.peek(); Class<?> businessItf = cr.getBusinessInterface();