Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
 
 
 package org.jboss.remoting.serialization.impl.jboss;
 
 import  org.jboss.logging.Logger;
 import  org.jboss.serial.io.JBossObjectInputStream;
 import  org.jboss.serial.io.JBossObjectOutputStream;
 import  org.jboss.serial.util.StringUtilBuffer;
 
Instantiates the Streamings according to JbossObjectOutputStream and JBossObjectInputStream. Also, it uses a different approach for MarshallValues as we don't need to convert objects in bytes. $Id: JBossSerializationManager.java 5282 2009-05-19 20:53:07Z ron.sigal@jboss.com $

Author(s):
Clebert Suconic
 
 {
    protected static final Logger log = Logger.getLogger(JBossSerializationManager.class);
 
    private static boolean trace = .isTraceEnabled();
 
    public ObjectInputStream createInput(InputStream inputClassLoader loaderthrows IOException
    {
       if () { .trace(this + " creating JBossObjectInputStream"); }
       return new JBossObjectInputStream(inputloadernew StringUtilBuffer(10024, 10024));
    }
 
    public ObjectOutputStream createOutput(OutputStream outputthrows IOException
    {
       if () { .trace(this + " creating JBossObjectOutputStream"); }
       return new JBossObjectOutputStream(outputnew StringUtilBuffer(10024, 10024));
    }

   
Creates a MarshalledValue that does lazy serialization.
 
    public IMarshalledValue createdMarshalledValue(Object sourcethrows IOException
    {
       if (source instanceof IMarshalledValue)
       {
          return (IMarshalledValuesource;
       }
       else
       {
          return new MarshalledValue(source);
       }
    }
 
    {
       return new SmartCloningMarshalledValue(original);
    }
 
 
    public void sendObject(ObjectOutputStream oosObject dataObjectint versionthrows IOException
    {
       oos.writeObject(dataObject);
       oos.flush();
    }
 
    public Object receiveObject(InputStream inputStreamClassLoader customClassLoaderint version)
    {
       ObjectInputStream objInputStream = null;
       Object obj = null;
       boolean useCurrentThreadClassLoader = false;
      
      if (inputStream instanceof ObjectInputStreamWithClassLoader)
      {
         ClassLoader cl = ((ObjectInputStreamWithClassLoaderinputStream).getClassLoader();
         if (cl instanceof RemotingClassLoader)
         {
            useCurrentThreadClassLoader = ((RemotingClassLoadercl).isUseCurrentThreadClassLoader();
         }
         if (cl == null || useCurrentThreadClassLoader)
         {
            ((ObjectInputStreamWithClassLoaderinputStream).setClassLoader(customClassLoader);
         }
         objInputStream = (ObjectInputStreaminputStream;
      }
      else if (inputStream instanceof JBossObjectInputStream)
      {
         ClassLoader cl = ((JBossObjectInputStream) inputStream).getClassLoader();
         if (cl instanceof RemotingClassLoader)
         {
            useCurrentThreadClassLoader = ((RemotingClassLoadercl).isUseCurrentThreadClassLoader();
         }
         if (cl == null || useCurrentThreadClassLoader )
         {
            ((JBossObjectInputStream) inputStream).setClassLoader(customClassLoader);
         }
         objInputStream = (ObjectInputStreaminputStream;
      }
      else if (inputStream instanceof ObjectInputStream)
      {
         objInputStream = (ObjectInputStreaminputStream;
      }
      else
      {
         if (customClassLoader != null)
         {
            objInputStream = SerializationStreamFactory.getManagerInstance(.).createInput(inputStreamcustomClassLoader);
         }
         else
         {
            objInputStream = SerializationStreamFactory.getManagerInstance(.).createRegularInput(inputStream);
         }
      }
      obj = objInputStream.readObject();
      return obj;
   }
   public String toString()
   {
      return "JBossSerializationManager[" + Integer.toHexString(hashCode()) + "]";
   }
New to GrepCode? Check out our FAQ X