Author: julien_viet
Date: 2011-09-02 05:47:08 -0400 (Fri, 02 Sep 2011)
New Revision: 7291
Added:
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/PortletRegistry.java
Modified:
portal/branches/api/component/api-impl/pom.xml
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/AbstractAPITestCase.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java
portal/branches/api/component/api-impl/src/test/resources/org/gatein/portal/api/impl/configuration.xml
Log:
start to integrate the local portlet invoker
Modified: portal/branches/api/component/api-impl/pom.xml
===================================================================
--- portal/branches/api/component/api-impl/pom.xml 2011-09-02 08:53:42 UTC (rev 7290)
+++ portal/branches/api/component/api-impl/pom.xml 2011-09-02 09:47:08 UTC (rev 7291)
@@ -66,7 +66,15 @@
<groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.component.application-registry</artifactId>
<type>test-jar</type>
+ <scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.gatein.pc</groupId>
+ <artifactId>pc-portlet</artifactId>
+ <version>2.3.0-Beta05</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-09-02
08:53:42 UTC (rev 7290)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-09-02
09:47:08 UTC (rev 7291)
@@ -69,7 +69,7 @@
import org.gatein.api.util.IterableIdentifiableCollection;
import org.gatein.api.util.Type;
import org.gatein.common.util.ParameterValidation;
-import org.gatein.pc.federation.FederatingPortletInvoker;
+import org.gatein.pc.api.PortletInvoker;
import org.gatein.portal.api.impl.portal.DashboardSiteImpl;
import org.gatein.portal.api.impl.portal.GroupSiteImpl;
import org.gatein.portal.api.impl.portal.PageImpl;
@@ -150,7 +150,7 @@
private UserPortalConfigService configService;
private Map<Type, Object> properties = new HashMap<Type, Object>(7);
private LifecycleManager lcManager = GateIn.NO_OP_MANAGER;
- private FederatingPortletInvoker portletInvoker;
+ private PortletInvoker portletInvoker;
public GateInImpl(ExoContainerContext context, InitParams params, ConfigurationManager
configurationManager, ExoKernelIntegration exoKernelIntegration)
{
@@ -663,7 +663,7 @@
gadgetService =
(GadgetRegistryService)container.getComponentInstanceOfType(GadgetRegistryService.class);
sourceStorage =
(SourceStorage)container.getComponentInstanceOfType(SourceStorage.class);
configService =
(UserPortalConfigService)container.getComponentInstanceOfType(UserPortalConfigService.class);
- portletInvoker =
(FederatingPortletInvoker)container.getComponentInstanceOfType(FederatingPortletInvoker.class);
+ portletInvoker =
(PortletInvoker)container.getComponentInstanceOfType(PortletInvoker.class);
}
public void stop()
@@ -691,7 +691,7 @@
return sourceStorage;
}
- public FederatingPortletInvoker getPortletInvoker()
+ public PortletInvoker getPortletInvoker()
{
return portletInvoker;
}
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-09-02
08:53:42 UTC (rev 7290)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-09-02
09:47:08 UTC (rev 7291)
@@ -34,6 +34,9 @@
import org.gatein.api.content.Portlet;
import org.gatein.api.content.WSRP;
import org.gatein.api.id.Id;
+import org.gatein.pc.api.PortletContext;
+import org.gatein.pc.api.PortletInvoker;
+import org.gatein.pc.api.PortletInvokerException;
import org.gatein.portal.api.impl.GateInImpl;
import org.gatein.portal.api.impl.portal.PortalImpl;
@@ -190,15 +193,27 @@
//
Class<C> type = id.getIdentifiableType();
- if (Portlet.class.equals(type))
+ if (Portlet.class.isAssignableFrom(type))
{
- throw new UnsupportedOperationException("todo for portlet");
+ try
+ {
+ Portlet.Id portletId = (Portlet.Id)(Content.Id)id;
+ PortletContext ctx = PortletContext.createPortletContext("local./"
+ portletId.getApplicationId() + "." + portletId.getPortletName());
+ PortletInvoker invoker = gateIn.getPortletInvoker();
+ org.gatein.pc.api.Portlet p = invoker.getPortlet(ctx);
+ Portlet portlet = new PortletImpl(p, gateIn);
+ return id.getIdentifiableType().cast(portlet);
+ }
+ catch (PortletInvokerException e)
+ {
+ return null;
+ }
}
- if (WSRP.class.equals(type))
+ if (WSRP.class.isAssignableFrom(type))
{
throw new UnsupportedOperationException("todo for wsrp");
}
- if (Gadget.class.equals(type))
+ if (Gadget.class.isAssignableFrom(type))
{
throw new UnsupportedOperationException("todo for gadget");
}
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java 2011-09-02
08:53:42 UTC (rev 7290)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java 2011-09-02
09:47:08 UTC (rev 7291)
@@ -39,7 +39,7 @@
{
super(
new Id(portlet.getInfo().getApplicationName(), portlet.getInfo().getName()),
- "todo?",
+ portlet.getInfo().getName(),
gateIn);
//
Modified:
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/AbstractAPITestCase.java
===================================================================
---
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/AbstractAPITestCase.java 2011-09-02
08:53:42 UTC (rev 7290)
+++
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/AbstractAPITestCase.java 2011-09-02
09:47:08 UTC (rev 7291)
@@ -19,6 +19,7 @@
import org.exoplatform.portal.pom.data.ModelDataStorage;
import org.exoplatform.web.application.RequestContext;
import org.gatein.api.GateIn;
+import org.gatein.pc.api.PortletInvoker;
/** @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a> */
@ConfiguredBy({
@@ -41,6 +42,9 @@
protected ModelDataStorage storage;
/** . */
+ protected PortletRegistry invoker;
+
+ /** . */
protected GateIn gatein;
@Override
@@ -53,6 +57,7 @@
POMSessionManager mgr =
(POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
NavigationService navService =
(NavigationService)container.getComponentInstanceOfType(NavigationService.class);
GateInImpl gatein = new GateInImpl(container.getContext(), null, null, null);
+ PortletRegistry invoker =
(PortletRegistry)container.getComponentInstanceOfType(PortletInvoker.class);
//
gatein.start();
@@ -65,6 +70,7 @@
this.mgr = mgr;
this.navService = navService;
this.storage =
(ModelDataStorage)container.getComponentInstanceOfType(ModelDataStorage.class);
+ this.invoker = invoker;
//
begin();
Added:
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/PortletRegistry.java
===================================================================
---
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/PortletRegistry.java
(rev 0)
+++
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/PortletRegistry.java 2011-09-02
09:47:08 UTC (rev 7291)
@@ -0,0 +1,20 @@
+package org.gatein.portal.api.impl;
+
+import org.gatein.pc.federation.impl.FederatingPortletInvokerService;
+import org.gatein.pc.portlet.support.PortletInvokerSupport;
+
+/** @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a> */
+public class PortletRegistry extends FederatingPortletInvokerService
+{
+
+ /** . */
+ public final PortletInvokerSupport localInvoker;
+
+ public PortletRegistry()
+ {
+ localInvoker = new PortletInvokerSupport();
+
+ //
+ registerInvoker("local", localInvoker);
+ }
+}
Modified:
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java
===================================================================
---
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java 2011-09-02
08:53:42 UTC (rev 7290)
+++
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java 2011-09-02
09:47:08 UTC (rev 7291)
@@ -4,6 +4,7 @@
import org.gatein.api.content.Category;
import org.gatein.api.content.ContentRegistry;
import org.gatein.api.content.Portlet;
+import org.gatein.pc.portlet.support.info.PortletInfoSupport;
import org.gatein.portal.api.impl.AbstractAPITestCase;
import java.util.Collections;
@@ -40,8 +41,13 @@
//
ContentRegistry registry = gatein.getDefaultPortal().getContentRegistry();
+ PortletInfoSupport info = new PortletInfoSupport();
+ info.setApplicationName("foo");
+ info.setName("bar");
+ invoker.localInvoker.addPortlet("/foo.bar", info);
//
- registry.getContent(new Portlet.Id("foo", "bar"));
+ Portlet portlet = registry.getContent(new Portlet.Id("foo",
"bar"));
+ assertEquals("bar", portlet.getName());
}
}
Modified:
portal/branches/api/component/api-impl/src/test/resources/org/gatein/portal/api/impl/configuration.xml
===================================================================
---
portal/branches/api/component/api-impl/src/test/resources/org/gatein/portal/api/impl/configuration.xml 2011-09-02
08:53:42 UTC (rev 7290)
+++
portal/branches/api/component/api-impl/src/test/resources/org/gatein/portal/api/impl/configuration.xml 2011-09-02
09:47:08 UTC (rev 7291)
@@ -25,6 +25,10 @@
http://www.exoplaform.org/xml/ns/kernel_1_2.xsd"
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd">
+ <component>
+ <type>org.gatein.portal.api.impl.PortletRegistry</type>
+ </component>
+
<external-component-plugins>
<target-component>org.exoplatform.application.registry.ApplicationRegistryService</target-component>
<component-plugin>