pax_global_header 0000666 0000000 0000000 00000000064 12006244625 0014513 g ustar 00root root 0000000 0000000 52 comment=a9f22d15d5a56f001369be8bbaf454588e83f8c0
livetribe-jsr223-2.0.7/ 0000775 0000000 0000000 00000000000 12006244625 0014531 5 ustar 00root root 0000000 0000000 livetribe-jsr223-2.0.7/.gitignore 0000664 0000000 0000000 00000000123 12006244625 0016515 0 ustar 00root root 0000000 0000000 # intellij project files
*.ipr
*.iml
*.iws
.idea
# all target dirs
target/
output/
livetribe-jsr223-2.0.7/LICENSE.txt 0000664 0000000 0000000 00000026137 12006244625 0016365 0 ustar 00root root 0000000 0000000
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed 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.
livetribe-jsr223-2.0.7/pom.xml 0000664 0000000 0000000 00000006015 12006244625 0016050 0 ustar 00root root 0000000 0000000 org.livetribelivetribe74.0.0org.livetribelivetribe-jsr2232.0.7LiveTribe :: JSR 223bundleinstallorg.apache.maven.pluginsmaven-compiler-plugin2.5.11.51.5org.apache.felixmaven-bundle-plugin1.4.3true${project.artifactId}${project.groupId}.${project.artifactId}_1.0_specLiveTribe :: JSR 223!META-INF*,javax.script.*;version=1.0LiveTribe :: JSR 223${project.version}bundle-manifestprocess-classesmanifestjunitjunit4.5testcodehausCodeHaus Repositoryhttp://repository.codehaus.orgcodehaus.snapshotsCodeHaus Snapshots Repositoryhttp://snapshots.repository.codehaus.org
livetribe-jsr223-2.0.7/src/ 0000775 0000000 0000000 00000000000 12006244625 0015320 5 ustar 00root root 0000000 0000000 livetribe-jsr223-2.0.7/src/main/ 0000775 0000000 0000000 00000000000 12006244625 0016244 5 ustar 00root root 0000000 0000000 livetribe-jsr223-2.0.7/src/main/java/ 0000775 0000000 0000000 00000000000 12006244625 0017165 5 ustar 00root root 0000000 0000000 livetribe-jsr223-2.0.7/src/main/java/javax/ 0000775 0000000 0000000 00000000000 12006244625 0020276 5 ustar 00root root 0000000 0000000 livetribe-jsr223-2.0.7/src/main/java/javax/script/ 0000775 0000000 0000000 00000000000 12006244625 0021602 5 ustar 00root root 0000000 0000000 livetribe-jsr223-2.0.7/src/main/java/javax/script/AbstractScriptEngine.java 0000664 0000000 0000000 00000005617 12006244625 0026534 0 ustar 00root root 0000000 0000000 /**
*
* Copyright 2006 - 2007 (C) The original author or authors
*
* Licensed 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 javax.script;
import java.io.Reader;
/**
* @version $Revision$ $Date$
*/
public abstract class AbstractScriptEngine implements ScriptEngine
{
protected ScriptContext context;
public AbstractScriptEngine()
{
context = new SimpleScriptContext();
}
public AbstractScriptEngine(Bindings bindings)
{
context = new SimpleScriptContext();
context.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
}
public ScriptContext getContext()
{
return context;
}
public void setContext(ScriptContext context)
{
this.context = context;
}
public Bindings getBindings(int scope)
{
return context.getBindings(scope);
}
public void setBindings(Bindings bindings, int scope)
{
context.setBindings(bindings, scope);
}
public Object get(String key)
{
return context.getBindings(ScriptContext.ENGINE_SCOPE).get(key);
}
public void put(String key, Object value)
{
if (key == null) throw new IllegalArgumentException("Key is null");
context.getBindings(ScriptContext.ENGINE_SCOPE).put(key, value);
}
public Object eval(Reader reader) throws ScriptException
{
return eval(reader, context);
}
public Object eval(String script, Bindings bindings) throws ScriptException
{
return eval(script, getScriptContext(bindings));
}
public Object eval(String script) throws ScriptException
{
return eval(script, context);
}
public Object eval(Reader reader, Bindings bindings) throws ScriptException
{
return eval(reader, getScriptContext(bindings));
}
protected ScriptContext getScriptContext(Bindings bindings)
{
ScriptContext result = new SimpleScriptContext();
if (bindings != null)
{
result.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
}
if (context.getBindings(ScriptContext.GLOBAL_SCOPE) != null)
{
result.setBindings(context.getBindings(ScriptContext.GLOBAL_SCOPE), ScriptContext.GLOBAL_SCOPE);
}
result.setReader(context.getReader());
result.setWriter(context.getWriter());
result.setErrorWriter(context.getErrorWriter());
return result;
}
}
livetribe-jsr223-2.0.7/src/main/java/javax/script/Bindings.java 0000664 0000000 0000000 00000001770 12006244625 0024207 0 ustar 00root root 0000000 0000000 /**
*
* Copyright 2006 - 2007 (C) The original author or authors
*
* Licensed 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 javax.script;
import java.util.Map;
/**
* @version $Revision$ $Date$
*/
public interface Bindings extends Map
{
boolean containsKey(Object key);
Object get(Object key);
Object put(String name, Object value);
void putAll(Map extends String, ? extends Object> toMerge);
Object remove(Object key);
}
livetribe-jsr223-2.0.7/src/main/java/javax/script/Compilable.java 0000664 0000000 0000000 00000001624 12006244625 0024517 0 ustar 00root root 0000000 0000000 /**
*
* Copyright 2005 (C) The original author or authors
*
* Licensed 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 javax.script;
import java.io.Reader;
/**
* @version $Revision$ $Date$
*/
public interface Compilable
{
public CompiledScript compile(String script) throws ScriptException;
public CompiledScript compile(Reader script) throws ScriptException;
}
livetribe-jsr223-2.0.7/src/main/java/javax/script/CompiledScript.java 0000664 0000000 0000000 00000003036 12006244625 0025370 0 ustar 00root root 0000000 0000000 /**
*
* Copyright 2006 - 2007 (C) The original author or authors
*
* Licensed 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 javax.script;
/**
* @version $Revision$ $Date$
*/
public abstract class CompiledScript
{
public CompiledScript()
{
}
public Object eval() throws ScriptException
{
return eval(getEngine().getContext());
}
public Object eval(Bindings bindings) throws ScriptException
{
ScriptEngine engine = getEngine();
SimpleScriptContext context = new SimpleScriptContext();
context.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
context.setBindings(engine.getBindings(ScriptContext.GLOBAL_SCOPE), ScriptContext.GLOBAL_SCOPE);
context.setReader(engine.getContext().getReader());
context.setWriter(engine.getContext().getWriter());
return eval(context);
}
public abstract Object eval(ScriptContext context) throws ScriptException;
public abstract ScriptEngine getEngine();
}
livetribe-jsr223-2.0.7/src/main/java/javax/script/Invocable.java 0000664 0000000 0000000 00000002073 12006244625 0024351 0 ustar 00root root 0000000 0000000 /**
*
* Copyright 2005 (C) The original author or authors
*
* Licensed 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 javax.script;
/**
* @version $Revision$ $Date$
*/
public interface Invocable
{
public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException;
public Object invokeFunction(String name, Object... args) throws ScriptException, NoSuchMethodException;
public T getInterface(Class clazz);
public T getInterface(Object thiz, Class clazz);
}
livetribe-jsr223-2.0.7/src/main/java/javax/script/ScriptContext.java 0000664 0000000 0000000 00000003114 12006244625 0025255 0 ustar 00root root 0000000 0000000 /**
*
* Copyright 2006 - 2007 (C) The original author or authors
*
* Licensed 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 javax.script;
import java.io.Reader;
import java.io.Writer;
import java.util.List;
/**
* @version $Revision$ $Date$
*/
public interface ScriptContext
{
public final static int ENGINE_SCOPE = 100;
public final static int GLOBAL_SCOPE = 200;
public Object getAttribute(String name);
public Object getAttribute(String name, int scope);
public int getAttributesScope(String name);
public Bindings getBindings(int scope);
public Writer getErrorWriter();
public Reader getReader();
public List getScopes();
public Writer getWriter();
public Object removeAttribute(String name, int scope);
public void setAttribute(String name, Object value, int scope);
public void setBindings(Bindings bindings, int scope);
public void setErrorWriter(Writer writer);
public void setReader(Reader reader);
public void setWriter(Writer writer);
}
livetribe-jsr223-2.0.7/src/main/java/javax/script/ScriptEngine.java 0000664 0000000 0000000 00000004103 12006244625 0025035 0 ustar 00root root 0000000 0000000 /**
*
* Copyright 2006 - 2007 (C) The original author or authors
*
* Licensed 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 javax.script;
import java.io.Reader;
/**
* @version $Revision$ $Date$
*/
public interface ScriptEngine
{
public final static String ARGV = "javax.script.argv";
public final static String FILENAME = "javax.script.filename";
public final static String ENGINE = "javax.script.engine";
public final static String ENGINE_VERSION = "javax.script.engine_version";
public final static String NAME = "javax.script.name";
public final static String LANGUAGE = "javax.script.language";
public final static String LANGUAGE_VERSION = "javax.script.language_version";
public Object eval(String script, ScriptContext context) throws ScriptException;
public Object eval(Reader reader, ScriptContext context) throws ScriptException;
public Object eval(String script) throws ScriptException;
public Object eval(Reader reader) throws ScriptException;
public Object eval(String script, Bindings bindings) throws ScriptException;
public Object eval(Reader reader, Bindings bindings) throws ScriptException;
public Object get(String key);
public void put(String key, Object value);
public Bindings getBindings(int scope);
public void setBindings(Bindings bindings, int scope);
public Bindings createBindings();
public ScriptContext getContext();
public void setContext(ScriptContext context);
public ScriptEngineFactory getFactory();
}
livetribe-jsr223-2.0.7/src/main/java/javax/script/ScriptEngineFactory.java 0000664 0000000 0000000 00000002523 12006244625 0026371 0 ustar 00root root 0000000 0000000 /**
*
* Copyright 2005 (C) The LogicBlaze, Inc. All Rights Reserved.
*
* Licensed 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 javax.script;
import java.util.List;
/**
* @version $Revision$ $Date$
*/
public interface ScriptEngineFactory
{
public String getEngineName();
public String getEngineVersion();
public List getExtensions();
public String getLanguageName();
public String getLanguageVersion();
public String getMethodCallSyntax(String obj, String m, String... args);
public List getMimeTypes();
public List getNames();
public String getOutputStatement(String toDisplay);
public Object getParameter(String key);
public String getProgram(String... statements);
public ScriptEngine getScriptEngine();
}
livetribe-jsr223-2.0.7/src/main/java/javax/script/ScriptEngineInfo.java 0000664 0000000 0000000 00000002423 12006244625 0025654 0 ustar 00root root 0000000 0000000 /**
*
* Copyright 2005 (C) The original author or authors
*
* Licensed 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 javax.script;
import java.util.List;
/**
* @version $Revision$ $Date$
*/
public interface ScriptEngineInfo
{
public String getEngineName();
public String getEngineVersion();
public List getExtensions();
public List getMimeTypes();
public List getNames();
public String getLanguageName();
public String getLanguageVersion();
public Object getParameter(String key);
public String getMethodCallSyntax(String obj, String m, String... args);
public String getOutputStatement(String toDisplay);
public String getProgram(String... statements);
}
livetribe-jsr223-2.0.7/src/main/java/javax/script/ScriptEngineManager.java 0000664 0000000 0000000 00000015577 12006244625 0026351 0 ustar 00root root 0000000 0000000 /**
*
* Copyright 2006 - 2008 (C) The original author or authors
*
* Licensed 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 javax.script;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.annotation.AnnotationFormatError;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
/**
* @version $Revision$ $Date$
*/
public class ScriptEngineManager
{
private final Set engineSpis = new HashSet();
private final Map byName = new HashMap();
private final Map registeredByName = new HashMap();
private final Map byExtension = new HashMap();
private final Map registeredByExtension = new HashMap();
private final Map byMimeType = new HashMap();
private final Map registeredByMimeType = new HashMap();
private Bindings globalScope;
public ScriptEngineManager()
{
this(Thread.currentThread().getContextClassLoader());
}
@SuppressWarnings({"EmptyCatchBlock"})
public ScriptEngineManager(ClassLoader classLoader)
{
try
{
Enumeration factoryResources = classLoader.getResources("META-INF/services/javax.script.ScriptEngineFactory");
while (factoryResources.hasMoreElements())
{
URL url = (URL) factoryResources.nextElement();
for (String className : getClassNames(url))
{
try
{
Class factoryClass = classLoader.loadClass(className);
Object object = factoryClass.newInstance();
if (object instanceof ScriptEngineFactory)
{
ScriptEngineFactory factory = (ScriptEngineFactory) object;
for (String name : factory.getNames()) byName.put(name, factory);
for (String extension : factory.getExtensions()) byExtension.put(extension, factory);
for (String mimeType : factory.getMimeTypes()) byMimeType.put(mimeType, factory);
engineSpis.add(factory);
}
}
catch (ClassNotFoundException doNothing)
{
}
catch (IllegalAccessException doNothing)
{
}
catch (InstantiationException doNothing)
{
}
catch (LinkageError doNothing)
{
}
catch (AnnotationFormatError doNothing)
{
}
}
}
}
catch (IOException doNothing)
{
}
}
public Bindings getGlobalScope()
{
return globalScope;
}
public void setGlobalScope(Bindings globalScope)
{
this.globalScope = globalScope;
}
public void put(String key, Object value)
{
if (globalScope != null) globalScope.put(key, value);
}
public Object get(String key)
{
if (globalScope != null) return globalScope.get(key);
else return null;
}
public ScriptEngine getEngineByName(String shortName)
{
ScriptEngineFactory factory = registeredByName.get(shortName);
if (factory == null) factory = byName.get(shortName);
if (factory == null) return null;
ScriptEngine engine = factory.getScriptEngine();
engine.setBindings(globalScope, ScriptContext.GLOBAL_SCOPE);
return engine;
}
public ScriptEngine getEngineByExtension(String extension)
{
ScriptEngineFactory factory = registeredByExtension.get(extension);
if (factory == null) factory = byExtension.get(extension);
if (factory == null) return null;
ScriptEngine engine = factory.getScriptEngine();
engine.setBindings(globalScope, ScriptContext.GLOBAL_SCOPE);
return engine;
}
public ScriptEngine getEngineByMimeType(String mimeType)
{
ScriptEngineFactory factory = registeredByMimeType.get(mimeType);
if (factory == null) factory = byMimeType.get(mimeType);
if (factory == null) return null;
ScriptEngine engine = factory.getScriptEngine();
engine.setBindings(globalScope, ScriptContext.GLOBAL_SCOPE);
return engine;
}
public List getEngineFactories()
{
return new ArrayList(engineSpis);
}
public void registerEngineName(String name, ScriptEngineFactory factory)
{
registeredByName.put(name, factory);
}
public void registerEngineMimeType(String type, ScriptEngineFactory factory)
{
registeredByMimeType.put(type, factory);
}
public void registerEngineExtension(String extension, ScriptEngineFactory factory)
{
registeredByExtension.put(extension, factory);
}
@SuppressWarnings({"EmptyCatchBlock"})
private Iterable getClassNames(URL url)
{
Stack stack = new Stack();
BufferedReader r = null;
try
{
r = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while ((line = r.readLine()) != null)
{
int comment = line.indexOf('#');
if (comment != -1) line = line.substring(0, comment);
line = line.trim();
if (line.length() > 0)
stack.push(line);
}
}
catch (IOException doNothing)
{
}
finally
{
try
{
if (r != null)
r.close();
}
catch (IOException doNothing)
{
}
}
return stack;
}
}
livetribe-jsr223-2.0.7/src/main/java/javax/script/ScriptException.java 0000664 0000000 0000000 00000004561 12006244625 0025576 0 ustar 00root root 0000000 0000000 /**
*
* Copyright 2005 (C) The original author or authors
*
* Licensed 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 javax.script;
/**
* @version $Revision$ $Date$
*/
public class ScriptException extends Exception
{
private final String fileName;
private final int lineNumber;
private final int columnNumber;
public ScriptException(String message)
{
this(message, null, -1, -1);
}
public ScriptException(Exception e)
{
super(e.getMessage(), e);
this.fileName = null;
this.lineNumber = -1;
this.columnNumber = -1;
}
public ScriptException(String message, String fileName, int lineNumber)
{
this(message, fileName, lineNumber, -1);
}
public ScriptException(String message, String fileName, int lineNumber, int columnNumber)
{
super(message);
this.fileName = fileName;
this.lineNumber = lineNumber;
this.columnNumber = columnNumber;
}
public String getMessage()
{
if (fileName != null)
{
StringBuffer message = new StringBuffer(super.getMessage() == null ? "" : super.getMessage());
if (lineNumber != -1)
{
message.append(" at [").append(lineNumber);
if (columnNumber != -1) message.append(", ").append(columnNumber);
message.append("]");
}
message.append(" in file ").append(fileName);
return message.toString();
}
else
{
return super.getMessage();
}
}
public String getFileName()
{
return fileName;
}
public int getLineNumber()
{
return lineNumber;
}
public int getColumnNumber()
{
return columnNumber;
}
}
livetribe-jsr223-2.0.7/src/main/java/javax/script/SimpleBindings.java 0000664 0000000 0000000 00000004611 12006244625 0025356 0 ustar 00root root 0000000 0000000 /**
*
* Copyright 2006 - 2007 (C) The original author or authors
*
* Licensed 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 javax.script;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* @version $Revision$ $Date$
*/
public class SimpleBindings implements Bindings
{
private final Map map;
public SimpleBindings()
{
this(new HashMap());
}
public SimpleBindings(Map map)
{
this.map = map;
}
public Object put(String name, Object value)
{
if (name == null) throw new NullPointerException("Name is null");
return map.put((String) name, value);
}
public void putAll(Map extends String, ? extends Object> toMerge)
{
for (String key : toMerge.keySet())
{
if (key == null) throw new NullPointerException("Key is null");
}
map.putAll(toMerge);
}
public int size()
{
return map.size();
}
public boolean isEmpty()
{
return map.isEmpty();
}
public boolean containsKey(Object key)
{
return map.containsKey(key);
}
public boolean containsValue(Object value)
{
return map.containsValue(value);
}
public Object get(Object key)
{
return map.get(key);
}
public Object remove(Object key)
{
return map.remove(key);
}
public void clear()
{
map.clear();
}
public Set keySet()
{
return map.keySet();
}
public Collection