/** * Returns a writeable view of a configuration object * @param source the configured interface implementation * @return the new interface implementation providing write access * @throws TransactionFailure if the object cannot be enrolled (probably already enrolled in * another transaction). */ public <T extends ConfigBeanProxy> T getWriteableView(final T source) throws TransactionFailure { T configBeanProxy = revealProxy(source); ConfigView sourceBean = (ConfigView) Proxy.getInvocationHandler(configBeanProxy); WriteableView writeableView = getWriteableView(configBeanProxy, (ConfigBean) sourceBean.getMasterView()); return (T) writeableView.getProxy(sourceBean.getProxyType()); }
@SuppressWarnings("unchecked") public <T extends ConfigBeanProxy> T transform(T source) { final ConfigView handler = (ConfigView) Proxy.getInvocationHandler(source); return (T) handler.getMasterView().getProxy(handler.getMasterView().getProxyType()); } };
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return getTranslatedValue(masterView.invoke(proxy, method, args)); }
/** * Return the main implementation bean for a proxy. * @param source configuration interface proxy * @return the implementation bean */ public static ConfigView getImpl(ConfigBeanProxy source) { Object bean = Proxy.getInvocationHandler(source); if (bean instanceof ConfigView) { return ((ConfigView) bean).getMasterView(); } else { return (ConfigBean) bean; } }
/** * Returns the type of configuration object this config proxy represents. * @param element is the configuration object * @return the configuration interface class */ public static <T extends ConfigBeanProxy> Class<T> proxyType(T element) { ConfigView bean = getImpl(element); return bean.getProxyType(); }
public WriteableView(ConfigBeanProxy readView) { this.bean = (ConfigBean) ((ConfigView) Proxy.getInvocationHandler(readView)).getMasterView(); this.defaultView = bean.createProxy(); changedAttributes = new HashMap<String, PropertyChangeEvent>(); changedCollections = new HashMap<String, ProtectedList>(); }
@Override public <T extends ConfigBeanProxy> Class<T> getProxyType() { return masterView.getProxyType(); }
/** * Enroll a configuration object in a transaction and returns a writeable view of it * * @param source the configured interface implementation * @return the new interface implementation providing write access * @throws TransactionFailure if the object cannot be enrolled (probably already enrolled in * another transaction). */ public <T extends ConfigBeanProxy> T enroll(final T source) throws TransactionFailure { T configBeanProxy = ConfigSupport.revealProxy(source); ConfigView sourceBean = (ConfigView) Proxy.getInvocationHandler(configBeanProxy); WriteableView writeableView = ConfigSupport.getWriteableView(configBeanProxy, (ConfigBean) sourceBean.getMasterView()); if (!writeableView.join(this)) { throw new TransactionFailure("Cannot join transaction : " + sourceBean.getProxyType()); } return (T) writeableView.getProxy(sourceBean.getProxyType()); }
/** * Unwraps the proxy and returns the underlying {@link Dom} object. * * @return * null if the given instance is not actually a proxy to a DOM. */ public static Dom unwrap(ConfigBeanProxy proxy) { ConfigBeanProxy configBeanProxy = ConfigSupport.revealProxy(proxy); InvocationHandler ih = Proxy.getInvocationHandler(configBeanProxy); if (ih instanceof Dom) return (Dom) ih; if (ih instanceof ConfigView) { return (Dom) ((ConfigView)ih).getMasterView(); } return null; }
@SuppressWarnings("unchecked") public <T extends ConfigBeanProxy> T transform(T source) { final ConfigView handler = (ConfigView) Proxy.getInvocationHandler(source); return (T) handler.getMasterView().getProxy(handler.getMasterView().getProxyType()); } };
@Override public <T extends ConfigBeanProxy> Class<T> getProxyType() { return masterView.getProxyType(); }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return getTranslatedValue(masterView.invoke(proxy, method, args)); }
+ ConfigSupport.getImpl(ejb).getClass().getName()); System.out.println("getImpl(ejb).getMasterView() == > " + ConfigSupport.getImpl(ejb).getMasterView().getClass().getName()); System.out.println("getImpl(ejb).getProxyType() == > " + ConfigSupport.getImpl(ejb).getProxyType().getClass().getName()); } catch (Exception e) { e.printStackTrace();
ConfigView handler = ((ConfigView) Proxy.getInvocationHandler(object)).getMasterView(); for (int index = 0 ; index<proxied.size() && !removed; index++) { Object target = proxied.get(index); try { ConfigView targetHandler = ((ConfigView) Proxy.getInvocationHandler(target)).getMasterView(); if (targetHandler==handler) { removed = (proxied.remove(index)!=null);
@SuppressWarnings("unchecked") public <T extends ConfigBeanProxy> T transform(T source) { final ConfigView handler = (ConfigView) Proxy.getInvocationHandler(source); return (T) handler.getMasterView().getProxy(handler.getMasterView().getProxyType()); } };
public <T extends ConfigBeanProxy> Class<T> getProxyType() { return masterView.getProxyType(); }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return getTranslatedValue(masterView.invoke(proxy, method, args)); }
/** * Returns a writeable view of a configuration object * @param source the configured interface implementation * @return the new interface implementation providing write access * @throws TransactionFailure if the object cannot be enrolled (probably already enrolled in * another transaction). */ public <T extends ConfigBeanProxy> T getWriteableView(final T source) throws TransactionFailure { ConfigView sourceBean = (ConfigView) Proxy.getInvocationHandler(source); WriteableView writeableView = getWriteableView(source, (ConfigBean) sourceBean.getMasterView()); return (T) writeableView.getProxy(sourceBean.getProxyType()); }
if (job.mEvents != null) { for (PropertyChangeEvent event : job.mEvents) { final Dom dom = (Dom) ((ConfigView) Proxy.getInvocationHandler(event.getSource())).getMasterView(); configListeners.addAll(dom.getListeners());
@SuppressWarnings("unchecked") public <T extends ConfigBeanProxy> T transform(T source) { final ConfigView handler = (ConfigView) Proxy.getInvocationHandler(source); return (T) handler.getMasterView().getProxy(handler.getMasterView().getProxyType()); } };