You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ch...@apache.org on 2016/10/03 10:59:38 UTC

svn commit: r1763153 - /sling/trunk/contrib/extensions/tracer/src/main/java/org/apache/sling/tracer/internal/LogTracer.java

Author: chetanm
Date: Mon Oct  3 10:59:38 2016
New Revision: 1763153

URL: http://svn.apache.org/viewvc?rev=1763153&view=rev
Log:
SLING-6089 - Log Tracer does not work with system having new HTTP whiteboard implementation

Register the filter with both old and new properties

Modified:
    sling/trunk/contrib/extensions/tracer/src/main/java/org/apache/sling/tracer/internal/LogTracer.java

Modified: sling/trunk/contrib/extensions/tracer/src/main/java/org/apache/sling/tracer/internal/LogTracer.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/tracer/src/main/java/org/apache/sling/tracer/internal/LogTracer.java?rev=1763153&r1=1763152&r2=1763153&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/tracer/src/main/java/org/apache/sling/tracer/internal/LogTracer.java (original)
+++ sling/trunk/contrib/extensions/tracer/src/main/java/org/apache/sling/tracer/internal/LogTracer.java Mon Oct  3 10:59:38 2016
@@ -111,8 +111,9 @@ public class LogTracer {
     private static final String PROP_TRACER_ENABLED = "enabled";
 
     private static final boolean PROP_TRACER_SERVLET_ENABLED_DEFAULT = false;
-    @Property(label = "Servlet Enabled",
-            description = "Enable the Tracer Servlet",
+    @Property(label = "Recording Servlet Enabled",
+            description = "Enable the Tracer Servlet. This servlet is required for the tracer recording feature " +
+                    "to work and provides access to the json dump of the recording performed",
             boolValue = PROP_TRACER_SERVLET_ENABLED_DEFAULT
     )
     private static final String PROP_TRACER_SERVLET_ENABLED = "servletEnabled";
@@ -270,6 +271,15 @@ public class LogTracer {
 
         Dictionary<String, Object> filterProps = new Hashtable<String, Object>();
         filterProps.put("pattern", "/.*");
+
+        //Do not use constant name to keep dependency as optional
+        //filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/");
+        //filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT,
+        //        "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=*)");
+
+        filterProps.put("osgi.http.whiteboard.filter.pattern", "/");
+        filterProps.put("osgi.http.whiteboard.context.select",
+                "(osgi.http.whiteboard.context.name=*)");
         filterProps.put(Constants.SERVICE_DESCRIPTION, "Servlet Filter required for Log Tracer");
         filterRegistration = context.registerService(Filter.class.getName(),
                 new TracerFilter(), filterProps);



Re: svn commit: r1763153 - /sling/trunk/contrib/extensions/tracer/src/main/java/org/apache/sling/tracer/internal/LogTracer.java

Posted by Chetan Mehrotra <ch...@gmail.com>.
On Mon, Oct 3, 2016 at 5:13 PM, Robert Munteanu <ro...@apache.org> wrote:
> AFAIR it analyses the bytecode
> and the imports are simply not there.

Okie. I thought that inlining of constant is implementation detail of
javac and may or may not work in all cases. However reading [1]
confirms that its guaranteed so can be relied upon!

Chetan Mehrotra
[1] http://stackoverflow.com/questions/1406616/is-java-guaranteed-to-inline-string-constants-if-they-can-be-determined-at-compi

Re: svn commit: r1763153 - /sling/trunk/contrib/extensions/tracer/src/main/java/org/apache/sling/tracer/internal/LogTracer.java

Posted by Robert Munteanu <ro...@apache.org>.
On Mon, 2016-10-03 at 17:12 +0530, Chetan Mehrotra wrote:
> On Mon, Oct 3, 2016 at 4:57 PM, Robert Munteanu <ro...@apache.org>
> wrote:
> > AFAIK constants will be inlined by javac, so by referencing them
> > bnd
> > will not add imports to the packages.
> 
> 
> Did not knew that bnd avoids adding import in such cases. Changed the
> code to use the constants then. Thanks for the review feedback!

I don't think bnd does anything special, AFAIR it analyses the bytecode
and the imports are simply not there.

Robert

Re: svn commit: r1763153 - /sling/trunk/contrib/extensions/tracer/src/main/java/org/apache/sling/tracer/internal/LogTracer.java

Posted by Chetan Mehrotra <ch...@gmail.com>.
On Mon, Oct 3, 2016 at 4:57 PM, Robert Munteanu <ro...@apache.org> wrote:
> AFAIK constants will be inlined by javac, so by referencing them bnd
> will not add imports to the packages.

Did not knew that bnd avoids adding import in such cases. Changed the
code to use the constants then. Thanks for the review feedback!

Chetan Mehrotra

Re: svn commit: r1763153 - /sling/trunk/contrib/extensions/tracer/src/main/java/org/apache/sling/tracer/internal/LogTracer.java

Posted by Robert Munteanu <ro...@apache.org>.
Hi Chetan,

On Mon, 2016-10-03 at 10:59 +0000, chetanm@apache.org wrote:
> +������� //Do not use constant name to keep dependency as optional
> +�������
> //filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATT
> ERN, "/");
> +�������
> //filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SEL
> ECT,
> +������� //������� "(" +
> HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=*)");

AFAIK constants will be inlined by javac, so by referencing them bnd
will not add imports to the packages.

Robert