/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.util.ExceptionUtils
 *  javax.jms.Destination
 *  javax.jms.JMSException
 *  javax.jms.MessageProducer
 *  javax.jms.Queue
 *  javax.jms.Session
 */
package com.l7tech.server.transport.jms2.synch;

import com.l7tech.server.transport.jms.JmsBag;
import com.l7tech.server.transport.jms.JmsRuntimeException;
import com.l7tech.server.transport.jms.JmsUtil;
import com.l7tech.server.transport.jms2.AbstractJmsEndpointListener;
import com.l7tech.server.transport.jms2.JmsConnectionMaxWaitException;
import com.l7tech.server.transport.jms2.JmsEndpointConfig;
import com.l7tech.server.transport.jms2.JmsRequestHandlerImpl;
import com.l7tech.util.ExceptionUtils;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.naming.NamingException;

class a
extends AbstractJmsEndpointListener {
    private static final Logger j;
    private final JmsRequestHandlerImpl k;
    private MessageProducer l;
    private static final String[] n;

    a(JmsEndpointConfig jmsEndpointConfig) {
        super(jmsEndpointConfig, j);
        this.k = new JmsRequestHandlerImpl(jmsEndpointConfig.getApplicationContext());
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Loose catch block
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    MessageProducer b() throws JMSException, NamingException, JmsConnectionMaxWaitException, JmsRuntimeException {
        Object object = this.sync;
        synchronized (object) {
            if (this.l != null) return this.l;
            try {
                if (!this._endpointCfg.isTransactional()) return this.l;
                if (this._endpointCfg.getEndpoint().getFailureDestinationName() == null) return this.l;
            }
            catch (JMSException jMSException) {
                throw a.a(jMSException);
            }
            j.finest(n[0]);
            boolean bl2 = false;
            String string = null;
            try {
                JmsBag jmsBag = this.getJmsBag();
                Session session = jmsBag.getSession();
                Queue queue = this.getFailureQueue();
                this.l = JmsUtil.createMessageProducer(session, (Destination)queue);
                bl2 = true;
            }
            catch (JMSException jMSException) {
                try {
                    string = ExceptionUtils.getMessage((Throwable)jMSException);
                    throw jMSException;
                    catch (NamingException namingException) {
                        string = ExceptionUtils.getMessage((Throwable)namingException);
                        throw namingException;
                    }
                    catch (JmsConnectionMaxWaitException jmsConnectionMaxWaitException) {
                        string = ExceptionUtils.getMessage((Throwable)jmsConnectionMaxWaitException);
                        throw jmsConnectionMaxWaitException;
                    }
                    catch (RuntimeException runtimeException) {
                        string = ExceptionUtils.getMessage((Throwable)runtimeException);
                        throw runtimeException;
                    }
                    catch (JmsRuntimeException jmsRuntimeException) {
                        string = ExceptionUtils.getMessage((Throwable)jmsRuntimeException);
                        throw jmsRuntimeException;
                    }
                }
                catch (Throwable throwable) {
                    try {
                        if (bl2) throw throwable;
                        this.fireConnectError(string);
                        throw throwable;
                    }
                    catch (JMSException jMSException2) {
                        throw a.a(jMSException2);
                    }
                }
            }
            try {
                if (bl2) return this.l;
                this.fireConnectError(string);
            }
            catch (JMSException jMSException) {
                throw a.a(jMSException);
            }
            return this.l;
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    @Override
    protected void cleanup() {
        Object object = this.sync;
        synchronized (object) {
            if (this.l != null) {
                try {
                    this.l.close();
                }
                catch (JMSException jMSException) {
                    j.log(Level.INFO, n[1], jMSException);
                }
                this.l = null;
            }
            super.cleanup();
        }
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[2];
        int n2 = 0;
        String string = "OA?(R\u001f8(J.+\u001b<:{W*;^!-g@>?^\u0003\"KE>;S\u0005\u007fBi\u0018\u0019C\u0012:xP\"3UQ;}V\"2\\Q<dA*2N\u0001";
        int n3 = "OA?(R\u001f8(J.+\u001b<:{W*;^!-g@>?^\u0003\"KE>;S\u0005\u007fBi\u0018\u0019C\u0012:xP\"3UQ;}V\"2\\Q<dA*2N\u0001".length();
        int n4 = 27;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = a.b(71, a.b(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                n = stringArray;
                j = Logger.getLogger(a.class.getName());
                return;
            }
            n4 = string.charAt(n5);
        }
    }

    private static JMSException a(JMSException jMSException) {
        return jMSException;
    }

    private static char[] b(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x18);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String b(int n2, char[] cArray) {
        char[] cArray2;
        block11: {
            int n3;
            int n4;
            int n5;
            block10: {
                n5 = n2;
                cArray2 = cArray;
                n4 = cArray.length;
                n3 = 0;
                if (!true) break block10;
                n4 = n4;
                if (n4 <= n3) break block11;
            }
            do {
                n5 = n5;
                cArray2 = cArray2;
                int n6 = n3;
                cArray2[n6] = (char)(cArray2[n6] ^ (n5 ^ (switch (n3 % 7) {
                    case 0 -> 79;
                    case 1 -> 99;
                    case 2 -> 12;
                    case 3 -> 27;
                    case 4 -> 124;
                    case 5 -> 54;
                    default -> 24;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

