You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bridges-commits@portals.apache.org by ta...@apache.org on 2005/11/22 04:51:39 UTC

svn commit: r348073 - /portals/bridges/trunk/velocity/src/java/org/apache/portals/bridges/velocity/AbstractVelocityMessagingPortlet.java

Author: taylor
Date: Mon Nov 21 19:51:38 2005
New Revision: 348073

URL: http://svn.apache.org/viewcvs?rev=348073&view=rev
Log:
little helper from velocity fw

Added:
    portals/bridges/trunk/velocity/src/java/org/apache/portals/bridges/velocity/AbstractVelocityMessagingPortlet.java

Added: portals/bridges/trunk/velocity/src/java/org/apache/portals/bridges/velocity/AbstractVelocityMessagingPortlet.java
URL: http://svn.apache.org/viewcvs/portals/bridges/trunk/velocity/src/java/org/apache/portals/bridges/velocity/AbstractVelocityMessagingPortlet.java?rev=348073&view=auto
==============================================================================
--- portals/bridges/trunk/velocity/src/java/org/apache/portals/bridges/velocity/AbstractVelocityMessagingPortlet.java (added)
+++ portals/bridges/trunk/velocity/src/java/org/apache/portals/bridges/velocity/AbstractVelocityMessagingPortlet.java Mon Nov 21 19:51:38 2005
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.bridges.velocity;
+
+import javax.portlet.PortletRequest;
+
+import org.apache.portals.bridges.velocity.GenericVelocityPortlet;
+import org.apache.portals.messaging.PortletMessaging;
+
+/**
+ * velocity abstract messaging portlet
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: AbstractVelocityMessagingPortlet.java,v 1.3 2005/03/23 06:24:38 david Exp $
+ */
+public abstract class AbstractVelocityMessagingPortlet extends GenericVelocityPortlet
+{
+    private String topic = null;
+    public static final String STATUS_MESSAGE = "statusMsg";
+    
+    protected boolean isEmpty(String s)
+    {
+        if (s == null)
+            return true;
+        
+        if (s.trim().length() == 0)
+            return true;
+        
+        return false;
+    }
+    
+    protected String getTopic()
+    {
+        return topic;
+    }
+    protected void setTopic(String topic)
+    {
+        this.topic = topic;
+    }
+    
+    protected void cancelRenderMessage(PortletRequest request, String message)
+    {
+        try
+        {
+            if (topic == null)
+                PortletMessaging.cancel(request, message);
+            else
+                PortletMessaging.cancel(request, topic, message);
+        }
+        catch (Exception e)
+        {}
+    }
+    
+    protected Object receiveRenderMessage(PortletRequest request, String message)
+    {
+        try
+        {
+            if (topic == null)
+                return PortletMessaging.receive(request, message);
+            else
+                return PortletMessaging.receive(request, topic, message);
+        }
+        catch (Exception e)
+        {}
+        return null;
+    }
+    
+    protected Object consumeRenderMessage(PortletRequest request, String message)
+    {
+        try
+        {
+            if (topic == null)
+                return PortletMessaging.consume(request, message);            
+            else
+                return PortletMessaging.consume(request, topic, message);            
+        }
+        catch (Exception e)
+        {}        
+        return null;
+    }
+    
+    protected void publishRenderMessage(PortletRequest request, String message, Object value)
+    {
+        try
+        {
+            if (topic == null)
+                PortletMessaging.publish(request, message, value);
+            else
+                PortletMessaging.publish(request, topic, message, value);
+        }
+        catch (Exception e)
+        {}
+    }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: bridges-commits-unsubscribe@portals.apache.org
For additional commands, e-mail: bridges-commits-help@portals.apache.org