You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2008/09/17 10:45:21 UTC
svn commit: r696199 - in
/felix/sandbox/clement/ipojo-utils/specification-injection: ./ lib/ src/
src/org/ src/org/apache/ src/org/apache/felix/ src/org/apache/felix/ipojo/
src/org/apache/felix/ipojo/composite/
src/org/apache/felix/ipojo/composite/spec...
Author: clement
Date: Wed Sep 17 01:45:19 2008
New Revision: 696199
URL: http://svn.apache.org/viewvc?rev=696199&view=rev
Log:
Commit the specification injection tools allowing to generate the 'specification' field from an XML file. This helps developers creating service specification used in composites.
Added:
felix/sandbox/clement/ipojo-utils/specification-injection/
felix/sandbox/clement/ipojo-utils/specification-injection/README
felix/sandbox/clement/ipojo-utils/specification-injection/build.xml
felix/sandbox/clement/ipojo-utils/specification-injection/lib/
felix/sandbox/clement/ipojo-utils/specification-injection/lib/bnd-0.0.223.jar (with props)
felix/sandbox/clement/ipojo-utils/specification-injection/lib/org.apache.felix.ipojo.metadata-0.9.0-SNAPSHOT.jar (with props)
felix/sandbox/clement/ipojo-utils/specification-injection/lib/xercesImpl-2.8.1.jar (with props)
felix/sandbox/clement/ipojo-utils/specification-injection/specification.injection.bnd
felix/sandbox/clement/ipojo-utils/specification-injection/src/
felix/sandbox/clement/ipojo-utils/specification-injection/src/org/
felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/
felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/felix/
felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/felix/ipojo/
felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/felix/ipojo/composite/
felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/felix/ipojo/composite/specification/
felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/felix/ipojo/composite/specification/injection/
felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/felix/ipojo/composite/specification/injection/SpecificationInjection.java
felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/felix/ipojo/composite/specification/injection/XMLMetadataParser.java
felix/sandbox/clement/ipojo-utils/specification-injection/test/
felix/sandbox/clement/ipojo-utils/specification-injection/test/org/
felix/sandbox/clement/ipojo-utils/specification-injection/test/org/apache/
felix/sandbox/clement/ipojo-utils/specification-injection/test/org/apache/felix/
felix/sandbox/clement/ipojo-utils/specification-injection/test/org/apache/felix/ipojo/
felix/sandbox/clement/ipojo-utils/specification-injection/test/org/apache/felix/ipojo/test/
felix/sandbox/clement/ipojo-utils/specification-injection/test/org/apache/felix/ipojo/test/Foo.java
felix/sandbox/clement/ipojo-utils/specification-injection/test/spec.xml
Added: felix/sandbox/clement/ipojo-utils/specification-injection/README
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/specification-injection/README?rev=696199&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/specification-injection/README (added)
+++ felix/sandbox/clement/ipojo-utils/specification-injection/README Wed Sep 17 01:45:19 2008
@@ -0,0 +1,25 @@
+Specification-Injection
+
+This tools is a very simple tools to inject a 'specification' field in java interface.
+This field is used by iPOJO to describe service specification and more precisely
+specification-level service dependencies.The syntax used to describe those specifications
+is a little complex (to improve parsing time at runtime). So this tools aims to provide
+a way to describe those specifications in an XML file that will be translate and injected
+in the java file.
+
+This tools is quite simple to use:
+java -jar specification.injection.jar $PATH_TO_THE_JAVA_INTERFACE $PATH_TO_THE_XML_FILE
+
+such as:
+java -jar specification.injection test/org/apache/felix/ipojo/test/Foo.java test/spec.xml
+
+where Foo.java is a java interface, and spec.xml is an xml file describing service dependencies such as:
+<specification>
+ <requires specification="org.apache.felix.ipojo.test.composite.service.Toto"
+ optional="true" aggregate="true" type="service"
+ />
+ </specification>
+
+TODO List:
+- do not reinject an already injected field
+- provide a dump mode just dumping the field declaration
\ No newline at end of file
Added: felix/sandbox/clement/ipojo-utils/specification-injection/build.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/specification-injection/build.xml?rev=696199&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/specification-injection/build.xml (added)
+++ felix/sandbox/clement/ipojo-utils/specification-injection/build.xml Wed Sep 17 01:45:19 2008
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+
+<project name="specification.injection" default="package" basedir=".">
+
+ <property name="src.dir" value="src"/>
+ <property name="build.dir" value="output/classes"/>
+ <property name="output.dir" value="output"/>
+ <property name="lib.dir" value="lib"/>
+
+ <taskdef resource="aQute/bnd/ant/taskdef.properties"
+ classpath="lib/bnd-0.0.223.jar"/>
+
+
+
+ <target name="clean">
+ <delete dir="${build.dir}"/>
+ <delete dir="${output.dir}"/>
+ </target>
+
+ <target name="compile" depends="clean">
+ <mkdir dir="${output.dir}"/>
+ <mkdir dir="${build.dir}"/>
+
+ <javac srcdir="${src.dir}"
+ destdir="${build.dir}"
+ debug="on"
+ >
+ <classpath>
+ <filelist>
+ <file name="${lib.dir}/org.apache.felix.ipojo.metadata-0.9.0-SNAPSHOT.jar"/>
+ </filelist>
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="package" depends="compile">
+ <bnd
+ classpath="${build.dir}"
+ failok="false"
+ exceptions="true"
+ files="${ant.project.name}.bnd"
+ output="${output.dir}"/>
+ </target>
+
+</project>
Added: felix/sandbox/clement/ipojo-utils/specification-injection/lib/bnd-0.0.223.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/specification-injection/lib/bnd-0.0.223.jar?rev=696199&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/clement/ipojo-utils/specification-injection/lib/bnd-0.0.223.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: felix/sandbox/clement/ipojo-utils/specification-injection/lib/org.apache.felix.ipojo.metadata-0.9.0-SNAPSHOT.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/specification-injection/lib/org.apache.felix.ipojo.metadata-0.9.0-SNAPSHOT.jar?rev=696199&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/clement/ipojo-utils/specification-injection/lib/org.apache.felix.ipojo.metadata-0.9.0-SNAPSHOT.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: felix/sandbox/clement/ipojo-utils/specification-injection/lib/xercesImpl-2.8.1.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/specification-injection/lib/xercesImpl-2.8.1.jar?rev=696199&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/clement/ipojo-utils/specification-injection/lib/xercesImpl-2.8.1.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: felix/sandbox/clement/ipojo-utils/specification-injection/specification.injection.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/specification-injection/specification.injection.bnd?rev=696199&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/specification-injection/specification.injection.bnd (added)
+++ felix/sandbox/clement/ipojo-utils/specification-injection/specification.injection.bnd Wed Sep 17 01:45:19 2008
@@ -0,0 +1,3 @@
+Private-Package:org.apache.felix.ipojo.composite.specification.injection
+Include-Resource: @lib/xercesImpl-2.8.1.jar, @lib/org.apache.felix.ipojo.metadata-0.9.0-SNAPSHOT.jar
+Main-Class: org.apache.felix.ipojo.composite.specification.injection.SpecificationInjection
Added: felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/felix/ipojo/composite/specification/injection/SpecificationInjection.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/felix/ipojo/composite/specification/injection/SpecificationInjection.java?rev=696199&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/felix/ipojo/composite/specification/injection/SpecificationInjection.java (added)
+++ felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/felix/ipojo/composite/specification/injection/SpecificationInjection.java Wed Sep 17 01:45:19 2008
@@ -0,0 +1,200 @@
+/*
+ * 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.ipojo.composite.specification.injection;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.felix.ipojo.metadata.Attribute;
+import org.apache.felix.ipojo.metadata.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+
+public class SpecificationInjection {
+
+
+ public static void inject(File java, File xml) throws IOException {
+
+ String spec = parseSpecification(xml);
+ System.out.println("Inject : ");
+ System.out.println(spec);
+ StringBuffer sb = computeNewClass(java, spec);
+ FileWriter fw = new FileWriter(java);
+ fw.write(sb.toString());
+ fw.close();
+
+ }
+
+ private static StringBuffer computeNewClass(File java, String spec) throws IOException {
+ FileReader reader = new FileReader(java);
+ BufferedReader br = new BufferedReader(reader);
+ StringBuffer sb = new StringBuffer();
+ char c;
+ boolean noinjected = true;
+ while((c = (char) br.read()) != (char) -1) {
+ sb.append(c);
+ if (c == '{' && noinjected) {
+ sb.append('\n');
+ sb.append('\t');
+ sb.append(spec);
+ sb.append('\n');
+ noinjected = false;
+ }
+ }
+
+ br.close();
+ return sb;
+ }
+
+ private static String parseSpecification(File xml) {
+ URL url = null;
+ Element metadata = null;
+ try {
+ url = xml.toURL();
+ if (url == null) {
+ System.err.println("Cannot find the metadata file : " + xml.getAbsolutePath());
+ return "";
+ }
+
+ InputStream stream = url.openStream();
+ XMLReader parser = (XMLReader) Class.forName("org.apache.xerces.parsers.SAXParser").newInstance();
+ XMLMetadataParser handler = new XMLMetadataParser();
+ parser.setContentHandler(handler);
+ parser.setFeature("http://xml.org/sax/features/validation",
+ true);
+ parser.setFeature("http://apache.org/xml/features/validation/schema",
+ true);
+
+ parser.setErrorHandler(handler);
+
+ InputSource is = new InputSource(stream);
+ parser.parse(is);
+ metadata = handler.getMetadata();
+ stream.close();
+
+ } catch (MalformedURLException e) {
+ error("Malformed Metadata URL for " + xml.getAbsolutePath());
+ return null;
+ } catch (IOException e) {
+ error("Cannot open the file : " + xml.getAbsolutePath());
+ return null;
+ } catch (SAXParseException e) {
+ error("Error during metadata parsing at line " + e.getLineNumber() + " : " + e.getMessage());
+ return null;
+ } catch (SAXException e) {
+ error("Parsing Error when parsing (Sax Error) the XML file " + xml.getAbsolutePath() + " : " + e.getMessage());
+ return null;
+ } catch (InstantiationException e) {
+ error("Cannot instantiate the SAX parser for the XML file " + xml.getAbsolutePath() + " : " + e.getMessage());
+ return null;
+ } catch (IllegalAccessException e) {
+ error("Cannot instantiate the SAX parser (IllegalAccess) for the XML file " + xml.getAbsolutePath() + " : " + e.getMessage());
+ return null;
+ } catch (ClassNotFoundException e) {
+ error("Cannot load the Sax Parser : " + e.getMessage());
+ return null;
+ }
+
+ // Element was parsed.
+ return "public static String specification = \"" + computeSpecification(metadata, "") +"\";";
+ }
+
+ private static void error(String message) {
+ throw new RuntimeException(message);
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ if (args.length != 2) {
+ System.out.println("Usage SpecificationInjection $JAVA_FILE $XML_FILE");
+ return;
+ }
+ String java = args[0];
+ String xml = args[1];
+
+ System.out.println("Java File : " + java);
+ System.out.println("XML File : " + xml);
+
+ File javaFile = new File(java);
+ File xmlFile = new File(xml);
+
+ if (! javaFile.exists()) {
+ System.out.println("The Java file does not exist : " + javaFile.getAbsolutePath());
+ return;
+ }
+
+ if (! xmlFile.exists()) {
+ System.out.println("The XML file does not exist : " + xmlFile.getAbsolutePath());
+ return;
+ }
+
+ try {
+ inject(javaFile, xmlFile);
+ } catch (IOException e) {
+ System.err.println("An error occurs during injection : " + e.getMessage());
+ return;
+ }
+
+
+ System.out.println("Done");
+ }
+
+ /**
+ * Generate specification metadata.
+ * @param element : actual element.
+ * @param actual : actual manipulation metadata.
+ * @return : the String form of the given element.
+ */
+ private static String computeSpecification(Element element, String actual) {
+ String result = "";
+ if (element.getNameSpace() == null) {
+ result = actual + element.getName() + " { ";
+ } else {
+ result = actual + element.getNameSpace() + ":" + element.getName() + " { ";
+ }
+
+ Attribute[] atts = element.getAttributes();
+ for (int i = 0; i < atts.length; i++) {
+ Attribute current = (Attribute) atts[i];
+ if (current.getNameSpace() == null) {
+ result = result + "$" + current.getName() + "=\\\"" + current.getValue() + "\\\" ";
+ } else {
+ result = result + "$" + current.getNameSpace() + ":" + current.getName() + "=\\\"" + current.getValue() + "\\\" ";
+ }
+ }
+
+ Element[] elems = element.getElements();
+ for (int i = 0; i < elems.length; i++) {
+ result = computeSpecification(elems[i], result);
+ }
+
+ return result + "}";
+ }
+
+}
Added: felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/felix/ipojo/composite/specification/injection/XMLMetadataParser.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/felix/ipojo/composite/specification/injection/XMLMetadataParser.java?rev=696199&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/felix/ipojo/composite/specification/injection/XMLMetadataParser.java (added)
+++ felix/sandbox/clement/ipojo-utils/specification-injection/src/org/apache/felix/ipojo/composite/specification/injection/XMLMetadataParser.java Wed Sep 17 01:45:19 2008
@@ -0,0 +1,269 @@
+/*
+ * 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.ipojo.composite.specification.injection;
+
+import org.apache.felix.ipojo.metadata.Attribute;
+import org.apache.felix.ipojo.metadata.Element;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * XML Metadata parser.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class XMLMetadataParser implements ContentHandler, ErrorHandler {
+
+ /**
+ * Element of the metadata.
+ */
+ private Element[] m_elements = new Element[0];
+
+ /**
+ * Get parsed metadata.
+ * The document must be parsed before calling this method.
+ * @return : all the metadata.
+ * @throws ParseException : occurs if an error occurs during the parsing.
+ */
+ public Element getMetadata() {
+ return m_elements[0];
+ }
+
+
+ /**
+ * Characters.
+ * @param ch : character
+ * @param start : start
+ * @param length : length
+ * @throws SAXException : can never occurs.
+ * @see org.xml.sax.ContentHandler#characters(char[], int, int)
+ */
+ public void characters(char[] ch, int start, int length) throws SAXException {
+ // NOTHING TO DO
+
+ }
+
+
+ /**
+ * End the document.
+ * @throws SAXException : can never occrus.
+ * @see org.xml.sax.ContentHandler#endDocument()
+ */
+ public void endDocument() throws SAXException {
+ }
+
+
+ /**
+ * End of an element.
+ * @param namespaceURI : element namespace
+ * @param localName : local name
+ * @param qName : qualified name
+ * @throws SAXException : occurs when the element is malformed
+ * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
+ // Get the last element of the list
+ Element lastElement = removeLastElement();
+
+ // The name is consistent
+ // Add this element last element with if it is not the root
+ if (m_elements.length != 0) {
+ Element newQueue = m_elements[m_elements.length - 1];
+ newQueue.addElement(lastElement);
+ } else {
+ // It is the last element
+ addElement(lastElement);
+ }
+
+ }
+
+ /**
+ * End prefix mapping.
+ * @param prefix : ended prefix
+ * @throws SAXException : can never occurs.
+ * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
+ */
+ public void endPrefixMapping(String prefix) throws SAXException {
+ // NOTHING TO DO
+ }
+
+
+ /**
+ * Ignore whitespace.
+ * @param ch : character
+ * @param start : start
+ * @param length : length
+ * @throws SAXException : can never occurs.
+ * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
+ */
+ public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
+ // NOTHING TO DO
+ }
+
+ /**
+ * Process an instruction.
+ * @param target : target
+ * @param data : data
+ * @throws SAXException : can never occurs.
+ * @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String)
+ */
+ public void processingInstruction(String target, String data) throws SAXException {
+ // DO NOTHING
+ }
+
+ /**
+ * Set Document locator.
+ * @param locator : new locator.
+ * @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator)
+ */
+ public void setDocumentLocator(Locator locator) {
+ // NOTHING TO DO
+
+ }
+
+ /**
+ * Skipped entity.
+ * @param name : name.
+ * @throws SAXException : can never occurs.
+ * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
+ */
+ public void skippedEntity(String name) throws SAXException {
+ // NOTHING TO DO
+
+ }
+
+ /**
+ * Start a document.
+ * @throws SAXException : can never occurs.
+ * @see org.xml.sax.ContentHandler#startDocument()
+ */
+ public void startDocument() throws SAXException {
+ }
+
+
+ /**
+ * Start an element.
+ * @param namespaceURI : element namespace.
+ * @param localName : local element.
+ * @param qName : qualified name.
+ * @param atts : attribute
+ * @throws SAXException : occurs if the element cannot be parsed correctly.
+ * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
+ */
+ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
+ String namespace = namespaceURI;
+ if (namespaceURI != null
+ && (namespaceURI.equalsIgnoreCase("org.apache.felix.ipojo") || namespaceURI.equalsIgnoreCase("org.apache.felix.ipojo.composite"))) {
+ namespace = null; // Remove the 'org.apache.felix.ipojo' namespace
+ }
+
+ Element elem = new Element(localName, namespace);
+ for (int i = 0; i < atts.getLength(); i++) {
+ String name = (String) atts.getLocalName(i);
+ String ns = (String) atts.getURI(i);
+ String value = (String) atts.getValue(i);
+ Attribute att = new Attribute(name, ns, value);
+ elem.addAttribute(att);
+ }
+
+ addElement(elem);
+
+ }
+
+ /**
+ * Start a prefix mapping.
+ * @param prefix : prefix.
+ * @param uri : uri.
+ * @throws SAXException : can never occurs.
+ * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
+ */
+ public void startPrefixMapping(String prefix, String uri) throws SAXException {
+ // NOTHING TO DO
+
+ }
+
+ /**
+ * Add an element.
+ * @param elem : the element to add
+ */
+ private void addElement(Element elem) {
+ for (int i = 0; (m_elements != null) && (i < m_elements.length); i++) {
+ if (m_elements[i] == elem) {
+ return;
+ }
+ }
+
+ if (m_elements != null) {
+ Element[] newElementsList = new Element[m_elements.length + 1];
+ System.arraycopy(m_elements, 0, newElementsList, 0, m_elements.length);
+ newElementsList[m_elements.length] = elem;
+ m_elements = newElementsList;
+ } else {
+ m_elements = new Element[] { elem };
+ }
+ }
+
+ /**
+ * Remove an element.
+ * @return : the removed element.
+ */
+ private Element removeLastElement() {
+ int idx = -1;
+ idx = m_elements.length - 1;
+ Element last = m_elements[idx];
+ if (idx >= 0) {
+ if ((m_elements.length - 1) == 0) {
+ // It is the last element of the list;
+ m_elements = new Element[0];
+ } else {
+ // Remove the last element of the list :
+ Element[] newElementsList = new Element[m_elements.length - 1];
+ System.arraycopy(m_elements, 0, newElementsList, 0, idx);
+ m_elements = newElementsList;
+ }
+ }
+ return last;
+ }
+
+
+ public void error(SAXParseException saxparseexception) throws SAXException {
+ if (saxparseexception.getMessage().contains("cvc-elt.1")) {
+ return; // Do not throw an exception when no schema defined.
+ }
+ throw saxparseexception;
+ }
+
+
+ public void fatalError(SAXParseException saxparseexception)
+ throws SAXException {
+ System.err.println("Fatal error during XML-Schema parsing : " + saxparseexception);
+ throw saxparseexception;
+ }
+
+
+ public void warning(SAXParseException saxparseexception)
+ throws SAXException {
+ System.err.println("Warning : an error was detected in the metadata file : " + saxparseexception);
+
+ }
+}
Added: felix/sandbox/clement/ipojo-utils/specification-injection/test/org/apache/felix/ipojo/test/Foo.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/specification-injection/test/org/apache/felix/ipojo/test/Foo.java?rev=696199&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/specification-injection/test/org/apache/felix/ipojo/test/Foo.java (added)
+++ felix/sandbox/clement/ipojo-utils/specification-injection/test/org/apache/felix/ipojo/test/Foo.java Wed Sep 17 01:45:19 2008
@@ -0,0 +1,9 @@
+package org.apache.felix.ipojo.test;
+
+
+public interface Foo {
+ public static String specification = "specification { foo { }requires { $optional=\"true\" $type=\"service\" $aggregate=\"true\" $specification=\"org.apache.felix.ipojo.test.composite.service.Toto\" }}";
+
+ public void doSomething();
+ public String sayHello();
+}
\ No newline at end of file
Added: felix/sandbox/clement/ipojo-utils/specification-injection/test/spec.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/specification-injection/test/spec.xml?rev=696199&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/specification-injection/test/spec.xml (added)
+++ felix/sandbox/clement/ipojo-utils/specification-injection/test/spec.xml Wed Sep 17 01:45:19 2008
@@ -0,0 +1,6 @@
+ <specification>
+ <requires specification="org.apache.felix.ipojo.test.composite.service.Toto"
+ optional="true" aggregate="true" type="service"
+ />
+ <foo/>
+ </specification>
\ No newline at end of file