Package org.apache.openejb.assembler.classic

Examples of org.apache.openejb.assembler.classic.ResourceInfo


        }

        Resource resource = new Resource(resourceId, providerId, null);
        resource.getProperties().setProperty("destination", resourceId);

        ResourceInfo resourceInfo = configFactory.configureService(resource, ResourceInfo.class);
        logger.info("Auto-creating a resource with id '" + resourceInfo.id +  "' of type '" + type  + " for '" + beanName + "'.");
        return installResource(beanName, resourceInfo);
    }
View Full Code Here


    }

    public void testQueue() throws Exception {
        ConfigurationFactory factory = new ConfigurationFactory();

        ResourceInfo resourceInfo = factory.configureService(new Resource("myQueue", "Queue"), ResourceInfo.class);

        assertNotNull(resourceInfo);
        assertEquals("myQueue", resourceInfo.id);
        assertNotNull(resourceInfo.constructorArgs);
        assertNotNull(resourceInfo.properties);
View Full Code Here

        //
        for (Object resourceProvider : applicationContext.getBeansOfType(ResourceProvider.class).values()) {
            resources.add((ResourceProvider) resourceProvider);
        }
        for (ResourceProvider resourceProvider : getResources()) {
            ResourceInfo info = configurationFactory.configureService(resourceProvider.getResourceDefinition(), ResourceInfo.class);
            importedResourceIds.add(info.id);
            assembler.createResource(info);
        }
        if (isImportContext() && applicationContext != null) {
            for (String beanName : applicationContext.getBeanDefinitionNames()) {
                if (!importedResourceIds.contains(beanName)) {
                    Class beanType = applicationContext.getType(beanName);
                    Class factoryType = applicationContext.getType("&" + beanName);
                    if (isImportableType(beanType, factoryType)) {
                        SpringReference factory = new SpringReference(applicationContext, beanName, beanType);

                        ResourceInfo info = initPassthrough(beanName, new ResourceInfo(), "Resource", factory);
                        info.types = getTypes(beanType);
                        assembler.createResource(info);
                    }
                }
            }
View Full Code Here

    }

    private void buildAppResources(AppModule module, AppInfo info) {
        for (Resource def : module.getResources()) {
            ResourceInfo resourceInfo = new ResourceInfo();
            resourceInfo.id = module.getModuleId() + "/" + def.getJndi().replace("java:", "");

            resourceInfo.service = "Resource";
            resourceInfo.types.add(def.getType());
            resourceInfo.properties = def.getProperties();
View Full Code Here

                    properties.setProperty("TransactionSupport", transactionSupport);
                    if (connectorInfo.resourceAdapter != null) {
                      properties.setProperty("ResourceAdapter", connectorInfo.resourceAdapter.id);
                    }

                    ResourceInfo resourceInfo = configFactory.configureService(resource, ResourceInfo.class);
                    connectorInfo.outbound.add(resourceInfo);
                }
            }

            InboundResourceadapter inbound = resourceAdapter.getInboundResourceAdapter();
            if (inbound != null) {
                for (MessageListener messageListener : inbound.getMessageAdapter().getMessageListener()) {
                    String id = getId(messageListener, inbound, connectorModule);

                    Container container = new Container(id, "MESSAGE", null);

                    Properties properties = container.getProperties();
                    properties.setProperty("ResourceAdapter", connectorInfo.resourceAdapter.id);
                    properties.setProperty("MessageListenerInterface", messageListener.getMessageListenerType());
                    properties.setProperty("ActivationSpecClass", messageListener.getActivationSpec().getActivationSpecClass());

                    MdbContainerInfo mdbContainerInfo = configFactory.configureService(container, MdbContainerInfo.class);
                    connectorInfo.inbound.add(mdbContainerInfo);
                }
            }

            for (AdminObject adminObject : resourceAdapter.getAdminObject()) {

                String id = getId(adminObject, resourceAdapter, connectorModule);
                String className = adminObject.getAdminObjectClass();
                String type = adminObject.getAdminObjectInterface();

                ServiceProvider provider = new ServiceProvider(className, id, "Resource");
                provider.getTypes().add(type);

                ServiceUtils.registerServiceProvider(appId, provider);

                Resource resource = new Resource(id, type, appId + "#" + id);
                Properties properties = resource.getProperties();
                for (ConfigProperty property : adminObject.getConfigProperty()) {
                    String name = property.getConfigPropertyName();
                    String value = property.getConfigPropertyValue();
                    if (value != null) {
                        properties.setProperty(name, value);
                    }
                }
                ResourceInfo resourceInfo = configFactory.configureService(resource, ResourceInfo.class);
                connectorInfo.adminObject.add(resourceInfo);
            }

            appInfo.connectors.add(connectorInfo);
        }
View Full Code Here

     *
     * @throws Exception
     */
    public void test() throws Exception {

        ResourceInfo jta = addDataSource("Orange", OrangeDriver.class, "jdbc:orange:some:stuff", true);
        ResourceInfo nonJta = addDataSource("OrangeUnmanaged", OrangeDriver.class, "jdbc:orange:some:stuff", false);

        assertSame(jta, resources.get(0));
        assertSame(nonJta, resources.get(1));

        PersistenceUnitInfo unitInfo = addPersistenceUnit("orange-unit", "orange", "orangeUnmanaged");
View Full Code Here

     *
     * @throws Exception
     */
    public void testMultiple() throws Exception {

        ResourceInfo orangeJta = addDataSource("Orange", OrangeDriver.class, "jdbc:orange:some:stuff", true);
        ResourceInfo orangeNonJta = addDataSource("OrangeUnmanaged", OrangeDriver.class, "jdbc:orange:some:stuff", false);
        ResourceInfo limeJta = addDataSource("Lime", LimeDriver.class, "jdbc:lime:some:stuff", true);
        ResourceInfo limeNonJta = addDataSource("LimeUnmanaged", LimeDriver.class, "jdbc:lime:some:stuff", false);

        assertSame(orangeJta, resources.get(0));
        assertSame(orangeNonJta, resources.get(1));
        assertSame(limeJta, resources.get(2));
        assertSame(limeNonJta, resources.get(3));
View Full Code Here

     * The orange-unit app should automatically use orange-unit data source and the non-jta-datasource should be null
     *
     * @throws Exception
     */
    public void testFromUnitNameThirdParty() throws Exception {
        ResourceInfo supplied = addDataSource("orange-unit", OrangeDriver.class, "jdbc:orange:some:stuff", null);
        assertSame(supplied, resources.get(0));

        PersistenceUnitInfo unitInfo = addPersistenceUnit("orange-unit", null, null);
        assertNotNull(unitInfo);

View Full Code Here

     * The orange-unit app should automatically use orange-unit data source and create a new non-JtaManaged datasource
     *
     * @throws Exception
     */
    public void testFromUnitNameJta() throws Exception {
        ResourceInfo supplied = addDataSource("orange-unit", OrangeDriver.class, "jdbc:orange:some:stuff", true);
        assertSame(supplied, resources.get(0));

        PersistenceUnitInfo unitInfo = addPersistenceUnit("orange-unit", null, null);
        assertNotNull(unitInfo);

        // Check results
        ResourceInfo generated = resources.get(1);
        assertEquals(supplied.id + "NonJta", generated.id);
        assertEquals(supplied.service, generated.service);
        assertEquals(supplied.className, generated.className);
        assertEquals(supplied.properties.get("JdbcDriver"), generated.properties.get("JdbcDriver"));
        assertEquals(supplied.properties.get("JdbcUrl"), generated.properties.get("JdbcUrl"));
View Full Code Here

     * The orange-unit app should automatically use orange-unit data source and create a new JtaManaged datasource
     *
     * @throws Exception
     */
    public void testFromUnitNameNonJta() throws Exception {
        ResourceInfo supplied = addDataSource("orange-unit", OrangeDriver.class, "jdbc:orange:some:stuff", false);
        assertSame(supplied, resources.get(0));

        PersistenceUnitInfo unitInfo = addPersistenceUnit("orange-unit", null, null);
        assertNotNull(unitInfo);

        // Check results
        ResourceInfo generated = resources.get(1);
        assertEquals(supplied.id + "Jta", generated.id);
        assertEquals(supplied.service, generated.service);
        assertEquals(supplied.className, generated.className);
        assertEquals(supplied.properties.get("JdbcDriver"), generated.properties.get("JdbcDriver"));
        assertEquals(supplied.properties.get("JdbcUrl"), generated.properties.get("JdbcUrl"));
View Full Code Here

TOP

Related Classes of org.apache.openejb.assembler.classic.ResourceInfo

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.