|
From: <mwl...@us...> - 2008-03-21 16:23:41
|
Revision: 670
http://cishell.svn.sourceforge.net/cishell/?rev=670&view=rev
Author: mwlinnem
Date: 2008-03-21 09:23:25 -0700 (Fri, 21 Mar 2008)
Log Message:
-----------
Initial import. Test algorithm for user preference service.
Added Paths:
-----------
branches/user_prefs/org.cishell.testalgorithm2/.classpath
branches/user_prefs/org.cishell.testalgorithm2/.project
branches/user_prefs/org.cishell.testalgorithm2/.settings/
branches/user_prefs/org.cishell.testalgorithm2/META-INF/
branches/user_prefs/org.cishell.testalgorithm2/META-INF/MANIFEST.MF
branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/
branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/algorithm.properties
branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/component.xml
branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/l10n/
branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/l10n/bundle_en.properties
branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/metatype/
branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/metatype/METADATA.XML
branches/user_prefs/org.cishell.testalgorithm2/build.properties
branches/user_prefs/org.cishell.testalgorithm2/src/
branches/user_prefs/org.cishell.testalgorithm2/src/org/
branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/
branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/
branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2.java
branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2Factory.java
Added: branches/user_prefs/org.cishell.testalgorithm2/.classpath
===================================================================
--- branches/user_prefs/org.cishell.testalgorithm2/.classpath (rev 0)
+++ branches/user_prefs/org.cishell.testalgorithm2/.classpath 2008-03-21 16:23:25 UTC (rev 670)
@@ -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: branches/user_prefs/org.cishell.testalgorithm2/.project
===================================================================
--- branches/user_prefs/org.cishell.testalgorithm2/.project (rev 0)
+++ branches/user_prefs/org.cishell.testalgorithm2/.project 2008-03-21 16:23:25 UTC (rev 670)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.cishell.testalgorithm2</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: branches/user_prefs/org.cishell.testalgorithm2/META-INF/MANIFEST.MF
===================================================================
--- branches/user_prefs/org.cishell.testalgorithm2/META-INF/MANIFEST.MF (rev 0)
+++ branches/user_prefs/org.cishell.testalgorithm2/META-INF/MANIFEST.MF 2008-03-21 16:23:25 UTC (rev 670)
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Test Algorithm 2
+Bundle-SymbolicName: org.cishell.testalgorithm2
+Bundle-Version: 0.0.1
+Bundle-ClassPath: .
+Import-Package: org.cishell.framework,
+ org.cishell.framework.algorithm,
+ org.cishell.framework.data,
+ org.osgi.framework;version="1.3.0",
+ org.osgi.service.cm;version="1.2.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: branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/algorithm.properties
===================================================================
--- branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/algorithm.properties (rev 0)
+++ branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/algorithm.properties 2008-03-21 16:23:25 UTC (rev 670)
@@ -0,0 +1,9 @@
+menu_path=File/additions
+label=Test Algorithm 2 (Load)
+description=tests various things
+in_data=null
+out_data=null
+service.pid=org.cishell.testalgorithm2.TestAlgorithm2
+remoteable=false
+prefs_published=local
+receive_prefs=true
Added: branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/component.xml
===================================================================
--- branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/component.xml (rev 0)
+++ branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/component.xml 2008-03-21 16:23:25 UTC (rev 670)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<component name="org.cishell.testalgorithm2.TestAlgorithm2.component" immediate="false">
+ <implementation class="org.cishell.testalgorithm2.TestAlgorithm2Factory"/>
+ <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"/>
+ <provide interface=
+ "org.osgi.service.cm.ManagedService"/>
+ </service>
+</component>
\ No newline at end of file
Added: branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/l10n/bundle_en.properties
===================================================================
--- branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/l10n/bundle_en.properties (rev 0)
+++ branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/l10n/bundle_en.properties 2008-03-21 16:23:25 UTC (rev 670)
@@ -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: branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/metatype/METADATA.XML
===================================================================
--- branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/metatype/METADATA.XML (rev 0)
+++ branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/metatype/METADATA.XML 2008-03-21 16:23:25 UTC (rev 670)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0">
+
+ <OCD name="Imaginary Load Algorithm" id="org.cishell.testalgorithm2.TestAlgorithm2.prefs.local.OCD"
+ description="tests various things">
+ <AD name="Default load directory" id="loadDir" type="String" default="directory:"/>
+ <AD name="Default separator characters" id="sepChars" type="String" default=",;"/>
+ </OCD>
+
+ <OCD name="Test Algorithm2" id="org.cishell.testalgorithm2.TestAlgorithm2.old.OCD"
+ description="tests various things">
+ <AD name="stringName" id="stringID" type="String" default="string default"/>
+ <AD name="boolName" id="boolID" type="Boolean" default="true"/>
+ <AD name="intName" id="intID" type="Integer" default="0"/>
+ <AD name="fontName" id="fontID" type="String" default="font:"/>
+ <AD name="directoryName" id="directoryID" type="String" default="directory:/home/"/>
+ <AD name="fileName" id="fileID" type="String" default="file:/home/mwlinnem/nwb/nwb"/>
+ <AD name="pathName" id="pathID" type="String" default="path:/home/mwlinnem/nwb/"/>
+ <AD name="radioName" id="radioID" type="String" default="radio default">
+ <Option label="option 1" value="value 1"/>
+ <Option label="option 2" value="value 2"/>
+ <Option label="option 3" value="value 3"/>
+ </AD>
+ <AD name="floatName" id="floatID" type="Float" default="1.23"/>
+ <Ad name="doubleName" id="doubleID" type="Double" default="1.2345678675442"/>
+ </OCD>
+
+ <Designate pid="org.cishell.testalgorithm2.TestAlgorithm2.prefs.local">
+ <Object ocdref="org.cishell.testalgorithm2.TestAlgorithm2.prefs.local.OCD" />
+ </Designate>
+
+</metatype:MetaData>
Added: branches/user_prefs/org.cishell.testalgorithm2/build.properties
===================================================================
--- branches/user_prefs/org.cishell.testalgorithm2/build.properties (rev 0)
+++ branches/user_prefs/org.cishell.testalgorithm2/build.properties 2008-03-21 16:23:25 UTC (rev 670)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = build/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/
Added: branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2.java
===================================================================
--- branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2.java (rev 0)
+++ branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2.java 2008-03-21 16:23:25 UTC (rev 670)
@@ -0,0 +1,44 @@
+package org.cishell.testalgorithm2;
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+
+import org.cishell.framework.CIShellContext;
+import org.cishell.framework.algorithm.Algorithm;
+import org.cishell.framework.data.Data;
+
+public class TestAlgorithm2 implements Algorithm {
+ Data[] data;
+ Dictionary parameters;
+ CIShellContext context;
+
+ private Dictionary preferences;
+
+ public TestAlgorithm2(Data[] data, Dictionary parameters, CIShellContext context, Dictionary preferences) {
+ this.data = data;
+ this.parameters = parameters;
+ this.context = context;
+ this.preferences = preferences;
+ }
+
+ public Data[] execute() {
+ printPreferences(this.preferences);
+ return null;
+ }
+
+ private void printPreferences(Dictionary preferences) {
+ System.out.println(" Preferences are as follows:");
+ if (preferences == null) {
+ System.out.println(" Dictionary is null!");
+ } else {
+ Enumeration propertiesKeys = preferences.keys();
+
+ while (propertiesKeys.hasMoreElements()) {
+ String propertiesKey = (String) propertiesKeys.nextElement();
+
+ Object propertiesValue = preferences.get(propertiesKey);
+ System.out.println(" " + propertiesKey + ":" + propertiesValue);
+ }
+ }
+}
+}
\ No newline at end of file
Added: branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2Factory.java
===================================================================
--- branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2Factory.java (rev 0)
+++ branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2Factory.java 2008-03-21 16:23:25 UTC (rev 670)
@@ -0,0 +1,99 @@
+package org.cishell.testalgorithm2;
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+
+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.framework.BundleContext;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.metatype.MetaTypeProvider;
+import org.osgi.service.metatype.MetaTypeService;
+import org.osgi.service.metatype.ObjectClassDefinition;
+
+
+public class TestAlgorithm2Factory implements AlgorithmFactory, ManagedService {
+ private MetaTypeProvider provider;
+
+ private BundleContext bContext;
+ private Dictionary preferences;
+
+ protected void activate(ComponentContext ctxt) {
+ //System.out.println("TestAlgorithm 2 beginning activation");
+ //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());
+
+ Dictionary properties = ctxt.getProperties();
+
+ Enumeration propertiesKeys = properties.keys();
+
+ while (propertiesKeys.hasMoreElements()) {
+ String propertiesKey = (String) propertiesKeys.nextElement();
+
+ Object propertiesValue = properties.get(propertiesKey);
+ }
+
+ this.bContext = ctxt.getBundleContext();
+
+ //System.out.println("TestAlgorithm 2 done activating");
+ }
+
+ protected void deactivate(ComponentContext ctxt) {
+ provider = null;
+ }
+
+ public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) {
+
+// //not renaming everything parametersX for sake of ease
+//
+// Enumeration propertiesKeys = parameters.keys();
+//
+// while (propertiesKeys.hasMoreElements()) {
+// String propertiesKey = (String) propertiesKeys.nextElement();
+//
+// Object propertiesValue = parameters.get(propertiesKey);
+// }
+
+ System.out.println("TestAlgorithm 2 executing!");
+ return new TestAlgorithm2(data, parameters, context, this.preferences);
+ }
+ public MetaTypeProvider createParameters(Data[] data) {
+ return provider;
+ }
+ public void updated(Dictionary properties) throws ConfigurationException {
+ // System.out.println("TestAlgorithm 2 updated!");
+
+
+ this.preferences = properties;
+
+ // printPreferences(this.preferences);
+ }
+
+ private void printPreferences(Dictionary properties) {
+ System.out.println(" Preferences are as follows:");
+ if (properties == null) {
+ System.out.println(" Dictionary is null!");
+ } else {
+ Enumeration propertiesKeys = properties.keys();
+
+ while (propertiesKeys.hasMoreElements()) {
+ String propertiesKey = (String) propertiesKeys.nextElement();
+
+ Object propertiesValue = properties.get(propertiesKey);
+ System.out.println(" " + propertiesKey + ":" + propertiesValue);
+ }
+ }
+ }
+
+ public String[] getLocales() {
+ return null;
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|