You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2018/04/05 11:33:11 UTC
[sling-ide-tooling] branch feature/intellij updated (88f99e0 ->
fa57700)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a change to branch feature/intellij
in repository https://gitbox.apache.org/repos/asf/sling-ide-tooling.git.
discard 88f99e0 SLING-5648 - Make Non-Eclipse Module regular Maven Packages
new fa57700 SLING-5648 - Make Non-Eclipse Module regular Maven Packages
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (88f99e0)
\
N -- N -- N refs/heads/feature/intellij (fa57700)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
eclipse/eclipse-core/META-INF/MANIFEST.MF | 1 +
.../eclipse/core/debug/PluginLoggerRegistrar.java | 82 +++++++++++++++-------
.../sling/ide/eclipse/core/internal/Activator.java | 21 +++---
eclipse/eclipse-m2e-ui/META-INF/MANIFEST.MF | 1 +
.../sling/ide/eclipse/m2e/internal/Activator.java | 2 +-
eclipse/eclipse-sightly-core/META-INF/MANIFEST.MF | 1 +
.../ide/eclipse/sightly/internal/Activator.java | 3 +-
eclipse/eclipse-ui/META-INF/MANIFEST.MF | 1 +
.../sling/ide/eclipse/ui/internal/Activator.java | 2 +-
9 files changed, 72 insertions(+), 42 deletions(-)
--
To stop receiving notification emails like this one, please contact
rombert@apache.org.
[sling-ide-tooling] 01/01: SLING-5648 - Make Non-Eclipse Module
regular Maven Packages
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch feature/intellij
in repository https://gitbox.apache.org/repos/asf/sling-ide-tooling.git
commit fa57700474bbe5bf7c0d3f19b7cd388a5ed82c51
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Tue Apr 3 17:23:23 2018 +0300
SLING-5648 - Make Non-Eclipse Module regular Maven Packages
Allow impl-vlt to contribute a PluginLogger without explicitly relying on eclipse-core.
---
eclipse/eclipse-core/META-INF/MANIFEST.MF | 1 +
.../eclipse/core/debug/PluginLoggerRegistrar.java | 92 ++++++++++++++++++++--
.../sling/ide/eclipse/core/debug/impl/Tracer.java | 15 ++--
.../sling/ide/eclipse/core/internal/Activator.java | 16 ++--
eclipse/eclipse-m2e-ui/META-INF/MANIFEST.MF | 1 +
.../sling/ide/eclipse/m2e/internal/Activator.java | 2 +-
eclipse/eclipse-sightly-core/META-INF/MANIFEST.MF | 1 +
.../ide/eclipse/sightly/internal/Activator.java | 3 +-
eclipse/eclipse-ui/META-INF/MANIFEST.MF | 1 +
.../sling/ide/eclipse/ui/internal/Activator.java | 2 +-
shared/modules/impl-vlt/bnd.bnd | 1 +
.../sling/ide/impl/vlt/VltRepositoryFactory.java | 4 +-
.../vlt/serialization/VltSerializationManager.java | 1 -
13 files changed, 113 insertions(+), 27 deletions(-)
diff --git a/eclipse/eclipse-core/META-INF/MANIFEST.MF b/eclipse/eclipse-core/META-INF/MANIFEST.MF
index d0c633c..8f1103a 100644
--- a/eclipse/eclipse-core/META-INF/MANIFEST.MF
+++ b/eclipse/eclipse-core/META-INF/MANIFEST.MF
@@ -57,3 +57,4 @@ Export-Package: org.apache.sling.ide.eclipse.core,
org.apache.sling.ide.eclipse.core.progress,
org.apache.sling.ide.eclipse.internal.validation;x-friends:="org.apache.sling.ide.eclipse-test"
Service-Component: OSGI-INF/TraceCommandExecutionEventsHandler.xml
+SlingIDE-PluginLoggerEnabled: true
diff --git a/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/debug/PluginLoggerRegistrar.java b/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/debug/PluginLoggerRegistrar.java
index 969a756..d76693a 100644
--- a/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/debug/PluginLoggerRegistrar.java
+++ b/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/debug/PluginLoggerRegistrar.java
@@ -18,38 +18,114 @@ package org.apache.sling.ide.eclipse.core.debug;
import java.util.Dictionary;
import java.util.Hashtable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
import org.apache.sling.ide.eclipse.core.debug.impl.Tracer;
import org.apache.sling.ide.log.Logger;
-import org.eclipse.core.runtime.Plugin;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.service.debug.DebugOptionsListener;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
import org.osgi.framework.ServiceRegistration;
/**
* The <tt>PluginLoggerRegistrar</tt> registers {@link Logger} implementations for use for specific plugins
+ *
+ * <p>This implementation acts as an extender, looking for the header {@value #HEADER_NAME_LOGGER_ENABLED} in
+ * the bundle's manifest. If presented and with a value of <tt>true</tt>, a <tt>Logger</tt> instance is registered
+ * for that bundle.</p>
+ *
+ * <p>In turn, <tt>ServiceRegistration</tt> objects can be accessed using the {@link #getServiceRegistration(Bundle)}.
+ * This method and the static {@link #getInstance()}} method are present to make it easier to consume in Eclipse
+ * plug-ins, where working with declarative services is more complicated.</p>
*
*/
-public class PluginLoggerRegistrar {
+public class PluginLoggerRegistrar implements BundleListener {
+
+ private static final String HEADER_NAME_LOGGER_ENABLED = "SlingIDE-PluginLoggerEnabled";
+
+ private static final PluginLoggerRegistrar INSTANCE = new PluginLoggerRegistrar();
+
+ public static PluginLoggerRegistrar getInstance() {
+ return INSTANCE;
+ }
+
+ private final ConcurrentMap<Long, ServiceRegistration<Logger>> registrations = new ConcurrentHashMap<>();
+
+ private PluginLoggerRegistrar() {
+
+ }
+
+ public void init(Bundle[] bundles) {
+ for ( Bundle bundle : bundles )
+ if ( bundle.getState() == Bundle.ACTIVE || bundle.getState() == Bundle.STARTING)
+ registerIfEnabled(bundle);
+ }
+
+ public void shutdown() {
+ for ( ServiceRegistration<Logger> reg : registrations.values() )
+ reg.unregister();
+ }
+
+ /**
+ * Gets the service registartion of a <tt>Logger</tt> for the specified bundle
+ *
+ * <p>The client must <b>not</b> call <tt>unregister</tt> on the returned instance, as
+ * it is owned by the <tt>PluginLoggerRegistrar</tt>.</p>
+ *
+ * @param bundle the bundle to get the service registartion for for
+ * @return the service registration, or <code>null</code> if none was found for this bundle
+ */
+ public ServiceRegistration<Logger> getServiceRegistration(Bundle bundle) {
+ return registrations.get(bundle.getBundleId());
+ }
+
+ @Override
+ public void bundleChanged(BundleEvent evt) {
+ switch ( evt.getType() ) {
+ case BundleEvent.STARTED:
+ registerIfEnabled(evt.getBundle());
+ break;
+
+ case BundleEvent.STOPPING:
+ unregister(evt.getBundle());
+ break;
+ }
+ }
+ private void unregister(Bundle bundle) {
+ ServiceRegistration<Logger> reg = registrations.remove(bundle.getBundleId());
+ if ( reg != null )
+ reg.unregister();
+
+ }
+
+ private void registerIfEnabled(final Bundle bundle) {
+ if ( Boolean.parseBoolean(bundle.getHeaders().get(HEADER_NAME_LOGGER_ENABLED)) )
+ registrations.put(bundle.getBundleId(), register(bundle));
+ }
+
/**
- * Registers a new tracer for the specified plugin
+ * Registers a new tracer for the specified bundle
*
- * @param plugin the plugin to register for
+ * @param bundle the bundle to register for
* @return the service registration
*/
- public static ServiceRegistration<Logger> register(Plugin plugin) {
+ private ServiceRegistration<Logger> register(Bundle bundle) {
Dictionary<String, Object> props = new Hashtable<>();
- props.put(DebugOptions.LISTENER_SYMBOLICNAME, plugin.getBundle().getSymbolicName());
- BundleContext ctx = plugin.getBundle().getBundleContext();
+ props.put(DebugOptions.LISTENER_SYMBOLICNAME, bundle.getSymbolicName());
+ BundleContext ctx = bundle.getBundleContext();
// safe to downcast since we are registering the Tracer which implements Logger
@SuppressWarnings("unchecked")
ServiceRegistration<Logger> serviceRegistration = (ServiceRegistration<Logger>) ctx.registerService(new String[] { DebugOptionsListener.class.getName(), Logger.class.getName() },
- new Tracer(plugin), props);
+ new Tracer(bundle), props);
return serviceRegistration;
}
+
}
diff --git a/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/debug/impl/Tracer.java b/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/debug/impl/Tracer.java
index d5abe22..cea6f88 100644
--- a/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/debug/impl/Tracer.java
+++ b/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/debug/impl/Tracer.java
@@ -20,12 +20,13 @@ import java.util.Date;
import org.apache.sling.ide.log.Logger;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.service.debug.DebugOptionsListener;
import org.eclipse.osgi.service.debug.DebugTrace;
import org.eclipse.osgi.util.NLS;
+import org.osgi.framework.Bundle;
/**
* The <tt>Tracer</tt> is the default implementation of the <tt>Logger</tt>
@@ -34,20 +35,20 @@ public class Tracer implements DebugOptionsListener, Logger {
private static final long PERF_IGNORE_THRESHOLD = 50;
- private final Plugin plugin;
+ private final Bundle bundle;
private boolean debugEnabled;
private boolean consoleEnabled;
private boolean performanceEnabled;
private DebugTrace trace;
- public Tracer(Plugin plugin) {
- this.plugin = plugin;
+ public Tracer(Bundle bundle) {
+ this.bundle = bundle;
}
@Override
public void optionsChanged(DebugOptions options) {
- String pluginId = plugin.getBundle().getSymbolicName();
+ String pluginId = bundle.getSymbolicName();
debugEnabled = options.getBooleanOption(pluginId + "/debug", false);
consoleEnabled = options.getBooleanOption(pluginId + "/debug/console", false) && debugEnabled;
@@ -73,7 +74,7 @@ public class Tracer implements DebugOptionsListener, Logger {
private void writeToConsole(String message, Throwable t) {
System.out.println("[" + Thread.currentThread().getName() + "] " + new Date() + " "
- + plugin.getBundle().getSymbolicName() + " : " + message);
+ + bundle.getSymbolicName() + " : " + message);
if (t != null)
t.printStackTrace(System.out);
}
@@ -130,6 +131,6 @@ public class Tracer implements DebugOptionsListener, Logger {
}
private void logInternal(int statusCode, String message, Throwable cause) {
- plugin.getLog().log(new Status(statusCode, plugin.getBundle().getSymbolicName(), message, cause));
+ Platform.getLog(bundle).log(new Status(statusCode, bundle.getSymbolicName(), message, cause));
}
}
diff --git a/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/Activator.java b/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/Activator.java
index f3671d5..c6d58c3 100644
--- a/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/Activator.java
+++ b/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/Activator.java
@@ -32,8 +32,6 @@ import org.apache.sling.ide.transport.BatcherFactory;
import org.apache.sling.ide.transport.CommandExecutionProperties;
import org.apache.sling.ide.transport.RepositoryFactory;
import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.event.Event;
@@ -73,8 +71,13 @@ public class Activator extends Plugin {
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
+
+ PluginLoggerRegistrar loggerRegistrar = PluginLoggerRegistrar.getInstance();
+
+ loggerRegistrar.init(context.getBundles());
+ context.addBundleListener(loggerRegistrar);
- tracerRegistration = PluginLoggerRegistrar.register(this);
+ tracerRegistration = loggerRegistrar.getServiceRegistration(context.getBundle());
eventAdmin = new ServiceTracker<>(context, EventAdmin.class, null);
eventAdmin.open();
@@ -111,8 +114,11 @@ public class Activator extends Plugin {
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
-
- tracerRegistration.unregister();
+
+ PluginLoggerRegistrar loggerRegistrar = PluginLoggerRegistrar.getInstance();
+
+ context.removeBundleListener(loggerRegistrar);
+ loggerRegistrar.shutdown();
repositoryFactory.close();
serializationManager.close();
diff --git a/eclipse/eclipse-m2e-ui/META-INF/MANIFEST.MF b/eclipse/eclipse-m2e-ui/META-INF/MANIFEST.MF
index d12fb8c..c06fad4 100644
--- a/eclipse/eclipse-m2e-ui/META-INF/MANIFEST.MF
+++ b/eclipse/eclipse-m2e-ui/META-INF/MANIFEST.MF
@@ -68,3 +68,4 @@ Import-Package: org.apache.commons.httpclient;version="3.1.0",
Bundle-ActivationPolicy: lazy
Export-Package: org.apache.sling.ide.eclipse.m2e,org.apache.sling.ide.
eclipse.ui.wizards.np
+SlingIDE-PluginLoggerEnabled: true
diff --git a/eclipse/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/Activator.java b/eclipse/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/Activator.java
index 10ef667..5720e10 100644
--- a/eclipse/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/Activator.java
+++ b/eclipse/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/Activator.java
@@ -62,7 +62,7 @@ public class Activator extends Plugin {
null);
osgiClientFactory.open();
- tracerRegistration = PluginLoggerRegistrar.register(this);
+ tracerRegistration = PluginLoggerRegistrar.getInstance().getServiceRegistration(context.getBundle());
tracer = new ServiceTracker<>(context, tracerRegistration.getReference(), null);
tracer.open();
diff --git a/eclipse/eclipse-sightly-core/META-INF/MANIFEST.MF b/eclipse/eclipse-sightly-core/META-INF/MANIFEST.MF
index 337588f..c556dfc 100644
--- a/eclipse/eclipse-sightly-core/META-INF/MANIFEST.MF
+++ b/eclipse/eclipse-sightly-core/META-INF/MANIFEST.MF
@@ -37,3 +37,4 @@ Export-Package: org.apache.sling.ide.eclipse.sightly,
org.apache.sling.ide.eclipse.sightly.model,
org.apache.sling.ide.eclipse.sightly.validation,
org.apache.sling.ide.eclipse.sightly.internal;x-friends:="org.apache.sling.ide.eclipse-test"
+SlingIDE-PluginLoggerEnabled: true
diff --git a/eclipse/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/internal/Activator.java b/eclipse/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/internal/Activator.java
index 554c372..31cadd0 100644
--- a/eclipse/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/internal/Activator.java
+++ b/eclipse/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/internal/Activator.java
@@ -39,7 +39,7 @@ public class Activator extends Plugin {
public void start(BundleContext context) throws Exception {
- loggerRegistration = PluginLoggerRegistrar.register(this);
+ loggerRegistration = PluginLoggerRegistrar.getInstance().getServiceRegistration(context.getBundle());
loggerTracker = new ServiceTracker<>(context, loggerRegistration.getReference(), null);
loggerTracker.open();
@@ -54,7 +54,6 @@ public class Activator extends Plugin {
public void stop(BundleContext context) throws Exception {
plugin = null;
- loggerRegistration.unregister();
super.stop(context);
}
diff --git a/eclipse/eclipse-ui/META-INF/MANIFEST.MF b/eclipse/eclipse-ui/META-INF/MANIFEST.MF
index 019e27e..fb4de9b 100644
--- a/eclipse/eclipse-ui/META-INF/MANIFEST.MF
+++ b/eclipse/eclipse-ui/META-INF/MANIFEST.MF
@@ -101,3 +101,4 @@ Export-Package: org.apache.sling.ide.eclipse.ui,
org.apache.sling.ide.eclipse.ui.propertyPages,
org.apache.sling.ide.eclipse.ui.views,
org.apache.sling.ide.eclipse.ui.wizards
+SlingIDE-PluginLoggerEnabled: true
diff --git a/eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/Activator.java b/eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/Activator.java
index 27141be..28a3810 100644
--- a/eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/Activator.java
+++ b/eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/Activator.java
@@ -59,7 +59,7 @@ public class Activator extends AbstractUIPlugin {
public void start(BundleContext context) throws Exception {
super.start(context);
- tracerRegistration = PluginLoggerRegistrar.register(this);
+ tracerRegistration = PluginLoggerRegistrar.getInstance().getServiceRegistration(context.getBundle());
serializationManager = new ServiceTracker<>(context, SerializationManager.class, null);
serializationManager.open();
diff --git a/shared/modules/impl-vlt/bnd.bnd b/shared/modules/impl-vlt/bnd.bnd
index 9906412..398eae2 100644
--- a/shared/modules/impl-vlt/bnd.bnd
+++ b/shared/modules/impl-vlt/bnd.bnd
@@ -2,3 +2,4 @@ Bundle-ActivationPolicy: lazy
-exportcontents: ${packages;VERSIONED}
-includeresource: plugin.xml, .options
Bundle-SymbolicName: org.apache.sling.ide.impl-vlt;singleton:=true
+SlingIDE-PluginLoggerEnabled: true
\ No newline at end of file
diff --git a/shared/modules/impl-vlt/src/main/java/org/apache/sling/ide/impl/vlt/VltRepositoryFactory.java b/shared/modules/impl-vlt/src/main/java/org/apache/sling/ide/impl/vlt/VltRepositoryFactory.java
index fab8329..5b3dc00 100644
--- a/shared/modules/impl-vlt/src/main/java/org/apache/sling/ide/impl/vlt/VltRepositoryFactory.java
+++ b/shared/modules/impl-vlt/src/main/java/org/apache/sling/ide/impl/vlt/VltRepositoryFactory.java
@@ -38,9 +38,9 @@ public class VltRepositoryFactory implements RepositoryFactory {
@Reference
private EventAdmin eventAdmin;
- @Reference
+ @Reference(target = "(listener.symbolic.name=org.apache.sling.ide.impl-vlt)")
private Logger logger;
-
+
private Map<String,VltRepository> repositoryMap = new HashMap<>();
@Override
diff --git a/shared/modules/impl-vlt/src/main/java/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java b/shared/modules/impl-vlt/src/main/java/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java
index 42909a6..a68475f 100644
--- a/shared/modules/impl-vlt/src/main/java/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java
+++ b/shared/modules/impl-vlt/src/main/java/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java
@@ -58,7 +58,6 @@ public class VltSerializationManager implements SerializationManager {
static final String EXTENSION_XML = ".xml";
- @Reference
private VltSerializationDataBuilder builder;
@Reference
--
To stop receiving notification emails like this one, please contact
rombert@apache.org.