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 3976 2008-04-12 04:32:06Z 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(final InputStream inputfinal ClassLoader loaderthrows IOException
    {
       if () { .trace(this + " creating JBossObjectInputStream"); }
       
       if (SecurityUtility.skipAccessControl())
       {
          return new JBossObjectInputStream(inputloadernew StringUtilBuffer(10024, 10024));
       }
       
       try
       {
          return (ObjectInputStream)AccessController.doPrivilegednew PrivilegedExceptionAction()
          {
             public Object run() throws Exception
             {
                return new JBossObjectInputStream(inputloadernew StringUtilBuffer(10024, 10024));
             }
          });
       }
       catch (PrivilegedActionException e)
       {
          throw (IOExceptione.getCause();
       }
    }
 
    public ObjectOutputStream createOutput(final OutputStream outputthrows IOException
    {
       if () { .trace(this + " creating JBossObjectOutputStream"); }
 
       if (SecurityUtility.skipAccessControl())
       {
          return new JBossObjectOutputStream(outputnew StringUtilBuffer(10024, 10024));
       }
       
       try
       {
          return (ObjectOutputStream)AccessController.doPrivilegednew PrivilegedExceptionAction()
          {
             public Object run() throws Exception
             {
                return new JBossObjectOutputStream(outputnew StringUtilBuffer(10024, 10024));
             }
         });
      }
      catch (PrivilegedActionException e)
      {
         throw (IOExceptione.getCause();
      }
   }

   
Creates a MarshalledValue that does lazy serialization.
   {
      if (source instanceof IMarshalledValue)
      {
         return (IMarshalledValuesource;
      }
      else
      {
         return new MarshalledValue(source);
      }
   }
   {
      return new SmartCloningMarshalledValue(original);
   }
   public void sendObject(final ObjectOutputStream oosfinal Object dataObjectint versionthrows IOException
   {
      if (SecurityUtility.skipAccessControl())
      {
         oos.writeObject(dataObject);
         oos.flush();
         return;
      }
      
      try
      {
         AccessController.doPrivilegednew PrivilegedExceptionAction()
         {
            public Object run() throws Exception
            {
               oos.writeObject(dataObject);
               oos.flush();
               return null;
            }
         });
      }
      catch (PrivilegedActionException e)
      {
         throw (IOExceptione.getCause();
      }
   }
   public Object receiveObject(InputStream inputStreamClassLoader customClassLoaderint version)
   {
      ObjectInputStream objInputStream = null;
      Object obj = null;
      if (inputStream instanceof ObjectInputStreamWithClassLoader)
      {
         ((ObjectInputStreamWithClassLoaderinputStream).setClassLoader(customClassLoader);
         objInputStream = (ObjectInputStreaminputStream;
      }
      else if (inputStream instanceof JBossObjectInputStream)
      {
         ((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);
         }
      }
      if (SecurityUtility.skipAccessControl())
      {
         return objInputStream.readObject();
      }
      
      try
      {
         final ObjectInputStream ois = objInputStream;
         obj = AccessController.doPrivilegednew PrivilegedExceptionAction()
         {
            public Object run() throws Exception
            {
               return ois.readObject();
            }
         });
      }
      catch (PrivilegedActionException e)
      {
         throw (IOExceptione.getCause();
      }
      return obj;
   }
   public String toString()
   {
      return "JBossSerializationManager[" + Integer.toHexString(hashCode()) + "]";
   }
New to GrepCode? Check out our FAQ X