[jboss-cvs] JBossAS SVN: r63989 - in projects/microcontainer/trunk/container/src/main/org/jboss: reflect/plugins and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jul 12 07:27:07 EDT 2007
Author: alesj
Date: 2007-07-12 07:27:07 -0400 (Thu, 12 Jul 2007)
New Revision: 63989
Removed:
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionSerializationHelper.java
Modified:
projects/microcontainer/trunk/container/src/main/org/jboss/javabean/plugins/xml/ConfigurationUtil.java
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/SerializationHelper.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
Log:
Simplyfied by readResolve on the ClassInfoImpl.
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/javabean/plugins/xml/ConfigurationUtil.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/javabean/plugins/xml/ConfigurationUtil.java 2007-07-12 10:09:16 UTC (rev 63988)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/javabean/plugins/xml/ConfigurationUtil.java 2007-07-12 11:27:07 UTC (rev 63989)
@@ -22,15 +22,13 @@
package org.jboss.javabean.plugins.xml;
import java.security.AccessController;
-import java.security.PrivilegedExceptionAction;
+import java.security.PrivilegedAction;
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.info.spi.PropertyInfo;
import org.jboss.config.plugins.property.PropertyConfiguration;
import org.jboss.config.spi.Configuration;
-import org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory;
import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.reflect.spi.TypeInfoFactory;
import org.jboss.util.propertyeditor.PropertyEditors;
/**
@@ -42,31 +40,18 @@
{
/** The kernel config */
private static Configuration config;
- /** The type info factory */
- private static final TypeInfoFactory typeInfoFactory = new IntrospectionTypeInfoFactory();
static synchronized void init()
{
- if( config == null )
+ if(config == null)
{
- try
+ config = AccessController.doPrivileged(new PrivilegedAction<Configuration>()
{
- config = AccessController.doPrivileged(new PrivilegedExceptionAction<Configuration>()
+ public Configuration run()
{
- public Configuration run() throws Exception
- {
- return new PropertyConfiguration(System.getProperties());
- }
- });
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- throw new RuntimeException("Error getting configuration", e);
- }
+ return new PropertyConfiguration(System.getProperties());
+ }
+ });
PropertyEditors.init();
}
}
@@ -128,7 +113,7 @@
TypeInfo type = property.getType();
if (override != null)
- type = typeInfoFactory.getTypeInfo(override, null);
+ type = config.getTypeInfoFactory().getTypeInfo(override, null);
return type != null ? type.convertValue(value) : value;
}
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-12 10:09:16 UTC (rev 63988)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java 2007-07-12 11:27:07 UTC (rev 63989)
@@ -26,9 +26,6 @@
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;
@@ -119,9 +116,6 @@
/** The attachments */
private transient TypeInfoAttachments attachments;
- /** The serialization helper */
- private SerializationHelper serializationHelper;
-
/**
* Create a new abstract ClassInfo.
*/
@@ -173,19 +167,14 @@
return typeInfoFactory;
}
- public void setSerializationHelper(SerializationHelper serializationHelper)
+ public void setTypeInfoFactory(TypeInfoFactory typeInfoFactory)
{
- if (serializationHelper == null)
- throw new IllegalArgumentException("Null serialization helper.");
- this.serializationHelper = serializationHelper;
- provideHelpers();
+ this.typeInfoFactory = typeInfoFactory;
}
- private void provideHelpers()
+ public void setClassInfoHelper(ClassInfoHelper classInfoHelper)
{
- this.classInfoHelper = serializationHelper.provideClassInfoHelper();
- this.typeInfoFactory = serializationHelper.provideTypeInfoFactory();
- this.annotationHelper = serializationHelper.provideAnnotationHelper();
+ this.classInfoHelper = classInfoHelper;
}
/**
@@ -634,14 +623,9 @@
return (name != null ? name.hashCode() : 0);
}
- private void writeObject(ObjectOutputStream oos) throws IOException
+ Object readResolve()
{
- oos.defaultWriteObject();
+ TypeInfoFactory typeInfoFactory = SerializationHelper.getTypeInfoFactory();
+ return typeInfoFactory.getTypeInfo(getType());
}
-
- 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-12 10:09:16 UTC (rev 63988)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/InheritableAnnotationHolder.java 2007-07-12 11:27:07 UTC (rev 63989)
@@ -77,7 +77,12 @@
{
this.annotatedElement = annotatedElement;
}
-
+
+ public void setAnnotationHelper(AnnotationHelper annotationHelper)
+ {
+ this.annotationHelper = annotationHelper;
+ }
+
/**
* Get the declared annotations
*
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/SerializationHelper.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/SerializationHelper.java 2007-07-12 10:09:16 UTC (rev 63988)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/SerializationHelper.java 2007-07-12 11:27:07 UTC (rev 63989)
@@ -21,35 +21,37 @@
*/
package org.jboss.reflect.plugins;
-import java.io.Serializable;
+import java.security.PrivilegedAction;
+import java.security.AccessController;
+import org.jboss.config.spi.Configuration;
+import org.jboss.config.plugins.property.PropertyConfiguration;
import org.jboss.reflect.spi.TypeInfoFactory;
/**
- * Provide helper instances for ClassInfo to work.
+ * Provide type info factory for ClassInfoImpl.
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public interface SerializationHelper extends Serializable
+class SerializationHelper
{
- /**
- * Get the type info factory.
- *
- * @return type info factory
- */
- TypeInfoFactory provideTypeInfoFactory();
+ /** The type info factory */
+ private static final TypeInfoFactory factory;
- /**
- * Get the class info helper.
- *
- * @return class info helper
- */
- ClassInfoHelper provideClassInfoHelper();
+ static
+ {
+ Configuration configuration = AccessController.doPrivileged(new PrivilegedAction<Configuration>()
+ {
+ public Configuration run()
+ {
+ return new PropertyConfiguration();
+ }
+ });
+ factory = configuration.getTypeInfoFactory();
+ }
- /**
- * Get the annotation helper.
- *
- * @return annotation helper
- */
- AnnotationHelper provideAnnotationHelper();
+ static TypeInfoFactory getTypeInfoFactory()
+ {
+ return factory;
+ }
}
Deleted: 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 2007-07-12 10:09:16 UTC (rev 63988)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionSerializationHelper.java 2007-07-12 11:27:07 UTC (rev 63989)
@@ -1,65 +0,0 @@
-/*
-* 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 final long serialVersionUID = 2750888041049795818L;
- 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-12 10:09:16 UTC (rev 63988)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactory.java 2007-07-12 11:27:07 UTC (rev 63989)
@@ -34,20 +34,23 @@
*
* @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
*/
-public class IntrospectionTypeInfoFactory extends IntrospectionDelegateHolder implements TypeInfoFactory
+public class IntrospectionTypeInfoFactory implements TypeInfoFactory
{
+ /** The delegate */
+ private static IntrospectionTypeInfoFactoryImpl delegate = new IntrospectionTypeInfoFactoryImpl();
+
public TypeInfo getTypeInfo(Class clazz)
{
- return getDelegate().getTypeInfo(clazz);
+ return delegate.getTypeInfo(clazz);
}
public TypeInfo getTypeInfo(String name, ClassLoader cl) throws ClassNotFoundException
{
- return getDelegate().getTypeInfo(name, cl);
+ return delegate.getTypeInfo(name, cl);
}
public TypeInfo getTypeInfo(Type type)
{
- return getDelegate().getTypeInfo(type);
+ return delegate.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-12 10:09:16 UTC (rev 63988)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java 2007-07-12 11:27:07 UTC (rev 63989)
@@ -300,11 +300,11 @@
name = ((Class) type).getName();
if (name != null)
{
- TypeInfo primitive = PrimitiveInfo.valueOf(((Class) type).getName());
+ TypeInfo primitive = PrimitiveInfo.valueOf(name);
if (primitive != null)
return primitive;
- NumberInfo number = NumberInfo.valueOf(((Class) type).getName());
+ NumberInfo number = NumberInfo.valueOf(name);
if (number != null)
{
if (number.isInitialized() == false)
@@ -383,16 +383,14 @@
}
((AnnotationInfoImpl)result).setAttributes(atttributes);
}
- else if (clazz.isInterface())
- {
- result = new ReflectClassInfoImpl(clazz.getName());
- }
else
{
result = new ReflectClassInfoImpl(clazz.getName());
}
result.setType(clazz);
- result.setSerializationHelper(IntrospectionSerializationHelper.getInstance());
+ result.setTypeInfoFactory(this);
+ result.setClassInfoHelper(this);
+ result.setAnnotationHelper(this);
return result;
}
More information about the jboss-cvs-commits
mailing list