|
From: <bea...@us...> - 2006-11-21 22:32:30
|
Revision: 339
http://svn.sourceforge.net/cishell/?rev=339&view=rev
Author: bearsfan
Date: 2006-11-21 14:31:51 -0800 (Tue, 21 Nov 2006)
Log Message:
-----------
Test plugin for process trackable algorithms.
Added Paths:
-----------
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/.classpath
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/.project
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/.settings/
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/.settings/org.eclipse.pde.core.prefs
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/META-INF/
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/META-INF/MANIFEST.MF
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/algorithm.properties
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/component.xml
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/l10n/
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/l10n/bundle_en.properties
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/metatype/
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/metatype/METADATA.XML
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/build/
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/build.properties
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/src/
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/src/org/
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/src/org/cishell/
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/src/org/cishell/tests/
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/src/org/cishell/tests/ProgressTrackableAlgorithm/
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/src/org/cishell/tests/ProgressTrackableAlgorithm/AlgorithmTest.java
trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/src/org/cishell/tests/ProgressTrackableAlgorithm/AlgorithmTestFactory.java
Added: trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/.classpath
===================================================================
--- trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/.classpath (rev 0)
+++ trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/.classpath 2006-11-21 22:31:51 UTC (rev 339)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="build"/>
+</classpath>
Added: trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/.project
===================================================================
--- trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/.project (rev 0)
+++ trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/.project 2006-11-21 22:31:51 UTC (rev 339)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.cishell.tests.ProgressTrackableAlgorithm</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/.settings/org.eclipse.pde.core.prefs
===================================================================
--- trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/.settings/org.eclipse.pde.core.prefs (rev 0)
+++ trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/.settings/org.eclipse.pde.core.prefs 2006-11-21 22:31:51 UTC (rev 339)
@@ -0,0 +1,4 @@
+#Thu Nov 16 12:05:17 EST 2006
+eclipse.preferences.version=1
+pluginProject.equinox=false
+pluginProject.extensions=false
Added: trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/META-INF/MANIFEST.MF
===================================================================
--- trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/META-INF/MANIFEST.MF (rev 0)
+++ trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/META-INF/MANIFEST.MF 2006-11-21 22:31:51 UTC (rev 339)
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: My algorithm tester
+Bundle-SymbolicName: org.my.algorithm.test
+Bundle-Version: 0.0.1
+Bundle-ClassPath: .
+Bundle-Localization: plugin
+Import-Package: org.cishell.framework,
+ org.cishell.framework.algorithm,
+ org.cishell.framework.data,
+ org.osgi.framework;version="1.3.0",
+ org.osgi.service.component;version="1.0.0",
+ org.osgi.service.log;version="1.3.0",
+ org.osgi.service.metatype;version="1.1.0",
+ org.osgi.service.prefs;version="1.1.0"
+X-AutoStart: true
+Service-Component: OSGI-INF/component.xml
Added: trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/algorithm.properties
===================================================================
--- trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/algorithm.properties (rev 0)
+++ trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/algorithm.properties 2006-11-21 22:31:51 UTC (rev 339)
@@ -0,0 +1,7 @@
+menu_path=Test/algorithm
+label=Algorithm Tester
+description=This algorithm does tests for me not you
+in_data=null
+out_data=null
+service.pid=org.cishell.tests.ProgressTrackableAlgorithm.AlgorithmTest
+remoteable=false
Added: trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/component.xml
===================================================================
--- trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/component.xml (rev 0)
+++ trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/component.xml 2006-11-21 22:31:51 UTC (rev 339)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<component name="org.cishell.tests.ProgressTrackableAlgorithm.AlgorithmTest.component" immediate="false">
+ <implementation class="org.cishell.tests.ProgressTrackableAlgorithm.AlgorithmTestFactory"/>
+ <properties entry="OSGI-INF/algorithm.properties"/>
+ <reference name="LOG" interface="org.osgi.service.log.LogService"/>
+ <reference name="MTS" interface="org.osgi.service.metatype.MetaTypeService"/>
+
+ <service>
+ <provide interface=
+ "org.cishell.framework.algorithm.AlgorithmFactory"/>
+ </service>
+</component>
\ No newline at end of file
Added: trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/l10n/bundle_en.properties
===================================================================
--- trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/l10n/bundle_en.properties (rev 0)
+++ trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/l10n/bundle_en.properties 2006-11-21 22:31:51 UTC (rev 339)
@@ -0,0 +1,7 @@
+#Localization variables for OSGI-INF/metatatype/METADATA.XML
+#
+#Samples:
+#input=Input
+#desc=Enter an integer (that will be converted to a string)
+#name=Input->String
+#name_desc=Converts inputted integer to string
Added: trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/metatype/METADATA.XML
===================================================================
--- trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/metatype/METADATA.XML (rev 0)
+++ trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/OSGI-INF/metatype/METADATA.XML 2006-11-21 22:31:51 UTC (rev 339)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0">
+ <OCD name="Algorithm Tester" id="org.my.algorithm.test.AlgorithmTest.OCD"
+ description="">
+ </OCD>
+ <Designate pid="org.my.algorithm.test.AlgorithmTest">
+ <Object ocdref="org.my.algorithm.test.AlgorithmTest.OCD" />
+ </Designate>
+</metatype:MetaData>
Added: trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/build.properties
===================================================================
--- trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/build.properties (rev 0)
+++ trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/build.properties 2006-11-21 22:31:51 UTC (rev 339)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = build/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/
Added: trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/src/org/cishell/tests/ProgressTrackableAlgorithm/AlgorithmTest.java
===================================================================
--- trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/src/org/cishell/tests/ProgressTrackableAlgorithm/AlgorithmTest.java (rev 0)
+++ trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/src/org/cishell/tests/ProgressTrackableAlgorithm/AlgorithmTest.java 2006-11-21 22:31:51 UTC (rev 339)
@@ -0,0 +1,69 @@
+package org.cishell.tests.ProgressTrackableAlgorithm;
+
+import java.util.Dictionary;
+
+import org.cishell.framework.CIShellContext;
+import org.cishell.framework.algorithm.Algorithm;
+import org.cishell.framework.algorithm.ProgressMonitor;
+import org.cishell.framework.algorithm.ProgressTrackable;
+import org.cishell.framework.data.Data;
+
+public class AlgorithmTest implements Algorithm, ProgressTrackable {
+//public class AlgorithmTest implements Algorithm {
+ public static final int TOTAL_WORK_UNITS = 100;
+
+ Data[] data;
+ Dictionary parameters;
+ CIShellContext context;
+ ProgressMonitor monitor;
+
+ public AlgorithmTest(Data[] data, Dictionary parameters, CIShellContext context) {
+ this.data = data;
+ this.parameters = parameters;
+ this.context = context;
+ }
+
+ public Data[] execute() {
+ if (monitor != null) {
+ monitor.start(ProgressMonitor.CANCELLABLE |
+ ProgressMonitor.PAUSEABLE |
+ ProgressMonitor.WORK_TRACKABLE, TOTAL_WORK_UNITS);
+ for (int i = 0; i < TOTAL_WORK_UNITS; ++i) {
+ if (monitor.isCanceled()) {
+ break;
+ }
+ else if (monitor.isPaused()) {
+ --i;
+ }
+ monitor.worked(i);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ monitor.done();
+ return null;
+ }
+ else {
+ for (int i = 0; i < TOTAL_WORK_UNITS; ++i) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+ }
+
+ public ProgressMonitor getProgressMonitor() {
+ // TODO Auto-generated method stub
+ return this.monitor;
+ }
+
+ public void setProgressMonitor(ProgressMonitor monitor) {
+ this.monitor = monitor;
+ }
+}
\ No newline at end of file
Added: trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/src/org/cishell/tests/ProgressTrackableAlgorithm/AlgorithmTestFactory.java
===================================================================
--- trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/src/org/cishell/tests/ProgressTrackableAlgorithm/AlgorithmTestFactory.java (rev 0)
+++ trunk/examples/org.cishell.tests.ProgressTrackableAlgorithm/src/org/cishell/tests/ProgressTrackableAlgorithm/AlgorithmTestFactory.java 2006-11-21 22:31:51 UTC (rev 339)
@@ -0,0 +1,34 @@
+package org.cishell.tests.ProgressTrackableAlgorithm;
+
+import java.util.Dictionary;
+
+import org.cishell.framework.CIShellContext;
+import org.cishell.framework.algorithm.Algorithm;
+import org.cishell.framework.algorithm.AlgorithmFactory;
+import org.cishell.framework.data.Data;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.metatype.MetaTypeProvider;
+import org.osgi.service.metatype.MetaTypeService;
+
+
+public class AlgorithmTestFactory implements AlgorithmFactory {
+ private MetaTypeProvider provider;
+
+ protected void activate(ComponentContext ctxt) {
+ //You may delete all references to metatype service if
+ //your algorithm does not require parameters and return
+ //null in the createParameters() method
+ MetaTypeService mts = (MetaTypeService)ctxt.locateService("MTS");
+ provider = mts.getMetaTypeInformation(ctxt.getBundleContext().getBundle());
+ }
+ protected void deactivate(ComponentContext ctxt) {
+ provider = null;
+ }
+
+ public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) {
+ return new AlgorithmTest(data, parameters, context);
+ }
+ public MetaTypeProvider createParameters(Data[] data) {
+ return provider;
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|