sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject svn commit: r1512503 - in /sling/trunk/tooling/ide: api/src/org/apache/sling/ide/transport/ impl-resource/OSGI-INF/ impl-resource/src/org/apache/sling/ide/impl/resource/transport/ impl-resource/src/org/apache/sling/ide/impl/resource/util/
Date Fri, 09 Aug 2013 21:31:02 GMT
Author: rombert
Date: Fri Aug  9 21:31:02 2013
New Revision: 1512503

URL: http://svn.apache.org/r1512503
Log:
SLING-2667 - [Tooling] create text-only console that exposes the
operations performed and their results

Modify the Tracer to be bound to the EventAdmin as well.

Modified:
    sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/CommandExecutionProperties.java
    sling/trunk/tooling/ide/impl-resource/OSGI-INF/RepositoryImpl.xml
    sling/trunk/tooling/ide/impl-resource/OSGI-INF/Tracer.xml
    sling/trunk/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/transport/RepositoryImpl.java
    sling/trunk/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/transport/TracingCommand.java
    sling/trunk/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/util/Tracer.java

Modified: sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/CommandExecutionProperties.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/CommandExecutionProperties.java?rev=1512503&r1=1512502&r2=1512503&view=diff
==============================================================================
--- sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/CommandExecutionProperties.java
(original)
+++ sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/CommandExecutionProperties.java
Fri Aug  9 21:31:02 2013
@@ -17,6 +17,8 @@
 
 public final class CommandExecutionProperties {
 
+    public static final String TOPIC = Repository.class.getPackage().getName().replace('.',
'/');
+
     public static final String TIMESTAMP_START = "timestamp.start";
     public static final String TIMESTAMP_END = "timestamp.end";
     public static final String ACTION_TYPE = "action.type";

Modified: sling/trunk/tooling/ide/impl-resource/OSGI-INF/RepositoryImpl.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/impl-resource/OSGI-INF/RepositoryImpl.xml?rev=1512503&r1=1512502&r2=1512503&view=diff
==============================================================================
--- sling/trunk/tooling/ide/impl-resource/OSGI-INF/RepositoryImpl.xml (original)
+++ sling/trunk/tooling/ide/impl-resource/OSGI-INF/RepositoryImpl.xml Fri Aug  9 21:31:02
2013
@@ -4,6 +4,5 @@
    <service>
       <provide interface="org.apache.sling.ide.transport.Repository"/>
    </service>
-   <reference bind="bindTracer" cardinality="1..1" interface="org.apache.sling.ide.impl.resource.util.Tracer"
name="Tracer" policy="static" unbind="unbindTracer"/>
    <reference bind="bindEventAdmin" cardinality="1..1" interface="org.osgi.service.event.EventAdmin"
name="EventAdmin" policy="static" unbind="unbindEventAdmin"/>
 </scr:component>

Modified: sling/trunk/tooling/ide/impl-resource/OSGI-INF/Tracer.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/impl-resource/OSGI-INF/Tracer.xml?rev=1512503&r1=1512502&r2=1512503&view=diff
==============================================================================
--- sling/trunk/tooling/ide/impl-resource/OSGI-INF/Tracer.xml (original)
+++ sling/trunk/tooling/ide/impl-resource/OSGI-INF/Tracer.xml Fri Aug  9 21:31:02 2013
@@ -2,8 +2,10 @@
 <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="false">
    <implementation class="org.apache.sling.ide.impl.resource.util.Tracer"/>
    <property name="listener.symbolic.name" type="String" value="org.apache.sling.ide.impl-resource"/>
+   <property name="event.topics" value="org/apache/sling/ide/transport"/>
    <service>
       <provide interface="org.apache.sling.ide.impl.resource.util.Tracer"/>
       <provide interface="org.eclipse.osgi.service.debug.DebugOptionsListener"/>
+      <provide interface="org.osgi.service.event.EventHandler"/>
    </service>
 </scr:component>

Modified: sling/trunk/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/transport/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/transport/RepositoryImpl.java?rev=1512503&r1=1512502&r2=1512503&view=diff
==============================================================================
--- sling/trunk/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/transport/RepositoryImpl.java
(original)
+++ sling/trunk/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/transport/RepositoryImpl.java
Fri Aug  9 21:31:02 2013
@@ -19,7 +19,6 @@ package org.apache.sling.ide.impl.resour
 import java.util.Map;
 
 import org.apache.commons.httpclient.HttpClient;
-import org.apache.sling.ide.impl.resource.util.Tracer;
 import org.apache.sling.ide.transport.Command;
 import org.apache.sling.ide.transport.FileInfo;
 import org.apache.sling.ide.transport.ResourceProxy;
@@ -28,7 +27,6 @@ import org.osgi.service.event.EventAdmin
 public class RepositoryImpl extends AbstractRepository{
 	
     private final HttpClient httpClient = new HttpClient();
-    private Tracer tracer;
     private EventAdmin eventAdmin;
 
 	@Override
@@ -36,9 +34,9 @@ public class RepositoryImpl extends Abst
         return wrap(new AddNodeCommand(fileInfo, repositoryInfo, httpClient));
 	}
 
-    private <T> Command<T> wrap(AbstractCommand<T> command) {
 
-        return new TracingCommand<T>(command, tracer, eventAdmin);
+    private <T> Command<T> wrap(AbstractCommand<T> command) {
+        return new TracingCommand<T>(command, eventAdmin);
     }
 
 	@Override
@@ -68,16 +66,6 @@ public class RepositoryImpl extends Abst
         return wrap(new UpdateContentCommand(repositoryInfo, httpClient, fileInfo.getRelativeLocation(),
properties, fileInfo));
 	}
 
-    public void bindTracer(Tracer tracer) {
-
-        this.tracer = tracer;
-    }
-
-    public void unbindTracer(Tracer tracer) {
-
-        this.tracer = null;
-    }
-
     public void bindEventAdmin(EventAdmin eventAdmin) {
 
         this.eventAdmin = eventAdmin;

Modified: sling/trunk/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/transport/TracingCommand.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/transport/TracingCommand.java?rev=1512503&r1=1512502&r2=1512503&view=diff
==============================================================================
--- sling/trunk/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/transport/TracingCommand.java
(original)
+++ sling/trunk/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/transport/TracingCommand.java
Fri Aug  9 21:31:02 2013
@@ -19,7 +19,6 @@ package org.apache.sling.ide.impl.resour
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.sling.ide.impl.resource.util.Tracer;
 import org.apache.sling.ide.transport.Command;
 import org.apache.sling.ide.transport.CommandExecutionProperties;
 import org.apache.sling.ide.transport.RepositoryException;
@@ -30,12 +29,10 @@ import org.osgi.service.event.EventAdmin
 class TracingCommand<T> implements Command<T> {
 
     private final AbstractCommand<T> command;
-    private final Tracer tracer;
     private final EventAdmin eventAdmin;
 
-    public TracingCommand(AbstractCommand<T> command, Tracer tracer, EventAdmin eventAdmin)
{
+    public TracingCommand(AbstractCommand<T> command, EventAdmin eventAdmin) {
         this.command = command;
-        this.tracer = tracer;
         this.eventAdmin = eventAdmin;
     }
 
@@ -46,9 +43,6 @@ class TracingCommand<T> implements Comma
         Result<T> result = command.execute();
         long end = System.currentTimeMillis();
 
-        if (tracer != null)
-            tracer.trace("{0} -> {1}", command, result.toString());
-
         if (eventAdmin != null) {
             Map<String, Object> props = new HashMap<String, Object>();
             props.put(CommandExecutionProperties.RESULT_TEXT, result.toString());
@@ -61,7 +55,7 @@ class TracingCommand<T> implements Comma
             props.put(CommandExecutionProperties.ACTION_TARGET, command.getPath());
             props.put(CommandExecutionProperties.TIMESTAMP_START, start);
             props.put(CommandExecutionProperties.TIMESTAMP_END, end);
-            Event event = new Event("org/apache/sling/ide/transport", props);
+            Event event = new Event(CommandExecutionProperties.TOPIC, props);
             eventAdmin.postEvent(event);
         }
 

Modified: sling/trunk/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/util/Tracer.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/util/Tracer.java?rev=1512503&r1=1512502&r2=1512503&view=diff
==============================================================================
--- sling/trunk/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/util/Tracer.java
(original)
+++ sling/trunk/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/util/Tracer.java
Fri Aug  9 21:31:02 2013
@@ -16,12 +16,15 @@
  */
 package org.apache.sling.ide.impl.resource.util;
 
+import org.apache.sling.ide.transport.CommandExecutionProperties;
 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.service.event.Event;
+import org.osgi.service.event.EventHandler;
 
-public class Tracer implements DebugOptionsListener {
+public class Tracer implements DebugOptionsListener, EventHandler {
 
     private boolean debugEnabled;
     private DebugTrace trace;
@@ -43,4 +46,17 @@ public class Tracer implements DebugOpti
         trace.trace("/debug", message);
     }
 
+    @Override
+    public void handleEvent(Event event) {
+        if ( !debugEnabled ) 
+            return;
+        
+        String type = (String) event.getProperty(CommandExecutionProperties.ACTION_TYPE);
+        String target = (String) event.getProperty(CommandExecutionProperties.ACTION_TARGET);
+        String result = (String) event.getProperty(CommandExecutionProperties.RESULT_TEXT);
+
+
+        trace.trace("/debug", NLS.bind("{0} -> {1} : {2}", new Object[] { type, target,
result }));
+    }
+
 }



Mime
View raw message