You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by gt...@apache.org on 2010/12/12 07:14:00 UTC
svn commit: r1044769 - in /incubator/river/jtsk/skunk/surrogate: ./
nbproject/ schemas/ src/org/apache/river/container/
src/org/apache/river/container/config/ src/schemas/
test/org/apache/river/container/ test/org/apache/river/container/config/
testfil...
Author: gtrasuk
Date: Sun Dec 12 06:13:59 2010
New Revision: 1044769
URL: http://svn.apache.org/viewvc?rev=1044769&view=rev
Log:
Core container loads up, and deploys JMX-enabled core components. Next up, we'll need to fill in the security manager and codebase servers.
Added:
incubator/river/jtsk/skunk/surrogate/build-before-management.xml
incubator/river/jtsk/skunk/surrogate/nbproject/management-build-impl.xml
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Bootstrap.java
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/DeploymentListener.java
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/MBeanRegistrar.java
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/ShowContextToConsole.java
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/ShutdownListener.java
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/ShutdownListenerMXBean.java
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Utils.java
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/config/
incubator/river/jtsk/skunk/surrogate/src/schemas/
incubator/river/jtsk/skunk/surrogate/src/schemas/config.xsd
- copied, changed from r1043056, incubator/river/jtsk/skunk/surrogate/schemas/config.xsd
incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/BootstrapTest.java
incubator/river/jtsk/skunk/surrogate/testfiles/testroot/
incubator/river/jtsk/skunk/surrogate/testfiles/testroot/profile/
incubator/river/jtsk/skunk/surrogate/testfiles/testroot/profile/default/
incubator/river/jtsk/skunk/surrogate/testfiles/testroot/profile/default/config.xml
Removed:
incubator/river/jtsk/skunk/surrogate/schemas/config.xsd
Modified:
incubator/river/jtsk/skunk/surrogate/build.xml
incubator/river/jtsk/skunk/surrogate/nbproject/genfiles.properties
incubator/river/jtsk/skunk/surrogate/nbproject/project.properties
incubator/river/jtsk/skunk/surrogate/nbproject/project.xml
incubator/river/jtsk/skunk/surrogate/schemas/config-sample.xml
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/AnnotatedClassDeployer.java
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/MessageNames.java
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Messages.properties
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Strings.java
incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/config/ConfigurationParserTest.java
Added: incubator/river/jtsk/skunk/surrogate/build-before-management.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/build-before-management.xml?rev=1044769&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/build-before-management.xml (added)
+++ incubator/river/jtsk/skunk/surrogate/build-before-management.xml Sun Dec 12 06:13:59 2010
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See commented blocks below for -->
+<!-- some examples of how to customize the build. -->
+<!-- (If you delete it and reopen the project it will be recreated.) -->
+<!-- By default, only the Clean and Build commands use this build script. -->
+<!-- Commands such as Run, Debug, and Test only use this build script if -->
+<!-- the Compile on Save feature is turned off for the project. -->
+<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
+<!-- in the project's Project Properties dialog box.-->
+<project name="surrogate" default="default" basedir=".">
+ <description>Builds, tests, and runs the project RiverSurrogate.</description>
+ <import file="nbproject/build-impl.xml"/>
+ <!--
+
+ There exist several targets which are by default empty and which can be
+ used for execution of your tasks. These targets are usually executed
+ before and after some main targets. They are:
+
+ -pre-init: called before initialization of project properties
+ -post-init: called after initialization of project properties
+ -pre-compile: called before javac compilation
+ -post-compile: called after javac compilation
+ -pre-compile-single: called before javac compilation of single file
+ -post-compile-single: called after javac compilation of single file
+ -pre-compile-test: called before javac compilation of JUnit tests
+ -post-compile-test: called after javac compilation of JUnit tests
+ -pre-compile-test-single: called before javac compilation of single JUnit test
+ -post-compile-test-single: called after javac compilation of single JUunit test
+ -pre-jar: called before JAR building
+ -post-jar: called after JAR building
+ -post-clean: called after cleaning build products
+
+ (Targets beginning with '-' are not intended to be called on their own.)
+
+ Example of inserting an obfuscator after compilation could look like this:
+
+ <target name="-post-compile">
+ <obfuscate>
+ <fileset dir="${build.classes.dir}"/>
+ </obfuscate>
+ </target>
+
+ For list of available properties check the imported
+ nbproject/build-impl.xml file.
+
+
+ Another way to customize the build is by overriding existing main targets.
+ The targets of interest are:
+
+ -init-macrodef-javac: defines macro for javac compilation
+ -init-macrodef-junit: defines macro for junit execution
+ -init-macrodef-debug: defines macro for class debugging
+ -init-macrodef-java: defines macro for class execution
+ -do-jar-with-manifest: JAR building (if you are using a manifest)
+ -do-jar-without-manifest: JAR building (if you are not using a manifest)
+ run: execution of project
+ -javadoc-build: Javadoc generation
+ test-report: JUnit report generation
+
+ An example of overriding the target for project execution could look like this:
+
+ <target name="run" depends="RiverSurrogate-impl.jar">
+ <exec dir="bin" executable="launcher.exe">
+ <arg file="${dist.jar}"/>
+ </exec>
+ </target>
+
+ Notice that the overridden target depends on the jar target and not only on
+ the compile target as the regular run target does. Again, for a list of available
+ properties which you can use, check the target you are overriding in the
+ nbproject/build-impl.xml file.
+
+ -->
+
+ <target name="-post-init">
+ <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
+ <classpath>
+ <path path="${libs.jaxb.classpath}" />
+ </classpath>
+ </taskdef>
+
+ </target>
+ <!--
+ Build the whatever sample artifacts are needed for unit testing. In
+ particular, we need a sample surrogate.
+ -->
+ <target name='-post-compile-test'>
+ <mkdir dir="${basedir}/build/test/files"/>
+ <property name="build.test.sample-surrogate.dir"
+ value="${basedir}/build/test/sample-surrogate"/>
+
+ <mkdir dir="${build.test.sample-surrogate.dir}"/>
+ <!-- Create and copy the classes. -->
+ <copy todir="${build.test.sample-surrogate.dir}">
+ <fileset dir="${basedir}/build/test/classes"
+ includes="org/apache/river/surrogate/sample/**"/>
+ </copy>
+ <mkdir dir="${build.test.sample-surrogate.dir}/META-INF"/>
+ <copy tofile="${build.test.sample-surrogate.dir}/META-INF/MANIFEST.MF"
+ file="${basedir}/testfiles/SampleSurrogate.MF"/>
+ <jar basedir="${build.test.sample-surrogate.dir}"
+ jarfile="${basedir}/build/test/files/sample-surrogate.jar"/>
+ </target>
+
+ <!-- Pre-compiler target to run javacc against our parser sources. -->
+ <target name="-pre-compile">
+ <mkdir dir="${build.generated.sources.dir}/org/apache/river/container/security"/>
+ <jjtree
+ target="${basedir}/src/org/apache/river/container/security/PermissionFileParser.jjt"
+ outputdirectory="${build.generated.sources.dir}/org/apache/river/container/security"
+ javacchome="${libs.JavaCC.src}"
+ />
+ <javacc
+ target="${build.generated.sources.dir}/org/apache/river/container/security/PermissionFileParser.jj"
+ outputdirectory="${build.generated.sources.dir}/org/apache/river/container/security"
+ javacchome="${libs.JavaCC.src}"
+ />
+ <mkdir dir="${build.generated.sources.dir}/org/apache/river/container/config" />
+ <xjc destdir="${build.generated.sources.dir}" schema="src/schemas/config.xsd"
+ package="org.apache.river.container.config">
+ <produces dir="src/org/apache/river/container/config" includes="*.java" />
+ </xjc>
+ </target>
+</project>
Modified: incubator/river/jtsk/skunk/surrogate/build.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/build.xml?rev=1044769&r1=1044768&r2=1044769&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/build.xml (original)
+++ incubator/river/jtsk/skunk/surrogate/build.xml Sun Dec 12 06:13:59 2010
@@ -10,7 +10,8 @@
<project name="surrogate" default="default" basedir=".">
<description>Builds, tests, and runs the project RiverSurrogate.</description>
<import file="nbproject/build-impl.xml"/>
- <!--
+
+ <import file="nbproject/management-build-impl.xml"/> <!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
@@ -116,9 +117,10 @@
javacchome="${libs.JavaCC.src}"
/>
<mkdir dir="${build.generated.sources.dir}/org/apache/river/container/config" />
- <xjc destdir="${build.generated.sources.dir}" schema="schemas/config.xsd"
+ <xjc destdir="${build.generated.sources.dir}" schema="src/schemas/config.xsd"
package="org.apache.river.container.config">
<produces dir="src/org/apache/river/container/config" includes="*.java" />
</xjc>
</target>
</project>
+
Modified: incubator/river/jtsk/skunk/surrogate/nbproject/genfiles.properties
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/nbproject/genfiles.properties?rev=1044769&r1=1044768&r2=1044769&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/nbproject/genfiles.properties (original)
+++ incubator/river/jtsk/skunk/surrogate/nbproject/genfiles.properties Sun Dec 12 06:13:59 2010
@@ -6,3 +6,6 @@ build.xml.stylesheet.CRC32=28e38971@1.38
nbproject/build-impl.xml.data.CRC32=26182442
nbproject/build-impl.xml.script.CRC32=40951c41
nbproject/build-impl.xml.stylesheet.CRC32=229523de@1.38.3.45
+nbproject/management-build-impl.xml.data.CRC32=318d2fde
+nbproject/management-build-impl.xml.script.CRC32=630dcf8f
+nbproject/management-build-impl.xml.stylesheet.CRC32=545273be@1.1
Added: incubator/river/jtsk/skunk/surrogate/nbproject/management-build-impl.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/nbproject/management-build-impl.xml?rev=1044769&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/nbproject/management-build-impl.xml (added)
+++ incubator/river/jtsk/skunk/surrogate/nbproject/management-build-impl.xml Sun Dec 12 06:13:59 2010
@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT ***
+*** EDIT ../build.xml INSTEAD ***
+
+For the purpose of easier reading the script
+is divided into following sections:
+
+ - initialization
+ - management
+
+-->
+<project name="RiverSurrogate-management-impl" default="run-management" basedir=".." xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1">
+ <target name="default" depends="run-management" description="Build the project and enable management."/>
+ <!--
+ ======================
+ INITIALIZATION SECTION
+ ======================
+ -->
+ <target name="-mgt-pre-init">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="-mgt-init-private" depends="-mgt-pre-init">
+ <property file="nbproject/private/private.properties"/>
+ </target>
+ <target name="-mgt-init-user" depends="-mgt-pre-init,-mgt-init-private">
+ <property file="${user.properties.file}"/>
+ <!-- The two properties below are usually overridden -->
+ <!-- by the active platform. Just a fallback. -->
+ <property name="default.javac.source" value="1.4"/>
+ <property name="default.javac.target" value="1.4"/>
+ </target>
+ <target name="-mgt-init-project" depends="-mgt-pre-init,-mgt-init-private,-mgt-init-user">
+ <property file="nbproject/project.properties"/>
+ </target>
+ <target name="-mgt-do-init" depends="-mgt-pre-init,-mgt-init-private,-mgt-init-user,-mgt-init-project,-mgt-init-macrodef-property">
+ <available file="${manifest.file}" property="manifest.available"/>
+ <condition property="manifest.available+main.class">
+ <and>
+ <isset property="manifest.available"/>
+ <isset property="main.class"/>
+ <not>
+ <equals arg1="${main.class}" arg2="" trim="true"/>
+ </not>
+ </and>
+ </condition>
+ <available property="have.tests" file="${test.src.dir}"/>
+ <condition property="netbeans.home+have.tests">
+ <and>
+ <isset property="netbeans.home"/>
+ <isset property="have.tests"/>
+ </and>
+ </condition>
+ <condition property="no.javadoc.preview">
+ <isfalse value="${javadoc.preview}"/>
+ </condition>
+ <property name="run.jvmargs" value=""/>
+ <property name="javac.compilerargs" value=""/>
+ <property name="work.dir" value="${basedir}"/>
+ <condition property="no.deps">
+ <and>
+ <istrue value="${no.dependencies}"/>
+ </and>
+ </condition>
+ </target>
+ <target name="-mgt-post-init">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="-mgt-init-check" depends="-mgt-pre-init,-mgt-init-private,-mgt-init-user,-mgt-init-project,-mgt-do-init">
+ <fail unless="src.dir">Must set src.dir</fail>
+ <fail unless="test.src.dir">Must set test.src.dir</fail>
+ <fail unless="build.dir">Must set build.dir</fail>
+ <fail unless="dist.dir">Must set dist.dir</fail>
+ <fail unless="build.classes.dir">Must set build.classes.dir</fail>
+ <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
+ <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
+ <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
+ <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
+ <fail unless="dist.jar">Must set dist.jar</fail>
+ </target>
+ <target name="-mgt-init-macrodef-property">
+ <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute name="name"/>
+ <attribute name="value"/>
+ <sequential>
+ <property name="@{name}" value="${@{value}}"/>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="init" depends="-mgt-pre-init,-mgt-init-private,-mgt-init-user,-mgt-init-project,-mgt-do-init,-mgt-post-init,-mgt-init-check,-mgt-init-macrodef-property"/>
+ <!--
+ ==================
+ MANAGEMENT SECTION
+ ==================
+ -->
+ <target name="-mgt-init-platform">
+ <condition property="platform.home" value="${jdk.home}">
+ <isfalse value="${platform.home}"/>
+ </condition>
+ <condition property="platform.java" value="${jdk.home}/bin/java">
+ <isfalse value="${platform.java}"/>
+ </condition>
+ </target>
+ <target name="-init-macrodef-management">
+ <macrodef name="management">
+ <attribute name="classname" default="${main.class}"/>
+ <element name="customize" optional="true"/>
+ <sequential>
+ <java fork="true" classname="@{classname}" dir="${work.dir}" jvm="${platform.java}">
+ <jvmarg line="${management.jvmargs} ${run.jvmargs}"/>
+ <classpath>
+ <path path="${run.classpath}"/>
+ </classpath>
+ <syspropertyset>
+ <propertyref prefix="run-sys-prop."/>
+ <mapper type="glob" from="run-sys-prop.*" to="*"/>
+ </syspropertyset>
+ <customize/>
+ </java>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-connect-jconsole" depends="init,-mgt-init-platform">
+ <echo message="jconsole ${jconsole.settings.vmoptions} -interval=${jconsole.settings.polling} ${jconsole.settings.notile} ${jconsole.managed.process.url}"/>
+ <java fork="true" classname="sun.tools.jconsole.JConsole" jvm="${platform.java}">
+ <jvmarg line="${jconsole.settings.vmoptions}"/>
+ <arg line="-interval=${jconsole.settings.polling} ${jconsole.settings.notile} ${jconsole.managed.process.url}"/>
+ <classpath>
+ <path path="${run.classpath}:${platform.home}/lib/jconsole.jar:${platform.home}/lib/tools.jar"/>
+ </classpath>
+ </java>
+ </target>
+ <target name="run-management" if="netbeans.home" depends="init,compile,-mgt-init-platform,-init-macrodef-management" description="Enable local mgt for a project in the IDE.">
+ <echo message="${connecting.jconsole.msg} ${jconsole.managed.process.url}"/>
+ <management>
+ <customize>
+ <arg line="${application.args}"/>
+ </customize>
+ </management>
+ </target>
+ <target name="run-lcl-mgt-single" if="netbeans.home" depends="init,compile-single" description="Manage a selected class in the IDE.">
+ <fail unless="manage.class">Must select one file in the IDE or set manage.class</fail>
+ <!--
+ TODO
+ -->
+ </target>
+ <!--
+ ========================
+ MANAGEMENT DEBUG SECTION
+ ========================
+ -->
+ <target name="-init-debug-args">
+ <exec executable="${platform.java}" outputproperty="version-output">
+ <arg value="-version"/>
+ </exec>
+ <condition property="have-jdk-older-than-1.4">
+ <or>
+ <contains string="${version-output}" substring="java version "1.0"/>
+ <contains string="${version-output}" substring="java version "1.1"/>
+ <contains string="${version-output}" substring="java version "1.2"/>
+ <contains string="${version-output}" substring="java version "1.3"/>
+ </or>
+ </condition>
+ <condition property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none" else="-Xdebug">
+ <istrue value="${have-jdk-older-than-1.4}"/>
+ </condition>
+ </target>
+ <target name="-init-macrodef-management-debug" depends="-init-debug-args">
+ <macrodef name="debug-management">
+ <attribute name="classname" default="${main.class}"/>
+ <attribute name="classpath" default="${debug.classpath}"/>
+ <attribute name="args" default="${application.args}"/>
+ <sequential>
+ <java fork="true" classname="@{classname}" dir="${work.dir}" jvm="${platform.java}">
+ <jvmarg line="${debug-args-line}"/>
+ <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+ <jvmarg line="${management.jvmargs} ${run.jvmargs}"/>
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ <syspropertyset>
+ <propertyref prefix="run-sys-prop."/>
+ <mapper type="glob" from="run-sys-prop.*" to="*"/>
+ </syspropertyset>
+ <arg line="@{args}"/>
+ </java>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-debug-start-debugger" if="netbeans.home" depends="init">
+ <j2seproject1:nbjpdastart name="${debug.class}"/>
+ </target>
+ <target name="-debug-start-managed-debuggee" depends="init,compile,-mgt-init-platform,-init-macrodef-management-debug">
+ <debug-management/>
+ </target>
+ <target name="debug-management" if="netbeans.home" depends="init,compile,-debug-start-debugger,-debug-start-managed-debuggee" description="Debug project in IDE with Local mgt enabled."/>
+</project>
Modified: incubator/river/jtsk/skunk/surrogate/nbproject/project.properties
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/nbproject/project.properties?rev=1044769&r1=1044768&r2=1044769&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/nbproject/project.properties (original)
+++ incubator/river/jtsk/skunk/surrogate/nbproject/project.properties Sun Dec 12 06:13:59 2010
@@ -24,6 +24,7 @@ debug.test.classpath=\
dist.dir=dist
dist.jar=${dist.dir}/RiverSurrogate.jar
dist.javadoc.dir=${dist.dir}/javadoc
+endorsed.classpath=
#endorsed.classpath=\
# ${libs.JAXB-ENDORSED.classpath}
excludes=
@@ -69,7 +70,7 @@ jnlp.enabled=false
jnlp.mixed.code=defaut
jnlp.offline-allowed=false
jnlp.signed=false
-main.class=
+main.class=org.apache.river.container.Bootstrap
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
platform.active=default_platform
Modified: incubator/river/jtsk/skunk/surrogate/nbproject/project.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/nbproject/project.xml?rev=1044769&r1=1044768&r2=1044769&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/nbproject/project.xml (original)
+++ incubator/river/jtsk/skunk/surrogate/nbproject/project.xml Sun Dec 12 06:13:59 2010
@@ -11,5 +11,6 @@
<root id="test.src.dir"/>
</test-roots>
</data>
+ <data xmlns="http://www.netbeans.org/ns/jmx/1" version="0.4"/>
</configuration>
</project>
Modified: incubator/river/jtsk/skunk/surrogate/schemas/config-sample.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/schemas/config-sample.xml?rev=1044769&r1=1044768&r2=1044769&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/schemas/config-sample.xml (original)
+++ incubator/river/jtsk/skunk/surrogate/schemas/config-sample.xml Sun Dec 12 06:13:59 2010
@@ -25,7 +25,7 @@
xsi:schemaLocation='http://river.apache.org/xml/ns/container/config/1.0 file:/home/trasukg/development/surrogate/schemas/config.xsd'>
<!-- List jars and/or directories to be included in the container's
classloader. Format is a space-separated list of jar files or directories.
- The file specs can include wildcards.
+ The file specs cannnot include wildcards.
Note that the core classloader will not have a usable codebase annotation
(the classpath will not be exported) so if components want to make
@@ -34,7 +34,8 @@
-->
<cfg:classpath>
- lib/*.jar
+ lib/container.jar
+ lib/abc.jar
</cfg:classpath>
<!-- List components here:
Modified: incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/AnnotatedClassDeployer.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/AnnotatedClassDeployer.java?rev=1044769&r1=1044768&r2=1044769&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/AnnotatedClassDeployer.java (original)
+++ incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/AnnotatedClassDeployer.java Sun Dec 12 06:13:59 2010
@@ -45,6 +45,8 @@ public class AnnotatedClassDeployer impl
new ArrayList<DeployedObject>();
private Map<String, DeployedObject> initializedObjects =
new HashMap<String, DeployedObject>();
+ private List<DeploymentListener> deploymentListeners=
+ new ArrayList<DeploymentListener>();
public void put(String name, Object o) {
/*
@@ -84,8 +86,19 @@ public class AnnotatedClassDeployer impl
for(Method initMethod: deployed.getInitMethods()) {
initMethod.invoke(deployed.getDeployedObject());
}
+ notifyDeploymentListeners(deployed);
uninitializedObjects.remove(deployed);
initializedObjects.put(deployed.getName(), deployed);
+ if(deployed.getDeployedObject() instanceof DeploymentListener){
+ deploymentListeners.add((DeploymentListener)
+ deployed.getDeployedObject());
+ }
+ }
+ }
+
+ private void notifyDeploymentListeners(DeployedObject deployed) {
+ for (DeploymentListener l: deploymentListeners) {
+ l.postInit(deployed.getName(), deployed.getDeployedObject());
}
}
@@ -275,10 +288,16 @@ public class AnnotatedClassDeployer impl
private void memberSet(Object target, Member member, Object value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
if (member instanceof Field) {
Field f = (Field) member;
+ boolean originalAccess=f.isAccessible();
+ f.setAccessible(true);
f.set(target, value);
+ f.setAccessible(originalAccess);
} else {
Method m = (Method) member;
+ boolean originalAccess=m.isAccessible();
+ m.setAccessible(true);
m.invoke(target, value);
+ m.setAccessible(originalAccess);
}
}
}
Added: incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Bootstrap.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Bootstrap.java?rev=1044769&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Bootstrap.java (added)
+++ incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Bootstrap.java Sun Dec 12 06:13:59 2010
@@ -0,0 +1,164 @@
+/*
+ * 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.river.container;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import org.apache.river.container.config.Component;
+import org.apache.river.container.config.ContainerConfig;
+import org.apache.river.container.config.DiscoveryContextType;
+import org.apache.river.container.config.Property;
+import org.xml.sax.SAXException;
+
+/**
+Bootstrap loader for the container.
+Performs roughly the following:
+<ul>
+<li>Based on the configuration parameter fed in at the command line, determine
+the configuration directory and the config file.</li>
+<li>Read the configuration file</li>
+<li>Based on the classpath declared in the config file, create the container's
+classloader.</li>
+<li>Using that classloader, create the context.</li>
+<li>Load any command-line parameters into the context</li>
+<li>Create all the elements (beans, discovery sets, etc) that are
+called out in the config file and put them into the context. This will cause
+those beans to setup and initialize themselves.</li>
+</li>
+
+ * @author trasukg
+ */
+public class Bootstrap {
+
+ private static final Logger log =
+ Logger.getLogger(Bootstrap.class.getName(),MessageNames.BUNDLE_NAME);
+
+ public static void main(String args[]) {
+ try {
+ initializeContainer(args);
+ } catch (Exception ex) {
+ log.log(Level.SEVERE, MessageNames.INITIALIZATION_EXCEPTION, ex);
+ System.exit(-1);
+ }
+ }
+
+ static Unmarshaller createConfigUnmarshaller() throws SAXException, JAXBException {
+ JAXBContext ctx = JAXBContext.newInstance("org.apache.river.container.config");
+ Unmarshaller um = ctx.createUnmarshaller();
+ SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Source source = new StreamSource(Bootstrap.class.getResourceAsStream("/schemas/config.xsd"));
+ Schema schema = sf.newSchema(source);
+ um.setSchema(schema);
+ return um;
+ }
+
+ static URL[] findClasspathURLS(String classpathStr) throws MalformedURLException {
+ StringTokenizer tok = new StringTokenizer(classpathStr, Strings.WHITESPACE_SEPARATORS);
+ List<URL> pathElements = new ArrayList<URL>();
+ while (tok.hasMoreTokens()) {
+ File f = new File(tok.nextToken());
+ pathElements.add(f.toURI().toURL());
+ }
+ URL[] urls = (URL[]) pathElements.toArray(new URL[0]);
+ return urls;
+ }
+
+ static void initializeContainer(String args[]) throws SAXException, JAXBException, FileNotFoundException, MalformedURLException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException {
+ Unmarshaller um = createConfigUnmarshaller();
+
+ /* If there is a first argument, and it doesn't begin with '-', then
+ it's a profile name.
+ */
+ String profileName = Strings.DEFAULT;
+ if (args.length > 0 && !args[0].startsWith(Strings.DASH)) {
+ profileName = args[0];
+ }
+ File profileDir =
+ new File(Strings.PROFILE + File.separator + profileName);
+ File configFile = new File(profileDir, Strings.CONFIG_XML);
+ InputStream is = new FileInputStream(configFile);
+ ContainerConfig containerConfig = (ContainerConfig) um.unmarshal(is);
+ URL[] urls = findClasspathURLS(containerConfig);
+ log.log(Level.INFO, MessageNames.CONFIGURED_CLASSPATH, new Object[] {
+ Utils.format(urls) } );
+ /* Setup the classloader using the parent of the bootstrap's classloader,
+ which should be the extension loader.
+ */
+ SettableCodebaseClassLoader classLoader = new SettableCodebaseClassLoader(urls,
+ Bootstrap.class.getClassLoader().getParent());
+ /* Create the context object. */
+ Object context = Class.forName(Strings.CONTEXT_CLASS, true, classLoader).newInstance();
+ Method putMethod = context.getClass().getMethod(Strings.PUT, new Class[]{Object.class});
+ Method putByNameMethod = context.getClass().getMethod(
+ Strings.PUT, new Class[] { String.class, Object.class});
+ putMethod.invoke(context, (Object) args);
+ Thread.currentThread().setContextClassLoader(classLoader);
+ for (Object element : containerConfig.getElements()) {
+ if (element instanceof Component) {
+ Component c = (Component) element;
+ Class compClass = Class.forName(c.getClazz(), true, classLoader);
+ Object instance = compClass.newInstance();
+ putMethod.invoke(context, instance);
+ } else if (element instanceof Property) {
+ Property p=(Property) element;
+ putByNameMethod.invoke(context, p.getName(), p.getValue());
+ } else if(element instanceof DiscoveryContextType) {
+ /* Just drop the element into the context under the
+ appropriate name.
+ */
+ DiscoveryContextType dct=(DiscoveryContextType) element;
+ if (dct.getName() == null) {
+ putByNameMethod.invoke(context,
+ Strings.DEFAULT_DISCOVERY_CONTEXT,
+ dct);
+ } else {
+ putByNameMethod.invoke(context,
+ dct.getName(),
+ dct);
+ }
+ } else {
+ throw new ConfigurationException(MessageNames.UNSUPPORTED_ELEMENT, element.getClass().getName());
+ }
+ }
+ }
+
+ static URL[] findClasspathURLS(ContainerConfig containerConfig) throws MalformedURLException {
+ String classpathStr = containerConfig.getClasspath();
+ URL[] urls = findClasspathURLS(classpathStr);
+ return urls;
+ }
+}
Added: incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/DeploymentListener.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/DeploymentListener.java?rev=1044769&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/DeploymentListener.java (added)
+++ incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/DeploymentListener.java Sun Dec 12 06:13:59 2010
@@ -0,0 +1,14 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.river.container;
+
+/**
+ *
+ * @author trasukg
+ */
+public interface DeploymentListener {
+ public void postInit(String name, Object object);
+}
Added: incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/MBeanRegistrar.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/MBeanRegistrar.java?rev=1044769&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/MBeanRegistrar.java (added)
+++ incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/MBeanRegistrar.java Sun Dec 12 06:13:59 2010
@@ -0,0 +1,39 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.river.container;
+
+import java.lang.management.ManagementFactory;
+import java.util.Hashtable;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ *
+ * @author trasukg
+ */
+public class MBeanRegistrar implements DeploymentListener {
+
+ private MBeanServer mbeanServer=null;
+
+ public void postInit(String name, Object object) {
+ try {
+ /*
+ Just try to register it. If it fails, that's OK.
+ */
+ Hashtable<String,String> props=new Hashtable<String, String>();
+ props.put(Strings.NAME, name);
+ ObjectName objectName=new ObjectName(Strings.CONTAINER_JMX_DOMAIN, props);
+ mbeanServer.registerMBean(object, objectName);
+ } catch(Exception ex) {
+ // Don't really care.
+ }
+ }
+
+ @Init
+ public void init() {
+ mbeanServer=ManagementFactory.getPlatformMBeanServer();
+ }
+}
Modified: incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/MessageNames.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/MessageNames.java?rev=1044769&r1=1044768&r2=1044769&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/MessageNames.java (original)
+++ incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/MessageNames.java Sun Dec 12 06:13:59 2010
@@ -26,8 +26,11 @@ public class MessageNames {
public static final String BUNDLE_NAME="org.apache.river.container.Messages";
public static final String
+ CONFIGURED_CLASSPATH = "configuredClasspath",
+ CONTEXT_ITEM = "contextItem",
ILLEGAL_ARGUMENT_EXCEPTION="illegalArgumentException",
ILLEGAL_ACCESS_EXCEPTION="illegalAccessException",
+ INITIALIZATION_EXCEPTION="initializationException",
INVOCATION_TARGET_EXCEPTION="invocationTargetException",
INIT_METHOD_HAS_PARAMETERS="initMethodHasParameters",
INIT_METHOD_NOT_VOID="initMethodIsntVoid",
@@ -35,5 +38,6 @@ public class MessageNames {
READING_OBJECT="readingObject",
READING_OBJECT_MEMBER_COUNT="readingObject.memberCount",
READING_OBJECT_ANNOTATED_MEMBER_FOUND="readingObject.annotatedMemberFound",
- READING_OBJECT_NON_ANNOTATED_MEMBER_FOUND="readingObject.nonAnnotatedMemberFound";
+ READING_OBJECT_NON_ANNOTATED_MEMBER_FOUND="readingObject.nonAnnotatedMemberFound",
+ UNSUPPORTED_ELEMENT="unsupportedElement";
}
Modified: incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Messages.properties?rev=1044769&r1=1044768&r2=1044769&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Messages.properties (original)
+++ incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Messages.properties Sun Dec 12 06:13:59 2010
@@ -16,9 +16,12 @@
* limitations under the License.
*/
+configuredClasspath=The configured classpath is {0}.
+contextItem=Context key {0} refers to ''{1}''.
illegalArgumentException=An operation threw an IllegalArgumentException.
illegalAccessException=An operation threw an IllegalAccessException.
invocationTargetException=An operation threw an InvocationTargetException.
+initializationException=An exception has occured while initializing the container.
initMethodHasParameters=A method flagged as @Init must take no parameters. \
Method ''{1}'' on class ''{0}'' has parameters.
initMethodIsntVoid=A method flagged as @Init must be void return type. \
@@ -28,3 +31,4 @@ readingObject=Reading instance of {1} na
readingObject.memberCount={0} members found.
readingObject.annotatedMemberFound=Member ''{0}'' is annotated @Injected.
readingObject.nonAnnotatedMemberFound=Member ''{0}'' is not annotated @Injected.
+unsupportedElement=Element type {0} is currently unsupported.
Added: incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/ShowContextToConsole.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/ShowContextToConsole.java?rev=1044769&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/ShowContextToConsole.java (added)
+++ incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/ShowContextToConsole.java Sun Dec 12 06:13:59 2010
@@ -0,0 +1,29 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.river.container;
+
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+
+/**
+ *
+ * @author trasukg
+ */
+public class ShowContextToConsole {
+
+ @Injected private Context context;
+
+ @Init
+ public void init() {
+ ResourceBundle rb=ResourceBundle.getBundle(MessageNames.BUNDLE_NAME);
+
+ for(String key: context.contents.keySet()) {
+ String out=MessageFormat.format(rb.getString(MessageNames.CONTEXT_ITEM),
+ key, context.contents.get(key));
+ System.out.println(out);
+ }
+ }
+}
Added: incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/ShutdownListener.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/ShutdownListener.java?rev=1044769&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/ShutdownListener.java (added)
+++ incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/ShutdownListener.java Sun Dec 12 06:13:59 2010
@@ -0,0 +1,48 @@
+/*
+ * 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.river.container;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author trasukg
+ */
+public class ShutdownListener implements ShutdownListenerMXBean, Runnable {
+ public void run() {
+ synchronized(this) {
+ try {
+ wait();
+ } catch (InterruptedException ex) {
+ Logger.getLogger(ShutdownListener.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ }
+
+ public void shutdown() {
+ synchronized(this) {
+ this.notifyAll();
+ }
+ }
+
+ @Init
+ public void init() {
+ new Thread(this).start();
+ }
+}
Added: incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/ShutdownListenerMXBean.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/ShutdownListenerMXBean.java?rev=1044769&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/ShutdownListenerMXBean.java (added)
+++ incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/ShutdownListenerMXBean.java Sun Dec 12 06:13:59 2010
@@ -0,0 +1,29 @@
+/*
+ * 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.river.container;
+
+import javax.management.MXBean;
+
+/**
+ *
+ * @author trasukg
+ */
+@MXBean
+public interface ShutdownListenerMXBean {
+ public void shutdown();
+}
Modified: incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Strings.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Strings.java?rev=1044769&r1=1044768&r2=1044769&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Strings.java (original)
+++ incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Strings.java Sun Dec 12 06:13:59 2010
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.river.container;
/**
@@ -25,6 +24,18 @@ package org.apache.river.container;
public class Strings {
public static final String
- EMPTY = "",
- SET = "set";
+ COMMAND_LINE_ARGS = "commandLineArgs",
+ CONFIG_XML = "config.xml",
+ CONTAINER_JMX_DOMAIN="org.apache.river.container",
+ CONTEXT_CLASS = "org.apache.river.container.Context",
+ DASH = "-",
+ DEFAULT = "default",
+ DEFAULT_DISCOVERY_CONTEXT = "defaultDiscoveryContext",
+ EMPTY = "",
+ NAME="name",
+ PROFILE = "profile",
+ PUT = "put",
+ SET = "set",
+ TYPE="type",
+ WHITESPACE_SEPARATORS=" \t\n\r";
}
Added: incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Utils.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Utils.java?rev=1044769&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Utils.java (added)
+++ incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/Utils.java Sun Dec 12 06:13:59 2010
@@ -0,0 +1,44 @@
+/*
+ * 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.river.container;
+
+/**
+ *
+ * @author trasukg
+ */
+public class Utils {
+ public static String format(Object array[]) {
+ if (array == null) {
+ return "null";
+ }
+ StringBuffer sb = new StringBuffer();
+ sb.append("[");
+ for (int j = 0; j < array.length; j++) {
+ if (j != 0) {
+ sb.append(", ");
+ }
+ sb.append("'");
+ sb.append(array[j].toString());
+ sb.append("'");
+ }
+ sb.append("]");
+
+ return sb.toString();
+ }
+
+}
Copied: incubator/river/jtsk/skunk/surrogate/src/schemas/config.xsd (from r1043056, incubator/river/jtsk/skunk/surrogate/schemas/config.xsd)
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/src/schemas/config.xsd?p2=incubator/river/jtsk/skunk/surrogate/src/schemas/config.xsd&p1=incubator/river/jtsk/skunk/surrogate/schemas/config.xsd&r1=1043056&r2=1044769&rev=1044769&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/schemas/config.xsd (original)
+++ incubator/river/jtsk/skunk/surrogate/src/schemas/config.xsd Sun Dec 12 06:13:59 2010
@@ -27,11 +27,12 @@
<xsd:complexType name="DiscoveryContextType">
<xsd:sequence>
- <xsd:element name="locator" type="xsd:anyURI" maxOccurs="unbounded"/>
- <xsd:element name="group" type="xsd:string" maxOccurs="unbounded"/>
+ <xsd:element name="locator" type="xsd:anyURI" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <xsd:element name="group" type="xsd:string" minOccurs="0"
+ maxOccurs="unbounded"/>
</xsd:sequence>
- <xsd:attribute name="is-default" type="xsd:boolean" default="false"/>
- <xsd:attribute name="id" type="xsd:string" use="optional"/>
+ <xsd:attribute name="name" type="xsd:string" use="optional"/>
</xsd:complexType>
<xsd:element name="classpath" type="xsd:string"/>
Added: incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/BootstrapTest.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/BootstrapTest.java?rev=1044769&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/BootstrapTest.java (added)
+++ incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/BootstrapTest.java Sun Dec 12 06:13:59 2010
@@ -0,0 +1,63 @@
+/*
+ * 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.river.container;
+
+import java.util.logging.Logger;
+import java.net.URL;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author trasukg
+ */
+public class BootstrapTest {
+
+ private static Logger log=Logger.getLogger(BootstrapTest.class.getName());
+
+ public BootstrapTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ @Test
+ public void testFindClasspathURLS() throws Exception {
+ URL[] urls = Bootstrap.findClasspathURLS("abc.jar");
+ log.info("URLs:" + Utils.format(urls));
+ assertEquals("No URLS found.", 1, urls.length);
+ }
+
+}
Modified: incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/config/ConfigurationParserTest.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/config/ConfigurationParserTest.java?rev=1044769&r1=1044768&r2=1044769&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/config/ConfigurationParserTest.java (original)
+++ incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/config/ConfigurationParserTest.java Sun Dec 12 06:13:59 2010
@@ -1,12 +1,25 @@
/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+ * 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.river.container.config;
import java.io.InputStream;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import javax.xml.XMLConstants;
import javax.xml.bind.JAXBException;
import org.junit.After;
import org.junit.AfterClass;
@@ -16,6 +29,11 @@ import org.junit.BeforeClass;
import org.junit.Test;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import org.xml.sax.SAXException;
/**
*
@@ -35,15 +53,21 @@ public class ConfigurationParserTest {
}
@Before
- public void setUp() {
+ public void setUp() throws JAXBException, SAXException {
+ ctx = JAXBContext.newInstance("org.apache.river.container.config");
+ um = ctx.createUnmarshaller();
+ SchemaFactory sf=SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Source source=new StreamSource(getClass().getResourceAsStream("/schemas/config.xsd"));
+ Schema schema=sf.newSchema(source);
+ um.setSchema(schema);
}
@After
public void tearDown() {
}
- JAXBContext ctx = JAXBContext.newInstance("org.apache.river.container.config");
- Unmarshaller um = ctx.createUnmarshaller();
+ JAXBContext ctx = null;
+ Unmarshaller um = null;
@Test
public void testConfigFileRead() throws Exception {
Added: incubator/river/jtsk/skunk/surrogate/testfiles/testroot/profile/default/config.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/testfiles/testroot/profile/default/config.xml?rev=1044769&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/testfiles/testroot/profile/default/config.xml (added)
+++ incubator/river/jtsk/skunk/surrogate/testfiles/testroot/profile/default/config.xml Sun Dec 12 06:13:59 2010
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Document : config.xml
+ Created on : December 10, 2010, 6:39 PM
+ Author : trasukg
+ Description:
+ Purpose of the document follows.
+-->
+
+<cfg:container-config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xmlns:cfg='http://river.apache.org/xml/ns/container/config/1.0'
+ xsi:schemaLocation='http://river.apache.org/xml/ns/container/config/1.0 file:/home/trasukg/development/surrogate/src/schemas/config.xsd'>
+ <cfg:classpath>../../dist/RiverSurrogate.jar</cfg:classpath>
+ <cfg:property name="testProp" value="ABC"></cfg:property>
+ <cfg:component class="org.apache.river.container.AnnotatedClassDeployer"/>
+ <cfg:component class="org.apache.river.container.MBeanRegistrar"/>
+ <cfg:discovery-context name="abc">
+ <cfg:group>TEST</cfg:group>
+ </cfg:discovery-context>
+ <cfg:component class="org.apache.river.container.ShutdownListener"/>
+ <cfg:component class="org.apache.river.container.ShowContextToConsole"/>
+
+</cfg:container-config>