You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by do...@apache.org on 2007/12/08 00:54:46 UTC
svn commit: r602277 - in /felix/sandbox/donsez/sosoc: ./
src/main/java/org/apache/felix/sandbox/sosoc/
src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/
src/main/java/org/apache/felix/sandbox/sosoc/manager/java/
src/main/java/org/apache/feli...
Author: donsez
Date: Fri Dec 7 15:54:36 2007
New Revision: 602277
URL: http://svn.apache.org/viewvc?rev=602277&view=rev
Log:
add replace elements to the implementation element
add source, attribute replace elements to the implementation element : multiple sources are concatenated together then tokens are replaced by their values in the text. attributes are passed to the script engine (ie compile=true, source=6.0, target=6.0, debug=true, ...)
Added:
felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Attribute.java (with props)
felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Replace.java (with props)
felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Source.java (with props)
felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/util/replace/
felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/util/replace/ReplaceUtility.java (with props)
felix/sandbox/donsez/sosoc/src/site/component.mbean.xml (with props)
felix/sandbox/donsez/sosoc/src/site/component.runnablejava.xml (with props)
Modified:
felix/sandbox/donsez/sosoc/pom.xml
felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/SOSOCActivator.java
felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/DescriptorParser.java
felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Implementation.java
felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/manager/java/JavaComponentManager.java
felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/manager/rhino/JavaScriptComponentManager.java
felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/manager/script/ScriptComponentManager.java
felix/sandbox/donsez/sosoc/src/site/component.benchcmd.xml
felix/sandbox/donsez/sosoc/src/site/component.echocmd.withembeddedscript.xml
felix/sandbox/donsez/sosoc/src/site/component.echocmd.xml
felix/sandbox/donsez/sosoc/src/site/component.hotdog.vendor.xml
felix/sandbox/donsez/sosoc/src/site/component.loglistener.xml
felix/sandbox/donsez/sosoc/src/site/component.prototype.xml
felix/sandbox/donsez/sosoc/src/site/component.ruleset.xml
felix/sandbox/donsez/sosoc/src/site/component.runnable.xml
felix/sandbox/donsez/sosoc/src/site/component.runnable6.xml
felix/sandbox/donsez/sosoc/src/site/component.servlet.xml
felix/sandbox/donsez/sosoc/src/site/component.thread.xml
felix/sandbox/donsez/sosoc/src/site/index.html
felix/sandbox/donsez/sosoc/src/site/script.txt
felix/sandbox/donsez/sosoc/src/site/template.standalonecomponent.xml
Modified: felix/sandbox/donsez/sosoc/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/pom.xml?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/pom.xml (original)
+++ felix/sandbox/donsez/sosoc/pom.xml Fri Dec 7 15:54:36 2007
@@ -28,7 +28,7 @@
<name>SOSOC</name>
<artifactId>org.apache.felix.sandbox.sosoc</artifactId>
<groupId>org.apache.felix.sandbox</groupId>
- <version>0.1.0</version>
+ <version>0.2.0</version>
<description>${description}</description>
<dependencies>
@@ -57,6 +57,21 @@
<artifactId>js</artifactId>
<version>1.6R7</version>
</dependency>
+
+ <!--
+ <dependency>
+ <groupId>sun.jdk</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.6.0</version>
+ -
+ mvn install:install-file -DgroupId=sun.jdk -DartifactId=tools -Dversion=1.6.0 -Dpackaging=jar -Dfile="c:\Program Files\Java\jdk1.6.0_03\lib\tools.jar"
+ <scope>system</scope>
+ <systemPath>${java.home}/../lib/tools.jar</systemPath>
+ -
+ </dependency>
+ -->
+
+
</dependencies>
Modified: felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/SOSOCActivator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/SOSOCActivator.java?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/SOSOCActivator.java (original)
+++ felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/SOSOCActivator.java Fri Dec 7 15:54:36 2007
@@ -184,6 +184,7 @@
DescriptorParser descriptorParser = new DescriptorParser();
descriptorParser.setTrace(m_logger.getParserTraceFlag());
Component component = descriptorParser.getComponent(serviceComponentClassLoader, descriptorLocation);
+ // TODO check if the name is unique
componentDescriptors.put(component.getName(),component);
}
} else {
@@ -191,6 +192,7 @@
DescriptorParser descriptorParser = new DescriptorParser();
Component component = descriptorParser.getComponent(
serviceComponentClassLoader, m_inputStream);
+ // TODO check if the name is unique
componentDescriptors.put(component.getName(),component);
}
if (componentDescriptors != null) {
Added: felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Attribute.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Attribute.java?rev=602277&view=auto
==============================================================================
--- felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Attribute.java (added)
+++ felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Attribute.java Fri Dec 7 15:54:36 2007
@@ -0,0 +1,101 @@
+/*
+ * 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.felix.sandbox.sosoc.descriptor.xml;
+
+/**
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class Attribute {
+
+ /**
+ * the name of the attribute
+ */
+ private String name;
+
+ /**
+ * the value of the attribute
+ */
+ private String value;
+
+ /**
+ * the CDATA text of the attribute
+ */
+ private String text;
+
+ public String toString(){
+ StringBuffer sb=new StringBuffer();
+ sb.append("[Attribute:");
+ if(name!=null) sb.append("name=").append(name).append(';');
+ if(value!=null) sb.append("value=").append(value).append(';');
+ if(text!=null) sb.append("text=").append(text).append(';');
+ sb.append(']');
+ return sb.toString();
+ }
+
+ public void process() throws Throwable {
+ if(name==null) throw new IllegalArgumentException("attribute name is missing");
+ if(value!=null && text!=null) throw new IllegalArgumentException("could not have both attribute value and CDATA");
+ if(value==null && text==null) throw new IllegalArgumentException("attribute value or CDATA are missing");
+ }
+
+
+ /**
+ * @return the name
+ */
+ public final String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public final void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the value
+ */
+ public final String getValue() {
+ return value;
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public final void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return the text of CDATA
+ */
+ public final String getText() {
+ return text;
+ }
+
+ /**
+ * @return add the text of CDATA
+ */
+ public final void addText(String text) {
+ this.text = text;
+ }
+
+
+}
Propchange: felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Attribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/DescriptorParser.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/DescriptorParser.java?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/DescriptorParser.java (original)
+++ felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/DescriptorParser.java Fri Dec 7 15:54:36 2007
@@ -64,11 +64,11 @@
try {
// 4) set the corresponding type for each element
- // java.util.ArrayList is used for a element which is a list of sub-elements
handler.addType("component", Component.class);
- // attributes and sub-elements are put in SpecialMultivalueMap. When sub-elements have the same name, the values are stored in a java.util.List.
handler.addType("implementation", Implementation.class);
- // the specified type must have setter or adder methods for each attributes and sub-elements
+ handler.addType("attribute", Attribute.class);
+ handler.addType("replace", Replace.class);
+ handler.addType("source", Source.class);
handler.addType("service", Service.class);
handler.addType("provide", Provide.class);
handler.addType("reference", Reference.class);
Modified: felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Implementation.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Implementation.java?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Implementation.java (original)
+++ felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Implementation.java Fri Dec 7 15:54:36 2007
@@ -18,69 +18,43 @@
*/
package org.apache.felix.sandbox.sosoc.descriptor.xml;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
/**
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public class Implementation {
private String clazz;
-
- /**
- * the langage of the SOSOC script. by default Java
- */
- private String language="java";
- /**
- * the entry in which the SOSOC script is stored
- */
- private String entry;
+ private List/*<Attribute>*/ attributes;
- /**
- * the url in which the SOSOC script is stored
- */
- private String url;
+ private List/*<Replaces>*/ replaces;
+
+ private List/*<Source>*/ sources;
/**
- * the CDATA text of the SOSOC script
+ * the langage of the SOSOC script. by default Java
*/
- private String text;
-
+ private String language="java";
- public String getClassName() {
- return clazz;
- }
-
- public void setClass(String clazz) {
- this.clazz = clazz;
- }
-
public String toString(){
StringBuffer sb=new StringBuffer();
sb.append("[Implementation:");
if(language!=null) sb.append("language=").append(language).append(';');
if(clazz!=null) sb.append("class=").append(clazz).append(';');
- if(entry!=null) sb.append("entry=").append(entry).append(';');
- if(url!=null) sb.append("url=").append(url).append(';');
- if(text!=null) sb.append("text=").append(text).append(';');
+ if(attributes!=null) sb.append("attributes=").append(attributes).append(';');
+ if(replaces!=null) sb.append("replaces=").append(replaces).append(';');
+ if(sources!=null) sb.append("sources=").append(sources).append(';');
sb.append(']');
return sb.toString();
}
public void process() throws Throwable {
- if(clazz==null && entry==null && url==null && text==null) throw new IllegalArgumentException("attribute class is missing");
- if(clazz!=null && entry!=null) throw new IllegalArgumentException("could not have both attributes class and entry");
- if(url!=null && entry!=null) throw new IllegalArgumentException("could not have both attributes url and entry");
- if(clazz!=null && url!=null) throw new IllegalArgumentException("could not have both attributes class and url");
- if(clazz==null && language==null && (entry!=null || url!=null)) throw new IllegalArgumentException("attribute language is missing");
-
- // check for text : remark text is append to the script located in the url or in the entry
- }
-
- public String getEntry() {
- return entry;
- }
-
- public void setEntry(String entry) {
- this.entry = entry;
+ if(clazz==null && language==null) throw new IllegalArgumentException("attribute class is missing");
+ if(clazz!=null && language!=null) throw new IllegalArgumentException("could not have both attributes classname and language");
+ if(language!=null && sources==null) throw new IllegalArgumentException("must have sources");
}
public String getLanguage() {
@@ -91,19 +65,42 @@
this.language = language;
}
- public String getUrl() {
- return url;
+ public String getClassName() {
+ return clazz;
}
- public void setUrl(String url) {
- this.url = url;
- }
-
- public String getText() {
- return text;
+ public void setClass(String clazz) {
+ this.clazz = clazz;
}
- public void addText(String text) {
- this.text = text;
+ public List getAttributes() {
+ return attributes;
}
+
+ public void addAttribute(Attribute a) {
+ if (attributes == null)
+ attributes = new ArrayList();
+ attributes.add(a);
+ }
+
+ public List getSources() {
+ return sources;
+ }
+
+ public void addSource(Source s) {
+ if (sources == null)
+ sources = new ArrayList();
+ sources.add(s);
+ }
+
+ public List getReplaces() {
+ return replaces;
+ }
+
+ public void addReplace(Replace r) {
+ if (replaces == null)
+ replaces = new ArrayList();
+ replaces.add(r);
+ }
+
}
Added: felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Replace.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Replace.java?rev=602277&view=auto
==============================================================================
--- felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Replace.java (added)
+++ felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Replace.java Fri Dec 7 15:54:36 2007
@@ -0,0 +1,101 @@
+/*
+ * 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.felix.sandbox.sosoc.descriptor.xml;
+
+/**
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class Replace {
+
+ /**
+ * the name of the attribute
+ */
+ private String token;
+
+ /**
+ * the value of the attribute
+ */
+ private String value;
+
+ /**
+ * the CDATA text of the attribute
+ */
+ private String text;
+
+ public String toString(){
+ StringBuffer sb=new StringBuffer();
+ sb.append("[Replace:");
+ if(token!=null) sb.append("token=").append(token).append(';');
+ if(value!=null) sb.append("value=").append(value).append(';');
+ if(text!=null) sb.append("text=").append(text).append(';');
+ sb.append(']');
+ return sb.toString();
+ }
+
+ public void process() throws Throwable {
+ if(token==null) throw new IllegalArgumentException("attribute token is missing");
+ if(value!=null && text!=null) throw new IllegalArgumentException("could not have both attribute value and CDATA");
+ if(value==null && text==null) throw new IllegalArgumentException("attribute value or CDATA are missing");
+ }
+
+
+ /**
+ * @return the token
+ */
+ public final String getToken() {
+ return token;
+ }
+
+ /**
+ * @param token the token to set
+ */
+ public final void setToken(String token) {
+ this.token = token;
+ }
+
+ /**
+ * @return the value
+ */
+ public final String getValue() {
+ return value;
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public final void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return the text of CDATA
+ */
+ public final String getText() {
+ return text;
+ }
+
+ /**
+ * @return add the text of CDATA
+ */
+ public final void addText(String text) {
+ this.text = text;
+ }
+
+
+}
Propchange: felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Replace.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Source.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Source.java?rev=602277&view=auto
==============================================================================
--- felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Source.java (added)
+++ felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Source.java Fri Dec 7 15:54:36 2007
@@ -0,0 +1,79 @@
+/*
+ * 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.felix.sandbox.sosoc.descriptor.xml;
+
+/**
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class Source {
+
+ /**
+ * the entry in which the SOSOC script is stored
+ */
+ private String entry;
+
+ /**
+ * the url in which the SOSOC script is stored
+ */
+ private String url;
+
+ /**
+ * the CDATA text of the SOSOC script
+ */
+ private String text;
+
+ public String toString(){
+ StringBuffer sb=new StringBuffer();
+ sb.append("[Source:");
+ if(entry!=null) sb.append("entry=").append(entry).append(';');
+ if(url!=null) sb.append("url=").append(url).append(';');
+ if(text!=null) sb.append("text=").append(text).append(';');
+ sb.append(']');
+ return sb.toString();
+ }
+
+ public void process() throws Throwable {
+ if(entry==null && url==null && text==null) throw new IllegalArgumentException("CDATA or attributes entry and url are missing");
+ if(url!=null && entry!=null) throw new IllegalArgumentException("could not have both attributes url and entry");
+ }
+
+ public String getEntry() {
+ return entry;
+ }
+
+ public void setEntry(String entry) {
+ this.entry = entry;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void addText(String text) {
+ this.text = text;
+ }
+}
Propchange: felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/descriptor/xml/Source.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/manager/java/JavaComponentManager.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/manager/java/JavaComponentManager.java?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/manager/java/JavaComponentManager.java (original)
+++ felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/manager/java/JavaComponentManager.java Fri Dec 7 15:54:36 2007
@@ -38,6 +38,9 @@
Class c = m_activator.getClass().getClassLoader().loadClass(
componentDescription.getImplementation().getClassName());
// Create from no-param constructor
+
+ // TODO use javax.tools.JavaCompiler and may be JavaSourceFromString extends SimpleJavaFileObject to compile on-the-fly Java sources
+
return c.newInstance();
}
Modified: felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/manager/rhino/JavaScriptComponentManager.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/manager/rhino/JavaScriptComponentManager.java?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/manager/rhino/JavaScriptComponentManager.java (original)
+++ felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/manager/rhino/JavaScriptComponentManager.java Fri Dec 7 15:54:36 2007
@@ -21,15 +21,22 @@
import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import org.apache.felix.sandbox.sosoc.SOSOCActivator;
import org.apache.felix.sandbox.sosoc.descriptor.xml.Component;
import org.apache.felix.sandbox.sosoc.descriptor.xml.Implementation;
import org.apache.felix.sandbox.sosoc.descriptor.xml.Reference;
+import org.apache.felix.sandbox.sosoc.descriptor.xml.Replace;
+import org.apache.felix.sandbox.sosoc.descriptor.xml.Source;
import org.apache.felix.sandbox.sosoc.manager.ComponentManager;
import org.apache.felix.sandbox.sosoc.manager.Logger;
import org.apache.felix.sandbox.sosoc.manager.ReferenceManager;
import org.apache.felix.sandbox.util.load.LoadUtils;
+import org.apache.felix.sandbox.util.replace.ReplaceUtility;
/**
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
@@ -49,35 +56,58 @@
// load the text of the script
Implementation implementation = componentDescription.getImplementation();
+ List attributes=implementation.getAttributes();
+ List sources=implementation.getSources();
+
String scriptText = null;
- if (implementation.getUrl() != null) {
- String urlStr=implementation.getUrl();
+
+ if(sources!=null){
+ Iterator iterator=sources.iterator();
+ while (iterator.hasNext()) {
+ Source source = (Source) iterator.next();
+ if (source.getUrl() != null) {
+ String urlStr=source.getUrl();
+
+ URL url=null;
+ try {
+ url=new URL(urlStr);
+ } catch (MalformedURLException e) {
+ try {
+ if(baseUrlStr==null){
+ throw e;
+ }
+ url=new URL(new URL(baseUrlStr),urlStr);
+ } catch (MalformedURLException e1) {
+ throw e1;
+ }
+ }
+ scriptText = LoadUtils.loadAsUrl(url.toExternalForm());
+ } else if (source.getEntry() != null) {
+ scriptText = LoadUtils.loadAsRessource(m_activator.getClass().getClassLoader(), source.getEntry());
+ }
- URL url=null;
- try {
- url=new URL(urlStr);
- } catch (MalformedURLException e) {
- try {
- if(baseUrlStr==null){
- throw e;
+ // text is appended to the external script texts
+ if (source.getText() != null) {
+ if(scriptText==null) {
+ scriptText = source.getText();
+ } else {
+ scriptText += '\n' + source.getText();
}
- url=new URL(new URL(baseUrlStr),urlStr);
- } catch (MalformedURLException e1) {
- throw e1;
}
}
- scriptText = LoadUtils.loadAsUrl(url.toExternalForm());
- } else if (implementation.getEntry() != null) {
- scriptText = LoadUtils.loadAsRessource(m_activator.getClass().getClassLoader(), implementation.getEntry());
}
-
- // text is appended to the external script texts
- if (implementation.getText() != null) {
- if(scriptText==null) {
- scriptText = implementation.getText();
- } else {
- scriptText += implementation.getText();
- }
+
+ List replaces=implementation.getReplaces();
+ if(replaces!=null){
+ Map replaceMap=new HashMap();
+ Iterator iterator=replaces.iterator();
+ while (iterator.hasNext()) {
+ Replace replace = (Replace) iterator.next();
+ String value=replace.getValue();
+ if(value==null) value=replace.getText();
+ if(value!=null) replaceMap.put(replace.getToken(), value);
+ }
+ scriptText=ReplaceUtility.replace(scriptText, replaceMap);
}
String[] interfaceNames = componentDescription.getServiceInterfaces();
Modified: felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/manager/script/ScriptComponentManager.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/manager/script/ScriptComponentManager.java?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/manager/script/ScriptComponentManager.java (original)
+++ felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/sosoc/manager/script/ScriptComponentManager.java Fri Dec 7 15:54:36 2007
@@ -21,15 +21,22 @@
import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import org.apache.felix.sandbox.sosoc.SOSOCActivator;
import org.apache.felix.sandbox.sosoc.descriptor.xml.Component;
import org.apache.felix.sandbox.sosoc.descriptor.xml.Implementation;
import org.apache.felix.sandbox.sosoc.descriptor.xml.Reference;
+import org.apache.felix.sandbox.sosoc.descriptor.xml.Replace;
+import org.apache.felix.sandbox.sosoc.descriptor.xml.Source;
import org.apache.felix.sandbox.sosoc.manager.ComponentManager;
import org.apache.felix.sandbox.sosoc.manager.Logger;
import org.apache.felix.sandbox.sosoc.manager.ReferenceManager;
import org.apache.felix.sandbox.util.load.LoadUtils;
+import org.apache.felix.sandbox.util.replace.ReplaceUtility;
/**
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
@@ -49,37 +56,60 @@
// load the text of the script
Implementation implementation = componentDescription.getImplementation();
+ List attributes=implementation.getAttributes();
+ List sources=implementation.getSources();
+
String scriptText = null;
- if (implementation.getUrl() != null) {
- String urlStr=implementation.getUrl();
+
+ if(sources!=null){
+ Iterator iterator=sources.iterator();
+ while (iterator.hasNext()) {
+ Source source = (Source) iterator.next();
+ if (source.getUrl() != null) {
+ String urlStr=source.getUrl();
+
+ URL url=null;
+ try {
+ url=new URL(urlStr);
+ } catch (MalformedURLException e) {
+ try {
+ if(baseUrlStr==null){
+ throw e;
+ }
+ url=new URL(new URL(baseUrlStr),urlStr);
+ } catch (MalformedURLException e1) {
+ throw e1;
+ }
+ }
+ scriptText = LoadUtils.loadAsUrl(url.toExternalForm());
+ } else if (source.getEntry() != null) {
+ scriptText = LoadUtils.loadAsRessource(m_activator.getClass().getClassLoader(), source.getEntry());
+ }
- URL url=null;
- try {
- url=new URL(urlStr);
- } catch (MalformedURLException e) {
- try {
- if(baseUrlStr==null){
- throw e;
+ // text is appended to the external script texts
+ if (source.getText() != null) {
+ if(scriptText==null) {
+ scriptText = source.getText();
+ } else {
+ scriptText += '\n' + source.getText();
}
- url=new URL(new URL(baseUrlStr),urlStr);
- } catch (MalformedURLException e1) {
- throw e1;
}
}
- scriptText = LoadUtils.loadAsUrl(url.toExternalForm());
- } else if (implementation.getEntry() != null) {
- scriptText = LoadUtils.loadAsRessource(m_activator.getClass().getClassLoader(), implementation.getEntry());
- }
-
- // text is appended to the external script texts
- if (implementation.getText() != null) {
- if(scriptText==null) {
- scriptText = implementation.getText();
- } else {
- scriptText += implementation.getText();
- }
}
+ List replaces=implementation.getReplaces();
+ if(replaces!=null){
+ Map replaceMap=new HashMap();
+ Iterator iterator=replaces.iterator();
+ while (iterator.hasNext()) {
+ Replace replace = (Replace) iterator.next();
+ String value=replace.getValue();
+ if(value==null) value=replace.getText();
+ if(value!=null) replaceMap.put(replace.getToken(), value);
+ }
+ scriptText=ReplaceUtility.replace(scriptText, replaceMap);
+ }
+
String[] interfaceNames = componentDescription.getServiceInterfaces();
ClassLoader cl = m_activator.getClass().getClassLoader();
Class[] interfaces=null;
Added: felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/util/replace/ReplaceUtility.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/util/replace/ReplaceUtility.java?rev=602277&view=auto
==============================================================================
--- felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/util/replace/ReplaceUtility.java (added)
+++ felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/util/replace/ReplaceUtility.java Fri Dec 7 15:54:36 2007
@@ -0,0 +1,46 @@
+/*
+ * 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.felix.sandbox.util.replace;
+
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ReplaceUtility {
+
+ public static String replace(String text, Map replaceMap) {
+ StringBuffer sb=new StringBuffer(text);
+ Iterator iterator=replaceMap.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Map.Entry entry = (Map.Entry) iterator.next();
+ String token=(String)entry.getKey();
+ int lenToken=token.length();
+ String value=(String)entry.getValue();
+ int fromIndex=0;
+ int index;
+ while((index=sb.indexOf(token, fromIndex))!=-1) {
+ sb.replace(index, index+lenToken, value);
+ fromIndex=index;
+ }
+ }
+ return sb.toString();
+ }
+}
Propchange: felix/sandbox/donsez/sosoc/src/main/java/org/apache/felix/sandbox/util/replace/ReplaceUtility.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: felix/sandbox/donsez/sosoc/src/site/component.benchcmd.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/component.benchcmd.xml?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/component.benchcmd.xml (original)
+++ felix/sandbox/donsez/sosoc/src/site/component.benchcmd.xml Fri Dec 7 15:54:36 2007
@@ -25,7 +25,9 @@
<!-- July 17 2005 -->
<component name="sosoc.bench.command">
- <implementation language="javascript"><![CDATA[
+ <implementation language="javascript">
+ <attribute name="compile" value="true"/>
+ <source><![CDATA[
// TODO : bench set of Runnable services")
// TODO : bench targetted Runnable services
@@ -87,22 +89,21 @@
// do something
}
- ]]></implementation>
+ ]]></source>
+ </implementation>
- <service>
- <provide interface="org.apache.felix.shell.Command"/>
- </service>
-
- <property value="category" name="command" type="string" />
-
- <!-- Required services -->
- <reference name="RUNNABLE"
- interface="java.lang.Runnable"
- cardinality="1..1"
- policy="static"
- bind="bindRunnable"
- unbind="unbindRunnable"
- />
-<!-- target="(service.pid=sosoc.bench.server)"
- -->
+ <service>
+ <provide interface="org.apache.felix.shell.Command"/>
+ </service>
+
+ <property value="category" name="command" type="string" />
+
+ <!-- Required services -->
+ <reference name="RUNNABLE"
+ interface="java.lang.Runnable"
+ cardinality="1..1"
+ policy="static"
+ bind="bindRunnable"
+ unbind="unbindRunnable"
+ />
</component>
Modified: felix/sandbox/donsez/sosoc/src/site/component.echocmd.withembeddedscript.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/component.echocmd.withembeddedscript.xml?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/component.echocmd.withembeddedscript.xml (original)
+++ felix/sandbox/donsez/sosoc/src/site/component.echocmd.withembeddedscript.xml Fri Dec 7 15:54:36 2007
@@ -24,69 +24,77 @@
<!-- July 17 2005 -->
<component name="sosoc.command.echo.embeddedscript">
- <implementation language="javascript"><![CDATA[
+ <implementation language="javascript">
+ <attribute name="compile" value="true"/>
+ <replace token="##command.name##">echo2</replace>
+ <source><![CDATA[
- // the Java reference to the LogService
- var service;
+ // the Java reference to the LogService
+ var service;
+
+ // Command functions
+ function getName(){
+ return "##command.name##";
+ }
+
+ function getUsage(){
+ return "##command.name## <msg>";
+ }
+
+ function getShortDescription(){
+ return "echo and log a line";
+ }
+
+ function execute(commandLine,out,err){
+ if(service!=undefined){
+ out.println("Log the message from ##command.name##");
+ service.log(3,commandLine); // INFO log level
+ }
+ out.println(commandLine);
+ }
+ ]]></source>
+ <source><![CDATA[
+
+ // Binding/unbinding functions
+ function bindLogService(svcref,svc){
+ service=svc;
+ }
+
+ function unbindLogService(svcref,svc){
+ service=undefined; // undefined is null in JavaScript
+ }
+ ]]></source>
+ <source><![CDATA[
+
+ // Lifecycle functions
+ function activate(){
+ // do something
+ java.lang.System.out.println("script: call activate() function");
+ }
+
+ function deactivate(){
+ java.lang.System.out.println("script: call deactivate() function");
+ // do something
+ }
- // Command functions
- function getName(){
- return "echo2";
- }
+ ]]></source>
+ </implementation>
- function getUsage(){
- return "echo2 <msg>";
- }
- function getShortDescription(){
- return "echo and log a line";
- }
-
- function execute(commandLine,out,err){
- if(service!=undefined){
- out.println("Log the message");
- service.log(3,commandLine); // INFO log level
- }
- out.println(commandLine);
- }
-
- // Binding/unbinding functions
- function bindLogService(svcref,svc){
- service=svc;
- }
-
- function unbindLogService(svcref,svc){
- service=undefined; // undefined is null in JavaScript
- }
-
- // Lifecycle functions
- function activate(){
- // do something
- java.lang.System.out.println("script: call activate() function");
- }
-
- function deactivate(){
- java.lang.System.out.println("script: call deactivate() function");
- // do something
- }
-
- ]]></implementation>
-
-
- <service>
- <provide interface="org.apache.felix.shell.Command"/>
- </service>
-
- <property value="service.pid" name="org.apache.felix.sandbox.command" type="string" />
- <property value="category" name="command" type="string" />
-
- <!-- Required optional service -->
- <reference name="LOG"
- interface="org.osgi.service.log.LogService"
- cardinality="0..1"
- policy="dynamic"
- bind="bindLogService"
- unbind="unbindLogService"
- />
+ <service>
+ <provide interface="org.apache.felix.shell.Command"/>
+ </service>
+
+ <property value="service.pid" name="org.apache.felix.sandbox.command" type="string" />
+ <property value="category" name="command" type="string" />
+
+ <!-- Required optional service -->
+ <reference name="LOG"
+ interface="org.osgi.service.log.LogService"
+ cardinality="0..1"
+ policy="dynamic"
+ bind="bindLogService"
+ unbind="unbindLogService"
+ />
</component>
Modified: felix/sandbox/donsez/sosoc/src/site/component.echocmd.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/component.echocmd.xml?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/component.echocmd.xml (original)
+++ felix/sandbox/donsez/sosoc/src/site/component.echocmd.xml Fri Dec 7 15:54:36 2007
@@ -24,22 +24,24 @@
<!-- July 17 2005 -->
<component name="sosoc.command.echo">
- <implementation language="javascript" url="./echocmd.js"/>
+ <implementation language="javascript">
+ <source url="./echocmd.js"/>
+ </implementation>
- <service>
- <provide interface="org.apache.felix.shell.Command"/>
- </service>
+ <service>
+ <provide interface="org.apache.felix.shell.Command"/>
+ </service>
- <property value="service.pid" name="org.apache.felix.sandbox.sosoc.echocmd" type="string" />
- <property value="category" name="command" type="string" />
-
- <!-- Required services -->
- <reference name="LOG"
- interface="org.osgi.service.log.LogService"
- cardinality="0..1"
- policy="dynamic"
- bind="bindLogService"
- unbind="unbindLogService"
- />
+ <property value="service.pid" name="org.apache.felix.sandbox.sosoc.echocmd" type="string" />
+ <property value="category" name="command" type="string" />
+
+ <!-- Required services -->
+ <reference name="LOG"
+ interface="org.osgi.service.log.LogService"
+ cardinality="0..1"
+ policy="dynamic"
+ bind="bindLogService"
+ unbind="unbindLogService"
+ />
</component>
Modified: felix/sandbox/donsez/sosoc/src/site/component.hotdog.vendor.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/component.hotdog.vendor.xml?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/component.hotdog.vendor.xml (original)
+++ felix/sandbox/donsez/sosoc/src/site/component.hotdog.vendor.xml Fri Dec 7 15:54:36 2007
@@ -21,45 +21,46 @@
<!--
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-->
-<!-- July 17 2005 -->
+<!-- December 7 2007 -->
// see Snackbar tutorial http://www.plop-plop.net/eOSGi/index.php?title=TP2
<component name="sosoc.snackbar.hotdogvendor">
- <implementation language="javascript" url="./hotdog.vendor.js"/>
+ <implementation language="javascript">
+ <source url="./hotdog.vendor.js"/>
+ </implementation>
- <service>
- <provide interface="eosgi.snackbar.service.vendor.VendorService"/>
- </service>
-
- <property value="type" name="hotdog" type="string" />
-
- <!-- Required services -->
- <reference name="LOG"
- interface="org.osgi.service.log.LogService"
- cardinality="0..1"
- policy="dynamic"
- bind="bindLogService"
- unbind="unbindLogService"
- />
+ <service>
+ <provide interface="eosgi.snackbar.service.vendor.VendorService"/>
+ </service>
+
+ <property value="type" name="hotdog" type="string" />
+
+ <!-- Required services -->
+ <reference name="LOG"
+ interface="org.osgi.service.log.LogService"
+ cardinality="0..1"
+ policy="dynamic"
+ bind="bindLogService"
+ unbind="unbindLogService"
+ />
- <!-- Required services -->
- <reference name="WEINER"
- interface="eosgi.snackbar.service.vendor.VendorService"
- target="(type=weiner)"
- cardinality="1..1"
- policy="dynamic"
- bind="bindWeinerVendorService"
- unbind="unbindWeinerVendorService"
- />
+ <!-- Required services -->
+ <reference name="WEINER"
+ interface="eosgi.snackbar.service.vendor.VendorService"
+ target="(type=weiner)"
+ cardinality="1..1"
+ policy="dynamic"
+ bind="bindWeinerVendorService"
+ unbind="unbindWeinerVendorService"
+ />
- <!-- Required services -->
- <reference name="BUN"
- interface="eosgi.snackbar.service.vendor.VendorService"
- target="(type=bun)"
- cardinality="1..1"
- policy="dynamic"
- bind="bindBunVendorService"
- unbind="unbindBunVendorService"
- />
-
+ <!-- Required services -->
+ <reference name="BUN"
+ interface="eosgi.snackbar.service.vendor.VendorService"
+ target="(type=bun)"
+ cardinality="1..1"
+ policy="dynamic"
+ bind="bindBunVendorService"
+ unbind="unbindBunVendorService"
+ />
</component>
Modified: felix/sandbox/donsez/sosoc/src/site/component.loglistener.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/component.loglistener.xml?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/component.loglistener.xml (original)
+++ felix/sandbox/donsez/sosoc/src/site/component.loglistener.xml Fri Dec 7 15:54:36 2007
@@ -23,69 +23,70 @@
-->
<!-- December 5 2007 -->
<component name="sosoc.loglistener.console">
- <implementation language="javascript"><![CDATA[
+ <implementation language="javascript">
+ <source><![CDATA[
- var logEntryTypes=[ "",
- "[ ERROR ] ",
- "[WARNING] ",
- "[ INFO ] ",
- "[ DEBUG ] "
- ];
+ var logEntryTypes=[ "",
+ "[ ERROR ] ",
+ "[WARNING] ",
+ "[ INFO ] ",
+ "[ DEBUG ] "
+ ];
- // the Java reference to the logReaderService
- var logReaderService;
+ // the Java reference to the logReaderService
+ var logReaderService;
- function logged(entry){
- java.lang.System.out.println(format(entry));
- }
-
- function format(entry){
- var str = logEntryTypes[entry.getLevel()];
- if( entry.getBundle() != undefined) {
- str+= ("bundle:" + entry.getBundle().getBundleId()+" ");
- }
- if (entry.getException() != undefined) {
- str+= ("exception:"+entry.getException().getMessage()+" ");
- }
- str+=entry.getMessage();
-
- return str;
- }
-
- // Binding/unbinding functions
- function bindLogReaderService(svcref,svc){
- logReaderService=svc;
+ function logged(entry){
+ java.lang.System.out.println(format(entry));
+ }
+
+ function format(entry){
+ var str = logEntryTypes[entry.getLevel()];
+ if( entry.getBundle() != undefined) {
+ str+= ("bundle:" + entry.getBundle().getBundleId()+" ");
+ }
+ if (entry.getException() != undefined) {
+ str+= ("exception:"+entry.getException().getMessage()+" ");
}
+ str+=entry.getMessage();
+
+ return str;
+ }
+
+ // Binding/unbinding functions
+ function bindLogReaderService(svcref,svc){
+ logReaderService=svc;
+ }
- function unbindLogReaderService(svcref,svc){
- logReaderService=undefined; // undefined is null in JavaScript
- }
+ function unbindLogReaderService(svcref,svc){
+ logReaderService=undefined; // undefined is null in JavaScript
+ }
+
+ // Lifecycle functions
+ function activate(){
+ logReaderService.addLogListener(this);
+ java.lang.System.out.println("script: call activate() function");
+ }
+
+ function deactivate(){
+ java.lang.System.out.println("script: call deactivate() function");
+ logReaderService.removeLogListener(this);
+ }
- // Lifecycle functions
- function activate(){
- logReaderService.addLogListener(this);
- java.lang.System.out.println("script: call activate() function");
- }
-
- function deactivate(){
- java.lang.System.out.println("script: call deactivate() function");
- logReaderService.removeLogListener(this);
- }
-
- ]]></implementation>
+ ]]></source></implementation>
- <service>
- <provide interface="org.osgi.service.log.LogListener"/>
- </service>
-
- <!-- Required mandatory service -->
- <reference name="LOGREADER"
- interface="org.osgi.service.log.LogReaderService"
- cardinality="1..1"
- policy="dynamic"
- bind="bindLogReaderService"
- unbind="unbindLogReaderService"
- />
+ <service>
+ <provide interface="org.osgi.service.log.LogListener"/>
+ </service>
+
+ <!-- Required mandatory service -->
+ <reference name="LOGREADER"
+ interface="org.osgi.service.log.LogReaderService"
+ cardinality="1..1"
+ policy="dynamic"
+ bind="bindLogReaderService"
+ unbind="unbindLogReaderService"
+ />
</component>
Added: felix/sandbox/donsez/sosoc/src/site/component.mbean.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/component.mbean.xml?rev=602277&view=auto
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/component.mbean.xml (added)
+++ felix/sandbox/donsez/sosoc/src/site/component.mbean.xml Fri Dec 7 15:54:36 2007
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<!-- Component Description used by SOSOC -->
+<!--
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+-->
+<!-- July 17 2005 -->
+
+<component name="sosoc.mbean.simple">
+ <implementation language="javascript"><![CDATA[
+
+ function run(){
+ // do nothing
+ }
+
+ // Lifecycle functions
+ function activate(){
+ // do something
+ java.lang.System.out.println("sosoc.bench.server: call activate() function");
+ }
+
+ function deactivate(){
+ java.lang.System.out.println("sosoc.bench.server: call deactivate() function");
+ // do something
+ }
+
+ ]]></implementation>
+
+ <service>
+ <provide interface="java.lang.Runnable"/>
+ </service>
+
+ <property value="jmx.objectName" name=":" type="string" />
+
+</component>
Propchange: felix/sandbox/donsez/sosoc/src/site/component.mbean.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: felix/sandbox/donsez/sosoc/src/site/component.prototype.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/component.prototype.xml?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/component.prototype.xml (original)
+++ felix/sandbox/donsez/sosoc/src/site/component.prototype.xml Fri Dec 7 15:54:36 2007
@@ -24,7 +24,7 @@
<!-- July 17 2005 -->
<component name="Simple.JavaScript.Component">
- <implementation language="javascript"><![CDATA[
+ <implementation language="javascript"><source><![CDATA[
// this example uses a prototype to build object
function Component(){
@@ -74,19 +74,22 @@
var myComp=new Component();
- ]]></implementation>
+ ]]></source></implementation>
- <provides service="org.ungoverned.osgi.service.shell.Command" />
- <property value="service.pid" name="org.ungoverned.osgi.service.shell.command.hello" type="string" />
- <property value="category" name="command" type="string" />
-
- <!-- Required services -->
- <reference name="HELLO"
- interface="org.apache.felix.sandbox.bundle.hello.HelloService"
- cardinality="1..1"
- policy="dynamic"
- bind="bindHelloService"
- unbind="unbindHelloService"
- />
+ <service>
+ <provide service="org.apache.felix.shell.Command" />
+ <service>
+
+ <property value="service.pid" name="" type="string" />
+ <property value="category" name="command" type="string" />
+
+ <!-- Required services -->
+ <reference name="HELLO"
+ interface="org.apache.felix.sandbox.bundle.hello.HelloService"
+ cardinality="1..1"
+ policy="dynamic"
+ bind="bindHelloService"
+ unbind="unbindHelloService"
+ />
</component>
Modified: felix/sandbox/donsez/sosoc/src/site/component.ruleset.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/component.ruleset.xml?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/component.ruleset.xml (original)
+++ felix/sandbox/donsez/sosoc/src/site/component.ruleset.xml Fri Dec 7 15:54:36 2007
@@ -24,7 +24,7 @@
<!-- July 17 2005 -->
<component name="sosoc.command.echo">
- <implementation language="javascript"><![CDATA[
+ <implementation language="javascript"><source><![CDATA[
// the Java reference to the LogService
var service;
@@ -50,27 +50,27 @@
// do something
}
- ]]></implementation>
+ ]]></source></implementation>
- <!-- Required services -->
- <reference name="LOG"
- interface="org.osgi.service.log.LogService"
- cardinality="0..1"
- policy="dynamic"
- bind="bindLogService"
- unbind="unbindLogService"
- />
+ <!-- Required services -->
+ <reference name="LOG"
+ interface="org.osgi.service.log.LogService"
+ cardinality="0..1"
+ policy="dynamic"
+ bind="bindLogService"
+ unbind="unbindLogService"
+ />
<!--
- <ruleset>
- <rule
- name="rule1"
- condition=""
- ranking=""
- action=""
- topics=""
- synchronous=""
- />
- </ruleset>
+ <ruleset>
+ <rule
+ name="rule1"
+ condition=""
+ ranking=""
+ action=""
+ topics=""
+ synchronous=""
+ />
+ </ruleset>
-->
</component>
Modified: felix/sandbox/donsez/sosoc/src/site/component.runnable.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/component.runnable.xml?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/component.runnable.xml (original)
+++ felix/sandbox/donsez/sosoc/src/site/component.runnable.xml Fri Dec 7 15:54:36 2007
@@ -24,7 +24,9 @@
<!-- July 17 2005 -->
<component name="sosoc.bench.server">
- <implementation language="javascript"><![CDATA[
+ <implementation language="javascript">
+ <attribute name="compile" value="true"/>
+ <source><![CDATA[
function run(){
// do nothing
@@ -41,7 +43,8 @@
// do something
}
- ]]></implementation>
+ ]]></source>
+ </implementation>
<service>
<provide interface="java.lang.Runnable"/>
Modified: felix/sandbox/donsez/sosoc/src/site/component.runnable6.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/component.runnable6.xml?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/component.runnable6.xml (original)
+++ felix/sandbox/donsez/sosoc/src/site/component.runnable6.xml Fri Dec 7 15:54:36 2007
@@ -24,7 +24,9 @@
<!-- July 17 2005 -->
<component name="sosoc.bench.server">
- <implementation language="js"><![CDATA[
+ <implementation language="js">
+ <attribute name="compile" value="true"/>
+ <source><![CDATA[
function run(){
// do nothing
@@ -41,7 +43,8 @@
// do something
}
- ]]></implementation>
+ ]]></source>
+ </implementation>
<service>
<provide interface="java.lang.Runnable"/>
Added: felix/sandbox/donsez/sosoc/src/site/component.runnablejava.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/component.runnablejava.xml?rev=602277&view=auto
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/component.runnablejava.xml (added)
+++ felix/sandbox/donsez/sosoc/src/site/component.runnablejava.xml Fri Dec 7 15:54:36 2007
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<!-- Component Description used by SOSOC -->
+<!--
+ Example of on-the-fly compilation
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+-->
+<!-- December 7 2007 -->
+
+<component name="sosoc.bench.server.java">
+ <implementation language="java">
+ <attribute name="source" value="6.0"/>
+ <attribute name="target" value="6.0"/>
+ <replace token="##package.name##">thiz.is.a.privAte.pacKage</token>
+ <source><![CDATA[
+ package ##package.name##;
+
+ public class RunnableServiceImpl implements java.lang.Runnable
+
+ public void run(){
+ // do nothing
+ }
+
+ // Lifecycle functions
+ public void activate(org.osgi.service.component.ComponentContext componentContext){
+ // do something
+ java.lang.System.out.println("sosoc.bench.server.java: call activate() method");
+ }
+
+ public void deactivate(org.osgi.service.component.ComponentContext componentContext){
+ java.lang.System.out.println("sosoc.bench.server.java: call deactivate() method");
+ // do something
+ }
+
+ ]]><source>
+ </implementation>
+
+ <service>
+ <provide interface="java.lang.Runnable"/>
+ <!-- <provide interface="org.osgi.service.cm.ManagedService"/> -->
+ </service>
+
+ <property value="service.pid" name="sosoc.bench.server.java" type="string" />
+
+</component>
Propchange: felix/sandbox/donsez/sosoc/src/site/component.runnablejava.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: felix/sandbox/donsez/sosoc/src/site/component.servlet.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/component.servlet.xml?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/component.servlet.xml (original)
+++ felix/sandbox/donsez/sosoc/src/site/component.servlet.xml Fri Dec 7 15:54:36 2007
@@ -23,7 +23,8 @@
-->
<!-- December 5 2007 -->
<component name="sosoc.servlet">
- <implementation language="javascript"><![CDATA[
+ <implementation language="javascript">
+ <source><![CDATA[
// the Java reference to the HttpService
var httpService;
@@ -60,23 +61,24 @@
java.lang.System.out.println("sosoc.servlet: call deactivate() function");
}
- ]]></implementation>
+ ]]></source>
+ </implementation>
- <!-- Required mandatory service -->
- <reference name="HTTP"
- interface="org.osgi.service.http.HttpService"
- cardinality="1..1"
- policy="static"
- bind="bindHttpService"
- unbind="unbindHttpService"
- />
-
- <!-- Required optional service -->
- <reference name="LOG"
- interface="org.osgi.service.log.LogService"
- cardinality="0..1"
- policy="dynamic"
- bind="bindLogService"
- unbind="unbindLogService"
- />
+ <!-- Required mandatory service -->
+ <reference name="HTTP"
+ interface="org.osgi.service.http.HttpService"
+ cardinality="1..1"
+ policy="static"
+ bind="bindHttpService"
+ unbind="unbindHttpService"
+ />
+
+ <!-- Required optional service -->
+ <reference name="LOG"
+ interface="org.osgi.service.log.LogService"
+ cardinality="0..1"
+ policy="dynamic"
+ bind="bindLogService"
+ unbind="unbindLogService"
+ />
</component>
Modified: felix/sandbox/donsez/sosoc/src/site/component.thread.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/component.thread.xml?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/component.thread.xml (original)
+++ felix/sandbox/donsez/sosoc/src/site/component.thread.xml Fri Dec 7 15:54:36 2007
@@ -24,9 +24,9 @@
<!-- July 17 2005 -->
<component name="sosoc.thread">
- <implementation language="javascript"
- url="./thread.js"
- />
+ <implementation language="javascript">
+ <source url="./thread.js"/>
+ </implementation>
<!-- Required services -->
<reference name="LOG"
Modified: felix/sandbox/donsez/sosoc/src/site/index.html
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/index.html?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/index.html (original)
+++ felix/sandbox/donsez/sosoc/src/site/index.html Fri Dec 7 15:54:36 2007
@@ -96,8 +96,9 @@
</p>
<p id="gateways">
-<b>Tested R4 gateways</b><br>
+<b>Tested gateways</b><br>
<ul>
+<li>Oscar (done for the very early version)</li>
<li>Felix (done)</li>
<li>Eclipse OSGi (to do)</li>
</ul>
@@ -106,7 +107,7 @@
<p id="todo">
<b>TODO (contributions are welcome)</b><br>
<ul>
-<li>TODO: add append and prepend elements in implementation element : useful to complete import (legacy) scripts</li>
+<li>TODO: use javax.tools.JavaCompiler and may be JavaSourceFromString extends SimpleJavaFileObject to compile on-the-fly Java sources</li>
<li>TODO: add field attribute in reference for direct IoD</li>
<li>TODO: use dynamic import to load scripting engine classes</li>
<li>TODO: org.mozilla.javascript.Context.setErrorReporter(org.mozilla.javascript.ErrorReporter) with XML start line</li>
@@ -121,15 +122,18 @@
</ul>
<ul>
+<li>DONE (06/12/2007): add replace elements to the implementation element</li>
+<li>DONE (06/12/2007): add source and attribute elements to the implementation element : multiple sources are concated and attributes can be passed to the script engine (ie compile=true, source=6.0, ...</li>
<li>DONE (06/12/2007): use JSR223 ("Scripting for the JavaTM Platform 6") for other scripting language : Groovy, PHP, Jython, Jacl, BeanShell, NetRexx, JRuby, JudoScript, ObjectScript ... </li>
-<li>DONE (05/12/2007): rename SCRScript in SOSOC </li>
<li>DONE (05/12/2007): append CDATA to the script located in the entry or url attributes of the implementation element : useful to complete import (legacy) scripts</li>
<li>DONE (05/12/2007): add a "base" mechanism for URL completion: so, scripts file could have a relative URL according to the component XML descriptor file</li>
+<li>DONE (04/12/2007): rename SCRX in SOSOC </li>
+<li>DONE (04/12/2007): mavenize the project </li>
<li>DONE (26/07/2005): defines a service and a command to start and stop scripts (embedded in the component description) from a URL (see <a href="http://people.apache.org/~donsez/dev/osgi/sosoc">http://people.apache.org/~donsez/dev/osgi/sosoc</a></li>
<li>DONE (27/07/2005): provisioning the script outside the descriptor to ease script writing (specialized editor plugin) and off-bundle debugging (thanks to Rick Hall for his remark)</li>
-<li>DONE (27/07/2005): <script language="javascript" res="echocmd.js"/> when the script is provisioned in the bundle jar as a ressource</li>
+<li>DONE (27/07/2005): <script language="javascript" entry="echocmd.js"/> when the script is provisioned in the bundle jar as a ressource</li>
<li>DONE (27/07/2005): <script language="javascript" url="http://www.foo.org/osgi/sb/scripts/echocmd.js"/> when the script is provisioned on a external web site</li>
-<li>DONE (27/07/2005): give a hook on SB metadata in the script scope</li>
+<li>DONE (27/07/2005): give a hook on SOSOC metadata in the script scope</li>
<li>BUG FIXED (27/07/2005): fix this warning <i>--- ScriptComponent:call method execute
RHINO USAGE WARNING: Missed Context.javaToJS() conversion:
Rhino runtime detected object org.apache.felix.sandbox.bundle.hello.impl.HelloServiceImpl@1
Modified: felix/sandbox/donsez/sosoc/src/site/script.txt
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/script.txt?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/script.txt (original)
+++ felix/sandbox/donsez/sosoc/src/site/script.txt Fri Dec 7 15:54:36 2007
@@ -17,7 +17,9 @@
sosoc start component.echocmd.withembeddedscript.xml
echo2 Felix is great !
+help
services -a
+
sosoc list
Modified: felix/sandbox/donsez/sosoc/src/site/template.standalonecomponent.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/sosoc/src/site/template.standalonecomponent.xml?rev=602277&r1=602276&r2=602277&view=diff
==============================================================================
--- felix/sandbox/donsez/sosoc/src/site/template.standalonecomponent.xml (original)
+++ felix/sandbox/donsez/sosoc/src/site/template.standalonecomponent.xml Fri Dec 7 15:54:36 2007
@@ -23,9 +23,11 @@
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-->
<component name="%sosoc.component.name%">
- <implementation language="%sosoc.component.language%" url="%sosoc.component.url%"/>
-
- <!-- No provided service -->
- <!-- No required services -->
+ <implementation language="%sosoc.component.language%">
+ <source url="%sosoc.component.url%"/>
+ </implementation>
+
+ <!-- No provided service -->
+ <!-- No required services -->
</component>