Author: cziegeler Date: Fri Jul 17 08:34:52 2009 New Revision: 795009 URL: http://svn.apache.org/viewvc?rev=795009&view=rev Log: Move scripting constants into own constants class.
Added: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/scripting/SlingScriptConstants.java (with props) Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/SlingConstants.java sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/SlingScriptAdapterFactory.java Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/SlingConstants.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/SlingConstants.java?rev=795009&r1=795008&r2=795009&view=diff ============================================================================== --- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/SlingConstants.java (original) +++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/SlingConstants.java Fri Jul 17 08:34:52 2009 @@ -238,68 +238,4 @@ * @since 2.0.6 */ public static final String PROPERTY_ADAPTER_CLASSES = "adapters"; - - /** - * The topic for the OSGi event which is sent when a script engine factory has been added. - * The event contains at least the {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_NAME}, - * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_VERSION}, - * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_EXTENSIONS}, - * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_NAME}, - * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_VERSION}, - * and {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_MIME_TYPES} poperties. - * @since 2.0.6 - */ - public static final String TOPIC_SCRIPT_ENGINE_FACTORY_ADDED = "javax/script/ScriptEngineFactory/ADDED"; - - /** - * The topic for the OSGi event which is sent when a script engine factory has been removed. - * The event contains at least the {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_NAME}, - * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_VERSION}, - * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_EXTENSIONS}, - * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_NAME}, - * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_VERSION}, - * and {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_MIME_TYPES} poperties. - * @since 2.0.6 - */ - public static final String TOPIC_SCRIPT_ENGINE_FACTORY_REMOVED = "javax/script/ScriptEngineFactory/REMOVED"; - - /** - * The event property listing the script engine factory name. The value is a string. - * @since 2.0.6 - */ - public static final String PROPERTY_SCRIPT_ENGINE_FACTORY_NAME = "engineName"; - - /** - * The event property listing the script engine factory name. The value is a string. - * @since 2.0.6 - */ - public static final String PROPERTY_SCRIPT_ENGINE_FACTORY_VERSION = "engineVersion"; - - /** - * The event property listing the script engine factory extensions. The value is - * a string array. - * @since 2.0.6 - */ - public static final String PROPERTY_SCRIPT_ENGINE_FACTORY_EXTENSIONS = "extensions"; - - /** - * The event property listing the script engine factory language. The value is - * a string. - * @since 2.0.6 - */ - public static final String PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_NAME = "languageName"; - - /** - * The event property listing the script engine factory language version. The value is - * a string. - * @since 2.0.6 - */ - public static final String PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_VERSION = "languageVersion"; - - /** - * The event property listing the script engine factory mime types. The value is - * a string array. - * @since 2.0.6 - */ - public static final String PROPERTY_SCRIPT_ENGINE_FACTORY_MIME_TYPES = "mimeTypes"; } Added: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/scripting/SlingScriptConstants.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/scripting/SlingScriptConstants.java?rev=795009&view=auto ============================================================================== --- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/scripting/SlingScriptConstants.java (added) +++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/scripting/SlingScriptConstants.java Fri Jul 17 08:34:52 2009 @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.api.scripting; + +/** + * Some constants for the scripting. + * @since 2.0.6 + */ +public abstract class SlingScriptConstants { + + /** + * The name of the script context attribute holding the {...@link org.apache.sling.api.resource.ResourceResolver} which + * has been used to resolve the script. This resource resolver can be used by the + * script engines to further locate scripts (for includes etc.). + * @since 2.0.6 + */ + public static final String ATTR_SCRIPT_RESOURCE_RESOLVER = "org.apache.sling.api.scripting.ScriptResourceResolver"; + + /** + * The topic for the OSGi event which is sent when a script engine factory has been added. + * The event contains at least the {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_NAME}, + * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_VERSION}, + * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_EXTENSIONS}, + * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_NAME}, + * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_VERSION}, + * and {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_MIME_TYPES} poperties. + * @since 2.0.6 + */ + public static final String TOPIC_SCRIPT_ENGINE_FACTORY_ADDED = "javax/script/ScriptEngineFactory/ADDED"; + + /** + * The topic for the OSGi event which is sent when a script engine factory has been removed. + * The event contains at least the {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_NAME}, + * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_VERSION}, + * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_EXTENSIONS}, + * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_NAME}, + * {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_VERSION}, + * and {...@link #PROPERTY_SCRIPT_ENGINE_FACTORY_MIME_TYPES} poperties. + * @since 2.0.6 + */ + public static final String TOPIC_SCRIPT_ENGINE_FACTORY_REMOVED = "javax/script/ScriptEngineFactory/REMOVED"; + + /** + * The event property listing the script engine factory name. The value is a string. + * @since 2.0.6 + */ + public static final String PROPERTY_SCRIPT_ENGINE_FACTORY_NAME = "engineName"; + + /** + * The event property listing the script engine factory name. The value is a string. + * @since 2.0.6 + */ + public static final String PROPERTY_SCRIPT_ENGINE_FACTORY_VERSION = "engineVersion"; + + /** + * The event property listing the script engine factory extensions. The value is + * a string array. + * @since 2.0.6 + */ + public static final String PROPERTY_SCRIPT_ENGINE_FACTORY_EXTENSIONS = "extensions"; + + /** + * The event property listing the script engine factory language. The value is + * a string. + * @since 2.0.6 + */ + public static final String PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_NAME = "languageName"; + + /** + * The event property listing the script engine factory language version. The value is + * a string. + * @since 2.0.6 + */ + public static final String PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_VERSION = "languageVersion"; + + /** + * The event property listing the script engine factory mime types. The value is + * a string array. + * @since 2.0.6 + */ + public static final String PROPERTY_SCRIPT_ENGINE_FACTORY_MIME_TYPES = "mimeTypes"; +} Propchange: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/scripting/SlingScriptConstants.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/scripting/SlingScriptConstants.java ------------------------------------------------------------------------------ svn:keywords = author date id revision rev url Propchange: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/scripting/SlingScriptConstants.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/SlingScriptAdapterFactory.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/SlingScriptAdapterFactory.java?rev=795009&r1=795008&r2=795009&view=diff ============================================================================== --- sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/SlingScriptAdapterFactory.java (original) +++ sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/SlingScriptAdapterFactory.java Fri Jul 17 08:34:52 2009 @@ -33,9 +33,9 @@ import javax.script.ScriptEngineFactory; import javax.script.ScriptEngineManager; -import org.apache.sling.api.SlingConstants; import org.apache.sling.api.adapter.AdapterFactory; import org.apache.sling.api.resource.Resource; +import org.apache.sling.api.scripting.SlingScriptConstants; import org.apache.sling.commons.mime.MimeTypeProvider; import org.apache.sling.scripting.core.impl.helper.SlingScriptEngineManager; import org.osgi.framework.Bundle; @@ -70,12 +70,7 @@ public class SlingScriptAdapterFactory implements AdapterFactory, MimeTypeProvider, BundleListener { - private static final Logger log = LoggerFactory.getLogger(SlingScriptAdapterFactory.class); - - /** - * jcr:encoding - */ - public static final String JCR_ENCODING = "jcr:encoding"; + private final Logger log = LoggerFactory.getLogger(SlingScriptAdapterFactory.class); private static final String ENGINE_FACTORY_SERVICE = "META-INF/services/" + ScriptEngineFactory.class.getName(); @@ -155,6 +150,7 @@ return scriptEngineManager; } + @SuppressWarnings("unchecked") private Collection<?> registerFactories(SlingScriptEngineManager mgr, Bundle bundle) { URL url = bundle.getEntry(ENGINE_FACTORY_SERVICE); @@ -167,7 +163,6 @@ String line; while ((line = reader.readLine()) != null) { try { - @SuppressWarnings("unchecked") Class<ScriptEngineFactory> clazz = bundle.loadClass(line); ScriptEngineFactory spi = clazz.newInstance(); registerFactory(mgr, spi); @@ -329,12 +324,12 @@ final EventAdmin localEA = this.getEventAdmin(); if ( localEA != null ) { final Dictionary<String, Object> props = new Hashtable<String, Object>(); - props.put(SlingConstants.PROPERTY_SCRIPT_ENGINE_FACTORY_NAME, scriptEngineFactory.getEngineName()); - props.put(SlingConstants.PROPERTY_SCRIPT_ENGINE_FACTORY_VERSION, scriptEngineFactory.getEngineVersion()); - props.put(SlingConstants.PROPERTY_SCRIPT_ENGINE_FACTORY_EXTENSIONS, toArray(scriptEngineFactory.getExtensions())); - props.put(SlingConstants.PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_NAME, scriptEngineFactory.getLanguageName()); - props.put(SlingConstants.PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_VERSION, scriptEngineFactory.getLanguageVersion()); - props.put(SlingConstants.PROPERTY_SCRIPT_ENGINE_FACTORY_MIME_TYPES, toArray(scriptEngineFactory.getMimeTypes())); + props.put(SlingScriptConstants.PROPERTY_SCRIPT_ENGINE_FACTORY_NAME, scriptEngineFactory.getEngineName()); + props.put(SlingScriptConstants.PROPERTY_SCRIPT_ENGINE_FACTORY_VERSION, scriptEngineFactory.getEngineVersion()); + props.put(SlingScriptConstants.PROPERTY_SCRIPT_ENGINE_FACTORY_EXTENSIONS, toArray(scriptEngineFactory.getExtensions())); + props.put(SlingScriptConstants.PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_NAME, scriptEngineFactory.getLanguageName()); + props.put(SlingScriptConstants.PROPERTY_SCRIPT_ENGINE_FACTORY_LANGUAGE_VERSION, scriptEngineFactory.getLanguageVersion()); + props.put(SlingScriptConstants.PROPERTY_SCRIPT_ENGINE_FACTORY_MIME_TYPES, toArray(scriptEngineFactory.getMimeTypes())); localEA.postEvent(new Event(topic, props)); } } @@ -344,7 +339,7 @@ engineSpiServices.add(scriptEngineFactory); scriptEngineManager = null; // send event - postEvent(SlingConstants.TOPIC_SCRIPT_ENGINE_FACTORY_ADDED, scriptEngineFactory); + postEvent(SlingScriptConstants.TOPIC_SCRIPT_ENGINE_FACTORY_ADDED, scriptEngineFactory); } protected void unbindScriptEngineFactory( @@ -352,7 +347,7 @@ engineSpiServices.remove(scriptEngineFactory); scriptEngineManager = null; // send event - postEvent(SlingConstants.TOPIC_SCRIPT_ENGINE_FACTORY_REMOVED, scriptEngineFactory); + postEvent(SlingScriptConstants.TOPIC_SCRIPT_ENGINE_FACTORY_REMOVED, scriptEngineFactory); } }