Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2A76FC958 for ; Tue, 4 Jun 2013 07:03:55 +0000 (UTC) Received: (qmail 48846 invoked by uid 500); 4 Jun 2013 07:03:54 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 48784 invoked by uid 500); 4 Jun 2013 07:03:52 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 48776 invoked by uid 99); 4 Jun 2013 07:03:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Jun 2013 07:03:50 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Jun 2013 07:03:49 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id DD4F723888E7; Tue, 4 Jun 2013 07:03:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1489301 - /sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java Date: Tue, 04 Jun 2013 07:03:29 -0000 To: commits@sling.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130604070329.DD4F723888E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cziegeler Date: Tue Jun 4 07:03:29 2013 New Revision: 1489301 URL: http://svn.apache.org/r1489301 Log: SLING-2899 : Directly register script engine as event handler Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java?rev=1489301&r1=1489300&r2=1489301&view=diff ============================================================================== --- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java (original) +++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java Tue Jun 4 07:03:29 2013 @@ -20,7 +20,6 @@ import static org.apache.sling.api.scrip import java.io.Reader; import java.util.Dictionary; -import java.util.Hashtable; import javax.script.Bindings; import javax.script.ScriptContext; @@ -57,9 +56,9 @@ import org.apache.sling.scripting.jsp.ja import org.apache.sling.scripting.jsp.jasper.runtime.JspApplicationContextImpl; import org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper; import org.apache.sling.scripting.jsp.util.TagUtil; -import org.osgi.framework.ServiceRegistration; import org.osgi.service.component.ComponentContext; import org.osgi.service.event.Event; +import org.osgi.service.event.EventConstants; import org.osgi.service.event.EventHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -71,7 +70,7 @@ import org.slf4j.LoggerFactory; @Component(label="%jsphandler.name", description="%jsphandler.description", metatype=true) -@Service(value=javax.script.ScriptEngineFactory.class) +@Service(value={javax.script.ScriptEngineFactory.class, EventHandler.class}) @Properties({ @Property(name="service.description",value="JSP Script Handler"), @Property(name="service.vendor",value="The Apache Software Foundation"), @@ -82,7 +81,8 @@ import org.slf4j.LoggerFactory; @Property(name="jasper.keepgenerated",boolValue=true), @Property(name="jasper.mappedfile",boolValue=true), @Property(name="jasper.trimSpaces",boolValue=false), - @Property(name="jasper.displaySourceFragments",boolValue=false) + @Property(name="jasper.displaySourceFragments",boolValue=false), + @Property(name=EventConstants.EVENT_TOPIC, value="org/apache/sling/api/resource/*") }) public class JspScriptEngineFactory extends AbstractScriptEngineFactory @@ -118,8 +118,6 @@ public class JspScriptEngineFactory private ServletConfig servletConfig; - private ServiceRegistration eventHandlerRegistration; - private boolean defaultIsSession; /** The handler for the jsp factories. */ @@ -335,15 +333,6 @@ public class JspScriptEngineFactory Thread.currentThread().setContextClassLoader(old); } - // register event handler - final Dictionary props = new Hashtable(); - props.put("event.topics","org/apache/sling/api/resource/*"); - props.put("service.description","JSP Script Modification Handler"); - props.put("service.vendor","The Apache Software Foundation"); - - this.eventHandlerRegistration = componentContext.getBundleContext() - .registerService(EventHandler.class.getName(), this, props); - logger.debug("IMPORTANT: Do not modify the generated servlets"); } @@ -357,10 +346,6 @@ public class JspScriptEngineFactory this.tldLocationsCache.deactivate(componentContext.getBundleContext()); this.tldLocationsCache = null; } - if ( this.eventHandlerRegistration != null ) { - this.eventHandlerRegistration.unregister(); - this.eventHandlerRegistration = null; - } if (jspRuntimeContext != null) { this.destroyJspRuntimeContext(this.jspRuntimeContext); jspRuntimeContext = null;