Package org.apache.openjpa.meta

Examples of org.apache.openjpa.meta.MetaDataRepository


     */
    public ApplicationIdTool(OpenJPAConfiguration conf, Class type) {
        _log = conf.getLog(OpenJPAConfiguration.LOG_ENHANCE);
        _type = type;

        MetaDataRepository repos = conf.newMetaDataRepositoryInstance();
        repos.setValidate(repos.VALIDATE_NONE);
        repos.setSourceMode(repos.MODE_MAPPING, false);
        loadObjectIds(repos, true);
        _meta = repos.getMetaData(type, null, false);
        if (_meta != null) {
            _abstract = Modifier.isAbstract(_meta.getDescribedType().
                getModifiers());
            _fields = getDeclaredPrimaryKeyFields(_meta);
        }
View Full Code Here


     * Run the tool. Returns false if invalid options were given.
     */
    public static boolean run(OpenJPAConfiguration conf, String[] args,
        Flags flags, ClassLoader loader)
        throws IOException, ClassNotFoundException {
        MetaDataRepository repos = conf.newMetaDataRepositoryInstance();
        repos.setValidate(repos.VALIDATE_NONE, true);
        loadObjectIds(repos, flags.name == null && flags.suffix == null);

        Log log = conf.getLog(OpenJPAConfiguration.LOG_TOOL);
        Collection classes;
        if (args.length == 0) {
            log.info(_loc.get("running-all-classes"));
            classes = repos.loadPersistentTypes(true, loader);
        } else {
            ClassArgParser cap = conf.getMetaDataRepositoryInstance().
                getMetaDataFactory().newClassArgParser();
            cap.setClassLoader(loader);
            classes = new HashSet();
            for (int i = 0; i < args.length; i++)
                classes.addAll(Arrays.asList(cap.parseTypes(args[i])));
        }
        if (flags.name != null && classes.size() > 1)
            throw new UserException(_loc.get("name-mult-args", classes));

        ApplicationIdTool tool;
        Class cls;
        ClassMetaData meta;
        BCClassLoader bc = (BCClassLoader) AccessController
            .doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(new Project()));
        for (Iterator itr = classes.iterator(); itr.hasNext();) {
            cls = (Class) itr.next();
            log.info(_loc.get("appid-running", cls));

            meta = repos.getMetaData(cls, null, false);
            setObjectIdType(meta, flags, bc);

            tool = new ApplicationIdTool(conf, cls, meta);
            tool.setDirectory(flags.directory);
            tool.setIgnoreErrors(flags.ignoreErrors);
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(repos.VALIDATE_RUNTIME, true);
            repos.setResolve(repos.MODE_MAPPING_INIT, true);
            PCRegistry.addRegisterClassListener(repos);

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

      Class<?> cls = meta.getDescribedType();
      Class<?> sup = cls.getSuperclass();
      if (sup == null || "java.lang.Object".equals(
          sup.getName()))
        return null;
      MetaDataRepository repos = meta.getRepository();
      ClassMetaData supMeta = repos.getCachedMetaData(sup);
      if (supMeta == null)
        supMeta = repos.getMetaData(sup, null, false);
      return supMeta;
    }
View Full Code Here

            CacheObjectA a2 = (CacheObjectA) em2.find(CacheObjectA.class, oid);

            // assert that the oid is in factory2's cache
            //MetaDataRepository repos2 = factory2.getConfiguration()
            //    .getMetaDataRepositoryInstance();
            MetaDataRepository repos2 =
                ((((OpenJPAEntityManagerFactorySPI) factory2))
                .getConfiguration()).getMetaDataRepositoryInstance();
            ClassMetaData meta = repos2
                .getMetaData(CacheObjectA.class, em2.getClassLoader(), true);
            cache = meta.getDataCache();
            assertTrue(cache.contains(oidwithclass));

            // modify the object.
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 (log.isWarnEnabled())
                log.warn(_loc.get("dup-metadata", _cls, getSourceName()));
            _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

            // cached instance?
            StateManagerImpl sm = null;
            if (!copy.isEmbedded())
                sm = getStateManagerImplById(oid, true);
            if (sm == null) {
                MetaDataRepository repos = _conf.
                    getMetaDataRepositoryInstance();
                ClassMetaData meta = repos.getMetaData(type, _loader, true);
                // construct a new state manager with all info known
                sm = newStateManagerImpl(oid, meta);
                sm.setObjectId(oid);
                sm.initialize(sm.getMetaData().getDescribedType(), state);
            }
View Full Code Here

     * Returns the repository for this parser. If none has been set,
     * create 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).setAnnotationParser(this);
            _repos = repos;
View Full Code Here

    em = emf.createEntityManager();
    createData(CHILD_COUNT);
  }

  public void xtestStrategies() {
    MetaDataRepository repos = emf.getConfiguration()
        .getMetaDataRepositoryInstance();
    for (int i = 0; i < VALUE_STRATEGIES.length; i++) {
            ClassMetaData meta = repos.getMetaData(PARENT_ID_TYPES[i], null,
                    true);
      FieldMetaData fmd = meta.getPrimaryKeyFields()[0];
            assertEquals(fmd + " strategy is " + fmd.getValueStrategy(),
                    VALUE_STRATEGIES[i], fmd.getValueStrategy());
    }
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.