[jbosscache-commits] JBoss Cache SVN: r6866 - in core/branches/flat/src/main/java/org/jboss/starobrno: commands and 1 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Wed Oct 8 07:29:20 EDT 2008
Author: mircea.markus
Date: 2008-10-08 07:29:20 -0400 (Wed, 08 Oct 2008)
New Revision: 6866
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ClearCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutMapCommand.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
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/Visitor.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java
Log:
_____ ____ ____
\/__/\ \ \ \L\ \\ \ \/\_\
_\ \ \ \ _ <'\ \ \/_/_
/\ \_\ \ \ \L\ \\ \ \L\ \
\ \____/\ \____/ \ \____/
\/___/ \/___/ \/___/
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-10-08 11:15:39 UTC (rev 6865)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-10-08 11:29:20 UTC (rev 6866)
@@ -40,6 +40,7 @@
{
// PutKeyValueCommand
InvocationContext ctx = invocationContextContainer.get();
+
return null;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/Visitor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/Visitor.java 2008-10-08 11:15:39 UTC (rev 6865)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/Visitor.java 2008-10-08 11:29:20 UTC (rev 6866)
@@ -22,27 +22,19 @@
package org.jboss.starobrno.commands;
import org.jboss.starobrno.context.InvocationContext;
-import org.jboss.starobrno.commands.write.PutKeyValueCommand;
+import org.jboss.starobrno.commands.write.*;
-/**
- * This interface is the core of JBoss Cache, where each {@link org.jboss.cache.commands.VisitableCommand} can be visited by a Visitor implementation.
- * Visitors which are accepted by the {@link org.jboss.cache.commands.VisitableCommand} are able to modify the command
- * based on any logic encapsulated by the visitor.
- *
- * @author Mircea.Markus at jboss.com
- * @author Manik Surtani
- * @since 2.2.0
- */
public interface Visitor
{
-
- /**
- * Visits a PutKeyValueCommand.
- *
- * @param ctx invocation context
- * @param command command to visit
- * @return response from the visit
- * @throws Throwable in the event of problems.
- */
Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable;
+
+ Object visitRemoveCommand(InvocationContext ctx, RemoveCommand removeCommand);
+
+ Object visitReplaceCommand(InvocationContext ctx, ReplaceCommand replaceCommand);
+
+ Object visitClearCommand(InvocationContext ctx, ClearCommand clearCommand);
+
+ Object visitPutMapCommand(InvocationContext ctx, PutMapCommand putMapCommand);
+
+ Object visitEvictCommand(InvocationContext ctx, Visitor visitor);
}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ClearCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ClearCommand.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ClearCommand.java 2008-10-08 11:29:20 UTC (rev 6866)
@@ -0,0 +1,62 @@
+/*
+ * 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.write;
+
+import org.jboss.starobrno.commands.VisitableCommand;
+import org.jboss.starobrno.commands.Visitor;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.util.NotImplementedException;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public class ClearCommand implements VisitableCommand
+{
+ public static final Object[] params = new Object[0];
+
+ public static final int METHOD_ID = 17;
+
+ public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+ {
+ return visitor.visitClearCommand(ctx, this);
+ }
+
+ public Object perform(InvocationContext ctx) throws Throwable
+ {
+ throw new NotImplementedException("Not Implemented");//todo implement
+ }
+
+ public Object[] getParameters()
+ {
+ return params;
+ }
+
+ public int getCommandId()
+ {
+ return METHOD_ID;
+ }
+
+ public void setParameters(int commandId, Object[] parameters)
+ {
+ if (commandId != METHOD_ID) throw new IllegalStateException("Invalid method id");
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java 2008-10-08 11:29:20 UTC (rev 6866)
@@ -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.write;
+
+import org.jboss.starobrno.commands.read.AbstractDataCommand;
+import org.jboss.starobrno.commands.Visitor;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.util.NotImplementedException;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public class EvictCommand extends AbstractDataCommand
+{
+ public static final int METHOD_ID = 3000;
+
+ public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+ {
+ return visitor.visitEvictCommand(ctx, visitor);
+ }
+
+ public Object perform(InvocationContext ctx) throws Throwable
+ {
+ throw new NotImplementedException("Not Implemented");//todo implement
+ }
+
+ public int getCommandId()
+ {
+ return METHOD_ID;
+ }
+}
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 11:15:39 UTC (rev 6865)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java 2008-10-08 11:29:20 UTC (rev 6866)
@@ -21,20 +21,11 @@
*/
package org.jboss.starobrno.commands.write;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.NodeNotExistsException;
-import org.jboss.cache.NodeSPI;
-
-import org.jboss.cache.notifications.event.NodeModifiedEvent;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.commands.read.AbstractDataCommand;
import org.jboss.starobrno.commands.Visitor;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.util.NotImplementedException;
-import java.util.Collections;
-import java.util.Map;
-
/**
* Implements functionality defined by {@link org.jboss.cache.Cache#put(org.jboss.cache.Fqn, Object, Object)}.
*
@@ -44,99 +35,33 @@
public class PutKeyValueCommand extends AbstractDataCommand
{
public static final int METHOD_ID = 3;
- public static final int VERSIONED_METHOD_ID = 39;
- private static final Log log = LogFactory.getLog(org.jboss.cache.commands.write.PutKeyValueCommand.class);
- private static final boolean trace = log.isTraceEnabled();
-
- /* parametres */
- protected Object key;
protected Object value;
- public PutKeyValueCommand(GlobalTransaction gtx, Object key, Object value)
- {
- this.key = key;
- this.value = value;
- }
-
- public PutKeyValueCommand()
- {
- }
-
- /**
- * Puts the specified key and value into the data map in the node referenced by the specified Fqn.
- *
- * @param ctx invocation context
- * @return the value being overwritten, if any, otherwise a null.
- */
- public Object perform(InvocationContext ctx)
- {
- if (trace) log.trace("Perform(, k='" + key + "', v='" + value + "')");
- return null;
- }
-
public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
{
return visitor.visitPutKeyValueCommand(ctx, this);
}
- public Object getKey()
+ public Object perform(InvocationContext ctx) throws Throwable
{
- return key;
+ throw new NotImplementedException("Not Implemented");//todo implement
}
- public Object getValue()
- {
- return value;
- }
-
- public void setKey(Object key)
- {
- this.key = key;
- }
-
- public void setValue(Object value)
- {
- this.value = value;
- }
-
public int getCommandId()
{
return METHOD_ID;
}
- @Override
public Object[] getParameters()
{
- return new Object[]{key, value, false};
+ return new Object[] {key, value};
}
- @Override
- public void setParameters(int commandId, Object[] args)
+ public void setParameters(int commandId, Object[] parameters)
{
- key = args[0];
- value = args[1];
+ if (commandId != METHOD_ID) throw new IllegalStateException("Invalid method id");
+ key = parameters[0];
+ value = parameters[1];
}
-
- public boolean equals(Object o)
- {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
-
- PutKeyValueCommand that = (PutKeyValueCommand) o;
-
- if (key != null ? !key.equals(that.key) : that.key != null) return false;
- if (value != null ? !value.equals(that.value) : that.value != null) return false;
-
- return true;
- }
-
- public int hashCode()
- {
- int result = super.hashCode();
- result = 31 * result + (key != null ? key.hashCode() : 0);
- result = 31 * result + (value != null ? value.hashCode() : 0);
- return result;
- }
}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutMapCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutMapCommand.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutMapCommand.java 2008-10-08 11:29:20 UTC (rev 6866)
@@ -0,0 +1,74 @@
+/*
+ * 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.write;
+
+import org.jboss.starobrno.commands.VisitableCommand;
+import org.jboss.starobrno.commands.Visitor;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.util.NotImplementedException;
+
+import java.util.Map;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public class PutMapCommand implements VisitableCommand
+{
+ public static final int METHOD_ID = 2000;
+
+ private Map map;
+
+ public PutMapCommand(Map map)
+ {
+ this.map = map;
+ }
+
+ public PutMapCommand()
+ {
+ }
+
+ public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+ {
+ return visitor.visitPutMapCommand(ctx, this);
+ }
+
+ public Object perform(InvocationContext ctx) throws Throwable
+ {
+ throw new NotImplementedException("Not Implemented");//todo implement
+ }
+
+ public int getCommandId()
+ {
+ return METHOD_ID;
+ }
+
+ public Object[] getParameters()
+ {
+ return new Object[] {map};
+ }
+
+ public void setParameters(int commandId, Object[] parameters)
+ {
+ if (commandId != METHOD_ID) throw new IllegalStateException("Invalid method id");
+ map = (Map) parameters[0];
+ }
+}
Added: 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 (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java 2008-10-08 11:29:20 UTC (rev 6866)
@@ -0,0 +1,51 @@
+/*
+ * 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.write;
+
+import org.jboss.starobrno.commands.read.AbstractDataCommand;
+import org.jboss.starobrno.commands.Visitor;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.util.NotImplementedException;
+
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public class RemoveCommand extends AbstractDataCommand
+{
+ public static final int METHOD_ID = 6;
+
+ public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+ {
+ return visitor.visitRemoveCommand(ctx, this);
+ }
+
+ public Object perform(InvocationContext ctx) throws Throwable
+ {
+ throw new NotImplementedException("Not Implemented");//todo implement
+ }
+
+ public int getCommandId()
+ {
+ return METHOD_ID;
+ }
+}
Added: 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 (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java 2008-10-08 11:29:20 UTC (rev 6866)
@@ -0,0 +1,78 @@
+/*
+ * 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.write;
+
+import org.jboss.starobrno.commands.read.AbstractDataCommand;
+import org.jboss.starobrno.commands.Visitor;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.util.NotImplementedException;
+
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public class ReplaceCommand extends AbstractDataCommand
+{
+ public static final int METHOD_ID = 99;
+
+ protected Object oldValue;
+ protected Object newValue;
+
+ public ReplaceCommand(Object key, Object oldValue, Object newValue)
+ {
+ super(key);
+ this.oldValue = oldValue;
+ this.newValue = newValue;
+ }
+
+ public ReplaceCommand()
+ {
+ }
+
+ public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+ {
+ return visitor.visitReplaceCommand(ctx, this);
+ }
+
+ public Object perform(InvocationContext ctx) throws Throwable
+ {
+ throw new NotImplementedException("Not Implemented");//todo implement
+ }
+
+ public int getCommandId()
+ {
+ return METHOD_ID;
+ }
+
+ public Object[] getParameters()
+ {
+ return new Object[] {key, oldValue, newValue};
+ }
+
+ public void setParameters(int commandId, Object[] parameters)
+ {
+ if (commandId != METHOD_ID) throw new IllegalArgumentException("Invalid method name");
+ key = parameters[0];
+ oldValue = parameters[1];
+ newValue = parameters[2];
+ }
+}
More information about the jbosscache-commits
mailing list