[jboss-svn-commits] JBL Code SVN: r18381 - in labs/jbossforums/branches/multipleforums110P26: cache-plugin and 8 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Feb 7 13:35:11 EST 2008


Author: sviluppatorefico
Date: 2008-02-07 13:35:11 -0500 (Thu, 07 Feb 2008)
New Revision: 18381

Added:
   labs/jbossforums/branches/multipleforums110P26/cache-plugin/
   labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/
   labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/
   labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/
   labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/
   labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/
   labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/
   labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/
   labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/
   labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/AbstractJBossService.java
   labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/JBossTreeCacheProvider.java
   labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/JBossTreeCacheProviderMBean.java
   labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/JMXTreeCacheProvider.java
   labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/TreeCacheProvider.java
Log:
plugin for clusterized forums. It contains jboss cache implementation and a JMX service

Added: labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/AbstractJBossService.java
===================================================================
--- labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/AbstractJBossService.java	                        (rev 0)
+++ labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/AbstractJBossService.java	2008-02-07 18:35:11 UTC (rev 18381)
@@ -0,0 +1,74 @@
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.util.cache;
+
+import org.jboss.logging.Logger;
+import org.jboss.system.ServiceMBeanSupport;
+
+/**
+ * JBoss service integration helper.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:jedim at vige.it">Luca Stancapiano</a>
+ * @version $Revision: 8784 $
+ */
+public class AbstractJBossService extends ServiceMBeanSupport
+{
+
+   public AbstractJBossService()
+   {
+   }
+
+   public AbstractJBossService(final Class type)
+   {
+      super(type);
+   }
+
+   public AbstractJBossService(final String category)
+   {
+      super(category);
+   }
+
+   public AbstractJBossService(final Logger log)
+   {
+      super(log);
+   }
+
+   public final int getState()
+   {
+      return super.getState();
+   }
+
+   public final String getStateString()
+   {
+      return super.getStateString();
+   }
+
+   public final void create() throws Exception
+   {
+      super.create();
+   }
+
+   public final void start() throws Exception
+   {
+      super.start();
+   }
+
+   public final void stop()
+   {
+      super.stop();
+   }
+
+   public final void destroy()
+   {
+      super.destroy();
+   }
+}


Property changes on: labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/AbstractJBossService.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/JBossTreeCacheProvider.java
===================================================================
--- labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/JBossTreeCacheProvider.java	                        (rev 0)
+++ labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/JBossTreeCacheProvider.java	2008-02-07 18:35:11 UTC (rev 18381)
@@ -0,0 +1,49 @@
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.util.cache;
+
+import org.jboss.cache.TreeCache;
+
+import javax.management.ObjectName;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:jedim at vige.it">Luca Stancapiano</a>
+ * @version $Revision: 8784 $
+ */
+public class JBossTreeCacheProvider extends AbstractJBossService implements TreeCacheProvider, JBossTreeCacheProviderMBean
+{
+
+   private ObjectName cacheName;
+
+   public ObjectName getCacheName()
+   {
+      return cacheName;
+   }
+
+   public void setCacheName(ObjectName cacheName)
+   {
+      this.cacheName = cacheName;
+   }
+
+   public TreeCache getTreeCache()
+   {
+      try
+      {
+         return (TreeCache)server.getAttribute(cacheName, "Instance");
+      }
+      catch (Exception e)
+      {
+         log.error("Cannot get cache instance", e);
+         return null;
+      }
+   }
+}


Property changes on: labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/JBossTreeCacheProvider.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/JBossTreeCacheProviderMBean.java
===================================================================
--- labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/JBossTreeCacheProviderMBean.java	                        (rev 0)
+++ labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/JBossTreeCacheProviderMBean.java	2008-02-07 18:35:11 UTC (rev 18381)
@@ -0,0 +1,27 @@
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.util.cache;
+
+import org.jboss.cache.TreeCache;
+
+import javax.management.ObjectName;
+
+/**
+ */
+public interface JBossTreeCacheProviderMBean
+{
+
+   public ObjectName getCacheName();
+
+   public void setCacheName(ObjectName cacheName);
+
+   public TreeCache getTreeCache();
+}


Property changes on: labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/JBossTreeCacheProviderMBean.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/JMXTreeCacheProvider.java
===================================================================
--- labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/JMXTreeCacheProvider.java	                        (rev 0)
+++ labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/JMXTreeCacheProvider.java	2008-02-07 18:35:11 UTC (rev 18381)
@@ -0,0 +1,90 @@
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.util.cache;
+
+import org.apache.log4j.Logger;
+import org.hibernate.cache.Cache;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CacheProvider;
+import org.hibernate.cache.OptimisticTreeCache;
+import org.hibernate.cache.TreeCache;
+import org.jboss.mx.util.MBeanProxy;
+import org.jboss.mx.util.MBeanServerLocator;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:jedim at vige.it">Luca Stancapiano</a>
+ * @version $Revision: 9318 $
+ */
+public class JMXTreeCacheProvider implements CacheProvider
+{
+
+   /** Our logger. */
+   private static final Logger log = Logger.getLogger(JMXTreeCacheProvider.class);
+
+   public boolean isMinimalPutsEnabledByDefault()
+   {
+      return true;
+   }
+
+   public Cache buildCache(String regionName, Properties properties) throws CacheException
+   {
+      try
+      {
+         String objectNameAsString = properties.getProperty("hibernate.cache.object_name");
+         log.debug("Uses tree cache provider with object name " + objectNameAsString);
+
+         //
+         ObjectName providerName = ObjectName.getInstance(objectNameAsString);
+
+         //
+         MBeanServer server = MBeanServerLocator.locateJBoss();
+         TreeCacheProvider provider = (TreeCacheProvider)MBeanProxy.get(TreeCacheProvider.class, providerName, server);
+         org.jboss.cache.TreeCache cache = provider.getTreeCache();
+         
+         //Select the proper type of hibernate cache to be used
+         Cache hibernateCache = null;
+         if(cache.getNodeLockingScheme().equalsIgnoreCase("OPTIMISTIC"))
+         {
+            log.debug("Selecting Optimistic Cache");
+            hibernateCache = new OptimisticTreeCache(cache, regionName);
+         }
+         else
+         {            
+            log.debug("Selecting regular Tree Cache");
+            hibernateCache = new TreeCache(cache, regionName, cache.getTransactionManager());
+         }
+         
+         return hibernateCache;
+      }
+      catch (Exception e)
+      {
+         throw new CacheException(e);
+      }
+   }
+
+   public long nextTimestamp()
+   {
+      return System.currentTimeMillis() / 100;
+   }
+
+   public void start(Properties properties) throws CacheException
+   {
+   }
+
+   public void stop()
+   {
+   }
+}


Property changes on: labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/JMXTreeCacheProvider.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/TreeCacheProvider.java
===================================================================
--- labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/TreeCacheProvider.java	                        (rev 0)
+++ labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/TreeCacheProvider.java	2008-02-07 18:35:11 UTC (rev 18381)
@@ -0,0 +1,26 @@
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.util.cache;
+
+import org.jboss.cache.TreeCache;
+
+/**
+ * Provide a tree cache. <code>org.jboss.cache.TreeCache</code> is a concrete class and cannot be proxy injected. This
+ * interface enable injection and gives a way to the dependant to retrieve the cache.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:jedim at vige.it">Luca Stancapiano</a>
+ * @version $Revision: 8784 $
+ */
+public interface TreeCacheProvider
+{
+   TreeCache getTreeCache();
+}


Property changes on: labs/jbossforums/branches/multipleforums110P26/cache-plugin/src/main/org/jboss/portlet/forums/util/cache/TreeCacheProvider.java
___________________________________________________________________
Name: svn:executable
   + *




More information about the jboss-svn-commits mailing list