Examples of DataDomain


Examples of org.apache.cayenne.access.DataDomain

        if (logger.isInfoEnabled() && map != null) {
            logger.info("Extra container PersistenceUnitInfo properties: " + map);
        }

        String name = unit.getPersistenceUnitName();
        DataDomain domain = configuration.getDomain(name);

        // TODO: andrus, 2/3/2007 - considering property overrides, it may be a bad idea
        // to cache domains. Essentially we are caching a PersistenceUnitInfo with a given
        // name, without a possibility to refresh it. But maybe this is ok...?
        if (domain == null) {

            long t0 = System.currentTimeMillis();

            boolean isJTA = isJta(unit, map);

            EntityMapLoader loader = new EntityMapLoader(unit);

            // add transformer before DataMapConverter starts loading the classes via app
            // class loader
            ClassFileTransformer enhancer = new Enhancer(new JpaEnhancerVisitorFactory(
                    loader.getEntityMap()));
            Map<String, JpaClassDescriptor> managedClasses = loader
                    .getEntityMap()
                    .getManagedClasses();
            unit.addTransformer(new UnitClassTransformer(managedClasses, loader
                    .getContext()
                    .getTempClassLoader(), enhancer));

            DataMapConverter converter = new DataMapConverter();
            DataMap cayenneMap = converter.toDataMap(name, loader.getContext());

            // configure Cayenne domain
            domain = new DataDomain(name);
            ClassDescriptorMap descriptors = domain
                    .getEntityResolver()
                    .getClassDescriptorMap();
            FaultFactory faultFactory = new SingletonFaultFactory();
            descriptors.addFactory(new JpaClassDescriptorFactory(
                    loader.getEntityMap(),
                    descriptors,
                    faultFactory));
            configuration.addDomain(domain);

            // TODO: andrus, 2/3/2007 - clarify this logic.... JTA EM may not always mean
            // JTA DS?
            DataSource dataSource = isJTA ? unit.getJtaDataSource() : unit
                    .getNonJtaDataSource();

            if (dataSource == null) {
                String jta = isJTA ? "JTA" : "non-JTA";
                logger.warn("NULL "
                        + jta
                        + " DataSource returned from PersistenceUnitInfo");
            }

            DbAdapter adapter = createCustomAdapter(loader.getContext(), unit);
            DataNode node = new DataNode(name);
            if (adapter == null) {
                adapter = new AutoAdapter(new NodeDataSource(node));
            }

            node.setAdapter(adapter);
            node.setDataSource(dataSource);
            node.addDataMap(cayenneMap);

            domain.addNode(node);

            // note that for now we do not apply object layer defaults, as that would
            // require extra enhancement for runtime relationships...
            domain.getEntityResolver().applyDBLayerDefaults();
            domain.setUsingExternalTransactions(isJTA);

            if ("true".equalsIgnoreCase(unit.getProperties().getProperty(
                    DROP_SCHEMA_PROPERTY))) {
                dropSchema(dataSource, adapter, cayenneMap);
            }

            if ("true".equalsIgnoreCase(unit.getProperties().getProperty(
                    CREATE_SCHEMA_PROPERTY))) {
                loadSchema(dataSource, adapter, cayenneMap);
            }

            long t1 = System.currentTimeMillis();

            // report conflicts...
            ValidationResult conflicts = loader.getContext().getConflicts();
            if (conflicts.hasFailures()) {
                for (Object failure : conflicts.getFailures()) {
                    logger.info("*** mapping conflict: " + failure);
                }
            }

            if (logger.isDebugEnabled()) {
                logger.debug("loaded persistence unit '"
                        + name
                        + "' in "
                        + (t1 - t0)
                        + " ms.");
            }
        }

        // see TODO above - JTA vs RESOURCE_LOCAL is cached per domain... maybe need to
        // change that
        return domain.isUsingExternalTransactions() ? new JtaEntityManagerFactory(
                this,
                domain,
                unit) : new ResourceLocalEntityManagerFactory(this, domain, unit);
    }
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

        if (domain.getName() == null) {
            throw new NullPointerException("Attempt to add DataDomain with no name.");
        }

        DataDomain old = dataDomains.put(domain.getName(), domain);
        if (old != null && old != domain) {
            dataDomains.put(domain.getName(), old);
            throw new IllegalArgumentException("Attempt to overwrite domain with name "
                    + domain.getName());
        }
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

     * this Configuration object. Note that any domain database
     * connections remain open, and it is a responsibility of a
     * caller to clean it up.
     */
    public void removeDomain(String name) {
        DataDomain domain = dataDomains.remove(name);

        if (domain != null) {
            domain.setEventManager(null);
        }
    }
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

    public RuntimeSaveDelegate() {
        super();
    }

    protected DataDomain findDomain(String domainName) {
        DataDomain domain = config.getDomain(domainName);
        if (domain == null) {
            throw new IllegalArgumentException("Can't find DataDomain: " + domainName);
        }

        return domain;
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

        return domain;
    }

    protected DataNode findNode(String domainName, String nodeName) {
        DataDomain domain = findDomain(domainName);
        DataNode node = domain.getNode(nodeName);
        if (node == null) {
            throw new IllegalArgumentException("Can't find DataNode: "
                    + domainName
                    + "."
                    + nodeName);
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

                break;
            }
        }

        // check for dupliucates in other DataMaps
        DataDomain domain = path.firstInstanceOf(DataDomain.class);
        if (domain != null) {
            for (DataMap nextMap : domain.getDataMaps()) {
                if (nextMap == map) {
                    continue;
                }

                ObjEntity conflictingEntity = nextMap.getObjEntity(name);
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

    }

    @Override
    protected DataDomain createAndInitDataDomain() throws Exception {

        DataDomain domain = super.createAndInitDataDomain();

      
        for (DataMap dataMap : domain.getDataMaps()) {

            // add nodes and DataSources dynamically...
            DataNode node = new DataNode(dataMap.getName());
            node.setJdbcEventLogger(jdbcEventLogger);

            // shared or dedicated DataSources can be mapped per DataMap
            node.setDataSource(dataSourceFactory.getDataSource(dataMap.getName()));
            node.setAdapter(adapter);
            node.addDataMap(dataMap);
            node.setSchemaUpdateStrategy(new SkipSchemaUpdateStrategy());

            // tweak procedures for testing...
            for (Procedure proc : dataMap.getProcedures()) {
                unitDbAdapter.tweakProcedure(proc);
            }
           
            // customizations from SimpleAccessStackAdapter that are not yet
            // ported...
            // those can be done better now

            // node
            // .getAdapter()
            // .getExtendedTypes()
            // .registerType(new StringET1ExtendedType());
            //

            domain.addNode(node);
        }

        return domain;
    }
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

            InputSource in = new InputSource(stream);
            in.setSystemId(DATA_MAPS_REQUIREING_SCHEMA_SETUP[i]);
            maps[i] = new MapLoader().loadDataMap(in);
        }

        this.domain = new DataDomain("temp");
        domain.setEventManager(new DefaultEventManager(2));
        domain.setEntitySorter(new AshwoodEntitySorter());
        domain.setQueryCache(new MapQueryCache(50));

        try {
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

            if (namingContext == null) {
                return false;
            }

            if (namingContext instanceof DataDomain) {
                DataDomain domain = (DataDomain) namingContext;
                return domain.getDataMap(name) != null;
            }

            if (namingContext instanceof DataChannelDescriptor) {
                DataChannelDescriptor domain = (DataChannelDescriptor) namingContext;
                return domain.getDataMap(name) != null;
            }
            return false;

        }
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

     *
     * @return a pooled SQL connection
     * @throws SQLException if a database connection could not be obtained
     */
    protected Connection getConnection() throws SQLException {
        DataDomain domain = Configuration.getSharedConfiguration().getDomain();

        DataNode node = domain.getDataNodes().iterator().next();

        return node.getDataSource().getConnection();
    }
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.