Package org.apache.cayenne.di

Examples of org.apache.cayenne.di.Injector


    private boolean createFK;

    public void execute() throws MojoExecutionException, MojoFailureException {

        Log logger = new MavenLogger(this);
        Injector injector = DIBootstrap.createInjector(new ToolsModule(logger));
        AdhocObjectFactory objectFactory = injector.getInstance(AdhocObjectFactory.class);

        logger.info(String.format("connection settings - [driver: %s, url: %s, username: %s]", driver, url, username));

        logger.info(String.format(
                "generator options - [dropTables: %s, dropPK: %s, createTables: %s, createPK: %s, createFK: %s]",
View Full Code Here


    public void execute() throws MojoExecutionException, MojoFailureException {

        Log logger = new MavenLogger(this);

        DbImportParameters parameters = toParameters();
        Injector injector = DIBootstrap.createInjector(new ToolsModule(logger), new DbImportModule());

        try {
            injector.getInstance(DbImportAction.class).execute(parameters);
        } catch (Exception ex) {
            Throwable th = Util.unwindException(ex);

            String message = "Error importing database schema";
View Full Code Here

    protected boolean attachToRuntimeIfNeeded() {
        if (channel != null) {
            return false;
        }

        Injector injector = CayenneRuntime.getThreadInjector();
        if (injector == null) {
            throw new CayenneRuntimeException("Can't attach to Cayenne runtime. "
                    + "Null injector returned from CayenneRuntime.getThreadInjector()");
        }
View Full Code Here

                binder.bind(ConfigurationNameMapper.class).to(
                        DefaultConfigurationNameMapper.class);
            }
        };

        Injector injector = DIBootstrap.createInjector(testModule);

        // create and initialize loader instance to test
        XMLDataChannelDescriptorLoader loader = new XMLDataChannelDescriptorLoader();
        injector.injectMembers(loader);

        String testConfigName = "relationship-optimisation";
        URL url = getClass().getResource("cayenne-" + testConfigName + ".xml");

        ConfigurationTree<DataChannelDescriptor> tree = loader.load(new URLResource(url));
View Full Code Here

                        new MockDataSourceFactoryLoader());
                binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
            }
        };

        Injector injector = DIBootstrap.createInjector(testModule);

        // create and initialize provide instance to test
        DataDomainProvider provider = new DataDomainProvider();
        injector.injectMembers(provider);

        DataChannel channel = provider.get();
        assertNotNull(channel);

        assertTrue(channel instanceof DataDomain);
View Full Code Here

                binder.bind(DataDomain.class).toInstance(domain);
                binder.bind(EventManager.class).toInstance(eventManager);
            }
        };

        Injector injector = DIBootstrap.createInjector(testModule);

        DataContextFactory factory = new DataContextFactory();
        injector.injectMembers(factory);

        DataContext c3 = (DataContext) factory.createContext();
        assertNotNull(c3.getObjectStore().getDataRowCache());
        assertNull(domain.getSharedSnapshotCache());
        assertNotSame(c3.getObjectStore().getDataRowCache(), domain
View Full Code Here

                binder.bind(DataDomain.class).toInstance(domain);
                binder.bind(EventManager.class).toInstance(eventManager);
            }
        };

        Injector injector = DIBootstrap.createInjector(testModule);

        DataContextFactory factory = new DataContextFactory();
        injector.injectMembers(factory);

        DataContext c1 = (DataContext) factory.createContext();
        assertTrue(c1.isValidatingObjectsOnCommit());

        domain.setValidatingObjectsOnCommit(false);
View Full Code Here

public class CAY_743Test extends TestCase {

    public void testLoad2MapsWithCrossMapInheritance() throws Exception {

        Injector injector = DIBootstrap.createInjector(new ServerModule(
                "cay743/cayenne-domain.xml"));

        DataDomain domain = injector.getInstance(DataDomain.class);
        assertEquals(2, domain.getDataMaps().size());

        DataMap m1 = domain.getDataMap("map1");
        DataMap m2 = domain.getDataMap("map2");
View Full Code Here

                binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
                binder.bind(ResourceLocator.class).to(MockResourceLocator.class);
            }
        };

        Injector injector = DIBootstrap.createInjector(testModule);

        DefaultDataSourceFactoryLoader factoryLoader = new DefaultDataSourceFactoryLoader();
        injector.injectMembers(factoryLoader);

        DataSourceFactory factory = factoryLoader.getDataSourceFactory(nodeDescriptor);
        assertNotNull(factory);
        assertTrue(factory instanceof XMLPoolingDataSourceFactory);
    }
View Full Code Here

                binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
                binder.bind(ResourceLocator.class).to(MockResourceLocator.class);
            }
        };

        Injector injector = DIBootstrap.createInjector(testModule);

        DefaultDataSourceFactoryLoader factoryLoader = new DefaultDataSourceFactoryLoader();
        injector.injectMembers(factoryLoader);

        DataSourceFactory factory = factoryLoader.getDataSourceFactory(nodeDescriptor);
        assertNotNull(factory);
        assertTrue(factory instanceof MockDataSourceFactory1);
        assertSame(
View Full Code Here

TOP

Related Classes of org.apache.cayenne.di.Injector

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.