Package com.caucho.config.inject

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


        return;

      if (_auth != null) {
        _auth.init();

        InjectManager cdiManager = InjectManager.create();
        BeanBuilder<?> factory = cdiManager.createBeanFactory(Authenticator.class);
        factory.type(Authenticator.class);
        factory.type(AdminAuthenticator.class);
       
        factory.qualifier(DefaultLiteral.DEFAULT);
        factory.qualifier(new AdminLiteral());

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

      if (_transactionManager != null)
        _transactionManager.start();
    } catch (Exception e) {
View Full Code Here


   * Creates the webApp.
   */
  @Override
  protected void configureInstanceVariables(WebApp webApp)
  {
    InjectManager beanManager = InjectManager.create();
    BeanBuilder<WebApp> factory = beanManager.createBeanFactory(WebApp.class);
    factory.type(WebApp.class);
    factory.type(ServletContext.class);
    // factory.stereotype(CauchoDeploymentLiteral.create());

    beanManager.addBean(factory.singleton(webApp));

    Config.setProperty("webApp", getVar());
    Config.setProperty("app", getVar());

    webApp.setRegexp(_regexpValues);
View Full Code Here

      //  setRootDirectory(Vfs.getPwd());

      Environment.addChildLoaderListener(new ListenerPersistenceEnvironment());
      Environment.addChildLoaderListener(new WebBeansAddLoaderListener());
      Environment.addChildLoaderListener(new EjbEnvironmentListener());
      InjectManager cdiManager = InjectManager.create();
     
      ResinVar resinVar = new ResinVar(getServerId(),
                                       getResinHome(),
                                       getRootDirectory(),
                                       getResinConf(),
                                       isProfessional(),
                                       null);

      Config.setProperty("resinHome", getResinHome());
      Config.setProperty("resin", resinVar);
      Config.setProperty("server", resinVar);
      Config.setProperty("java", new JavaVar());
      Config.setProperty("system", System.getProperties());
      Config.setProperty("getenv", System.getenv());

      // _management = createResinManagement();

      if (cdiManager.getBeans(ResinCdiProducer.class).size() == 0) {
        Config.setProperty("fmt", new FmtFunctions());

        ResinConfigLibrary.configure(cdiManager);

        try {
          Method method = Jndi.class.getMethod("lookup", new Class[] { String.class });
          Config.setProperty("jndi", method);
          Config.setProperty("jndi:lookup", method);
        } catch (Exception e) {
          throw ConfigException.create(e);
        }

        cdiManager.addManagedBean(cdiManager.createManagedBean(ResinCdiProducer.class));
        Class<?> resinValidatorClass = ResinCdiProducer.createResinValidatorProducer();
       
        if (resinValidatorClass != null)
          cdiManager.addManagedBean(cdiManager.createManagedBean(resinValidatorClass));

        cdiManager.update();
      }

      _threadPoolAdmin = ThreadPoolAdmin.create();
      _resinAdmin = new ResinAdmin(this);
View Full Code Here

    if (ra == null) {
      throw new ConfigException(L.l("'{0}' does not have a defined resource-adapter.  Check the rar or META-INF/resin-ra.xml files",
                                    cl.getName()));
    }

    InjectManager webBeans = InjectManager.create();
   
    _raController
      = webBeans.getReference(ResourceAdapterController.class,
                              Names.create(ra.getResourceAdapterClass().getName()));
   
    if (_raController == null) {
      throw new ConfigException(L.l("'{0}' does not have a configured resource-adapter for '{1}'.",
                                    ra.getResourceAdapterClass().getName(),
View Full Code Here

        getInit().configure(resourceObject);

      if (_ra != null && resourceObject instanceof ResourceAdapterAssociation)
        ((ResourceAdapterAssociation) resourceObject).setResourceAdapter(_ra);

      InjectManager beanManager = InjectManager.create();

      BeanBuilder factory = beanManager.createBeanFactory(resourceObject.getClass());
     
      if (getName() != null) {
        Jndi.bindDeepShort(getName(), resourceObject);

        beanManager.addBean(factory.name(getName()).singleton(resourceObject));
      }
      else {
        beanManager.addBean(factory.singleton(resourceObject));
      }
    }
View Full Code Here

      = ResourceArchiveManager.findResourceArchive(type.getName());

    ResourceAdapterController controller
      = new ResourceAdapterController((Bean<ResourceAdapter>) getComponent(), ra);

    InjectManager beanManager = InjectManager.create();
    BeanBuilder<T> factory = beanManager.createBeanFactory(type);
   
    factory.type(ResourceAdapter.class, type);
   
    String name = type.getSimpleName();
   
    name = Character.toLowerCase(name.charAt(0)) + name.substring(1);

    factory.name(name);
    factory.qualifier(Names.create(name));
    factory.qualifier(DefaultLiteral.DEFAULT);
   
    ResourceAdapterProducer<T> producer = new ResourceAdapterProducer(controller);
   
    Bean<T> bean = factory.injection(producer);

    beanManager.addBean(bean);
   
    ((InjectionBean) bean).introspectProduces();
  }
View Full Code Here

  {
    super.init();

    Bean<?> comp = getComponent();

    InjectManager cdiManager = InjectManager.create();

    ManagedConnectionFactory managedFactory
      = (ManagedConnectionFactory) cdiManager.getReference(comp);

    if (managedFactory instanceof ResourceAdapterAssociation) {
      Class<?> cl = managedFactory.getClass();

      ResourceAdapter ra = findResourceAdapter(cl);

      ResourceAdapterAssociation factoryAssoc
        = (ResourceAdapterAssociation) managedFactory;

      try {
        factoryAssoc.setResourceAdapter(ra);
      } catch (Exception e) {
        throw ConfigException.create(e);
      }
    }

    ResourceManagerImpl rm = ResourceManagerImpl.create();

    ConnectionPool cm = rm.createConnectionPool();

    if (getName() != null)
      cm.setName(getName());

    cm.setMaxConnections(_maxConnections);
    cm.setMaxActiveTime(_maxActiveTime);

    ResourceArchive rar = null;

    if (rar != null) {
      String trans = rar.getTransactionSupport();

      if (trans == null) { // guess XA
        cm.setXATransaction(true);
        cm.setLocalTransaction(true);
      }
      else if (trans.equals("XATransaction")) {
        cm.setXATransaction(true);
        cm.setLocalTransaction(true);
      }
      else if (trans.equals("NoTransaction")) {
        cm.setXATransaction(false);
        cm.setLocalTransaction(false);
      }
      else if (trans.equals("LocalTransaction")) {
        cm.setXATransaction(false);
        cm.setLocalTransaction(true);
      }
    }
    /*
    cm.setLocalTransactionOptimization(getLocalTransactionOptimization());
    cm.setShareable(getShareable());
    */

    Object connectionFactory;

    try {
      connectionFactory = cm.init(managedFactory);
      cm.start();

      BeanBuilder factory
        = cdiManager.createBeanFactory(connectionFactory.getClass());

      if (getName() != null) {
        Jndi.bindDeepShort(getName(), connectionFactory);

        factory.name(getName());
        factory.qualifier(Names.create(getName()));
        // server/30i0
        factory.qualifier(CurrentLiteral.CURRENT);
      }
     
      factory.qualifier(DefaultLiteral.DEFAULT);

      Bean bean = factory.singleton(connectionFactory);

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

    if (ra == null) {
      throw new ConfigException(L.l("'{0}' does not have a defined resource-adapter.  Either define it in a &lt;resource-adapter> property or check the rar or META-INF/resin-ra.xml files",
                                    cl.getName()));
    }

    InjectManager cdiManager = InjectManager.create();
    String raName = ra.getResourceAdapterClass().getSimpleName();
   
    raName = Character.toLowerCase(raName.charAt(0)) + raName.substring(1);

    Instance<ResourceAdapter> instance
      = _raInstance.select(Names.create(raName));

    Bean<?> bean = cdiManager.resolve(cdiManager.getBeans(ResourceAdapter.class,
                                                          Names.create(raName)));
   
    CreationalContext<?> env = cdiManager.createCreationalContext(bean);
    ResourceAdapter resourceAdapter
      = (ResourceAdapter) cdiManager.getReference(bean, ResourceAdapter.class, env);

    if (resourceAdapter == null) {
      throw new ConfigException(L.l("'{0}' does not have a configured resource-adapter for '{1}'.",
                                    raName,
                                    cl.getName()));
View Full Code Here

    if (_init != null)
      _init.configure(_ra);

    ResourceManagerImpl.addResource(_ra);

    InjectManager beanManager = InjectManager.create();

    BeanBuilder factory = beanManager.createBeanFactory(_ra.getClass());
   
    if (_resourceAdapter.getName() != null) {
      Jndi.bindDeepShort(_resourceAdapter.getName(), _ra);

      beanManager.addBean(factory.name(_resourceAdapter.getName())
                          .singleton(_ra));
    }
    else {
      beanManager.addBean(factory.name(_name).singleton(_ra));
    }

    // create a default outbound factory
    if (_outboundList.size() == 0 && _jndiName != null && _rar != null) {
      ObjectConfig factoryConfig = _rar.getConnectionDefinition(null);
View Full Code Here

      cm.setShareable(getShareable());

      Object connectionFactory = cm.init(managedFactory);
      cm.start();

      InjectManager manager = InjectManager.create();
      BeanBuilder factory
        = manager.createBeanFactory(connectionFactory.getClass());
     
      if (getName() != null) {
        Jndi.bindDeepShort(getName(), connectionFactory);

        factory.name(getName());
        // server/30b4
        factory.qualifier(Names.create(getName()));
        factory.qualifier(CurrentLiteral.CURRENT);
      }
     
      manager.addBean(factory.singleton(connectionFactory));
    }
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.