示例#1
0
  @Override
  public void start() {
    InjectManager cdiManager = InjectManager.getCurrent();

    if (_authenticator == null) {
      Bean<Authenticator> bean = findAuthenticator(cdiManager);

      if (bean != null) {
        CreationalContext<Authenticator> env = cdiManager.createCreationalContext(bean);

        _authenticator = (Authenticator) cdiManager.getReference(bean, Authenticator.class, env);
      }
    }
  }
  public static Object generateDelegate(List<Decorator> beans, Object tail) {
    InjectManager webBeans = InjectManager.create();

    Bean parentBean = null;
    CreationalContext env = webBeans.createCreationalContext(parentBean);

    for (int i = beans.size() - 1; i >= 0; i--) {
      Decorator bean = beans.get(i);

      Object instance = webBeans.getReference(bean, bean.getBeanClass(), env);

      // XXX:
      // bean.setDelegate(instance, tail);

      tail = instance;
    }

    return tail;
  }
  public static Object[] generateProxyDelegate(
      InjectManager webBeans, List<Decorator<?>> beans, Object proxy) {
    Object[] instances = new Object[beans.size()];

    Bean parentBean = null;
    CreationalContext env = webBeans.createCreationalContext(parentBean);

    for (int i = 0; i < beans.size(); i++) {
      Decorator bean = beans.get(i);

      Object instance = webBeans.getReference(bean, bean.getBeanClass(), env);

      // XXX:
      ((DecoratorBean) bean).setDelegate(instance, proxy);

      instances[beans.size() - 1 - i] = instance;
    }

    return instances;
  }