Author: chris.laprun(a)jboss.com
Date: 2011-07-26 11:30:55 -0400 (Tue, 26 Jul 2011)
New Revision: 6931
Added:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/LifecycleManager.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/NoOpLifecycleManager.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/RequestLifecycleManager.java
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
Log:
- Added LifecycleManager interface to decouple lifecycle management (needed for JCR
access) from GateIn itself. By default, GateIn uses the NoOpLifecycleManager since
lifecycle will be automatically managed in a portlet environment. However, in the context
of an extension, it might be needed to provide manual lifecycle management using
RequestLifecycleManager for example.
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-07-26
12:45:24 UTC (rev 6930)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-07-26
15:30:55 UTC (rev 6931)
@@ -27,7 +27,6 @@
import org.exoplatform.application.registry.ApplicationRegistryService;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.container.component.RequestLifeCycle;
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.portal.config.Query;
@@ -58,6 +57,7 @@
import org.gatein.api.util.IterableIdentifiableCollection;
import org.gatein.api.util.Type;
import org.gatein.common.util.ParameterValidation;
+import org.gatein.portal.api.impl.lifecycle.NoOpLifecycleManager;
import org.gatein.portal.api.impl.portal.GroupSiteImpl;
import org.gatein.portal.api.impl.portal.PageImpl;
import org.gatein.portal.api.impl.portal.PortalImpl;
@@ -70,7 +70,7 @@
import java.util.regex.Pattern;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
-public class GateInImpl implements GateIn, Startable
+public class GateInImpl implements GateIn, Startable, LifecycleManager
{
private static final Query<PortalData> PORTALS = new
Query<PortalData>(SiteType.PORTAL.getName(), null, PortalData.class);
private static final Query<DashboardData> DASHBOARDS = new
Query<DashboardData>(SiteType.USER.getName(), null, DashboardData.class);
@@ -103,12 +103,18 @@
private ApplicationRegistryService registryService;
private GadgetRegistryService gadgetService;
private SourceStorage sourceStorage;
+ private LifecycleManager lcManager = new NoOpLifecycleManager();
public GateInImpl(ExoContainerContext context, InitParams params, ConfigurationManager
configurationManager)
{
container = context.getContainer();
}
+ public void setLifecycleManager(LifecycleManager lcManager)
+ {
+ this.lcManager = lcManager;
+ }
+
public IterableIdentifiableCollection<Portal> getPortals()
{
try
@@ -139,11 +145,6 @@
}
}
- public void end()
- {
- RequestLifeCycle.end();
- }
-
public Portal getPortal(Id<Portal> portalId)
{
PortalData portalData = getPortalDataFor(portalId);
@@ -376,9 +377,14 @@
public void begin()
{
- RequestLifeCycle.begin(container);
+ lcManager.begin();
}
+ public void end()
+ {
+ lcManager.end();
+ }
+
public GadgetRegistryService getGadgetService()
{
return gadgetService;
Added:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/LifecycleManager.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/LifecycleManager.java
(rev 0)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/LifecycleManager.java 2011-07-26
15:30:55 UTC (rev 6931)
@@ -0,0 +1,31 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.portal.api.impl;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public interface LifecycleManager
+{
+ void begin();
+
+ void end();
+}
Added:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/NoOpLifecycleManager.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/NoOpLifecycleManager.java
(rev 0)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/NoOpLifecycleManager.java 2011-07-26
15:30:55 UTC (rev 6931)
@@ -0,0 +1,40 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.portal.api.impl.lifecycle;
+
+import org.gatein.portal.api.impl.LifecycleManager;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class NoOpLifecycleManager implements LifecycleManager
+{
+
+ public void begin()
+ {
+ // do nothing
+ }
+
+ public void end()
+ {
+ // do nothing
+ }
+}
Added:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/RequestLifecycleManager.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/RequestLifecycleManager.java
(rev 0)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/lifecycle/RequestLifecycleManager.java 2011-07-26
15:30:55 UTC (rev 6931)
@@ -0,0 +1,48 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.portal.api.impl.lifecycle;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.component.RequestLifeCycle;
+import org.gatein.portal.api.impl.LifecycleManager;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class RequestLifecycleManager implements LifecycleManager
+{
+ private final ExoContainer container;
+
+ public RequestLifecycleManager(ExoContainer container)
+ {
+ this.container = container;
+ }
+
+ public void begin()
+ {
+ RequestLifeCycle.begin(container);
+ }
+
+ public void end()
+ {
+ RequestLifeCycle.end();
+ }
+}