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

📄 jco$pool.java

📁 SAP这个系统的一个转换器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   JCO.java

package com.sap.mw.jco;

import com.sap.mw.jco.util.LimitedList;
import com.sap.mw.jco.util.ObjectList;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Properties;

// Referenced classes of package com.sap.mw.jco:
//            JCO, IMiddleware

public static class JCO$Pool
{

    protected void initPool()
    {
        synchronized(this)
        {
            if(is_initialized)
                return;
            master.connect();
            if(((ction) (master)).properties.getProperty("jco.client.type", "3").equals("E"))
                master.ping();
            butes attrib = master.getAttributes();
            master.disconnect();
            String prel = attrib.getPartnerRelease();
            if(prel != null && prel.length() > 0)
                r3_version = (byte)(prel.charAt(0) - 48);
            else
                r3_version = 0;
            if(JCO.properties.getProperty("jco.client.idle_timeout", null) != null)
            {
                int idle_timeout = Integer.parseInt(JCO.properties.getProperty("jco.client.idle_timeout")) * 1000;
                if(getConnectionTimeout() > (long)idle_timeout)
                    setConnectionTimeout(idle_timeout);
            }
            is_initialized = true;
        }
    }

    public final void setResetOnRelease(boolean reset_on_release)
    {
        if(JCO.trace_level > 0)
            JCO.fireTrace(1, "[JAV-LAYER] JCO.Pool.setResetOnRelease(" + reset_on_release + ")");
        this.reset_on_release = reset_on_release;
    }

    public final boolean getResetOnRelease()
    {
        return reset_on_release;
    }

    public void setAbapDebug(boolean debug)
    {
        if(JCO.trace_level > 0)
            JCO.fireTrace(1, "[JAV-LAYER] JCO.Pool.setAbapDebug(" + debug + ")");
        if(getAbapDebug() != debug)
            master.setAbapDebug(debug);
    }

    public final boolean getAbapDebug()
    {
        return master.getAbapDebug();
    }

    public final boolean getTrace()
    {
        return master.getTrace();
    }

    public final void setTrace(boolean trace)
    {
        if(JCO.trace_level > 0)
            JCO.fireTrace(1, "[JAV-LAYER] JCO.Pool.setTrace(" + trace + ")");
        if(getTrace() != trace)
            master.setTrace(trace);
    }

    public final String getName()
    {
        return name;
    }

    public final anager getPoolManager()
    {
        return manager;
    }

    public final int getMaxPoolSize()
    {
        return available.getLimit();
    }

    public final void setMaxPoolSize(int max_pool_size)
    {
        if(JCO.trace_level > 0)
            JCO.fireTrace(1, "[JAV-LAYER] JCO.Pool.setMaxPoolSize(" + max_pool_size + ")");
        if(max_pool_size < 0)
            throw new IllegalArgumentException("max_pool_size [" + max_pool_size + "] less than zero");
        synchronized(available)
        {
            if(max_pool_size < available.size())
            {
                int i = 0;
                for(int to = available.size() - max_pool_size; i < to; i++)
                {
                    t to_close = (t)available.remove(i);
                    to_close.disconnect(true);
                }

            }
            available.setLimit(max_pool_size);
        }
        if(max_pool_size == 0)
            manager.timeout_checker.stopCheckerFor(this);
        if(getMaxConnections() < max_pool_size)
            setMaxConnections(max_pool_size);
    }

    public final int getMaxConnections()
    {
        return max_connections;
    }

    public final void setMaxConnections(int max_connections)
    {
        if(JCO.trace_level > 0)
            JCO.fireTrace(1, "[JAV-LAYER] JCO.Pool.setMaxConnections(" + max_connections + ")");
        if(getMaxPoolSize() > max_connections)
            setMaxPoolSize(max_connections);
        this.max_connections = max_connections;
    }

    public final int getCurrentPoolSize()
    {
        int currSize = current_used + available.size();
        return currSize;
    }

    public final int getMaxUsed()
    {
        return max_used;
    }

    public final int getNumUsed()
    {
        return current_used;
    }

    public final int getNumWaitingThreads()
    {
        return waiting_threads == null ? 0 : waiting_threads.size();
    }

    public final void setMaxWaitTime(long max_wait_time)
    {
        if(JCO.trace_level > 0)
            JCO.fireTrace(1, "[JAV-LAYER] JCO.Pool.setMaxWaitTime(" + max_wait_time + ")");
        if(max_wait_time >= 0L)
            this.max_wait_time = max_wait_time;
    }

    public final long getMaxWaitTime()
    {
        return max_wait_time;
    }

    public long getConnectionTimeout()
    {
        return connection_timeout;
    }

    public void setConnectionTimeout(long connection_timeout)
    {
        if(JCO.trace_level > 0)
            JCO.fireTrace(1, "[JAV-LAYER] JCO.Pool.setConnectionTimeout(" + connection_timeout + ")");
        this.connection_timeout = connection_timeout;
    }

    public long getTimeoutCheckPeriod()
    {
        return timeout_check_period;
    }

    public void setTimeoutCheckPeriod(long timeout_check_period)
    {
        if(JCO.trace_level > 0)
            JCO.fireTrace(1, "[JAV-LAYER] JCO.Pool.setTimeoutCheckPeriod(" + timeout_check_period + ") on pool " + getName());
        if(timeout_check_period < 0L)
            throw new IllegalArgumentException("timeout_check_period " + timeout_check_period + " must be greater than or equal to zero.");
        if(manager == null)
            return;
        this.timeout_check_period = timeout_check_period;
        if(timeout_check_period > 0L)
            manager.timeout_checker.startCheckerFor(this);
        else
            manager.timeout_checker.stopCheckerFor(this);
    }

    protected final void clear()
    {
        synchronized(available)
        {
            for(; !available.isEmpty(); ((t)available.pop()).disconnect(true));
            if(waiting_threads != null && waiting_threads.size() > 0)
            {
                if(JCO.trace_level > 0)
                    JCO.fireTrace(1, "[JAV-LAYER] Warning: Pool.clear() was called, although " + waiting_threads.size() + " threads are still waiting in getClient().");
                available.notifyAll();
            }
        }
    }

    /**
     * @deprecated Method getStates is deprecated
     */

    public final byte[] getStates()
    {
        return new byte[0];
    }

    protected final t getClient(boolean reset)
    {
        boolean shouldStopTimeoutChecker = false;
        t client = null;
        if(JCO.trace_level > 1)
            JCO.fireTrace(2, "[JAV-LAYER] JCO.Pool.getClient(" + reset + ")  from pool " + getName() + "    [enter]");
        if(manager == null)
            throw new tion(106, "JCO_ERROR_RESOURCE", "Connection pool " + name + " is removed.");
        synchronized(available)
        {
            if(!available.isEmpty())
            {
                client = (t)available.pop();
                if(available.isEmpty())
                    shouldStopTimeoutChecker = true;
                current_used++;
            } else
            if(current_used < max_connections)
            {
                client = (t)master.clone();
                client.pool = this;
                current_used++;
            }
        }
        if(client == null && max_wait_time > 0L)
        {
            if(JCO.trace_level > 4)
                JCO.fireTrace(5, "[JAV-LAYER] JCO.Pool.getClient() no connections available " + "[pool size " + getCurrentPoolSize() + ", max conns " + getMaxConnections() + ", waiting threads " + getNumWaitingThreads() + ", currently used " + getNumUsed() + "]");
            synchronized(available)
            {
                long duration = max_wait_time;
                try
                {
                    if(waiting_threads == null)
                        waiting_threads = new ObjectList();
                    waiting_threads.add(Thread.currentThread());
                    long t0;
                    for(; client == null && duration > 0L; duration -= System.currentTimeMillis() - t0)
                    {
                        t0 = System.currentTimeMillis();
                        available.wait(duration);
                        if(manager == null)
                        {
                            t t1 = null;
                            return t1;
                        }
                        int num_available = Math.min(max_connections - current_used, waiting_threads.size());
                        for(int i = 0; i < num_available; i++)
                        {
                            if(waiting_threads.get(i) != Thread.currentThread())
                                continue;
                            waiting_threads.remove(Thread.currentThread());
                            if(waiting_threads.size() == 0)
                                waiting_threads = null;
                            if(!available.isEmpty())
                            {

⌨️ 快捷键说明

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