Examples of BeanFactory


Examples of com.caucho.config.inject.BeanFactory

    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

Examples of com.ibm.commons.runtime.impl.ManagedBeanFactory.BeanFactory

    AbstractApplication app = getApplicationUnchecked();
    if(app!=null) {
      ManagedBeanFactory[] factories = app.getManagedBeanFactories();
      if(factories!=null && factories.length>0) {
        for(int i=0; i<factories.length; i++) {
          BeanFactory factory = factories[i].getBeanFactory(beanName);
          if(factory!=null) {
            Map<String,Object> map = getScope(factory.getScope());
            synchronized(map) {
              Object o = map.get(beanName);
              if(o==null) {
                o = factory.create(getClassLoader());
                if(o!=null) {
                  map.put(beanName, o);
                }
              }
              return o;
View Full Code Here

Examples of com.inspiresoftware.lib.dto.geda.adapter.BeanFactory

        final Assembler assembler = DTOAssembler.newAssembler(dto.getClass(), entity.getClass());

        final Map<String, Object> adapters = new HashMap<String, Object>();
        adapters.put("CatalogCodeMatcher", new CatalogCodeMatcher());

        assembler.assembleDto(dto, entity, adapters, new BeanFactory() {
            public Class getClazz(final String entityBeanKey) {
                if ("DtoCatalogCode".equals(entityBeanKey)) {
                    return DtoCatalogCodeClass.class;
                } else if ("DtoCode".equals(entityBeanKey)) {
                    return DtoCodeClass.class;
                } else if ("DtoCatalog".equals(entityBeanKey)) {
                    return DtoCatalogClass.class;
                }
                fail("Unknown DTO key: " + entityBeanKey);
                return null;
            }

            public Object get(final String entityBeanKey) {
                if ("DtoCatalogCode".equals(entityBeanKey)) {
                    return new DtoCatalogCodeClass();
                } else if ("DtoCode".equals(entityBeanKey)) {
                    return new DtoCodeClass();
                } else if ("DtoCatalog".equals(entityBeanKey)) {
                    return new DtoCatalogClass();
                }
                fail("Unknown DTO key: " + entityBeanKey);
                return null;
            }
        });

        assertEquals("ID-ABC", dto.getId());

        final DtoCodeClass dtoType = dto.getType();
        assertNotNull(dtoType);
        assertEquals("ID-123", dtoType.getId());
        assertEquals("CODE-AG1", dtoType.getCode());

        final Collection<DtoCodeClass> dtoCodes = dto.getCodes();
        assertNotNull(dtoCodes);
        assertFalse(dtoCodes.isEmpty());
        // The collection is actually an ArrayList, so we will cheat a little
        final List<DtoCodeClass> dtoCodesAsList = (List) dtoCodes;
        assertEquals(2, dtoCodesAsList.size());

        final DtoCodeClass dtoCode1 = dtoCodesAsList.get(0);
        assertNotNull(dtoCode1);
        assertEquals("ID-123", dtoCode1.getId());
        assertEquals("CODE-AG1", dtoCode1.getCode());

        final DtoCodeClass dtoCode2 = dtoCodesAsList.get(1);
        assertNotNull(dtoCode2);
        assertEquals("ID-235", dtoCode2.getId());
        assertEquals("CODE-DT1", dtoCode2.getCode());

        final EntityCatalog<EntityCatalogCode> entityCopy = new EntityCatalogClass<EntityCatalogCode>();

        assembler.assembleEntity(dto, entityCopy, adapters, new BeanFactory() {
            public Class getClazz(final String entityBeanKey) {
                if ("CatalogCode".equals(entityBeanKey)) {
                    return EntityCatalogCodeClass.class;
                } else if ("Catalog".equals(entityBeanKey)) {
                    return EntityCatalogClass.class;
View Full Code Here

Examples of org.apache.commons.configuration2.beanutils.BeanFactory

     */
    @Test
    public void testBeanHelperInConfiguration() throws ConfigurationException
    {
        final Set<Class<?>> classesPassedToFactory = new HashSet<Class<?>>();
        BeanFactory factory = new DefaultBeanFactory()
        {
            @Override
            public Object createBean(BeanCreationContext bcc) throws Exception
            {
                classesPassedToFactory.add(bcc.getBeanClass());
View Full Code Here

Examples of org.apache.hivemind.lib.BeanFactory

        if (locator.length() == 0)
            throw new ApplicationRuntimeException(
                FactoryMessages.invalidBeanTranslatorFormat(inputValue));

        BeanFactory f = (BeanFactory) contributingModule.getService(serviceId, BeanFactory.class);

        return f.get(locator);
    }
View Full Code Here

Examples of org.apache.hivemind.lib.BeanFactory

            throw new ApplicationRuntimeException(
                FactoryMessages.invalidBeanTranslatorFormat(inputValue),
                location,
                null);

        BeanFactory f = (BeanFactory) contributingModule.getService(serviceId, BeanFactory.class);

        return f.get(locator);
    }
View Full Code Here

Examples of org.apache.hivemind.lib.BeanFactory

    public void testSuccess()
    {
        String result = "Obtained via BeanFactory.";

        MockControl factoryControl = newControl(BeanFactory.class);
        BeanFactory factory = (BeanFactory) factoryControl.getMock();

        MockControl moduleControl = newControl(Module.class);
        Module module = (Module) moduleControl.getMock();

        module.getService("factory", BeanFactory.class);
        moduleControl.setReturnValue(factory);

        factory.get("my-bean,initialized");
        factoryControl.setReturnValue(result);

        replayControls();

        ObjectProvider op = new BeanFactoryObjectProvider();
View Full Code Here

Examples of org.apache.hivemind.lib.BeanFactory

        replayControls();

        BeanFactoryBuilder b = new BeanFactoryBuilder();

        BeanFactory f = (BeanFactory) b.createCoreServiceImplementation(fp);

        Integer i = (Integer) f.get("integer,5");

        assertEquals(new Integer(5), i);

        verifyControls();
    }
View Full Code Here

Examples of org.apache.hivemind.lib.BeanFactory

     */
    public void testIntegration() throws Exception
    {
        Registry r = buildFrameworkRegistry("NumberFactory.xml");

        BeanFactory f = (BeanFactory) r.getService(
                "hivemind.lib.test.NumberFactory",
                BeanFactory.class);

        assertEquals(new Integer(27), f.get("int,27"));
        assertEquals(new Double(-22.5), f.get("double,-22.5"));
    }
View Full Code Here

Examples of org.dozer.BeanFactory

      String factoryBeanId = directive.getFactoryId();

      // By default, use dest object class name for factory bean id
      String beanId = !MappingUtils.isBlankOrNull(factoryBeanId) ? factoryBeanId : classToCreate.getName();

      BeanFactory factory = factoryCache.get(factoryName);
      if (factory == null) {
        Class<?> factoryClass = MappingUtils.loadClass(factoryName);
        if (!BeanFactory.class.isAssignableFrom(factoryClass)) {
          MappingUtils.throwMappingException("Custom bean factory must implement "
                  + BeanFactory.class.getName() + " interface : " + factoryClass);
        }
        factory = (BeanFactory) ReflectionUtils.newInstance(factoryClass);
        // put the created factory in our factory map
        factoryCache.put(factoryName, factory);
      }

      Object result = factory.createBean(directive.getSrcObject(), directive.getSrcClass(), beanId);

      log.debug("Bean instance created with custom factory -->\n  Bean Type: {}\n  Factory Name: {}",
              result.getClass().getName(), factoryName);

      if (!classToCreate.isAssignableFrom(result.getClass())) {
        MappingUtils.throwMappingException("Custom bean factory (" + factory.getClass() +
                ") did not return correct type of destination data object. Expected : "
                + classToCreate + ", Actual : " + result.getClass());
      }
      return result;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.