Package com.sun.jdo.api.persistence.model.mapping

Examples of com.sun.jdo.api.persistence.model.mapping.MappingClassElement


        // MappingFile.
        Map mappingMap = new HashMap();
        AbstractNameMapper nameMapper = getNameMapper();
        Iterator iter = mappingClasses.iterator();
        while (iter.hasNext()) {
            MappingClassElement mappingClass = (MappingClassElement)iter.next();
            String ejbName = nameMapper.getEjbNameForPersistenceClass(
                    mappingClass.getName());
            mappingMap.put(ejbName, mappingClass);
        }
        MappingFile mf = new MappingFile();
        OutputStream sunCmpMapping = null;
        try {
View Full Code Here


            String jvmClassName = className.replace('.', '/');
            File file = gen.generate(jvmClassName);
            fileList.add(file);

            // write mapping file
            MappingClassElement mappingClass
                = model.getMappingClass(className);
            BufferedOutputStream mapOut = null;
            try {
                String mapPath = className.replace('.', File.separatorChar);
                String mappingFile = mapPath + MAPPING_EXTENSION;
View Full Code Here

    // the first in the cache.
    // Any other access of _classes potentially needs to be synchronized
    // using the same variable _classes (e.g. updateKeyForClass).
    synchronized (this._classes)
    {
      MappingClassElement mappingClass =
        (MappingClassElement)_classes.get(className);

      if (mappingClass == null)
      {
        // check whether the class is known to be non PC
        if (_nonPCClasses.contains(className))
          return null;

        try
        {
          InputStream stream = getInputStreamForResource(className,
            classLoader, getResourceNameWithExtension(className));

          if (stream != null)
          {
            // if the file is empty, the archiver prints an
            // exception, so protect against that case and
            // return null without updating either cache
            if (stream.available() > 0)
            {
              XMLInputStream xmlInput = new XMLInputStream(stream,
                getClass().getClassLoader());

              mappingClass =
                (MappingClassElement)xmlInput.readObject();
              xmlInput.close();

              // postUnarchive performs version number checking
              // and possible format conversions
              mappingClass.postUnarchive();

              // can't call updateKeyForClass here there are cases
              // when the mapping class name doesn't match the
              // classname (such as copy/paste, move etc.)
              _classes.put(className, mappingClass);

              // update the modified flags for the mapping and
              // persistence classes since the xml archiver uses
              // all the set methods
              mappingClass.setModified(false);
              getPersistenceClass(mappingClass).
                setModified(false);
            }
          }
          else
View Full Code Here

    synchronized (this._classes)
    {
      for (Iterator i = classNames.iterator(); i.hasNext();)
      {
        String className = (String)i.next();
        MappingClassElement mapping =
          (MappingClassElement)_classes.get(className);

        // If the cache has a MappingClassElement with the specified
        // className, get its databaseRoot and remove the corresonding
        // SchemaElement from the SchemaElement cache.
        if (mapping != null)
          SchemaElement.removeFromCache(mapping.getDatabaseRoot());
       
        // remove the corresponding MappingClassElement from cache
        _classes.remove(className);
       
        // remove the class from the set of classes known to be non PC
View Full Code Here

   * @exception IOException if there is some error saving the class
   * @see #storeMappingClass
   */
  public void storeMappingClass (String className) throws IOException
  {
    MappingClassElement mappingClass = null;

    synchronized (this._classes)
    {
      mappingClass = (MappingClassElement)_classes.get(className);
    }
View Full Code Here

   * @return <code>true</code> if this field name represents a field in
   * the default fetch group; <code>false</code> otherwise.
   */
  public boolean isDefaultFetchGroup (String className, String fieldName)
  {
    MappingClassElement mappingClass = getMappingClass(className);

    try
    {
      return (MappingFieldElement.GROUP_DEFAULT ==
        mappingClass.getField(fieldName).getFetchGroup());
    }
    catch (Exception e)
    {}  // will return false

    return false;
View Full Code Here

   * @see com.sun.jdo.api.persistence.model.mapping.impl.MappingClassElementImpl#forName(String, Model)
   */
  public MappingClassElement getMappingClass (String className,
    ClassLoader classLoader)
  {
    MappingClassElement mappingClass = null;

    // First check class loader. This has to be done before the super call!
    // Method Model.getMappingClass will check the MappingClassElement cache
    // and will find an entry in the case of a multiple class loader for the
    // same class name. So we have to check the multiple class loader first.
    classLoader = findClassLoader(className, classLoader);
    mappingClass = super.getMappingClass(className, classLoader);
    if ((mappingClass != null) && (classLoader != null))
    {
      // Lookup the SchemElement connected to mappingClass. This reads
      // the .dbschema file using the specified classLoader and stores the
      // SchemaElement in the SchemaElement cache. Any subsequent
      // SchemaElement.forName or TableElement.forName lookups will use
      // the cached version.
      String databaseRoot = mappingClass.getDatabaseRoot();

      // An unmapped mapping class is allowed in which case the
      // databaseRoot will be null (never mapped) or empty
      // (mapped once, unmapped now), but if the databaseRoot is
      // not null or empty and we can't find the schema, throw a
View Full Code Here

        String className = pcClass.getName();
        ClassLoader classLoader = pcClass.getClassLoader();
        ClassDesc rc = null;

        try {
            MappingClassElement mdConfig =
               model.getMappingClass(className, classLoader);

            // Validate the model information for this class.
            validateModel(model, className, classLoader);
View Full Code Here

            // The mapping class element may be null if there is inconsistency
            // in sun-cmp-mappings.xml and ejb-jar.xml. For example,
            // the bean has mapping information in sun-cmp-mappings.xml but
            // no definition in the ejb-jar.xml.
            // So iterate over the mappings until the 1st non-null is found.
            MappingClassElement mc = null;
            Iterator iter = mappingClasses.values().iterator();
            while (iter.hasNext()) {
                mc = (MappingClassElement)iter.next();
                if (mc != null) {
                    schema = SchemaElement.forName(mc.getDatabaseRoot());
                    break;
                }
            }

            if (logger.isLoggable(Logger.FINE)){
View Full Code Here

        // MappingFile.
        Map mappingMap = new HashMap();
        AbstractNameMapper nameMapper = getNameMapper();
        Iterator iter = mappingClasses.iterator();
        while (iter.hasNext()) {
            MappingClassElement mappingClass = (MappingClassElement)iter.next();
            String ejbName = nameMapper.getEjbNameForPersistenceClass(
                    mappingClass.getName());
            mappingMap.put(ejbName, mappingClass);
        }
        MappingFile mf = new MappingFile();
        OutputStream sunCmpMapping = null;
        try {
View Full Code Here

TOP

Related Classes of com.sun.jdo.api.persistence.model.mapping.MappingClassElement

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.