incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
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 GMT
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<String, String> props = new Hashtable<String, String>();
-        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;



Mime
View raw message