public Object getPrimaryKey() { return ((BaseEjbProxyHandler) org.apache.openejb.util.proxy.ProxyManager.getInvocationHandler(theProxy)).primaryKey; }
public static InvocationHandler getInvocationHandler(Object proxy) { checkDefaultFactory(); return defaultFactory.getInvocationHandler(proxy); }
public static synchronized ProxyFactory setDefaultFactory(final String factoryName) { final ProxyFactory newFactory = getFactory(factoryName); if (newFactory == null) { return defaultFactory; } final ProxyFactory oldFactory = defaultFactory; defaultFactory = newFactory; defaultFactoryName = factoryName; return oldFactory; }
private Collection<Class<?>> getContextTypes(final Object resourceObject) { if (!ProxyManager.isProxyClass(resourceObject.getClass()) && !LocalBeanProxyFactory.isProxy(resourceObject.getClass())) { return Collections.emptySet(); } final InvocationHandler handler = ProxyManager.getInvocationHandler(resourceObject); if (!(handler instanceof BeanContextInvocationHandler)) { return Collections.emptySet(); } final BeanContext beanContext = ((BeanContextInvocationHandler) handler).getBeanContext(); if (beanContext == null) { return Collections.emptySet(); } return contextTypes.get(beanContext.getBeanClass()); }
public static Object newProxyInstance(final Class interfaceType, final InvocationHandler h) throws IllegalAccessException { return newProxyInstance(new Class[]{interfaceType}, h); }
public void createProxyFactory(final ProxyFactoryInfo serviceInfo) throws OpenEJBException { final ObjectRecipe serviceRecipe = createRecipe(serviceInfo); final Object service = serviceRecipe.create(); logUnusedProperties(serviceRecipe, serviceInfo); final Class interfce = serviceInterfaces.get(serviceInfo.service); checkImplementation(interfce, service.getClass(), serviceInfo.service, serviceInfo.id); ProxyManager.registerFactory(serviceInfo.id, (ProxyFactory) service); ProxyManager.setDefaultFactory(serviceInfo.id); bindService(serviceInfo, service); setSystemInstanceComponent(interfce, service); getContext().put(interfce.getName(), service); props.put(interfce.getName(), service); props.put(serviceInfo.service, service); props.put(serviceInfo.id, service); // Update the config tree config.facilities.intraVmServer = serviceInfo; logger.getChildLogger("service").debug("createService.success", serviceInfo.service, serviceInfo.id, serviceInfo.className); }
public static Class getProxyClass(final Class interfaceType) throws IllegalAccessException { return getProxyClass(new Class[]{interfaceType}); }
public static Object newProxyInstance(final Class interfaceType, final InvocationHandler h) throws IllegalAccessException { return newProxyInstance(new Class[]{interfaceType}, h); }
private void destroyScopedStateful(final T instance, final CreationalContext<T> cc) { try { instance.hashCode(); // force the instance to be created - otherwise we'll miss @PreDestroy for instance } catch (final NoSuchEJBException e) { InvocationHandler handler = null; if (LocalBeanProxyFactory.isProxy(instance.getClass())) { handler = LocalBeanProxyFactory.getInvocationHandler(instance); } else if (ProxyManager.isProxyClass(instance.getClass())) { handler = ProxyManager.getInvocationHandler(instance); } if (BaseEjbProxyHandler.class.isInstance(handler) && !BaseEjbProxyHandler.class.cast(handler).isValid()) { return; // already destroyed } // else log error logger.log(Level.FINE, "The stateful instance " + instance + " can't be removed since it was invalidated", e); return; } final Object ejbInstance = dependentSFSBToBeRemoved.remove(System.identityHashCode(instance)); if (ejbInstance != null) { destroyStatefulSessionBeanInstance((T) ejbInstance, cc); } else { destroyStatefulSessionBeanInstance(instance, cc); } }
public void createProxyFactory(final ProxyFactoryInfo serviceInfo) throws OpenEJBException { final ObjectRecipe serviceRecipe = createRecipe(Collections.<ServiceInfo>emptyList(), serviceInfo); final Object service = serviceRecipe.create(); logUnusedProperties(serviceRecipe, serviceInfo); final Class interfce = serviceInterfaces.get(serviceInfo.service); checkImplementation(interfce, service.getClass(), serviceInfo.service, serviceInfo.id); ProxyManager.registerFactory(serviceInfo.id, (ProxyFactory) service); ProxyManager.setDefaultFactory(serviceInfo.id); bindService(serviceInfo, service); setSystemInstanceComponent(interfce, service); getContext().put(interfce.getName(), service); props.put(interfce.getName(), service); props.put(serviceInfo.service, service); props.put(serviceInfo.id, service); // Update the config tree config.facilities.intraVmServer = serviceInfo; logger.getChildLogger("service").debug("createService.success", serviceInfo.service, serviceInfo.id, serviceInfo.className); }
public static Class getProxyClass(Class interfaceType) throws IllegalAccessException { return getProxyClass(new Class[]{interfaceType}); }
public Object getPrimaryKey() { return ((BaseEjbProxyHandler) ProxyManager.getInvocationHandler(theProxy)).primaryKey; }
public static Object newProxyInstance(Class interfaceType, InvocationHandler h) throws IllegalAccessException { return newProxyInstance(new Class[]{interfaceType}, h); }
private void destroyScopedStateful(final T instance, final CreationalContext<T> cc) { try { instance.hashCode(); // force the instance to be created - otherwise we'll miss @PreDestroy for instance } catch (final NoSuchEJBException e) { InvocationHandler handler = null; if (LocalBeanProxyFactory.isProxy(instance.getClass())) { handler = LocalBeanProxyFactory.getInvocationHandler(instance); } else if (ProxyManager.isProxyClass(instance.getClass())) { handler = ProxyManager.getInvocationHandler(instance); } if (BaseEjbProxyHandler.class.isInstance(handler) && !BaseEjbProxyHandler.class.cast(handler).isValid()) { return; // already destroyed } // else log error logger.log(Level.FINE, "The stateful instance " + instance + " can't be removed since it was invalidated", e); return; } final Object ejbInstance = dependentSFSBToBeRemoved.remove(System.identityHashCode(instance)); if (ejbInstance != null) { destroyStatefulSessionBeanInstance((T) ejbInstance, cc); } else { destroyStatefulSessionBeanInstance(instance, cc); } }
public static Object newProxyInstance(final Class[] interfaces, final InvocationHandler h) throws IllegalAccessException { checkDefaultFactory(); return defaultFactory.newProxyInstance(interfaces, h); }
public void createProxyFactory(ProxyFactoryInfo serviceInfo) throws OpenEJBException { ObjectRecipe serviceRecipe = createRecipe(serviceInfo); Object service = serviceRecipe.create(); logUnusedProperties(serviceRecipe, serviceInfo); Class interfce = serviceInterfaces.get(serviceInfo.service); checkImplementation(interfce, service.getClass(), serviceInfo.service, serviceInfo.id); ProxyManager.registerFactory(serviceInfo.id, (ProxyFactory) service); ProxyManager.setDefaultFactory(serviceInfo.id); bindService(serviceInfo, service); setSystemInstanceComponent(interfce, service); getContext().put(interfce.getName(), service); props.put(interfce.getName(), service); props.put(serviceInfo.service, service); props.put(serviceInfo.id, service); // Update the config tree config.facilities.intraVmServer = serviceInfo; logger.getChildLogger("service").debug("createService.success", serviceInfo.service, serviceInfo.id, serviceInfo.className); }
public static synchronized ProxyFactory setDefaultFactory(String factoryName) { ProxyFactory newFactory = getFactory(factoryName); if (newFactory == null) return defaultFactory; ProxyFactory oldFactory = defaultFactory; defaultFactory = newFactory; defaultFactoryName = factoryName; return oldFactory; }
public static Class getProxyClass(final Class interfaceType) throws IllegalAccessException { return getProxyClass(new Class[]{interfaceType}); }
public Object getPrimaryKey() { return ((BaseEjbProxyHandler) ProxyManager.getInvocationHandler(theProxy)).primaryKey; }
public static Object createHomeProxy(DeploymentInfo deploymentInfo, InterfaceType interfaceType, List<Class> objectInterfaces) { if (!interfaceType.isHome()) throw new IllegalArgumentException("InterfaceType is not a Home type: " + interfaceType); try { EjbHomeProxyHandler handler = createHomeHandler(deploymentInfo, interfaceType, objectInterfaces); List<Class> proxyInterfaces = new ArrayList<Class>(2); Class homeInterface = deploymentInfo.getInterface(interfaceType); proxyInterfaces.add(homeInterface); proxyInterfaces.add(IntraVmProxy.class); return ProxyManager.newProxyInstance(proxyInterfaces.toArray(new Class[]{}), handler); } catch (Exception e) { throw new RuntimeException("Can't create EJBHome stub" + e.getMessage(), e); } }