Package com.caucho.config.inject

Examples of com.caucho.config.inject.InjectManager$TypedBean


                                       _authMethod));

      if (_authenticator != null)
        login.setAuthenticator(_authenticator);

      InjectManager manager = InjectManager.create();
      InjectionTarget inject = manager.createInjectionTarget(login.getClass());
      inject.inject(login, manager.createCreationalContext(null));

      login.init();

      return login;
    } catch (Exception e) {
View Full Code Here


   
    resin.preConfigureInit();
   
    // XXX: needs to be config

    InjectManager cdiManager = InjectManager.create();

    Config.setProperty("resinHome", elContext.getResinHome());
    Config.setProperty("resin", elContext.getResinVar());
    Config.setProperty("server", elContext.getServerVar());
    Config.setProperty("java", elContext.getJavaVar());
    Config.setProperty("system", System.getProperties());
    Config.setProperty("getenv", System.getenv());

    ResinConfigLibrary.configure(cdiManager);

    _watchdogPort = _args.getWatchdogPort();
   
    readConfig(_args);
   
    WatchdogChild server = null;
   
    String serverId = _args.getServerId();

    if (_args.isDynamicServer()) {
      serverId = _args.getDynamicServerId();
    }
     
    server = _watchdogMap.get(_args.getServerId());

    if (server == null)
      throw new IllegalStateException(L().l("'{0}' is an unknown server",
                                            serverId));
   
    JniBoot boot = new JniBoot();
    Path logDirectory = getLogDirectory();

    if (boot.isValid()) {
      if (! isLogDirectoryExists) {
        logDirectory.mkdirs();

        boot.chown(logDirectory, server.getUserName(), server.getGroupName());
      }
    }

    server.getConfig().logInit(logStream);

    resin.preConfigureInit();
    resin.setConfigFile(_args.getResinConf().getNativePath());

    thread = Thread.currentThread();
    thread.setContextClassLoader(resin.getClassLoader());

    CloudSystem cloudSystem = TopologyService.getCurrent().getSystem();
   
    CloudCluster cluster = cloudSystem.createCluster("watchdog");
    CloudPod pod = cluster.createPod();
    pod.createStaticServer("default", "localhost", -1, false);

    _server = resin.createServer();
   
    thread.setContextClassLoader(_server.getClassLoader());
   
   
    NetworkListenSystem listenService
      = _system.getService(NetworkListenSystem.class);
   
    _httpPort = new TcpSocketLinkListener();
    _httpPort.setProtocol(new HttpProtocol());

    if (_watchdogPort > 0)
      _httpPort.setPort(_watchdogPort);
    else
      _httpPort.setPort(server.getWatchdogPort());

    _httpPort.setAddress(server.getWatchdogAddress());

    _httpPort.setAcceptThreadMin(2);
    _httpPort.setAcceptThreadMax(3);

    _httpPort.init();

    listenService.addListener(_httpPort);
   
    ClassLoader oldLoader = thread.getContextClassLoader();

    try {
      thread.setContextClassLoader(_system.getClassLoader());

      cdiManager = InjectManager.create();
      AdminAuthenticator auth = null;

      if (_management != null)
        auth = _management.getAdminAuthenticator();

      if (auth != null) {
        BeanBuilder<Authenticator> factory = cdiManager.createBeanFactory(Authenticator.class);

        factory.type(Authenticator.class);
        factory.type(AdminAuthenticator.class);
        factory.qualifier(DefaultLiteral.DEFAULT);

        cdiManager.addBean(factory.singleton(auth));
      }

      DependencyCheckInterval depend = new DependencyCheckInterval();
      depend.setValue(new Period(-1));
      depend.init();
View Full Code Here

  {
    try {
      if (_auth != null) {
        _auth.init();
     
        InjectManager manager = InjectManager.create();
        BeanBuilder<?> factory = manager.createBeanFactory(Authenticator.class);
        factory.type(Authenticator.class);
        factory.type(AdminAuthenticator.class);

        manager.addBean(factory.singleton(_auth));
      }
    } catch (Exception e) {
      e.printStackTrace();
      throw ConfigException.create(e);
    }
View Full Code Here

   * Configures the bean (for internal use)
   */
  protected void configure()
  {
    try {
      InjectManager cdiManager = InjectManager.create();
     
      if (_value != null) {
        BeanBuilder<?> factory = cdiManager.createBeanFactory(_value.getClass());

        if (_name != null)
          factory.name(_name);

        cdiManager.addBean(factory.singleton(_value));
      }
      else if (_className == null)
        throw new ConfigException(L.l("BeanEmbed must either have a value or a class"));
      else {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();

        Class<?> cl = Class.forName(_className, false, loader);

        BeanBuilder<?> factory = cdiManager.createBeanFactory(cl);

        factory.scope(ApplicationScoped.class);

        if (_name != null)
          factory.name(_name);

        if (_init != null)
          factory.init(_init);

        cdiManager.addBean(factory.bean());
      }
    } catch (Exception e) {
      throw ConfigException.create(e);
    }
  }
View Full Code Here

    /**
     * XXX: the following setVar calls should not be necessary, but the
     * EL.setEnviornment() call above is not effective:
     */
    InjectManager beanManager = InjectManager.create();

    Config.setProperty("resinHome", elContext.getResinHome());
    Config.setProperty("java", elContext.getJavaVar());
    Config.setProperty("resin", elContext.getResinVar());
    Config.setProperty("server", elContext.getServerVar());
View Full Code Here

  {
    if (getProtocol() != null) {

    }
    else if (_protocolClass != null) {
      InjectManager webBeans = InjectManager.create();

      /*
      Protocol protocol
        = (Protocol) webBeans.createTransientObjectNoInit(_protocolClass);
      */
      InjectionTarget target = webBeans.createInjectionTarget(_protocolClass);
      CreationalContext env = webBeans.createCreationalContext(null);

      AbstractProtocol protocol = (AbstractProtocol) target.produce(env);
      target.inject(protocol, env);

      if (_init != null)
View Full Code Here

                             boolean isTop)
  {
    if (ejbClass == null)
      return;
   
    InjectManager cdiManager = InjectManager.getCurrent();

    for (Type localApi : ejbClass.getGenericInterfaces()) {
      BaseType type = cdiManager.createTargetBaseType(localApi);
     
      Class<?> rawClass = type.getRawClass();
     
      Local local = rawClass.getAnnotation(Local.class);
View Full Code Here

  private <X> void addClassByName(String className, String moduleName)
  {
    try {
      ClassLoader loader = _ejbManager.getClassLoader();
     
      InjectManager manager = InjectManager.create(loader);
     
      Class<X> type = loadClass(className, loader);
     
      AnnotatedType<X> annType = manager.createAnnotatedType(type);
     
      if (annType.isAnnotationPresent(ManagedBean.class)) {
        // ioc/00b0
        manager.discoverBean(annType);
        return;
      }
     
      addAnnotatedType(annType, annType, null, moduleName);
    }
View Full Code Here

    return server;
  }
 
  private void deployBindings(ArrayList<AnnotatedType<?>> bindTypes)
  {
    InjectManager cdiManager = _ejbManager.getInjectManager();

    for (AnnotatedType<?> annType : bindTypes) {
      // ioc/123q
      cdiManager.getInjectionPointHandler(EJBs.class).introspectType(annType);
     
      cdiManager.getInjectionPointHandler(DataSourceDefinition.class).introspectType(annType);
      cdiManager.getInjectionPointHandler(DataSourceDefinitions.class).introspectType(annType);
    }
  }
View Full Code Here

  private void resolve()
  {
    Destination destination = null;

    InjectManager webBeans = InjectManager.create();

    String name = _mappedName;

    if (name == null)
      name = _messageDestinationName;
View Full Code Here

TOP

Related Classes of com.caucho.config.inject.InjectManager$TypedBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.