Author: julien(a)jboss.com
Date: 2007-01-15 18:29:20 -0500 (Mon, 15 Jan 2007)
New Revision: 6009
Added:
trunk/core/src/main/org/jboss/portal/core/cms/content/CMSContent.java
trunk/core/src/main/org/jboss/portal/core/cms/content/CMSContentHandler.java
trunk/core/src/main/org/jboss/portal/core/cms/content/CMSContentMetaData.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/
trunk/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContentHandler.java
trunk/core/src/main/org/jboss/portal/core/model/content/
trunk/core/src/main/org/jboss/portal/core/model/content/Content.java
trunk/core/src/main/org/jboss/portal/core/model/content/ContentType.java
trunk/core/src/main/org/jboss/portal/core/model/content/metadata/
trunk/core/src/main/org/jboss/portal/core/model/content/metadata/ContentMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/content/spi/
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandler.java
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandlerRegistry.java
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentState.java
trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/content/PortletContent.java
trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/content/PortletContentHandler.java
trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/content/PortletContentMetaData.java
Log:
- JBPORTAL-1195 : Content framework for content integration at the window level
Added: trunk/core/src/main/org/jboss/portal/core/cms/content/CMSContent.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/cms/content/CMSContent.java 2007-01-15
23:22:53 UTC (rev 6008)
+++ trunk/core/src/main/org/jboss/portal/core/cms/content/CMSContent.java 2007-01-15
23:29:20 UTC (rev 6009)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.core.cms.content;
+
+import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.spi.ContentState;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CMSContent implements Content
+{
+
+ /** . */
+ private final ContentState state;
+
+ public CMSContent(ContentState state)
+ {
+ this.state = state;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getURI()
+ {
+ return state.getURI();
+ }
+
+ /**
+ *
+ * @param uri
+ */
+ public void setURI(String uri)
+ {
+ state.setURI(uri);
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/cms/content/CMSContentHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/cms/content/CMSContentHandler.java 2007-01-15
23:22:53 UTC (rev 6008)
+++
trunk/core/src/main/org/jboss/portal/core/cms/content/CMSContentHandler.java 2007-01-15
23:29:20 UTC (rev 6009)
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.core.cms.content;
+
+import org.jboss.portal.core.model.content.spi.ContentHandler;
+import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.impl.model.content.AbstractContentHandler;
+import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.metadata.ContentMetaData;
+import org.jboss.portal.common.util.XML;
+import org.w3c.dom.Element;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CMSContentHandler extends AbstractContentHandler implements ContentHandler
+{
+ public Content newContent(String contextId, ContentState state)
+ {
+ return new CMSContent(state);
+ }
+
+ public ContentMetaData newMetaData(Element windowElement)
+ {
+ CMSContentMetaData contentMD = new CMSContentMetaData();
+ String instanceRef = XML.asString(XML.getUniqueChild(windowElement,
"uri", true));
+ contentMD.setUri(instanceRef);
+ return contentMD;
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/cms/content/CMSContentMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/cms/content/CMSContentMetaData.java 2007-01-15
23:22:53 UTC (rev 6008)
+++
trunk/core/src/main/org/jboss/portal/core/cms/content/CMSContentMetaData.java 2007-01-15
23:29:20 UTC (rev 6009)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.core.cms.content;
+
+import org.jboss.portal.core.model.content.metadata.ContentMetaData;
+import org.jboss.portal.core.model.content.Content;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CMSContentMetaData implements ContentMetaData
+{
+
+ /** The instance handle of this window. */
+ protected String uri;
+
+ public String getUri()
+ {
+ return uri;
+ }
+
+ public void setUri(String uri)
+ {
+ this.uri = uri;
+ }
+
+ public void configure(Content content)
+ {
+ CMSContent pc = (CMSContent)content;
+ pc.setURI(uri);
+ }
+}
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContentHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContentHandler.java 2007-01-15
23:22:53 UTC (rev 6008)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContentHandler.java 2007-01-15
23:29:20 UTC (rev 6009)
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.core.impl.model.content;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.spi.ContentHandler;
+import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
+import org.jboss.portal.core.model.content.spi.ContentState;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractContentHandler extends AbstractJBossService implements
ContentHandler
+{
+
+ /** . */
+ private ContentHandlerRegistry registry;
+
+ /** . */
+ private String contentType;
+
+ /** . */
+ private ContentType registeredContentType;
+
+ public String getContentType()
+ {
+ return contentType;
+ }
+
+ public void setContentType(String contentType)
+ {
+ this.contentType = contentType;
+ }
+
+ public ContentHandlerRegistry getRegistry()
+ {
+ return registry;
+ }
+
+ public ContentType getRegisteredContentType()
+ {
+ return registeredContentType;
+ }
+
+ public void setRegistry(ContentHandlerRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ protected void createService() throws Exception
+ {
+ registeredContentType = ContentType.create(contentType);
+
+ //
+ registry.registerHandler(registeredContentType, this);
+ }
+
+ protected void destroyService() throws Exception
+ {
+ if (registeredContentType != null)
+ {
+ registry.unregisterHandler(registeredContentType);
+ }
+ }
+
+ public void createContent(String contextId, ContentState state)
+ {
+ }
+
+ public void destroyContent(String contextId, ContentState state)
+ {
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/model/content/Content.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/content/Content.java 2007-01-15
23:22:53 UTC (rev 6008)
+++ trunk/core/src/main/org/jboss/portal/core/model/content/Content.java 2007-01-15
23:29:20 UTC (rev 6009)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.core.model.content;
+
+/**
+ * The content.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Content
+{
+}
Added: trunk/core/src/main/org/jboss/portal/core/model/content/ContentType.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/content/ContentType.java 2007-01-15
23:22:53 UTC (rev 6008)
+++ trunk/core/src/main/org/jboss/portal/core/model/content/ContentType.java 2007-01-15
23:29:20 UTC (rev 6009)
@@ -0,0 +1,97 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.core.model.content;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public final class ContentType
+{
+
+ /** . */
+ public static final ContentType UNKNOWN = new ContentType("unknown");
+
+ /** . */
+ public static final ContentType CMS = new ContentType("cms");
+
+ /** . */
+ public static final ContentType PORTLET = new ContentType("portlet");
+
+ /** . */
+ private final String value;
+
+ private ContentType(String value)
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.value = value;
+ }
+
+ public int hashCode()
+ {
+ return value.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof ContentType)
+ {
+ ContentType that = (ContentType)obj;
+ return value.equals(that.value);
+ }
+ return false;
+ }
+
+ public String toString()
+ {
+ return value;
+ }
+
+ public static ContentType create(String value) throws IllegalArgumentException
+ {
+ if ("portlet".equals(value))
+ {
+ return PORTLET;
+ }
+ else if ("cms".equals(value))
+ {
+ return CMS;
+ }
+ else if ("unknown".equals(value))
+ {
+ return UNKNOWN;
+ }
+ else if (value == null)
+ {
+ throw new IllegalArgumentException("No null value for content type
accepted");
+ }
+ return new ContentType(value);
+ }
+}
Added:
trunk/core/src/main/org/jboss/portal/core/model/content/metadata/ContentMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/content/metadata/ContentMetaData.java 2007-01-15
23:22:53 UTC (rev 6008)
+++
trunk/core/src/main/org/jboss/portal/core/model/content/metadata/ContentMetaData.java 2007-01-15
23:29:20 UTC (rev 6009)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.core.model.content.metadata;
+
+import org.jboss.portal.core.model.content.Content;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ContentMetaData
+{
+ void configure(Content content);
+}
Added: trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandler.java 2007-01-15
23:22:53 UTC (rev 6008)
+++
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandler.java 2007-01-15
23:29:20 UTC (rev 6009)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.core.model.content.spi;
+
+import org.jboss.portal.core.model.content.metadata.ContentMetaData;
+import org.jboss.portal.core.model.content.Content;
+import org.w3c.dom.Element;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ContentHandler
+{
+ /**
+ * Factory method to create an instance of window content object.
+ */
+ Content newContent(String contextId, ContentState state);
+
+ /**
+ * Life cycle method to signal creation.
+ */
+ void createContent(String contextId, ContentState state);
+
+ /**
+ * Life cycle method to signal destruction.
+ */
+ void destroyContent(String contextId, ContentState state);
+
+ /**
+ * Factory method treate the window content meta data from XML.
+ */
+ ContentMetaData newMetaData(Element windowElement);
+}
Added:
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandlerRegistry.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandlerRegistry.java 2007-01-15
23:22:53 UTC (rev 6008)
+++
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandlerRegistry.java 2007-01-15
23:29:20 UTC (rev 6009)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.core.model.content.spi;
+
+import org.jboss.portal.core.model.content.ContentType;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ContentHandlerRegistry
+{
+ /**
+ *
+ * @param contentType
+ * @param handler
+ * @throws IllegalArgumentException
+ */
+ void registerHandler(ContentType contentType, ContentHandler handler) throws
IllegalArgumentException;
+
+ /**
+ *
+ * @param contentType
+ * @return
+ */
+ ContentHandler getHandler(ContentType contentType);
+
+ /**
+ *
+ * @param contentType
+ */
+ void unregisterHandler(ContentType contentType);
+}
Added: trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentState.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentState.java 2007-01-15
23:22:53 UTC (rev 6008)
+++
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentState.java 2007-01-15
23:29:20 UTC (rev 6009)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.core.model.content.spi;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ContentState
+{
+ /**
+ *
+ * @return
+ */
+ String getURI();
+
+ /**
+ *
+ * @return
+ */
+ void setURI(String uri);
+
+ /**
+ *
+ * @param name
+ * @param value
+ */
+ void setProperty(String name, String value);
+
+ /**
+ *
+ * @param name
+ * @return
+ */
+ String getProperty(String name);
+}
Added:
trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/content/PortletContent.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/content/PortletContent.java 2007-01-15
23:22:53 UTC (rev 6008)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/content/PortletContent.java 2007-01-15
23:29:20 UTC (rev 6009)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.core.model.portal.portlet.content;
+
+import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.spi.ContentState;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletContent implements Content
+{
+
+ /** . */
+ private final ContentState state;
+
+ /** . */
+ private final PortletContentHandler handler;
+
+ /** . */
+ private final String contextId;
+
+ public PortletContent(PortletContentHandler handler, String contextId, ContentState
state)
+ {
+ this.handler = handler;
+ this.contextId = contextId;
+ this.state = state;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getInstanceRef()
+ {
+ return state.getURI();
+ }
+
+ /**
+ *
+ * @param instanceRef
+ */
+ public void setInstanceRef(String instanceRef)
+ {
+ String currentInstanceRef = state.getURI();
+
+ //
+ if (currentInstanceRef != null && currentInstanceRef.equals(instanceRef) ==
false)
+ {
+ handler.destroyContent(contextId, state);
+ }
+
+ //
+ state.setURI(instanceRef);
+ }
+}
Added:
trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/content/PortletContentHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/content/PortletContentHandler.java 2007-01-15
23:22:53 UTC (rev 6008)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/content/PortletContentHandler.java 2007-01-15
23:29:20 UTC (rev 6009)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.core.model.portal.portlet.content;
+
+import org.jboss.portal.core.model.content.spi.ContentHandler;
+import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.impl.model.content.AbstractContentHandler;
+import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.metadata.ContentMetaData;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.common.util.XML;
+import org.w3c.dom.Element;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletContentHandler extends AbstractContentHandler implements
ContentHandler
+{
+
+ /** . */
+ private InstanceContainer instanceContainer;
+
+ public InstanceContainer getInstanceContainer()
+ {
+ return instanceContainer;
+ }
+
+ public void setInstanceContainer(InstanceContainer instanceContainer)
+ {
+ this.instanceContainer = instanceContainer;
+ }
+
+ public Content newContent(String contextId, ContentState state)
+ {
+ return new PortletContent(this, contextId, state);
+ }
+
+ public ContentMetaData newMetaData(Element windowElement)
+ {
+ PortletContentMetaData contentMD = new PortletContentMetaData();
+ String instanceRef = XML.asString(XML.getUniqueChild(windowElement,
"instance-ref", true));
+ contentMD.setInstanceRef(instanceRef);
+ return contentMD;
+ }
+
+ public void destroyContent(String contextId, ContentState state)
+ {
+ String instanceRef = state.getURI();
+
+ // Do we have a related instance ?
+ if (instanceRef != null)
+ {
+ Instance instance = instanceContainer.getDefinition(instanceRef);
+
+ // Destroy related instance customization if possible
+ if (instance != null)
+ {
+ instance.destroyCustomization(contextId);
+ }
+ }
+ }
+}
Added:
trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/content/PortletContentMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/content/PortletContentMetaData.java 2007-01-15
23:22:53 UTC (rev 6008)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/content/PortletContentMetaData.java 2007-01-15
23:29:20 UTC (rev 6009)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.core.model.portal.portlet.content;
+
+import org.jboss.portal.core.model.content.metadata.ContentMetaData;
+import org.jboss.portal.core.model.content.Content;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletContentMetaData implements ContentMetaData
+{
+
+ /** The instance handle of this window. */
+ protected String instanceRef;
+
+ public String getInstanceRef()
+ {
+ return instanceRef;
+ }
+
+ public void setInstanceRef(String instanceRef)
+ {
+ this.instanceRef = instanceRef;
+ }
+
+ public void configure(Content content)
+ {
+ PortletContent pc = (PortletContent)content;
+ pc.setInstanceRef(instanceRef);
+ }
+}