001/*
002 * Copyright (c) 2009-2012 The Regents of the University of California.
003 * All rights reserved.
004 *
005 * '$Author: jianwu $'
006 * '$Date: 2012-10-10 00:45:41 +0000 (Wed, 10 Oct 2012) $' 
007 * '$Revision: 30849 $'
008 * 
009 * Permission is hereby granted, without written agreement and without
010 * license or royalty fees, to use, copy, modify, and distribute this
011 * software and its documentation for any purpose, provided that the above
012 * copyright notice and the following two paragraphs appear in all copies
013 * of this software.
014 *
015 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
016 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
017 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
018 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
019 * SUCH DAMAGE.
020 *
021 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
022 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
024 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
025 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
026 * ENHANCEMENTS, OR MODIFICATIONS.
027 *
028 */
029
030package org.sdm.spa.actors.transport;
031
032
033/**
034 * Factory class to return a FileCopier class specific to the protocol passed
035 * @author Chandrika Sivaramakrishnan
036 *
037 */
038public class FileCopierFactory {
039
040        
041        /**
042         * Returns the appropriate derived class of FileCopier based on the protocol
043         * passed. Defaults to LocalFileCopier, if the protocol passed is unknown
044         * @param protocol - the protocol to be used to copy files
045         * @return instance of appropriate FileCopier class. Defaults to LocalFileCopier
046         */
047        public static FileCopierBase getFileCopier(String protocol){
048
049                if("scp".equals(protocol)){
050                        return new ScpCopier();
051                } else if("sftp".equals(protocol)){
052                        return new SftpCopier();
053                }else if("bbcp".equals(protocol)){
054                        return new BbcpCopier();
055                }else if("srmlite".equals(protocol)){
056                        return new SrmliteCopier();
057                }else {
058                        return new LocalFileCopier();
059                }
060                
061        }
062}