gatein SVN: r1342 - in portal/trunk/portlet/exoadmin/src/main: webapp/WEB-INF/classes/locale/portlet/exoadmin and 1 other directory.
by do-not-reply@jboss.org
Author: tan_pham_dinh
Date: 2010-01-17 23:18:28 -0500 (Sun, 17 Jan 2010)
New Revision: 1342
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIAddApplicationForm.java
portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_ar.xml
portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties
portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_es.properties
portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_it.properties
portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_ko.xml
portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_ru.properties
portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_uk.properties
portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_vi.xml
Log:
GTNPORTAL-316: Should show a message when select type of apps, which has no apps, in UIAddApplicationForm
Modified: portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIAddApplicationForm.java
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIAddApplicationForm.java 2010-01-18 02:13:08 UTC (rev 1341)
+++ portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIAddApplicationForm.java 2010-01-18 04:18:28 UTC (rev 1342)
@@ -37,8 +37,8 @@
import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
import org.exoplatform.webui.core.model.SelectItemOption;
import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.event.Event.Phase;
-import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.form.UIForm;
import org.exoplatform.webui.form.UIFormInputInfo;
import org.exoplatform.webui.form.UIFormInputSet;
@@ -196,7 +196,7 @@
String portletName = info.getName();
Application app = new Application();
app.setApplicationName(portletName);
-// app.setApplicationGroup(info.getApplicationName());
+ // app.setApplicationGroup(info.getApplicationName());
ApplicationType appType;
String contentId;
if (remote)
@@ -207,7 +207,7 @@
else
{
appType = ApplicationType.PORTLET;
- contentId = info.getApplicationName() + "/" + info.getName();
+ contentId = info.getApplicationName() + "/" + info.getName();
}
app.setType(appType);
app.setDisplayName(Util.getLocalizedStringValue(displayNameLS, portletName));
@@ -228,6 +228,14 @@
UIAddApplicationForm uiForm = event.getSource();
String type = uiForm.getUIFormSelectBox(UIAddApplicationForm.FIELD_TYPE).getValue();
uiForm.setApplicationList(type);
+ uiForm.getChild(UIFormTableIteratorInputSet.class).setRendered(true);
+ if (uiForm.getApplications().size() == 0)
+ {
+ UIApplication uiApp = event.getRequestContext().getUIApplication();
+ uiApp.addMessage(new ApplicationMessage("UIAddApplicationForm.msg.typeNoApps", null));
+ event.getRequestContext().addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages());
+ uiForm.getChild(UIFormTableIteratorInputSet.class).setRendered(false);
+ }
event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
}
@@ -282,7 +290,7 @@
uiOrganizer.setSelectedCategory(selectedCate.getName());
uiOrganizer.selectApplication(app.getApplicationName());
ctx.addUIComponentToUpdateByAjax(uiOrganizer);
- }
+ }
private Application cloneApplication(Application app)
{
Modified: portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_ar.xml
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_ar.xml 2010-01-18 02:13:08 UTC (rev 1341)
+++ portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_ar.xml 2010-01-18 04:18:28 UTC (rev 1342)
@@ -145,6 +145,7 @@
<msg>
<PortletExist>!إن هذه الخدمة في الفئة ، يرجى اختيار واحدة أخرى</PortletExist>
<appNotExists>Please select an application.</appNotExists>
+ <typeNoApps>There is no applications of this type.</typeNoApps>
</msg>
<label>
<displayName>#{label.displayName}</displayName>
Modified: portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties 2010-01-18 02:13:08 UTC (rev 1341)
+++ portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties 2010-01-18 04:18:28 UTC (rev 1342)
@@ -76,6 +76,7 @@
UIAddApplicationForm.action.Add=Add
UIAddApplicationForm.msg.PortletExist=This Application is already in category, please select another one!
UIAddApplicationForm.msg.appNotExists=Please select an application.
+UIAddApplicationForm.msg.typeNoApps=There is no applications of this type.
UIAddApplicationForm.action.Cancel=#{word.cancel}
UIAddApplicationForm.label.displayName=#{label.displayName}
UIAddApplicationForm.label.type=Application Type
Modified: portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_es.properties
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_es.properties 2010-01-18 02:13:08 UTC (rev 1341)
+++ portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_es.properties 2010-01-18 04:18:28 UTC (rev 1342)
@@ -76,6 +76,7 @@
UIAddApplicationForm.action.Add=A\u00f1adir
UIAddApplicationForm.msg.PortletExist=Esta aplicaci\u00f3n ya existe en la categor\u00eda, por favor seleccione otra aplicaci\u00f3n!
UIAddApplicationForm.msg.appNotExists=Por favor, selecciona una aplicaci\u00f3n.
+UIAddApplicationForm.msg.typeNoApps=There is no applications of this type.
UIAddApplicationForm.action.Cancel=#{word.cancel}
UIAddApplicationForm.label.displayName=#{label.displayName}
UIAddApplicationForm.label.type=Tipo de Aplicaci\u00f3n
Modified: portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_it.properties
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_it.properties 2010-01-18 02:13:08 UTC (rev 1341)
+++ portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_it.properties 2010-01-18 04:18:28 UTC (rev 1342)
@@ -76,6 +76,7 @@
UIAddApplicationForm.action.Add=Aggiungi
UIAddApplicationForm.msg.PortletExist=L'applicazione \u00E8 gi\u00E0 presente nella categoria, selezionane un'altra!
UIAddApplicationForm.msg.appNotExists=Seleziona l'applicazione.
+UIAddApplicationForm.msg.typeNoApps=There is no applications of this type.
UIAddApplicationForm.action.Cancel=#{word.cancel}
UIAddApplicationForm.label.displayName=#{label.displayName}
UIAddApplicationForm.label.type=Tipo di Applicazione
Modified: portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_ko.xml
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_ko.xml 2010-01-18 02:13:08 UTC (rev 1341)
+++ portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_ko.xml 2010-01-18 04:18:28 UTC (rev 1342)
@@ -145,6 +145,7 @@
<msg>
<PortletExist>카테고리에 이 애플리케이션이 이미 존재합니다. 다른 애플리케이션을 선택해 주십시오.</PortletExist>
<appNotExists>애플리케이션을 선택해 주십시오.</appNotExists>
+ <typeNoApps>There is no applications of this type.</typeNoApps>
</msg>
<label>
<displayName>#{label.displayName}</displayName>
Modified: portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_ru.properties
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_ru.properties 2010-01-18 02:13:08 UTC (rev 1341)
+++ portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_ru.properties 2010-01-18 04:18:28 UTC (rev 1342)
@@ -77,6 +77,7 @@
UIAddApplicationForm.action.Add=Добавить
UIAddApplicationForm.msg.PortletExist=Это приложение уже в указанной категории. Выберите другую категори.
UIAddApplicationForm.msg.appNotExists=Please select an application.
+UIAddApplicationForm.msg.typeNoApps=There is no applications of this type.
UIAddApplicationForm.action.Cancel=#{word.cancel}
UIAddApplicationForm.label.displayName=#{label.displayName}
UIAddApplicationForm.label.type=Тип приложения
Modified: portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_uk.properties
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_uk.properties 2010-01-18 02:13:08 UTC (rev 1341)
+++ portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_uk.properties 2010-01-18 04:18:28 UTC (rev 1342)
@@ -77,6 +77,7 @@
UIAddApplicationForm.action.Add=Додати
UIAddApplicationForm.msg.PortletExist=Це застосування вже є в категорії, будь ласка, оберіть інше!
UIAddApplicationForm.msg.appNotExists=Please select an application.
+UIAddApplicationForm.msg.typeNoApps=There is no applications of this type.
UIAddApplicationForm.action.Cancel=#{word.cancel}
UIAddApplicationForm.label.displayName=#{label.displayName}
UIAddApplicationForm.label.type=Тип застосування
Modified: portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_vi.xml
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_vi.xml 2010-01-18 02:13:08 UTC (rev 1341)
+++ portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_vi.xml 2010-01-18 04:18:28 UTC (rev 1342)
@@ -145,6 +145,7 @@
<msg>
<PortletExist>Ứng dụng này đã tồn tại trong danh mục này, hãy chọn một ứng dụng khác!</PortletExist>
<appNotExists>Vui lòng chọn một ứng dụng.</appNotExists>
+ <typeNoApps>Không tồn tại ứng dụng theo kiểu ứng dụng đã chọn.</typeNoApps>
</msg>
<label>
<displayName>#{label.displayName}</displayName>
14 years, 11 months
gatein SVN: r1341 - in portal/trunk: webui/core/src/main/java/org/exoplatform/webui/bean and 1 other directories.
by do-not-reply@jboss.org
Author: liem_nguyen
Date: 2010-01-17 21:13:08 -0500 (Sun, 17 Jan 2010)
New Revision: 1341
Modified:
portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIRepeater.gtmpl
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/bean/UIDataFeed.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIRepeater.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIVirtualList.java
Log:
GTNPORTAL-430 Show exception when delete page in special case (Re-opened)
Modified: portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIRepeater.gtmpl
===================================================================
--- portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIRepeater.gtmpl 2010-01-18 00:14:27 UTC (rev 1340)
+++ portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIRepeater.gtmpl 2010-01-18 02:13:08 UTC (rev 1341)
@@ -12,8 +12,7 @@
String name = uicomponent.getLabel() ;
UIForm uiForm = uicomponent.getAncestorOfType(UIForm.class);
- DateFormat dateFormat = null;
- try {
+ DateFormat dateFormat = null;
%>
<div id="$uicomponent.id">
<table class="UIGrid" cellspacing="0">
@@ -90,6 +89,4 @@
%>
</tbody>
</table>
-</div>
-
-<% } catch (java.lang.Throwable e) {} %>
\ No newline at end of file
+</div>
\ No newline at end of file
Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/bean/UIDataFeed.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/bean/UIDataFeed.java 2010-01-18 00:14:27 UTC (rev 1340)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/bean/UIDataFeed.java 2010-01-18 02:13:08 UTC (rev 1341)
@@ -19,6 +19,7 @@
package org.exoplatform.webui.bean;
+import org.exoplatform.commons.utils.DataMissingException;
import org.exoplatform.commons.utils.PageList;
/**
@@ -30,7 +31,12 @@
public void setDataSource(PageList datasource) throws Exception;
- public void feedNext() throws Exception;
+ /***
+ * Load data of next page. Throws DataMissingException when page's data is cannot load
+ * @throws DataMissingException
+ * @throws Exception
+ */
+ public void feedNext() throws DataMissingException, Exception;
public boolean hasNext();
}
Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIRepeater.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIRepeater.java 2010-01-18 00:14:27 UTC (rev 1340)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIRepeater.java 2010-01-18 02:13:08 UTC (rev 1341)
@@ -19,6 +19,7 @@
package org.exoplatform.webui.core;
+import org.exoplatform.commons.utils.DataMissingException;
import org.exoplatform.commons.utils.PageList;
import org.exoplatform.util.ReflectionUtil;
import org.exoplatform.webui.bean.UIDataFeed;
@@ -105,7 +106,7 @@
return method.invoke(bean, ReflectionUtil.EMPTY_ARGS);
}
- public void feedNext() throws Exception
+ public void feedNext() throws DataMissingException, Exception
{
int page = datasource.getCurrentPage();
page++;
@@ -113,6 +114,20 @@
{
datasource.getPage(page);
}
+
+ // Check LazyList load current page
+ try
+ {
+ List<?> objects = datasource.currentPage();
+ for (Object obj : objects) {
+ if (obj == null) throw new Exception("Data Row is Null");
+ }
+ }
+ catch (Throwable e)
+ {
+ datasource.getPage(page--);
+ throw new DataMissingException(e);
+ }
}
public boolean hasNext()
Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIVirtualList.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIVirtualList.java 2010-01-18 00:14:27 UTC (rev 1340)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIVirtualList.java 2010-01-18 02:13:08 UTC (rev 1341)
@@ -19,6 +19,7 @@
package org.exoplatform.webui.core;
+import org.exoplatform.commons.utils.DataMissingException;
import org.exoplatform.commons.utils.PageList;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.bean.UIDataFeed;
@@ -75,7 +76,17 @@
UIVirtualList virtualList = event.getSource();
UIDataFeed dataFeed = virtualList.getDataFeed();
WebuiRequestContext rContext = event.getRequestContext();
- dataFeed.feedNext();
+ try
+ {
+ dataFeed.feedNext();
+ }
+ catch (DataMissingException e)
+ {
+ // Update parent of virtual list to refresh
+ event.getRequestContext().addUIComponentToUpdateByAjax(virtualList.getParent());
+ return;
+ }
+
if (!dataFeed.hasNext())
{
rContext.getJavascriptManager().addJavascript(
14 years, 11 months
gatein SVN: r1340 - in portal/trunk/component/common/src: test/java/org/exoplatform/commons/utils and 1 other directory.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-01-17 19:14:27 -0500 (Sun, 17 Jan 2010)
New Revision: 1340
Added:
portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/NoArgConstructorPageList.java
portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/PageListAccess.java
portal/trunk/component/common/src/test/java/org/exoplatform/commons/utils/StringPageListAccess.java
portal/trunk/component/common/src/test/java/org/exoplatform/commons/utils/TestPageListAccess.java
Log:
version of PageList that can "reconnect" to a data set
Added: portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/NoArgConstructorPageList.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/NoArgConstructorPageList.java (rev 0)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/NoArgConstructorPageList.java 2010-01-18 00:14:27 UTC (rev 1340)
@@ -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.commons.utils;
+
+/**
+ * This class is required for the {@link org.exoplatform.commons.utils.PageListAccess} class to be serializable.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class NoArgConstructorPageList<E> extends PageList<E>
+{
+
+ protected NoArgConstructorPageList(int pageSize)
+ {
+ super(pageSize);
+ }
+
+ protected NoArgConstructorPageList()
+ {
+ super(10);
+ }
+}
Added: portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/PageListAccess.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/PageListAccess.java (rev 0)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/PageListAccess.java 2010-01-18 00:14:27 UTC (rev 1340)
@@ -0,0 +1,234 @@
+/*
+ * 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.commons.utils;
+
+import java.io.*;
+import java.lang.reflect.Field;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class PageListAccess<E, S extends Serializable> extends NoArgConstructorPageList<E> implements Serializable
+{
+
+ /** . */
+ private static final Field pageSizeField;
+
+ static
+ {
+ try
+ {
+ pageSizeField = PageList.class.getDeclaredField("pageSize_");
+ pageSizeField.setAccessible(true);
+ }
+ catch (NoSuchFieldException e)
+ {
+ throw new Error(e);
+ }
+ }
+
+ /** The state that recreates the list. */
+ private S state;
+
+ /** . */
+ private LazyList<E> lazyList;
+
+ protected PageListAccess(S state, int pageSize)
+ {
+ super(pageSize);
+
+ //
+ if (state == null)
+ {
+ throw new NullPointerException();
+ }
+ if (pageSize < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.state = state;
+ this.lazyList = null;
+ }
+
+ private void ensureCorrectState()
+ {
+ if (lazyList == null)
+ {
+ lazyList = new LazyList<E>(create(state), super.getPageSize());
+
+ // Save temporarily the current page
+ int currentPage = currentPage_;
+
+ // Refresh state
+ super.setAvailablePage(lazyList.size());
+
+ // Put back current page that was written by previous method call
+ if (currentPage != -1)
+ {
+ currentPage_ = currentPage;
+ }
+ }
+ }
+
+
+ @Override
+ protected final void populateCurrentPage(int page) throws Exception
+ {
+ // Make sure we have correct state
+ ensureCorrectState();
+
+ //
+ int from = getFrom();
+ int to = getTo();
+ currentListPage_ = lazyList.subList(from, to);
+ }
+
+ @Override
+ public final List<E> getAll()
+ {
+ ensureCorrectState();
+
+ //
+ return lazyList;
+ }
+
+ protected abstract ListAccess<E> create(S state);
+
+ // Serialization
+
+ private void writeObject(ObjectOutputStream out) throws IOException
+ {
+ int pageSize;
+ try
+ {
+ pageSize = pageSizeField.getInt(this);
+ }
+ catch (IllegalAccessException e)
+ {
+ InvalidObjectException ioe = new InvalidObjectException("Cannot set page size");
+ ioe.initCause(e);
+ throw ioe;
+ }
+
+ //
+ out.writeInt(pageSize);
+ out.writeInt(currentPage_);
+ out.writeObject(state);
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
+ {
+ try
+ {
+ pageSizeField.setInt(this, in.readInt());
+ }
+ catch (IllegalAccessException e)
+ {
+ InvalidObjectException ioe = new InvalidObjectException("Cannot set page size");
+ ioe.initCause(e);
+ throw ioe;
+ }
+ currentPage_ = in.readInt();
+ state = (S)in.readObject();
+ }
+
+ // Intercept all method calls
+
+ @Override
+ public final int getAvailablePage()
+ {
+ ensureCorrectState();
+ return super.getAvailablePage();
+ }
+
+ @Override
+ public final int getTo()
+ {
+ ensureCorrectState();
+ return super.getTo();
+ }
+
+ @Override
+ public final int getFrom()
+ {
+ ensureCorrectState();
+ return super.getFrom();
+ }
+
+ @Override
+ protected final void setAvailablePage(int available)
+ {
+ ensureCorrectState();
+ super.setAvailablePage(available);
+ }
+
+ @Override
+ protected final void checkAndSetPage(int page) throws Exception
+ {
+ ensureCorrectState();
+ super.checkAndSetPage(page);
+ }
+
+ @Override
+ public final List<E> getPage(int page) throws Exception
+ {
+ ensureCorrectState();
+ return super.getPage(page);
+ }
+
+ @Override
+ public final List<E> currentPage() throws Exception
+ {
+ ensureCorrectState();
+ return super.currentPage();
+ }
+
+ @Override
+ public final int getAvailable()
+ {
+ ensureCorrectState();
+ return super.getAvailable();
+ }
+
+ @Override
+ public final int getCurrentPage()
+ {
+ ensureCorrectState();
+ return super.getCurrentPage();
+ }
+
+ @Override
+ public final void setPageSize(int pageSize)
+ {
+ ensureCorrectState();
+ super.setPageSize(pageSize);
+ }
+
+ @Override
+ public final int getPageSize()
+ {
+ ensureCorrectState();
+ return super.getPageSize();
+ }
+}
Added: portal/trunk/component/common/src/test/java/org/exoplatform/commons/utils/StringPageListAccess.java
===================================================================
--- portal/trunk/component/common/src/test/java/org/exoplatform/commons/utils/StringPageListAccess.java (rev 0)
+++ portal/trunk/component/common/src/test/java/org/exoplatform/commons/utils/StringPageListAccess.java 2010-01-18 00:14:27 UTC (rev 1340)
@@ -0,0 +1,63 @@
+/*
+ * 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.commons.utils;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class StringPageListAccess extends PageListAccess<String, String[]>
+{
+
+ public StringPageListAccess(int pageSize, String... state)
+ {
+ super(state, pageSize);
+ }
+
+ @Override
+ protected ListAccess<String> create(String[] state)
+ {
+ return new ArrayListAccess(state);
+ }
+
+ private static class ArrayListAccess implements ListAccess<String>
+ {
+
+ /** . */
+ private final String[] values;
+
+ private ArrayListAccess(String... values)
+ {
+ this.values = values;
+ }
+
+ public String[] load(int index, int length) throws Exception, IllegalArgumentException
+ {
+ String[] batch = new String[length];
+ System.arraycopy(values, index, batch, 0, length);
+ return batch;
+ }
+
+ public int getSize() throws Exception
+ {
+ return values.length;
+ }
+ }
+}
Added: portal/trunk/component/common/src/test/java/org/exoplatform/commons/utils/TestPageListAccess.java
===================================================================
--- portal/trunk/component/common/src/test/java/org/exoplatform/commons/utils/TestPageListAccess.java (rev 0)
+++ portal/trunk/component/common/src/test/java/org/exoplatform/commons/utils/TestPageListAccess.java 2010-01-18 00:14:27 UTC (rev 1340)
@@ -0,0 +1,154 @@
+/*
+ * 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.commons.utils;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import java.io.*;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestPageListAccess extends TestCase
+{
+
+ private final String[] l = {"0", "1", "2", "3", "4", "5", "6"};
+
+ public void testPageList() throws Exception
+ {
+ StringPageListAccess pageList = new StringPageListAccess(3, l);
+
+ //
+ assertState1(pageList);
+
+ //
+ pageList = clone(pageList);
+ assertState1(pageList);
+
+ //
+ List<String> list = pageList.getPage(1);
+ assertListState1(list);
+ assertState1(pageList);
+
+ //
+ pageList = clone(pageList);
+ list = pageList.getPage(1);
+ assertListState1(list);
+ assertState1(pageList);
+
+ //
+ list = pageList.getPage(2);
+ assertListState2(list);
+ assertState2(pageList);
+
+ //
+ pageList = clone(pageList);
+ list = pageList.getPage(2);
+ assertListState2(list);
+ assertState2(pageList);
+
+ //
+ list = pageList.getPage(3);
+ assertListState3(list);
+ assertState3(pageList);
+
+ //
+ pageList = clone(pageList);
+ list = pageList.getPage(3);
+ assertListState3(list);
+ assertState3(pageList);
+ }
+
+ private void assertListState3(List<String> list)
+ {
+ assertNotNull(list);
+ assertEquals(1, list.size());
+ assertEquals("6", list.get(0));
+ }
+
+ private void assertState3(PageList<String> list)
+ {
+ assertEquals(6, list.getFrom());
+ assertEquals(7, list.getTo());
+ assertEquals(3, list.getCurrentPage());
+ assertEquals(3, list.getAvailablePage());
+ assertEquals(7, list.getAvailable());
+ }
+
+ private void assertState2(PageList<String> list)
+ {
+ assertEquals(3, list.getFrom());
+ assertEquals(6, list.getTo());
+ assertEquals(2, list.getCurrentPage());
+ assertEquals(3, list.getAvailablePage());
+ assertEquals(7, list.getAvailable());
+ }
+
+ private void assertListState2(List<String> s)
+ {
+ assertNotNull(s);
+ assertEquals(3, s.size());
+ assertEquals("3", s.get(0));
+ assertEquals("4", s.get(1));
+ assertEquals("5", s.get(2));
+ }
+
+ private void assertListState1(List<String> s)
+ {
+ assertNotNull(s);
+ assertEquals(3, s.size());
+ assertEquals("0", s.get(0));
+ assertEquals("1", s.get(1));
+ assertEquals("2", s.get(2));
+ }
+
+ private void assertState1(PageList<String> list)
+ {
+ assertEquals(0, list.getFrom());
+ assertEquals(3, list.getTo());
+ assertEquals(1, list.getCurrentPage());
+ assertEquals(3, list.getAvailablePage());
+ assertEquals(7, list.getAvailable());
+ }
+
+
+ private StringPageListAccess clone(StringPageListAccess pageList)
+ {
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(pageList);
+ oos.close();
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ return (StringPageListAccess)ois.readObject();
+ }
+ catch (Exception e)
+ {
+ AssertionFailedError afe = new AssertionFailedError();
+ afe.initCause(e);
+ throw afe;
+ }
+ }
+}
14 years, 11 months
gatein SVN: r1339 - in components/pc/trunk/federation/src: main/java/org/gatein/pc/federation/impl and 1 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2010-01-17 11:52:24 -0500 (Sun, 17 Jan 2010)
New Revision: 1339
Added:
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/NullInvokerHandler.java
Modified:
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/FederatingPortletInvoker.java
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java
components/pc/trunk/federation/src/test/java/org/gatein/pc/federation/FederatingPortletInvokerTestCase.java
Log:
- Added NullInvokerHandler concept to allow for easier resolution of federated invokers when the default mechanism fails to resolve. This is
in particularly useful for WSRP so that we can activate and register consumers that we know of but that haven't been made available to
a FederatingPortletInvoker. NullInvokerHandlers allows for the resolution behavior to be extended without requiring the base resolution
mechanism to be overriden.
Modified: components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/FederatingPortletInvoker.java
===================================================================
--- components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/FederatingPortletInvoker.java 2010-01-17 14:19:01 UTC (rev 1338)
+++ components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/FederatingPortletInvoker.java 2010-01-17 16:52:24 UTC (rev 1339)
@@ -1,25 +1,25 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, 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. *
- ******************************************************************************/
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, 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.gatein.pc.federation;
import org.gatein.pc.api.Portlet;
@@ -86,4 +86,12 @@
* @return a Set containing only the portlets from remote federated invokers.
*/
Set<Portlet> getRemotePortlets() throws PortletInvokerException;
+
+ /**
+ * Specifies which NullInvokerHandler to use to attempt retrieval of a federated invoker when default resolution
+ * mechanism cannot find an associated invoker.
+ *
+ * @param nullHandler
+ */
+ void setNullInvokerHandler(NullInvokerHandler nullHandler);
}
Added: components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/NullInvokerHandler.java
===================================================================
--- components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/NullInvokerHandler.java (rev 0)
+++ components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/NullInvokerHandler.java 2010-01-17 16:52:24 UTC (rev 1339)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, 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.gatein.pc.federation;
+
+import org.gatein.pc.api.NoSuchPortletException;
+
+/**
+ * Encapsulates behavior to resolve FederatedPortletInvokers in the context of a FederatingPortletInvoker when the
+ * default resolution mechanism fails to retrieve an associated FederatedPortletInvoker.
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public interface NullInvokerHandler
+{
+ NullInvokerHandler DEFAULT_HANDLER = new NullInvokerHandler()
+ {
+ public FederatedPortletInvoker resolvePortletInvokerFor(String compoundPortletId, String invokerId) throws NoSuchPortletException
+ {
+ throw new NoSuchPortletException(compoundPortletId);
+ }
+ };
+
+ FederatedPortletInvoker resolvePortletInvokerFor(String compoundPortletId, String invokerId) throws NoSuchPortletException;
+}
Modified: components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java
===================================================================
--- components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java 2010-01-17 14:19:01 UTC (rev 1338)
+++ components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java 2010-01-17 16:52:24 UTC (rev 1339)
@@ -37,6 +37,7 @@
import org.gatein.pc.api.state.PropertyMap;
import org.gatein.pc.federation.FederatedPortletInvoker;
import org.gatein.pc.federation.FederatingPortletInvoker;
+import org.gatein.pc.federation.NullInvokerHandler;
import java.util.Collection;
import java.util.Collections;
@@ -64,6 +65,8 @@
/** The registred FederatedPortletInvokers. */
private volatile Map<String, FederatedPortletInvoker> registry = new HashMap<String, FederatedPortletInvoker>();
+ private NullInvokerHandler nullHandler = NullInvokerHandler.DEFAULT_HANDLER;
+
public synchronized FederatedPortletInvoker registerInvoker(String federatedId, PortletInvoker federatedInvoker)
{
if (federatedId == null)
@@ -162,20 +165,20 @@
public Portlet getPortlet(PortletContext compoundPortletContext) throws IllegalArgumentException, PortletInvokerException
{
- FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
+ PortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
return federated.getPortlet(compoundPortletContext);
}
public PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
{
PortletContext compoundPortletContext = invocation.getTarget();
- FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
+ PortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
return federated.invoke(invocation);
}
public PortletContext createClone(PortletStateType stateType, PortletContext compoundPortletContext) throws PortletInvokerException
{
- FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
+ PortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
return federated.createClone(stateType, compoundPortletContext);
}
@@ -191,10 +194,10 @@
}
// Get the invoker and check that we address only one invoker (for now)
- FederatedPortletInvoker invoker = null;
+ PortletInvoker invoker = null;
for (PortletContext compoundPortletContext : portletContexts)
{
- FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
+ PortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
if (invoker == null)
{
invoker = federated;
@@ -211,22 +214,34 @@
public PropertyMap getProperties(PortletContext compoundPortletContext, Set<String> keys) throws PortletInvokerException
{
- FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
+ PortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
return federated.getProperties(compoundPortletContext, keys);
}
public PropertyMap getProperties(PortletContext compoundPortletContext) throws PortletInvokerException
{
- FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
+ PortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
return federated.getProperties(compoundPortletContext);
}
public PortletContext setProperties(PortletContext compoundPortletContext, PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
- FederatedPortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
+ PortletInvoker federated = getFederatedPortletInvokerFor(compoundPortletContext);
return federated.setProperties(compoundPortletContext, changes);
}
+ public synchronized void setNullInvokerHandler(NullInvokerHandler nullHandler)
+ {
+ if (nullHandler == null)
+ {
+ this.nullHandler = NullInvokerHandler.DEFAULT_HANDLER;
+ }
+ else
+ {
+ this.nullHandler = nullHandler;
+ }
+ }
+
// Support methods **************************************************************************************************
/**
@@ -259,7 +274,7 @@
FederatedPortletInvoker federated = registry.get(invokerId);
if (federated == null)
{
- throw new NoSuchPortletException(compoundPortletId);
+ return nullHandler.resolvePortletInvokerFor(compoundPortletId, invokerId);
}
//
Modified: components/pc/trunk/federation/src/test/java/org/gatein/pc/federation/FederatingPortletInvokerTestCase.java
===================================================================
--- components/pc/trunk/federation/src/test/java/org/gatein/pc/federation/FederatingPortletInvokerTestCase.java 2010-01-17 14:19:01 UTC (rev 1338)
+++ components/pc/trunk/federation/src/test/java/org/gatein/pc/federation/FederatingPortletInvokerTestCase.java 2010-01-17 16:52:24 UTC (rev 1339)
@@ -1,28 +1,29 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, 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. *
- ******************************************************************************/
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, 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.gatein.pc.federation;
import org.gatein.common.i18n.LocalizedString;
+import org.gatein.pc.api.NoSuchPortletException;
import org.gatein.pc.api.Portlet;
import org.gatein.pc.api.PortletContext;
import org.gatein.pc.api.PortletInvoker;
@@ -32,7 +33,6 @@
import org.gatein.pc.federation.impl.FederatingPortletInvokerService;
import org.gatein.pc.portlet.support.PortletInvokerSupport;
import org.gatein.pc.portlet.support.info.PortletInfoSupport;
-import static org.jboss.unit.api.Assert.*;
import org.jboss.unit.api.pojo.annotations.Create;
import org.jboss.unit.api.pojo.annotations.Destroy;
import org.jboss.unit.api.pojo.annotations.Test;
@@ -41,6 +41,8 @@
import java.util.Locale;
import java.util.Set;
+import static org.jboss.unit.api.Assert.*;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -188,4 +190,41 @@
assertNotNull(portlet);
assertEquals("foo.MyPortlet", portlet.getContext().getId());
}
+
+ @Test
+ public void testDelegatedResolution() throws PortletInvokerException
+ {
+ // create an invoker to check NullInvokerHandler behavior
+ final TestFederatedPortletInvoker remote = new TestFederatedPortletInvoker();
+ PortletInfoSupport remoteInfo = new PortletInfoSupport();
+ remoteInfo.getMeta().setDisplayName("RemotePortlet");
+ Portlet portlet = remote.addPortlet("RemotePortlet", remoteInfo);
+
+ // this invoker is not registered
+ assertNull(federatingInvoker.getFederatedInvoker("inexistent"));
+
+ federatingInvoker.setNullInvokerHandler(new NullInvokerHandler()
+ {
+ public FederatedPortletInvoker resolvePortletInvokerFor(String compoundPortletId, String invokerId) throws NoSuchPortletException
+ {
+ return remote;
+ }
+ });
+
+ assertEquals(portlet, federatingInvoker.getPortlet(PortletContext.createPortletContext("inexistent.RemotePortlet")));
+ }
+
+ private class TestFederatedPortletInvoker extends PortletInvokerSupport implements FederatedPortletInvoker
+ {
+
+ public String getId()
+ {
+ return "inexistent";
+ }
+
+ public PortletInvoker getPortletInvoker()
+ {
+ return null;
+ }
+ }
}
14 years, 11 months
gatein SVN: r1338 - in portal/trunk/webui/core/src: main/java/org/exoplatform/webui/application/replication/model/metadata and 3 other directories.
by do-not-reply@jboss.org
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();
+ }
+}
14 years, 11 months
gatein SVN: r1337 - portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal.
by do-not-reply@jboss.org
Author: thomas.heute(a)jboss.com
Date: 2010-01-17 04:50:01 -0500 (Sun, 17 Jan 2010)
New Revision: 1337
Removed:
portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/services_it.xml
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/expression_it.properties
Log:
GTNPORTAL-496: Translation in Italian
Duplicated files in .xml and .properties.
expression_it.properties was in XML
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/expression_it.properties
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/expression_it.properties 2010-01-17 00:17:36 UTC (rev 1336)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/expression_it.properties 2010-01-17 09:50:01 UTC (rev 1337)
@@ -1,191 +1,159 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
+#
+# 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.
+#
- 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.
-
--->
-
-<bundle>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'A' #
- ###################################################################
- -->
- <word>
- <accessPermission>Permesso di Accesso</accessPermission>
- <abort>Abbandona</abort>
- <action>Azione</action>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'B' #
- ###################################################################
- -->
- <back>Indietro</back>
- <birthday>Compleanno</birthday>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'c' #
- ###################################################################
- -->
- <cancel>Annulla</cancel>
- <category>Categoria</category>
- <change>Cambia</change>
- <city>Citt\u00E0</city>
- <close>Chiudi</close>
- <comment>Commento</comment>
- <content>Contenuto</content>
- <country>Nazione</country>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'd' #
- ###################################################################
- -->
- <date>Data</date>
- <decorator>Decoratore</decorator>
- <department>Dipartimento</department>
- <description>Descrizione</description>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'e' #
- ###################################################################
- -->
- <editPermission>Modifica il permesso</editPermission>
- <email>Email</email>
- <employer>Dipendente</employer>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'f' #
- ###################################################################
- -->
- <familyName>Cognome</familyName>
- <finish>Termina</finish>
- <firstName>Nome</firstName>
- <format>Formato</format>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'g' #
- ###################################################################
- -->
- <groupId>Id del Gruppo</groupId>
- <gender>Sesso</gender>
- <givenName>Nome</givenName>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'h' #
- ###################################################################
- -->
- <height>Altezza</height>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'i' #
- ###################################################################
- -->
- <icon>Icona</icon>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'j' #
- ###################################################################
- -->
- <jobTitle>Qualifica lavorativa</jobTitle>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'l' #
- ###################################################################
- -->
- <locale>Lingua</locale>
- <label>Etichetta</label>
- <language>Linguaggio</language>
- <lastName>Cognome</lastName>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'm' #
- ###################################################################
- -->
- <mobile>Mobile</mobile>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'n' #
- ###################################################################
- -->
- <name>Nome</name>
- <nickName>Nick Name</nickName>
- <next>Prossimo</next>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'o' #
- ###################################################################
- -->
- <owner>Proprietario</owner>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'p' #
- ###################################################################
- -->
- <postalCode>Codice Postale</postalCode>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'r' #
- ###################################################################
- -->
- <refresh>Aggiorna</refresh>
- <restore>Recupera</restore>
- <!--
- ###################################################################
- # EXPRESSION START WITH 's' #
- ###################################################################
- -->
- <save>Salva</save>
- <stateProv>=Stato/Prov</stateProv>
- <street>Strada</street>
- <style>Stile</style>
- <subject>Soggetto</subject>
- <summary>Intestazione</summary>
- <skin>Skin</skin>
- <!--
- ###################################################################
- # EXPRESSION START WITH 't' #
- ###################################################################
- -->
- <template>Template</template>
- <tel>Tel</tel>
- <title>Titolo</title>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'u' #
- ###################################################################
- -->
- <uri>Uri</uri>
- <userName>Nome Utente</userName>
- <update>Aggiorna</update>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'v' #
- ###################################################################
- -->
- <viewPermission>Visualizza il permesso</viewPermission>
- <!--
- ###################################################################
- # EXPRESSION START WITH 'w' #
- ###################################################################
- -->
- <width>Larghezza</width>
- <website>Sito Web</website>
- </word>
-
-</bundle>
-
+###################################################################
+# EXPRESSION START WITH 'A' #
+###################################################################
+word.accessPermission=Permesso di Accesso
+word.abort=Abbandona
+word.action=Azione
+###################################################################
+# EXPRESSION START WITH 'B' #
+###################################################################
+word.back=Indietro
+word.birthday=Compleanno
+
+###################################################################
+# EXPRESSION START WITH 'c' #
+###################################################################
+word.cancel=Annulla
+word.category=Categoria
+word.change=Cambia
+word.city=Citt\u00E0
+word.close=Chiudi
+word.comment=Commento
+word.content=Contenuto
+word.country=Nazione
+
+###################################################################
+# EXPRESSION START WITH 'd' #
+###################################################################
+word.date=Data
+word.decorator=Decorator
+word.department=Dipartimento
+word.description=Descrizione
+
+###################################################################
+# EXPRESSION START WITH 'e' #
+###################################################################
+word.editPermission=Modifica il permesso
+word.email=Email
+word.employer=Dipendente
+
+###################################################################
+# EXPRESSION START WITH 'f' #
+###################################################################
+word.familyName=Cognome
+word.finish=Termina
+word.firstName=Nome
+word.format=Formato
+
+###################################################################
+# EXPRESSION START WITH 'g' #
+###################################################################
+word.groupId=Id del Gruppo
+word.gender=Sesso
+word.givenName=Nome
+
+###################################################################
+# EXPRESSION START WITH 'h' #
+###################################################################
+word.height=Altezza
+
+###################################################################
+# EXPRESSION START WITH 'i' #
+###################################################################
+word.icon=Icona
+
+###################################################################
+# EXPRESSION START WITH 'i' #
+###################################################################
+word.jobTitle=Qualifica lavorativa
+
+###################################################################
+# EXPRESSION START WITH 'l' #
+###################################################################
+word.locale=Lingua
+word.label=Etichetta
+word.language=Linguaggio
+word.lastName=Cognome
+
+###################################################################
+# EXPRESSION START WITH 'm' #
+###################################################################
+word.mobile=Mobile
+
+###################################################################
+# EXPRESSION START WITH 'n' #
+###################################################################
+word.name=Nome
+word.nickName=Nick Name
+word.next=Prossimo
+
+###################################################################
+# EXPRESSION START WITH 'o' #
+###################################################################
+word.owner=Proprietario
+
+###################################################################
+# EXPRESSION START WITH 'p' #
+###################################################################
+word.postalCode=Codice Postale
+
+###################################################################
+# EXPRESSION START WITH 'r' #
+###################################################################
+word.refresh=Aggiorna
+word.restore=Recupera
+
+###################################################################
+# EXPRESSION START WITH 's' #
+###################################################################
+word.save=Salva
+word.stateProv=Stato/Prov
+word.street=Strada
+word.style=Stile
+word.subject=Soggetto
+word.summary=Intestazione
+word.skin=Skin
+
+###################################################################
+# EXPRESSION START WITH 't' #
+###################################################################
+word.template=Template
+word.tel=Tel
+word.title=Titolo
+
+###################################################################
+# EXPRESSION START WITH 'u' #
+###################################################################
+word.uri=Uri
+word.userName=Nome Utente
+word.update=Aggiorna
+
+###################################################################
+# EXPRESSION START WITH 'v' #
+###################################################################
+word.viewPermission=Visualizza il permesso
+
+###################################################################
+# EXPRESSION START WITH 'w' #
+###################################################################
+word.width=Larghezza
+word.website=Sito Web
Deleted: portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/services_it.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/services_it.xml 2010-01-17 00:17:36 UTC (rev 1336)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/services_it.xml 2010-01-17 09:50:01 UTC (rev 1337)
@@ -1,221 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-
-<bundle>
- <!--
- #############################################################################
- # Empty String Validator #
- #############################################################################
- #class org.exoplatform.webui.form.Validator.EmptyFieldValidator
- #{0}=input field name
- -->
- <EmptyStringValidator>
- <msg>
- <empty-input>Il campo "{0}" \u00E8 richiesto</empty-input>
- </msg>
- </EmptyStringValidator>
- <!--
- #############################################################################
- # Email Address Validator #
- #############################################################################
- #class org.exoplatform.webui.form.validator.Validator.EmailAddressValidator
- #{1}=input field name, {0} user input email address
- -->
- <EmailAddressValidator>
- <msg>
- <invalid-email>Hai inserito "{0}" nel campo {1}, non \u00E8 un valido</invalid-email>
- </msg>
- </EmailAddressValidator>
- <!--
- #############################################################################
- # Number Format Validator #
- #############################################################################
- #class org.exoplatform.webui.form.validator.Validator.NumberFormatValidator
- #{0}=input field name, {1} user input limit access
- -->
- <NumberFormatValidator>
- <msg>
- <invalid-limitAccess>Hai inserito "{0}" nel campo {1}, non \u00E8 un valido \ limite di accesso</invalid-limitAccess>
- <Invalid-input>Il valore inserito nel campo {0}, non \u00E8 nel formato numerico</Invalid-input>
- </msg>
- </NumberFormatValidator>
- <!--
- #{0}=input field name
- -->
- <!--
- #############################################################################
- # Identifier String Validator #
- #############################################################################
- #class org.exoplatform.webui.form.validator.Validator.IdentifierValidator
- #{0}=input field name
- -->
- <IdentifierValidator>
- <msg>
- <empty-input>Il campo "{0}" non pu\u00F2 essere vuoto</empty-input>
- <invalid-char>Sono permessi soltanto caratteri alfabetici, numerici e underscore per il campo {0}</invalid-char>
- </msg>
- </IdentifierValidator>
- <!--
- #{0}=input field name
- -->
- <!--
- #############################################################################
- # Name String Validator #
- #############################################################################
- #class org.exoplatform.webui.form.validator.Validator.NameValidator
- #{0}=input field name
- -->
- <NameValidator>
- <msg>
- <empty-input>Il campo "{0}" non pu\u00F2 essere vuotoy</empty-input>
- <invalid-char>Sono permessi soltanto caratteri alfabetici, numerici, punto, trattino e underscore per il campo {0}</invalid-char>
- </msg>
- </NameValidator>
- <!--
- #{0}=input field name
- -->
- <!--
- #############################################################################
- # Valid User Validator #
- #############################################################################
- #class org.exoplatform.faces.user.validator.ValidUserValidator
- #{0}=input field name, {1} input user name
- -->
- <ValidUserValidator>
- <msg>
- <empty-input>Inserisci un valore per il campo {0}</empty-input>
- <invalid-username>Il sistema non trova l'utente {0}</invalid-username>
- </msg>
- </ValidUserValidator>
- <!--
- #{0}=input field name, {1} input user name
- -->
- <!--
- #############################################################################
- # Valid User Validator #
- #############################################################################
- #class org.exoplatform.faces.user.validator.ValidGroupValidator
- #{0}=input field name, {1} input group id
- -->
- <ValidGroupValidator>
- <msg>
- <empty-input>Inserisci un valore nel campo {0}</empty-input>
- <invalid-group-id>Il sistema non trova il gruppo {0}</invalid-group-id>
- </msg>
- </ValidGroupValidator>
- <!--
- #{0}=input field name, {1} input group id
- -->
- <!--
- #############################################################################
- # Valid Permission Validator #
- #############################################################################
- -->
- <PermissionValidator>
- <msg>
- <invalid-permission-input>Permesso non valido, il formato del permesso deve essere del tipo: membership:/groupId.</invalid-permission-input>
- <membership-group-not-found>Membership o gruppo non trovati.</membership-group-not-found>
- </msg>
- </PermissionValidator>
- <!--
- #############################################################################
- # CheckAdminOrOwnerRoleInterceptor #
- #############################################################################
- #class org.exoplatform.faces.core.event.CheckAdminOrOwnerRoleInterceptor
- #{0}=action name
- -->
- <CheckAdminOrOwnerRoleInterceptor>
- <msg>
- <owner-or-admin-require>Devi essere loggato o avere il ruolo di admin per eseguire l'operazione '{0}'</owner-or-admin-require>
- </msg>
- </CheckAdminOrOwnerRoleInterceptor>
- <!--
- #############################################################################
- # CheckOwnerInterceptor #
- #############################################################################
- #class org.exoplatform.faces.core.event.CheckOwnerInterceptor
- #{0}=action name
- -->
- <CheckOwnerInterceptor>
- <msg>
- <owner-require>Devi essere loggato per eseguire l'operazione '{0}'</owner-require>
- </msg>
- </CheckOwnerInterceptor>
- <!--
- #############################################################################
- # ExoPermissionException #
- #############################################################################
- #class org.exoplatform.commons.exception.ExoPermissionException
- #{0}=require role, {1} action name
- -->
- <ExoPermissionException>
- <msg>
- <message>Devi avere il ruolo {0} per eseguire l'operazione {1}</message>
- </msg>
- </ExoPermissionException>
- <!--
- #############################################################################
- # Message Service properties #
- #############################################################################
- #this exception is throw in GroupQueryHandler class
- -->
- <OrganizationService>
- <unique-group-exception>Il nome del gruppo {0} esiste gi\u00E0</unique-group-exception>
- </OrganizationService>
- <!--
- #Throw in org.exoplatform.commons.utils.PageList, {0}=request page parameter, {1}=available pages parameter
- -->
- <PageList>
- <page-out-of-range>Hai provato a ottenere la pagina {0}, ma ci sono soltanto {1} pagine disponibili</page-out-of-range>
- </PageList>
- <!--
- #Throw in exo.services.communication.message.impl.MessageServiceImpl.
- #{0}=account name, {1}=user name
- -->
- <MessageService>
- <account-not-found>Non posso trovare l'account {0} per l'utente {1}</account-not-found>
- <invalid-standalone-message-address>Stai usando l'account standalone con \ l'indirizzo {0} is not valid. non \u00E8 valido. Il sistema si aspetta un indirizzo con il seguente formato: \ ricevente#nomeAccount</invalid-standalone-message-address>
- <send-message-fail>Non posso mandare il messaggio. Verifica l'indirizzo email \n\ Errore: {0}</send-message-fail>
- </MessageService>
- <!--
- #Throw in exo.services.communication.message.impl.StandaloneProtocolPlugin.
- #{0}=to address
- -->
- <!--
- #Throw in exo.services.communication.message.impl.MailServiceImpl
- #{0}=The orginal error message throw by java mail library
- -->
- <!--
- #############################################################################
- # Forum Service properties #
- #############################################################################
- #Throw in org.exoplatform.services.communication.forum.impl.ForumServiceImpl
- #Throw in org.exoplatform.services.indexing.Searcher
- #{0}=The orginal error message throw by lucence
- -->
- <Searcher>
- <msg>
- <search-expression-error><![CDATA[C'\u00E8 un errore nell'espressione inserita.<br />{0}]]></search-expression-error>
- </msg>
- </Searcher>
-</bundle>
-
14 years, 11 months
gatein SVN: r1336 - in portal/trunk/webui/core/src: main/java/org/exoplatform/webui/application/replication/serial and 1 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-01-16 19:17:36 -0500 (Sat, 16 Jan 2010)
New Revision: 1336
Added:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/SerializationMode.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/B1.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/B2.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/B3.java
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ClassTypeModel.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/DataKind.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
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/TestConverter.java
Log:
implement converter type that converts to java.io.Serializable
Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ClassTypeModel.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ClassTypeModel.java 2010-01-16 23:15:12 UTC (rev 1335)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ClassTypeModel.java 2010-01-17 00:17:36 UTC (rev 1336)
@@ -40,9 +40,9 @@
private final Map<String, FieldModel<O, ?>> immutableFields;
/** . */
- private final boolean serialized;
+ private final SerializationMode serializationMode;
- ClassTypeModel(Class<O> type, ClassTypeModel<? super O> superType, Map<String, FieldModel<O, ?>> fields, boolean serialized)
+ ClassTypeModel(Class<O> type, ClassTypeModel<? super O> superType, Map<String, FieldModel<O, ?>> fields, SerializationMode serializationMode)
{
super(type, superType);
@@ -50,7 +50,7 @@
this.superType = superType;
this.fields = fields;
this.immutableFields = Collections.unmodifiableMap(fields);
- this.serialized = serialized;
+ this.serializationMode = serializationMode;
}
@Override
@@ -59,9 +59,9 @@
return superType;
}
- public boolean isSerialized()
+ public SerializationMode getSerializationMode()
{
- return serialized;
+ return serializationMode;
}
public Collection<FieldModel<O, ?>> getFields()
Added: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/SerializationMode.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/SerializationMode.java (rev 0)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/SerializationMode.java 2010-01-17 00:17:36 UTC (rev 1336)
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public enum SerializationMode
+{
+
+ SERIALIZED,
+
+ SERIALIZABLE,
+
+ NONE
+
+
+}
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-16 23:15:12 UTC (rev 1335)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeDomain.java 2010-01-17 00:17:36 UTC (rev 1336)
@@ -23,6 +23,7 @@
import org.exoplatform.webui.application.replication.api.annotations.Converted;
import org.exoplatform.webui.application.replication.api.annotations.Serialized;
+import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
@@ -263,9 +264,24 @@
TreeMap<String, FieldModel<O, ?>> fieldModels = new TreeMap<String, FieldModel<O, ?>>();
//
- ClassTypeModel<O> typeModel = new ClassTypeModel<O>(javaType, superTypeModel, fieldModels, serialized);
+ SerializationMode serializationMode;
+ if (serialized)
+ {
+ serializationMode = SerializationMode.SERIALIZED;
+ }
+ else if (Serializable.class.isAssignableFrom(javaType))
+ {
+ serializationMode = SerializationMode.SERIALIZABLE;
+ }
+ else
+ {
+ serializationMode = SerializationMode.NONE;
+ }
//
+ ClassTypeModel<O> typeModel = new ClassTypeModel<O>(javaType, superTypeModel, fieldModels, serializationMode);
+
+ //
addedTypeModels.put(javaType.getName(), typeModel);
// Now build fields
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-16 23:15:12 UTC (rev 1335)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/DataKind.java 2010-01-17 00:17:36 UTC (rev 1336)
@@ -30,5 +30,6 @@
public static final int NULL_VALUE = 1;
public static final int OBJECT_REF = 2;
public static final int CONVERTED_OBJECT = 3;
+ public static final int SERIALIZED_OBJECT = 4;
}
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-16 23:15:12 UTC (rev 1335)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectReader.java 2010-01-17 00:17:36 UTC (rev 1336)
@@ -109,7 +109,6 @@
Object o = container.readObject();
state.put(fieldModel, o);
break;
-
}
}
}
@@ -207,6 +206,8 @@
ConvertedTypeModel<?, ?> ctm = (ConvertedTypeModel<?,?>) context.getTypeDomain().getTypeModel(tclazz);
return convertObject(container, ctm);
}
+ case DataKind.SERIALIZED_OBJECT:
+ return container.readObject();
default:
throw new StreamCorruptedException("Unrecognized data " + sw);
}
@@ -228,14 +229,14 @@
}
//
- O o;
+ O o = null;
try
{
o = converter.read(t);
}
catch (Exception e)
{
- InvalidObjectException ioe = new InvalidObjectException("The object " + t + " conversion throw an exception ");
+ InvalidObjectException ioe = new InvalidObjectException("The object " + t + " conversion throw an exception " + converter);
ioe.initCause(e);
throw ioe;
}
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-16 23:15:12 UTC (rev 1335)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectWriter.java 2010-01-17 00:17:36 UTC (rev 1336)
@@ -21,10 +21,7 @@
import org.exoplatform.webui.application.replication.SerializationContext;
import org.exoplatform.webui.application.replication.api.TypeConverter;
-import org.exoplatform.webui.application.replication.model.ClassTypeModel;
-import org.exoplatform.webui.application.replication.model.ConvertedTypeModel;
-import org.exoplatform.webui.application.replication.model.FieldModel;
-import org.exoplatform.webui.application.replication.model.TypeModel;
+import org.exoplatform.webui.application.replication.model.*;
import java.io.*;
import java.util.IdentityHashMap;
@@ -125,79 +122,86 @@
private <O> void write(ClassTypeModel<O> typeModel, O obj, DataContainer output) throws IOException
{
- if (!typeModel.isSerialized())
+ if (typeModel.getSerializationMode() == SerializationMode.SERIALIZED)
{
- throw new NotSerializableException("Type " + typeModel + " cannot be serialized");
- }
+ //
+ output.writeInt(DataKind.OBJECT);
+ output.writeInt(register(obj));
+ output.writeObject(typeModel.getJavaType());
- //
- output.writeInt(DataKind.OBJECT);
- output.writeInt(register(obj));
- output.writeObject(typeModel.getJavaType());
-
- //
- SerializationStatus status = SerializationStatus.NONE;
- for (ClassTypeModel<? super O> currentTypeModel = typeModel;currentTypeModel != null;currentTypeModel = currentTypeModel.getSuperType())
- {
- if (currentTypeModel instanceof ClassTypeModel<?>)
+ //
+ SerializationStatus status = SerializationStatus.NONE;
+ for (ClassTypeModel<? super O> currentTypeModel = typeModel;currentTypeModel != null;currentTypeModel = currentTypeModel.getSuperType())
{
- for (FieldModel<?, ?> fieldModel : currentTypeModel.getFields())
+ if (currentTypeModel instanceof ClassTypeModel<?>)
{
- if (!fieldModel.isTransient())
+ for (FieldModel<?, ?> fieldModel : currentTypeModel.getFields())
{
- Object fieldValue = fieldModel.get(obj);
- if (fieldValue == null)
+ if (!fieldModel.isTransient())
{
- output.writeObject(DataKind.NULL_VALUE);
- }
- else
- {
- Integer fieldValueId = objectToId.get(fieldValue);
- if (fieldValueId != null)
+ Object fieldValue = fieldModel.get(obj);
+ if (fieldValue == null)
{
- output.writeObject(DataKind.OBJECT_REF);
- output.writeInt(fieldValueId);
+ output.writeObject(DataKind.NULL_VALUE);
}
else
{
- output.writeObject(DataKind.OBJECT);
- output.writeObject(fieldValue);
+ Integer fieldValueId = objectToId.get(fieldValue);
+ if (fieldValueId != null)
+ {
+ output.writeObject(DataKind.OBJECT_REF);
+ output.writeInt(fieldValueId);
+ }
+ else
+ {
+ output.writeObject(DataKind.OBJECT);
+ output.writeObject(fieldValue);
+ }
}
}
}
- }
- switch (status)
- {
- case NONE:
- status = SerializationStatus.FULL;
- break;
- }
- }
- else
- {
- if (!currentTypeModel.getFields().isEmpty())
- {
switch (status)
{
- case FULL:
- status = SerializationStatus.PARTIAL;
+ case NONE:
+ status = SerializationStatus.FULL;
break;
}
}
+ else
+ {
+ if (!currentTypeModel.getFields().isEmpty())
+ {
+ switch (status)
+ {
+ case FULL:
+ status = SerializationStatus.PARTIAL;
+ break;
+ }
+ }
+ }
}
+
+ //
+ switch (status)
+ {
+ case FULL:
+ break;
+ case PARTIAL:
+ System.out.println("Partial serialization of object " + obj);
+ break;
+ case NONE:
+ throw new NotSerializableException("Type " + typeModel + " is not serializable");
+ }
}
-
- //
- switch (status)
+ else if (typeModel.getSerializationMode() == SerializationMode.SERIALIZABLE)
{
- case FULL:
- break;
- case PARTIAL:
- System.out.println("Partial serialization of object " + obj);
- break;
- case NONE:
- throw new NotSerializableException("Type " + typeModel + " is not serializable");
+ output.writeInt(DataKind.SERIALIZED_OBJECT);
+ output.writeObject(obj);
}
+ else
+ {
+ throw new NotSerializableException("Type " + typeModel + " is not serializable");
+ }
}
@Override
Added: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/B1.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/B1.java (rev 0)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/B1.java 2010-01-17 00:17:36 UTC (rev 1336)
@@ -0,0 +1,42 @@
+/*
+ * 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.converter;
+
+import org.exoplatform.webui.application.replication.api.annotations.Converted;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+(a)Converted(B3.class)
+public class B1
+{
+
+ String state;
+
+ public B1()
+ {
+ }
+
+ public B1(String state)
+ {
+ this.state = state;
+ }
+}
Added: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/B2.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/B2.java (rev 0)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/B2.java 2010-01-17 00:17:36 UTC (rev 1336)
@@ -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.converter;
+
+import org.exoplatform.webui.application.replication.api.annotations.Serialized;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class B2 implements Serializable
+{
+
+ String state;
+
+ public B2()
+ {
+ }
+
+ public B2(String state)
+ {
+ this.state = state;
+ }
+}
\ No newline at end of file
Added: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/B3.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/B3.java (rev 0)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/B3.java 2010-01-17 00:17:36 UTC (rev 1336)
@@ -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.converter;
+
+import junit.framework.AssertionFailedError;
+import org.exoplatform.webui.application.replication.api.TypeConverter;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class B3 extends TypeConverter<B1, B2>
+{
+
+ @Override
+ public B2 write(B1 input) throws Exception
+ {
+ return new B2(input.state);
+ }
+
+ @Override
+ public B1 read(B2 output) throws Exception
+ {
+ return new B1(output.state);
+ }
+}
\ No newline at end of file
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/TestConverter.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/TestConverter.java 2010-01-16 23:15:12 UTC (rev 1335)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/TestConverter.java 2010-01-17 00:17:36 UTC (rev 1336)
@@ -35,7 +35,7 @@
public class TestConverter extends TestCase
{
- public void testConvert() throws Exception
+ public void testConvertSerializedType() throws Exception
{
TypeDomain domain = new TypeDomain();
domain.add(A1.class);
@@ -60,6 +60,18 @@
assertEquals("foo", a.state);
}
+ public void testConvertSerializableType() throws Exception
+ {
+ TypeDomain domain = new TypeDomain();
+ domain.add(B1.class);
+ B1 b = new B1("foo");
+
+ //
+ SerializationContext context = new SerializationContext(domain);
+ b = context.clone(b);
+ assertEquals("foo", b.state);
+ }
+
public void testConverterWriteThrowsException() throws Exception
{
TypeDomain domain = new TypeDomain();
14 years, 11 months
gatein SVN: r1335 - in portal/trunk/webui/core/src: main/java/org/exoplatform/webui/application/replication/model and 3 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-01-16 18:15:12 -0500 (Sat, 16 Jan 2010)
New Revision: 1335
Added:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ConvertedTypeModel.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/A1.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/A2.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/A3.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/TestConverter.java
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/model/ClassTypeModel.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/model/TypeModel.java
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/ObjectReader.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectWriter.java
Log:
implement and test type converter
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-16 14:24:10 UTC (rev 1334)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/Converted.java 2010-01-16 23:15:12 UTC (rev 1335)
@@ -22,11 +22,25 @@
import org.exoplatform.webui.application.replication.api.TypeConverter;
import org.exoplatform.webui.application.replication.impl.api.DefaultTypeConverter;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
/**
+ * Annotates a type to be converted to another type for serialization.
+ *
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
+(a)Target(ElementType.TYPE)
+(a)Retention(RetentionPolicy.RUNTIME)
public @interface Converted
{
+ /**
+ * Specify the converter class.
+ *
+ * @return the converter class
+ */
Class<? extends TypeConverter<?, ?>> value();
}
Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ClassTypeModel.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ClassTypeModel.java 2010-01-16 14:24:10 UTC (rev 1334)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ClassTypeModel.java 2010-01-16 23:15:12 UTC (rev 1335)
@@ -44,7 +44,7 @@
ClassTypeModel(Class<O> type, ClassTypeModel<? super O> superType, Map<String, FieldModel<O, ?>> fields, boolean serialized)
{
- super(type, superType, fields);
+ super(type, superType);
//
this.superType = superType;
Added: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ConvertedTypeModel.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ConvertedTypeModel.java (rev 0)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ConvertedTypeModel.java 2010-01-16 23:15:12 UTC (rev 1335)
@@ -0,0 +1,59 @@
+/*
+ * 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;
+
+import org.exoplatform.webui.application.replication.api.TypeConverter;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ConvertedTypeModel<O, T> extends TypeModel<O>
+{
+
+ /** . */
+ private final TypeModel<T> targetType;
+
+ /** . */
+ private final Class<? extends TypeConverter<O, T>> converterJavaType;
+
+ ConvertedTypeModel(
+ Class<O> javaType,
+ TypeModel<? super O> superType,
+ TypeModel<T> targetType,
+ Class<? extends TypeConverter<O, T>> converterJavaType)
+ {
+ super(javaType, superType);
+
+ //
+ this.targetType = targetType;
+ this.converterJavaType = converterJavaType;
+ }
+
+ public TypeModel<T> getTargetType()
+ {
+ return targetType;
+ }
+
+ public Class<? extends TypeConverter<O, T>> getConverterJavaType()
+ {
+ return converterJavaType;
+ }
+}
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-16 14:24:10 UTC (rev 1334)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeDomain.java 2010-01-16 23:15:12 UTC (rev 1335)
@@ -19,10 +19,13 @@
package org.exoplatform.webui.application.replication.model;
+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 java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@@ -49,13 +52,13 @@
}
/** . */
- private final Map<String, TypeModel> typeModelMap;
+ private final Map<String, TypeModel<?>> typeModelMap;
/** . */
- private final Map<String, TypeModel> immutableTypeModelMap;
+ private final Map<String, TypeModel<?>> immutableTypeModelMap;
/** . */
- private final Collection<TypeModel> immutableTypeModelSet;
+ private final Collection<TypeModel<?>> immutableTypeModelSet;
/** . */
private final boolean buildIfAbsent;
@@ -67,9 +70,9 @@
public TypeDomain(boolean buildIfAbsent)
{
- ConcurrentHashMap<String, TypeModel> typeModelMap = new ConcurrentHashMap<String, TypeModel>();
- Map<String, TypeModel> immutableTypeModelMap = Collections.unmodifiableMap(typeModelMap);
- Collection<TypeModel> immutableTypeModelSet = Collections.unmodifiableCollection(typeModelMap.values());
+ ConcurrentHashMap<String, TypeModel<?>> typeModelMap = new ConcurrentHashMap<String, TypeModel<?>>();
+ Map<String, TypeModel<?>> immutableTypeModelMap = Collections.unmodifiableMap(typeModelMap);
+ Collection<TypeModel<?>> immutableTypeModelSet = Collections.unmodifiableCollection(typeModelMap.values());
//
this.typeModelMap = typeModelMap;
@@ -78,7 +81,7 @@
this.buildIfAbsent = buildIfAbsent;
}
- public Map<String, TypeModel> getTypeModelMap()
+ public Map<String, TypeModel<?>> getTypeModelMap()
{
return immutableTypeModelMap;
}
@@ -88,12 +91,12 @@
return buildIfAbsent;
}
- public Collection<TypeModel> getTypeModels()
+ public Collection<TypeModel<?>> getTypeModels()
{
return immutableTypeModelSet;
}
- public TypeModel getTypeModel(String typeName)
+ public TypeModel<?> getTypeModel(String typeName)
{
if (typeName == null)
{
@@ -102,15 +105,15 @@
return typeModelMap.get(typeName);
}
- public TypeModel getTypeModel(Class<?> javaType)
+ public <O> TypeModel<O> getTypeModel(Class<O> javaType)
{
if (javaType == null)
{
throw new NullPointerException();
}
- //
- TypeModel typeModel = typeModelMap.get(javaType.getName());
+ // Cast OK
+ TypeModel<O> typeModel = (TypeModel<O>)typeModelMap.get(javaType.getName());
//
if (typeModel == null && buildIfAbsent)
@@ -133,6 +136,8 @@
// Build the missing types required to have knowledge about the
// provided java type
Map<String, TypeModel<?>> addedTypeModels = new HashMap<String, TypeModel<?>>();
+
+ //
TypeModel<O> model = build(javaType, addedTypeModels);
// Perform merge
@@ -157,58 +162,131 @@
throw new IllegalArgumentException("No primitive type accepted");
}
- // Cast OK
- TypeModel<O> typeModel = (TypeModel<O>)get(javaType, addedTypeModels);
+ //
+ TypeModel<O> typeModel = get(javaType, addedTypeModels);
//
if (typeModel == null)
{
- boolean replicated = javaType.getAnnotation(Serialized.class) != null;
+ boolean serialized = javaType.getAnnotation(Serialized.class) != null;
+ boolean converted = javaType.getAnnotation(Converted.class) != null;
//
- ClassTypeModel<? super O> superTypeModel = null;
- if (javaType.getSuperclass() != null)
+ if (serialized)
{
- TypeModel<? super O> builtType = build(javaType.getSuperclass(), addedTypeModels);
- if (builtType instanceof ClassTypeModel)
+ if (converted)
{
- superTypeModel = (ClassTypeModel<? super O>)builtType;
- }
- else
- {
throw new TypeException();
}
+ typeModel = buildClassType(javaType, addedTypeModels, true);
}
+ else if (converted)
+ {
+ typeModel = buildConvertedType(javaType, addedTypeModels);
+ }
+ else
+ {
+ typeModel = buildClassType(javaType, addedTypeModels, false);
+ }
+ }
- //
- TreeMap<String, FieldModel<O, ?>> fieldModels = new TreeMap<String, FieldModel<O, ?>>();
+ //
+ return typeModel;
+ }
- //
- typeModel = new ClassTypeModel<O>(javaType, superTypeModel, fieldModels, replicated);
+ private <O> ConvertedTypeModel<O, ?> buildConvertedType(Class<O> javaType, Map<String, TypeModel<?>> addedTypeModels)
+ {
+ Converted converted = javaType.getAnnotation(Converted.class);
- //
- addedTypeModels.put(javaType.getName(), typeModel);
+ //
+ Class<? extends TypeConverter<?, ?>> converterClass = converted.value();
+ ParameterizedType converterParameterizedType = (ParameterizedType)converterClass.getGenericSuperclass();
- // Now build fields
- for (Field field : javaType.getDeclaredFields())
+ //
+ if (!converterParameterizedType.getActualTypeArguments()[0].equals(javaType))
+ {
+ throw new TypeException();
+ }
+
+ //
+ Class<? extends TypeConverter<O, ?>> converterJavaType = (Class<TypeConverter<O, ?>>)converted.value();
+
+ //
+ return buildConvertedType(javaType, addedTypeModels, converterJavaType);
+ }
+
+ private <O, T> ConvertedTypeModel<O, T> buildConvertedType(
+ Class<O> javaType,
+ Map<String, TypeModel<?>> addedTypeModels,
+ Class<? extends TypeConverter<O, ? /* This is a bit funky and nasty, need to investigate*/ >> converterJavaType)
+ {
+ Class<T> outputClass = (Class<T>)((ParameterizedType)converterJavaType.getGenericSuperclass()).getActualTypeArguments()[1];
+
+ //
+ ClassTypeModel<T> targetType = (ClassTypeModel<T>)build(outputClass, addedTypeModels);
+
+ //
+ TypeModel<? super O> superType = null;
+ Class<? super O> superJavaType = javaType.getSuperclass();
+ if (superJavaType != null)
+ {
+ superType = build(superJavaType, addedTypeModels);
+ }
+
+ //
+ ConvertedTypeModel<O, T> typeModel = new ConvertedTypeModel<O, T>(javaType, superType, targetType, (Class<TypeConverter<O, T>>) converterJavaType);
+
+ //
+ addedTypeModels.put(typeModel.getName(), typeModel);
+
+ //
+ return typeModel;
+ }
+
+ private <O> ClassTypeModel<O> buildClassType(Class<O> javaType, Map<String, TypeModel<?>> addedTypeModels, boolean serialized)
+ {
+ ClassTypeModel<? super O> superTypeModel = null;
+ if (javaType.getSuperclass() != null)
+ {
+ TypeModel<? super O> builtType = build(javaType.getSuperclass(), addedTypeModels);
+ if (builtType instanceof ClassTypeModel)
{
- if (!Modifier.isStatic(field.getModifiers()))
- {
- field.setAccessible(true);
- Class<?> fieldJavaType = field.getType();
+ superTypeModel = (ClassTypeModel<? super O>)builtType;
+ }
+ else
+ {
+ throw new TypeException();
+ }
+ }
- // Replace if a primitive
- if (fieldJavaType.isPrimitive())
- {
- fieldJavaType = primitiveToWrapperMap.get(fieldJavaType);
- }
+ //
+ TreeMap<String, FieldModel<O, ?>> fieldModels = new TreeMap<String, FieldModel<O, ?>>();
- TypeModel<?> fieldTypeModel = build(fieldJavaType, addedTypeModels);
- if (fieldTypeModel != null)
- {
- fieldModels.put(field.getName(), createField(typeModel, field, fieldTypeModel));
- }
+ //
+ ClassTypeModel<O> typeModel = new ClassTypeModel<O>(javaType, superTypeModel, fieldModels, serialized);
+
+ //
+ addedTypeModels.put(javaType.getName(), typeModel);
+
+ // Now build fields
+ for (Field field : javaType.getDeclaredFields())
+ {
+ if (!Modifier.isStatic(field.getModifiers()))
+ {
+ field.setAccessible(true);
+ Class<?> fieldJavaType = field.getType();
+
+ // Replace if a primitive
+ if (fieldJavaType.isPrimitive())
+ {
+ fieldJavaType = primitiveToWrapperMap.get(fieldJavaType);
}
+
+ TypeModel<?> fieldTypeModel = build(fieldJavaType, addedTypeModels);
+ if (fieldTypeModel != null)
+ {
+ fieldModels.put(field.getName(), createField(typeModel, field, fieldTypeModel));
+ }
}
}
Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeModel.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeModel.java 2010-01-16 14:24:10 UTC (rev 1334)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeModel.java 2010-01-16 23:15:12 UTC (rev 1335)
@@ -19,10 +19,6 @@
package org.exoplatform.webui.application.replication.model;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
@@ -36,7 +32,7 @@
/** . */
private final TypeModel<? super O> superType;
- TypeModel(Class<O> javaType, TypeModel<? super O> superType, Map<String, FieldModel<O, ?>> fields)
+ TypeModel(Class<O> javaType, TypeModel<? super O> superType)
{
this.javaType = javaType;
this.superType = superType;
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-16 14:24:10 UTC (rev 1334)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/DataKind.java 2010-01-16 23:15:12 UTC (rev 1335)
@@ -29,6 +29,6 @@
public static final int OBJECT = 0;
public static final int NULL_VALUE = 1;
public static final int OBJECT_REF = 2;
- public static final int SERIALIZABLE_OBJECT = 3;
+ public static final int CONVERTED_OBJECT = 3;
}
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-16 14:24:10 UTC (rev 1334)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectReader.java 2010-01-16 23:15:12 UTC (rev 1335)
@@ -20,8 +20,10 @@
package org.exoplatform.webui.application.replication.serial;
import org.exoplatform.webui.application.replication.SerializationContext;
+import org.exoplatform.webui.application.replication.api.TypeConverter;
import org.exoplatform.webui.application.replication.api.factory.ObjectFactory;
import org.exoplatform.webui.application.replication.model.ClassTypeModel;
+import org.exoplatform.webui.application.replication.model.ConvertedTypeModel;
import org.exoplatform.webui.application.replication.model.FieldModel;
import java.io.*;
@@ -177,33 +179,81 @@
}
}
+ private Object read(DataContainer container) throws IOException
+ {
+ int sw = container.readInt();
+ switch (sw)
+ {
+ case DataKind.OBJECT_REF:
+ {
+ int id = container.readInt();
+ Object o1 = idToObject.get(id);
+ if (o1 == null)
+ {
+ throw new AssertionError();
+ }
+ return o1;
+ }
+ case DataKind.OBJECT:
+ {
+ int id = container.readInt();
+ Class<?> clazz = (Class)container.readObject();
+ ClassTypeModel<?> typeModel = (ClassTypeModel<?>)context.getTypeDomain().getTypeModel(clazz);
+ return instantiate(id, container, typeModel);
+ }
+ case DataKind.CONVERTED_OBJECT:
+ {
+ Class<?> tclazz = (Class<?>)container.readObject();
+ ConvertedTypeModel<?, ?> ctm = (ConvertedTypeModel<?,?>) context.getTypeDomain().getTypeModel(tclazz);
+ return convertObject(container, ctm);
+ }
+ default:
+ throw new StreamCorruptedException("Unrecognized data " + sw);
+ }
+ }
+
+ private <O, T> O convertObject(DataContainer container, ConvertedTypeModel<O, T> convertedType) throws IOException
+ {
+ Object inner = resolveObject(container);
+ T t = convertedType.getTargetType().getJavaType().cast(inner);
+
+ TypeConverter<O, T> converter;
+ try
+ {
+ converter = convertedType.getConverterJavaType().newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new AssertionError(e);
+ }
+
+ //
+ O o;
+ try
+ {
+ o = converter.read(t);
+ }
+ catch (Exception e)
+ {
+ InvalidObjectException ioe = new InvalidObjectException("The object " + t + " conversion throw an exception ");
+ ioe.initCause(e);
+ throw ioe;
+ }
+ if (o == null)
+ {
+ throw new InvalidObjectException("The object " + t + " was converted to null by converter " + converter);
+ }
+
+ //
+ return o;
+ }
+
@Override
protected Object resolveObject(Object obj) throws IOException
{
if (obj instanceof DataContainer)
{
- DataContainer container = (DataContainer) obj;
-
- int id;
- int sw = container.readInt();
- switch (sw)
- {
- case DataKind.OBJECT_REF:
- id = container.readInt();
- Object o1 = idToObject.get(id);
- if (o1 == null)
- {
- throw new AssertionError();
- }
- return o1;
- case DataKind.OBJECT:
- id = container.readInt();
- Class<?> clazz = (Class) container.readObject();
- ClassTypeModel<?> typeModel = (ClassTypeModel<?>)context.getTypeDomain().getTypeModel(clazz);
- return instantiate(id, container, typeModel);
- default:
- throw new StreamCorruptedException("Unrecognized data " + sw);
- }
+ return read((DataContainer)obj);
}
else
{
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-16 14:24:10 UTC (rev 1334)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectWriter.java 2010-01-16 23:15:12 UTC (rev 1335)
@@ -20,8 +20,11 @@
package org.exoplatform.webui.application.replication.serial;
import org.exoplatform.webui.application.replication.SerializationContext;
+import org.exoplatform.webui.application.replication.api.TypeConverter;
import org.exoplatform.webui.application.replication.model.ClassTypeModel;
+import org.exoplatform.webui.application.replication.model.ConvertedTypeModel;
import org.exoplatform.webui.application.replication.model.FieldModel;
+import org.exoplatform.webui.application.replication.model.TypeModel;
import java.io.*;
import java.util.IdentityHashMap;
@@ -58,8 +61,70 @@
return nextId;
}
- private <O> void write(DataContainer output, ClassTypeModel<O> typeModel, O obj) throws IOException
+ private void write(Object obj, DataContainer output) throws IOException
{
+ Class objClass = obj.getClass();
+ TypeModel typeModel = context.getTypeDomain().getTypeModel(objClass);
+
+ //
+ if (typeModel == null)
+ {
+ throw new NotSerializableException("Object " + obj + " does not have its type described");
+ }
+
+ //
+ if (typeModel instanceof ClassTypeModel)
+ {
+ // This is obviously unchecked because of the fact that Object.getClass() returns Class<?>
+ // need to find a work around for that
+ write((ClassTypeModel)typeModel, obj, output);
+ }
+ else
+ {
+ write((ConvertedTypeModel)typeModel, obj, output);
+ }
+ }
+
+ private <O, T> void write(ConvertedTypeModel<O, T> typeModel, O obj, DataContainer output) throws IOException
+ {
+ Class<? extends TypeConverter<O, T>> converterClass = typeModel.getConverterJavaType();
+
+ //
+ TypeConverter<O, T> converter;
+ try
+ {
+ converter = converterClass.newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new AssertionError(e);
+ }
+
+ //
+ T target;
+ try
+ {
+ target = converter.write(obj);
+ }
+ catch (Exception e)
+ {
+ InvalidObjectException ioe = new InvalidObjectException("The object " + obj + " conversion threw an exception ");
+ ioe.initCause(e);
+ throw ioe;
+ }
+ if (target == null)
+ {
+ throw new InvalidObjectException("The object " + obj + " was converted to null by converter " + converter);
+ }
+
+ //
+ output.writeInt(DataKind.CONVERTED_OBJECT);
+ output.writeObject(typeModel.getJavaType());
+ write(target, output);
+ }
+
+ private <O> void write(ClassTypeModel<O> typeModel, O obj, DataContainer output) throws IOException
+ {
if (!typeModel.isSerialized())
{
throw new NotSerializableException("Type " + typeModel + " cannot be serialized");
@@ -154,23 +219,13 @@
Integer id = objectToId.get(obj);
if (id != null)
{
+ output = new DataContainer();
output.writeInt(DataKind.OBJECT_REF);
output.writeObject(id);
}
else
{
- Class objClass = obj.getClass();
- ClassTypeModel typeModel = (ClassTypeModel)context.getTypeDomain().getTypeModel(objClass);
-
- //
- if (typeModel == null)
- {
- throw new NotSerializableException("Object " + obj + " does not have its type described");
- }
-
- // This is obviously unchecked because of the fact that Object.getClass() returns Class<?>
- // need to find a work around for that
- write(output, typeModel, obj);
+ write(obj, output);
}
//
Added: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/A1.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/A1.java (rev 0)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/A1.java 2010-01-16 23:15:12 UTC (rev 1335)
@@ -0,0 +1,42 @@
+/*
+ * 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.converter;
+
+import org.exoplatform.webui.application.replication.api.annotations.Converted;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+(a)Converted(A3.class)
+public class A1
+{
+
+ String state;
+
+ public A1()
+ {
+ }
+
+ public A1(String state)
+ {
+ this.state = state;
+ }
+}
Added: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/A2.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/A2.java (rev 0)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/A2.java 2010-01-16 23:15:12 UTC (rev 1335)
@@ -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.converter;
+
+import org.exoplatform.webui.application.replication.api.annotations.Serialized;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+@Serialized
+public class A2
+{
+
+ String state;
+
+ public A2()
+ {
+ }
+
+ public A2(String state)
+ {
+
+ this.state = state;
+ }
+}
Added: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/A3.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/A3.java (rev 0)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/A3.java 2010-01-16 23:15:12 UTC (rev 1335)
@@ -0,0 +1,54 @@
+/*
+ * 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.converter;
+
+import junit.framework.AssertionFailedError;
+import org.exoplatform.webui.application.replication.api.TypeConverter;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class A3 extends TypeConverter<A1, A2>
+{
+
+ /** . */
+ public static TypeConverter<A1, A2> delegate;
+
+ @Override
+ public A2 write(A1 input) throws Exception
+ {
+ if (delegate == null)
+ {
+ throw new AssertionFailedError();
+ }
+ return delegate.write(input);
+ }
+
+ @Override
+ public A1 read(A2 output) throws Exception
+ {
+ if (delegate == null)
+ {
+ throw new AssertionFailedError();
+ }
+ return delegate.read(output);
+ }
+}
Added: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/TestConverter.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/TestConverter.java (rev 0)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/converter/TestConverter.java 2010-01-16 23:15:12 UTC (rev 1335)
@@ -0,0 +1,190 @@
+/*
+ * 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.converter;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+import org.exoplatform.webui.application.replication.SerializationContext;
+import org.exoplatform.webui.application.replication.api.TypeConverter;
+import org.exoplatform.webui.application.replication.model.TypeDomain;
+
+import java.io.IOException;
+import java.io.InvalidObjectException;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestConverter extends TestCase
+{
+
+ public void testConvert() throws Exception
+ {
+ TypeDomain domain = new TypeDomain();
+ domain.add(A1.class);
+ A1 a = new A1("foo");
+
+ //
+ A3.delegate = new TypeConverter<A1, A2>()
+ {
+ @Override
+ public A2 write(A1 input) throws Exception
+ {
+ return new A2(input.state);
+ }
+ @Override
+ public A1 read(A2 output) throws Exception
+ {
+ return new A1(output.state);
+ }
+ };
+ SerializationContext context = new SerializationContext(domain);
+ a = context.clone(a);
+ assertEquals("foo", a.state);
+ }
+
+ public void testConverterWriteThrowsException() throws Exception
+ {
+ TypeDomain domain = new TypeDomain();
+ domain.add(A1.class);
+ A1 a = new A1("foo");
+
+ //
+ final Exception e = new Exception();
+ A3.delegate = new TypeConverter<A1, A2>()
+ {
+ @Override
+ public A2 write(A1 input) throws Exception
+ {
+ throw e;
+ }
+ @Override
+ public A1 read(A2 output) throws Exception
+ {
+ throw new AssertionFailedError();
+ }
+ };
+ SerializationContext context = new SerializationContext(domain);
+ try
+ {
+ a = context.clone(a);
+ fail();
+ }
+ catch (InvalidObjectException ioe)
+ {
+ assertSame(e, ioe.getCause());
+ }
+ }
+
+ public void testConverterWriteReturnsNull() throws Exception
+ {
+ TypeDomain domain = new TypeDomain();
+ domain.add(A1.class);
+ A1 a = new A1("foo");
+
+ //
+ A3.delegate = new TypeConverter<A1, A2>()
+ {
+ @Override
+ public A2 write(A1 input) throws Exception
+ {
+ return null;
+ }
+ @Override
+ public A1 read(A2 output) throws Exception
+ {
+ throw new AssertionFailedError();
+ }
+ };
+ SerializationContext context = new SerializationContext(domain);
+ try
+ {
+ a = context.clone(a);
+ fail();
+ }
+ catch (InvalidObjectException e)
+ {
+ }
+ }
+
+ public void testConverterReadReturnsNull() throws Exception
+ {
+ TypeDomain domain = new TypeDomain();
+ domain.add(A1.class);
+ A1 a = new A1("foo");
+
+ //
+ A3.delegate = new TypeConverter<A1, A2>()
+ {
+ @Override
+ public A2 write(A1 input) throws Exception
+ {
+ return new A2(input.state);
+ }
+ @Override
+ public A1 read(A2 output) throws Exception
+ {
+ return null;
+ }
+ };
+ SerializationContext context = new SerializationContext(domain);
+ try
+ {
+ a = context.clone(a);
+ fail();
+ }
+ catch (InvalidObjectException e)
+ {
+ }
+ }
+
+ public void testConverterReadThrowsException() throws Exception
+ {
+ TypeDomain domain = new TypeDomain();
+ domain.add(A1.class);
+ A1 a = new A1("foo");
+
+ //
+ final Exception e = new Exception();
+ A3.delegate = new TypeConverter<A1, A2>()
+ {
+ @Override
+ public A2 write(A1 input) throws Exception
+ {
+ return new A2(input.state);
+ }
+ @Override
+ public A1 read(A2 output) throws Exception
+ {
+ throw e;
+ }
+ };
+ SerializationContext context = new SerializationContext(domain);
+ try
+ {
+ a = context.clone(a);
+ fail();
+ }
+ catch (InvalidObjectException ioe)
+ {
+ assertSame(e, ioe.getCause());
+ }
+ }
+}
14 years, 11 months
gatein SVN: r1334 - in portal/trunk/webui/core/src: main/java/org/exoplatform/webui/application/replication/impl/api and 4 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-01-16 09:24:10 -0500 (Sat, 16 Jan 2010)
New Revision: 1334
Added:
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
Removed:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedField.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedType.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ReplicatableTypeModel.java
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/impl/api/DefaultTypeConverter.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ClassTypeModel.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/model/TypeModel.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
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/A.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/B.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C1.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C2.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/D.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E1.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E2.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/F.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/G.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/TestTypeModel.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/A2.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/B.java
Log:
refactored a bit the type system to simplify it and add notion of converted type
Added: 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 (rev 0)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/Converted.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -0,0 +1,32 @@
+/*
+ * 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.api.annotations;
+
+import org.exoplatform.webui.application.replication.api.TypeConverter;
+import org.exoplatform.webui.application.replication.impl.api.DefaultTypeConverter;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public @interface Converted
+{
+ Class<? extends TypeConverter<?, ?>> value();
+}
Deleted: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedField.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedField.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedField.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -1,36 +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.api.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotates a field
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-(a)Target(ElementType.FIELD)
-(a)Retention(RetentionPolicy.RUNTIME)
-public @interface ReplicatedField {
-}
Deleted: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedType.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedType.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedType.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -1,42 +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.api.annotations;
-
-import org.exoplatform.webui.application.replication.api.TypeConverter;
-import org.exoplatform.webui.application.replication.impl.api.DefaultTypeConverter;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotates a field
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-(a)Target(ElementType.TYPE)
-(a)Retention(RetentionPolicy.RUNTIME)
-public @interface ReplicatedType {
-
- Class<? extends TypeConverter<?, ?>> convertedBy() default DefaultTypeConverter.class;
-
-}
\ No newline at end of file
Copied: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/Serialized.java (from rev 1333, portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedType.java)
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/Serialized.java (rev 0)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/Serialized.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -0,0 +1,37 @@
+/*
+ * 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.api.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotates a type to be serializable.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+(a)Target(ElementType.TYPE)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface Serialized
+{
+}
\ No newline at end of file
Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/impl/api/DefaultTypeConverter.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/impl/api/DefaultTypeConverter.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/impl/api/DefaultTypeConverter.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -25,16 +25,16 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
-public class DefaultTypeConverter extends TypeConverter<Object, Object>
+public class DefaultTypeConverter<O> extends TypeConverter<O, O>
{
@Override
- public Object write(Object input) throws Exception
+ public O write(O input) throws Exception
{
return input;
}
@Override
- public Object read(Object output) throws Exception
+ public O read(O output) throws Exception
{
return output;
}
Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ClassTypeModel.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ClassTypeModel.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ClassTypeModel.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -19,6 +19,8 @@
package org.exoplatform.webui.application.replication.model;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Map;
/**
@@ -27,8 +29,49 @@
*/
public final class ClassTypeModel<O> extends TypeModel<O>
{
- ClassTypeModel(Class<O> type, TypeModel<? super O> superType, Map<String, FieldModel<O, ?>> fields)
+
+ /** . */
+ private final ClassTypeModel<? super O> superType;
+
+ /** . */
+ private final Map<String, FieldModel<O, ?>> fields;
+
+ /** . */
+ private final Map<String, FieldModel<O, ?>> immutableFields;
+
+ /** . */
+ private final boolean serialized;
+
+ ClassTypeModel(Class<O> type, ClassTypeModel<? super O> superType, Map<String, FieldModel<O, ?>> fields, boolean serialized)
{
super(type, superType, fields);
+
+ //
+ this.superType = superType;
+ this.fields = fields;
+ this.immutableFields = Collections.unmodifiableMap(fields);
+ this.serialized = serialized;
}
+
+ @Override
+ public ClassTypeModel<? super O> getSuperType()
+ {
+ return superType;
+ }
+
+ public boolean isSerialized()
+ {
+ return serialized;
+ }
+
+ public Collection<FieldModel<O, ?>> getFields()
+ {
+ return immutableFields.values();
+ }
+
+ public Map<String, FieldModel<O, ?>> getFieldMap()
+ {
+ return immutableFields;
+ }
+
}
\ No newline at end of file
Deleted: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ReplicatableTypeModel.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ReplicatableTypeModel.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/ReplicatableTypeModel.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -1,38 +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.model;
-
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public final class ReplicatableTypeModel<O> extends TypeModel<O>
-{
-
- ReplicatableTypeModel(
- Class<O> javaType,
- TypeModel<? super O> superType,
- Map<String, FieldModel<O, ?>> fields)
- {
- super(javaType, superType, fields);
- }
-}
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-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeDomain.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -19,7 +19,7 @@
package org.exoplatform.webui.application.replication.model;
-import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.Serialized;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@@ -123,7 +123,7 @@
}
// For now that operation is synchronized
- public synchronized TypeModel add(Class<?> javaType)
+ public synchronized <O> TypeModel<O> add(Class<O> javaType)
{
if (javaType == null)
{
@@ -132,8 +132,8 @@
// Build the missing types required to have knowledge about the
// provided java type
- Map<String, TypeModel> addedTypeModels = new HashMap<String, TypeModel>();
- TypeModel model = build(javaType, addedTypeModels);
+ Map<String, TypeModel<?>> addedTypeModels = new HashMap<String, TypeModel<?>>();
+ TypeModel<O> model = build(javaType, addedTypeModels);
// Perform merge
typeModelMap.putAll(addedTypeModels);
@@ -150,7 +150,7 @@
return typeModelMap.size();
}
- private <O> TypeModel build(Class<O> javaType, Map<String, TypeModel> addedTypeModels)
+ private <O> TypeModel<O> build(Class<O> javaType, Map<String, TypeModel<?>> addedTypeModels)
{
if (javaType.isPrimitive())
{
@@ -163,31 +163,28 @@
//
if (typeModel == null)
{
- boolean replicated = javaType.getAnnotation(ReplicatedType.class) != null;
+ boolean replicated = javaType.getAnnotation(Serialized.class) != null;
//
- TypeModel<?> superTypeModel = null;
- for (Class<?> ancestor = javaType.getSuperclass();ancestor != null;ancestor = ancestor.getSuperclass())
+ ClassTypeModel<? super O> superTypeModel = null;
+ if (javaType.getSuperclass() != null)
{
- superTypeModel = build(ancestor, addedTypeModels);
- if (superTypeModel != null)
+ TypeModel<? super O> builtType = build(javaType.getSuperclass(), addedTypeModels);
+ if (builtType instanceof ClassTypeModel)
{
- break;
+ superTypeModel = (ClassTypeModel<? super O>)builtType;
}
+ else
+ {
+ throw new TypeException();
+ }
}
//
TreeMap<String, FieldModel<O, ?>> fieldModels = new TreeMap<String, FieldModel<O, ?>>();
//
- if (replicated)
- {
- typeModel = new ReplicatableTypeModel<O>(javaType, (TypeModel<? super O>)superTypeModel, fieldModels);
- }
- else
- {
- typeModel = new ClassTypeModel<O>(javaType, (TypeModel<? super O>)superTypeModel, fieldModels);
- }
+ typeModel = new ClassTypeModel<O>(javaType, superTypeModel, fieldModels, replicated);
//
addedTypeModels.put(javaType.getName(), typeModel);
@@ -224,13 +221,14 @@
return new FieldModel<O, V>(owner, field, fieldTypeModel);
}
- private TypeModel get(Class<?> javaType, Map<String, TypeModel> addedTypeModels)
+ private <O> TypeModel<O> get(Class<O> javaType, Map<String, TypeModel<?>> addedTypeModels)
{
- TypeModel typeModel = typeModelMap.get(javaType.getName());
+ TypeModel<?> typeModel = typeModelMap.get(javaType.getName());
if (typeModel == null)
{
typeModel = addedTypeModels.get(javaType.getName());
}
- return typeModel;
+ // Cast OK
+ return (TypeModel<O>)typeModel;
}
}
Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeModel.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeModel.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeModel.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -36,30 +36,12 @@
/** . */
private final TypeModel<? super O> superType;
- /** . */
- private final Map<String, FieldModel<O, ?>> fields;
-
- /** . */
- private final Map<String, FieldModel<O, ?>> immutableFields;
-
TypeModel(Class<O> javaType, TypeModel<? super O> superType, Map<String, FieldModel<O, ?>> fields)
{
this.javaType = javaType;
this.superType = superType;
- this.fields = fields;
- this.immutableFields = Collections.unmodifiableMap(fields);
}
- public Collection<FieldModel<O, ?>> getFields()
- {
- return immutableFields.values();
- }
-
- public Map<String, FieldModel<O, ?>> getFieldMap()
- {
- return immutableFields;
- }
-
public String getName()
{
return javaType.getName();
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-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectReader.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -21,9 +21,8 @@
import org.exoplatform.webui.application.replication.SerializationContext;
import org.exoplatform.webui.application.replication.api.factory.ObjectFactory;
-import org.exoplatform.webui.application.replication.model.ReplicatableTypeModel;
+import org.exoplatform.webui.application.replication.model.ClassTypeModel;
import org.exoplatform.webui.application.replication.model.FieldModel;
-import org.exoplatform.webui.application.replication.model.TypeModel;
import java.io.*;
import java.util.*;
@@ -57,7 +56,7 @@
this.idToResolutions = new HashMap<Integer, List<FutureFieldUpdate<?>>>();
}
- private <O> O instantiate(ReplicatableTypeModel<O> typeModel, Map<FieldModel<? super O, ?>, ?> state) throws InvalidClassException
+ private <O> O instantiate(ClassTypeModel<O> typeModel, Map<FieldModel<? super O, ?>, ?> state) throws InvalidClassException
{
try
{
@@ -74,14 +73,14 @@
}
}
- protected <O> O instantiate(int id, DataContainer container, ReplicatableTypeModel<O> typeModel) throws IOException
+ protected <O> O instantiate(int id, DataContainer container, ClassTypeModel<O> typeModel) throws IOException
{
Map<FieldModel<? super O, ?>, Object> state = new HashMap<FieldModel<? super O, ?>, Object>();
- TypeModel<? super O> currentTypeModel = typeModel;
+ ClassTypeModel<? super O> currentTypeModel = typeModel;
List<FieldUpdate<O>> sets = new ArrayList<FieldUpdate<O>>();
while (currentTypeModel != null)
{
- if (currentTypeModel instanceof ReplicatableTypeModel)
+ if (currentTypeModel instanceof ClassTypeModel)
{
for (FieldModel<? super O, ?> fieldModel : currentTypeModel.getFields())
{
@@ -200,7 +199,7 @@
case DataKind.OBJECT:
id = container.readInt();
Class<?> clazz = (Class) container.readObject();
- ReplicatableTypeModel<?> typeModel = (ReplicatableTypeModel)context.getTypeDomain().getTypeModel(clazz);
+ ClassTypeModel<?> typeModel = (ClassTypeModel<?>)context.getTypeDomain().getTypeModel(clazz);
return instantiate(id, container, typeModel);
default:
throw new StreamCorruptedException("Unrecognized data " + sw);
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-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectWriter.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -20,9 +20,8 @@
package org.exoplatform.webui.application.replication.serial;
import org.exoplatform.webui.application.replication.SerializationContext;
-import org.exoplatform.webui.application.replication.model.ReplicatableTypeModel;
+import org.exoplatform.webui.application.replication.model.ClassTypeModel;
import org.exoplatform.webui.application.replication.model.FieldModel;
-import org.exoplatform.webui.application.replication.model.TypeModel;
import java.io.*;
import java.util.IdentityHashMap;
@@ -59,6 +58,83 @@
return nextId;
}
+ private <O> void write(DataContainer output, ClassTypeModel<O> typeModel, O obj) throws IOException
+ {
+ if (!typeModel.isSerialized())
+ {
+ throw new NotSerializableException("Type " + typeModel + " cannot be serialized");
+ }
+
+ //
+ output.writeInt(DataKind.OBJECT);
+ output.writeInt(register(obj));
+ output.writeObject(typeModel.getJavaType());
+
+ //
+ SerializationStatus status = SerializationStatus.NONE;
+ for (ClassTypeModel<? super O> currentTypeModel = typeModel;currentTypeModel != null;currentTypeModel = currentTypeModel.getSuperType())
+ {
+ if (currentTypeModel instanceof ClassTypeModel<?>)
+ {
+ for (FieldModel<?, ?> fieldModel : currentTypeModel.getFields())
+ {
+ if (!fieldModel.isTransient())
+ {
+ Object fieldValue = fieldModel.get(obj);
+ if (fieldValue == null)
+ {
+ output.writeObject(DataKind.NULL_VALUE);
+ }
+ else
+ {
+ Integer fieldValueId = objectToId.get(fieldValue);
+ if (fieldValueId != null)
+ {
+ output.writeObject(DataKind.OBJECT_REF);
+ output.writeInt(fieldValueId);
+ }
+ else
+ {
+ output.writeObject(DataKind.OBJECT);
+ output.writeObject(fieldValue);
+ }
+ }
+ }
+ }
+ switch (status)
+ {
+ case NONE:
+ status = SerializationStatus.FULL;
+ break;
+ }
+ }
+ else
+ {
+ if (!currentTypeModel.getFields().isEmpty())
+ {
+ switch (status)
+ {
+ case FULL:
+ status = SerializationStatus.PARTIAL;
+ break;
+ }
+ }
+ }
+ }
+
+ //
+ switch (status)
+ {
+ case FULL:
+ break;
+ case PARTIAL:
+ System.out.println("Partial serialization of object " + obj);
+ break;
+ case NONE:
+ throw new NotSerializableException("Type " + typeModel + " is not serializable");
+ }
+ }
+
@Override
protected Object replaceObject(final Object obj) throws IOException
{
@@ -83,8 +159,8 @@
}
else
{
- Class<?> objClass = obj.getClass();
- TypeModel<?> typeModel = context.getTypeDomain().getTypeModel(objClass);
+ Class objClass = obj.getClass();
+ ClassTypeModel typeModel = (ClassTypeModel)context.getTypeDomain().getTypeModel(objClass);
//
if (typeModel == null)
@@ -92,74 +168,9 @@
throw new NotSerializableException("Object " + obj + " does not have its type described");
}
- //
- output.writeInt(DataKind.OBJECT);
- output.writeInt(register(obj));
- output.writeObject(objClass);
-
- //
- SerializationStatus status = SerializationStatus.NONE;
- for (TypeModel<?> currentTypeModel = typeModel;currentTypeModel != null;currentTypeModel = currentTypeModel.getSuperType())
- {
- if (currentTypeModel instanceof ReplicatableTypeModel<?>)
- {
- for (FieldModel<?, ?> fieldModel : currentTypeModel.getFields())
- {
- if (!fieldModel.isTransient())
- {
- Object fieldValue = fieldModel.get(obj);
- if (fieldValue == null)
- {
- output.writeObject(DataKind.NULL_VALUE);
- }
- else
- {
- Integer fieldValueId = objectToId.get(fieldValue);
- if (fieldValueId != null)
- {
- output.writeObject(DataKind.OBJECT_REF);
- output.writeInt(fieldValueId);
- }
- else
- {
- output.writeObject(DataKind.OBJECT);
- output.writeObject(fieldValue);
- }
- }
- }
- }
- switch (status)
- {
- case NONE:
- status = SerializationStatus.FULL;
- break;
- }
- }
- else
- {
- if (!currentTypeModel.getFields().isEmpty())
- {
- switch (status)
- {
- case FULL:
- status = SerializationStatus.PARTIAL;
- break;
- }
- }
- }
- }
-
- //
- switch (status)
- {
- case FULL:
- break;
- case PARTIAL:
- System.out.println("Partial serialization of object " + obj);
- break;
- case NONE:
- throw new NotSerializableException("Type " + objClass.getName() + " is not serializable");
- }
+ // This is obviously unchecked because of the fact that Object.getClass() returns Class<?>
+ // need to find a work around for that
+ write(output, typeModel, obj);
}
//
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/A.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/A.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/A.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -19,13 +19,13 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.Serialized;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
-@ReplicatedType
+@Serialized
public class A {
String a;
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/B.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/B.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/B.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -19,13 +19,13 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.Serialized;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
-@ReplicatedType
+@Serialized
public class B
{
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C1.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C1.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C1.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -19,13 +19,13 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.Serialized;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
-@ReplicatedType
+@Serialized
public class C1
{
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C2.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C2.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C2.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -19,13 +19,13 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.Serialized;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
-@ReplicatedType
+@Serialized
public class C2 extends C1
{
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/D.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/D.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/D.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -19,13 +19,13 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.Serialized;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
-@ReplicatedType
+@Serialized
public class D
{
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E1.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E1.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E1.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -19,13 +19,13 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.Serialized;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
-@ReplicatedType
+@Serialized
public class E1
{
}
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E2.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E2.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E2.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -19,13 +19,13 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.Serialized;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
-@ReplicatedType
+@Serialized
public class E2 extends E1
{
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/F.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/F.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/F.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -19,7 +19,7 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.Serialized;
import java.util.ArrayList;
import java.util.List;
@@ -28,7 +28,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
-@ReplicatedType
+@Serialized
public class F
{
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/G.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/G.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/G.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -19,13 +19,13 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.Serialized;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
-@ReplicatedType
+@Serialized
public class G
{
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/TestTypeModel.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/TestTypeModel.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/TestTypeModel.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -54,7 +54,7 @@
public void testJuu()
{
TypeDomain domain = new TypeDomain();
- ReplicatableTypeModel<A> aTM = (ReplicatableTypeModel) domain.add(A.class);
+ ClassTypeModel<A> aTM = (ClassTypeModel<A>)domain.add(A.class);
assertEquals(A.class.getName(), aTM.getName());
/*
assertEquals(SetBuilder.
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/A2.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/A2.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/A2.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -19,13 +19,13 @@
package org.exoplatform.webui.replication.factory;
-import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.Serialized;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
-@ReplicatedType
+@Serialized
public class A2
{
}
\ No newline at end of file
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/B.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/B.java 2010-01-16 13:19:15 UTC (rev 1333)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/B.java 2010-01-16 14:24:10 UTC (rev 1334)
@@ -19,13 +19,13 @@
package org.exoplatform.webui.replication.factory;
-import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.Serialized;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
-@ReplicatedType
+@Serialized
public class B
{
public B()
14 years, 11 months
gatein SVN: r1333 - in portal/trunk/webui/core/src: main/java/org/exoplatform/webui/application/replication/api and 9 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-01-16 08:19:15 -0500 (Sat, 16 Jan 2010)
New Revision: 1333
Added:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/
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/
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedField.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedType.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/factory/
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/factory/CreateException.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/impl/
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/impl/api/
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/impl/api/DefaultTypeConverter.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/impl/api/factory/
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/impl/api/factory/DefaultObjectFactory.java
Removed:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/annotations/
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/factory/
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/SerializationContext.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/test/java/org/exoplatform/webui/replication/A.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/B.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C1.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C2.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/D.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E1.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E2.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/F.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/G.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/A1.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/A2.java
portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/B.java
Log:
- make an API package to scope what should be used by clients
- introduce notion of type converter
Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/SerializationContext.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/SerializationContext.java 2010-01-16 12:38:39 UTC (rev 1332)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/SerializationContext.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -19,8 +19,8 @@
package org.exoplatform.webui.application.replication;
-import org.exoplatform.webui.application.replication.factory.DefaultObjectFactory;
-import org.exoplatform.webui.application.replication.factory.ObjectFactory;
+import org.exoplatform.webui.application.replication.impl.api.factory.DefaultObjectFactory;
+import org.exoplatform.webui.application.replication.api.factory.ObjectFactory;
import org.exoplatform.webui.application.replication.model.TypeDomain;
import org.exoplatform.webui.application.replication.serial.ObjectReader;
import org.exoplatform.webui.application.replication.serial.ObjectWriter;
Added: 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 (rev 0)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/TypeConverter.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -0,0 +1,33 @@
+/*
+ * 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.api;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class TypeConverter<I, O>
+{
+
+ public abstract O write(I input) throws Exception;
+
+ public abstract I read(O output) throws Exception;
+
+}
Added: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedField.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedField.java (rev 0)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedField.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -0,0 +1,36 @@
+/*
+ * 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.api.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotates a field
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+(a)Target(ElementType.FIELD)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface ReplicatedField {
+}
Added: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedType.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedType.java (rev 0)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/annotations/ReplicatedType.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -0,0 +1,42 @@
+/*
+ * 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.api.annotations;
+
+import org.exoplatform.webui.application.replication.api.TypeConverter;
+import org.exoplatform.webui.application.replication.impl.api.DefaultTypeConverter;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotates a field
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+(a)Target(ElementType.TYPE)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface ReplicatedType {
+
+ Class<? extends TypeConverter<?, ?>> convertedBy() default DefaultTypeConverter.class;
+
+}
\ No newline at end of file
Added: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/factory/CreateException.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/factory/CreateException.java (rev 0)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/factory/CreateException.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -0,0 +1,46 @@
+/*
+ * 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.api.factory;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class CreateException extends Exception
+{
+ public CreateException()
+ {
+ }
+
+ public CreateException(String message)
+ {
+ super(message);
+ }
+
+ public CreateException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public CreateException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Added: 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 (rev 0)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/api/factory/ObjectFactory.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -0,0 +1,45 @@
+/*
+ * 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.api.factory;
+
+import org.exoplatform.webui.application.replication.model.FieldModel;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ * @param <B> the base object type
+ */
+public abstract class ObjectFactory<B>
+{
+
+ /**
+ * Instantiate an object based on the provided class.
+ *
+ * @param type the type
+ * @param state the state
+ * @param <S> the sub type of the base type
+ * @return the S instance
+ * @throws CreateException anything wrong that could happen during instance creation
+ */
+ public abstract <S extends B> S create(Class<S> type, Map<FieldModel<? super S, ?>, ?> state) throws CreateException;
+
+}
Added: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/impl/api/DefaultTypeConverter.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/impl/api/DefaultTypeConverter.java (rev 0)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/impl/api/DefaultTypeConverter.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -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.impl.api;
+
+import org.exoplatform.webui.application.replication.api.TypeConverter;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class DefaultTypeConverter extends TypeConverter<Object, Object>
+{
+ @Override
+ public Object write(Object input) throws Exception
+ {
+ return input;
+ }
+
+ @Override
+ public Object read(Object output) throws Exception
+ {
+ return output;
+ }
+}
Copied: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/impl/api/factory/DefaultObjectFactory.java (from rev 1332, portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/factory/DefaultObjectFactory.java)
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/impl/api/factory/DefaultObjectFactory.java (rev 0)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/impl/api/factory/DefaultObjectFactory.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -0,0 +1,57 @@
+/*
+ * 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.impl.api.factory;
+
+import org.exoplatform.webui.application.replication.api.factory.CreateException;
+import org.exoplatform.webui.application.replication.api.factory.ObjectFactory;
+import org.exoplatform.webui.application.replication.model.FieldModel;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public final class DefaultObjectFactory extends ObjectFactory<Object>
+{
+ @Override
+ public <S> S create(Class<S> type, Map<FieldModel<? super S, ?>, ?> state) throws CreateException
+ {
+ try
+ {
+ S instance = type.newInstance();
+
+ //
+ for (Map.Entry<FieldModel<? super S, ?>, ?> entry : state.entrySet())
+ {
+ FieldModel<?, ?> fieldModel = entry.getKey();
+ Object value = entry.getValue();
+ fieldModel.castAndSet(instance, value);
+ }
+
+ //
+ return instance;
+ }
+ catch (Exception e)
+ {
+ throw new CreateException(e);
+ }
+ }
+}
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-16 12:38:39 UTC (rev 1332)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeDomain.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -19,7 +19,7 @@
package org.exoplatform.webui.application.replication.model;
-import org.exoplatform.webui.application.replication.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
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-16 12:38:39 UTC (rev 1332)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/serial/ObjectReader.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -20,7 +20,7 @@
package org.exoplatform.webui.application.replication.serial;
import org.exoplatform.webui.application.replication.SerializationContext;
-import org.exoplatform.webui.application.replication.factory.ObjectFactory;
+import org.exoplatform.webui.application.replication.api.factory.ObjectFactory;
import org.exoplatform.webui.application.replication.model.ReplicatableTypeModel;
import org.exoplatform.webui.application.replication.model.FieldModel;
import org.exoplatform.webui.application.replication.model.TypeModel;
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/A.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/A.java 2010-01-16 12:38:39 UTC (rev 1332)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/A.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -19,7 +19,7 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/B.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/B.java 2010-01-16 12:38:39 UTC (rev 1332)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/B.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -19,7 +19,7 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C1.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C1.java 2010-01-16 12:38:39 UTC (rev 1332)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C1.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -19,7 +19,7 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C2.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C2.java 2010-01-16 12:38:39 UTC (rev 1332)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/C2.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -19,7 +19,7 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/D.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/D.java 2010-01-16 12:38:39 UTC (rev 1332)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/D.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -19,7 +19,7 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E1.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E1.java 2010-01-16 12:38:39 UTC (rev 1332)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E1.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -19,7 +19,7 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E2.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E2.java 2010-01-16 12:38:39 UTC (rev 1332)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/E2.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -19,7 +19,7 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/F.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/F.java 2010-01-16 12:38:39 UTC (rev 1332)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/F.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -19,7 +19,7 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
import java.util.ArrayList;
import java.util.List;
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/G.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/G.java 2010-01-16 12:38:39 UTC (rev 1332)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/G.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -19,7 +19,7 @@
package org.exoplatform.webui.replication;
-import org.exoplatform.webui.application.replication.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/A1.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/A1.java 2010-01-16 12:38:39 UTC (rev 1332)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/A1.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -19,8 +19,8 @@
package org.exoplatform.webui.replication.factory;
-import org.exoplatform.webui.application.replication.factory.ObjectFactory;
-import org.exoplatform.webui.application.replication.factory.CreateException;
+import org.exoplatform.webui.application.replication.api.factory.ObjectFactory;
+import org.exoplatform.webui.application.replication.api.factory.CreateException;
import org.exoplatform.webui.application.replication.model.FieldModel;
import java.util.Map;
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/A2.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/A2.java 2010-01-16 12:38:39 UTC (rev 1332)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/A2.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -19,7 +19,7 @@
package org.exoplatform.webui.replication.factory;
-import org.exoplatform.webui.application.replication.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
Modified: portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/B.java
===================================================================
--- portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/B.java 2010-01-16 12:38:39 UTC (rev 1332)
+++ portal/trunk/webui/core/src/test/java/org/exoplatform/webui/replication/factory/B.java 2010-01-16 13:19:15 UTC (rev 1333)
@@ -19,7 +19,7 @@
package org.exoplatform.webui.replication.factory;
-import org.exoplatform.webui.application.replication.annotations.ReplicatedType;
+import org.exoplatform.webui.application.replication.api.annotations.ReplicatedType;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
14 years, 11 months