Author: gnodet
Date: Fri Sep 29 09:18:19 2006
New Revision: 451337

URL: http://svn.apache.org/viewvc?view=rev&rev=451337
Log:
SM-613, SM-614: Remove old xbean stuff and parse JBI descriptors using plain DOM

Added:
    
incubator/servicemix/trunk/servicemix-core/src/main/resources/jbi-descriptor.xsd
    
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ComponentTest.java
      - copied, changed from r448980, 
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/DeploymentTest.java
    
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ServiceUnitTest.java
    
incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/deployment/component.xml
      - copied unchanged from r448980, 
incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/deployment/example.xml
    
incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/deployment/serviceUnit.xml
Removed:
    
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/config/
    
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/impl/
    
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/DeploymentTest.java
    
incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/deployment/example.xml
    
incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/deployment/tmp.xml
Modified:
    
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/Main.java
    
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/DescriptorFactory.java
    
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ServiceAssemblyTest.java
    
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/SharedLibraryTest.java
    
incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/deployment/serviceAssembly.xml

Modified: 
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/Main.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/Main.java?view=diff&rev=451337&r1=451336&r2=451337
==============================================================================
--- 
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/Main.java
 (original)
+++ 
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/Main.java
 Fri Sep 29 09:18:19 2006
@@ -20,7 +20,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.servicemix.jbi.config.spring.XBeanProcessor;
 import org.apache.servicemix.jbi.container.SpringJBIContainer;
 import org.springframework.beans.factory.DisposableBean;
 import org.springframework.context.ApplicationContext;
@@ -62,23 +61,8 @@
                 
                 List processors = new ArrayList();
                 processors.add(new ClassLoaderXmlPreprocessor(new 
FileSystemRepository(new File("."))));
-                if (file.equals("-v1")) {
-                    
-                    processors.add(new XBeanProcessor());
-                    if (args.length <= 1) {
-                        System.out.println("Loading Apache ServiceMix 
(compatible 1.x) from servicemix.xml on the CLASSPATH");
-                        context = new 
ClassPathXmlApplicationContext("servicemix.xml", processors);
-                    }
-                    else {
-                        file = args[1];
-                        System.out.println("Loading Apache ServiceMix 
(compatible 1.x) from file: " + file);
-                        context = new FileSystemXmlApplicationContext(file, 
processors);
-                    }
-                }
-                else {
-                    System.out.println("Loading Apache ServiceMix from file: " 
+ file);
-                    context = new FileSystemXmlApplicationContext(file, 
processors);
-                }
+                System.out.println("Loading Apache ServiceMix from file: " + 
file);
+                context = new FileSystemXmlApplicationContext(file, 
processors);
             }
             SpringJBIContainer container = (SpringJBIContainer) 
context.getBean("jbi");
             Object lock = new Object();

Modified: 
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/DescriptorFactory.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/DescriptorFactory.java?view=diff&rev=451337&r1=451336&r2=451337
==============================================================================
--- 
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/DescriptorFactory.java
 (original)
+++ 
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/DescriptorFactory.java
 Fri Sep 29 09:18:19 2006
@@ -16,6 +16,7 @@
  */
 package org.apache.servicemix.jbi.deployment;
 
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -23,21 +24,37 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.servicemix.jbi.config.spring.XBeanProcessor;
+import org.apache.servicemix.jbi.util.DOMUtil;
 import org.apache.servicemix.jbi.util.FileUtil;
-import org.apache.xbean.spring.context.ResourceXmlApplicationContext;
-import org.springframework.core.io.UrlResource;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
 
 /**
  * @version $Revision: 359151 $
  */
 public class DescriptorFactory {
 
+    /**
+     * JAXP attribute value indicating the XSD schema language.
+     */
+    private static final String XSD_SCHEMA_LANGUAGE = 
"http://www.w3.org/2001/XMLSchema";;
+
     public static final String DESCRIPTOR_FILE = "META-INF/jbi.xml";
 
     private static Log log = LogFactory.getLog(DescriptorFactory.class);
@@ -70,19 +87,226 @@
      *            url to the jbi descriptor
      * @return the Descriptor object
      */
-    public static Descriptor buildDescriptor(URL url) {
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+    public static Descriptor buildDescriptor(final URL url) {
         try {
-            
Thread.currentThread().setContextClassLoader(DescriptorFactory.class.getClassLoader());
-            ResourceXmlApplicationContext context = new 
ResourceXmlApplicationContext(
-                            new UrlResource(url), 
-                            Arrays.asList(new Object[] { new XBeanProcessor() 
}));
-            Descriptor descriptor = (Descriptor) context.getBean("jbi");
-            checkDescriptor(descriptor);
-            return descriptor;
-        } finally {
-            Thread.currentThread().setContextClassLoader(cl);
+            // Read descriptor
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            FileUtil.copyInputStream(url.openStream(), baos);
+            // Validate descriptor
+            SchemaFactory schemaFactory = 
SchemaFactory.newInstance(XSD_SCHEMA_LANGUAGE);
+            Schema schema = 
schemaFactory.newSchema(DescriptorFactory.class.getResource("/jbi-descriptor.xsd"));
+            Validator validator = schema.newValidator();
+            validator.setErrorHandler(new ErrorHandler() {
+                public void warning(SAXParseException exception) throws 
SAXException {
+                    log.debug("Validation warning on " + url + ": " + 
exception);
+                }
+                public void error(SAXParseException exception) throws 
SAXException {
+                    log.info("Validation error on " + url + ": " + exception);
+                }
+                public void fatalError(SAXParseException exception) throws 
SAXException {
+                    throw exception;
+                }
+            });
+            validator.validate(new StreamSource(new 
ByteArrayInputStream(baos.toByteArray())));
+            // Parse descriptor
+            DocumentBuilderFactory factory = 
DocumentBuilderFactory.newInstance();
+            factory.setNamespaceAware(true);
+            DocumentBuilder docBuilder = factory.newDocumentBuilder();
+            Document doc = docBuilder.parse(new 
ByteArrayInputStream(baos.toByteArray()));
+            Element jbi = doc.getDocumentElement();
+            Descriptor desc = new Descriptor();
+            desc.setVersion(Double.parseDouble(getAttribute(jbi, "version")));
+            Element child = DOMUtil.getFirstChildElement(jbi);
+            if ("component".equals(child.getLocalName())) {
+                Component component = new Component();
+                component.setType(child.getAttribute("type"));
+                
component.setComponentClassLoaderDelegation(getAttribute(child, 
"component-class-loader-delegation"));
+                
component.setBootstrapClassLoaderDelegation(getAttribute(child, 
"bootstrap-class-loader-delegation"));
+                ArrayList sls = new ArrayList();
+                DocumentFragment ext = null;
+                for (Element e = DOMUtil.getFirstChildElement(child); e != 
null; e = DOMUtil.getNextSiblingElement(e)) {
+                    if ("identification".equals(e.getLocalName())) {
+                        component.setIdentification(readIdentification(e));
+                    } else if 
("component-class-name".equals(e.getLocalName())) {
+                        component.setComponentClassName(getText(e));
+                        component.setDescription(getAttribute(e, 
"description"));
+                    } else if 
("component-class-path".equals(e.getLocalName())) {
+                        ClassPath componentClassPath = new ClassPath();
+                        ArrayList l = new ArrayList();
+                        for (Element e2 = DOMUtil.getFirstChildElement(e); e2 
!= null; e2 = DOMUtil.getNextSiblingElement(e2)) {
+                            if ("path-element".equals(e2.getLocalName())) {
+                                l.add(getText(e2));
+                            }
+                        }
+                        componentClassPath.setPathList(l);
+                        component.setComponentClassPath(componentClassPath);
+                    } else if 
("bootstrap-class-name".equals(e.getLocalName())) {
+                        component.setBootstrapClassName(getText(e));
+                    } else if 
("bootstrap-class-path".equals(e.getLocalName())) {
+                        ClassPath bootstrapClassPath = new ClassPath();
+                        ArrayList l = new ArrayList();
+                        for (Element e2 = DOMUtil.getFirstChildElement(e); e2 
!= null; e2 = DOMUtil.getNextSiblingElement(e2)) {
+                            if ("path-element".equals(e2.getLocalName())) {
+                                l.add(getText(e2));
+                            }
+                        }
+                        bootstrapClassPath.setPathList(l);
+                        component.setBootstrapClassPath(bootstrapClassPath);
+                    } else if ("shared-library".equals(e.getLocalName())) {
+                        SharedLibraryList sl = new SharedLibraryList();
+                        sl.setName(getText(e));
+                        sl.setVersion(getAttribute(e, "version"));
+                        sls.add(sl);
+                    } else {
+                        if (ext == null) {
+                            ext = doc.createDocumentFragment();
+                        }
+                        ext.appendChild(e);
+                    }
+                }
+                component.setSharedLibraries((SharedLibraryList[]) 
sls.toArray(new SharedLibraryList[sls.size()]));
+                if (ext != null) {
+                    InstallationDescriptorExtension descriptorExtension = new 
InstallationDescriptorExtension();
+                    descriptorExtension.setDescriptorExtension(ext);
+                    component.setDescriptorExtension(descriptorExtension);
+                }
+                desc.setComponent(component);
+            } else if ("shared-library".equals(child.getLocalName())) {
+                SharedLibrary sharedLibrary = new SharedLibrary();
+                sharedLibrary.setClassLoaderDelegation(getAttribute(child, 
"class-loader-delegation"));
+                sharedLibrary.setVersion(getAttribute(child, "version"));
+                for (Element e = DOMUtil.getFirstChildElement(child); e != 
null; e = DOMUtil.getNextSiblingElement(e)) {
+                    if ("identification".equals(e.getLocalName())) {
+                        sharedLibrary.setIdentification(readIdentification(e));
+                    } else if 
("shared-library-class-path".equals(e.getLocalName())) {
+                        ClassPath sharedLibraryClassPath = new ClassPath();
+                        ArrayList l = new ArrayList();
+                        for (Element e2 = DOMUtil.getFirstChildElement(e); e2 
!= null; e2 = DOMUtil.getNextSiblingElement(e2)) {
+                            if ("path-element".equals(e2.getLocalName())) {
+                                l.add(getText(e2));
+                            }
+                        }
+                        sharedLibraryClassPath.setPathList(l);
+                        
sharedLibrary.setSharedLibraryClassPath(sharedLibraryClassPath);
+                    }
+                }
+                desc.setSharedLibrary(sharedLibrary);
+            } else if ("service-assembly".equals(child.getLocalName())) {
+                ServiceAssembly serviceAssembly = new ServiceAssembly();
+                ArrayList sus = new ArrayList();
+                for (Element e = DOMUtil.getFirstChildElement(child); e != 
null; e = DOMUtil.getNextSiblingElement(e)) {
+                    if ("identification".equals(e.getLocalName())) {
+                        
serviceAssembly.setIdentification(readIdentification(e));
+                    } else if ("service-unit".equals(e.getLocalName())) {
+                        ServiceUnit su = new ServiceUnit();
+                        for (Element e2 = DOMUtil.getFirstChildElement(e); e2 
!= null; e2 = DOMUtil.getNextSiblingElement(e2)) {
+                            if ("identification".equals(e2.getLocalName())) {
+                                su.setIdentification(readIdentification(e2));
+                            } else if ("target".equals(e2.getLocalName())) {
+                                Target target = new Target();
+                                for (Element e3 = 
DOMUtil.getFirstChildElement(e2); e3 != null; e3 = 
DOMUtil.getNextSiblingElement(e3)) {
+                                    if 
("artifacts-zip".equals(e3.getLocalName())) {
+                                        target.setArtifactsZip(getText(e3));
+                                    } else if 
("component-name".equals(e3.getLocalName())) {
+                                        target.setComponentName(getText(e3));
+                                    }
+                                }
+                                su.setTarget(target);
+                            }
+                        }
+                        sus.add(su);
+                    } else if ("connections".equals(e.getLocalName())) {
+                        Connections connections = new Connections();
+                        ArrayList cns = new ArrayList();
+                        for (Element e2 = DOMUtil.getFirstChildElement(e); e2 
!= null; e2 = DOMUtil.getNextSiblingElement(e2)) {
+                            if ("connection".equals(e2.getLocalName())) {
+                                Connection cn = new Connection();
+                                for (Element e3 = 
DOMUtil.getFirstChildElement(e2); e3 != null; e3 = 
DOMUtil.getNextSiblingElement(e3)) {
+                                    if ("consumer".equals(e3.getLocalName())) {
+                                        Consumer consumer = new Consumer();
+                                        
consumer.setInterfaceName(readAttributeQName(e3, "interface-name"));
+                                        
consumer.setServiceName(readAttributeQName(e3, "service-name"));
+                                        
consumer.setEndpointName(getAttribute(e3, "endpoint-name"));
+                                        cn.setConsumer(consumer);
+                                    } else if 
("provider".equals(e3.getLocalName())) {
+                                        Provider provider = new Provider();
+                                        
provider.setServiceName(readAttributeQName(e3, "service-name"));
+                                        
provider.setEndpointName(getAttribute(e3, "endpoint-name"));
+                                        cn.setProvider(provider);
+                                    }
+                                }
+                                cns.add(cn);
+                            }
+                        }
+                        connections.setConnections(((Connection[]) 
cns.toArray(new Connection[cns.size()])));
+                        serviceAssembly.setConnections(connections);
+                    }
+                }
+                serviceAssembly.setServiceUnits(((ServiceUnit[]) 
sus.toArray(new ServiceUnit[sus.size()])));
+                desc.setServiceAssembly(serviceAssembly);
+            } else if ("services".equals(child.getLocalName())) {
+                Services services = new Services();
+                
services.setBindingComponent(Boolean.parseBoolean(getAttribute(child, 
"binding-component")));
+                ArrayList provides = new ArrayList();
+                ArrayList consumes = new ArrayList();
+                for (Element e = DOMUtil.getFirstChildElement(child); e != 
null; e = DOMUtil.getNextSiblingElement(e)) {
+                    if ("provides".equals(e.getLocalName())) {
+                        Provides p = new Provides();
+                        p.setInterfaceName(readAttributeQName(e, 
"interface-name"));
+                        p.setServiceName(readAttributeQName(e, 
"service-name"));
+                        p.setEndpointName(getAttribute(e, "endpoint-name"));
+                        provides.add(p);
+                    } else if ("consumes".equals(e.getLocalName())) {
+                        Consumes c = new Consumes();
+                        c.setInterfaceName(readAttributeQName(e, 
"interface-name"));
+                        c.setServiceName(readAttributeQName(e, 
"service-name"));
+                        c.setEndpointName(getAttribute(e, "endpoint-name"));
+                        c.setLinkType(getAttribute(e, "link-type"));
+                        consumes.add(c);
+                    }
+                }
+                services.setProvides((Provides[]) provides.toArray(new 
Provides[provides.size()]));
+                services.setConsumes((Consumes[]) consumes.toArray(new 
Consumes[consumes.size()]));
+                desc.setServices(services);
+            }
+            checkDescriptor(desc);
+            return desc;
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
+    private static String getAttribute(Element e, String name) {
+        if (e.hasAttribute(name)) {
+            return e.getAttribute(name);
+        } else {
+            return null;
+        }
+    }
+    
+    private static QName readAttributeQName(Element e, String name) {
+        String attr = getAttribute(e, name);
+        if (attr != null) {
+            return DOMUtil.createQName(e, attr);
+        } else {
+            return null;
+        }
+    }
+    
+    private static String getText(Element e) {
+        return DOMUtil.getElementText(e).trim();
+    }
+    
+    private static Identification readIdentification(Element e) {
+        Identification ident = new Identification();
+        for (Element e2 = DOMUtil.getFirstChildElement(e); e2 != null; e2 = 
DOMUtil.getNextSiblingElement(e2)) {
+            if ("name".equals(e2.getLocalName())) {
+                ident.setName(DOMUtil.getElementText(e2));
+            } else if ("description".equals(e2.getLocalName())) {
+                ident.setDescription(DOMUtil.getElementText(e2));
+            }
         }
+        return ident;
     }
 
     /**

Added: 
incubator/servicemix/trunk/servicemix-core/src/main/resources/jbi-descriptor.xsd
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/resources/jbi-descriptor.xsd?view=auto&rev=451337
==============================================================================
--- 
incubator/servicemix/trunk/servicemix-core/src/main/resources/jbi-descriptor.xsd
 (added)
+++ 
incubator/servicemix/trunk/servicemix-core/src/main/resources/jbi-descriptor.xsd
 Fri Sep 29 09:18:19 2006
@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
elementFormDefault="qualified"
+  targetNamespace="http://java.sun.com/xml/ns/jbi"; 
xmlns:jbi="http://java.sun.com/xml/ns/jbi";>
+  <xs:element name="jbi">
+    <xs:complexType>
+      <xs:choice>
+        <xs:element ref="jbi:component" />
+        <xs:element ref="jbi:shared-library" />
+        <xs:element ref="jbi:service-assembly" />
+        <xs:element ref="jbi:services" />
+      </xs:choice>
+      <xs:attribute name="version" use="required" type="xs:decimal" />
+    </xs:complexType>
+  </xs:element>

+  <xs:element name="component">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="identification" type="jbi:identification" />
+      <xs:element name="component-class-name">
+        <xs:complexType mixed="true">
+          <xs:attribute name="description" />
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="component-class-path" type="jbi:class-path" />
+      <xs:element name="bootstrap-class-name" type="xs:string" />
+      <xs:element name="bootstrap-class-path" type="jbi:class-path" />
+      <xs:element minOccurs="0" maxOccurs="unbounded" name="shared-library">
+        <xs:complexType mixed="true">
+          <xs:attribute name="version" />
+        </xs:complexType>
+      </xs:element>
+      <xs:choice minOccurs="0" maxOccurs="unbounded">
+        <xs:any namespace="##other" processContents="skip" />
+        <xs:any namespace="##local" processContents="skip" />
+      </xs:choice>
+    </xs:sequence>
+    <xs:attribute name="type" use="required">
+      <xs:simpleType>
+        <xs:restriction base="xs:token">
+          <xs:enumeration value="service-engine" />
+          <xs:enumeration value="binding-component" />
+        </xs:restriction>
+      </xs:simpleType>
+    </xs:attribute>
+    <xs:attribute name="component-class-loader-delegation">
+      <xs:simpleType>
+        <xs:restriction base="xs:token">
+          <xs:enumeration value="parent-first" />
+          <xs:enumeration value="self-first" />
+        </xs:restriction>
+      </xs:simpleType>
+    </xs:attribute>
+    <xs:attribute name="bootstrap-class-loader-delegation">
+      <xs:simpleType>
+        <xs:restriction base="xs:token">
+          <xs:enumeration value="parent-first" />
+          <xs:enumeration value="self-first" />
+        </xs:restriction>
+      </xs:simpleType>
+    </xs:attribute>
+  </xs:complexType>

+  </xs:element>

+  <xs:element name="shared-library">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="identification" type="jbi:identification" />
+      <xs:element name="shared-library-class-path" type="jbi:class-path" />
+    </xs:sequence>
+    <xs:attribute name="class-loader-delegation">
+      <xs:simpleType>
+        <xs:restriction base="xs:token">
+          <xs:enumeration value="parent-first" />
+          <xs:enumeration value="self-first" />
+        </xs:restriction>
+      </xs:simpleType>
+    </xs:attribute>
+    <xs:attribute name="version" />
+  </xs:complexType>

+  </xs:element>

+  <xs:element name="service-assembly">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="identification" type="jbi:identification" />
+      <xs:element minOccurs="0" maxOccurs="unbounded" name="service-unit">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="identification" type="jbi:identification" />
+            <xs:element name="target">
+              <xs:complexType>
+                <xs:sequence>
+                  <xs:element name="artifacts-zip" type="xs:string" />
+                  <xs:element name="component-name" type="xs:NCName" />
+                </xs:sequence>
+              </xs:complexType>
+            </xs:element>
+            <xs:choice minOccurs="0" maxOccurs="unbounded">
+              <xs:any namespace="##other" processContents="skip" />
+              <xs:any namespace="##local" processContents="skip" />
+            </xs:choice>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:element minOccurs="0" name="connections">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element minOccurs="0" maxOccurs="unbounded" name="connection">
+              <xs:complexType>
+                <xs:sequence>
+                  <xs:element name="consumer">
+                    <xs:complexType>
+                      <xs:attribute name="interface-name" type="xs:QName" />
+                      <xs:attribute name="service-name" type="xs:QName" />
+                      <xs:attribute name="endpoint-name" />
+                    </xs:complexType>
+                  </xs:element>
+                  <xs:element name="provider">
+                    <xs:complexType>
+                      <xs:attribute name="service-name" use="required" 
type="xs:QName" />
+                      <xs:attribute name="endpoint-name" use="required" />
+                    </xs:complexType>
+                  </xs:element>
+                </xs:sequence>
+              </xs:complexType>
+            </xs:element>
+            <xs:choice minOccurs="0" maxOccurs="unbounded">
+              <xs:any namespace="##other" processContents="skip" />
+              <xs:any namespace="##local" processContents="skip" />
+            </xs:choice>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:choice minOccurs="0" maxOccurs="unbounded">
+        <xs:any namespace="##other" processContents="skip" />
+        <xs:any namespace="##local" processContents="skip" />
+      </xs:choice>
+    </xs:sequence>
+  </xs:complexType>

+  </xs:element>

+  <xs:element name="services">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element minOccurs="0" maxOccurs="unbounded" name="provides">
+        <xs:complexType>
+          <xs:choice minOccurs="0" maxOccurs="unbounded">
+            <xs:any namespace="##other" processContents="skip" />
+            <xs:any namespace="##local" processContents="skip" />
+          </xs:choice>
+          <xs:attribute name="interface-name" use="required" type="xs:QName" />
+          <xs:attribute name="service-name" use="required" type="xs:QName" />
+          <xs:attribute name="endpoint-name" use="required" />
+        </xs:complexType>
+      </xs:element>
+      <xs:element minOccurs="0" maxOccurs="unbounded" name="consumes">
+        <xs:complexType>
+          <xs:choice minOccurs="0" maxOccurs="unbounded">
+            <xs:any namespace="##other" processContents="skip" />
+            <xs:any namespace="##local" processContents="skip" />
+          </xs:choice>
+          <xs:attribute name="interface-name" use="required" type="xs:QName" />
+          <xs:attribute name="service-name" type="xs:QName" />
+          <xs:attribute name="endpoint-name" />
+          <xs:attribute name="link-type">
+            <xs:simpleType>
+              <xs:restriction base="xs:token">
+                <xs:enumeration value="standard" />
+                <xs:enumeration value="hard" />
+                <xs:enumeration value="soft" />
+              </xs:restriction>
+            </xs:simpleType>
+          </xs:attribute>
+        </xs:complexType>
+      </xs:element>
+      <xs:choice minOccurs="0" maxOccurs="unbounded">
+        <xs:any namespace="##other" processContents="skip" />
+        <xs:any namespace="##local" processContents="skip" />
+      </xs:choice>
+    </xs:sequence>
+    <xs:attribute name="binding-component" use="required" type="xs:boolean" />
+  </xs:complexType>

+  </xs:element>
+  <xs:complexType name="identification">

+    <xs:sequence>

+      <xs:element name="name" type="xs:NCName" />

+      <xs:element name="description" type="xs:string" />

+      <xs:choice minOccurs="0" maxOccurs="unbounded">

+        <xs:any namespace="##other" processContents="skip" />

+        <xs:any namespace="##local" processContents="skip" />

+      </xs:choice>

+    </xs:sequence>

+  </xs:complexType>

+  <xs:complexType name="class-path">

+    <xs:sequence>

+      <xs:element maxOccurs="unbounded" name="path-element" type="xs:string" />

+    </xs:sequence>

+  </xs:complexType>

+</xs:schema>


Copied: 
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ComponentTest.java
 (from r448980, 
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/DeploymentTest.java)
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ComponentTest.java?view=diff&rev=451337&p1=incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/DeploymentTest.java&r1=448980&p2=incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ComponentTest.java&r2=451337
==============================================================================
--- 
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/DeploymentTest.java
 (original)
+++ 
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ComponentTest.java
 Fri Sep 29 09:18:19 2006
@@ -16,37 +16,27 @@
  */
 package org.apache.servicemix.jbi.deployment;
 
-import org.apache.servicemix.jbi.config.DebugClassPathXmlApplicationContext;
-import org.apache.servicemix.jbi.config.spring.XBeanProcessor;
-import org.apache.servicemix.jbi.deployment.ClassPath;
-import org.apache.servicemix.jbi.deployment.Component;
-import org.apache.servicemix.jbi.deployment.Descriptor;
-import org.apache.servicemix.jbi.deployment.Identification;
-import org.apache.servicemix.jbi.deployment.InstallationDescriptorExtension;
-import org.apache.servicemix.jbi.deployment.SharedLibraryList;
-import org.apache.servicemix.jbi.jaxp.SourceTransformer;
-import org.springframework.context.support.AbstractXmlApplicationContext;
-import org.w3c.dom.DocumentFragment;
+import java.util.Arrays;
 
 import javax.xml.transform.dom.DOMSource;
 
-import java.util.Arrays;
-
 import junit.framework.TestCase;
 
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.w3c.dom.DocumentFragment;
+
 /**
  * @version $Revision$
  */
-public class DeploymentTest extends TestCase {
+public class ComponentTest extends TestCase {
 
-    protected AbstractXmlApplicationContext context;
     protected SourceTransformer transformer = new SourceTransformer();
 
     public void testParse() throws Exception {
 
         // lets force the JBI container to be constructed first
-        Descriptor root = (Descriptor) context.getBean("jbi");
-        assertNotNull("JBI Container not found in spring!", root);
+        Descriptor root = 
DescriptorFactory.buildDescriptor(getClass().getResource("component.xml"));
+        assertNotNull("Unable to parse descriptor", root);
 
         // component stuff
         Component component = root.getComponent();
@@ -93,15 +83,6 @@
         }
         buffer.append("]");
         return buffer.toString();
-    }
-
-    protected void setUp() throws Exception {
-        context = createBeanFactory();
-    }
-
-    protected AbstractXmlApplicationContext createBeanFactory() throws 
Exception {
-        return new 
DebugClassPathXmlApplicationContext("org/apache/servicemix/jbi/deployment/example.xml",
-                                                       Arrays.asList(new 
Object[] { new XBeanProcessor() }));
     }
 
 }

Modified: 
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ServiceAssemblyTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ServiceAssemblyTest.java?view=diff&rev=451337&r1=451336&r2=451337
==============================================================================
--- 
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ServiceAssemblyTest.java
 (original)
+++ 
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ServiceAssemblyTest.java
 Fri Sep 29 09:18:19 2006
@@ -16,28 +16,20 @@
  */
 package org.apache.servicemix.jbi.deployment;
 
-import org.apache.servicemix.jbi.config.DebugClassPathXmlApplicationContext;
-import org.apache.servicemix.jbi.config.spring.XBeanProcessor;
-import org.apache.servicemix.jbi.deployment.Descriptor;
-import org.apache.servicemix.jbi.deployment.Identification;
-import org.apache.servicemix.jbi.deployment.ServiceAssembly;
-import org.apache.servicemix.jbi.deployment.ServiceUnit;
-import org.springframework.context.support.AbstractXmlApplicationContext;
-
-import java.util.Arrays;
-
 import javax.xml.namespace.QName;
 
+import junit.framework.TestCase;
+
 /**
  * @version $Revision$
  */
-public class ServiceAssemblyTest extends DeploymentTest {
+public class ServiceAssemblyTest extends TestCase {
 
     public void testParse() throws Exception {
 
         // lets force the JBI container to be constructed first
-        Descriptor root = (Descriptor) context.getBean("jbi");
-        assertNotNull("JBI Container not found in spring!", root);
+        Descriptor root = 
DescriptorFactory.buildDescriptor(getClass().getResource("serviceAssembly.xml"));
+        assertNotNull("Unable to parse descriptor", root);
 
         ServiceAssembly serviceAssembly = root.getServiceAssembly();
         assertNotNull("serviceAssembly is null", serviceAssembly);
@@ -65,12 +57,7 @@
         assertNotNull("connections are null", connections);
         assertEquals("connections size", 2, connections.length);
         
-        assertEquals("getConsumer().getServiceName() for 0", new 
QName("http://www.gaiati.com/emee/ns/csi";, "csi-service"), 
connections[0].getConsumer().getServiceName());
-    }
-
-    protected AbstractXmlApplicationContext createBeanFactory() throws 
Exception {
-        return new 
DebugClassPathXmlApplicationContext("org/apache/servicemix/jbi/deployment/serviceAssembly.xml",
-                                                       Arrays.asList(new 
Object[] { new XBeanProcessor() }));
+        assertEquals("getConsumer().getServiceName() for 0", new 
QName("urn:csi", "csi-service"), connections[0].getConsumer().getServiceName());
     }
 
 }

Added: 
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ServiceUnitTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ServiceUnitTest.java?view=auto&rev=451337
==============================================================================
--- 
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ServiceUnitTest.java
 (added)
+++ 
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ServiceUnitTest.java
 Fri Sep 29 09:18:19 2006
@@ -0,0 +1,43 @@
+/*
+ * 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.servicemix.jbi.deployment;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+
+/**
+ * @version $Revision: 426415 $
+ */
+public class ServiceUnitTest extends TestCase {
+
+    protected SourceTransformer transformer = new SourceTransformer();
+
+    public void testParse() throws Exception {
+
+        // lets force the JBI container to be constructed first
+        Descriptor root = 
DescriptorFactory.buildDescriptor(getClass().getResource("serviceUnit.xml"));
+        assertNotNull("Unable to parse descriptor", root);
+
+        Services services = root.getServices();
+        Consumes[] consumes = services.getConsumes();
+        assertNotNull("consumes are null", consumes);
+        assertEquals("consumes size", 1, consumes.length);
+        
+    }
+
+}

Modified: 
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/SharedLibraryTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/SharedLibraryTest.java?view=diff&rev=451337&r1=451336&r2=451337
==============================================================================
--- 
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/SharedLibraryTest.java
 (original)
+++ 
incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/SharedLibraryTest.java
 Fri Sep 29 09:18:19 2006
@@ -16,62 +16,28 @@
  */
 package org.apache.servicemix.jbi.deployment;
 
-import org.apache.servicemix.jbi.config.DebugClassPathXmlApplicationContext;
-import org.apache.servicemix.jbi.config.spring.XBeanProcessor;
-import org.apache.servicemix.jbi.deployment.Descriptor;
-import org.apache.servicemix.jbi.deployment.Identification;
-import org.apache.servicemix.jbi.deployment.SharedLibrary;
-import org.apache.servicemix.jbi.jaxp.SourceTransformer;
-import org.springframework.context.support.AbstractXmlApplicationContext;
-
-import java.util.Arrays;
-
 import junit.framework.TestCase;
 
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+
 /**
  * @version $Revision$
  */
 public class SharedLibraryTest extends TestCase {
 
-    protected AbstractXmlApplicationContext context;
     protected SourceTransformer transformer = new SourceTransformer();
 
     public void testParse() throws Exception {
 
         // lets force the JBI container to be constructed first
-        Descriptor root = (Descriptor) 
context.getBeansOfType(Descriptor.class).values().iterator().next();
-        assertNotNull("JBI Container not found in spring!", root);
+        Descriptor root = 
DescriptorFactory.buildDescriptor(getClass().getResource("SharedLibrary.xml"));
+        assertNotNull("Unable to parse descriptor", root);
 
         SharedLibrary sl = root.getSharedLibrary();
         Identification identification = sl.getIdentification();
         assertEquals("getName", "TestSharedLibrary", identification.getName());
         assertEquals("getDescription", "This is a test shared library.", 
identification.getDescription());
         
-    }
-
-    protected String toString(Object[] objects) {
-        if (objects == null) {
-            return "null Object[]";
-        }
-        StringBuffer buffer = new StringBuffer("[");
-        for (int i = 0; i < objects.length; i++) {
-            Object object = objects[i];
-            if (i > 0) {
-                buffer.append(", ");
-            }
-            buffer.append(object);
-        }
-        buffer.append("]");
-        return buffer.toString();
-    }
-
-    protected void setUp() throws Exception {
-        context = createBeanFactory();
-    }
-
-    protected AbstractXmlApplicationContext createBeanFactory() throws 
Exception {
-        return new 
DebugClassPathXmlApplicationContext("org/apache/servicemix/jbi/deployment/SharedLibrary.xml",
-                                                       Arrays.asList(new 
Object[] { new XBeanProcessor() }));
     }
 
 }

Modified: 
incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/deployment/serviceAssembly.xml
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/deployment/serviceAssembly.xml?view=diff&rev=451337&r1=451336&r2=451337
==============================================================================
--- 
incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/deployment/serviceAssembly.xml
 (original)
+++ 
incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/deployment/serviceAssembly.xml
 Fri Sep 29 09:18:19 2006
@@ -18,7 +18,7 @@
 
 -->
 <jbi version="1" xmlns="http://java.sun.com/xml/ns/jbi";
-        xmlns:csi="http://www.gaiati.com/emee/ns/csi";>
+        xmlns:csi="urn:csi" xmlns:ems="urn:ems">
        <service-assembly>
                <identification>
                        <name>ServiceAssembly_041207153211-0800_saId</name>

Added: 
incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/deployment/serviceUnit.xml
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/deployment/serviceUnit.xml?view=auto&rev=451337
==============================================================================
--- 
incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/deployment/serviceUnit.xml
 (added)
+++ 
incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/deployment/serviceUnit.xml
 Fri Sep 29 09:18:19 2006
@@ -0,0 +1,24 @@
+<?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.

+  

+-->

+<jbi xmlns="http://java.sun.com/xml/ns/jbi"; version="1.0">
+  <services xmlns:b="http://servicemix.apache.org/samples/bridge";>
+    <consumes service-name="b:pipeline"/>

+  </services>
+</jbi>
\ No newline at end of file


Reply via email to