Package Framework

Source Code of Framework.FileSystemProxy

/*
Copyright (c) 2003-2009 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.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Hashtable;

import Framework.anchored.AnchoredProxy;
import Framework.anchored.MethodMapper;
import Framework.anchored.ServiceInvoker;
import Framework.anchored.ServiceProxy;

public class FileSystemProxy extends FileSystem implements AnchoredProxy, RemoteProxy{
    private transient ServiceProxy proxy = null;
    private String objectName;
    private String hostName;
    private int port;

    /**
     * @deprecated This constructor is present only to allow proxies to be serialised via the efficient serialiser
     * and should not be called at any other time. 
     */
    public FileSystemProxy() {
        super((ServiceObjectContext)null);
    }

    /**
     * This constructor can store no reference to the original object,
     * but must instead copy over it's necessary attributes.
     */
    public FileSystemProxy(FileSystem baseClass) {
        super((ServiceObjectContext)null);
        ServiceInvoker serviceInvoker = getInvoker(baseClass);
        if (serviceInvoker == null) {
            throw new UsageException("Cannot create a proxy for an object that has not yet been exported.");
        }
        this.objectName = serviceInvoker.getObjectName();
        // The proxy is being created on the same host as the real object
        //this.hostName = System.getProperty("RMIregistry.host");
        try {
            this.hostName = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            throw new UsageException("Cannot BIND to RMI object ", e);
        }
        this.port = serviceInvoker.getPort();
    }

    private ServiceProxy getServiceProxy() {
        if (proxy == null) {
            proxy = new ServiceProxy(objectName, hostName, port, this.getClass().getSuperclass());
        }
        return proxy;
    }

    @Override
    public TextData getCurrentDir() {
        String qq_name = MethodMapper.computeName("getCurrentDir");
        return (TextData)getServiceProxy().intercept(qq_name);
    }

    @Override
    public TextData getCurrentRemoteDir() {
        String qq_name = MethodMapper.computeName("getCurrentRemoteDir");
        return (TextData)getServiceProxy().intercept(qq_name);
    }

    @Override
    public void pullFiles(Array_Of_TextData<TextData> copyList, int cmdFlags) {
        String qq_name = MethodMapper.computeName("pullFiles", Array_Of_TextData.class, Integer.class);
        getServiceProxy().intercept(qq_name, copyList, cmdFlags);
    }

    @Override
    public void pushFiles(Array_Of_TextData<TextData> copyList, int cmdFlags) {
        String qq_name = MethodMapper.computeName("pushFiles", Array_Of_TextData.class, Integer.class);
        getServiceProxy().intercept(qq_name, copyList, cmdFlags);
    }
    @Override
    public void setRemoteDir(String dirName) {
        String qq_name = MethodMapper.computeName("setRemoteDir", String.class);
        getServiceProxy().intercept(qq_name, dirName);
    }
    @Override
    public void setRemoteDir(TextData dirName) {
        String qq_name = MethodMapper.computeName("setRemoteDir", TextData.class);
        getServiceProxy().intercept(qq_name, dirName);
    }
    @Override
    public void setRemoteDir(TextData dirName, boolean collapseDir) {
        String qq_name = MethodMapper.computeName("setRemoteDir", TextData.class, Boolean.class);
        getServiceProxy().intercept(qq_name, dirName, collapseDir);
    }
    @Override
    public void setLocalDir(String dirName) {
        String qq_name = MethodMapper.computeName("setLocalDir", String.class);
        getServiceProxy().intercept(qq_name, dirName);
    }
    @Override
    public void setLocalDir(TextData dirName) {
        String qq_name = MethodMapper.computeName("setLocalDir", TextData.class);
        getServiceProxy().intercept(qq_name, dirName);
    }
    @Override
    public void setLocalDir(TextData dirName, boolean collapseDir) {
        String qq_name = MethodMapper.computeName("setLocalDir", TextData.class, Boolean.class);
        getServiceProxy().intercept(qq_name, dirName, collapseDir);
    }
    @Override
    public void setRemoteFS(FileSystem remoteFS) {
        String qq_name = MethodMapper.computeName("setRemoteFS", FileSystem.class);
        getServiceProxy().intercept(qq_name, remoteFS);
    }
   /**
     * Satisfy the {@link RemoteEventProxy} interface
     */
    @Override
    public String registerInterest(String pHostName, RemoteEvent pAnchoredObject, String pEvent)  {
        String qq_name = MethodMapper.computeName("registerInterest", String.class, RemoteEvent.class, String.class);
        return (String)getServiceProxy().intercept(qq_name, pHostName, pAnchoredObject, pEvent);
    }

    @Override
    public void postEvent(String pEventName, Hashtable<String, Object> pParameters) {
        String qq_name = MethodMapper.computeName("postEvent", String.class, Hashtable.class);
        getServiceProxy().intercept(qq_name, pEventName, pParameters);
    }

    @Override
    public void deregisterInterest(String pHostName, RemoteEvent pAnchoredObject, String pEvent)  {
        String qq_name = MethodMapper.computeName("deregisterInterest", String.class, RemoteEvent.class, String.class);
        getServiceProxy().intercept(qq_name, pHostName, pAnchoredObject, pEvent);
    }

}
TOP

Related Classes of Framework.FileSystemProxy

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.