package fi.cas.opplugin;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.Stub;

public class TxServiceGatewayProxy implements TxServiceGateway_PortType {
    private String _endpoint = null;
    private TxServiceGateway_PortType txServiceGateway_PortType = null;

    public TxServiceGatewayProxy() {
        _initTxServiceGatewayProxy();
    }

    public TxServiceGatewayProxy(String endpoint) {
        this._endpoint = endpoint;
        _initTxServiceGatewayProxy();
    }

    public TxServiceGatewayProxy(String endpoint,String url) {
        _initTxServiceGatewayProxy(url);
    }

    private void _initTxServiceGatewayProxy(String url) {
        try {
            this.txServiceGateway_PortType = new TxServiceGateway_ServiceLocator(url)
                    .getTxServiceGatewayPort();
            if (this.txServiceGateway_PortType != null)
                if (this._endpoint != null)
                    ((Stub) this.txServiceGateway_PortType)._setProperty(
                            "javax.xml.rpc.service.endpoint.address",
                            this._endpoint);
                else
                    this._endpoint = ((String) ((Stub) this.txServiceGateway_PortType)
                            ._getProperty("javax.xml.rpc.service.endpoint.address"));
        } catch (ServiceException localServiceException) {
        }
    }

    private void _initTxServiceGatewayProxy() {
        try {
            this.txServiceGateway_PortType = new TxServiceGateway_ServiceLocator()
                    .getTxServiceGatewayPort();
            if (this.txServiceGateway_PortType != null)
                if (this._endpoint != null)
                    ((Stub) this.txServiceGateway_PortType)._setProperty(
                            "javax.xml.rpc.service.endpoint.address",
                            this._endpoint);
                else
                    this._endpoint = ((String) ((Stub) this.txServiceGateway_PortType)
                            ._getProperty("javax.xml.rpc.service.endpoint.address"));
        } catch (ServiceException localServiceException) {
        }
    }

    public String getEndpoint() {
        return this._endpoint;
    }

    public void setEndpoint(String endpoint) {
        this._endpoint = endpoint;
        if (this.txServiceGateway_PortType != null)
            ((Stub) this.txServiceGateway_PortType)._setProperty(
                    "javax.xml.rpc.service.endpoint.address", this._endpoint);
    }

    public TxServiceGateway_PortType getTxServiceGateway_PortType() {
        if (this.txServiceGateway_PortType == null)
            _initTxServiceGatewayProxy();
        return this.txServiceGateway_PortType;
    }

    public String send(String message) throws RemoteException {
        if (this.txServiceGateway_PortType == null)
            _initTxServiceGatewayProxy();
        return this.txServiceGateway_PortType.send(message);
    }
}