예제 #1
0
파일: Dom.java 프로젝트: hk2-project/hk2
 /**
  * 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;
 }
예제 #2
0
파일: Dom.java 프로젝트: hk2-project/hk2
    @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;
    }