/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.util.ExceptionUtils
 *  javax.jms.Connection
 *  javax.jms.ConnectionFactory
 *  javax.jms.MessageConsumer
 *  javax.jms.MessageProducer
 *  javax.jms.Session
 */
package com.l7tech.server.transport.jms;

import com.l7tech.util.ExceptionUtils;
import java.io.Closeable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.naming.Context;

public class JmsBag
implements Closeable {
    private static final Logger a;
    private ConnectionFactory b;
    private Connection c;
    private Session d;
    private Context e;
    private MessageConsumer f;
    private MessageProducer g;
    private Object h;
    protected volatile boolean closed;
    private static final String[] i;

    public JmsBag(Context context, ConnectionFactory connectionFactory, Connection connection, Session session, MessageConsumer messageConsumer, MessageProducer messageProducer, Object object) {
        this.b = connectionFactory;
        this.c = connection;
        this.d = session;
        this.e = context;
        this.f = messageConsumer;
        this.g = messageProducer;
        this.h = object;
    }

    public JmsBag(Context context, ConnectionFactory connectionFactory, Connection connection, Session session, Object object) {
        this(context, connectionFactory, connection, session, null, null, object);
    }

    public ConnectionFactory getConnectionFactory() {
        this.a();
        return this.b;
    }

    public Connection getConnection() {
        this.a();
        return this.c;
    }

    public Session getSession() {
        this.a();
        return this.d;
    }

    public Context getJndiContext() {
        this.a();
        return this.e;
    }

    public Object getBagOwner() {
        return this.h;
    }

    public MessageConsumer getMessageConsumer() {
        return this.f;
    }

    public void closeSession() {
        String[] stringArray;
        if (this.f != null) {
            try {
                this.f.close();
            }
            catch (Exception exception) {
                stringArray = i;
                this.a(stringArray[7], exception);
            }
            this.f = null;
        }
        if (this.g != null) {
            try {
                this.g.close();
            }
            catch (Exception exception) {
                stringArray = i;
                this.a(stringArray[1], exception);
            }
            this.g = null;
        }
        if (this.d != null) {
            try {
                this.d.close();
            }
            catch (Exception exception) {
                this.a(i[4], exception);
            }
            this.d = null;
        }
    }

    @Override
    public void close() {
        if (!this.closed) {
            try {
                this.closeSession();
                if (this.c != null) {
                    String[] stringArray;
                    try {
                        this.c.stop();
                    }
                    catch (Exception exception) {
                        stringArray = i;
                        this.a(stringArray[2], exception);
                    }
                    try {
                        this.c.close();
                    }
                    catch (Exception exception) {
                        stringArray = i;
                        this.a(stringArray[0], exception);
                    }
                }
                if (this.e != null) {
                    try {
                        this.e.close();
                    }
                    catch (Exception exception) {
                        this.a(i[5], exception);
                    }
                }
            }
            finally {
                this.closed = true;
            }
        }
    }

    private void a(String string, Exception exception) {
        String[] stringArray = i;
        a.log(Level.WARNING, stringArray[8] + string + stringArray[3] + ExceptionUtils.getMessage((Throwable)exception), ExceptionUtils.getDebugException((Throwable)exception));
    }

    private void a() {
        try {
            if (this.closed) {
                throw new IllegalStateException(i[6]);
            }
        }
        catch (IllegalStateException illegalStateException) {
            throw JmsBag.a(illegalStateException);
        }
    }

    public MessageProducer getMessageProducer() {
        return this.g;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[9];
                var3_1 = 0;
                var2_2 = "qw\u00054'qI{w\u0005\u0014ty\u000267`XCm\u000e/'BO}|\u001e9'`\u000fal\u0004*bqR|v\u000e96{R|\u0003;\"K\u0007a}\u0018)+}S\u0004xv\u000f3\u0013Py\fz*sN2z\u000e?,2^~w\u0018?&";
                var4_3 = "qw\u00054'qI{w\u0005\u0014ty\u000267`XCm\u000e/'BO}|\u001e9'`\u000fal\u0004*bqR|v\u000e96{R|\u0003;\"K\u0007a}\u0018)+}S\u0004xv\u000f3\u0013Py\fz*sN2z\u000e?,2^~w\u0018?&".length();
                var1_4 = 10;
                var0_5 = -1;
lbl7:
                // 2 sources

                while (true) {
                    v0 = 72;
                    v1 = ++var0_5;
                    v2 = var2_2.substring(v1, v1 + var1_4);
                    v3 = -1;
                    break block9;
                    break;
                }
lbl13:
                // 1 sources

                while (true) {
                    var5[var3_1++] = JmsBag.a(v0, JmsBag.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "\u0010\u0016dHV\u001e9\u0001\u00166\u000bxTQS?\u001f\u0016yRM\u0014|9\u0014yyB\u0014|[";
                    var4_3 = "\u0010\u0016dHV\u001e9\u0001\u00166\u000bxTQS?\u001f\u0016yRM\u0014|9\u0014yyB\u0014|[".length();
                    var1_4 = 8;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 41;
                        v4 = ++var0_5;
                        v2 = var2_2.substring(v4, v4 + var1_4);
                        v3 = 0;
                        break block9;
                        break;
                    }
                    break;
                }
lbl28:
                // 1 sources

                while (true) {
                    var5[var3_1++] = JmsBag.a(v0, JmsBag.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    break block10;
                    break;
                }
            }
            switch (v3) {
                default: {
                    ** continue;
                }
                ** case 0:
lbl39:
                // 1 sources

                ** continue;
            }
        }
        JmsBag.i = var5;
        JmsBag.a = Logger.getLogger(JmsBag.class.getName());
    }

    private static IllegalStateException a(IllegalStateException illegalStateException) {
        return illegalStateException;
    }

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

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String a(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 -> 90;
                    case 1 -> 80;
                    case 2 -> 35;
                    case 3 -> 18;
                    case 4 -> 10;
                    case 5 -> 90;
                    default -> 117;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

