001: /*
002: * Created on 30/09/2005
003: *
004: * Swing Components - visit http://sf.net/projects/gfd
005: *
006: * Copyright (C) 2004 Igor Regis da Silva Simões
007: *
008: * This program is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public License
010: * as published by the Free Software Foundation; either version 2
011: * of the License, or (at your option) any later version.
012: *
013: * This program is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
021: *
022: */
023: package br.com.gfp.util;
024:
025: import java.awt.Component;
026: import java.io.File;
027: import java.util.Locale;
028:
029: import javax.swing.JOptionPane;
030:
031: import br.com.gfp.dao.GFPController;
032: import br.com.gfp.internationalization.ErrosDeDadosMessages;
033:
034: /**
035: *
036: * @author Igor Regis da Silva Simoes
037: * @since 30/09/2005
038: */
039: public class GFPThreadGroup extends ThreadGroup {
040: private SimpleLog log = null;
041:
042: /**
043: * Cria um novo grupo de threads
044: * @param parent O Thread group pai
045: * @param release Versão do GFP
046: */
047: public GFPThreadGroup(ThreadGroup parent, String release) {
048: //------------------------------------------------
049: super (parent, "GFPThreadGroup");
050:
051: GFPController.getGFPController().getContexto().put(
052: GFPController.LOG,
053: new SimpleLog("GFP", System.getProperty("user.dir")
054: + File.separator + "log"));
055:
056: log = (SimpleLog) GFPController.getGFPController()
057: .getContexto().get(GFPController.LOG);
058:
059: log
060: .log("\t______________________________________________________");
061: log.log("\t| Abrindo GFP - " + release
062: + " |");
063: log
064: .log("\t|_____________________________________________________|");
065: log.log("OS: " + System.getProperty("os.name") + " / "
066: + System.getProperty("os.version"));
067: log.log("JVM: " + System.getProperty("java.vm.name") + " / "
068: + System.getProperty("java.vm.version"));
069: log.log("Exec. dir. " + System.getProperty("user.dir"));
070: log.log("Total Memory: " + Runtime.getRuntime().totalMemory());
071: log.log("Free Memory: " + Runtime.getRuntime().freeMemory());
072: log.log("Locale: " + Locale.getDefault());
073:
074: // new Thread()
075: // {
076: // public void run()
077: // {
078: // while(true)
079: // try
080: // {
081: // Thread.sleep(5000);
082: // Thread[] t = new Thread[Thread.activeCount()];
083: // GFPThreadGroup.this.enumerate(t);
084: // for (int i = 0; i < t.length; i++)
085: // {
086: // if (t[i] != null)
087: // System.out.println("Thread " + t[i].getName());
088: // }
089: // System.out.println();
090: // }
091: // catch (InterruptedException e)
092: // {
093: // e.printStackTrace();
094: // }
095: // }
096: // }.start();
097: }
098:
099: /**
100: * @see java.lang.ThreadGroup#uncaughtException(java.lang.Thread, java.lang.Throwable)
101: */
102: @Override
103: public void uncaughtException(Thread t, Throwable e) {
104: if (e instanceof NoClassDefFoundError) {
105: if (e.getMessage().indexOf("org/apache/poi/") != -1) {
106: JOptionPane.showMessageDialog((Component) GFPController
107: .getGFPController().getContexto().get(
108: GFPController.FRAME_PRINCIPAL),
109: ErrosDeDadosMessages.getMessages().getString(
110: "InstaleXLSPlugin"),
111: ErrosDeDadosMessages.getMessages().getString(
112: "MessageTitle"),
113: JOptionPane.ERROR_MESSAGE);
114: return;
115: } else if (e.getMessage().indexOf("com/lowagie/text") != -1) {
116: JOptionPane.showMessageDialog((Component) GFPController
117: .getGFPController().getContexto().get(
118: GFPController.FRAME_PRINCIPAL),
119: ErrosDeDadosMessages.getMessages().getString(
120: "InstalePDFPlugin"),
121: ErrosDeDadosMessages.getMessages().getString(
122: "MessageTitle"),
123: JOptionPane.ERROR_MESSAGE);
124: return;
125: }
126: }
127:
128: log
129: .log(
130: "*************************************************************",
131: t.getName());
132: log.log("Total Memory: " + Runtime.getRuntime().totalMemory());
133: log.log("Free Memory: " + Runtime.getRuntime().freeMemory());
134: log.log("Excecao nao tratada! " + e.getLocalizedMessage(), t
135: .getName());
136: if (!log.log(e, t.getName())) {
137: if (getParent() != null)
138: getParent().uncaughtException(t, e);
139: } else
140: log
141: .log(
142: "*************************************************************",
143: t.getName());
144:
145: }
146: }
|