[Red5commits] [1655] Added support for pre-java6
pgregoire
luke at codegent.com
Thu Jan 25 14:20:09 EST 2007
Added support for pre-java6
Timestamp: 01/25/07 14:07:12 EST (less than one hour ago)
Change: 1655
Author: pgregoire
Files (see diff or trac for details):
java/server/trunk/.classpath
java/server/trunk/build.properties
java/server/trunk/build.xml
java/server/trunk/conf/log4j.properties
java/server/trunk/lib/java5
java/server/trunk/lib/java5/backport-util-concurrent.jar
java/server/trunk/lib/java5/java5.properties
java/server/trunk/lib/java5/java6-compatibility.jar
java/server/trunk/lib/java5/js.jar
java/server/trunk/lib/java5/jsr-223-1.0-pr.jar
java/server/trunk/lib/java5/jsr173_1.0_api.jar
java/server/trunk/src/org/red5/server/script/rhino/RhinoScriptUtils.java
java/server/trunk/webapps/oflaDemo/WEB-INF/red5-web.xml
java/server/trunk/webapps/oflaDemo/WEB-INF/src/applications/demoservice.js
java/server/trunk/webapps/oflaDemo/WEB-INF/src/applications/main.js
java/server/trunk/webapps/oflaDemo/WEB-INF/src/org/red5/server/webapp/oflaDemo/DemoServiceImpl.java
java/server/trunk/webapps/oflaDemo/WEB-INF/src/org/red5/server/webapp/oflaDemo/IDemoService.java
Trac: http://mirror1.cvsdude.com/trac/osflash/red5/changeset/1655
Index: /java/server/trunk/conf/log4j.properties
===================================================================
--- /java/server/trunk/conf/log4j.properties (revision 1654)
+++ /java/server/trunk/conf/log4j.properties (revision 1655)
@@ -19,5 +19,5 @@
log4j.logger.org.red5.server.stream=INFO
log4j.logger.org.red5.server.stream.consumer=INFO
-log4j.logger.org.red5.server.script=INFO
+log4j.logger.org.red5.server.script=DEBUG
# Apache / Other
log4j.logger.org.apache.catalina.authenticator=INFO
Index: /java/server/trunk/src/org/red5/server/script/rhino/RhinoScriptUtils.java
===================================================================
--- /java/server/trunk/src/org/red5/server/script/rhino/RhinoScriptUtils.java (revision 1654)
+++ /java/server/trunk/src/org/red5/server/script/rhino/RhinoScriptUtils.java (revision 1655)
@@ -49,7 +49,5 @@
//Javascript wrapper
- //private static final String jsWrapper = "function Wrapper(obj){return new JSAdapter(){ __has__ : function(name){return true;}, __get__ : function(name){if(name in obj){return obj[name];}else if(name in obj['parentClass']){return obj.parentClass.call(name, arguments);}else if(typeof(obj['doesNotUnderstand']) == 'function'){return function(){return obj.doesNotUnderstand(name, arguments);}}else{return undefined;}}};}";
private static final String jsWrapper = "function Wrapper(obj){return new JSAdapter(){ __has__ : function(name){return true;}, __get__ : function(name){if(name in obj){return obj[name];}else if(typeof(obj['doesNotUnderstand']) == 'function'){return function(){return obj.doesNotUnderstand(name, arguments);}}else{return undefined;}}};}";
- //private static final String jsWrapper = "function Wrapper(obj){return new JSAdapter(){ __has__ : function(name){return true;}, __get__ : function(name){if(name in obj){return obj[name];}else if(name in obj['parentClass']){var methd=obj.parentClass[name];return methd(arguments);}else if(typeof(obj['doesNotUnderstand']) == 'function'){return function(){return obj.doesNotUnderstand(name, arguments);}}else{return undefined;}}};}";
/**
@@ -104,6 +102,5 @@
o = script.eval();
} catch(Exception e) {
- //log.error("Problem evaluating script", e);
- log.error("Problem evaluating script");
+ log.error("Problem evaluating script", e);
}
if (log.isDebugEnabled()) {
Index: /java/server/trunk/build.properties
===================================================================
--- /java/server/trunk/build.properties (revision 1654)
+++ /java/server/trunk/build.properties (revision 1655)
@@ -20,5 +20,5 @@
# Change this var to build to a different Java version
-java.target_version=1.6
+java.target_version=1.5
# jikes options
Index: /java/server/trunk/build.xml
===================================================================
--- /java/server/trunk/build.xml (revision 1447)
+++ /java/server/trunk/build.xml (revision 1655)
@@ -25,7 +25,4 @@
<property name="testreports.dir" value="${testclass.dir}/testreports"/>
<property name="testdoc.dir" value="doc/test"/>
- <target name="-junit.check">
- <available property="junit.installed" classname="junit.framework.TestCase" />
- </target>
<path id="project.classpath">
@@ -37,4 +34,17 @@
<pathelement location="${bin.dir}"/>
</path>
+
+ <!-- For use with pre-java6 environment -->
+ <path id="project_compatibility.classpath">
+ <fileset dir="${lib.dir}" includesfile="${lib.dir}/library.properties" />
+ <fileset dir="${lib.dir}/java5" includesfile="${lib.dir}/java5/java5.properties" />
+ </path>
+
+ <!-- For use with pre-java6 environment -->
+ <path id="script_compatibility.classpath">
+ <fileset dir="${lib.dir}" includesfile="${lib.dir}/script.properties" />
+ <fileset dir="${lib.dir}/java5" includesfile="${lib.dir}/java5/java5.properties" />
+ <pathelement location="${bin.dir}"/>
+ </path>
<path id="webapps.classpath">
@@ -55,4 +65,16 @@
<echo>java.home is ${java.home} and the target version is ${java.target_version}</echo>
+ <target name="-junit.check">
+ <available property="junit.installed" classname="junit.framework.TestCase" />
+ </target>
+
+ <target name="-java6.check">
+ <condition property="java6.installed" value="true">
+ <and>
+ <available property="java6.installed" classname="javax.script.Bindings" />
+ <equals arg1="${java.target_version}" arg2="1.6" />
+ </and>
+ </condition>
+ </target>
<!-- setup the directories for building -->
@@ -96,5 +118,5 @@
</target>
- <target name="compile" depends="-junit.check, prepare">
+ <target name="compile" depends="-java6.check, -junit.check, prepare">
<condition property="java.target_version" value="1.5">
<not>
@@ -110,24 +132,6 @@
<echo message="Compiler adapter name: ${compiler}" />
- <javac
- sourcepath=""
- srcdir="${src.dir}"
- destdir="${classes.dir}"
- classpathref="project.classpath"
-
- optimize="${build.optimize}"
- verbose="${build.verbose}"
- fork="${build.fork}"
- nowarn="${build.nowarn}"
- deprecation="${build.deprecation}"
-
- debug="${debug.state}"
- compiler="${compiler}"
- source="${java.target_version}"
- target="${java.target_version}"
- memoryMaximumSize="1024m"
- excludes="**/*.jsp,com/sun/**,org/red5/server/script/**"
- listfiles="false"
- />
+ <antcall target="compile_core" inheritAll="true" inheritRefs="true" />
+ <antcall target="compile_core_compatibility" inheritAll="true" inheritRefs="true" />
<javac
@@ -217,4 +221,58 @@
/>
+ <antcall target="compile_script" inheritAll="true" inheritRefs="true" />
+ <antcall target="compile_script_compatibility" inheritAll="true" inheritRefs="true" />
+
+ </target>
+
+ <!-- Core -->
+ <target name="compile_core" if="java6.installed">
+ <javac
+ sourcepath=""
+ srcdir="${src.dir}"
+ destdir="${classes.dir}"
+ classpathref="project.classpath"
+
+ optimize="${build.optimize}"
+ verbose="${build.verbose}"
+ fork="${build.fork}"
+ nowarn="${build.nowarn}"
+ deprecation="${build.deprecation}"
+
+ debug="${debug.state}"
+ compiler="${compiler}"
+ source="${java.target_version}"
+ target="${java.target_version}"
+ memoryMaximumSize="1024m"
+ excludes="**/*.jsp,com/sun/**,org/red5/server/script/**"
+ listfiles="false"
+ />
+ </target>
+
+ <target name="compile_core_compatibility" unless="java6.installed">
+ <javac
+ sourcepath=""
+ srcdir="${src.dir}"
+ destdir="${classes.dir}"
+ classpathref="project_compatibility.classpath"
+
+ optimize="${build.optimize}"
+ verbose="${build.verbose}"
+ fork="${build.fork}"
+ nowarn="${build.nowarn}"
+ deprecation="${build.deprecation}"
+
+ debug="${debug.state}"
+ compiler="${compiler}"
+ source="${java.target_version}"
+ target="${java.target_version}"
+ memoryMaximumSize="1024m"
+ excludes="**/*.jsp,com/sun/**,org/red5/server/script/**"
+ listfiles="false"
+ />
+ </target>
+
+ <!-- Scripting -->
+ <target name="compile_script" if="java6.installed">
<javac
sourcepath=""
@@ -235,10 +293,42 @@
memoryMaximumSize="1024m"
listfiles="false"
- />
-
- </target>
+ />
+ </target>
+
+ <target name="compile_script_compatibility" unless="java6.installed">
+ <javac
+ sourcepath=""
+ srcdir="${src.dir}"
+ destdir="${classes.dir}"
+ classpathref="script_compatibility.classpath"
+
+ optimize="${build.optimize}"
+ verbose="${build.verbose}"
+ fork="${build.fork}"
+ nowarn="${build.nowarn}"
+ deprecation="${build.deprecation}"
+
+ debug="${debug.state}"
+ compiler="${compiler}"
+ source="${java.target_version}"
+ target="${java.target_version}"
+ memoryMaximumSize="1024m"
+ listfiles="false"
+ />
+ </target>
<target name="javadoc" description="Generate JavaDoc">
<echo message="Path: ${env.Path}" />
+ <!-- Determine the location of Suns api docs -->
+ <condition property="javadoc.loc" value="javase/6">
+ <equals arg1="${java6.installed}" arg2="true" />
+ </condition>
+ <condition property="javadoc.loc" value="j2se/1.5.0">
+ <not>
+ <equals arg1="${java6.installed}" arg2="true" />
+ </not>
+ </condition>
+ <echo message="Javadoc api stub: ${javadoc.loc}" />
+
<javadoc
useexternalfile="true"
@@ -267,5 +357,5 @@
<group title="IO Packages" packages="org.red5.io:org.red5.io.*"/>
<group title="Scripting" packages="org.red5.server.script:org.red5.server.script.*"/>
- <link href="http://java.sun.com/j2se/1.5.0/docs/api"/>
+ <link href="http://java.sun.com/${javadoc.loc}/docs/api"/>
<link href="http://jetty.mortbay.org/apidocs"/>
<link href="http://directory.apache.org/subprojects/mina/apidocs"/>
@@ -281,4 +371,14 @@
-->
<target name="javadoc-ydoc">
+ <!-- Determine the location of Suns api docs -->
+ <condition property="javadoc.loc" value="javase/6">
+ <equals arg1="${java6.installed}" arg2="true" />
+ </condition>
+ <condition property="javadoc.loc" value="j2se/1.5.0">
+ <not>
+ <equals arg1="${java6.installed}" arg2="true" />
+ </not>
+ </condition>
+ <echo message="Javadoc api stub: ${javadoc.loc}" />
<property name="ydoc.home" value="C:/dev/ydoc"/>
<property name="ps" value="${path.separator}"/>
@@ -329,5 +429,5 @@
<group title="IO Packages" packages="org.red5.io:org.red5.io.*"/>
<group title="Scripting" packages="org.red5.server.script:org.red5.server.script.*"/>
- <link href="http://java.sun.com/j2se/1.5.0/docs/api"/>
+ <link href="http://java.sun.com/${javadoc.loc}/docs/api"/>
<link href="http://jetty.mortbay.org/apidocs"/>
<link href="http://directory.apache.org/subprojects/mina/apidocs"/>
@@ -537,5 +637,5 @@
-->
- <target name="run-tests" if="junit.installed" depends="compiletests" description="Run JUnit tests and generate HTML reports">
+ <target name="run-tests" if="junit.installed" depends="compiletests" description="Run JUnit tests and generate HTML reports">
<junit fork="true" haltonfailure="no" printsummary="no" showoutput="no" dir="${testreports.dir}">
<classpath>
Index: /java/server/trunk/.classpath
===================================================================
--- /java/server/trunk/.classpath (revision 1654)
+++ /java/server/trunk/.classpath (revision 1655)
@@ -69,4 +69,9 @@
<classpathentry kind="lib" path="lib/mina-integration-spring-2.0.0-M1.jar"/>
<classpathentry kind="lib" path="lib/groovy-1.0.jar"/>
+ <classpathentry kind="lib" path="lib/groovy-1.0.jar"/>
+ <classpathentry kind="lib" path="lib/mina-core-2.0.0-M1.jar" sourcepath="C:/dev/other/mina/trunk/core/src/main/java"/>
+ <classpathentry kind="lib" path="lib/mina-filter-compression-2.0.0-M1.jar" sourcepath="C:/dev/other/mina/trunk/filter-compression/src/main/java"/>
+ <classpathentry kind="lib" path="lib/mina-filter-ssl-2.0.0-M1.jar" sourcepath="C:/dev/other/mina/trunk/filter-ssl/src/main/java"/>
+ <classpathentry kind="lib" path="lib/mina-integration-spring-2.0.0-M1.jar" sourcepath="C:/dev/other/mina/trunk/integration-spring/src/main/java"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Index: /java/server/trunk/webapps/oflaDemo/WEB-INF/src/applications/main.js
===================================================================
--- /java/server/trunk/webapps/oflaDemo/WEB-INF/src/applications/main.js (revision 1406)
+++ /java/server/trunk/webapps/oflaDemo/WEB-INF/src/applications/main.js (revision 1655)
@@ -72,5 +72,5 @@
if (supa) {
if (log.isDebugEnabled) {
- print('New instance of prototype: ' + supa);
+ print('New instance of prototype: ' + supa + '\n');
}
object(supa);
Index: /java/server/trunk/webapps/oflaDemo/WEB-INF/src/applications/demoservice.js
===================================================================
--- /java/server/trunk/webapps/oflaDemo/WEB-INF/src/applications/demoservice.js (revision 1405)
+++ /java/server/trunk/webapps/oflaDemo/WEB-INF/src/applications/demoservice.js (revision 1655)
@@ -16,85 +16,101 @@
importClass(Packages.org.red5.server.api.Red5);
-//class impersonator
-function DemoService() {
- this.className = 'DemoService';
- log.debug('DemoService init');
+function object(o) {
+ function DemoService() {
+ this.className = 'DemoService';
+ log.debug('DemoService init');
+
+ getListOfAvailableFLVs = function(string) {
+ log.debug('getListOfAvailableFLVs');
+ log.debug('Con local: ' + Red5.getConnectionLocal());
+ var scope = Red5.getConnectionLocal().getScope();
+ log.debug('Scope: ' + scope);
+ var filesMap = new HashMap();
+ var fileInfo;
+ try {
+ print('Getting the FLV files');
+ var flvs = scope.getResources("streams/*.flv"); //Resource[]
+ log.debug('Flvs: ' + flvs);
+ log.debug('Number of flvs: ' + flvs.length);
+ for (var i=0;i<flvs.length;i++) {
+ var file = flvs[i];
+ log.debug('file: ' + file);
+ log.debug('java.io.File type: ' + (file == typeof(java.io.File)));
+ log.debug('js type: ' + typeof(file));
+ log.debug('file path: ' + file.path);
+ log.debug('file url: ' + file.URL);
+ var serverRoot = java.lang.System.getProperty('red5.root');
+ log.debug('Red5 root: ' + serverRoot);
+ var fso = new File(serverRoot + '/webapps/oflaDemo' + file.path);
+ var flvName = fso.getName();
+ log.debug('flvName: ' + flvName);
+ log.debug('exist: ' + fso.exists());
+ log.debug('readable: ' + fso.canRead());
+ //loop thru props
+ var flvBytes = 0;
+ if ('length' in fso) {
+ flvBytes = fso.length();
+ } else {
+ log.warn('Length not found');
+ }
+ log.debug('flvBytes: ' + flvBytes);
+ var lastMod = '0';
+ if ('lastModified' in fso) {
+ lastMod = this.formatDate(new java.util.Date(fso.lastModified()));
+ } else {
+ log.debug('Last modified not found');
+ }
+
+ print('FLV Name: ' + flvName);
+ print('Last modified date: ' + lastMod);
+ print('Size: ' + flvBytes);
+ print('-------');
+
+ fileInfo = new HashMap(3);
+ fileInfo.put("name", flvName);
+ fileInfo.put("lastModified", lastMod);
+ fileInfo.put("size", flvBytes);
+ filesMap.put(flvName, fileInfo);
+ }
+ } catch (e) {
+ log.warn('Error in getListOfAvailableFLVs: ' + e);
+ }
+ return filesMap;
+ };
+
+ formatDate = function(date) {
+ //java 'thread-safe' date formatting
+ return new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").format(date);
+ };
+
+ toString = function(string) {
+ return 'Javascript:DemoService';
+ };
- if (log.isDebugEnabled) {
- for (property in this) {
- try {
- print('>>' + property);
- } catch(e) {
- e.rhinoException.printStackTrace();
- }
- }
- }
-
- this.getListOfAvailableFLVs = function() {
- log.debug('getListOfAvailableFLVs');
- log.debug('Con local: ' + Red5.getConnectionLocal());
- var scope = Red5.getConnectionLocal().getScope();
- log.debug('Scope: ' + scope);
- var filesMap = new HashMap();
- var fileInfo;
- try {
- print('Getting the FLV files');
- var flvs = scope.getResources("streams/*.flv"); //Resource[]
- log.debug('Flvs: ' + flvs);
- log.debug('Number of flvs: ' + flvs.length);
- for (var i=0;i<flvs.length;i++) {
- var file = flvs[i];
- log.debug('file: ' + file);
- log.debug('java.io.File type: ' + (file == typeof(java.io.File)));
- log.debug('js type: ' + typeof(file));
- log.debug('file path: ' + file.path);
- log.debug('file url: ' + file.URL);
- var serverRoot = java.lang.System.getProperty('red5.root');
- log.debug('Red5 root: ' + serverRoot);
- var fso = new File(serverRoot + '/webapps/oflaDemo' + file.path);
- var flvName = fso.getName();
- log.debug('flvName: ' + flvName);
- log.debug('exist: ' + fso.exists());
- log.debug('readable: ' + fso.canRead());
- //loop thru props
- var flvBytes = 0;
- if ('length' in fso) {
- flvBytes = fso.length();
- } else {
- log.warn('Length not found');
- }
- log.debug('flvBytes: ' + flvBytes);
- var lastMod = '0';
- if ('lastModified' in fso) {
- lastMod = this.formatDate(new java.util.Date(fso.lastModified()));
- } else {
- log.debug('Last modified not found');
- }
-
- print('FLV Name: ' + flvName);
- print('Last modified date: ' + lastMod);
- print('Size: ' + flvBytes);
- print('-------');
-
- fileInfo = new HashMap(3);
- fileInfo.put("name", flvName);
- fileInfo.put("lastModified", lastMod);
- fileInfo.put("size", flvBytes);
- filesMap.put(flvName, fileInfo);
- }
- } catch (e) {
- log.warn('Error in getListOfAvailableFLVs: ' + e);
- }
- return filesMap;
- };
+ doesNotUnderstand = function(name) {
+ print("Unknown method called: " + name + "\n");
+ for (n in context){
+ print('Context: '+n);
+ }
+ if (name in this.__proto__) {
+ if (arguments.length > 0) {
+ return this.__proto__[name](arguments);
+ } else {
+ return this.__proto__[name]();
+ }
+ }
+ };
+ }
+ DemoService.prototype = o;
+ return new DemoService();
}
-DemoService.prototype.formatDate = function(date) {
- //java 'thread-safe' date formatting
- return new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").format(date);
-};
+//if a super class exists in the namespace / bindings
+if (supa) {
+ if (log.isDebugEnabled) {
+ print('New instance of prototype: ' + supa + '\n');
+ }
+ object(supa);
+}
-DemoService.prototype.toString = function(string) {
- return 'Javascript:DemoService';
-};
Index: /java/server/trunk/webapps/oflaDemo/WEB-INF/src/org/red5/server/webapp/oflaDemo/DemoServiceImpl.java
===================================================================
--- /java/server/trunk/webapps/oflaDemo/WEB-INF/src/org/red5/server/webapp/oflaDemo/DemoServiceImpl.java (revision 1606)
+++ /java/server/trunk/webapps/oflaDemo/WEB-INF/src/org/red5/server/webapp/oflaDemo/DemoServiceImpl.java (revision 1655)
@@ -4,5 +4,5 @@
import java.util.Map;
-public class DemoServiceImpl {
+public class DemoServiceImpl implements IDemoService {
/**
* Getter for property 'listOfAvailableFLVs'.
@@ -13,3 +13,10 @@
return new HashMap(1);
}
+
+ public Map getListOfAvailableFLVs(String string) {
+ System.out.println("Got a string: " + string);
+ return getListOfAvailableFLVs();
+ }
+
}
+
Index: /java/server/trunk/webapps/oflaDemo/WEB-INF/src/org/red5/server/webapp/oflaDemo/IDemoService.java
===================================================================
--- /java/server/trunk/webapps/oflaDemo/WEB-INF/src/org/red5/server/webapp/oflaDemo/IDemoService.java (revision 1606)
+++ /java/server/trunk/webapps/oflaDemo/WEB-INF/src/org/red5/server/webapp/oflaDemo/IDemoService.java (revision 1655)
@@ -12,3 +12,5 @@
public Map getListOfAvailableFLVs();
+ public Map getListOfAvailableFLVs(String string);
+
}
Index: /java/server/trunk/webapps/oflaDemo/WEB-INF/red5-web.xml
===================================================================
--- /java/server/trunk/webapps/oflaDemo/WEB-INF/red5-web.xml (revision 1500)
+++ /java/server/trunk/webapps/oflaDemo/WEB-INF/red5-web.xml (revision 1655)
@@ -22,9 +22,9 @@
<property name="virtualHosts" value="${webapp.virtualHosts}" />
</bean>
-
+<!--
<bean id="web.handler"
class="org.red5.server.webapp.oflaDemo.Application" />
+-->
-<!--
<bean id="web.handler" class="org.red5.server.script.rhino.RhinoScriptFactory">
<constructor-arg index="0" value="classpath:applications/main.js"/>
@@ -39,5 +39,5 @@
</constructor-arg>
</bean>
-
+<!--
<bean id="web.handler" class="org.red5.server.script.jruby.JRubyScriptFactory">
<constructor-arg index="0" value="classpath:applications/main.rb"/>
@@ -67,8 +67,8 @@
</bean>
-->
-
+<!--
<bean id="demoService.service"
class="org.red5.server.webapp.oflaDemo.DemoService" />
-<!--
+-->
<bean id="demoService.service" class="org.red5.server.script.rhino.RhinoScriptFactory">
<constructor-arg index="0" value="classpath:applications/demoservice.js"/>
@@ -82,5 +82,5 @@
</constructor-arg>
</bean>
-
+<!--
<bean id="demoService.service" class="org.red5.server.script.jruby.JRubyScriptFactory">
<constructor-arg index="0" value="classpath:applications/demoservice.rb"/>
Index: /java/server/trunk/lib/java5/java5.properties
===================================================================
--- /java/server/trunk/lib/java5/java5.properties (revision 1655)
+++ /java/server/trunk/lib/java5/java5.properties (revision 1655)
@@ -0,0 +1,8 @@
+#
+# Java5 libraries
+#
+backport-util-concurrent.jar
+jsr.jar
+jsr173_1.0_api.jar
+jsr-223-1.0-pr.jar
+java6-compatibility.jar
Note:
Diffs are chopped if more than 25k.
This is to get past the limit on the mailing list.
More information about the Red5commits
mailing list