一路拾遺
          Collect By Finding All The Way ......
          posts - 81,comments - 41,trackbacks - 0

          Maryland 大學計算機系的Evren Sirin 開發。OWL-S API的類庫主要建立在Axis, Jena 以及Pellet上。
           
          Apache Axis 是Apache Web Service項目中的子項目,其最初起源于IBM的"SOAP4J",應該屬于最早的一批用于構造基于SOAP應用的Framework。它支持WSDL1.1,可自動由Java Object生成WSDL。
           
          Jena主要用來處理RDF,主要使用Jena的推理能力從本體推斷模型知識。
           
          Pellet是一個開源的基于JAVA的OWL推理機。
           
          包中還自帶兩個jar包形式的java類庫,owl-s.jar和upnp.jar。
          該OWL-S API的主要功能如下:
          讀/寫服務描述:
          OWL-S API中有兩個重要的接口:OWLOntology和OWLKnowledgeBase。OWLOntology代表了存儲在單個文件中的信息,而 OWLKnowledgeBase是許多Ontology的集合。RDF數據可以加載到OWLOntology上,只有OWLOntology對象才能組 合起來。OWLKnowledgeBase中只有一個Ontology是用來存儲數據的(例如執行之后,新的實例會被加到這個OWLOntology上。
           
          函 數OWLKnowledgeBase.read(URI)從給定的Ontology讀取信息,并產生OWLOntology。函數 OWLOntology.getService()用來獲取ontology中的服務實例。如果有許多服務,則用 OWLOntology.getServices()獲取。然后,函數OWLKnowledgeBase.readService(URI)以及 OWLKnowledgeBase.readServices(URI)將會讀取服務。如果函數調用發生錯誤將會產生null輸出。
           
          函數OWLOntology.write(Writer)可以使包含服務的ontology組合起來。
           
          這是一個例子:


           // create a URI for the service (note that this is a 0.9 version file)  
              URI uri = new URI("http://www.mindswap.org/2004/owl-s/0.9/ZipCodeFinder.owl");
              
          // create a KB 
              OWLKnowledgeBase kb = OWLFactory.createKB();

              
          // create a generic reader and a 1.0 writer
              OWLOntology ont = kb.read(uri);
             
              
          // get the service
              Service service = ont.getService();
             
              
          // write the output to console (a file stream can also be used here)
              ont.write(System.out);


          將舊服務描述轉換為新描述。
           
          驗證
           
          緩存Ontology
           
           
          執行服務:
          執 行服務意味著執行它的process。Process應該有有效的grounding說明,以便有效的調用服務。WSDL和UPnP的grounding 由API支持,函數ProcessExecutionEngine.execute(Process, ValueMap)可以執行一個process,ValueMap表示輸入的值,這個函數返回輸出值。
          舉例如下:
           


           // create an execution engine
              ProcessExecutionEngine exec = OWLSFactory.createExecutionEngine();
              
          // load the service description
              Service service = kb.readService("http://www.mindswap.org/2004/owl-s/1.0/Dictionary.owl");
              
          // get the process of the service
              Process process = service.getProcess();

              
          // create an empty value map
              ValueMap values = new ValueMap();
             
              
          // set the value of input parameter
              values.setDataValue(process.getInput("InputString"), "computer");   
              
          // execute the process with the given input bindings
              values = exec.execute(process, values); 
             
              
          // get the output value as a string
              String outValue = values.getStringValue(process.getOutput());
             
              
          // display the result
              System.out.println("Output = " + outValue);

          執行跟蹤功能:

          當執行復雜的服務時,知道執行的過程是很有用的,ProcessExecutionListener就是為這一目的設計的。 ProcessExecutionEngine.addExecutionListener(ProcessExecutionListener)就可以 為執行器添加這么一個監聽器。
           
          生成復合過程
           
          可以用程序產生服務的descriptions, profile或者processes描述。OWLOntology接口實現了這個功能。
           

          /**
             *
             * Create a new Sequence from the processes of the given services and put them in a new
             * Service.
             *
             * 
          @param services List of Services
             * 
          @param baseURI The base URI for the generated service
             * 
          @return The Service which is a Sequence of the given services
             
          */
            Service createSequenceService(List services, String baseURI) {  
              
          // create an empty ontology
              OWLOntology ont = OWLFactory.createOntology();
              
          // create a new service
              Service service = ont.createService(URI.create(baseURI + "Service"));
              
          // create a new composite process
              CompositeProcess process = ont.createCompositeProcess(URI.create(baseURI + "Process"));    

              
          // create a new sequence construct
              Sequence sequence = ont.createSequence();
              
          // put the sequence into composite process
              compositeProcess.setComposedOf(sequence);
             
              
          for(int i = 0; i < services.size(); i++) { 
                
          // get the service from the list
                Service s = (Service) services.get(i);
                
          // get the process fron the service
                Process p = s.getProcess();
               
                
          // create a perform construct
                Perform perform = ont.createPreform();
                perform.setProcess(p);
                
          // put the process into the sequence
                sequence.addComponent(p);

                
          // create data flow if necessary

              }

              
          // create profile

              
          // create grounding

              
          return service;
            }

           
          支持功能。

          API中包含了org.mindswap.owls.wsdl這個包,可以用來讀寫WSDL描述的服務。執行OWL-S服務就是通過這個包實現的。這個功能是建立在AXIS包1.1上的。
          posted on 2008-07-23 16:51 胖胖泡泡 閱讀(539) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 清徐县| 安阳市| 临江市| 东台市| 明溪县| 西和县| 神农架林区| 安陆市| 达拉特旗| 东山县| 禹城市| 日照市| 天门市| 慈溪市| 长泰县| 本溪市| 吴忠市| 安仁县| 宝清县| 肇源县| 岚皋县| 雷波县| 藁城市| 静宁县| 清流县| 会东县| 柳河县| 大足县| 睢宁县| 礼泉县| 临猗县| 吉水县| 丘北县| 安图县| 潜山县| 綦江县| 花垣县| 叙永县| 米泉市| 瑞丽市| 广南县|