Package nexj.core.rpc.file.ra

Examples of nexj.core.rpc.file.ra.LockableFile


      {
         //Not found
         return new InstanceArrayList(0);
      }

      LockableFile directFile = new LockableFile(dataFile);

      //BLOCKING
      directFile.lock(true);
     
      try
      {
         Instance instance = m_context.findInstance(query.getMetaclass(), oid);

         if (instance == null)
         {
            instance = new Instance(query.getMetaclass(), m_context);
            instance.cache(oid);
         }

         for (Iterator i = query.getFieldIterator(); i.hasNext(); )
         {
            Field field = (Field)i.next();
            Attribute attribute = field.getAttribute();
            FilePrimitiveMapping primitiveMapping = (FilePrimitiveMapping)query.getPersistenceMapping().getAttributeMapping(attribute);
           
            switch (primitiveMapping.getSysId())
            {
               case FilePrimitiveMapping.SYSID_ID:
                  instance.setOldValueDirect(attribute.getOrdinal(), oid.getValue(0));
                  break;
                 
               case FilePrimitiveMapping.SYSID_DATA:
                  Object value = null;
                 
                  try
                  {
                     value = (primitiveMapping.getAttribute().getType() == Primitive.STRING) ?
                        (Object)directFile.getDataAsString() : directFile.getDataAsBinary();
                  }
                  catch (IOException ex)
                  {
                     throw new PersistenceException("err.persistence.file.io", ex);
                  }
                 
                  instance.setOldValueDirect(attribute.getOrdinal(), value);
                 
                  break;
              
               case FilePrimitiveMapping.SYSID_LOCKING:
                  instance.setOldValueDirect(attribute.getOrdinal(),
                     Primitive.createLong(dataFile.lastModified()) );
                  break;
            }
         }
        
         InstanceArrayList result = new InstanceArrayList(1);
        
         result.add(instance);
        
         return result;
      }
      finally
      {
         if (directFile != null)
         {
            directFile.unlock();
            directFile.close();
         }
      }
   }
View Full Code Here


      }

      m_journalFile = new File(journalDirectory, JOURNAL_FILE1_NAME);
      m_compactionJournalFile = new File(journalDirectory, JOURNAL_FILE2_NAME);
      m_activeJournalPointerFile = new File(journalDirectory, JOURNAL_POINTER_FILE_NAME);
      m_journal = new LockableFile(m_journalFile);
      m_compactionJournal = new LockableFile(m_compactionJournalFile);

      boolean bReady = false;

      try
      {
View Full Code Here

   /**
    * Swaps the handles
    */
   protected void swapJournalFiles()
   {
      LockableFile handle;
      File file;
     
      handle = m_journal;
      m_journal = m_compactionJournal;
      m_compactionJournal = handle;
View Full Code Here

TOP

Related Classes of nexj.core.rpc.file.ra.LockableFile

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.