tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lrese...@apache.org
Subject svn commit: r557262 - in /incubator/tuscany/sandbox/amita/das: ./ api/src/main/java/org/apache/tuscany/das/ api/src/main/java/org/apache/tuscany/das/service/ api/src/main/resources/ xquery/src/main/java/org/apache/tuscany/das/xquery/impl/ xquery/src/te...
Date Wed, 18 Jul 2007 14:04:44 GMT
Author: lresende
Date: Wed Jul 18 07:04:42 2007
New Revision: 557262

URL: http://svn.apache.org/viewvc?view=rev&rev=557262
Log:
Applying Amita's patch for TUSCANY-1431

Modified:
    incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/Command.java
    incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/ConfigHelper.java
    incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/DAS.java
    incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/DASFactory.java
    incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/service/ServiceLoader.java
    incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/service/ServiceProvider.java
    incubator/tuscany/sandbox/amita/das/api/src/main/resources/config.xsd
    incubator/tuscany/sandbox/amita/das/pom.xml
    incubator/tuscany/sandbox/amita/das/xquery/src/main/java/org/apache/tuscany/das/xquery/impl/XQueryDASFactoryImpl.java
    incubator/tuscany/sandbox/amita/das/xquery/src/test/java/org/apache/tuscany/das/xquery/XQueryDASFactoryTestCase.java

Modified: incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/Command.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/Command.java?view=diff&rev=557262&r1=557261&r2=557262
==============================================================================
--- incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/Command.java
(original)
+++ incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/Command.java
Wed Jul 18 07:04:42 2007
@@ -59,10 +59,11 @@
     /**
      * Returns the value of the database-generated key. This method is specific 
      * to an "insert" command and will be valid only after the command has
-     * been executed.
+     * been executed. This methos is only relevant when database is data source.
      * 
      * @return the generated key
      */
     int getGeneratedKey();
 
+    public void setDataSourceConnection(DataSourceConnection con);
 }

Modified: incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/ConfigHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/ConfigHelper.java?view=diff&rev=557262&r1=557261&r2=557262
==============================================================================
--- incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/ConfigHelper.java
(original)
+++ incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/ConfigHelper.java
Wed Jul 18 07:04:42 2007
@@ -1,54 +0,0 @@
-/*
- * 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.tuscany.das;
-
-
-import org.apache.tuscany.das.config.Config;
-import org.apache.tuscany.das.config.ConfigFactory;
-
-/**
- * A ConfigHelper is used as an aid in programmatic construction of Config instances.
- * Manual contrution fo COnfig is an alternative to providing needed configuration
- * information in an XML file
- * 
- */
-public class ConfigHelper {
-
-    private Config config;
-
-    //private MappingWrapper configWrapper;
-
-    private ConfigFactory factory = ConfigFactory.INSTANCE;
-
-    public ConfigHelper() {
-        config = factory.createConfig();
-        //configWrapper = new MappingWrapper(config);
-    }
-
-    public ConfigHelper(Config config) {
-        this.config = config;
-        //configWrapper = new MappingWrapper(config);
-    }
-
-
-    public Config getConfig() {
-        return config;
-    }
-
-}

Modified: incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/DAS.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/DAS.java?view=diff&rev=557262&r1=557261&r2=557262
==============================================================================
--- incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/DAS.java
(original)
+++ incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/DAS.java
Wed Jul 18 07:04:42 2007
@@ -18,8 +18,6 @@
  */
 package org.apache.tuscany.das;
 
-//import org.apache.tuscany.das.rdb.impl.DASFactoryImpl;
-
 import commonj.sdo.DataObject;
 
 /**
@@ -28,9 +26,8 @@
  * 
  */
 public interface DAS {
-
-    //DASFactory FACTORY = new DASFactoryImpl();
-    
+	//hook to specify - e.g. say for XQuery DAS - are we using Saxon/DB2 Express/...
+	public void setImplementationFactory(ImplementationFactory implFactory);
 
     /**
      * The change history is scanned and modifications to the graph of data objects are flushed
to the database.
@@ -57,12 +54,12 @@
     void releaseResources();
 
     /**
-     * Creates a Command based on the provided SQL statement
+     * Creates a Command based on the provided Query statement
      * 
-     * @param sql
-     *            The SQL statement
+     * @param queryStr
+     *            The Query statement
      * @return returns a Command instance
      */
-    Command createCommand(String sql);
+    Command createCommand(String queryStr);
 
 }

Modified: incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/DASFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/DASFactory.java?view=diff&rev=557262&r1=557261&r2=557262
==============================================================================
--- incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/DASFactory.java
(original)
+++ incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/DASFactory.java
Wed Jul 18 07:04:42 2007
@@ -22,7 +22,7 @@
 import java.sql.Connection;
 import java.util.Iterator;
 
-import org.apache.tuscany.das.config.Config;
+//import org.apache.tuscany.das.config.Config;
 
 import sun.misc.Service;
 
@@ -83,6 +83,8 @@
      * @param connection
      * @return
      */
+    //TODO this should not be directly used, instead createDAS(InputStream configStream,
DataSourceConnection connection)
+    //should be used
     public abstract DAS createDAS(InputStream configStream, Connection connection);
     
     /**
@@ -92,7 +94,8 @@
      *            A DAS config object
      * @return returns a DAS instance
      */
-    public abstract DAS createDAS(Config config);
+     //TODO why to have Config here? Let it be only in Impls
+    //public abstract DAS createDAS(Config config);
 
     /**
      * Creates a DAS based on the provided config and connection
@@ -100,15 +103,32 @@
      * @param connection
      * @return
      */
-    public abstract DAS createDAS(Config config, Connection connection);
+    //TODO this should not be directly used, instead createDAS(Object config, DataSourceConnection
connection)
+    //should be used
+    //public abstract DAS createDAS(Config config, Connection connection);
 
     /**
      * Creates a DAS based on the provided connection
      * @param connection
      * @return
      */
-    public abstract DAS createDAS(Connection connection);
+    //TODO this should not be directly used, instead createDAS(DataSourceConnection connection)
+    //should be used
+    //public abstract DAS createDAS(Connection connection);
     
+    /**
+     * Connection needs to be generic and not only tied to database connection
+     * as in RDB-DAS, thus introduced DataSourceConnection and used here
+     */
+    public abstract DAS createDAS(DataSourceConnection connection);
+    
+    public abstract DAS createDAS(Object config, DataSourceConnection connection);
+    
+    public abstract DAS createDAS(InputStream configStream, DataSourceConnection connection);
 
+    public abstract DAS createDAS(Object config);
+    
 }
+
+
 

Modified: incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/service/ServiceLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/service/ServiceLoader.java?view=diff&rev=557262&r1=557261&r2=557262
==============================================================================
--- incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/service/ServiceLoader.java
(original)
+++ incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/service/ServiceLoader.java
Wed Jul 18 07:04:42 2007
@@ -20,6 +20,8 @@
 package org.apache.tuscany.das.service;
 
 import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -29,13 +31,15 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.log4j.*;
 /**
  * This class loads services present in the class path.
  */
 public class ServiceLoader {
 
      private static Map providerMap = new java.util.Hashtable();
-
+     static Logger log = Logger.getLogger("ServiceLoader.class");
+     
      public static synchronized Iterator providers(Class cls) {
          ClassLoader cl = cls.getClassLoader();
          // null if loaded by bootstrap class loader
@@ -44,67 +48,45 @@
          }
          String serviceFile = "META-INF/services/" + cls.getName();
 
-         // log.debug("File: " + serviceFile);
+          log.debug("File: " + serviceFile);
 
          List lst = (List)providerMap.get(serviceFile);
          if (lst != null) {
+        	 log.debug("file in map returning ");
              return lst.iterator();
          }
 
          lst = new java.util.Vector();
          providerMap.put(serviceFile, lst);
 
-         Enumeration e;
+         //Enumeration e=null;
+         FileInputStream fis=null;
+         InputStream is = null;
          try {
-             e = cl.getResources(serviceFile);
-         } catch (IOException ioe) {
-             return lst.iterator();
+        	 log.debug("getting resource");
+        	 is = cl.getResourceAsStream(serviceFile);
+        	 log.debug("is class "+is.getClass().getName());
+         }catch(Exception ex){
+        	 ex.printStackTrace();
+        	 log.debug("other exception");
          }
 
-         while (e.hasMoreElements()) {
-             try {
-                 java.net.URL u = (java.net.URL)e.nextElement();
-                 //log.debug("URL: " + u);
-
-                 InputStream is = u.openStream();
-                 Reader r = new InputStreamReader(is, "UTF-8");
-                 BufferedReader br = new BufferedReader(r);
-
-                 String line = br.readLine();
-                 while (line != null) {
-                     try {
-                         // First strip any comment...
-                         int idx = line.indexOf('#');
-                         if (idx != -1) {
-                             line = line.substring(0, idx);
-                         }
-
-                         // Trim whitespace.
-                         line = line.trim();
-
-                         // If nothing left then loop around...
-                         if (line.length() == 0) {
-                             line = br.readLine();
-                             continue;
-                         }
-                         // log.debug("Line: " + line);
-
-                         // Try and load the class
-                         // Object obj = cl.loadClass(line).newInstance();
-                         // stick it into our vector...
-                         lst.add(line);
-                     } catch (Exception ex) {
-                         // Just try the next line
-                     }
-
-                     line = br.readLine();
-                 }
-             } catch (Exception ex) {
-                 // Just try the next file...
-             }
-
+         log.debug("am here");
+         
+         if(is != null)
+        	 log.debug("found resource");
+         else
+        	 log.debug("not found resource");
+         
+         try {
+        	 byte[] byt=new byte[is.available()];
+        	 is.read(byt);
+        	 String line = new String(byt);
+        	 log.debug("Line: " + line);
+        	 lst.add(line);
+         }catch(Exception e){
+        	 e.printStackTrace();
          }
          return lst.iterator();
      }
-
  }

Modified: incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/service/ServiceProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/service/ServiceProvider.java?view=diff&rev=557262&r1=557261&r2=557262
==============================================================================
--- incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/service/ServiceProvider.java
(original)
+++ incubator/tuscany/sandbox/amita/das/api/src/main/java/org/apache/tuscany/das/service/ServiceProvider.java
Wed Jul 18 07:04:42 2007
@@ -28,22 +28,6 @@
 
 
 public class ServiceProvider {
-    /**
-     * The name of the property used to identify the LogFactory implementation class name.
-     */
-    public static final String FACTORY_PROPERTY = "org.apache.tuscany.das.DASFactory";
-    
-    /**
-     * 'Service Provider' specification ( http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html
)
-     */
-    protected static final String SERVICE_ID = "META-INF/services/org.apache.tuscany.das.DASFactory";
-    
-    
-    private static final String FACTORY_RESOURCE = "org.apache.tuscany.das.das";
-    
-    
-    private Map<String, String> registry = new HashMap<String, String>();
-
     private static final ServiceProvider instance = new ServiceProvider();
     
     protected ServiceProvider() {
@@ -54,9 +38,24 @@
         return instance;
     }
     
-       
+    public static DASFactory getDASFactory(){
+    	try{
+            Iterator ps = ServiceLoader.providers(DASFactory.class);
+            while(ps.hasNext()){
+            	String className = (String) ps.next();
+                DASFactory factory = (DASFactory) Class.forName(className).newInstance();
+                System.out.println( factory.getClass().getName() );
+                return factory;
+            }    		
+    	}catch(Exception e){
+    		e.printStackTrace();
+    		return null;	
+    	}
+    	return null;
+    }
+
     public static void Something(){
-//      Second, try to find a service by using the JDK1.3 jar
+    	//Second, try to find a service by using the JDK1.3 jar
         // discovery mechanism. This will allow users to plug a logger
         // by just placing it in the lib/ directory of the webapp ( or in
         // CLASSPATH or equivalent ). This is similar with the second
@@ -67,12 +66,10 @@
             DASFactory factory = (DASFactory) ps.next();
             System.out.println( factory.getClass().getName());
         }
-        
-        
     }
     
     public static void Anotherthing() throws Exception{
-//      Second, try to find a service by using the JDK1.3 jar
+    	//Second, try to find a service by using the JDK1.3 jar
         // discovery mechanism. This will allow users to plug a logger
         // by just placing it in the lib/ directory of the webapp ( or in
         // CLASSPATH or equivalent ). This is similar with the second
@@ -84,14 +81,12 @@
             DASFactory factory = (DASFactory) Class.forName(className).newInstance();
             System.out.println( factory.getClass().getName() );
         }
-        
-        
     }
-
     
     public static void main(String[] args) throws Exception{
         //DASFactory factory = ServiceProvider.getInstance().getFactory(Implementation.LDAP);
-        ServiceProvider.Something();
-        ServiceProvider.Anotherthing();
+        //ServiceProvider.Something();
+        //ServiceProvider.Anotherthing();
+    	ServiceProvider.getDASFactory();
     }
 }

Modified: incubator/tuscany/sandbox/amita/das/api/src/main/resources/config.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/amita/das/api/src/main/resources/config.xsd?view=diff&rev=557262&r1=557261&r2=557262
==============================================================================
--- incubator/tuscany/sandbox/amita/das/api/src/main/resources/config.xsd (original)
+++ incubator/tuscany/sandbox/amita/das/api/src/main/resources/config.xsd Wed Jul 18 07:04:42
2007
@@ -1,35 +0,0 @@
-<?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.
- -->
-<xsd:schema
-   xmlns:config="http:///org.apache.tuscany.das/config.xsd"
-   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-   targetNamespace="http:///org.apache.tuscany.das/config.xsd"
-   elementFormDefault="qualified">
-
-   <xsd:element name="Config" type="config:Config"/> 
-   
-   <xsd:complexType name="Config">
-      <xsd:sequence>
-         <xsd:element  maxOccurs="unbounded" minOccurs="0" name="Command" type="config:Command"/>
-      </xsd:sequence>
-      <xsd:attribute name="uri" type="xsd:string"/>
-      <xsd:attribute name="dataObjectModel" type="xsd:string"/>
-   </xsd:complexType>
-</xsd:schema>

Modified: incubator/tuscany/sandbox/amita/das/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/amita/das/pom.xml?view=diff&rev=557262&r1=557261&r2=557262
==============================================================================
--- incubator/tuscany/sandbox/amita/das/pom.xml (original)
+++ incubator/tuscany/sandbox/amita/das/pom.xml Wed Jul 18 07:04:42 2007
@@ -38,7 +38,7 @@
     
     <modules>
         <module>api</module>
-        <module>ldap</module>
+        <!--<module>ldap</module>-->
         <module>xquery</module>
     </modules>
 

Modified: incubator/tuscany/sandbox/amita/das/xquery/src/main/java/org/apache/tuscany/das/xquery/impl/XQueryDASFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/amita/das/xquery/src/main/java/org/apache/tuscany/das/xquery/impl/XQueryDASFactoryImpl.java?view=diff&rev=557262&r1=557261&r2=557262
==============================================================================
--- incubator/tuscany/sandbox/amita/das/xquery/src/main/java/org/apache/tuscany/das/xquery/impl/XQueryDASFactoryImpl.java
(original)
+++ incubator/tuscany/sandbox/amita/das/xquery/src/main/java/org/apache/tuscany/das/xquery/impl/XQueryDASFactoryImpl.java
Wed Jul 18 07:04:42 2007
@@ -5,7 +5,8 @@
 
 import org.apache.tuscany.das.DAS;
 import org.apache.tuscany.das.DASFactory;
-import org.apache.tuscany.das.config.Config;
+import org.apache.tuscany.das.xquery.config.Config;
+import org.apache.tuscany.das.DataSourceConnection;
 
 public class XQueryDASFactoryImpl extends DASFactory {
 	public static final String NAMESPACE = "das://xquery";
@@ -20,26 +21,31 @@
 
     @Override
     public DAS createDAS(InputStream configStream) {
-        return null;
+    	return new XQueryDASImpl(configStream);
     }
 
     @Override
-    public DAS createDAS(Config config) {
-        return null;
+    public DAS createDAS(DataSourceConnection connection){
+    	return new XQueryDASImpl(connection);
     }
-
+    
     @Override
-    public DAS createDAS(InputStream configStream, Connection connection) {
-        return null;
+    public DAS createDAS(Object config){
+    	return new XQueryDASImpl(config);
     }
-
+    
     @Override
-    public DAS createDAS(Config config, Connection connection) {
-        return null;
+    public DAS createDAS(Object config, DataSourceConnection connection) {
+    	return new XQueryDASImpl(config, connection);
     }
-
+        
     @Override
-    public DAS createDAS(Connection connection) {
+    public DAS createDAS(InputStream configStream, DataSourceConnection connection) {
+    	return new XQueryDASImpl(configStream, connection);
+    }
+    
+    public DAS createDAS(InputStream configStream, Connection connection) {
         return null;
     }
+
 }

Modified: incubator/tuscany/sandbox/amita/das/xquery/src/test/java/org/apache/tuscany/das/xquery/XQueryDASFactoryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/amita/das/xquery/src/test/java/org/apache/tuscany/das/xquery/XQueryDASFactoryTestCase.java?view=diff&rev=557262&r1=557261&r2=557262
==============================================================================
--- incubator/tuscany/sandbox/amita/das/xquery/src/test/java/org/apache/tuscany/das/xquery/XQueryDASFactoryTestCase.java
(original)
+++ incubator/tuscany/sandbox/amita/das/xquery/src/test/java/org/apache/tuscany/das/xquery/XQueryDASFactoryTestCase.java
Wed Jul 18 07:04:42 2007
@@ -18,10 +18,17 @@
  */
 package org.apache.tuscany.das.xquery;
 
+import java.io.InputStream;
+
 import junit.framework.TestCase;
 
+import org.apache.tuscany.das.Command;
+import org.apache.tuscany.das.DAS;
 import org.apache.tuscany.das.DASFactory;
+import org.apache.tuscany.das.ImplementationFactory;
 import org.apache.tuscany.das.xquery.impl.XQueryDASFactoryImpl;
+import org.apache.tuscany.das.xquery.impl.XQuerySaxonCommandImpl;
+import org.apache.tuscany.das.xquery.service.XQueryServiceProvider;
 
 public class XQueryDASFactoryTestCase extends TestCase {
 
@@ -30,10 +37,64 @@
         super.setUp();
     }
     
-    public void testDiscoverFactoryInstance() {
+    public void testDiscoverDASFactoryInstance() {
         DASFactory factory = DASFactory.getInstance(XQueryDASFactoryImpl.NAMESPACE);
         
+        System.out.println("factory.."+factory.getClass().getName());
         assertNotNull(factory);
         assertEquals(factory.getNamespace(), XQueryDASFactoryImpl.NAMESPACE);
     }
+    
+    public void testGetDASInstance() {
+        DASFactory dasFactory = DASFactory.getInstance(XQueryDASFactoryImpl.NAMESPACE); 
  	
+    	InputStream configStream = dasFactory.getClass().getClassLoader().getResourceAsStream("BooksCfg.xml");
+    	DAS das = dasFactory.createDAS(configStream);
+    	assertNotNull(das);
+    	assertEquals(das.getClass().getName(), "org.apache.tuscany.das.xquery.impl.XQueryDASImpl");
+    }
+    
+    public void testDiscoverXQueryImplementationFactory() {
+        DASFactory dasFactory = DASFactory.getInstance(XQueryDASFactoryImpl.NAMESPACE); 
  	
+    	InputStream configStream = dasFactory.getClass().getClassLoader().getResourceAsStream("BooksCfg.xml");
+    	DAS das = dasFactory.createDAS(configStream);
+
+    	ImplementationFactory xqryFactory = XQueryServiceProvider.getInstance().getXQueryFactory();
+    	das.setImplementationFactory(xqryFactory);
+    	assertNotNull(xqryFactory);
+    	assertEquals("org.apache.tuscany.das.xquery.impl.XQuerySaxonFactoryImpl", xqryFactory.getClass().getName());
+    }
+    
+    public void testGetCommand() {
+        DASFactory dasFactory = DASFactory.getInstance(XQueryDASFactoryImpl.NAMESPACE); 
  	
+    	InputStream configStream = dasFactory.getClass().getClassLoader().getResourceAsStream("BooksCfg.xml");
+    	DAS das = dasFactory.createDAS(configStream);
+
+    	ImplementationFactory xqryFactory = XQueryServiceProvider.getInstance().getXQueryFactory();
+    	das.setImplementationFactory(xqryFactory);
+    	
+    	Command cmd = das.getCommand("readBookCmd");
+    	assertNotNull(cmd);
+    	assertEquals(cmd.getClass().getName(), "org.apache.tuscany.das.xquery.impl.XQuerySaxonCommandImpl");
+    	
+    	if(cmd instanceof XQuerySaxonCommandImpl){
+    		assertEquals(((XQuerySaxonCommandImpl)cmd).getQueryString(),
+    			"//ITEM/TITLE");
+    	}
+    }
+    
+    public void testExecuteCommand() {
+        DASFactory dasFactory = DASFactory.getInstance(XQueryDASFactoryImpl.NAMESPACE); 
  	
+    	InputStream configStream = dasFactory.getClass().getClassLoader().getResourceAsStream("BooksCfg.xml");
+    	DAS das = dasFactory.createDAS(configStream);
+
+    	ImplementationFactory xqryFactory = XQueryServiceProvider.getInstance().getXQueryFactory();
+    	das.setImplementationFactory(xqryFactory);
+    	
+    	Command cmd = das.getCommand("readBookCmd");
+
+    	if(cmd instanceof XQuerySaxonCommandImpl){
+    		XQuerySaxonCommandImpl xqrySaxoncmd = (XQuerySaxonCommandImpl)cmd;
+    		xqrySaxoncmd.executeQuery();
+    	}
+    }    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message