/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.common.log.HybridDiagnosticContext
 *  com.l7tech.util.ExceptionUtils
 *  javax.jms.JMSException
 *  javax.jms.Message
 *  javax.jms.MessageListener
 *  javax.jms.MessageProducer
 */
package com.l7tech.server.transport.jms2.asynch;

import com.l7tech.common.log.HybridDiagnosticContext;
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.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.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;

public class JmsTask
implements MessageListener {
    private static final Logger a;
    private final JmsEndpointConfig b;
    private JmsBag c;
    private MessageProducer d;
    private JmsRequestHandlerImpl e;
    private static final String[] f;

    public JmsTask(JmsEndpointConfig jmsEndpointConfig, JmsBag jmsBag) {
        this.b = jmsEndpointConfig;
        this.c = jmsBag;
        this.e = new JmsRequestHandlerImpl(jmsEndpointConfig.getApplicationContext());
    }

    public void onMessage(Message message) {
        try {
            try {
                if (!this.b.isTransactional()) {
                    message.acknowledge();
                }
            }
            catch (JMSException jMSException) {
                throw JmsTask.a(jMSException);
            }
            this.a(message);
        }
        catch (JMSException jMSException) {
            String[] stringArray = f;
            a.log(Level.WARNING, stringArray[5] + JmsUtil.getJMSErrorMessage(jMSException), ExceptionUtils.getDebugException((Throwable)jMSException));
        }
        catch (JmsRuntimeException jmsRuntimeException) {
            JMSException jMSException;
            try {
                jMSException = jmsRuntimeException.getCause() instanceof JMSException ? (JMSException)jmsRuntimeException.getCause() : null;
            }
            catch (JMSException jMSException2) {
                throw JmsTask.a(jMSException2);
            }
            JMSException jMSException3 = jMSException;
            Object object = "";
            if (jMSException3 != null) {
                String[] stringArray = f;
                object = stringArray[4] + JmsUtil.getJMSErrorMessage(jMSException3);
            }
            String string = object;
            String string2 = ExceptionUtils.getMessage((Throwable)jmsRuntimeException);
            a.log(Level.WARNING, f[2] + string2 + string, ExceptionUtils.getDebugException((Throwable)jmsRuntimeException));
        }
    }

    void a(Message message) throws JmsRuntimeException {
        String[] stringArray = f;
        HybridDiagnosticContext.put((String)stringArray[3], (String)this.b.getEndpoint().getGoid().toString());
        HybridDiagnosticContext.put((String)stringArray[6], (String)this.b.getEndpoint().getName());
        try {
            this.e.onMessage(this.b, this.c, this.b.isTransactional(), message);
        }
        catch (Throwable throwable) {
            stringArray = f;
            HybridDiagnosticContext.remove((String)stringArray[0]);
            HybridDiagnosticContext.remove((String)stringArray[1]);
            throw throwable;
        }
        HybridDiagnosticContext.remove((String)stringArray[0]);
        HybridDiagnosticContext.remove((String)stringArray[1]);
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[7];
                var3_1 = 0;
                var2_2 = "5B~95&h+Jcq+br;\f5B~95&h+Jcq+\u0018\u001a]\u007f{+os>Aix0!|\u007fBhg*.|:\u0015-\u000f5B~95&h+Jcq+br;\ts\u000fia<oo0\u000f";
                var4_3 = "5B~95&h+Jcq+br;\f5B~95&h+Jcq+\u0018\u001a]\u007f{+os>Aix0!|\u007fBhg*.|:\u0015-\u000f5B~95&h+Jcq+br;\ts\u000fia<oo0\u000f".length();
                var1_4 = 15;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = JmsTask.a(v0, JmsTask.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "q6\u0014\u0010@\u0004\u0018U*\u0002\u0013[J\u0017\u0014)\u0003\fAE\u0017Q~F\f^)\u0015R^M\u0003@!\b\u001a@";
                    var4_3 = "q6\u0014\u0010@\u0004\u0018U*\u0002\u0013[J\u0017\u0014)\u0003\fAE\u0017Q~F\f^)\u0015R^M\u0003@!\b\u001a@".length();
                    var1_4 = 24;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 56;
                        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++] = JmsTask.a(v0, JmsTask.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;
            }
        }
        JmsTask.f = var5;
        JmsTask.a = Logger.getLogger(JmsTask.class.getName());
    }

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

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x48);
        }
        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 -> 12;
                    case 1 -> 124;
                    case 2 -> 94;
                    case 3 -> 71;
                    case 4 -> 10;
                    case 5 -> 28;
                    default -> 72;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

