PAGE_LINK =3D new ObjectType(PageLink.class);
+ public static final ObjectType PAGE_LINK =3D new ObjectType(12, PageLink.class);
=
/** . */
- public static final ObjectType URL_LINK =3D new ObjectType(URLLink.class);
+ public static final ObjectType URL_LINK =3D new ObjectType(13, URLLink.class);
=
/** . */
- private final Class javaType;
+ private static final ObjectType[] ENUMERATION =3D
+ {
+ ANY,
+ WORKSPACE,
+ SITE,
+ PORTAL_SITE,
+ GROUP_SITE,
+ USER_SITE,
+ PAGE,
+ NAVIGATION,
+ COMPONENT,
+ BODY,
+ CONTAINER,
+ WINDOW,
+ PAGE_LINK,
+ URL_LINK
+ };
=
/** . */
- private final Set> superTypes;
+ private final int ordinal;
=
- private ObjectType(Class javaType, ObjectType>... superTypes)
+ /** . */
+ private final transient Class javaType;
+
+ /** . */
+ private final transient Set> superTypes;
+
+ private ObjectType(int ordinal, Class javaType, ObjectType>... sup=
erTypes)
{
for (ObjectType> superType : superTypes)
{
@@ -103,6 +127,7 @@
}
=
//
+ this.ordinal =3D ordinal;
this.javaType =3D javaType;
this.superTypes =3D tmp;
}
@@ -141,6 +166,18 @@
}
}
=
+ private Object readResolve () throws java.io.ObjectStreamException
+ {
+ if (ordinal >=3D 0 || ordinal < ENUMERATION.length)
+ {
+ return ENUMERATION[ordinal];
+ }
+ else
+ {
+ throw new InvalidObjectException("Corrupted ordinal value" + ordi=
nal);
+ }
+ }
+
@Override
public String toString()
{
Modified: components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/w=
orkspace/ObjectTypeTestCase.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspa=
ce/ObjectTypeTestCase.java 2011-09-13 05:57:01 UTC (rev 7368)
+++ components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspa=
ce/ObjectTypeTestCase.java 2011-09-13 06:16:50 UTC (rev 7369)
@@ -21,6 +21,11 @@
import junit.framework.TestCase;
import org.gatein.mop.api.workspace.ObjectType;
=
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
/**
* @author Julien Viet
* @version $Revision$
@@ -44,4 +49,16 @@
assertTrue(ObjectType.SITE.isAssignableFrom(ObjectType.GROUP_SITE));
assertFalse(ObjectType.GROUP_SITE.isAssignableFrom(ObjectType.SITE));
}
+
+ public void testSerialization() throws Exception
+ {
+ ByteArrayOutputStream baos =3D new ByteArrayOutputStream();
+ ObjectOutputStream out =3D new ObjectOutputStream(baos);
+ out.writeObject(ObjectType.PAGE);
+ out.close();
+ ByteArrayInputStream bais =3D new ByteArrayInputStream(baos.toByteAr=
ray());
+ ObjectInputStream in =3D new ObjectInputStream(bais);
+ Object o =3D in.readObject();
+ assertSame(ObjectType.PAGE, o);
+ }
}
--===============3964936289402615573==--