[jbosscache-commits] JBoss Cache SVN: r6873 - in core/branches/flat/src/main/java/org/jboss/starobrno/commands: read and 1 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Oct 8 09:59:45 EDT 2008


Author: mircea.markus
Date: 2008-10-08 09:59:44 -0400 (Wed, 08 Oct 2008)
New Revision: 6873

Added:
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
Modified:
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java
Log:
  _____  ____     ____
 \/__/\ \ \ \L\ \\ \ \/\_\
    _\ \ \ \  _ <'\ \ \/_/_
   /\ \_\ \ \ \L\ \\ \ \L\ \
   \ \____/\ \____/ \ \____/
    \/___/  \/___/   \/___/

Added: core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java	2008-10-08 13:59:44 UTC (rev 6873)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.jboss.starobrno.commands;
+
+import org.jboss.starobrno.commands.write.*;
+import org.jboss.starobrno.commands.read.SizeCommand;
+import org.jboss.starobrno.commands.read.GetKeyValueCommand;
+
+import java.util.Map;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public interface CommandsFactory
+{
+   PutKeyValueCommand buildPutKeyValueCommand(Object key, Object value);
+
+   RemoveCommand buildRemoveCommand(Object key, Object value);
+
+   ReplaceCommand buildReplaceCommand(Object key, Object oldValue, Object newValue);
+
+   SizeCommand buildSizeCommand();
+
+   GetKeyValueCommand buildGetKeyValueCommand(Object key);
+
+   PutMapCommand buildPutMapCommand(Map t);
+
+   ClearCommand buildClearCommand();
+
+   EvictCommand buildEvictCommand(Object key);
+}

Added: core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java	2008-10-08 13:59:44 UTC (rev 6873)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.jboss.starobrno.commands;
+
+import org.jboss.starobrno.commands.write.*;
+import org.jboss.starobrno.commands.read.SizeCommand;
+import org.jboss.starobrno.commands.read.GetKeyValueCommand;
+import org.jboss.starobrno.DataContainer;
+import org.jboss.starobrno.notifier.Notifier;
+
+import java.util.Map;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public class CommandsFactoryImpl implements CommandsFactory
+{
+   private DataContainer dataContainer;
+   private Notifier notifier;
+
+   public PutKeyValueCommand buildPutKeyValueCommand(Object key, Object value)
+   {
+      return new PutKeyValueCommand(key, value, false);
+   }
+
+   public RemoveCommand buildRemoveCommand(Object key, Object value)
+   {
+      return new RemoveCommand(key, value);
+   }
+
+   public ReplaceCommand buildReplaceCommand(Object key, Object oldValue, Object newValue)
+   {
+      return new ReplaceCommand(key, oldValue, newValue);
+   }
+
+   public SizeCommand buildSizeCommand()
+   {
+      return new SizeCommand(dataContainer);
+   }
+
+   public GetKeyValueCommand buildGetKeyValueCommand(Object key)
+   {
+      return new GetKeyValueCommand(key, notifier);
+   }
+
+   public PutMapCommand buildPutMapCommand(Map map)
+   {
+      return new PutMapCommand(map);
+   }
+
+   public ClearCommand buildClearCommand()
+   {
+      return new ClearCommand();
+   }
+
+   public EvictCommand buildEvictCommand(Object key)
+   {
+      return new EvictCommand();
+   }
+}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java	2008-10-08 13:26:45 UTC (rev 6872)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java	2008-10-08 13:59:44 UTC (rev 6873)
@@ -23,10 +23,10 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.notifications.Notifier;
 import org.jboss.starobrno.commands.Visitor;
 import org.jboss.starobrno.context.InvocationContext;
 import org.jboss.starobrno.mvcc.MVCCEntry;
+import org.jboss.starobrno.notifier.Notifier;
 
 /**
  * // TODO: MANIK: Document this
@@ -70,7 +70,7 @@
       Object result = entry.getValue();
       if (trace) log.trace("Found value " + result);
 //      if (sendNodeEvent) notifier.notifyNodeVisited(fqn, false, ctx);
-      return result;
+      return  result;
    }
 
    public int getCommandId()

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java	2008-10-08 13:26:45 UTC (rev 6872)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java	2008-10-08 13:59:44 UTC (rev 6873)
@@ -46,7 +46,7 @@
       return visitor.visitSizeCommand(ctx, this);
    }
 
-   public Object perform(InvocationContext ctx) throws Throwable
+   public Integer perform(InvocationContext ctx) throws Throwable
    {
       return container.size();
    }

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java	2008-10-08 13:26:45 UTC (rev 6872)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java	2008-10-08 13:59:44 UTC (rev 6873)
@@ -37,7 +37,15 @@
    public static final int METHOD_ID = 3;
 
    protected Object value;
+   protected boolean putIfAbsent;
 
+   public PutKeyValueCommand(Object key, Object value, boolean putIfAbsent)
+   {
+      super(key);
+      this.value = value;
+      this.putIfAbsent = putIfAbsent;
+   }
+
    public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
    {
       return visitor.visitPutKeyValueCommand(ctx, this);
@@ -65,4 +73,14 @@
       key = parameters[0];
       value = parameters[1];
    }
+
+   public boolean isPutIfAbsent()
+   {
+      return putIfAbsent;
+   }
+
+   public void setPutIfAbsent(boolean putIfAbsent)
+   {
+      this.putIfAbsent = putIfAbsent;
+   }
 }
\ No newline at end of file

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java	2008-10-08 13:26:45 UTC (rev 6872)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java	2008-10-08 13:59:44 UTC (rev 6873)
@@ -34,12 +34,20 @@
 {
    public static final int METHOD_ID = 6;
 
+   protected Object value;
+
+   public RemoveCommand(Object key, Object value)
+   {
+      super(key);
+      this.value = value;
+   }
+
    public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
    {
       return visitor.visitRemoveCommand(ctx, this);
    }
 
-   public Object perform(InvocationContext ctx) throws Throwable
+   public Boolean perform(InvocationContext ctx) throws Throwable
    {
       MVCCEntry e = ctx.lookupEntry(key);
       if (e == null || e.isNullEntry()) return false;

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java	2008-10-08 13:26:45 UTC (rev 6872)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java	2008-10-08 13:59:44 UTC (rev 6873)
@@ -53,7 +53,7 @@
       return visitor.visitReplaceCommand(ctx, this);
    }
 
-   public Object perform(InvocationContext ctx) throws Throwable
+   public Boolean perform(InvocationContext ctx) throws Throwable
    {
       MVCCEntry e = ctx.lookupEntry(key);
       if (e == null || e.isNullEntry()) return false;




More information about the jbosscache-commits mailing list