Extending Server-Side ActionScript with Java
Server-Side ActionScript is written entirely
in Java, and one of the tremendous
advantages of SSAS is that you can extend it in Java as well. If your
workplace consists of ActionScript programmers who will be assembling
server-side methods using SSAS, a few custom Java functions can
provide any functionality that SSAS is missing. For example, the JRun
4 implementation of SSAS is missing the CF
object,
which is required for database queries. The functionality of the
CF
object can be mimicked in Java and used from
within SSAS. Similarly, the file and directory manipulation
techniques of ColdFusion, Java, and ASP.NET are missing from SSAS;
these too can be added using Java. I’ll show a few
simple examples of possible extensions to SSAS and then show a simple
CF
object with a query( )
method that can be used from within JRun 4.
The Principles of Extending SSAS
Server-Side ActionScript uses the Rhino JavaScript parser, which allows you to call Java methods as follows. To invoke a method of a Java class contained within the java package, first use the new operator to create an instance of the Java class:
var myVar = new java.packagename
.classname
;
Then call methods on the instance of the class as usual:
myVar.methodname
(params
);
You can also reference classes that are not in the
java
package by using the
Packages
prefix:
var myVar = new Packages.myPackagename
.myClassname
;
As an example of using a class that is not in the java package, consider the ...
Get Flash Remoting: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.