Package com.caucho.config.inject

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


      String name = _jndiName;

      Jndi.bindDeepShort(name, this);
    }

    InjectManager manager = InjectManager.create();
    BeanFactory<?> factory = manager.createBeanFactory(DataSource.class);

    String name = _name;
   
    if (name == null)
      name = _jndiName;
   
    if (name == null)
      name = _var;

    if (_bindingList.size() > 0) {
      factory.binding(_bindingList);
    }
    else {
      if (name != null)
        factory.binding(Names.create(name));
     
      factory.binding(CurrentLiteral.CURRENT);
    }

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

    // factory.stereotype(CauchoDeployment.class);

    manager.addBean(factory.singleton(this));

    _queryAdmin.register();
    _databaseAdmin.register();
  }
View Full Code Here


      name = _var;
   
    if (_name == null)
      name = _jndiName;
   
    InjectManager beanManager = InjectManager.create();

    BeanFactory factory = beanManager.createBeanFactory(_object.getClass());

    if (name != null) {
      factory.name(name);
      factory.binding(CurrentLiteral.CURRENT);
      factory.binding(Names.create(name));
    }

    // server/12dt
    // for backward compatibility <resource> is always ApplicationScoped
    factory.scope(ApplicationScoped.class);

    if (_object != null)
      beanManager.addBean(factory.singleton(_object));
    else
      beanManager.addBean(factory.bean());

    if (log.isLoggable(Level.CONFIG))
      logConfig();
  }
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

  {
    if (name == null)
      return null;
   
    Named named = Names.create(name);
    InjectManager beanManager = InjectManager.create();
   
    Set<Bean<?>> beans = beanManager.getBeans(DataSource.class, named);
   
    if (beans != null && beans.size() > 0) {
      return (DataSource) beanManager.getReference(beanManager.resolve(beans));
    }
   
    DataSource ds = (DataSource) Jndi.lookup(name);

    if (ds != null)
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

      _name = name;
    }
   
    private Object readResolve()
    {
      InjectManager beanManager = InjectManager.getCurrent();
     
      return beanManager.getReference(EntityManagerFactory.class,
                                      Names.create(_name));
    }
View Full Code Here

  }

  private void registerPersistenceUnit(ManagerPersistenceUnit pUnit)
  {
    try {
      InjectManager beanManager = InjectManager.create(_classLoader);
     
      BeanFactory<EntityManagerFactory> emfFactory;
      emfFactory = beanManager.createBeanFactory(EntityManagerFactory.class);

      emfFactory.binding(CurrentLiteral.CURRENT);
      emfFactory.binding(Names.create(pUnit.getName()));
      beanManager.addBean(emfFactory.singleton(pUnit.getEntityManagerFactoryProxy()));

      BeanFactory<EntityManager> emFactory;
      emFactory = beanManager.createBeanFactory(EntityManager.class);

      emFactory.binding(CurrentLiteral.CURRENT);
      emFactory.binding(Names.create(pUnit.getName()));
      beanManager.addBean(emFactory.singleton(pUnit.getEntityManagerJtaProxy()));

      /*
      factory = manager.createBeanFactory(EntityManager.class);
      factory.binding(CurrentLiteral.CURRENT);
      factory.binding(Names.create(unitName));
View Full Code Here

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

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

    InjectManager beanManager = InjectManager.create();
    BeanFactory<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.binding(Names.create(name));
    factory.binding(DefaultLiteral.DEFAULT);
   
    ResourceAdapterProducer<T> producer = new ResourceAdapterProducer(controller);

    beanManager.addBean(factory.injection(producer));
  }
View Full Code Here

  {
    super.init();

    Bean comp = getComponent();

    InjectManager manager = InjectManager.create();

    ManagedConnectionFactory managedFactory
      = (ManagedConnectionFactory) manager.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();

      BeanFactory factory
        = manager.createBeanFactory(connectionFactory.getClass());

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

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

      Bean bean = factory.singleton(connectionFactory);

      manager.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 webBeans = InjectManager.create();
    String raName = ra.getResourceAdapterClass().getName();

    Instance<ResourceAdapter> instance
      = _raInstance.select(Names.create(raName));
View Full Code Here

TOP

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

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.