(empty log message)
@@ -6,10 +6,8 @@ | ||
6 | 6 | */ |
7 | 7 | package jp.sourceforge.mergedoc.pleiades; |
8 | 8 | |
9 | -import java.io.File; | |
10 | 9 | import java.lang.instrument.Instrumentation; |
11 | 10 | |
12 | -import jp.sourceforge.mergedoc.pleiades.log.FileLogger; | |
13 | 11 | import jp.sourceforge.mergedoc.pleiades.log.Logger; |
14 | 12 | import jp.sourceforge.mergedoc.pleiades.runtime.Applicationz; |
15 | 13 | import jp.sourceforge.mergedoc.pleiades.runtime.LauncherTransformer; |
@@ -25,16 +23,19 @@ | ||
25 | 23 | /** Pleiades パッケージ名 (プラグイン名) */ |
26 | 24 | public static final String PACKAGE_NAME = Pleiades.class.getPackage().getName(); |
27 | 25 | |
26 | + /** Java アプリケーション起動時の -javaagent 引数 (JUnit や未指定の場合は null) */ | |
27 | + private static String javaagentArg; | |
28 | + | |
28 | 29 | /** バイトコード変換トランスフォーマーを登録・削除するための Instrumentation */ |
29 | 30 | private static Instrumentation instrumentation; |
30 | 31 | |
31 | - /** Pleiades コンテキスト */ | |
32 | - private static PleiadesContext pleiadesContext; | |
33 | - | |
34 | 32 | /** |
35 | - * 対象 Java アプリケーションの起動前に呼び出されるメソッドです。<br> | |
36 | - * 起動時の main スレッドから呼び出されるため、時間がかかる処理は非同期で行います。 | |
37 | - * @param agentArg -javaagent 引数 | |
33 | + * 対象 Java アプリケーションの起動前に呼び出されるメソッドです。 | |
34 | + * <ul> | |
35 | + * <li>起動時の main スレッドから呼び出されるため、時間がかかる処理は非同期で行います。 | |
36 | + * <li>main スレッドではログも通常は出力しません。 | |
37 | + * </ul> | |
38 | + * @param agentArg -javaagent 引数 (未指定の場合は null) | |
38 | 39 | * @param inst トランスフォーマー登録・削除用 Instrumentation |
39 | 40 | */ |
40 | 41 | public static void premain(final String agentArg, final Instrumentation inst) { |
@@ -44,17 +45,15 @@ | ||
44 | 45 | if (instrumentation != null) { |
45 | 46 | Logger log = Logger.getLogger(Pleiades.class); |
46 | 47 | log.info("instrumentation がすでに存在するため premain 処理を実行しません。"); |
47 | - pleiadesContext.isRestart = true; | |
48 | + PleiadesContext.getInstance().isRestart = true; | |
48 | 49 | return; |
49 | 50 | } |
51 | + javaagentArg = agentArg; | |
50 | 52 | instrumentation = inst; |
51 | 53 | |
52 | - // アプリケーションやロガーの初期化 | |
53 | - // 高速化: ここは起動時の main スレッドのため、getLogger やログ出力しない | |
54 | - pleiadesContext = new PleiadesContext(agentArg); | |
54 | + // アプリケーションの初期化と起動トランスフォーマーの登録 | |
55 | 55 | Applicationz.init(); |
56 | - File logFile = Applicationz.temp("pleiades.log"); | |
57 | - Logger.init(FileLogger.class, pleiadesContext.logLevel, logFile); | |
56 | + instrumentation.addTransformer(LauncherTransformer.getInstance()); | |
58 | 57 | |
59 | 58 | // Swing L&F 変更 - パフォーマンス以外に下記の理由により廃止 |
60 | 59 | // ・Windows Aptana でファイルタブから「Local Filesystem」を開くと VM クラッシュ |
@@ -62,9 +61,6 @@ | ||
62 | 61 | // ・同期処理でもタイミングによりイベントディスパッチスレッドで NPE が発生する |
63 | 62 | // ・Fedora6, 7 や CentOS では NPE が発生する |
64 | 63 | |
65 | - // 起動トランスフォーマーの登録 | |
66 | - instrumentation.addTransformer(LauncherTransformer.getInstance()); | |
67 | - | |
68 | 64 | } catch (Throwable e) { |
69 | 65 | abort(e, "Pleiades 初期化時にエラーが発生しました。"); |
70 | 66 | } |
@@ -71,25 +67,19 @@ | ||
71 | 67 | } |
72 | 68 | |
73 | 69 | /** |
74 | - * AOP バイトコード変換トランスフォーマーを登録・削除するための Instrumentation を取得します。 | |
75 | - * @return AOP トランスフォーマー登録・削除用 Instrumentation (not null) | |
70 | + * Java アプリケーション起動時の -javaagent 引数を取得します。 | |
71 | + * @return -javaagent 引数 (JUnit や 未指定時は null) | |
76 | 72 | */ |
77 | - public static Instrumentation getInstrumentation() { | |
78 | - return instrumentation; | |
73 | + public static String getJavaagentArg() { | |
74 | + return javaagentArg; | |
79 | 75 | } |
80 | 76 | |
81 | 77 | /** |
82 | - * Pleiades コンテキストを取得します。 | |
83 | - * @return Pleiades コンテキスト (not null) | |
78 | + * AOP バイトコード変換トランスフォーマーを登録・削除するための Instrumentation を取得します。 | |
79 | + * @return AOP トランスフォーマー登録・削除用 Instrumentation (JUnit は null) | |
84 | 80 | */ |
85 | - public static PleiadesContext getPleiadesContext() { | |
86 | - | |
87 | - if (pleiadesContext == null) { | |
88 | - Logger log = Logger.getLogger(Pleiades.class); | |
89 | - log.info("[JUnit/Tool] ツール向け PleiadesContext を生成しました。"); | |
90 | - pleiadesContext = new PleiadesContext(); | |
91 | - } | |
92 | - return pleiadesContext; | |
81 | + public static Instrumentation getInstrumentation() { | |
82 | + return instrumentation; | |
93 | 83 | } |
94 | 84 | |
95 | 85 | /** |
@@ -54,10 +54,32 @@ | ||
54 | 54 | |
55 | 55 | /** アプリケーション識別名 (デフォルト null) */ |
56 | 56 | public String appName; |
57 | + | |
58 | + // ------------------------------------------------------------------------------------------- | |
59 | + | |
60 | + /** Pleiades コンテキストのシングルトンインスタンス */ | |
61 | + private static final PleiadesContext singleton; | |
62 | + static { | |
63 | + if (Pleiades.getInstrumentation() != null) { | |
64 | + singleton = new PleiadesContext(Pleiades.getJavaagentArg()); | |
65 | + } else { | |
66 | + singleton = new PleiadesContext(); | |
67 | + System.out.println("JUnit や生成ツール向けの PleiadesContext を生成しました。"); | |
68 | + } | |
69 | + } | |
70 | + | |
71 | + /** | |
72 | + * Pleiades コンテキストを取得します。<br> | |
73 | + * pleiades-config.xml からも呼び出されていることに注意してください。 | |
74 | + * @return Pleiades コンテキスト (not null) | |
75 | + */ | |
76 | + public static PleiadesContext getInstance() { | |
77 | + return singleton; | |
78 | + } | |
57 | 79 | |
58 | 80 | /** |
59 | 81 | * Pleiades コンテキストを構築します。<br> |
60 | - * JUnit やツール用のコンストラクタです。 | |
82 | + * JUnit や生成ツール用のコンストラクタです。 | |
61 | 83 | */ |
62 | 84 | PleiadesContext() { |
63 | 85 |
@@ -16,7 +16,7 @@ | ||
16 | 16 | import java.util.Set; |
17 | 17 | import java.util.regex.Pattern; |
18 | 18 | |
19 | -import jp.sourceforge.mergedoc.pleiades.Pleiades; | |
19 | +import jp.sourceforge.mergedoc.pleiades.PleiadesContext; | |
20 | 20 | import jp.sourceforge.mergedoc.pleiades.log.Logger; |
21 | 21 | import jp.sourceforge.mergedoc.pleiades.runtime.Applicationz; |
22 | 22 |
@@ -41,7 +41,7 @@ | ||
41 | 41 | |
42 | 42 | /** 訳無しプロパティーインスタンスの初期化 */ |
43 | 43 | static { |
44 | - if (Pleiades.getPleiadesContext().enabledNotFoundLog) { | |
44 | + if (PleiadesContext.getInstance().enabledNotFoundLog) { | |
45 | 45 | singleton = new TranslationNotFoundProperties(); |
46 | 46 | } else { |
47 | 47 | singleton = new TranslationNotFoundProperties() { |
@@ -26,7 +26,6 @@ | ||
26 | 26 | import javassist.CtBehavior; |
27 | 27 | import javassist.CtClass; |
28 | 28 | import javassist.NotFoundException; |
29 | -import jp.sourceforge.mergedoc.pleiades.Pleiades; | |
30 | 29 | import jp.sourceforge.mergedoc.pleiades.PleiadesContext; |
31 | 30 | import jp.sourceforge.mergedoc.pleiades.log.Logger; |
32 | 31 | import jp.sourceforge.mergedoc.pleiades.resource.Filez; |
@@ -48,7 +47,7 @@ | ||
48 | 47 | private static final ClassPool javassist = new ClassPool(true); |
49 | 48 | |
50 | 49 | /** Pleiades コンテキスト */ |
51 | - protected static final PleiadesContext pleiadesContext = Pleiades.getPleiadesContext(); | |
50 | + protected static final PleiadesContext pleiadesContext = PleiadesContext.getInstance(); | |
52 | 51 | |
53 | 52 | // ------------------------------------------------------------------------------------------- |
54 | 53 |
@@ -15,6 +15,7 @@ | ||
15 | 15 | import java.util.function.Function; |
16 | 16 | |
17 | 17 | import jp.sourceforge.mergedoc.pleiades.Pleiades; |
18 | +import jp.sourceforge.mergedoc.pleiades.PleiadesContext; | |
18 | 19 | import jp.sourceforge.mergedoc.pleiades.log.Logger; |
19 | 20 | import jp.sourceforge.mergedoc.pleiades.log.Logger.LogLevel; |
20 | 21 | import jp.sourceforge.mergedoc.pleiades.runtime.resource.CallHierarchyExplorer; |
@@ -34,7 +35,7 @@ | ||
34 | 35 | private static final Logger log = Logger.getLogger(Analyses.class); |
35 | 36 | |
36 | 37 | /** デバッグ時は true */ |
37 | - private static final boolean IS_DEBUG = Pleiades.getPleiadesContext().logLevel == LogLevel.DEBUG; | |
38 | + private static final boolean IS_DEBUG = PleiadesContext.getInstance().logLevel == LogLevel.DEBUG; | |
38 | 39 | |
39 | 40 | /** |
40 | 41 | * 呼び出し回数時間マップ<br> |
@@ -15,11 +15,14 @@ | ||
15 | 15 | import org.apache.commons.lang3.SystemUtils; |
16 | 16 | |
17 | 17 | import jp.sourceforge.mergedoc.pleiades.Pleiades; |
18 | +import jp.sourceforge.mergedoc.pleiades.PleiadesContext; | |
19 | +import jp.sourceforge.mergedoc.pleiades.log.FileLogger; | |
20 | +import jp.sourceforge.mergedoc.pleiades.log.Logger; | |
18 | 21 | import jp.sourceforge.mergedoc.pleiades.resource.Filez; |
19 | 22 | import jp.sourceforge.mergedoc.pleiades.resource.PatternCache; |
20 | 23 | |
21 | 24 | /** |
22 | - * アプリケーション情報を参照するためのユーティリティクラスです。 | |
25 | + * アプリケーションのユーティリティクラスです。 | |
23 | 26 | * @author cypher256 |
24 | 27 | */ |
25 | 28 | public class Applicationz { |
@@ -31,7 +34,8 @@ | ||
31 | 34 | private static final Properties configIni = new Properties(); |
32 | 35 | |
33 | 36 | /** |
34 | - * Pleiades のログやキャッシュを保存する一時ディレクトリー | |
37 | + * Pleiades のログやキャッシュを保存する一時ディレクトリー<br> | |
38 | + * 通常は eclipse/configuration/jp.sourceforge.mergedoc.pleiades | |
35 | 39 | */ |
36 | 40 | private static File pleiadesTempDir; |
37 | 41 |
@@ -83,6 +87,10 @@ | ||
83 | 87 | } |
84 | 88 | } |
85 | 89 | pleiadesTempDir.mkdirs(); |
90 | + | |
91 | + // ロガーの初期化 (init 前に Logger.getLogger すると System.out が使用されることに注意) | |
92 | + File logFile = new File(pleiadesTempDir, "pleiades.log"); | |
93 | + Logger.init(FileLogger.class, PleiadesContext.getInstance().logLevel, logFile); | |
86 | 94 | } |
87 | 95 | |
88 | 96 | /** |
@@ -20,7 +20,6 @@ | ||
20 | 20 | import javax.swing.JLabel; |
21 | 21 | import javax.swing.JWindow; |
22 | 22 | |
23 | -import jp.sourceforge.mergedoc.pleiades.Pleiades; | |
24 | 23 | import jp.sourceforge.mergedoc.pleiades.PleiadesContext; |
25 | 24 | import jp.sourceforge.mergedoc.pleiades.log.Logger; |
26 | 25 | import jp.sourceforge.mergedoc.pleiades.resource.Filez; |
@@ -44,7 +43,7 @@ | ||
44 | 43 | */ |
45 | 44 | public static void show(final String splashFilePath) { |
46 | 45 | |
47 | - PleiadesContext pleiadesContext = Pleiades.getPleiadesContext(); | |
46 | + PleiadesContext pleiadesContext = PleiadesContext.getInstance(); | |
48 | 47 | if (!pleiadesContext.isClean) { |
49 | 48 | return; |
50 | 49 | } |
@@ -58,11 +58,11 @@ | ||
58 | 58 | @Override |
59 | 59 | protected void init() { |
60 | 60 | |
61 | - File plugins = Applicationz.osgiHome("plugins"); | |
62 | - File dropins = Applicationz.osgiHome("dropins"); | |
63 | - | |
64 | 61 | Asyncz.executeLog("プラグインの jar を AOP クラスパスへ追加", () -> { |
65 | 62 | |
63 | + File plugins = Applicationz.osgiHome("plugins"); | |
64 | + File dropins = Applicationz.osgiHome("dropins"); | |
65 | + | |
66 | 66 | // 直下の plugins |
67 | 67 | File[] jars = Filez.listBySuffix(plugins, ".jar"); |
68 | 68 |
@@ -132,6 +132,9 @@ | ||
132 | 132 | |
133 | 133 | Asyncz.executeForceClean("Eclipse プラグイン最終更新時刻の判定", () -> { |
134 | 134 | |
135 | + File plugins = Applicationz.osgiHome("plugins"); | |
136 | + File dropins = Applicationz.osgiHome("dropins"); | |
137 | + | |
135 | 138 | // 更新チェック (明示的な -clean 時でも次回起動時に前回更新日時が必要なため実行する) |
136 | 139 | if (new UpdateDetector().isUpdated(plugins, dropins)) { |
137 | 140 |
@@ -18,6 +18,7 @@ | ||
18 | 18 | import org.apache.commons.lang3.builder.ToStringStyle; |
19 | 19 | |
20 | 20 | import jp.sourceforge.mergedoc.pleiades.Pleiades; |
21 | +import jp.sourceforge.mergedoc.pleiades.PleiadesContext; | |
21 | 22 | import jp.sourceforge.mergedoc.pleiades.log.Logger; |
22 | 23 | import jp.sourceforge.mergedoc.pleiades.resource.Filez; |
23 | 24 | import jp.sourceforge.mergedoc.pleiades.runtime.Analyses; |
@@ -66,7 +67,7 @@ | ||
66 | 67 | */ |
67 | 68 | private PleiadesConfig() { |
68 | 69 | |
69 | - String configXmlPath = Pleiades.getPleiadesContext().configXmlPath; | |
70 | + String configXmlPath = PleiadesContext.getInstance().configXmlPath; | |
70 | 71 | if (configXmlPath == null) { |
71 | 72 | log.info("[JUnit/Tool] configXmlPath が null のため Pleiades 構成ファイルをロードしませんでした。"); |
72 | 73 | traceConfig = null; |
@@ -15,7 +15,7 @@ | ||
15 | 15 | import java.util.List; |
16 | 16 | import java.util.Map; |
17 | 17 | |
18 | -import jp.sourceforge.mergedoc.pleiades.Pleiades; | |
18 | +import jp.sourceforge.mergedoc.pleiades.PleiadesContext; | |
19 | 19 | import jp.sourceforge.mergedoc.pleiades.log.Logger; |
20 | 20 | import jp.sourceforge.mergedoc.pleiades.resource.Filez; |
21 | 21 | import jp.sourceforge.mergedoc.pleiades.resource.PropertySet; |
@@ -48,7 +48,7 @@ | ||
48 | 48 | */ |
49 | 49 | private ExcludePackageProperties() { |
50 | 50 | |
51 | - String appName = Pleiades.getPleiadesContext().appName; | |
51 | + String appName = PleiadesContext.getInstance().appName; | |
52 | 52 | if (appName == null) { |
53 | 53 | return; |
54 | 54 | } |
@@ -4,7 +4,7 @@ | ||
4 | 4 | import java.util.LinkedHashMap; |
5 | 5 | import java.util.Map; |
6 | 6 | |
7 | -import jp.sourceforge.mergedoc.pleiades.Pleiades; | |
7 | +import jp.sourceforge.mergedoc.pleiades.PleiadesContext; | |
8 | 8 | import jp.sourceforge.mergedoc.pleiades.log.Logger; |
9 | 9 | import jp.sourceforge.mergedoc.pleiades.runtime.advice.RuntimeJoinPoint; |
10 | 10 |
@@ -63,7 +63,7 @@ | ||
63 | 63 | |
64 | 64 | /** このクラスのシングルトンインスタンス */ |
65 | 65 | private static final TranslationCache instance |
66 | - = "idea".equals(Pleiades.getPleiadesContext().appName) | |
66 | + = "idea".equals(PleiadesContext.getInstance().appName) | |
67 | 67 | ? new TranslationIdeaCache() |
68 | 68 | : new TranslationCache(); |
69 | 69 |
@@ -16,7 +16,6 @@ | ||
16 | 16 | |
17 | 17 | import org.apache.commons.lang3.StringUtils; |
18 | 18 | |
19 | -import jp.sourceforge.mergedoc.pleiades.Pleiades; | |
20 | 19 | import jp.sourceforge.mergedoc.pleiades.PleiadesContext; |
21 | 20 | import jp.sourceforge.mergedoc.pleiades.log.Logger; |
22 | 21 | import jp.sourceforge.mergedoc.pleiades.resource.FileNamez; |
@@ -59,7 +58,7 @@ | ||
59 | 58 | private static final char[] GLOBAL_MULTIBYTES_CHARS = "‐‘’“”¤¶\u00A0…⇧⌘⌥⌃⏎→".toCharArray(); |
60 | 59 | |
61 | 60 | /** Pleiades コンテキスト */ |
62 | - private static PleiadesContext pleiadesContext = Pleiades.getPleiadesContext(); | |
61 | + private static PleiadesContext pleiadesContext = PleiadesContext.getInstance(); | |
63 | 62 | |
64 | 63 | /** このクラスのシングルトン・インスタンス */ |
65 | 64 | private static TranslationDictionary instance; |
@@ -139,7 +139,7 @@ | ||
139 | 139 | <!-- Eclipse 起動時のスプラッシュに表示する clean メッセージ 2021.07.09 --> |
140 | 140 | <pointCut editPoint="call" timing="around"> |
141 | 141 | <advice><![CDATA[ |
142 | - if (?{root}.pleiades.Pleiades.getPleiadesContext().isClean) | |
142 | + if (?{root}.pleiades.PleiadesContext.getInstance().isClean) | |
143 | 143 | $1 = "-clean " + $1; |
144 | 144 | $_ = $proceed($$); |
145 | 145 | ]]></advice> |