@@ -0,0 +1,2560 @@
+/*%0A * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and limitations under the License.%0A */%0A%0Apackage org.wso2.carbon.transport.http.netty.sender.channel.pool;%0A%0A%0Aimport org.apache.commons.pool.PoolableObjectFactory;%0Aimport org.apache.commons.pool.impl.GenericObjectPool;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport org.wso2.carbon.transport.http.netty.sender.channel.TargetChannel;%0A%0A/**%0A * A class which creates a TargetChannel pool for each route.%0A */%0Apublic class PoolableTargetChannelFactoryPerSrcHndlr implements PoolableObjectFactory %7B%0A%0A    private static final Logger log = LoggerFactory.getLogger(PoolableTargetChannelFactoryPerSrcHndlr.class);%0A%0A    private GenericObjectPool genericObjectPool;%0A%0A    public PoolableTargetChannelFactoryPerSrcHndlr(GenericObjectPool genericObjectPool) %7B%0A        this.genericObjectPool = genericObjectPool;%0A    %7D%0A%0A%0A    @Override%0A    public Object makeObject() throws Exception %7B%0A        TargetChannel targetChannel = (TargetChannel) this.genericObjectPool.borrowObject();%0A        while (!targetChannel.getChannel().isActive() %7C%7C !targetChannel.getChannel().isOpen()) %7B%0A            this.genericObjectPool.invalidateObject(targetChannel);%0A            targetChannel = (TargetChannel) this.genericObjectPool.borrowObject();%0A        %7D%0A        log.debug(%22Created channel: %7B%7D%22, targetChannel);%0A        return targetChannel;%0A    %7D%0A%0A    @Override%0A    public void destroyObject(Object o) throws Exception %7B%0A        if (((TargetChannel) o).getChannel().isOpen()) %7B%0A            this.genericObjectPool.returnObject(o);%0A        %7D%0A        log.debug(%22Destroying channel: %7B%7D%22, o);%0A    %7D%0A%0A    @Override%0A    public boolean validateObject(Object o) %7B%0A        boolean answer = ((TargetChannel) o).getChannel().isActive();%0A        log.debug(%22Validating channel: %7B%7D -%3E %7B%7D%22, o, answer);%0A        return answer;%0A    %7D%0A%0A    @Override%0A    public void activateObject(Object o) throws Exception %7B%0A%0A    %7D%0A%0A    @Override%0A    public void passivateObject(Object o) throws Exception %7B%0A%0A    %7D%0A%0A%0A%7D%0A

Add new pool configurator