blob: 542b64c94302ddea750f23a43151d4bbf5d8f451 [file] [log] [blame]
///////////////////////////////////////////////////////////////
* 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.
///////////////////////////////////////////////////////////////
[[lang-javascript, Javascript Scripting Library]]
= Javascript Scripting =
[devstatus]
--------------
source=libraries/lang-javascript/dev-status.xml
--------------
The Javascript Scripting Library allows Mixin methods to be implemented in Javascript and loaded dynamically on first use.
include::../../build/docs/buildinfo/artifact.txt[]
The Javascript Scripting Library is a Generic mixin class that implements
Composite interfaces by delegating to JavaScript functions using Rhino. Each
method in an interface is declared as a JS function in a file located in
classpath with the name "<interface>.<method>.js", where the interface name
includes the package, and has "." replaced with "/".
Example:
org/apache/zest/samples/hello/domain/HelloWorldSpeaker.say.js
That means that the HelloWorldSpeaker.say.js file may be co-located with the
class files in the same package. It is currently not supported to place the
Javascript implementation of the mixin in a different package than the
interface it implements.
To use Javascript to implement the Mixin functionality for a given interface,
simply declare the +JavaScriptMixin+ like any other mixin, either in the
interface or at assembly time.
[snippet,java]
----
source=libraries/lang-javascript/src/test/java/org/apache/zest/library/javascript/HelloSpeaker.java
tag=mixin
----