/**

   Copyright 2009 OpenEngSB Division, Vienna University of Technology

   Licensed 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.openengsb.config.jbi;

import java.io.FileInputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;

import org.openengsb.config.jbi.internal.XStreamFactory;
import org.openengsb.config.jbi.types.ComponentType;

import com.thoughtworks.xstream.XStream;

public class ComponentParser {
    public static List<ComponentType> parseComponents(List<URI> descriptors) {
        XStream x = XStreamFactory.createXStream();
        ArrayList<ComponentType> components = new ArrayList<ComponentType>();
        for (URI uri : descriptors) {
                try {
                    Object o = x.fromXML(new FileInputStream(uri.toURL().getPath()));
                    components.add((ComponentType)o);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
        }
        return components;
    }
}

@@ -675,20 +675,16 @@
 java.io.
-File
 InputStr
@@ -692,29 +692,8 @@
 am;%0A
-import java.net.URI;%0A
 impo
@@ -849,16 +849,73 @@
 entType;
+%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;
 %0A%0Aimport
@@ -981,16 +981,97 @@
 arser %7B%0A
+    private static Logger log = LoggerFactory.getLogger(ComponentParser.class);%0A%0A
     publ
@@ -1121,19 +1121,27 @@
 ts(List%3C
-URI
+InputStream
 %3E descri
@@ -1296,15 +1296,21 @@
 or (
-URI uri
+InputStream s
  : d
@@ -1390,50 +1390,9 @@
 XML(
-new FileInputStream(uri.toURL().getPath())
+s
 );%0A 
@@ -1444,16 +1444,47 @@
 ype)o);%0A
+                    s.close();%0A
         
@@ -1539,35 +1539,58 @@
     
-throw new RuntimeException(
+log.error(%22Parsing of component xml file failed%22, 
 e);%0A

load components directly from given input stream