示例#1
0
    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
      CopyOnWriteList core = copyOnWriteListConverter.unmarshal(reader, context);

      try {
        PersistedList r = (PersistedList) context.getRequiredType().newInstance();
        r.data.replaceBy(core);
        return r;
      } catch (InstantiationException e) {
        InstantiationError x = new InstantiationError();
        x.initCause(e);
        throw x;
      } catch (IllegalAccessException e) {
        IllegalAccessError x = new IllegalAccessError();
        x.initCause(e);
        throw x;
      }
    }
示例#2
0
      public Object createProxy() {
        final SimpleInterceptorFactoryContext factoryContext =
            new SimpleInterceptorFactoryContext();
        factoryContext.getContextData().put(Component.class, component);
        factoryContext.getContextData().put(ComponentView.class, View.this);
        factoryContext.getContextData().put(ComponentViewInstance.class, this);

        final Map<Method, InterceptorFactory> clientInterceptorFactories =
            ViewService.this.clientInterceptorFactories;
        final Map<Method, Interceptor> clientEntryPoints =
            new IdentityHashMap<Method, Interceptor>(clientInterceptorFactories.size());
        for (Method method : clientInterceptorFactories.keySet()) {
          clientEntryPoints.put(
              method, clientInterceptorFactories.get(method).create(factoryContext));
        }
        final Interceptor postConstructInterceptor = clientPostConstruct.create(factoryContext);
        try {
          Object object =
              proxyFactory.newInstance(
                  new ProxyInvocationHandler(clientEntryPoints, component, View.this, this));
          InterceptorContext interceptorContext = new InterceptorContext();
          interceptorContext.putPrivateData(ComponentView.class, View.this);
          interceptorContext.putPrivateData(ComponentViewInstance.class, this);
          interceptorContext.putPrivateData(Component.class, component);
          try {
            postConstructInterceptor.processInvocation(interceptorContext);
          } catch (Exception e) {
            InstantiationException exception =
                new InstantiationException("Post-construct lifecycle failed");
            exception.initCause(e);
            throw exception;
          }
          return object;
        } catch (InstantiationException e) {
          InstantiationError error = new InstantiationError(e.getMessage());
          Throwable cause = e.getCause();
          if (cause != null) error.initCause(cause);
          throw error;
        } catch (IllegalAccessException e) {
          IllegalAccessError error = new IllegalAccessError(e.getMessage());
          Throwable cause = e.getCause();
          if (cause != null) error.initCause(cause);
          throw error;
        }
      }