[jboss-cvs] jboss-portal/forums/src/main/org/jboss/portlet/forums/command/filter ...
Julien Viet
julien at jboss.com
Sun Aug 20 19:17:38 EDT 2006
User: julien
Date: 06/08/20 19:17:38
Added: forums/src/main/org/jboss/portlet/forums/command/filter
AbstractCommandFilter.java CommandFilter.java
CompositeFilter.java ExecuteFilter.java
Log:
move command framework for forums into the forums module
Revision Changes Path
1.1 date: 2006/08/20 23:17:38; author: julien; state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/filter/AbstractCommandFilter.java
Index: AbstractCommandFilter.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* 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.portlet.forums.command.filter;
import org.apache.log4j.Logger;
/**
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
public abstract class AbstractCommandFilter implements CommandFilter
{
protected final Logger log = Logger.getLogger(getClass());
private CommandFilter next;
public CommandFilter getNext()
{
return next;
}
public void setNext(CommandFilter next)
{
this.next = next;
}
}
1.1 date: 2006/08/20 23:17:38; author: julien; state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/filter/CommandFilter.java
Index: CommandFilter.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* 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.portlet.forums.command.filter;
import org.jboss.portlet.forums.command.result.Result;
import org.jboss.portlet.forums.command.Command;
import org.jboss.portlet.forums.command.CommandException;
/**
* A command filter which adds value around the command execution.
*
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
public interface CommandFilter
{
Result filter(Command command) throws CommandException;
void setNext(CommandFilter filter);
CommandFilter getNext();
}
1.1 date: 2006/08/20 23:17:38; author: julien; state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/filter/CompositeFilter.java
Index: CompositeFilter.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* 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.portlet.forums.command.filter;
import org.jboss.portlet.forums.command.Command;
import org.jboss.portlet.forums.command.CompositeCommand;
import org.jboss.portlet.forums.command.CommandException;
import org.jboss.portlet.forums.command.result.CompositeResult;
import org.jboss.portlet.forums.command.result.Result;
import java.util.Iterator;
/**
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
public class CompositeFilter extends AbstractCommandFilter
{
public Result filter(Command cmd) throws CommandException
{
if (cmd instanceof CompositeCommand)
{
CompositeResult result = new CompositeResult();
Iterator iterator = ((CompositeCommand)cmd).iterator();
while (iterator.hasNext())
{
result.addResult(getNext().filter((Command)iterator.next()));
}
return result;
}
else
{
return getNext().filter(cmd);
}
}
}
1.1 date: 2006/08/20 23:17:38; author: julien; state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/filter/ExecuteFilter.java
Index: ExecuteFilter.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* 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.portlet.forums.command.filter;
import org.jboss.portlet.forums.command.result.Result;
import org.jboss.portlet.forums.command.CommandException;
import org.jboss.portlet.forums.command.Command;
/**
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
public class ExecuteFilter extends AbstractCommandFilter
{
public Result filter(Command cmd) throws CommandException
{
Result result = cmd.execute();
// Allow post processing
if (getNext() != null)
{
getNext().filter(cmd);
}
return result;
}
}
More information about the jboss-cvs-commits
mailing list