/** * Load the persistent classes named in configuration. * This ensures that all subclasses and application identity classes of * each type are known in advance, without having to rely on the * application loading the classes before performing operations that * might involve them. * * @param devpath if true, search for metadata files in directories * in the classpath if the no classes are configured explicitly * @param envLoader the class loader to use, or null for default * @return the loaded classes, or empty collection if none */ public Collection<Class<?>> loadPersistentTypes(boolean devpath, ClassLoader envLoader) { return loadPersistentTypes(devpath, envLoader, false); } /**
/** * Load the persistent classes named in configuration. * This ensures that all subclasses and application identity classes of * each type are known in advance, without having to rely on the * application loading the classes before performing operations that * might involve them. * * @param devpath if true, search for metadata files in directories * in the classpath if the no classes are configured explicitly * @param envLoader the class loader to use, or null for default * @return the loaded classes, or empty collection if none */ public Collection<Class<?>> loadPersistentTypes(boolean devpath, ClassLoader envLoader) { return loadPersistentTypes(devpath, envLoader, false); } /**
/** * Load the persistent classes named in configuration. * This ensures that all subclasses and application identity classes of * each type are known in advance, without having to rely on the * application loading the classes before performing operations that * might involve them. * * @param devpath if true, search for metadata files in directories * in the classpath if the no classes are configured explicitly * @param envLoader the class loader to use, or null for default * @return the loaded classes, or empty collection if none */ public Collection<Class<?>> loadPersistentTypes(boolean devpath, ClassLoader envLoader) { return loadPersistentTypes(devpath, envLoader, false); } /**
/** * Load the persistent classes named in configuration. * This ensures that all subclasses and application identity classes of * each type are known in advance, without having to rely on the * application loading the classes before performing operations that * might involve them. * * @param devpath if true, search for metadata files in directories * in the classpath if the no classes are configured explicitly * @param envLoader the class loader to use, or null for default * @return the loaded classes, or empty collection if none */ public Collection<Class<?>> loadPersistentTypes(boolean devpath, ClassLoader envLoader) { return loadPersistentTypes(devpath, envLoader, false); } /**
/** * Resolve all known metadata classes. */ private void resolveAll(ClassLoader envLoader) { Collection<Class<?>> types = loadPersistentTypes(false, envLoader); for (Class<?> c : types) { getMetaData(c, envLoader, false); } }
/** * Resolve all known metadata classes. */ private void resolveAll(ClassLoader envLoader) { Collection<Class<?>> types = loadPersistentTypes(false, envLoader); for (Class<?> c : types) { getMetaData(c, envLoader, false); } }
/** * Resolve all known metadata classes. */ private void resolveAll(ClassLoader envLoader) { Collection types = loadPersistentTypes(false, envLoader); for (Iterator i = types.iterator(); i.hasNext(); ) { Class c = (Class) i.next(); getMetaData(c, envLoader, false); } }
/** * Resolve all known metadata classes. */ private void resolveAll(ClassLoader envLoader) { Collection<Class<?>> types = loadPersistentTypes(false, envLoader); for (Class<?> c : types) { getMetaData(c, envLoader, false); } }
/** * Resolve all known metadata classes. */ private void resolveAll(ClassLoader envLoader) { Collection<Class<?>> types = loadPersistentTypes(false, envLoader); for (Class<?> c : types) { getMetaData(c, envLoader, false); } }
@Override public Class<?> getResultSetMappingScope(String rsMappingName, ClassLoader loader) { if (rsMappingName == null) return null; Collection<Class<?>> classes = repos.loadPersistentTypes(false, loader); for (Class<?> cls : classes) { if ((AccessController.doPrivileged(J2DoPrivHelper .isAnnotationPresentAction(cls, SqlResultSetMapping.class))) .booleanValue() && hasRSMapping(rsMappingName, (SqlResultSetMapping) cls. getAnnotation(SqlResultSetMapping.class))) return cls; if ((AccessController.doPrivileged(J2DoPrivHelper .isAnnotationPresentAction(cls, SqlResultSetMappings.class))) .booleanValue() && hasRSMapping(rsMappingName, ((SqlResultSetMappings) cls. getAnnotation(SqlResultSetMappings.class)).value())) return cls; } return null; }
@Override public Class getResultSetMappingScope(String rsMappingName, ClassLoader loader) { if (rsMappingName == null) return null; Collection classes = repos.loadPersistentTypes(false, loader); for (Class cls : (Collection<Class>) classes) { if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(cls, SqlResultSetMapping.class))) .booleanValue() && hasRSMapping(rsMappingName, (SqlResultSetMapping) cls. getAnnotation(SqlResultSetMapping.class))) return cls; if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(cls, SqlResultSetMappings.class))) .booleanValue() && hasRSMapping(rsMappingName, ((SqlResultSetMappings) cls. getAnnotation(SqlResultSetMappings.class)).value())) return cls; } return null; }
@Override public Class<?> getResultSetMappingScope(String rsMappingName, ClassLoader loader) { if (rsMappingName == null) return null; Collection<Class<?>> classes = repos.loadPersistentTypes(false, loader); for (Class<?> cls : classes) { if ((AccessController.doPrivileged(J2DoPrivHelper .isAnnotationPresentAction(cls, SqlResultSetMapping.class))) .booleanValue() && hasRSMapping(rsMappingName, (SqlResultSetMapping) cls. getAnnotation(SqlResultSetMapping.class))) return cls; if ((AccessController.doPrivileged(J2DoPrivHelper .isAnnotationPresentAction(cls, SqlResultSetMappings.class))) .booleanValue() && hasRSMapping(rsMappingName, ((SqlResultSetMappings) cls. getAnnotation(SqlResultSetMappings.class)).value())) return cls; } return null; }
@Override public Class<?> getResultSetMappingScope(String rsMappingName, ClassLoader loader) { if (rsMappingName == null) return null; Collection<Class<?>> classes = repos.loadPersistentTypes(false, loader); for (Class<?> cls : classes) { if ((AccessController.doPrivileged(J2DoPrivHelper .isAnnotationPresentAction(cls, SqlResultSetMapping.class))) .booleanValue() && hasRSMapping(rsMappingName, (SqlResultSetMapping) cls. getAnnotation(SqlResultSetMapping.class))) return cls; if ((AccessController.doPrivileged(J2DoPrivHelper .isAnnotationPresentAction(cls, SqlResultSetMappings.class))) .booleanValue() && hasRSMapping(rsMappingName, ((SqlResultSetMappings) cls. getAnnotation(SqlResultSetMappings.class)).value())) return cls; } return null; }
@Override public Class<?> getResultSetMappingScope(String rsMappingName, ClassLoader loader) { if (rsMappingName == null) return null; Collection<Class<?>> classes = repos.loadPersistentTypes(false, loader); for (Class<?> cls : classes) { if ((AccessController.doPrivileged(J2DoPrivHelper .isAnnotationPresentAction(cls, SqlResultSetMapping.class))) .booleanValue() && hasRSMapping(rsMappingName, (SqlResultSetMapping) cls. getAnnotation(SqlResultSetMapping.class))) return cls; if ((AccessController.doPrivileged(J2DoPrivHelper .isAnnotationPresentAction(cls, SqlResultSetMappings.class))) .booleanValue() && hasRSMapping(rsMappingName, ((SqlResultSetMappings) cls. getAnnotation(SqlResultSetMappings.class)).value())) return cls; } return null; }
/** * The metadata repository for the factory that this instance was * constructed with will be serialized, along with any query * compilations etc. that have been created for the factory. */ public void store() { MetaDataRepository repos = conf.getMetaDataRepositoryInstance(); repos.setSourceMode(MetaDataRepository.MODE_ALL); Collection types = repos.loadPersistentTypes(devpath, null); for (Iterator iter = types.iterator(); iter.hasNext(); ) repos.getMetaData((Class) iter.next(), null, true); loadQueries(); log.info("The following data will be stored: "); log(repos, conf.getQueryCompilationCacheInstance()); CacheMarshallersValue.getMarshallerById(conf, getClass().getName()) .store(new Object[] { repos, conf.getQueryCompilationCacheInstance() }); }
/** * The metadata repository for the factory that this instance was * constructed with will be serialized, along with any query * compilations etc. that have been created for the factory. */ public void store() { MetaDataRepository repos = conf.getMetaDataRepositoryInstance(); repos.setSourceMode(MetaDataRepository.MODE_ALL); Collection types = repos.loadPersistentTypes(devpath, null); for (Iterator iter = types.iterator(); iter.hasNext(); ) repos.getMetaData((Class) iter.next(), null, true); loadQueries(); log.info("The following data will be stored: "); log(repos, conf.getQueryCompilationCacheInstance()); CacheMarshallersValue.getMarshallerById(conf, getClass().getName()) .store(new Object[] { repos, conf.getQueryCompilationCacheInstance() }); }
/** * The metadata repository for the factory that this instance was * constructed with will be serialized, along with any query * compilations etc. that have been created for the factory. */ public void store() { MetaDataRepository repos = conf.getMetaDataRepositoryInstance(); repos.setSourceMode(MetaDataRepository.MODE_ALL); Collection types = repos.loadPersistentTypes(devpath, null); for (Iterator iter = types.iterator(); iter.hasNext(); ) repos.getMetaData((Class) iter.next(), null, true); loadQueries(); log.info("The following data will be stored: "); log(repos, conf.getQueryCompilationCacheInstance()); CacheMarshallersValue.getMarshallerById(conf, getClass().getName()) .store(new Object[] { repos, conf.getQueryCompilationCacheInstance() }); }
/** * The metadata repository for the factory that this instance was * constructed with will be serialized, along with any query * compilations etc. that have been created for the factory. */ public void store() { MetaDataRepository repos = conf.getMetaDataRepositoryInstance(); repos.setSourceMode(MetaDataRepository.MODE_ALL); Collection types = repos.loadPersistentTypes(devpath, null); for (Iterator iter = types.iterator(); iter.hasNext(); ) repos.getMetaData((Class) iter.next(), null, true); loadQueries(); log.info("The following data will be stored: "); log(repos, conf.getQueryCompilationCacheInstance()); CacheMarshallersValue.getMarshallerById(conf, getClass().getName()) .store(new Object[] { repos, conf.getQueryCompilationCacheInstance() }); }
/** * The metadata repository for the factory that this instance was * constructed with will be serialized, along with any query * compilations etc. that have been created for the factory. */ public void store() { MetaDataRepository repos = conf.getMetaDataRepositoryInstance(); repos.setSourceMode(MetaDataRepository.MODE_ALL); Collection types = repos.loadPersistentTypes(devpath, null); for (Iterator iter = types.iterator(); iter.hasNext(); ) repos.getMetaData((Class) iter.next(), null, true); loadQueries(); log.info("The following data will be stored: "); log(repos, conf.getQueryCompilationCacheInstance()); CacheMarshallersValue.getMarshallerById(conf, getClass().getName()) .store(new Object[] { repos, conf.getQueryCompilationCacheInstance() }); }
public void injectLifecycle(EntityManagerFactory entityManagerFactory, JpaGpsDevice device) throws JpaGpsDeviceException { CompassGpsInterfaceDevice gps = (CompassGpsInterfaceDevice) device.getGps(); // TODO this should use OpenJPAEnitiyManagerFactorySPI, here for backward compatability with pre 1.0 EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) OpenJPAPersistence.cast(entityManagerFactory); if (eventListener == null) { eventListener = new OpenJPAEventListener(device); } if (useSpecificClassEvents) { ArrayList<Class> matchedClasses = new ArrayList<Class>(); Collection<Class> classes = emf.getConfiguration().getMetaDataRepositoryInstance().loadPersistentTypes(true, classLoader); for (Class clazz : classes) { ClassMetaData classMetaData = emf.getConfiguration().getMetaDataRepositoryInstance().getMetaData(clazz, classLoader, true); Class mappedClass = classMetaData.getDescribedType(); if (gps.hasMappingForEntityForMirror(mappedClass, Cascade.ALL)) { matchedClasses.add(mappedClass); } } if (matchedClasses.size() > 0) { emf.addLifecycleListener(eventListener, matchedClasses.toArray(new Class[0])); } } else { emf.addLifecycleListener(eventListener); } }