river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter_firmst...@apache.org
Subject svn commit: r1444324 - /river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/logging/Levels.java
Date Sat, 09 Feb 2013 04:15:43 GMT
Author: peter_firmstone
Date: Sat Feb  9 04:15:43 2013
New Revision: 1444324

URL: http://svn.apache.org/r1444324
Log:
RIVER-416

Modified:
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/logging/Levels.java

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/logging/Levels.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/logging/Levels.java?rev=1444324&r1=1444323&r2=1444324&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/logging/Levels.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/logging/Levels.java Sat Feb  9 04:15:43
2013
@@ -18,19 +18,11 @@
 
 package com.sun.jini.logging;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectStreamClass;
-import java.io.OutputStream;
-import java.io.Serializable;
 import java.util.logging.Level;
 
 /**
  * Defines additional {@link Level} values. <p>
- *
+ * <p/>
  * See the {@link LogManager} class for one way to use the <code>FAILED</code>
  * and <code>HANDLED</code> logging levels in standard logging configuration
  * files.
@@ -43,7 +35,7 @@ public class Levels {
     /**
      * <code>FAILED</code> is a message level indicating that a facility has
      * experienced a failure that it will reflect to its caller. <p>
-     *
+     * <p/>
      * <code>FAILED</code> messages are intended to provide users with
      * information about failures produced by internal components in order to
      * assist with debugging problems in systems with multiple components. This
@@ -55,7 +47,7 @@ public class Levels {
      * <code>HANDLED</code> is a message level indicating that a facility has
      * detected a failure that it will take steps to handle without reflecting
      * the failure to its caller. <p>
-     *
+     * <p/>
      * <code>HANDLED</code> messages are intended to provide users with
      * information about failures detected by internal components in order to
      * assist with debugging problems in systems with multiple components. This
@@ -63,83 +55,26 @@ public class Levels {
      */
     public static final Level HANDLED = createLevel("HANDLED", 550, null);
 
-    /** This class cannot be instantiated. */
-    private Levels() {
-	throw new AssertionError("This class cannot be instantiated");
-    }
-
     /**
-     * Defines a class that has the same data format as the Level class, to
-     * permit creating the serialized form of a Level instance.
+     * This class cannot be instantiated.
      */
-    private static final class LevelData implements Serializable {
-	private static final long serialVersionUID = -8176160795706313070L;
-	private final String name;
-	private final int value;
-	private final String resourceBundleName;
-	LevelData(String name, int value, String resourceBundleName) {
-	    this.name = name;
-	    this.value = value;
-	    this.resourceBundleName = resourceBundleName;
-	}
+    private Levels() {
+        throw new AssertionError("This class cannot be instantiated");
     }
 
-    /**
-     * Defines an object output stream that allows the data for one class to be
-     * interpreted as the data for another class.  This class is useful in
-     * creating serialization data for a class when access to an appropriate
-     * constructor is not available.
-     */
-    private static final class ClassReplacingObjectOutputStream
-	extends ObjectOutputStream
-    {
-	private final ObjectStreamClass from;
-	private final ObjectStreamClass to;
-
-	ClassReplacingObjectOutputStream(OutputStream out,
-					 Class from,
-					 Class to)
-	    throws IOException
-	{
-	    super(out);
-	    this.from = ObjectStreamClass.lookup(from);
-	    this.to = ObjectStreamClass.lookup(to);
-	}
-
-	protected void writeClassDescriptor(ObjectStreamClass desc)
-	    throws IOException
-	{
-	    if (from.equals(desc)) {
-		desc = to;
-	    }
-	    super.writeClassDescriptor(desc);
-	}
-    }
 
     /**
-     * Creates an instance of the Level class.  This method works around the
-     * fact that there is no public constructor for the Level class by
-     * constructing the serialized form for an instance with the specified
-     * field values and deserializing it.
+     * Creates an instance of the Level class.
      */
     private static Level createLevel(String name,
-				     int value,
-				     String resourceBundleName)
-    {
-	try {
-	    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
-	    ObjectOutputStream out =
-		new ClassReplacingObjectOutputStream(
-		    bytes, LevelData.class, Level.class);
-	    out.writeObject(new LevelData(name, value, resourceBundleName));
-	    out.close();
-	    ObjectInputStream in = new ObjectInputStream(
-		new ByteArrayInputStream(bytes.toByteArray()));
-	    Level result = (Level) in.readObject();
-	    in.close();
-	    return result;
-	} catch (Exception e) {
-	    throw new RuntimeException("Unexpected exception", e);
-	}
+                                     int value,
+                                     String resourceBundleName) {
+        return new CustomLevel(name, value, resourceBundleName);
+    }
+
+    static class CustomLevel extends Level {
+        CustomLevel(String name, int value, String resourceBundleName) {
+            super(name, value, resourceBundleName);
+        }
     }
 }



Mime
View raw message