Package org.apache.openjpa.meta

Examples of org.apache.openjpa.meta.MetaDataRepository


            .addLifecycleListener(listener, new Class[]{ RuntimeTest4.class });

        try {
            BrokerImpl broker = (BrokerImpl) JPAFacadeHelper.toBroker
                (pmf.createEntityManager());
            MetaDataRepository repos = broker.getConfiguration().
                getMetaDataRepositoryInstance();
            assertTrue("no listeners defined added to Runtimetest4",
                broker.getLifecycleEventManager().hasLoadListeners(
                    new RuntimeTest4("foo"),
                    repos.getMetaData(RuntimeTest4.class, null, true)));
            assertFalse("there should be listeners def for runtimetest1",
                broker.getLifecycleEventManager().hasLoadListeners
                    (new RuntimeTest1(), repos.getMetaData
                        (RuntimeTest1.class, null, true)));
            broker.close();
        } finally {
            pmfSPI.removeLifecycleListener(listener);
        }
View Full Code Here


            // setup transient state
            setup();

            // register the metdata repository to auto-load persistent types
            // and make sure types are enhanced
            MetaDataRepository repos = _conf.getMetaDataRepositoryInstance();
            repos.setValidate(MetaDataRepository.VALIDATE_RUNTIME, true);
            repos.setResolve(MetaDataModes.MODE_MAPPING_INIT, true);
            PCRegistry.addRegisterClassListener(repos);

            // freeze underlying configuration and eagerly initialize to
            // avoid synchronization
            _conf.setReadOnly(Configuration.INIT_STATE_FREEZING);
View Full Code Here

                _conf.isConnectionFactoryModeManaged(), _conf.getConnectionRetainModeConstant(), false).close();
        }
        // Don't catch any exceptions here because we want to fail-fast if something bad happens when we're preloading.
        Options o = Configurations.parseProperties(Configurations.getProperties(_conf.getMetaDataRepository()));
        if (MetaDataRepository.needsPreload(o) == true) {
            MetaDataRepository mdr = _conf.getMetaDataRepositoryInstance();
            mdr.setValidate(MetaDataRepository.VALIDATE_RUNTIME, true);
            mdr.setResolve(MetaDataRepository.MODE_MAPPING_INIT, true);

            // Load persistent classes and hook in subclasser
            loadPersistentTypes((ClassLoader) AccessController.doPrivileged(J2DoPrivHelper
                .getContextClassLoaderAction()));
            mdr.preload();
        }

        // Get a DataCacheManager instance up front to avoid threading concerns on first call.
        // _conf.getDataCacheManagerInstance();
View Full Code Here

        deleteAll(PCClassPC.class);
    }

    public void testMetaData() {

        MetaDataRepository repos = getConfiguration()
            .getMetaDataRepositoryInstance();
        ClassMetaData meta = repos.getMetaData(PCClassPC.class, null, true);

        FieldMetaData fmd = meta.getField("specificPC");
        assertNotNull("fmd is nulll", fmd);
        assertEquals("JavaTypes.PC != fmd.getTypeCode()", JavaTypes.PC,
            fmd.getTypeCode());
View Full Code Here

  public void testPreloadBasic() {
    OpenJPAEntityManagerFactorySPI emf = null;
    try {
      emf = createNamedEMF(PU_NAME, "openjpa.MetaDataRepository",
          "Preload=true");
      MetaDataRepository mdr = emf.getConfiguration()
          .getMetaDataRepositoryInstance();

      // Check that there is cached metadata in the repo
      ClassMetaData metadata = mdr.getCachedMetaData(MdrTestEntity.class);
      assertNotNull(metadata);

      // Make sure that there is an alias registered
      // int numEntities =
      // mdr.getPersistentTypeNames(false,
      // AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction())).size();
      Collection<String> aliases = mdr.getAliasNames();
      assertTrue(aliases.contains("MdrTestEntity"));

      // assertTrue(aliases.size() == numEntities);

      QueryMetaData query = mdr.getCachedQueryMetaData("query");
      assertNotNull(query);
    } finally {
      closeEMF(emf);
    }
  }
View Full Code Here

  }
 
  public void testPreloadCleanUp() {
        OpenJPAEntityManagerFactorySPI emf = null;
        emf = createNamedEMF(PU_NAME, "openjpa.MetaDataRepository", "Preload=true");
        MetaDataRepository repo = emf.getConfiguration().getMetaDataRepositoryInstance();
        emf.createEntityManager();
        closeEMF(emf);
        assertFalse("The PCRegistry should no longer reference the MetaDataRepository.", PCRegistry
            .removeRegisterClassListener(repo));
    }
View Full Code Here

        OpenJPAEntityManagerFactorySPI emf = null;
        try {
            emf =
                createNamedEMF("test", "openjpa.MetaDataRepository", "Preload=true", Customer.class,
                    Customer.CustomerKey.class, Order.class, EAddress.class);
            MetaDataRepository mdr = emf.getConfiguration().getMetaDataRepositoryInstance();

            assertNotNull(mdr.getCachedXMLMetaData(Address.class));
            assertNull(mdr.getCachedXMLMetaData(Order.class));
           

        } finally {
            closeEMF(emf);
        }
View Full Code Here

     * Returns the repository for this parser. If none has been set, creates
     * a new repository and sets it.
     */
    public MetaDataRepository getRepository() {
        if (_repos == null) {
            MetaDataRepository repos = _conf.newMetaDataRepositoryInstance();
            MetaDataFactory mdf = repos.getMetaDataFactory();
            if (mdf instanceof DelegatingMetaDataFactory)
                mdf = ((DelegatingMetaDataFactory) mdf).getInnermostDelegate();
            if (mdf instanceof PersistenceMetaDataFactory)
                ((PersistenceMetaDataFactory) mdf).setXMLParser(this);
            _repos = repos;
View Full Code Here

        Log log = getLog();
        if (log.isTraceEnabled())
            log.trace(_loc.get("parse-class", _cls.getName()));

        MetaDataRepository repos = getRepository();
        ClassMetaData meta = repos.getCachedMetaData(_cls);
        if (meta != null
            && ((isMetaDataMode() && (meta.getSourceMode() & MODE_META) != 0)
            || (isMappingMode() && (meta.getSourceMode() & MODE_MAPPING) != 0)))
        {
            if(isDuplicateClass(meta)) {
                if (log.isWarnEnabled()) {
                    log.warn(_loc.get("dup-metadata", _cls, getSourceName()));
                }
                if(log.isTraceEnabled()) {
                    log.trace(String.format(
                        "MetaData originally obtained from source: %s under mode: %d with scope: %s, and type: %d",
                        meta.getSourceName(), meta.getSourceMode(), meta.getSourceScope(), meta.getSourceType()));
                }
            }
            _cls = null;
            return false;
        }
       
        int access = AccessCode.UNKNOWN;
        if (meta == null) {
            int accessCode = toAccessType(attrs.getValue("access"));
            // if access not specified and access was specified at
            // the system level, use the system default (which may
            // be UNKNOWN)
            if (accessCode == AccessCode.UNKNOWN)
                accessCode = _access;
            meta = repos.addMetaData(_cls, accessCode, metaDataComplete);
            FieldMetaData[] fmds = meta.getFields();
            if (metaDataComplete) {
                for (int i = 0; i < fmds.length; i++) {
                    fmds[i].setExplicit(true);
                }
View Full Code Here

        return lineNum;
    }
   
    private boolean startDatastoreId(Attributes attrs)
            throws SAXException {
        MetaDataRepository repos = getRepository();
        ClassMetaData meta = repos.getCachedMetaData(_cls);
       
        //Set default value if not specified
        String strategy = attrs.getValue("strategy");
        if (StringUtils.isEmpty(strategy)) {
            strategy ="AUTO"    ;
View Full Code Here

TOP

Related Classes of org.apache.openjpa.meta.MetaDataRepository

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.