weaver 2003/10/17 12:57:26
Modified: portal/src/java/org/apache/jetspeed/services/entity
PortletEntityService.java PortletEntityAccess.java
PortletEntityServiceImpl.java
Log:
Refactoring of portlet entity service since PortletEntity is now persistent
Revision Changes Path
1.3 +5 -18
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityService.java
Index: PortletEntityService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityService.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PortletEntityService.java 6 Aug 2003 19:41:19 -0000 1.2
+++ PortletEntityService.java 17 Oct 2003 19:57:26 -0000 1.3
@@ -54,8 +54,7 @@
package org.apache.jetspeed.services.entity;
import org.apache.fulcrum.Service;
-import org.apache.jetspeed.om.common.entity.InitablePortletEntity;
-import org.apache.jetspeed.request.RequestContext;
+
import org.apache.pluto.om.common.ObjectID;
import org.apache.pluto.om.entity.PortletEntity;
import org.apache.pluto.om.portlet.PortletDefinition;
@@ -73,27 +72,15 @@
{
String SERVICE_NAME = "PortletEntityService";
- InitablePortletEntity getPortletEntity(ObjectID id);
+ PortletEntity getPortletEntity(ObjectID id);
- InitablePortletEntity getPortletEntity(PortletDefinition portletDefinition,
String portletName);
+ PortletEntity getPortletEntity(PortletDefinition portletDefinition, String
portletName);
void storePortletEntity(PortletEntity portletEntity);
void removePortletEntity(PortletEntity portletEntity);
- InitablePortletEntity newPortletEntityInstance();
+ PortletEntity newPortletEntityInstance(PortletDefinition portletDefinition);
- /**
- * Provides the thread-safe servicing of a request for this
<code>PortletEntity.</code>
- * <br/>
- * This should involve:
- * <ul>
- * <li>Intializing the user preferences</li>
- * </ul>
- *
- * @param request The @link{org.apache.jetspeed.request.RequestContext
RequestContext}
- * that this PortletEntity will service.
- */
- void serviceRequest(InitablePortletEntity portletEntity, RequestContext
request);
}
1.4 +6 -7
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityAccess.java
Index: PortletEntityAccess.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityAccess.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PortletEntityAccess.java 15 Aug 2003 00:27:54 -0000 1.3
+++ PortletEntityAccess.java 17 Oct 2003 19:57:26 -0000 1.4
@@ -53,9 +53,8 @@
*/
package org.apache.jetspeed.services.entity;
-import org.apache.jetspeed.om.common.entity.InitablePortletEntity;
-import org.apache.jetspeed.request.RequestContext;
import org.apache.jetspeed.util.ServiceUtil;
+import org.apache.pluto.om.entity.PortletEntity;
import org.apache.pluto.om.portlet.PortletDefinition;
/**
@@ -70,14 +69,14 @@
public class PortletEntityAccess
{
- public static InitablePortletEntity getEntity(PortletDefinition def, String
portletName)
+ public static PortletEntity getEntity(PortletDefinition def, String entityName)
{
- return getService().getPortletEntity(def, portletName);
+ return getService().getPortletEntity(def, entityName);
}
- public static void serviceRequest(InitablePortletEntity portletEntity,
RequestContext request)
+ public static void storePortletEntity(PortletEntity portletEntity)
{
- getService().serviceRequest(portletEntity, request);
+ getService().storePortletEntity(portletEntity);
}
protected static PortletEntityService getService()
1.7 +42 -24
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityServiceImpl.java
Index: PortletEntityServiceImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityServiceImpl.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- PortletEntityServiceImpl.java 10 Oct 2003 05:12:11 -0000 1.6
+++ PortletEntityServiceImpl.java 17 Oct 2003 19:57:26 -0000 1.7
@@ -57,13 +57,17 @@
import org.apache.fulcrum.BaseService;
import org.apache.fulcrum.InitializationException;
-import org.apache.jetspeed.om.common.entity.InitablePortletEntity;
import org.apache.jetspeed.om.entity.impl.PortletEntityImpl;
+import org.apache.jetspeed.persistence.LookupCriteria;
+import org.apache.jetspeed.persistence.PersistencePlugin;
+import org.apache.jetspeed.persistence.PersistenceService;
import org.apache.jetspeed.request.RequestContext;
import org.apache.jetspeed.util.ArgUtil;
import org.apache.jetspeed.util.JetspeedObjectID;
+import org.apache.jetspeed.util.ServiceUtil;
import org.apache.pluto.om.common.ObjectID;
import org.apache.pluto.om.entity.PortletEntity;
+import org.apache.pluto.om.entity.PortletEntityCtrl;
import org.apache.pluto.om.portlet.PortletDefinition;
/**
@@ -80,6 +84,8 @@
// TODO: this should eventually use a system cach like JCS
private HashMap entityCache = new HashMap();
+ private PersistencePlugin plugin;
+ private boolean autoCreateNewEntities;
/**
* @see org.apache.fulcrum.Service#init()
@@ -88,6 +94,10 @@
{
if (!isInitialized())
{
+ PersistenceService ps = (PersistenceService)
ServiceUtil.getServiceByName(PersistenceService.SERVICE_NAME);
+ String pluginName =
getConfiguration().getString("persistence.plugin.name", "jetspeed");
+ autoCreateNewEntities = getConfiguration().getBoolean("autocreate",
false);
+ plugin = ps.getPersistencePlugin(pluginName);
setInit(true);
}
@@ -96,31 +106,38 @@
/**
* @see
org.apache.jetspeed.services.entity.PortletEntityService#getPortletEntity(org.apache.pluto.om.common.ObjectID)
*/
- public InitablePortletEntity getPortletEntity(ObjectID id)
+ public PortletEntity getPortletEntity(ObjectID entityId)
{
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * @see
org.apache.jetspeed.services.entity.PortletEntityService#getPortletEntity(org.apache.jetspeed.request.RequestContext)
- */
- public InitablePortletEntity getPortletEntity(PortletDefinition
portletDefinition, String instanceName)
- {
- ObjectID entityId =
JetspeedObjectID.createPortletEntityId(portletDefinition, instanceName);
-
if (entityCache.containsKey(entityId))
{
- return (InitablePortletEntity) entityCache.get(entityId);
+ return (PortletEntity) entityCache.get(entityId);
}
else
{
- InitablePortletEntity portletEntity = newPortletEntityInstance();
- portletEntity.init(portletDefinition, instanceName);
+
+ LookupCriteria c = plugin.newLookupCriteria();
+ c.addEqualTo("oid", entityId);
+ Object q = plugin.generateQuery(PortletEntityImpl.class, c);
+ PortletEntity portletEntity = (PortletEntity)
plugin.getObjectByQuery(PortletEntityImpl.class, q);
+
entityCache.put(entityId, portletEntity);
return portletEntity;
}
+ }
+ /**
+ * @see
org.apache.jetspeed.services.entity.PortletEntityService#getPortletEntity(org.apache.jetspeed.request.RequestContext)
+ */
+ public PortletEntity getPortletEntity(PortletDefinition portletDefinition,
String entityName)
+ {
+ ObjectID entityId =
JetspeedObjectID.createPortletEntityId(portletDefinition, entityName);
+ PortletEntity portletEntity = getPortletEntity(entityId);
+ if (portletEntity == null)
+ {
+ portletEntity = newPortletEntityInstance(portletDefinition);
+ ((PortletEntityCtrl) portletEntity).setId(entityId.toString());
+ }
+ return portletEntity;
}
/**
@@ -128,7 +145,7 @@
*/
public void storePortletEntity(PortletEntity portletEntity)
{
- // TODO Auto-generated method stub
+ plugin.update(portletEntity);
}
@@ -137,22 +154,23 @@
*/
public void removePortletEntity(PortletEntity portletEntity)
{
- // TODO Auto-generated method stub
-
+ plugin.delete(portletEntity);
}
/**
* @see
org.apache.jetspeed.services.entity.PortletEntityService#newPortletEntityInstance()
*/
- public InitablePortletEntity newPortletEntityInstance()
+ public PortletEntity newPortletEntityInstance(PortletDefinition
portletDefinition)
{
// TODO: need to be made configurable
- return new PortletEntityImpl();
+ PortletEntityImpl portletEntity = new PortletEntityImpl();
+ portletEntity.setPortletDefinition(portletDefinition);
+ return portletEntity;
}
- public void serviceRequest(InitablePortletEntity portletEntity, RequestContext
request)
+ public void serviceRequest(PortletEntity portletEntity, RequestContext request)
{
- ArgUtil.notNull(new Object[] { portletEntity, request }, new String[] {
"portletEntity", "request" }, "serviceRequest()");
+ ArgUtil.notNull(new Object[] { portletEntity, request }, new String[] {
"portletEntity", "request" }, "serviceRequest()");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]