Package Framework

Source Code of Framework.FileSystem$qq_Resolver

/*
Copyright (c) 2003-2008 ITerative Consulting Pty Ltd. All Rights Reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

o Redistributions of source code must retain the above copyright notice, this list of conditions and
the following disclaimer.
 
o Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution.
   
o This jcTOOL Helper Class software, whether in binary or source form may not be used within,
or to derive, any other product without the specific prior written permission of the copyright holder

 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


*/
package Framework;

import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.Hashtable;

import org.apache.log4j.Logger;

import Framework.anchored.Anchorable;
import Framework.anchored.AnchoredProxy;
import Framework.anchored.ServiceInvoker;

/**
* The FileSystem class allows the copying of files between remote systems. NOTE: this is not implemented
*/
public class FileSystem implements Serializable, Anchorable{
    // ----------
    // Attributes
    // ----------
    /**
     * The flag to use for "isAnchored" and the listener for remote requests
     */
    protected ServiceInvoker invoker = null;
   
    protected TextData    localDir;
    protected boolean     localDirCollapse;
    protected TextData    remoteDir;
    protected boolean    remoteDirCollapse;
    protected FileSystem  remoteFS;

    /**
     * Resolves ambiguous constructor arguments
     */
    public static class qq_Resolver {
        public static final int cISANCHORED = 2;
    }
    // ------------
    // Constructors
    // ------------
    public FileSystem() {
        super();
        this.setIsAnchored(false);
    }
    /**
     * A dummy constructor used to instantiate a "blank" object. This is used for anchored objects, Spring beans and their
     * superclasses, but should not be expected to create a valid Bottom.
     */
    public FileSystem(ServiceObjectContext pContext) {
       
    }
    // ----------------------
    // Accessors and Mutators
    // ----------------------
    public boolean getIsAnchored() {
        return invoker != null;
    }

    public void setIsAnchored(boolean isAnchored) {
        if (isAnchored && invoker == null) {
            // Anchor the object, creating an invoker for it.
            this.invoker = new ServiceInvoker(this);
        }
        else if (!isAnchored && invoker != null) {
            this.invoker = null;
        }
    }

    /**
     * Get the invoker for this class. This method should only be called from the proxy, hence the protected level visibility.
     */
    protected ServiceInvoker getInvoker(FileSystem pService) {
        return pService.invoker;
    }
    public FileSystem(boolean pValue, int pResolver) {
        this();
        switch (pResolver){
            case qq_Resolver.cISANCHORED:
                // do nothing
        }
    }
    // -------
    // Methods
    // -------
    /**
     * Returns the current local directory.
     * @return
     */
    public TextData getCurrentDir(){
      return this.localDir;
    }
    /**
     * Returns the current remote directory.
     */
    public TextData getCurrentRemoteDir() {
      return this.remoteDir;
    }
    /**
     * Moves files from remote to local file system. NOT IMPLEMENTED
     * @param copyList
     * @param cmdFlags
     */
    public void pullFiles(Array_Of_TextData<TextData> copyList, int cmdFlags){
        UnsupportedOperationException errorVar = new UnsupportedOperationException("FileSystem.pullFiles() in not implemented");
        ErrorMgr.addError(errorVar);
        throw errorVar;
    }
    /**
     * Moves files from local to remote file system. MOT IMPLEMENTED
     * @param copyList
     * @param cmdFlags
     */
    public void pushFiles(Array_Of_TextData<TextData> copyList, int cmdFlags){
        UnsupportedOperationException errorVar = new UnsupportedOperationException("FileSystem.pushFiles() in not implemented");
        ErrorMgr.addError(errorVar);
        throw errorVar;
    }
    /**
     * Sets the current directory on the local system.
     * @param dirName
     */
    public void setLocalDir(String dirName){
        this.setLocalDir(new TextData(dirName));
    }
    public void setLocalDir(TextData dirName){
        this.setLocalDir(dirName, false);
    }
    public void setLocalDir(TextData dirName, boolean collapseDir){
      this.localDir = dirName;
      this.localDirCollapse = collapseDir;
    }
    /**
     * Sets the current directory on the remote system.
     * @param dirName
     */
    public void setRemoteDir(String dirName){
        this.setRemoteDir(new TextData(dirName));
    }
    public void setRemoteDir(TextData dirName){
        this.setRemoteDir(dirName, false);
    }
    public void setRemoteDir(TextData dirName, boolean collapseDir){
      this.remoteDir = dirName;
      this.remoteDirCollapse = collapseDir;
    }
    /**
     * Sets the FileSystem object from the remote system.
     * @param remoteFS
     */
    public void setRemoteFS(FileSystem  remoteFS){
      this.remoteFS = remoteFS;
    }
    /**
     * readbyPrsnId<p>
     * <p>
     */
    public void readbyPrsnId() {
        Logger.getLogger("task.part.logmgr").info("Invoked ReadByPrsnId()");
    }

    /**
     * Get the proxy class which will forwards remote requests to this class. This
     * must be kept as a method so it can be overridden in all subclasses, ensuring
     * a proxy to the lowest level subclass is returned.
     */
    public AnchoredProxy getProxy() {
        return new FileSystemProxy(this);
    }

    /**
     * Override the writeReplace method to replace this class with a proxy to it (if it's anchored)
     */
    public Object writeReplace() throws ObjectStreamException {
        if (getIsAnchored()) {
            this.invoker.prepareForRemoteCall();
            AnchoredProxy proxy = this.getProxy();
            //System.out.println("Replacing " + this + " with " + proxy + " in writeReplace");
            return proxy;
        }
        else {
            return this;
        }
    }

    /**
     * Satisfy the {@link RemoteEventProxy} interface
     */
    public String registerInterest(String pHostName, RemoteEvent pAnchoredObject, String pEvent)  {
        return EventManager.registerInterest(pHostName, pAnchoredObject, this, pEvent);
    }

    public void postEvent(String pEventName, Hashtable<String, Object> pParameters) {
        EventManager.postEvent(this, pEventName, pParameters);
    }

    public void deregisterInterest(String pHostName, RemoteEvent pAnchoredObject, String pEvent)  {
        EventManager.deregisterInterest(pHostName, pAnchoredObject, this, pEvent);
    }
}
TOP

Related Classes of Framework.FileSystem$qq_Resolver

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.