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;
 
 import  org.jboss.logging.Logger;
 
 import java.util.Map;

This factory is for defining the Object stream implemenations to be used along with creating those implemenations for use. The main function will be to return instance of ObjectOutput and ObjectInput. By default, the implementations will be java.io.ObjectOutputStream and java.io.ObjectInputStream.

Author(s):
Tom Elrod
Clebert Suconic
 
 {
    protected static final Logger log = Logger.getLogger(SerializationStreamFactory.class);
    private static Map managers = new HashMap();
 
    public static final String DEFAULT = "default";
    public static final String JAVA = "java";
    public static final String JBOSS = "jboss";
    public static final String JAVA_ENCRYPT = "javaencrypt";
    public static final String JBOSS_ENCRYPT = "jbossencrypt";
 
 
    static
    {
       try
       {
          String managerClassName = System.getProperty("SERIALIZATION"JavaSerializationManager.class.getName());
          setManagerClassName(managerClassName);
       }
       catch(Exception e)
       {
          .error(e.getMessage(), e);
       }
       try
       {
       }
       catch(Exception e)
       {
          .error(e.getMessage(), e);
       }
       try
       {
          setManagerClassName("org.jboss.remoting.serialization.impl.jboss.JBossSerializationManager");
       }
       catch(Throwable e// catching throwable as if jboss serialization not on classpath, will throw NoClassDefFoundError
       {
          .debug("Could not load JBoss Serialization.  Use Java Serialization default.");
          .trace(e);
       }
       try
       {
       }
       catch(Throwable e// catching throwable as if jboss serialization not on classpath, will throw NoClassDefFoundError
       {
          .debug("Could not load Java Encrypted Serialization.  Use Java Serialization default.");
          .trace(e);
       }
       try
       {
       }
       catch(Throwable e// catching throwable as if jboss serialization not on classpath, will throw NoClassDefFoundError
       {
          .debug("Could not load JBoss Encrypted Serialization.  Use Java Serialization default.");
          .trace(e);
      }
   }

   
The fully qualified classname of the DefaultSerializationManager implementation.

Parameters:
className
   {
      setManagerClassName(className);
   }

   
The fully qualified classname of the DefaultSerializationManager implementation.

Parameters:
className
   {
      loadObjectManagerClass(keyclassName);
   }
   public String getManager()
   {
      return getManager();
   }
   public String getManager(String key)
   {
      SerializationManager manager = (SerializationManager.get(key);
      if(manager == null)
      {
         return null;
      }
      else
      {
         return manager.getClass().getName();
      }
   }
   public void setManager(String managerthrows Exception
   {
      setManager(manager);
   }
   public void setManager(String keyString managerthrows Exception
   {
      setManagerClassName(keymanager);
   }

   
Loads the implementation class for ObjectOutput as specified by the object output class name. Will also load the constructor and cache it to be used when creating the actual implementation instance.
   private static void loadObjectManagerClass(String keyString managerClassNamethrows ClassNotFoundExceptionIllegalAccessExceptionInstantiationException
   {
      Class managerClass = ClassLoaderUtility.loadClass(SerializationStreamFactory.classmanagerClassName);
      SerializationManager manager = (SerializationManagermanagerClass.newInstance();
      if(.get(key) != null)
      {
         .remove(key);
      }
      .put(keymanager);
   }

   

Returns:
the SerializationManager instance corresponding to the given key. If key is null, "java" is assumed. The method never returns null, if there's no SerializationManager associated with the given key, the method throws exception.
Throws:
IOException if there's no corresponding SerializationManager instance.
   public static SerializationManager getManagerInstance(String keythrows IOException
   {
      if(key == null)
      {
         key = ;
      }
      SerializationManager manager = (SerializationManager.get(key);
      if (manager == null)
      {
         throw new IOException("Unknown serialization type: " + key);
      }
      return manager;
   }
   public static SerializationManager getManagerInstance() throws IOException
   {
      return getManagerInstance();
   }
New to GrepCode? Check out our FAQ X