logger classes fixed, added new events (swf, abc, method body parsed)

This commit is contained in:
2014-09-01 13:33:35 +02:00
parent c27eeafce4
commit 8325d07b24
26 changed files with 186 additions and 120 deletions
@@ -1,32 +0,0 @@
/*
* Copyright (C) 2010-2014 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.␍ */
package com.jpexs.decompiler.flash.helpers;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.action.ActionList;
/**
*
* @author JPEXS
*/
public class EmptySWFDecompilerListener implements SWFDecompilerListener {
@Override
public void actionListParsed(ActionList actions, SWF swf) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
@@ -12,10 +12,13 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.␍ */
* License along with this library.
*/
package com.jpexs.decompiler.flash.helpers;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.action.ActionList;
/**
@@ -24,5 +27,11 @@ import com.jpexs.decompiler.flash.action.ActionList;
*/
public interface SWFDecompilerListener {
void swfParsed(SWF swf);
void actionListParsed(ActionList actions, SWF swf);
void abcParsed(ABC abc, SWF swf);
void methodBodyParsed(MethodBody body, SWF swf);
}
@@ -12,9 +12,14 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.␍ */
* License along with this library.
*/
package com.jpexs.decompiler.flash.helpers;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.action.ActionList;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.plugin.CharSequenceJavaFileObject;
import com.jpexs.helpers.plugin.ClassFileManager;
@@ -33,7 +38,8 @@ import javax.tools.ToolProvider;
*/
public class SWFDecompilerPlugin {
public static SWFDecompilerListener listener;
private static final Logger logger = Logger.getLogger(SWFDecompilerPlugin.class.getName());
private static final List<SWFDecompilerListener> listeners = new ArrayList<>();
public static void loadPlugin(String path) {
@@ -68,9 +74,53 @@ public class SWFDecompilerPlugin {
// Creating an instance of our compiled class and
try {
listener = (SWFDecompilerListener) fileManager.getClassLoader(null).loadClass(fullName).newInstance();
listeners.add((SWFDecompilerListener) fileManager.getClassLoader(null).loadClass(fullName).newInstance());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
Logger.getLogger(SWFDecompilerPlugin.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
public static boolean fireSwfParsed(SWF swf) {
for (SWFDecompilerListener listener : listeners) {
try {
listener.swfParsed(swf);
} catch (Throwable e) {
logger.log(Level.SEVERE, "Failed to call plugin method swfParsed.", e);
}
}
return !listeners.isEmpty();
}
public static boolean fireActionListParsed(ActionList actions, SWF swf) {
for (SWFDecompilerListener listener : listeners) {
try {
listener.actionListParsed(actions, swf);
} catch (Throwable e) {
logger.log(Level.SEVERE, "Failed to call plugin method actionListParsed.", e);
}
}
return !listeners.isEmpty();
}
public static boolean fireAbcParsed(ABC abc, SWF swf) {
for (SWFDecompilerListener listener : listeners) {
try {
listener.abcParsed(abc, swf);
} catch (Throwable e) {
logger.log(Level.SEVERE, "Failed to call plugin method abcParsed.", e);
}
}
return !listeners.isEmpty();
}
public static boolean fireMethodBodyParsed(MethodBody body, SWF swf) {
for (SWFDecompilerListener listener : listeners) {
try {
listener.methodBodyParsed(body, swf);
} catch (Throwable e) {
logger.log(Level.SEVERE, "Failed to call plugin method methodBodyParsed.", e);
}
}
return !listeners.isEmpty();
}
}