/*
 * 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.util.id;

import java.security.AccessController;
import java.security.PrivilegedAction;

/**
 * Serialization version compatibility mode constants.<p>
 *
 * Contains static constants and attributes to help with serialization
 * versioning.<p>
 * 
 * Set the system property <pre>org.jboss.j2ee.Serialization</pre>
 * for serialization compatibility with jboss-4.0.2 and later.
 * 
 * @author  <a href="mailto:Adrian.Brock@JBoss.com">Adrian Brock</a>
 * @author  <a href="mailto:dimitris@jboss.org">Dimitris Andreadis</a>
 * @version $Revision: 1.2.4.2 $
 */
public class SerialVersion
{
   // Static --------------------------------------------------------

   /** Legacy, jboss 3.2.x, jboss-4.0.0, jboss-4.0.1 */
   public static final int LEGACY = 0;

   /** The serialization compatible with Sun's RI, jboss-4.0.2+ */
   public static final int JBOSS_402 = 1;

   /** The serialization version to use */
   public static int version = LEGACY;

   /** Determine the serialization version */
   static
   {
      AccessController.doPrivileged(new PrivilegedAction()
      {
         public Object run()
         {
            try
            {
               if (System.getProperty("org.jboss.j2ee.Serialization") != null)
               {
                  version = JBOSS_402;
               }
            }
            catch (Throwable ignored)
            {
            }
            return null;
         }
      });
   }
}
