Author: julien_viet
Date: 2010-01-17 09:19:01 -0500 (Sun, 17 Jan 2010)
New Revision: 1338
Added:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/ClassTypeMetaData.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/ConvertedTypeMetaData.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/DomainMetaData.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/TypeMetaData.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/metadata/
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/metadata/ArrayListTypeConverter.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/metadata/TestMetaData.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/metadata/ThreadTypeConverter.java
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/FieldModel.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeDomain.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectReader.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectWriter.java
Log:
add support for external metadata to configure type model
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/FieldModel.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/FieldModel.java 2010-01-17
09:50:01 UTC (rev 1337)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/FieldModel.java 2010-01-17
14:19:01 UTC (rev 1338)
@@ -114,4 +114,10 @@
throw new AssertionError(e);
}
}
+
+ @Override
+ public String toString()
+ {
+ return "FieldModel[name=" + field.getName() + ",owner=" + owner
+ "]";
+ }
}
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeDomain.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeDomain.java 2010-01-17
09:50:01 UTC (rev 1337)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeDomain.java 2010-01-17
14:19:01 UTC (rev 1338)
@@ -22,6 +22,10 @@
import org.exoplatform.webui.application.replication.api.TypeConverter;
import org.exoplatform.webui.application.replication.api.annotations.Converted;
import org.exoplatform.webui.application.replication.api.annotations.Serialized;
+import org.exoplatform.webui.application.replication.model.metadata.ClassTypeMetaData;
+import
org.exoplatform.webui.application.replication.model.metadata.ConvertedTypeMetaData;
+import org.exoplatform.webui.application.replication.model.metadata.DomainMetaData;
+import org.exoplatform.webui.application.replication.model.metadata.TypeMetaData;
import java.io.Serializable;
import java.lang.reflect.Field;
@@ -53,6 +57,9 @@
}
/** . */
+ private final DomainMetaData metaData;
+
+ /** . */
private final Map<String, TypeModel<?>> typeModelMap;
/** . */
@@ -64,13 +71,23 @@
/** . */
private final boolean buildIfAbsent;
+ public TypeDomain(boolean putIfAbsent)
+ {
+ this(new DomainMetaData(), putIfAbsent);
+ }
+
public TypeDomain()
{
- this(false);
+ this(new DomainMetaData(), false);
}
- public TypeDomain(boolean buildIfAbsent)
+ public TypeDomain(DomainMetaData metaData)
{
+ this(metaData, false);
+ }
+
+ public TypeDomain(DomainMetaData metaData, boolean buildIfAbsent)
+ {
ConcurrentHashMap<String, TypeModel<?>> typeModelMap = new
ConcurrentHashMap<String, TypeModel<?>>();
Map<String, TypeModel<?>> immutableTypeModelMap =
Collections.unmodifiableMap(typeModelMap);
Collection<TypeModel<?>> immutableTypeModelSet =
Collections.unmodifiableCollection(typeModelMap.values());
@@ -80,6 +97,7 @@
this.immutableTypeModelMap = immutableTypeModelMap;
this.immutableTypeModelSet = immutableTypeModelSet;
this.buildIfAbsent = buildIfAbsent;
+ this.metaData = new DomainMetaData(metaData);
}
public Map<String, TypeModel<?>> getTypeModelMap()
@@ -169,25 +187,39 @@
//
if (typeModel == null)
{
- boolean serialized = javaType.getAnnotation(Serialized.class) != null;
- boolean converted = javaType.getAnnotation(Converted.class) != null;
+ TypeMetaData typeMetaData = metaData.getTypeMetaData(javaType);
//
- if (serialized)
+ if (typeMetaData == null)
{
- if (converted)
+ boolean serialized = javaType.getAnnotation(Serialized.class) != null;
+ Converted converted = javaType.getAnnotation(Converted.class);
+ if (serialized)
{
- throw new TypeException();
+ if (converted != null)
+ {
+ throw new TypeException();
+ }
+ typeMetaData = new ClassTypeMetaData(true);
}
- typeModel = buildClassType(javaType, addedTypeModels, true);
+ else if (converted != null)
+ {
+ typeMetaData = new ConvertedTypeMetaData(converted.value());
+ }
+ else
+ {
+ typeMetaData = new ClassTypeMetaData(false);
+ }
}
- else if (converted)
+
+ //
+ if (typeMetaData instanceof ClassTypeMetaData)
{
- typeModel = buildConvertedType(javaType, addedTypeModels);
+ typeModel = buildClassType(javaType, addedTypeModels,
(ClassTypeMetaData)typeMetaData);
}
else
{
- typeModel = buildClassType(javaType, addedTypeModels, false);
+ typeModel = buildConvertedType(javaType, addedTypeModels,
(ConvertedTypeMetaData)typeMetaData);
}
}
@@ -195,12 +227,12 @@
return typeModel;
}
- private <O> ConvertedTypeModel<O, ?> buildConvertedType(Class<O>
javaType, Map<String, TypeModel<?>> addedTypeModels)
+ private <O> ConvertedTypeModel<O, ?> buildConvertedType(
+ Class<O> javaType,
+ Map<String, TypeModel<?>> addedTypeModels,
+ ConvertedTypeMetaData typeMetaData)
{
- Converted converted = javaType.getAnnotation(Converted.class);
-
- //
- Class<? extends TypeConverter<?, ?>> converterClass =
converted.value();
+ Class<? extends TypeConverter<?, ?>> converterClass =
typeMetaData.getConverterClass();
ParameterizedType converterParameterizedType =
(ParameterizedType)converterClass.getGenericSuperclass();
//
@@ -210,7 +242,7 @@
}
//
- Class<? extends TypeConverter<O, ?>> converterJavaType =
(Class<TypeConverter<O, ?>>)converted.value();
+ Class<? extends TypeConverter<O, ?>> converterJavaType =
(Class<TypeConverter<O, ?>>)typeMetaData.getConverterClass();
//
return buildConvertedType(javaType, addedTypeModels, converterJavaType);
@@ -244,7 +276,7 @@
return typeModel;
}
- private <O> ClassTypeModel<O> buildClassType(Class<O> javaType,
Map<String, TypeModel<?>> addedTypeModels, boolean serialized)
+ private <O> ClassTypeModel<O> buildClassType(Class<O> javaType,
Map<String, TypeModel<?>> addedTypeModels, ClassTypeMetaData typeMetaData)
{
ClassTypeModel<? super O> superTypeModel = null;
if (javaType.getSuperclass() != null)
@@ -265,7 +297,7 @@
//
SerializationMode serializationMode;
- if (serialized)
+ if (typeMetaData.isSerialized())
{
serializationMode = SerializationMode.SERIALIZED;
}
Added:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/ClassTypeMetaData.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/ClassTypeMetaData.java
(rev 0)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/ClassTypeMetaData.java 2010-01-17
14:19:01 UTC (rev 1338)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * 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.exoplatform.webui.application.replication.model.metadata;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class ClassTypeMetaData extends TypeMetaData
+{
+
+ /** . */
+ private final boolean serialized;
+
+ public ClassTypeMetaData(boolean serialized)
+ {
+ this.serialized = serialized;
+ }
+
+ public boolean isSerialized()
+ {
+ return serialized;
+ }
+}
Added:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/ConvertedTypeMetaData.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/ConvertedTypeMetaData.java
(rev 0)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/ConvertedTypeMetaData.java 2010-01-17
14:19:01 UTC (rev 1338)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * 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.exoplatform.webui.application.replication.model.metadata;
+
+import org.exoplatform.webui.application.replication.api.TypeConverter;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class ConvertedTypeMetaData extends TypeMetaData
+{
+
+ /** . */
+ private final Class<? extends TypeConverter<?, ?>> converterClass;
+
+ public ConvertedTypeMetaData(Class<? extends TypeConverter<?, ?>>
converterClass)
+ {
+ if (converterClass == null)
+ {
+ throw new NullPointerException();
+ }
+
+ //
+ this.converterClass = converterClass;
+ }
+
+ public Class<? extends TypeConverter<?, ?>> getConverterClass()
+ {
+ return converterClass;
+ }
+}
Added:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/DomainMetaData.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/DomainMetaData.java
(rev 0)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/DomainMetaData.java 2010-01-17
14:19:01 UTC (rev 1338)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * 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.exoplatform.webui.application.replication.model.metadata;
+
+import org.exoplatform.webui.application.replication.api.TypeConverter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class DomainMetaData
+{
+
+ /** . */
+ private final Map<String, TypeMetaData> state;
+
+ public DomainMetaData(DomainMetaData domainMetaData)
+ {
+ if (domainMetaData == null)
+ {
+ throw new NullPointerException();
+ }
+
+ //
+ this.state = new HashMap<String, TypeMetaData>(domainMetaData.state);
+ }
+
+ public DomainMetaData()
+ {
+ this.state = new HashMap<String, TypeMetaData>();
+ }
+
+ public TypeMetaData getTypeMetaData(Class clazz)
+ {
+ if (clazz == null)
+ {
+ throw new NullPointerException();
+ }
+ return state.get(clazz.getName());
+ }
+
+ public TypeMetaData getTypeMetaData(String name)
+ {
+ if (name == null)
+ {
+ throw new NullPointerException();
+ }
+ return state.get(name);
+ }
+
+ public void addConvertedType(Class<?> clazz, Class<? extends
TypeConverter<?, ?>> converterClass)
+ {
+ if (clazz == null)
+ {
+ throw new NullPointerException();
+ }
+ state.put(clazz.getName(), new ConvertedTypeMetaData(converterClass));
+ }
+
+ public void addClassType(Class<?> clazz, boolean serialized)
+ {
+ if (clazz == null)
+ {
+ throw new NullPointerException();
+ }
+ state.put(clazz.getName(), new ClassTypeMetaData(serialized));
+ }
+}
Added:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/TypeMetaData.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/TypeMetaData.java
(rev 0)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/metadata/TypeMetaData.java 2010-01-17
14:19:01 UTC (rev 1338)
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * 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.exoplatform.webui.application.replication.model.metadata;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public abstract class TypeMetaData
+{
+}
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectReader.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectReader.java 2010-01-17
09:50:01 UTC (rev 1337)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectReader.java 2010-01-17
14:19:01 UTC (rev 1338)
@@ -261,4 +261,19 @@
return obj;
}
}
+
+ @Override
+ protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException,
ClassNotFoundException
+ {
+ try
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ String name = desc.getName();
+ return Class.forName(name, false, cl);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ return super.resolveClass(desc);
+ }
+ }
}
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectWriter.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectWriter.java 2010-01-17
09:50:01 UTC (rev 1337)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectWriter.java 2010-01-17
14:19:01 UTC (rev 1338)
@@ -139,6 +139,7 @@
{
if (!fieldModel.isTransient())
{
+ System.out.println("About to serialize field " +
fieldModel + " of type " + currentTypeModel);
Object fieldValue = fieldModel.get(obj);
if (fieldValue == null)
{
Added:
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/metadata/ArrayListTypeConverter.java
===================================================================
---
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/metadata/ArrayListTypeConverter.java
(rev 0)
+++
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/metadata/ArrayListTypeConverter.java 2010-01-17
14:19:01 UTC (rev 1338)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * 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.exoplatform.webui.replication.metadata;
+
+import org.exoplatform.webui.application.replication.api.TypeConverter;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class ArrayListTypeConverter extends TypeConverter<ArrayList, LinkedList>
+{
+ @Override
+ public LinkedList write(ArrayList input) throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public ArrayList read(LinkedList output) throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+}
\ No newline at end of file
Added:
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/metadata/TestMetaData.java
===================================================================
---
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/metadata/TestMetaData.java
(rev 0)
+++
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/metadata/TestMetaData.java 2010-01-17
14:19:01 UTC (rev 1338)
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * 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.exoplatform.webui.replication.metadata;
+
+import junit.framework.TestCase;
+import org.exoplatform.webui.application.replication.model.ClassTypeModel;
+import org.exoplatform.webui.application.replication.model.ConvertedTypeModel;
+import org.exoplatform.webui.application.replication.model.SerializationMode;
+import org.exoplatform.webui.application.replication.model.TypeDomain;
+import org.exoplatform.webui.application.replication.model.metadata.DomainMetaData;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class TestMetaData extends TestCase
+{
+
+ public void testSerializedObjectClassType() throws Exception
+ {
+ DomainMetaData domainMD = new DomainMetaData();
+ domainMD.addClassType(Object.class, true);
+ TypeDomain typeDomain = new TypeDomain(domainMD);
+ ClassTypeModel<Object> objectTM = (ClassTypeModel<Object>)
typeDomain.add(Object.class);
+ assertEquals(SerializationMode.SERIALIZED, objectTM.getSerializationMode());
+ }
+
+ public void testObjectClassType() throws Exception
+ {
+ DomainMetaData domainMD = new DomainMetaData();
+ domainMD.addClassType(Object.class, false);
+ TypeDomain typeDomain = new TypeDomain(domainMD);
+ ClassTypeModel<Object> objectTM =
(ClassTypeModel<Object>)typeDomain.add(Object.class);
+ assertEquals(SerializationMode.NONE, objectTM.getSerializationMode());
+ }
+
+ public void testStringSerializedClassType() throws Exception
+ {
+ DomainMetaData domainMD = new DomainMetaData();
+ domainMD.addClassType(String.class, true);
+ TypeDomain typeDomain = new TypeDomain(domainMD);
+ ClassTypeModel<String> stringTM =
(ClassTypeModel<String>)typeDomain.add(String.class);
+ assertEquals(SerializationMode.SERIALIZED, stringTM.getSerializationMode());
+ }
+
+ public void testStringClassType() throws Exception
+ {
+ DomainMetaData domainMD = new DomainMetaData();
+ domainMD.addClassType(String.class, false);
+ TypeDomain typeDomain = new TypeDomain(domainMD);
+ ClassTypeModel<String> stringTM =
(ClassTypeModel<String>)typeDomain.add(String.class);
+ assertEquals(SerializationMode.SERIALIZABLE, stringTM.getSerializationMode());
+ }
+
+ public void testThreadConvertedType() throws Exception
+ {
+ DomainMetaData domainMD = new DomainMetaData();
+ domainMD.addConvertedType(Thread.class, ThreadTypeConverter.class);
+ TypeDomain typeDomain = new TypeDomain(domainMD);
+ ConvertedTypeModel<Thread, String> objectTM = (ConvertedTypeModel<Thread,
String>)typeDomain.add(Thread.class);
+ assertEquals(ThreadTypeConverter.class, objectTM.getConverterJavaType());
+ }
+
+ public void testArrayListConvertedType() throws Exception
+ {
+ DomainMetaData domainMD = new DomainMetaData();
+ domainMD.addConvertedType(ArrayList.class, ArrayListTypeConverter.class);
+ TypeDomain typeDomain = new TypeDomain(domainMD);
+ ConvertedTypeModel<ArrayList, LinkedList> arrayListTM =
(ConvertedTypeModel<ArrayList, LinkedList>)typeDomain.add(ArrayList.class);
+ assertEquals(ArrayListTypeConverter.class, arrayListTM.getConverterJavaType());
+ }
+}
Added:
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/metadata/ThreadTypeConverter.java
===================================================================
---
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/metadata/ThreadTypeConverter.java
(rev 0)
+++
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/metadata/ThreadTypeConverter.java 2010-01-17
14:19:01 UTC (rev 1338)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * 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.exoplatform.webui.replication.metadata;
+
+import org.exoplatform.webui.application.replication.api.TypeConverter;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class ThreadTypeConverter extends TypeConverter<Thread, String>
+{
+ @Override
+ public String write(Thread input) throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public Thread read(String output) throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+}