001 /* 002 * JBoss, Home of Professional Open Source. 003 * Copyright 2008, Red Hat Middleware LLC, and individual contributors 004 * as indicated by the @author tags. See the copyright.txt file in the 005 * distribution for a full listing of individual contributors. 006 * 007 * This is free software; you can redistribute it and/or modify it 008 * under the terms of the GNU Lesser General Public License as 009 * published by the Free Software Foundation; either version 2.1 of 010 * the License, or (at your option) any later version. 011 * 012 * This software is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * You should have received a copy of the GNU Lesser General Public 018 * License along with this software; if not, write to the Free 019 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 020 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 021 */ 022 package org.jboss.dna.graph.commands.executor; 023 024 import org.jboss.dna.graph.commands.CompositeCommand; 025 import org.jboss.dna.graph.commands.CopyBranchCommand; 026 import org.jboss.dna.graph.commands.CopyNodeCommand; 027 import org.jboss.dna.graph.commands.CreateNodeCommand; 028 import org.jboss.dna.graph.commands.DeleteBranchCommand; 029 import org.jboss.dna.graph.commands.GetChildrenCommand; 030 import org.jboss.dna.graph.commands.GetNodeCommand; 031 import org.jboss.dna.graph.commands.GetPropertiesCommand; 032 import org.jboss.dna.graph.commands.GraphCommand; 033 import org.jboss.dna.graph.commands.MoveBranchCommand; 034 import org.jboss.dna.graph.commands.RecordBranchCommand; 035 import org.jboss.dna.graph.commands.SetPropertiesCommand; 036 import org.jboss.dna.graph.connectors.RepositorySourceException; 037 038 /** 039 * @author Randall Hauch 040 */ 041 public interface CommandExecutor { 042 043 /** 044 * Execute a graph command. This method should examine the command's types to determine which other <code>execute</code> 045 * methods should be called, and should then call those methods. This method should also do nothing if the command is null. 046 * 047 * @param command the command to be executed 048 * @throws RepositorySourceException if there is an error executing the command 049 */ 050 void execute( GraphCommand command ) throws RepositorySourceException; 051 052 /** 053 * Execute a composite command that contains other commands. This method should simply obtain and execute each of the nested 054 * commands. 055 * 056 * @param command the command to be executed; may not be null 057 * @throws RepositorySourceException if there is an error executing the command 058 */ 059 void execute( CompositeCommand command ) throws RepositorySourceException; 060 061 /** 062 * Execute a command to get the properties and children of a node. {@link GetNodeCommand} is a subtype of both 063 * {@link GetPropertiesCommand} and {@link GetChildrenCommand}, so this method will be called in place of the 064 * {@link #execute(GetPropertiesCommand)} and {@link #execute(GetChildrenCommand)} methods. 065 * 066 * @param command the command to be executed; may not be null 067 * @throws RepositorySourceException if there is an error executing the command 068 */ 069 void execute( GetNodeCommand command ) throws RepositorySourceException; 070 071 /** 072 * Execute a command to get the properties of a node. 073 * 074 * @param command the command to be executed; may not be null 075 * @throws RepositorySourceException if there is an error executing the command 076 */ 077 void execute( GetPropertiesCommand command ) throws RepositorySourceException; 078 079 /** 080 * Execute a command to get the children of a node. 081 * 082 * @param command the command to be executed; may not be null 083 * @throws RepositorySourceException if there is an error executing the command 084 */ 085 void execute( GetChildrenCommand command ) throws RepositorySourceException; 086 087 /** 088 * Execute a command to create a node and set the node's properties. 089 * 090 * @param command the command to be executed; may not be null 091 * @throws RepositorySourceException if there is an error executing the command 092 */ 093 void execute( CreateNodeCommand command ) throws RepositorySourceException; 094 095 /** 096 * Execute a command to set some (or all) of the properties on a node. 097 * 098 * @param command the command to be executed; may not be null 099 * @throws RepositorySourceException if there is an error executing the command 100 */ 101 void execute( SetPropertiesCommand command ) throws RepositorySourceException; 102 103 /** 104 * Execute a command to copy a node to a new location. 105 * 106 * @param command the command to be executed; may not be null 107 * @throws RepositorySourceException if there is an error executing the command 108 */ 109 void execute( CopyNodeCommand command ) throws RepositorySourceException; 110 111 /** 112 * Execute a command to copy an entire branch to a new location. 113 * 114 * @param command the command to be executed; may not be null 115 * @throws RepositorySourceException if there is an error executing the command 116 */ 117 void execute( CopyBranchCommand command ) throws RepositorySourceException; 118 119 /** 120 * Execute a command to record the structure of a branch. 121 * 122 * @param command the command to be executed; may not be null 123 * @throws RepositorySourceException if there is an error executing the command 124 */ 125 void execute( RecordBranchCommand command ) throws RepositorySourceException; 126 127 /** 128 * Execute a command to delete an entire branch. 129 * 130 * @param command the command to be executed; may not be null 131 * @throws RepositorySourceException if there is an error executing the command 132 */ 133 void execute( DeleteBranchCommand command ) throws RepositorySourceException; 134 135 /** 136 * Execute a command to move a branch from one location to another. 137 * 138 * @param command the command to be executed; may not be null 139 * @throws RepositorySourceException if there is an error executing the command 140 */ 141 void execute( MoveBranchCommand command ) throws RepositorySourceException; 142 143 /** 144 * Close this executor, allowing it to clean up any open resources. 145 */ 146 void close(); 147 }