Package Express.services

Source Code of Express.services.ConcurrencyMgrProxy

package Express.services;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Hashtable;

import Framework.RemoteEvent;
import Framework.RemoteEventProxy;
import Framework.RemoteProxy;
import Framework.ServiceObjectContext;
import Framework.UsageException;
import Framework.anchored.AnchoredProxy;
import Framework.anchored.MethodMapper;
import Framework.anchored.ServiceInvoker;
import Framework.anchored.ServiceProxy;
import Framework.remoting.parameters.CopyInput;
import Framework.remoting.parameters.Input;

/**
Anchored object proxy for {@link ConcurrencyMgr}.
*/
public class ConcurrencyMgrProxy extends ConcurrencyMgr implements AnchoredProxy, RemoteProxy {
    private transient ServiceProxy proxy = null;
    private String objectName;
    private String hostName;
    private int port;

    /**
     * This constructor can store no reference to the original object,
     * but must instead copy over it's necessary attributes.
     */
    public ConcurrencyMgrProxy(ConcurrencyMgr baseClass) {
        super(new ServiceObjectContext());
        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 int getFreeUserCBhead() {
        String name = MethodMapper.computeName("getFreeUserCBhead");
        return ((Integer)getServiceProxy().intercept(name)).intValue();
    }

    @Override
    public void setFreeUserCBhead(int pValue) {
        String qq_name = MethodMapper.computeName("setFreeUserCBhead", Integer.TYPE);
        getServiceProxy().intercept(qq_name, pValue);
    }

    @Override
    public Trace getTrace() {
        String name = MethodMapper.computeName("getTrace");
        return (Trace)getServiceProxy().intercept(name);
    }

    @Override
    public void setTrace(Trace pValue) {
        String qq_name = MethodMapper.computeName("setTrace", Trace.class);
        getServiceProxy().intercept(qq_name, pValue);
    }

    @Override
    public void commitTrans(@CopyInput int clientID, @CopyInput int transactionMode) {
        String qq_name = MethodMapper.computeName("commitTrans", Integer.TYPE, Integer.TYPE);
        getServiceProxy().intercept(qq_name, clientID, transactionMode);
    }

    @Override
    public BusinessClass fetch(@Input BusinessKey key) {
        String qq_name = MethodMapper.computeName("fetch", BusinessKey.class);
        return (BusinessClass)getServiceProxy().intercept(qq_name, key);
    }

    @Override
    public int getClientID() {
        String qq_name = MethodMapper.computeName("getClientID");
        return ((Integer)getServiceProxy().intercept(qq_name)).intValue();
    }

    @Override
    public void load(@CopyInput int clientID, @CopyInput int transactionMode, @CopyInput Array_Of_BusinessKey<BusinessKey> source) {
        String qq_name = MethodMapper.computeName("load", Integer.TYPE, Integer.TYPE, Array_Of_BusinessKey.class);
        getServiceProxy().intercept(qq_name, clientID, transactionMode, source);
    }

    @Override
    public void load(@CopyInput int clientID, @CopyInput int transactionMode, @CopyInput Array_Of_BusinessClass<BusinessClass> source) {
        String qq_name = MethodMapper.computeName("load", Integer.TYPE, Integer.TYPE, Array_Of_BusinessClass.class);
        getServiceProxy().intercept(qq_name, clientID, transactionMode, source);
    }

    @Override
    public void readyToCommit(@CopyInput int clientID, @CopyInput int transactionMode, @CopyInput Array_Of_BusinessKey<BusinessKey> source) {
        String qq_name = MethodMapper.computeName("readyToCommit", Integer.TYPE, Integer.TYPE, Array_Of_BusinessKey.class);
        getServiceProxy().intercept(qq_name, clientID, transactionMode, source);
    }

    @Override
    public void relClientID(@CopyInput int clientID) {
        String qq_name = MethodMapper.computeName("relClientID", Integer.TYPE);
        getServiceProxy().intercept(qq_name, clientID);
    }

    @Override
    public void rollback(@CopyInput int clientID, @CopyInput int transactionMode) {
        String qq_name = MethodMapper.computeName("rollback", Integer.TYPE, Integer.TYPE);
        getServiceProxy().intercept(qq_name, clientID, transactionMode);
    }

    @Override
    public void qq_setCacheMode(@Input int mode) {
        String qq_name = MethodMapper.computeName("setCacheMode", Integer.TYPE);
        getServiceProxy().intercept(qq_name, mode);
    }

    @Override
    public void qq_setCacheSize(@Input int size) {
        String qq_name = MethodMapper.computeName("setCacheSize", Integer.TYPE);
        getServiceProxy().intercept(qq_name, size);
    }

    @Override
    public void qq_setConcurrencyMode(@Input int mode) {
        String qq_name = MethodMapper.computeName("setConcurrencyMode", Integer.TYPE);
        getServiceProxy().intercept(qq_name, mode);
    }

    @Override
    public void setup() {
        String qq_name = MethodMapper.computeName("setup");
        getServiceProxy().intercept(qq_name);
    }

    @Override
    public void startTrans(@CopyInput int clientID, @CopyInput int transactionMode) {
        String qq_name = MethodMapper.computeName("startTrans", Integer.TYPE, Integer.TYPE);
        getServiceProxy().intercept(qq_name, clientID, transactionMode);
    }

    /**
     * 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 Express.services.ConcurrencyMgrProxy

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.