Package org.apache.openjpa.util

Examples of org.apache.openjpa.util.MetaDataException


        }
    }

    private void setInterfaceImplInternal(ClassMetaData meta, Class<?> impl) {
            if (!meta.isManagedInterface())
                throw new MetaDataException(_loc.get("not-managed-interface", meta, impl));
            _ifaces.put(meta.getDescribedType(), impl);
            addDeclaredInterfaceImpl(meta, meta.getDescribedType());
            ClassMetaData sup = meta.getPCSuperclassMetaData();
            while (sup != null) {
                // record superclass interface info while we can as well as we
View Full Code Here


     * @param mustExist
     *            if true, throws a {@link MetaDataException} if no metadata is found
     */
    public ClassMetaData getMetaData(Object oid, ClassLoader envLoader, boolean mustExist) {
        if (oid == null && mustExist)
            throw new MetaDataException(_loc.get("no-oid-meta", oid, "?", _oids.toString()));
        if (oid == null)
            return null;

        if (oid instanceof OpenJPAId) {
            Class<?> cls = ((OpenJPAId) oid).getType();
            return getMetaData(cls, envLoader, mustExist);
        }

        // check cache
        processRegisteredClasses(envLoader);
        Class<?> cls = _oids.get(oid.getClass());
        if (cls != null)
            return getMetaData(cls, envLoader, mustExist);

        // maybe this is some type we've seen but just isn't valid
        if (_oids.containsKey(oid.getClass())) {
            if (mustExist)
                throw new MetaDataException(_loc.get("no-oid-meta", oid, oid.getClass(), _oids));
            return null;
        }

        // if still not match, register any classes that look similar to the
        // oid class and check again
        resolveIdentityClass(oid);
        if (processRegisteredClasses(envLoader).length > 0) {
            cls = _oids.get(oid.getClass());
            if (cls != null)
                return getMetaData(cls, envLoader, mustExist);
        }

        // record that this is an invalid type
        _oids.put(oid.getClass(), null);

        if (!mustExist)
            return null;
        throw new MetaDataException(_loc.get("no-oid-meta", oid, oid.getClass(), _oids)).setFailedObject(oid);
    }
View Full Code Here

     * @param mustExist
     *            if true, throws a {@link MetaDataException} if no metadata is found
     */
    public ClassMetaData[] getImplementorMetaDatas(Class<?> cls, ClassLoader envLoader, boolean mustExist) {
        if (cls == null && mustExist)
            throw new MetaDataException(_loc.get("no-meta", cls));
        if (cls == null)
            return EMPTY_METAS;

        // get impls of given interface / abstract class
        loadRegisteredClassMetaData(envLoader);
        Collection<Class<?>> vals = _impls.get(cls);
        ClassMetaData[] mapped = null;
        if (vals != null) {
            if (_locking) {
                synchronized (vals) {
                    mapped = getImplementorMetaDatasInternal(vals, envLoader, mustExist);
                }
            } else {
                mapped = getImplementorMetaDatasInternal(vals, envLoader, mustExist);
            }
        }

        if (mapped == null && mustExist)
            throw new MetaDataException(_loc.get("no-meta", cls));
        if (mapped == null)
            return EMPTY_METAS;
        return mapped;
    }
View Full Code Here

    private NonPersistentMetaData addPersistenceAwareInternal(Class<?> cls) {
            if (_pawares.containsKey(cls))
                return (NonPersistentMetaData) _pawares.get(cls);
            if (getCachedMetaData(cls) != null)
                throw new MetaDataException(_loc.get("pc-and-aware", cls));
            NonPersistentMetaData meta =
                new NonPersistentMetaData(cls, this, NonPersistentMetaData.TYPE_PERSISTENCE_AWARE);
            _pawares.put(cls, meta);
            return meta;
    }
View Full Code Here

     */
    public NonPersistentMetaData addNonMappedInterface(Class<?> iface) {
        if (iface == null)
            return null;
        if (!iface.isInterface())
            throw new MetaDataException(_loc.get("not-non-mapped", iface));
        if (_locking) {
            synchronized (this) {
                return addNonMappedInterfaceInternal(iface);
            }
        } else {
View Full Code Here

   
    private NonPersistentMetaData addNonMappedInterfaceInternal(Class<?> iface) {
            if (_nonMapped.containsKey(iface))
                return (NonPersistentMetaData) _nonMapped.get(iface);
            if (getCachedMetaData(iface) != null)
                throw new MetaDataException(_loc.get("non-mapped-pc", iface));
            NonPersistentMetaData meta =
                new NonPersistentMetaData(iface, this, NonPersistentMetaData.TYPE_NON_MAPPED_INTERFACE);
            _nonMapped.put(iface, meta);
            return meta;
        }
View Full Code Here

            Set<String> names = getPersistentTypeNames(devpath, envLoader);
            if (names == null || names.isEmpty()) {
                if (!mustExist)
                    return Collections.emptyList();
                else
                    throw new MetaDataException(_loc.get("eager-no-class-found"));
            }

            // attempt to load classes so that they get processed
            ClassLoader clsLoader = _conf.getClassResolverInstance().getClassLoader(getClass(), envLoader);
            List<Class<?>> classes = new ArrayList<Class<?>>(names.size());
            Class<?> cls;
            for (String className : names) {
                cls = classForName(className, clsLoader);
                if (_factory.isMetaClass(cls)) {
                    setMetaModel(cls);
                    continue;
                }
                if (cls != null) {
                    classes.add(cls);

                    // if the class is an interface, load its metadata to kick
                    // off the impl generator
                    if (cls.isInterface())
                        getMetaData(cls, clsLoader, false);
                } else if (cls == null && mustExist) {
                    throw new MetaDataException(_loc.get("eager-class-not-found", className));
                }
            }
            return classes;
    }
View Full Code Here

            checkEnhancementLevel(reg[i]);
            try {
                processRegisteredClass(reg[i]);
            } catch (Throwable t) {
                if (!_conf.getRetryClassRegistration())
                    throw new MetaDataException(_loc.get("error-registered", reg[i]), t);

                if (_log.isWarnEnabled())
                    _log.warn(_loc.get("failed-registered", reg[i]), t);
                if (failed == null)
                    failed = new ArrayList<Class<?>>();
View Full Code Here

    private void initializeMetaDataFactory() {
        if (_factory == null) {
            MetaDataFactory mdf = _conf.newMetaDataFactoryInstance();
            if (mdf == null)
                throw new MetaDataException(_loc.get("no-metadatafactory"));
            setMetaDataFactory(mdf);
        }
    }
View Full Code Here

                meta = getQueryMetaDataInternal(cls, name, envLoader);
            }

            if (meta == null && mustExist) {
                if (cls == null) {
                    throw new MetaDataException(_loc.get("no-named-query-null-class", getPersistentTypeNames(false,
                        envLoader), name));
                } else {
                    throw new MetaDataException(_loc.get("no-named-query", cls, name));
                }
            }

            return meta;
    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.util.MetaDataException

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.