[jboss-cvs] JBossAS SVN: r63973 - in projects/microcontainer/trunk: container/src/main/org/jboss/reflect/plugins/introspection and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jul 11 11:16:44 EDT 2007
Author: alesj
Date: 2007-07-11 11:16:44 -0400 (Wed, 11 Jul 2007)
New Revision: 63973
Added:
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/SerializationHelper.java
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionDelegateHolder.java
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionSerializationHelper.java
Modified:
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/InheritableAnnotationHolder.java
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactory.java
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java
projects/microcontainer/trunk/docs/gettingstarted/src/docbkx/en/modules/basics.xml
Log:
Introduction of serialization helper/provider for three non-serializable helpers.
Ignoring serialization/deserialization for Javassist test cases.
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java 2007-07-11 14:58:35 UTC (rev 63972)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java 2007-07-11 15:16:44 UTC (rev 63973)
@@ -26,6 +26,9 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import java.io.ObjectInputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
import org.jboss.reflect.spi.ClassInfo;
import org.jboss.reflect.spi.ConstructorInfo;
@@ -108,27 +111,86 @@
protected PackageInfo packageInfo;
/** The class info helper */
- protected ClassInfoHelper classInfoHelper;
+ protected transient ClassInfoHelper classInfoHelper;
/** The type info factory */
- protected TypeInfoFactory typeInfoFactory;
+ protected transient TypeInfoFactory typeInfoFactory;
/** The attachments */
private transient TypeInfoAttachments attachments;
+ /** The serialization helper */
+ private SerializationHelper serializationHelper;
+
+ /**
+ * Create a new abstract ClassInfo.
+ */
+ public ClassInfoImpl()
+ {
+ }
+
+ /**
+ * Create a new class info
+ *
+ * @param name the class name
+ */
+ public ClassInfoImpl(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Create a new abstract ClassInfo.
+ *
+ * @param name the class name
+ * @param modifiers the class modifiers
+ */
+ public ClassInfoImpl(String name, int modifiers)
+ {
+ this.name = name;
+ this.modifiers = modifiers;
+ }
+
+ /**
+ * Create a new abstract ClassInfo.
+ *
+ * @param name the class name
+ * @param modifiers the class modifiers
+ * @param interfaces the interfaces
+ * @param superclass the super class
+ */
+ public ClassInfoImpl(String name, int modifiers, InterfaceInfo[] interfaces,
+ ClassInfoImpl superclass)
+ {
+ this.name = name;
+ this.modifiers = modifiers;
+ this.interfaces = interfaces;
+ this.superclass = superclass;
+ }
+
public TypeInfoFactory getTypeInfoFactory()
{
return typeInfoFactory;
}
- public void setTypeInfoFactory(TypeInfoFactory typeInfoFactory)
+ public void setSerializationHelper(SerializationHelper serializationHelper)
{
- this.typeInfoFactory = typeInfoFactory;
+ if (serializationHelper == null)
+ throw new IllegalArgumentException("Null serialization helper.");
+ this.serializationHelper = serializationHelper;
+ provideHelpers();
}
+ private void provideHelpers()
+ {
+ this.classInfoHelper = serializationHelper.provideClassInfoHelper();
+ this.typeInfoFactory = serializationHelper.provideTypeInfoFactory();
+ this.annotationHelper = serializationHelper.provideAnnotationHelper();
+ }
+
/**
* Find a method
- *
+ *
* @param methods the methods
* @param name the name
* @param parameters the parameters
@@ -159,10 +221,10 @@
}
return null;
}
-
+
/**
* Find a constructor
- *
+ *
* @param constructors the constructors
* @param parameters the parameters
* @return the constructor info
@@ -192,7 +254,7 @@
/**
* Get an array class
- *
+ *
* TODO JBMICROCONT-123 there must be a better way to do this!
* @param clazz the class
* @param depth the depth
@@ -202,64 +264,8 @@
{
return Array.newInstance(clazz, depth).getClass();
}
-
- /**
- * Create a new abstract ClassInfo.
- */
- public ClassInfoImpl()
- {
- }
/**
- * Create a new class info
- *
- * @param name the class name
- */
- public ClassInfoImpl(String name)
- {
- this.name = name;
- }
-
- /**
- * Create a new abstract ClassInfo.
- *
- * @param name the class name
- * @param modifiers the class modifiers
- */
- public ClassInfoImpl(String name, int modifiers)
- {
- this.name = name;
- this.modifiers = modifiers;
- }
-
- /**
- * Create a new abstract ClassInfo.
- *
- * @param name the class name
- * @param modifiers the class modifiers
- * @param interfaces the interfaces
- * @param superclass the super class
- */
- public ClassInfoImpl(String name, int modifiers, InterfaceInfo[] interfaces,
- ClassInfoImpl superclass)
- {
- this.name = name;
- this.modifiers = modifiers;
- this.interfaces = interfaces;
- this.superclass = superclass;
- }
-
- /**
- * Set the class info helper
- *
- * @param helper the helper
- */
- public void setClassInfoHelper(ClassInfoHelper helper)
- {
- this.classInfoHelper = helper;
- }
-
- /**
* Set the type
*
* @param type the class
@@ -627,4 +633,15 @@
{
return (name != null ? name.hashCode() : 0);
}
+
+ private void writeObject(ObjectOutputStream oos) throws IOException
+ {
+ oos.defaultWriteObject();
+ }
+
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException
+ {
+ ois.defaultReadObject();
+ provideHelpers();
+ }
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/InheritableAnnotationHolder.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/InheritableAnnotationHolder.java 2007-07-11 14:58:35 UTC (rev 63972)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/InheritableAnnotationHolder.java 2007-07-11 15:16:44 UTC (rev 63973)
@@ -64,7 +64,7 @@
protected Object annotatedElement;
/** The annotation helper */
- protected AnnotationHelper annotationHelper;
+ protected transient AnnotationHelper annotationHelper;
/**
* Create a new InheritableAnnotationHolder.
@@ -73,16 +73,6 @@
{
}
- /**
- * Set the annotation helper
- *
- * @param helper the helper
- */
- public void setAnnotationHelper(AnnotationHelper helper)
- {
- this.annotationHelper = helper;
- }
-
public void setAnnotatedElement(Object annotatedElement)
{
this.annotatedElement = annotatedElement;
Added: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/SerializationHelper.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/SerializationHelper.java (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/SerializationHelper.java 2007-07-11 15:16:44 UTC (rev 63973)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.reflect.plugins;
+
+import java.io.Serializable;
+
+import org.jboss.reflect.spi.TypeInfoFactory;
+
+/**
+ * Provide helper instances for ClassInfo to work.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface SerializationHelper extends Serializable
+{
+ /**
+ * Get the type info factory.
+ *
+ * @return type info factory
+ */
+ TypeInfoFactory provideTypeInfoFactory();
+
+ /**
+ * Get the class info helper.
+ *
+ * @return class info helper
+ */
+ ClassInfoHelper provideClassInfoHelper();
+
+ /**
+ * Get the annotation helper.
+ *
+ * @return annotation helper
+ */
+ AnnotationHelper provideAnnotationHelper();
+}
Added: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionDelegateHolder.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionDelegateHolder.java (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionDelegateHolder.java 2007-07-11 15:16:44 UTC (rev 63973)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.reflect.plugins.introspection;
+
+/**
+ * Delegate holder.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class IntrospectionDelegateHolder
+{
+ /** The delegate */
+ private static IntrospectionTypeInfoFactoryImpl delegate = new IntrospectionTypeInfoFactoryImpl();
+
+ protected IntrospectionTypeInfoFactoryImpl getDelegate()
+ {
+ return delegate;
+ }
+}
Added: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionSerializationHelper.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionSerializationHelper.java (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionSerializationHelper.java 2007-07-11 15:16:44 UTC (rev 63973)
@@ -0,0 +1,64 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.reflect.plugins.introspection;
+
+import org.jboss.reflect.plugins.AnnotationHelper;
+import org.jboss.reflect.plugins.ClassInfoHelper;
+import org.jboss.reflect.plugins.SerializationHelper;
+import org.jboss.reflect.spi.TypeInfoFactory;
+
+/**
+ * Introspection serialization helper.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class IntrospectionSerializationHelper extends IntrospectionDelegateHolder implements SerializationHelper
+{
+ private static SerializationHelper instance = new IntrospectionSerializationHelper();
+
+ private IntrospectionSerializationHelper() {}
+
+ public static SerializationHelper getInstance()
+ {
+ return instance;
+ }
+
+ public TypeInfoFactory provideTypeInfoFactory()
+ {
+ return getDelegate();
+ }
+
+ public ClassInfoHelper provideClassInfoHelper()
+ {
+ return getDelegate();
+ }
+
+ public AnnotationHelper provideAnnotationHelper()
+ {
+ return getDelegate();
+ }
+
+ protected Object readResolve()
+ {
+ return instance;
+ }
+}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactory.java 2007-07-11 14:58:35 UTC (rev 63972)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactory.java 2007-07-11 15:16:44 UTC (rev 63973)
@@ -34,23 +34,20 @@
*
* @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
*/
-public class IntrospectionTypeInfoFactory implements TypeInfoFactory
+public class IntrospectionTypeInfoFactory extends IntrospectionDelegateHolder implements TypeInfoFactory
{
- /** The delegate */
- private static IntrospectionTypeInfoFactoryImpl delegate = new IntrospectionTypeInfoFactoryImpl();
-
public TypeInfo getTypeInfo(Class clazz)
{
- return delegate.getTypeInfo(clazz);
+ return getDelegate().getTypeInfo(clazz);
}
public TypeInfo getTypeInfo(String name, ClassLoader cl) throws ClassNotFoundException
{
- return delegate.getTypeInfo(name, cl);
+ return getDelegate().getTypeInfo(name, cl);
}
public TypeInfo getTypeInfo(Type type)
{
- return delegate.getTypeInfo(type);
+ return getDelegate().getTypeInfo(type);
}
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java 2007-07-11 14:58:35 UTC (rev 63972)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java 2007-07-11 15:16:44 UTC (rev 63973)
@@ -392,9 +392,7 @@
result = new ReflectClassInfoImpl(clazz.getName());
}
result.setType(clazz);
- result.setTypeInfoFactory(this);
- result.setClassInfoHelper(this);
- result.setAnnotationHelper(this);
+ result.setSerializationHelper(IntrospectionSerializationHelper.getInstance());
return result;
}
Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java 2007-07-11 14:58:35 UTC (rev 63972)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java 2007-07-11 15:16:44 UTC (rev 63973)
@@ -86,13 +86,21 @@
assertEquals(clazz, info.getType());
// TODO JBMICROCONT-128 fix the serialization
- //byte[] bytes = serialize(info);
- //Object deserialized = deserialize(bytes);
- //assertEquals(info, deserialized);
+ if (isJavassistTestCase() == false)
+ {
+ byte[] bytes = serialize(info);
+ Object deserialized = deserialize(bytes);
+ assertEquals(info, deserialized);
+ }
return info;
}
-
+
+ protected boolean isJavassistTestCase()
+ {
+ return (getClass().getName().contains("Javassist"));
+ }
+
protected void testArray(Class<?> clazz, TypeInfo info) throws Throwable
{
TypeInfo arrayType = info.getArrayType(1);
Modified: projects/microcontainer/trunk/docs/gettingstarted/src/docbkx/en/modules/basics.xml
===================================================================
--- projects/microcontainer/trunk/docs/gettingstarted/src/docbkx/en/modules/basics.xml 2007-07-11 14:58:35 UTC (rev 63972)
+++ projects/microcontainer/trunk/docs/gettingstarted/src/docbkx/en/modules/basics.xml 2007-07-11 15:16:44 UTC (rev 63973)
@@ -1103,6 +1103,10 @@
</deployment>
</programlisting>
+ <para>
+ TODO - alias as true dependency.
+ </para>
+
</section>
<section>
More information about the jboss-cvs-commits
mailing list