Package org.jboss.serial.classmetamodel

Examples of org.jboss.serial.classmetamodel.ClassMetaData


      {
        return Short.TYPE;
      }
      else
      {
        ClassMetaData metaData = ClassMetamodelFactory.getClassMetaData(name,resolver,loader,false);
        if (metaData.isArray())
        {
          return metaData.getArrayRepresentation();
        }
        else
        {
          return metaData.getClazz();
        }
      }
    }
View Full Code Here


        if (isDebug)
        {
          log.debug("describeObject for class=" + obj.getClass().getName());
        }

        ClassMetaData metaData = null;
        if (obj instanceof Class)
        {
          metaData = ClassMetamodelFactory.getClassMetaData((Class)obj,cache.isCheckSerializableClass());
        }
        else
        {
             metaData = ClassMetamodelFactory.getClassMetaData(obj.getClass(),cache.isCheckSerializableClass());
            if (metaData.getWriteReplaceMethod()!=null)
            {
              if (isDebug)
              {
                log.debug("describeObject::Calling writeReplace for " + metaData.getClazz().getName());
              }
              try {
                Object orig = obj;
            obj = metaData.getWriteReplaceMethod().invoke(obj,EMPTY_OBJECT_ARRAY);
            if (obj!=null && obj!=orig && obj.getClass()!=metaData.getClazz())
            {
              if (isDebug)
              {
                log.debug("originalObject=" + orig.getClass().getName() + " substituted by " + obj.getClass().getName());
              }
              describeObject(cache,obj);
              return;
            }
            metaData = ClassMetamodelFactory.getClassMetaData(obj.getClass(),cache.isCheckSerializableClass());
          } catch (Exception e) {
            IOException io = new IOException("Metadata Serialization Error");
            io.initCause(e);
            throw io;
          }
            }
        }

        if (cache.getSubstitution()!=null)
        {
          if (isDebug)
          {
            log.debug("describeObject::checking substitution on interface");
          }
          Object orig = obj;
            obj = cache.getSubstitution().replaceObject(obj);
      if (obj!=null && obj!=orig && obj.getClass()!=metaData.getClazz())
      {
            if (isDebug)
            {
              log.debug("describeObject::on check interface, original object[" + orig.getClass().getName() +"] was replaced by [" + obj.getClass().getName() + "]");
            }
View Full Code Here

          throw new IOException("Didn't find StreamingClass circular refernce id=" + referenceId);
        }
       
      }

        ClassMetaData metaData = streamingClass.getMetadata();

        if (isDebug)
        {
          log.debug("Reading object for id=" + reference + " classLoader=" + cache.getLoader() + " className = " + metaData.getClassName());
        }
       
        byte persisterId = input.readByte();
        Persister persister = PersistResolver.resolvePersister(persisterId);
        //Persister persister = PersistResolver.resolvePersister(description.getMetaData().getClazz(),
        //        description.getMetaData(),description.getMetaData().isArray());

        /*ObjectDescription description = new ObjectDescription();
        description.setMetaData(ClassMetamodelFactory.getClassMetaData(reference.getClassName(),cache.getLoader(),false));
        cache.putObjectInCache(reference,description); */


        Object value = persister.readData(cache.getLoader(), streamingClass, metaData, reference, cache, cache.getInput(), cache.getSubstitution());

        if (!(persister instanceof ClassReferencePersister)) //JBSER-83
        {
          if (cache.getSubstitution()!=null)
          {
              value = cache.getSubstitution().replaceObject(value);
          }
 
          try
          {
              if (metaData.getReadResolveMethod()!=null)
              {
                if (isDebug)
                {
                  log.debug("readObjectDescriptionFromStreaming::calling readResolve for className = " + metaData.getClassName());
                }
                  value = metaData.getReadResolveMethod().invoke(value,new Object[]{});
                  cache.reassignObjectInCacheRead(reference,value);
              }
          }
          catch (IllegalAccessException e)
          {
View Full Code Here

      {
        return Short.TYPE;
      }
      else
      {
        ClassMetaData metaData = ClassMetamodelFactory.getClassMetaData(name,resolver,loader,false);
        if (metaData.isArray())
        {
          return metaData.getArrayRepresentation();
        }
        else
        {
          return metaData.getClazz();
        }
      }
    }
View Full Code Here

    String instanceName = null;
    Class enumClass  = null;
    String classEnum = input.readUTF();
    try
    {
      ClassMetaData enummetaData = ClassMetamodelFactory.getClassMetaData(classEnum,cache.getClassResolver(),loader,true);
      enumClass = enummetaData.getClazz();
      instanceName = input.readUTF();
      Object enumInstance = Enum.valueOf(enumClass, instanceName);
      if (enumInstance!=null)
      {
        cache.putObjectInCacheRead(referenceId,enumInstance);
View Full Code Here

        if (objectDescriptorStrategy.writeObjectSpecialCase(outputParent, cache, obj))
        {
           return;
        }

        ClassMetaData metaData = getMetaData(obj, cache);
       
        if (objectDescriptorStrategy.writeDuplicateObject(outputParent, cache, obj, metaData))
        {
           return;
        }
       
        Object originalObject = obj;
        Object newObject = obj;
       
        do
        {
           obj = newObject;
           metaData = getMetaData(obj, cache);
           newObject = objectDescriptorStrategy.replaceObjectByClass(cache, obj, metaData);
          
           if (objectDescriptorStrategy.writeObjectSpecialCase(outputParent, cache, newObject))
           {
              return;
           }
        }
         while (!objectDescriptorStrategy.doneReplacing(cache, newObject, obj, metaData));

        obj = newObject;
        metaData = getMetaData(obj, cache);
       
        if (cache.getSubstitution()!=null)
        {
            if (isDebug)
            {
                log.debug("describeObject::checking substitution on interface");
            }
            Object orig = obj;
            obj = cache.getSubstitution().replaceObject(obj);
            if (obj!=orig)
            {
                if (isDebug)
                {
                    log.debug("describeObject::on check interface, original object[" + orig.getClass().getName() +"] was replaced by [" + obj.getClass().getName() + "]");
                }
                if (objectDescriptorStrategy.writeObjectSpecialCase(outputParent, cache, obj))
                {
                   return;
                }
               
                metaData = getMetaData(obj, cache);
            }
        }
       
        if (isDebug)
        {
      if (obj==null)
          {
        log.debug("obj==null",new Exception());
          }
        }
        if (isDebug)
        {
          log.debug("describeObject for class=" + obj.getClass().getName());
        }

        int description = 0;

        if (cache.getSafeToReuse()!=null)
        {
            description = cache.getSafeToReuse().storeSafe(obj);
            if (description!=0)
            {
              if (isDebug)
              {
                log.debug("describeObject::a safeClone reference " + description);
              }
                outputParent.writeByte(DataContainerConstants.SMARTCLONE_DEF);
              cache.getOutput().addObjectReference(description);
                return;
            }
           
        }

        description = cache.findIdInCacheWrite(obj, metaData.isImmutable());

        if (description != 0) // Shouldn't happen.
        {
          if (isDebug)
          {
            log.debug("describeObject::a circular reference " + description);
          }
            outputParent.writeByte(DataContainerConstants.OBJECTREF);
            cache.getOutput().addObjectReference(description);
            return;
        } else
        {
          
            ClassMetaData originalMetaData = metaData;
            if (obj != originalObject)
            {
               originalMetaData = getMetaData(originalObject, cache);
            }
          description = cache.putObjectInCacheWrite(originalObject, originalMetaData.isImmutable());
          if (isDebug)
          {
            log.debug("describeObject::a new reference " + description);
          }
            outputParent.writeByte(DataContainerConstants.NEWDEF);
View Full Code Here

      return input.readImmutable(byteIdentify,cache);
   }
  
   public Object readObject(JBossSeralizationInputInterface input, ObjectsCache cache, StreamingClass streamingClass, int reference) throws IOException
   {
      ClassMetaData metaData = streamingClass.getMetadata();

      if (isDebug)
      {
          log.debug("Reading object for id=" + reference + " classLoader=" + cache.getLoader() + " className = " + metaData.getClassName());
      }
     
      byte persisterId = input.readByte();
      Persister persister = PersistResolver.resolvePersister(persisterId);
     
      //Persister persister = PersistResolver.resolvePersister(description.getMetaData().getClazz(),
      //        description.getMetaData(),description.getMetaData().isArray());

      /*ObjectDescription description = new ObjectDescription();
      description.setMetaData(ClassMetamodelFactory.getClassMetaData(reference.getClassName(),cache.getLoader(),false));
      cache.putObjectInCache(reference,description); */
     
      Object value = persister.readData(cache.getLoader(), streamingClass, metaData, reference, cache, cache.getInput(), cache.getSubstitution());

      if (!(persister instanceof ClassReferencePersister)) //JBSER-83
      {
          if (cache.getSubstitution()!=null)
          {
              value = cache.getSubstitution().replaceObject(value);
          }
 
          try
          {
              if (metaData.getReadResolveMethod()!=null)
              {
                  if (isDebug)
                  {
                      log.debug("readObjectDescriptionFromStreaming::calling readResolve for className = " + metaData.getClassName());
                  }
                  value = metaData.getReadResolveMethod().invoke(value,new Object[]{});
                  cache.reassignObjectInCacheRead(reference,value);
              }
          }
          catch (IllegalAccessException e)
          {
View Full Code Here

    {
      Map map = (Map)valueIterator.next();
      Iterator classesIterator = map.values().iterator();
      while (classesIterator.hasNext())
      {
        ClassMetaData metaData = (ClassMetaData)classesIterator.next();
        metaData.setClazz(null);
      }
    }
  }
View Full Code Here

/* 160 */     if (isDebug)
/*     */     {
/* 162 */       log.debug("describeObject for class=" + obj.getClass().getName());
/*     */     }
/*     */
/* 165 */     ClassMetaData metaData = null;
/* 166 */     if ((obj instanceof Class))
/*     */     {
/* 168 */       metaData = ClassMetamodelFactory.getClassMetaData((Class)obj, cache.isCheckSerializableClass());
/*     */     }
/*     */     else
/*     */     {
/* 172 */       metaData = ClassMetamodelFactory.getClassMetaData(obj.getClass(), cache.isCheckSerializableClass());
/* 173 */       if (metaData.getWriteReplaceMethod() != null)
/*     */       {
/* 175 */         if (isDebug)
/*     */         {
/* 177 */           log.debug("describeObject::Calling writeReplace for " + metaData.getClazz().getName());
/*     */         }
/*     */         try {
/* 180 */           Object orig = obj;
/* 181 */           obj = metaData.getWriteReplaceMethod().invoke(obj, EMPTY_OBJECT_ARRAY);
/* 182 */           if ((obj != null) && (obj != orig) && (obj.getClass() != metaData.getClazz()))
/*     */           {
/* 184 */             if (isDebug)
/*     */             {
/* 186 */               log.debug("originalObject=" + orig.getClass().getName() + " substituted by " + obj.getClass().getName());
/*     */             }
/* 188 */             describeObject(cache, obj);
/* 189 */             return;
/*     */           }
/* 191 */           metaData = ClassMetamodelFactory.getClassMetaData(obj.getClass(), cache.isCheckSerializableClass());
/*     */         } catch (Exception e) {
/* 193 */           IOException io = new IOException("Metadata Serialization Error");
/* 194 */           io.initCause(e);
/* 195 */           throw io;
/*     */         }
/*     */       }
/*     */     }
/*     */
/* 200 */     if (cache.getSubstitution() != null)
/*     */     {
/* 202 */       if (isDebug)
/*     */       {
/* 204 */         log.debug("describeObject::checking substitution on interface");
/*     */       }
/* 206 */       Object orig = obj;
/* 207 */       obj = cache.getSubstitution().replaceObject(obj);
/* 208 */       if ((obj != null) && (obj != orig) && (obj.getClass() != metaData.getClazz()))
/*     */       {
/* 210 */         if (isDebug)
/*     */         {
/* 212 */           log.debug("describeObject::on check interface, original object[" + orig.getClass().getName() + "] was replaced by [" + obj.getClass().getName() + "]");
/*     */         }
View Full Code Here

/* 390 */         throw new IOException("Didn't find StreamingClass circular refernce id=" + referenceId);
/*     */       }
/*     */
/*     */     }
/*     */
/* 395 */     ClassMetaData metaData = streamingClass.getMetadata();
/*     */
/* 397 */     if (isDebug)
/*     */     {
/* 399 */       log.debug("Reading object for id=" + reference + " classLoader=" + cache.getLoader() + " className = " + metaData.getClassName());
/*     */     }
/*     */
/* 402 */     byte persisterId = input.readByte();
/* 403 */     Persister persister = PersistResolver.resolvePersister(persisterId);
/*     */
/* 412 */     Object value = persister.readData(cache.getLoader(), streamingClass, metaData, reference, cache, cache.getInput(), cache.getSubstitution());
/*     */
/* 414 */     if (!(persister instanceof ClassReferencePersister))
/*     */     {
/* 416 */       if (cache.getSubstitution() != null)
/*     */       {
/* 418 */         value = cache.getSubstitution().replaceObject(value);
/*     */       }
/*     */
/*     */       try
/*     */       {
/* 423 */         if (metaData.getReadResolveMethod() != null)
/*     */         {
/* 425 */           if (isDebug)
/*     */           {
/* 427 */             log.debug("readObjectDescriptionFromStreaming::calling readResolve for className = " + metaData.getClassName());
/*     */           }
/* 429 */           value = metaData.getReadResolveMethod().invoke(value, new Object[0]);
/* 430 */           cache.reassignObjectInCacheRead(reference, value);
/*     */         }
/*     */       }
/*     */       catch (IllegalAccessException e)
/*     */       {
View Full Code Here

TOP

Related Classes of org.jboss.serial.classmetamodel.ClassMetaData

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.