Package org.apache.openejb.assembler.classic

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


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

        ResourceInfo supplied = addDataSource("Orange", OrangeDriver.class, "jdbc:orange:some:stuff", true);
        assertSame(supplied, resources.get(0));

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

        assertNotNull(unitInfo);

        ResourceInfo generated = resources.get(1);

        assertEquals(supplied.id, unitInfo.jtaDataSource);
        assertEquals(generated.id, unitInfo.nonJtaDataSource);


View Full Code Here


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

        ResourceInfo supplied = addDataSource("Orange", OrangeDriver.class, "jdbc:orange:some:stuff", false);
        ResourceInfo badMatch = addDataSource("Lime", LimeDriver.class, "jdbc:lime:some:stuff", true);

        assertSame(supplied, resources.get(0));
        assertSame(badMatch, resources.get(1));

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

        assertNotNull(unitInfo);

        ResourceInfo generated = resources.get(2);

        assertEquals(generated.id, unitInfo.jtaDataSource);
        assertEquals(supplied.id, unitInfo.nonJtaDataSource);


View Full Code Here

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

        ResourceInfo supplied = addDataSource("Orange", OrangeDriver.class, "jdbc:orange:some:stuff", true);
        ResourceInfo badMatch = addDataSource("Lime", LimeDriver.class, "jdbc:lime:some:stuff", false);

        assertSame(supplied, resources.get(0));
        assertSame(badMatch, resources.get(1));

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

        assertNotNull(unitInfo);


        ResourceInfo generated = resources.get(2);

        assertEquals(supplied.id, unitInfo.jtaDataSource);
        assertEquals(generated.id, unitInfo.nonJtaDataSource);


View Full Code Here

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

        ResourceInfo supplied = addDataSource("Orange", OrangeDriver.class, "jdbc:orange:some:stuff", false);
        ResourceInfo badMatch = addDataSource("Lime", LimeDriver.class, "jdbc:lime:some:stuff", true);
        ResourceInfo goodMatch = addDataSource("JtaOrange", OrangeDriver.class, "jdbc:orange:some:stuff", true);

        assertSame(supplied, resources.get(0));
        assertSame(badMatch, resources.get(1));
        assertSame(goodMatch, resources.get(2));

View Full Code Here

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

        ResourceInfo supplied = addDataSource("Orange", OrangeDriver.class, "jdbc:orange:some:stuff", true);
        ResourceInfo badMatch = addDataSource("Lime", LimeDriver.class, "jdbc:lime:some:stuff", false);
        ResourceInfo goodMatch = addDataSource("OrangeUnmanaged", OrangeDriver.class, "jdbc:orange:some:stuff", false);

        assertSame(supplied, resources.get(0));
        assertSame(badMatch, resources.get(1));
        assertSame(goodMatch, resources.get(2));

View Full Code Here

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

        ResourceInfo supplied = addDataSource("Orange", OrangeDriver.class, "jdbc:orange:some:stuff", false);

        assertSame(supplied, resources.get(0));

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

        assertNotNull(unitInfo);

        ResourceInfo generated = resources.get(1);

        assertEquals(generated.id, unitInfo.jtaDataSource);
        assertEquals(supplied.id, unitInfo.nonJtaDataSource);


View Full Code Here

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

        ResourceInfo supplied = addDataSource("Orange", OrangeDriver.class, "jdbc:orange:some:stuff", true);

        assertSame(supplied, resources.get(0));

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

        assertNotNull(unitInfo);


        ResourceInfo generated = resources.get(1);

        assertEquals(supplied.id, unitInfo.jtaDataSource);
        assertEquals(generated.id, unitInfo.nonJtaDataSource);


View Full Code Here

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

        assertNotNull(unitInfo);

        ResourceInfo jta = resources.get(0);
        ResourceInfo nonJta = resources.get(1);

        assertEquals("Default JDBC Database", jta.id);
        assertEquals("Default Unmanaged JDBC Database", nonJta.id);

        assertEquals(jta.id, unitInfo.jtaDataSource);
View Full Code Here

        Resource resource = new Resource(id, "DataSource");
        resource.getProperties().put("JdbcDriver", driver.getName());
        resource.getProperties().put("JdbcUrl", url);
        resource.getProperties().put("JtaManaged", managed + " ")// space should be trimmed later, this verifies that.

        ResourceInfo resourceInfo = config.configureService(resource, ResourceInfo.class);

        if (managed == null){
            // Strip out the JtaManaged property so we can mimic
            // datasources that we don't control
            resourceInfo.properties.remove("JtaManaged");
View Full Code Here

        }
        logger.debug(message);

        // if there is a provider with the specified name. use it
        if (ServiceUtils.hasServiceProvider(resourceId)) {
            ResourceInfo resourceInfo = configFactory.configureService(resourceId, ResourceInfo.class);
            return installResource(beanName, resourceInfo);
        } else if (ServiceUtils.hasServiceProvider(shortName)) {
            ResourceInfo resourceInfo = configFactory.configureService(shortName, ResourceInfo.class);
            return installResource(beanName, resourceInfo);
        }

        // if there are any resources of the desired type, use the first one
        if (resourceIds.size() > 0) {
            return resourceIds.get(0);
        }

        // Auto create a resource using the first provider that can supply a resource of the desired type
        resourceId = ServiceUtils.getServiceProviderId(type);
        if (resourceId == null) {
            throw new OpenEJBException("No provider available for resource reference '" + resourceId + "' of type '" + type + "' for '" + beanName + "'.");
        }
        ResourceInfo resourceInfo = configFactory.configureService(resourceId, 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

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.