Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
0
    @Override
    public ConfigBeanProxy compute(final Class<?> proxyType) throws ComputationErrorException {

      ClassLoader cl;
      if (System.getSecurityManager() != null) {
        cl =
            AccessController.doPrivileged(
                new PrivilegedAction<ClassLoader>() {
                  @Override
                  public ClassLoader run() {
                    return proxyType.getClassLoader();
                  }
                });
      } else {
        cl = proxyType.getClassLoader();
      }

      ConfigBeanProxy retVal =
          (ConfigBeanProxy) Proxy.newProxyInstance(cl, new Class[] {proxyType}, dom);

      return retVal;
    }