org.apache.openjpa.meta
Class AbstractCFMetaDataFactory

java.lang.Object
  extended by org.apache.openjpa.meta.AbstractMetaDataFactory
      extended by org.apache.openjpa.meta.AbstractCFMetaDataFactory
All Implemented Interfaces:
MetaDataFactory, MetaDataModes

public abstract class AbstractCFMetaDataFactory
extends AbstractMetaDataFactory

Base class for factory implementations built around XML metadata files in the common fomat.

Since:
4.0
Author:
Abe White

Nested Class Summary
static interface AbstractCFMetaDataFactory.Parser
          Internal parser interface.
static interface AbstractCFMetaDataFactory.Serializer
          Internal serializer interface.
 
Field Summary
protected  java.util.Collection cpath
           
protected  java.util.Collection files
           
protected  java.util.Collection rsrcs
           
protected  java.util.Collection urls
           
 
Fields inherited from class org.apache.openjpa.meta.AbstractMetaDataFactory
dir, log, repos, store, strict, types
 
Fields inherited from interface org.apache.openjpa.meta.MetaDataFactory
STORE_DEFAULT, STORE_PER_CLASS, STORE_VERBOSE
 
Fields inherited from interface org.apache.openjpa.meta.MetaDataModes
MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY
 
Constructor Summary
AbstractCFMetaDataFactory()
           
 
Method Summary
protected  void backupAndDelete(java.util.Collection files)
          Backup and delete the source files for the given metadatas.
 void clear()
          Clear any internal caches.
protected  void clearMapping(ClassMetaData meta)
          Clear mapping information from the given metadata.
protected abstract  java.io.File defaultSourceFile(ClassMetaData meta)
          Return the default file for the given metadata.
protected abstract  java.io.File defaultSourceFile(QueryMetaData query, java.util.Map clsNames)
          Return a default file for the given query.
protected abstract  java.io.File defaultSourceFile(SequenceMetaData seq, java.util.Map clsNames)
          Return a default file for the given sequence.
 boolean drop(java.lang.Class[] cls, int mode, java.lang.ClassLoader envLoader)
          Drop the metadata for the given classes in the given mode(s).
protected  ClassMetaData getDefiningMetaData(QueryMetaData query, java.util.Map clsNames)
          Return the metadata that defines the given query, if any.
 java.util.Set getPersistentTypeNames(boolean devpath, java.lang.ClassLoader envLoader)
          Return all persistent class names, using the metadata locations supplied in configuration, optionally scanning the classpath.
protected  java.io.File getSourceFile(ClassMetaData meta)
          Return the current source file of the given metadata.
protected  java.io.File getSourceFile(SequenceMetaData meta)
          Return the current source file of the given metadata.
protected  boolean isMappingOnlyFactory()
          Return true if this factory deals only with mapping data, and relies on a separate factory for metadata.
protected  boolean isParseTopDown()
          Whether to parse classes top down.
protected  void mapPersistentTypeNames(java.lang.Object rsrc, java.lang.String[] names)
          Implement this method to map metadata resources to the persistent types contained within them.
protected abstract  org.apache.openjpa.lib.meta.MetaDataFilter newMetaDataFilter()
          Return a metadata filter that identifies metadata resources when performing jar and classpath scans.
protected abstract  AbstractCFMetaDataFactory.Parser newParser(boolean loading)
          Create a new metadata parser.
protected abstract  AbstractCFMetaDataFactory.Serializer newSerializer()
          Create a new metadata serializer.
protected  void parse(org.apache.openjpa.lib.meta.MetaDataParser parser, java.lang.Class[] cls)
          Parse all given classses.
protected  void parse(org.apache.openjpa.lib.meta.MetaDataParser parser, java.util.Collection files)
          Parse all given files.
protected  void serialize(org.apache.openjpa.lib.meta.MetaDataSerializer ser, java.util.Map output, int flags)
          Tell the given serialier to write its metadatas.
 void setClasspathScan(java.util.Collection cpath)
          Set of classpath directories or jars to scan for metadata supplied by user.
 void setClasspathScan(java.lang.String cpath)
          Set of classpath directories or jars to scan for metadata supplied by user via auto-configuration.
 void setFiles(java.util.Collection files)
          Set of Files of metadata files or directories supplied by user.
 void setFiles(java.lang.String files)
          Set of semicolon-separated Files of metadata files or directories supplied by user via auto-configuration.
 void setResources(java.util.Collection rsrcs)
          Set of resource paths of metadata files or jars supplied by user.
 void setResources(java.lang.String rsrcs)
          Set of semicolon-separated resource paths of metadata files or jars supplied by user via auto-configuration.
protected  void setSourceFile(ClassMetaData meta, java.io.File sourceFile)
          Set the current source file of the given metadata.
protected  void setSourceFile(SequenceMetaData meta, java.io.File sourceFile)
          Set the current source file of the given metadata.
 void setURLs(java.util.Collection urls)
          Set of URLs of metadata files or jars supplied by user.
 void setURLs(java.lang.String urls)
          Set of semicolon-separated URLs of metadata files or jars supplied by user via auto-configuration.
 boolean store(ClassMetaData[] metas, QueryMetaData[] queries, SequenceMetaData[] seqs, int mode, java.util.Map output)
          Store the given metadata.
 
Methods inherited from class org.apache.openjpa.meta.AbstractMetaDataFactory
addClassExtensionKeys, addFieldExtensionKeys, getQueryScope, newClassArgParser, setRepository, setStoreDirectory, setStoreMode, setStrict, setTypes, setTypes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.openjpa.meta.MetaDataFactory
getDefaults, load
 

Field Detail

files

protected java.util.Collection files

urls

protected java.util.Collection urls

rsrcs

protected java.util.Collection rsrcs

cpath

protected java.util.Collection cpath
Constructor Detail

AbstractCFMetaDataFactory

public AbstractCFMetaDataFactory()
Method Detail

setFiles

public void setFiles(java.util.Collection files)
Set of Files of metadata files or directories supplied by user.


setFiles

public void setFiles(java.lang.String files)
Set of semicolon-separated Files of metadata files or directories supplied by user via auto-configuration.


setURLs

public void setURLs(java.util.Collection urls)
Set of URLs of metadata files or jars supplied by user.


setURLs

public void setURLs(java.lang.String urls)
Set of semicolon-separated URLs of metadata files or jars supplied by user via auto-configuration.


setResources

public void setResources(java.util.Collection rsrcs)
Set of resource paths of metadata files or jars supplied by user.


setResources

public void setResources(java.lang.String rsrcs)
Set of semicolon-separated resource paths of metadata files or jars supplied by user via auto-configuration.


setClasspathScan

public void setClasspathScan(java.util.Collection cpath)
Set of classpath directories or jars to scan for metadata supplied by user.


setClasspathScan

public void setClasspathScan(java.lang.String cpath)
Set of classpath directories or jars to scan for metadata supplied by user via auto-configuration.


store

public boolean store(ClassMetaData[] metas,
                     QueryMetaData[] queries,
                     SequenceMetaData[] seqs,
                     int mode,
                     java.util.Map output)
Description copied from interface: MetaDataFactory
Store the given metadata.

Specified by:
store in interface MetaDataFactory
Overrides:
store in class AbstractMetaDataFactory
mode - hint about what aspects of the metadata have changed
output - if non-null, rather than storing metadata directly, add entries mapping each output destination such as a File to the planned output for that destination in string form
Returns:
false if this factory is unable to store metadata

drop

public boolean drop(java.lang.Class[] cls,
                    int mode,
                    java.lang.ClassLoader envLoader)
Description copied from interface: MetaDataFactory
Drop the metadata for the given classes in the given mode(s).

Specified by:
drop in interface MetaDataFactory
Overrides:
drop in class AbstractMetaDataFactory
Returns:
false if any metadata could not be dropped

isMappingOnlyFactory

protected boolean isMappingOnlyFactory()
Return true if this factory deals only with mapping data, and relies on a separate factory for metadata.


parse

protected void parse(org.apache.openjpa.lib.meta.MetaDataParser parser,
                     java.util.Collection files)
Parse all given files.


parse

protected void parse(org.apache.openjpa.lib.meta.MetaDataParser parser,
                     java.lang.Class[] cls)
Parse all given classses.


isParseTopDown

protected boolean isParseTopDown()
Whether to parse classes top down. Defaults to false.


serialize

protected void serialize(org.apache.openjpa.lib.meta.MetaDataSerializer ser,
                         java.util.Map output,
                         int flags)
Tell the given serialier to write its metadatas.


backupAndDelete

protected void backupAndDelete(java.util.Collection files)
Backup and delete the source files for the given metadatas.


clearMapping

protected void clearMapping(ClassMetaData meta)
Clear mapping information from the given metadata.


getSourceFile

protected java.io.File getSourceFile(ClassMetaData meta)
Return the current source file of the given metadata.


setSourceFile

protected void setSourceFile(ClassMetaData meta,
                             java.io.File sourceFile)
Set the current source file of the given metadata.


getSourceFile

protected java.io.File getSourceFile(SequenceMetaData meta)
Return the current source file of the given metadata.


setSourceFile

protected void setSourceFile(SequenceMetaData meta,
                             java.io.File sourceFile)
Set the current source file of the given metadata.


defaultSourceFile

protected abstract java.io.File defaultSourceFile(ClassMetaData meta)
Return the default file for the given metadata.


defaultSourceFile

protected abstract java.io.File defaultSourceFile(QueryMetaData query,
                                                  java.util.Map clsNames)
Return a default file for the given query.


defaultSourceFile

protected abstract java.io.File defaultSourceFile(SequenceMetaData seq,
                                                  java.util.Map clsNames)
Return a default file for the given sequence.


newParser

protected abstract AbstractCFMetaDataFactory.Parser newParser(boolean loading)
Create a new metadata parser.

Parameters:
loading - if true, this will be the cached parser used for loading metadata

newSerializer

protected abstract AbstractCFMetaDataFactory.Serializer newSerializer()
Create a new metadata serializer.


getDefiningMetaData

protected ClassMetaData getDefiningMetaData(QueryMetaData query,
                                            java.util.Map clsNames)
Return the metadata that defines the given query, if any.

Parameters:
clsNames - map of class names to metadatas

getPersistentTypeNames

public java.util.Set getPersistentTypeNames(boolean devpath,
                                            java.lang.ClassLoader envLoader)
Description copied from interface: MetaDataFactory
Return all persistent class names, using the metadata locations supplied in configuration, optionally scanning the classpath. Return null if no types are supplied and this factory is unable to scan the classpath. This method should not be used directly by outside code; use MetaDataRepository.getPersistentTypeNames(boolean, java.lang.ClassLoader) instead.

Specified by:
getPersistentTypeNames in interface MetaDataFactory
Overrides:
getPersistentTypeNames in class AbstractMetaDataFactory
See Also:
MetaDataRepository.getPersistentTypeNames(boolean, java.lang.ClassLoader), MetaDataRepository.loadPersistentTypes(boolean, java.lang.ClassLoader)

mapPersistentTypeNames

protected void mapPersistentTypeNames(java.lang.Object rsrc,
                                      java.lang.String[] names)
Implement this method to map metadata resources to the persistent types contained within them. The method will be called when getPersistentTypeNames(boolean, java.lang.ClassLoader) is invoked.


newMetaDataFilter

protected abstract org.apache.openjpa.lib.meta.MetaDataFilter newMetaDataFilter()
Return a metadata filter that identifies metadata resources when performing jar and classpath scans.


clear

public void clear()
Description copied from interface: MetaDataFactory
Clear any internal caches.

Specified by:
clear in interface MetaDataFactory
Overrides:
clear in class AbstractMetaDataFactory


Copyright © 2006 Apache Software Foundation. All Rights Reserved.