/** * 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; }
/** * 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()); }
/** * 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; }
/** * 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; }
/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * 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()); }