Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-04-12 11:43:08 -0400
committerIgor Fedorenko2011-04-12 11:43:08 -0400
commit182090e8d032e1b42195c06d291142eb1e41ff0a (patch)
tree406dcee79015947346bcd62f906f4a0d1650f712 /org.eclipse.m2e.logback.appender
parent49878718b849feda1697ffa506dc66208a1a28fa (diff)
downloadm2e-core-182090e8d032e1b42195c06d291142eb1e41ff0a.tar.gz
m2e-core-182090e8d032e1b42195c06d291142eb1e41ff0a.tar.xz
m2e-core-182090e8d032e1b42195c06d291142eb1e41ff0a.zip
342232 prevent eager activation of m2e.core.ui bundle
This goes way beyond my level of understand of java classloading, but apparent Class.newInstance reaches indirecly referenced classes more eagerly compared to straight new invocation. Moved all code that touches any of m2e.core.ui classes to separate MavenConsoleAppenderImpl and eager m2e.core.ui bundle does not happen any more. Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
Diffstat (limited to 'org.eclipse.m2e.logback.appender')
-rw-r--r--org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/MavenConsoleAppender.java24
-rw-r--r--org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/MavenConsoleAppenderImpl.java41
2 files changed, 42 insertions, 23 deletions
diff --git a/org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/MavenConsoleAppender.java b/org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/MavenConsoleAppender.java
index d648f5e5..a00780ac 100644
--- a/org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/MavenConsoleAppender.java
+++ b/org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/MavenConsoleAppender.java
@@ -13,17 +13,12 @@ package org.eclipse.m2e.logback.appender;
import org.osgi.framework.Bundle;
-import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.UnsynchronizedAppenderBase;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.m2e.core.ui.internal.M2EUIPluginActivator;
-import org.eclipse.m2e.core.ui.internal.console.MavenConsole;
-
-@SuppressWarnings("restriction")
public class MavenConsoleAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
private static final String M2E_CORE_UI_BUNDLE_ID = "org.eclipse.m2e.core.ui"; //$NON-NLS-1$
@@ -35,24 +30,7 @@ public class MavenConsoleAppender extends UnsynchronizedAppenderBase<ILoggingEve
return;
}
- if(!M2EUIPluginActivator.getDefault().hasMavenConsoleImpl()) {
- return;
- }
-
- MavenConsole mavenConsole = M2EUIPluginActivator.getDefault().getMavenConsole();
- switch(logEvent.getLevel().levelInt) {
- case Level.DEBUG_INT:
- mavenConsole.debug(logEvent.toString());
- return;
- case Level.ERROR_INT:
- mavenConsole.error(logEvent.toString());
- return;
- case Level.WARN_INT:
- case Level.INFO_INT:
- default:
- mavenConsole.info(logEvent.toString());
- return;
- }
+ new MavenConsoleAppenderImpl().append(logEvent);
}
private boolean isActive() {
diff --git a/org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/MavenConsoleAppenderImpl.java b/org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/MavenConsoleAppenderImpl.java
new file mode 100644
index 00000000..6c698507
--- /dev/null
+++ b/org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/MavenConsoleAppenderImpl.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Sonatype, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.m2e.logback.appender;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+
+import org.eclipse.m2e.core.ui.internal.M2EUIPluginActivator;
+import org.eclipse.m2e.core.ui.internal.console.MavenConsole;
+
+@SuppressWarnings("restriction")
+public class MavenConsoleAppenderImpl {
+ protected void append(ILoggingEvent logEvent) {
+ if(!M2EUIPluginActivator.getDefault().hasMavenConsoleImpl()) {
+ return;
+ }
+
+ MavenConsole mavenConsole = M2EUIPluginActivator.getDefault().getMavenConsole();
+ switch(logEvent.getLevel().levelInt) {
+ case Level.DEBUG_INT:
+ mavenConsole.debug(logEvent.toString());
+ return;
+ case Level.ERROR_INT:
+ mavenConsole.error(logEvent.toString());
+ return;
+ case Level.WARN_INT:
+ case Level.INFO_INT:
+ default:
+ mavenConsole.info(logEvent.toString());
+ return;
+ }
+ }
+}

Back to the top