package org.jonnyzzz.stack.impl;

import com.sun.istack.internal.logging.Logger;
import org.jetbrains.annotations.NotNull;
import org.jonnyzzz.stack.NamedStackFrame;
import org.jonnyzzz.stack.impl.gen.NamedExecutorsGenerator;
import org.jonnyzzz.stack.impl.gen.jcl.JavaClassLoaderGenerator;
import org.jonnyzzz.stack.impl.gen.stub.EmptyExecutorsGenerator;
import org.jonnyzzz.stack.impl.gen.stub.StubExecutorImpl;

/**
 * @author Eugene Petrenko (eugene.petrenko@gmail.com)
 */
public class NamedExecutors implements NamedExecutorsGenerator {
    private final NamedExecutorsGenerator myLoader = init();

    private NamedExecutorsGenerator init() {
        try {
            return new JavaClassLoaderGenerator();
        } catch (Throwable t) {
            Logger.getLogger(NamedStackFrame.class).warning("Failed to initialize proxy for NamedStackFrame. " + t.getMessage() + ". Default proxy will be used", t);
            return new EmptyExecutorsGenerator();
        }
    }

    @NotNull
    public NamedExecutor generate(@NotNull final String name) {
        try {
            return myLoader.generate(name);
        } catch (Throwable t) {
            //failed to generate the proxy, so we fallback
            Logger.getLogger(NamedStackFrame.class).warning("Failed to generate proxy for NamedStackFrame with name '" + name + "'. " + t.getMessage() + ". Default proxy will be used", t);
            return new StubExecutorImpl();
        }
    }
}

@@ -31,55 +31,8 @@
 l;%0A%0A
-import com.sun.istack.internal.logging.Logger;%0A
 impo
@@ -361,16 +361,50 @@
 rImpl;%0A%0A
+import java.util.logging.Logger;%0A%0A
 /**%0A * @
@@ -743,46 +743,15 @@
     
-Logger.getLogger(NamedStackFrame.class
+logger(
 ).wa
@@ -848,35 +848,32 @@
 xy will be used%22
-, t
 );%0A            r
@@ -1168,46 +1168,15 @@
     
-Logger.getLogger(NamedStackFrame.class
+logger(
 ).wa
@@ -1308,11 +1308,8 @@
 sed%22
-, t
 );%0A 
@@ -1365,11 +1365,127 @@
  %7D%0A    %7D
+%0A%0A    @NotNull%0A    private Logger logger() %7B%0A        return Logger.getLogger(NamedStackFrame.class.getName());%0A    %7D
 %0A%7D%0A

use right logger