⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jco$client.java

📁 SAP这个系统的一个转换器
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        }
    }

    public String createTID()
    {
        String tid = null;
        synchronized(semaphore)
        {
            if((super.state & 4) != 0)
                throw new on(132, "JCO_ERROR_CONCURRENT_CALL", "Concurrent call. Connection currently used in another thread.");
            super.state |= 4;
        }
        super.last_active_timestamp = System.currentTimeMillis();
        try
        {
            tid = middleware.createTID(this);
        }
        finally
        {
            super.state &= 0xfb;
            super.last_active_timestamp = System.currentTimeMillis();
        }
        return tid;
    }

    public void confirmTID(String tid)
    {
        synchronized(semaphore)
        {
            if((super.state & 4) != 0)
                throw new on(132, "JCO_ERROR_CONCURRENT_CALL", "Concurrent call. Connection currently used in another thread.");
            super.state |= 4;
        }
        super.last_active_timestamp = System.currentTimeMillis();
        try
        {
            middleware.confirmTID(this, tid);
        }
        finally
        {
            super.state &= 0xfb;
            super.last_active_timestamp = System.currentTimeMillis();
        }
    }

    public final void ping()
    {
        execute("RFC_PING", (erList)null, (erList)null, (erList)null);
    }

    public void setDsrPassport(DsrIPassport passport)
    {
        if(JCO.trace_level > 4)
            JCO.fireTrace(5, "[JAV-LAYER] setDsrPassport for connection with handle " + getConnectionHandle() + "  [enter]");
        if(passport != null && passport.isValid())
        {
            super.passport_bytes = passport.getNetPassport();
        } else
        {
            on e = new on(152, "JCO_ERROR_DSR_PASSPORT_NOT_VALID", passport != null ? "Dsr passport is not valid." : "Dsr passport equals null.");
            if(JCO.trace_level > 2)
                JCO.fireTrace(3, "[JAV-LAYER] " + e.toString());
            throw e;
        }
        if(JCO.trace_level > 4)
            JCO.fireTrace(5, "[JAV-LAYER] setDsrPassport for connection with handle " + getConnectionHandle() + "  [leave]");
    }

    protected void beginCall()
    {
        try
        {
            if((JCO.access$000() & 7) != 0)
            {
                super.jarm_monitor = Jarm.getRequestMonitor(null, "com.sap.mw.jco.JCO.Client");
                if(super.jarm_monitor != null)
                    super.jarm_monitor.startComponent("com.sap.mw.jco.JCO.Client");
                if(super.dsr_monitor == null && super.passport_bytes != null)
                    super.dsr_monitor = Dsr.createMonitor();
                if(super.dsr_monitor != null && super.passport_bytes != null)
                    super.dsr_monitor.openDsrRecord(getConnectionHandle(), 0, super.passport_bytes, super.start_time);
            }
        }
        catch(RuntimeException ex)
        {
            if(JCO.trace_level > 0)
            {
                StringWriter sw = new StringWriter();
                ex.printStackTrace(new PrintWriter(sw));
                sw.flush();
                JCO.fireTrace(1, "[JAV-LAYER] JCO.Client.beginCall() throws exception " + JCO.CRLF + sw.getBuffer());
            }
            throw ex;
        }
    }

    protected void endCall()
    {
        try
        {
            if((JCO.access$000() & 7) != 0)
            {
                if(super.jarm_monitor != null)
                {
                    tes attributes = getAttributes();
                    super.jarm_monitor.setUser(attributes == null ? (String)null : attributes.getUser());
                    super.jarm_monitor.endComponent();
                    super.jarm_monitor.endRequest();
                }
                if(super.dsr_monitor != null && super.passport_bytes != null)
                    super.dsr_monitor.closeDsrRecord(getConnectionHandle(), 0, super.rfm_name, super.time_total, super.time_middleware, -1L, super.num_sent_bytes, super.num_received_bytes);
            }
        }
        catch(RuntimeException ex)
        {
            if(JCO.trace_level > 0)
            {
                StringWriter sw = new StringWriter();
                ex.printStackTrace(new PrintWriter(sw));
                sw.flush();
                JCO.fireTrace(1, "[JAV-LAYER] JCO.Client.endCall() throws exception " + JCO.CRLF + sw.getBuffer());
            }
            throw ex;
        }
    }

    public void startAuthorizationTracing(String traceID, String serviceType)
    {
        if(JCO.trace_level > 4)
            JCO.fireTrace(5, "[JAV-LAYER] startAuthorizationTracing (" + traceID + ", " + serviceType + ") for client with handle " + getConnectionHandle() + "  [enter]");
        if(!isValid())
            throw new on(102, "JCO_ERROR_COMMUNICATION", "JCO.Client not connected, which is required for enabling authorization tracing");
        try
        {
            if(super.attributes == null)
                getAttributes();
            if(super.attributes.getPartnerReleaseNumber() >= 620)
            {
                boolean isUnicode = super.attributes.getPartnerCodepage().startsWith("4");
                erList imports = new erList(isUnicode ? ((IMetaData) (auth_trace_set_unicode)) : ((IMetaData) (auth_trace_set)));
                imports.setValue(serviceType, 0);
                imports.setValue(traceID, 1);
                n function = new n("AUTH_TRACE_SET_SERVICE", imports, null, null);
                execute(function);
                authorizationTraceID = traceID;
            }
        }
        catch(eption jae)
        {
            JCO.fireTrace(1, "[JAV-LAYER] startAuthorizationTracing (" + traceID + ", " + serviceType + ") for client with handle " + getConnectionHandle() + "  failed in backend: " + jae.getMessage());
        }
        catch(on ex)
        {
            JCO.fireTrace(1, "[JAV-LAYER] startAuthorizationTracing (" + traceID + ", " + serviceType + ") for client with handle " + getConnectionHandle() + "  failed: " + ex.getMessage());
        }
        if(JCO.trace_level > 4)
            JCO.fireTrace(5, "[JAV-LAYER] startAuthorizationTracing for client with handle " + getConnectionHandle() + "  [leave]");
    }

    public boolean isAuthorizationTracingEnabled()
    {
        if(JCO.trace_level > 4)
            JCO.fireTrace(5, "[JAV-LAYER] isAuthorizationTracingEnabled for client with handle " + getConnectionHandle() + "  [enter]");
        if(!isValid())
            throw new on(102, "JCO_ERROR_COMMUNICATION", "JCO.Client not connected, which is required for setting authorization tracing");
        boolean ret = false;
        try
        {
            if(super.attributes == null)
                getAttributes();
            if(super.attributes.getPartnerReleaseNumber() >= 620)
            {
                boolean isUnicode = super.attributes.getPartnerCodepage().startsWith("4");
                erList exports = new erList(isUnicode ? ((IMetaData) (auth_trace_status_unicode)) : ((IMetaData) (auth_trace_status)));
                n function = new n("AUTH_TRACE_GET_STATUS", null, exports, null);
                execute(function);
                re rc = exports.getStructure(0);
                ret = "X".equals(rc.getString(0));
            }
        }
        catch(on ex)
        {
            JCO.fireTrace(1, "[JAV-LAYER] isAuthorizationTracingEnabled for client with handle " + getConnectionHandle() + "  failed: " + ex.getMessage());
        }
        if(JCO.trace_level > 4)
            JCO.fireTrace(5, "[JAV-LAYER] isAuthorizationTracingEnabled for client with handle " + getConnectionHandle() + "  [leave]");
        return ret;
    }

    public String getAuthorizationTraceID()
    {
        return authorizationTraceID;
    }

    public void endAuthorizationTracing()
    {
        if(JCO.trace_level > 4)
            JCO.fireTrace(5, "[JAV-LAYER] endAuthorizationTracing for client with handle " + getConnectionHandle() + "  [enter]");
        if(authorizationTraceID != null)
        {
            authorizationTraceID = null;
            if(isValid())
                try
                {
                    if(super.attributes == null)
                        getAttributes();
                    if(super.attributes.getPartnerReleaseNumber() >= 620)
                    {
                        n function = new n("AUTH_TRACE_RESET", null, null, null);
                        execute(function);
                    }
                }
                catch(on ex)
                {
                    JCO.fireTrace(1, "[JAV-LAYER] WARNING: endAuthorizationTracing for client with handle " + getConnectionHandle() + "  failed: " + ex.getMessage());
                }
        } else
        if(JCO.trace_level > 0)
            JCO.fireTrace(1, "[JAV-LAYER] WARNING: endAuthorizationTracing for client with handle " + getConnectionHandle() + "  cannot be execute because the trace is not turned on.");
        if(JCO.trace_level > 4)
            JCO.fireTrace(5, "[JAV-LAYER] endAuthorizationTracing for client with handle " + getConnectionHandle() + "  [leave]");
    }

    protected .IClient middleware;
    private static final char SPACE = 32;
    protected String stack_trace;
    private Object semaphore;
    private String authorizationTraceID;
    protected static final a auth_trace_set;
    protected static final a auth_trace_set_unicode;
    protected static final a auth_trace_status_rc;
    protected static final a auth_trace_status_rc_unicode;
    protected static final a auth_trace_status;
    protected static final a auth_trace_status_unicode;

    static 
    {
        auth_trace_set = new a("AUTHTRACESET", 2);
        auth_trace_set_unicode = new a("AUTHTRACESET", 2);
        auth_trace_status_rc = new a("AUTHTRACESTATUSRC", 1);
        auth_trace_status_rc_unicode = new a("AUTHTRACESTATUSRC", 1);
        auth_trace_status = new a("AUTHTRACESTATUS", 1);
        auth_trace_status_unicode = new a("AUTHTRACESTATUS", 1);
        auth_trace_set.addInfo("SERVICE_TYPE", 0, 16, 0);
        auth_trace_set.addInfo("SERVICE", 29, 0, 16);
        auth_trace_set_unicode.addInfo("SERVICE_TYPE", 0, -32, 0);
        auth_trace_set_unicode.addInfo("SERVICE", 29, 0, 32);
        auth_trace_status_rc.addInfo("BOOLE", 0, 1, 0);
        auth_trace_status.addInfo("RC", 17, 0, 0, 0, 0, auth_trace_status_rc);
        auth_trace_status_rc_unicode.addInfo("BOOLE", 0, -2, 0);
        auth_trace_status_unicode.addInfo("RC", 17, 0, 0, 0, 0, auth_trace_status_rc_unicode);
    }


    protected JCO$Client(Properties properties)
    {
        stack_trace = null;
        semaphore = new Object();
        authorizationTraceID = null;
        if(properties != null)
            super.properties = (Properties)properties.clone();
        middleware = getClientInterface();
    }

    protected JCO$Client(String params[][])
    {
        stack_trace = null;
        semaphore = new Object();
        authorizationTraceID = null;
        for(int i = 0; i < params.length; i++)
        {
            String key;
            String val;
            if((key = params[i][0]) != null && (val = params[i][1]) != null)
            {
                key = key.toLowerCase().trim();
                if(key.indexOf("jco.client.") != 0)
                    key = "jco.client." + key;
                super.properties.put(key, val);
            }
        }

        middleware = getClientInterface();
    }

    protected JCO$Client(String client, String user, String passwd, String lang, String ashost, String sysnr)
    {
        this(client, user, passwd, lang, ashost, sysnr, null, null);
    }

    protected JCO$Client(String client, String user, String passwd, String lang, String ashost, String sysnr, String gwhost, 
            String gwserv)
    {
        stack_trace = null;
        semaphore = new Object();
        authorizationTraceID = null;
        super.properties.put("jco.client.type", "3");
        if(client != null)
            super.properties.put("jco.client.client", client);
        if(user != null)
            super.properties.put("jco.client.user", user);
        if(passwd != null)
            super.properties.put("jco.client.passwd", passwd);
        if(lang != null)
            super.properties.put("jco.client.lang", lang);
        if(ashost != null)
            super.properties.put("jco.client.ashost", ashost);
        if(sysnr != null)
            super.properties.put("jco.client.sysnr", sysnr);
        if(gwhost != null)
            super.properties.put("jco.client.gwhost", gwhost);
        if(gwserv != null)
            super.properties.put("jco.client.gwserv", gwserv);
        middleware = getClientInterface();
    }

    protected JCO$Client(String client, String user, String passwd, String lang, String mshost, String r3name, String group)
    {
        stack_trace = null;
        semaphore = new Object();
        authorizationTraceID = null;
        super.properties.put("jco.client.type", "3");
        if(client != null)
            super.properties.put("jco.client.client", client);
        if(user != null)
            super.properties.put("jco.client.user", user);
        if(passwd != null)
            super.properties.put("jco.client.passwd", passwd);
        if(lang != null)
            super.properties.put("jco.client.lang", lang);
        if(mshost != null)
            super.properties.put("jco.client.mshost", mshost);
        if(r3name != null)
            super.properties.put("jco.client.r3name", r3name);
        if(group != null)
            super.properties.put("jco.client.group", group);
        middleware = getClientInterface();
    }

    protected JCO$Client(String gwhost, String gwserv, String tpname)
    {
        stack_trace = null;
        semaphore = new Object();
        authorizationTraceID = null;
        super.properties.put("jco.client.type", "E");
        if(gwhost != null)
            super.properties.put("jco.client.gwhost", gwhost);
        if(gwserv != null)
            super.properties.put("jco.client.gwserv", gwserv);
        if(tpname != null)
            super.properties.put("jco.client.tpname", tpname);
        middleware = getClientInterface();
    }

    protected JCO$Client(String gwhost, String gwserv, String tpname, String tphost)
    {
        stack_trace = null;
        semaphore = new Object();
        authorizationTraceID = null;
        super.properties.put("jco.client.type", "E");
        if(gwhost != null)
            super.properties.put("jco.client.gwhost", gwhost);
        if(gwserv != null)
            super.properties.put("jco.client.gwserv", gwserv);
        if(tpname != null)
            super.properties.put("jco.client.tpname", tpname);
        if(tphost != null)
            super.properties.put("jco.client.tphost", tphost);
        middleware = getClientInterface();
    }

    protected JCO$Client(String client, String user, String passwd, String lang, String url)
    {
        stack_trace = null;
        semaphore = new Object();
        authorizationTraceID = null;
        if(client != null)
            super.properties.put("jco.client.client", client);
        if(user != null)
            super.properties.put("jco.client.user", user);
        if(passwd != null)
            super.properties.put("jco.client.passwd", passwd);
        if(lang != null)
            super.properties.put("jco.client.lang", lang);
        try
        {
            URL uri = new URL(url);
            super.properties.put("jco.client.url", uri.toString());
        }
        catch(MalformedURLException ex)
        {
            throw new on(102, "JCO_ERROR_COMMUNICATION", ex.getMessage());
        }
        finally
        {
            middleware = getClientInterface();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -