From: <ju...@jb...> - 2005-05-16 12:55:32
|
unless you put the jar in the lib or deploy directory of JBoss and not in the war files, in that case the scope would be per VM using tree cache replicated would be a good idea too but needs more work to put in place. View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3877829#3877829 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3877829 |
From: dajevtic <nu...@jb...> - 2005-05-16 13:35:00
|
Sorry, the above articles were posted while I was editing my post, so I didn't see that other answers were already provided. I agree that tree cache replicated would be a good solution. View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3877836#3877836 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3877836 |
From: dajevtic <nu...@jb...> - 2005-05-16 18:58:16
|
Hello there, I'm back with some news regarding Interportlet Communication. I've tested the PortletFormManager with the per webapp class loader and it produces the same results as the JbossWebLoader. So there shouldn't be any problems, because the class is explicitly declared to be singleton. As expected, a disitributed environment does not work. I therefore tested the 3 possible solutions: persistence, web service and TreeCacheAOP. They all work fine in a distributed environemt, however I'm still dealing with some security issues. I will run some further tests about performance, as well. If anoyone is interested I'll post the results in this forum?! Regards, dj View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3877873#3877873 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3877873 |
From: dajevtic <nu...@jb...> - 2005-05-16 21:39:01
|
Ok, I'm familiar with the SessionManager integration. I would be glad to create a portlet communication manager using this kind of integration. Do you have any specifications about what the Interportlet Comm Manager is supposed to do, or should I provide my own specification? With your permission, I would be glad to provide you with this manager using JBoss coding guidelines, etc. View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3877901#3877901 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3877901 |
From: <ju...@jb...> - 2005-05-16 23:18:08
|
actually you seem to have more insight than my on the subject so far, so come with your design and your code View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3877923#3877923 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3877923 |
From: <ju...@jb...> - 2005-05-17 02:47:55
|
I would prefer TreeCache (Aop or not), you can look at the code integrating tomcat SessionManager to see how they do it. View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3877897#3877897 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3877897 |
From: dajevtic <nu...@jb...> - 2005-05-17 04:04:24
|
In order to make it work for portlets within seperate webapps, the PortletFormManager.jar should be deployed to the "jboss-portal.sar\lib" directory. Then distributed webapp's portlets can use it without any problem. I have to check the behavior in a distributed environment, but I doubt that it will work, unless I use one of the two possibilities: 1.) Implement persistence for form data or 2.) Make the PortletFormManager a web service which receives and sends data via http But I will check so that I can give a 100% educated answer View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3877833#3877833 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3877833 |
From: dajevtic <nu...@jb...> - 2005-05-17 13:02:42
|
Ok, will do. For now I am posting the two portlets I wrote yesterday, in order to check TreeCache functionality for inter portlet communication. It is quick and dirty, so please ignore the fact that this is not production ready code. Maybe it will give some insight to others, who are thinking about implementing interportlet communication. Any constructive criticism is more than welcome. I want to use a Wrapper class so that the portlets themselves do not have to access (and configure connection) to the Cache itself. DoCachePortlet Source code: import java.io.IOException; import java.io.PrintWriter; import java.security.Principal; import java.util.Map; import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.GenericPortlet; import javax.portlet.PortletConfig; import javax.portlet.PortletException; import javax.portlet.PortletSecurityException; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import org.jboss.cache.CacheException; import org.jboss.cache.TreeCacheMBean; import org.jboss.mx.util.MBeanProxyExt; import org.jboss.mx.util.MBeanServerLocator; /** * XDoclet generated portlet description * * @portlet.portlet * description="This portlet displays a form with 3 text fields an a submit button." * display-name="DoCachePortlet" * expiration-cache="0" * name="DoCachePortlet" * * @portlet.portlet-init-param * name="CacheService" * value="jboss.cache:service=TreeCache" * * @portlet.portlet-info * title="CacheInputForm" * * @portlet.supports * mime-type="text/html" * modes="VIEW" * * @author Danijel Jevtic <danijel_point_jevtic_at_livemediagroup_dot_de> * @version 1.0 */ public class DoCachePortlet extends GenericPortlet { private String cacheService; private MBeanServer server; private TreeCacheMBean cache; private static final String CONTENT_TYPE = "text/html"; public void init(PortletConfig config) throws PortletException { super.init(config); // cacheService e.g. 'jboss.cache:service=TreeCache' cacheService = getInitParameter("CacheService"); if (cacheService == null) { throw new PortletException("No cache defined"); } // locate MBeanServer server = MBeanServerLocator.locate(); try { // get the tree cache cache=(TreeCacheMBean)MBeanProxyExt.create(TreeCacheMBean.class, cacheService, server); } catch (MalformedObjectNameException mone) { throw new PortletException(mone); } } public void doView(RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException { response.setContentType(CONTENT_TYPE); PrintWriter out = response.getWriter(); out.print("<form name=\"somename\" method=\"post\" action=\"" + response.createActionURL() + "\">"); out.print("<input type=\"text\" name=\"input1\"/>"); out.print("<input type=\"text\" name=\"input2\"/>"); out.print("<input type=\"text\" name=\"input3\"/>"); out.print("<input type=\"submit\"/>"); out.print(""); } public void processAction(ActionRequest request, ActionResponse response) throws PortletException, PortletSecurityException, IOException { String tree; Principal user = request.getUserPrincipal(); if (user == null) { tree = request.getPortletSession().getId() + "/" + getPortletName(); } else { tree = user.getName() + "/" + getPortletName(); } try { writeToCache(tree, request.getParameterMap()); } catch (CacheException ce) { throw new PortletException(ce); } } private void clearCache(String id) throws CacheException { cache.remove("/" + id); } private void writeToCache(String id, Map parameterMap) throws CacheException { clearCache(id); cache.put("/" + id, parameterMap); } } DoReceivePortlet source code: import java.io.IOException; import java.io.PrintWriter; import java.security.Principal; import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; import java.util.Set; import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.portlet.GenericPortlet; import javax.portlet.PortletConfig; import javax.portlet.PortletException; import javax.portlet.PortletSecurityException; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import org.jboss.cache.CacheException; import org.jboss.cache.TreeCacheMBean; import org.jboss.mx.util.MBeanProxyExt; import org.jboss.mx.util.MBeanServerLocator; /** * XDoclet generated portlet description * * @portlet.portlet * description="This portlet displays the form previous form posts." * display-name="DoReceivePortlet" * expiration-cache="0" * name="DoReceivePortlet" * * @portlet.portlet-init-param * name="CacheService" * value="jboss.cache:service=TreeCache" * * @portlet.portlet-info * title="CacheDisplay" * * @portlet.supports * mime-type="text/html" * modes="VIEW" * * @author Danijel Jevtic <danijel_point_jevtic_at_livemediagroup_dot_de> * @version 1.0 */ public class DoReceivePortlet extends GenericPortlet { private static final String CONTENT_TYPE = "text/html"; // the name of the portlet which posted the form values private static final String TRUSTED_PORTLET_NAME = "DoCachePortlet"; private String cacheService; private MBeanServer server; private TreeCacheMBean cache; public void init(PortletConfig config) throws PortletException { super.init(config); // cacheService e.g. 'jboss.cache:service=TreeCache' cacheService = getInitParameter("CacheService"); if (cacheService == null) { throw new PortletException("No cache defined"); } // locate MBeanServer server = MBeanServerLocator.locate(); try { // get the tree cache cache=(TreeCacheMBean)MBeanProxyExt.create(TreeCacheMBean.class, cacheService, server); } catch (MalformedObjectNameException mone) { throw new PortletException(mone); } } public void doView(RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException { String sessionId = request.getPortletSession().getId(); response.setContentType(CONTENT_TYPE); PrintWriter out = response.getWriter(); Hashtable parameters; String tree; Principal user = request.getUserPrincipal(); if (user == null) { out.print("Using your session ID for parameter storage"); tree = request.getPortletSession().getId() + "/" + TRUSTED_PORTLET_NAME; } else { out.print("Using your user name for parameter storage"); tree = user.getName() + "/" + TRUSTED_PORTLET_NAME; } try { parameters = getParameters(tree); } catch (CacheException ce) { throw new PortletException(ce); } if (!parameters.isEmpty()) { out.print("You entered the following form parameters:"); Enumeration keys = parameters.keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); String[] value = (String[])parameters.get(key); out.print(key + " = " + value[0] + ""); } } else { out.print("The cache was empty. You probably haven't filled it yet!"); } } private Hashtable getParameters(String id) throws CacheException { Hashtable parameters = new Hashtable(); Set set = cache.getKeys("/" + id); if (set != null) { Iterator setIterator = set.iterator(); while (setIterator.hasNext()) { String key = (String)setIterator.next(); parameters.put(key, cache.get("/" + id, key)); } } clearCache(id); return parameters; } private void clearCache(String id) throws CacheException { cache.remove("/" + id); } } View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3877994#3877994 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3877994 |