Author: julien_viet
Date: 2010-01-18 08:24:19 -0500 (Mon, 18 Jan 2010)
New Revision: 1350
Removed:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/Replicatable.java
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/TypeConverter.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/Converted.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/Serialized.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/factory/ObjectFactory.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/DataContainer.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/DataKind.java
Log:
a bit of tuning of the replication framework
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/Replicatable.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/Replicatable.java 2010-01-18
12:48:28 UTC (rev 1349)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/Replicatable.java 2010-01-18
13:24:19 UTC (rev 1350)
@@ -1,28 +0,0 @@
-/*
- * 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;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public interface Replicatable
-{
-}
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/TypeConverter.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/TypeConverter.java 2010-01-18
12:48:28 UTC (rev 1349)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/TypeConverter.java 2010-01-18
13:24:19 UTC (rev 1350)
@@ -20,14 +20,33 @@
package org.exoplatform.webui.application.replication.api;
/**
+ * A type converter that performs a bidirectional conversion between an external
+ * type and an internal type. The converter only assure conversion of non null values.
+ *
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
+ * @param <E> the type parameter of the external type
+ * @param <I> the type parameter of the internal type
*/
-public abstract class TypeConverter<I, O>
+public abstract class TypeConverter<E, I>
{
- public abstract O write(I input) throws Exception;
+ /**
+ * Converts an external value to an internal value.
+ *
+ * @param external the external value
+ * @return the the internal value
+ * @throws Exception any conversion exception
+ */
+ public abstract I write(E external) throws Exception;
- public abstract I read(O output) throws Exception;
+ /**
+ * Converts an internal value to an external value.
+ *
+ * @param internal the internal value
+ * @return the external value
+ * @throws Exception any conversion exception
+ */
+ public abstract E read(I internal) throws Exception;
}
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/Converted.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/Converted.java 2010-01-18
12:48:28 UTC (rev 1349)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/Converted.java 2010-01-18
13:24:19 UTC (rev 1350)
@@ -28,7 +28,7 @@
import java.lang.annotation.Target;
/**
- * Annotates a type to be converted to another type for serialization.
+ * Declares a type to be converted.
*
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/Serialized.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/Serialized.java 2010-01-18
12:48:28 UTC (rev 1349)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/Serialized.java 2010-01-18
13:24:19 UTC (rev 1350)
@@ -25,7 +25,7 @@
import java.lang.annotation.Target;
/**
- * Annotates a type to be serializable.
+ * Declares a type serialized.
*
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/factory/ObjectFactory.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/factory/ObjectFactory.java 2010-01-18
12:48:28 UTC (rev 1349)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/factory/ObjectFactory.java 2010-01-18
13:24:19 UTC (rev 1350)
@@ -24,21 +24,24 @@
import java.util.Map;
/**
+ * A factory that creates instance of a type.
+ *
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
- * @param <B> the base object type
+ * @param <B> the paraemter type of the base type
*/
public abstract class ObjectFactory<B>
{
/**
- * Instantiate an object based on the provided class.
+ * Instantiate an object based on the provided type. The implementor should take care
of
+ * configuring the state of the returned objet with the provided state map argument.
*
* @param type the type
* @param state the state
- * @param <S> the sub type of the base type
+ * @param <S> the parameter type of the sub type of the base type
* @return the S instance
- * @throws CreateException anything wrong that could happen during instance creation
+ * @throws CreateException anything wrong that happened during instance creation
*/
public abstract <S extends B> S create(Class<S> type,
Map<FieldModel<? super S, ?>, ?> state) throws CreateException;
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/DataContainer.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/DataContainer.java 2010-01-18
12:48:28 UTC (rev 1349)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/DataContainer.java 2010-01-18
13:24:19 UTC (rev 1350)
@@ -19,14 +19,17 @@
package org.exoplatform.webui.application.replication.serial;
-import java.io.*;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.LinkedList;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class DataContainer implements Serializable
+public class DataContainer implements Externalizable
{
/** . */
@@ -57,6 +60,24 @@
return structure.removeFirst();
}
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ out.writeInt(structure.size());
+ for (Object o : structure)
+ {
+ out.writeObject(o);
+ }
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ int size = in.readInt();
+ while (size-- > 0)
+ {
+ structure.addLast(in.readObject());
+ }
+ }
+
@Override
public String toString()
{
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/DataKind.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/DataKind.java 2010-01-18
12:48:28 UTC (rev 1349)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/DataKind.java 2010-01-18
13:24:19 UTC (rev 1350)
@@ -23,7 +23,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class DataKind
+class DataKind
{
public static final int OBJECT = 0;