SD-SDCAE-Tutorial
28 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
28 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

IST Amigo ProjectAmigo Semantic Services TutorialIST-2004-004182PublicOctober 2007 PublicProject Number : IST-004182Project Title : AmigoDeliverable Type : TutorialDeliverable Number :Title of Deliverable : Amigo Semantic Services TutorialNature of Deliverable : PublicInternal Document Number :Contractual Delivery Date :Actual Delivery Date :Contributing WPs :Author(s) : Graham Thomson, Sébastien Bianco – INRIA RocquencourtAmigo IST-2004-004182 1/27October 2007 PublicTable of ContentsTable of Contents....................................................................................21 Introduction........................................................................................32 How to create semantic services and descriptions ........................42.1 How to create and deploy the services...................................................................42.2mantic service descriptions ........................................................83 How to create a task description....................................................184 How to create a semantic service application...............................215 How to deploy a semantic service application..............................25Amigo IST-2004-004182 2/27October 2007 Public1 IntroductionIn this tutorial we shall look at how to construct a smart home alarm clock application that is based on Amigo Semantic Services. The application switches on a radio and brews a cup of ...

Informations

Publié par
Nombre de lectures 31
Langue English

Extrait

IST Amigo Project
Amigo Semantic Services Tutorial
IST-2004-004182 Public
October 2007
Project Number Project Title Deliverable Type
Deliverable Number Title of Deliverable Nature of Deliverable Internal Document Number Contractual Delivery Date Actual Delivery Date Contributing WPs Author(s)
Amigo IST-2004-004182
: : :
: : : : : : : :
IST-004182 Amigo Tutorial
Amigo Semantic Services Tutorial Public
Public
Graham Thomson, Sébastien Bianco – INRIA Rocquencourt
1/27
October 2007
Table of Contents
Public
Table of Contents....................................................................................2
1 Introduction........................................................................................3
2 How to create semantic services and descriptions ........................4 2.1 How to create and deploy the services...................................................................4 2.2 How to create semantic service descriptions ........................................................8
3
4
5
Ami
How to create a task description ....................................................18
How to create a semantic service application ...............................21
How to deploy a semantic service application ..............................25
go  IST-2004-040182
2/27
October 2007
Public
1 Introduction In this tutorial we shall look at how to construct a smart home alarm clock application that is based on Amigo Semantic Services. The application switches on a radio and brews a cup of coffee when the alarm activates. This tutorial has several parts: first, we will look at the services – the radio and coffee maker – and how they are described using the Amigo-S semantic service description language; next, we look at how to a task is described and how it composes the services in the way the alarm clock application requires; then, we look at how to create the application and how to use the semantic service repository; and finally, we look at how to deploy and run the application. For more a more detailed over view of Amigo Semantic Services middleware, please refer to Amigo D3.4 Amigo overall middleware: First Prototype implementation & documentation.
Amigo  IST-2004-040812
3/27
October 2007
Public
2 How to create semantic services and descriptions Our application requires to services to run – a radio service, and a coffee machine service. When the alarm clock activates we want the application to switch on the radio, switch on the coffee machine, and then instruct the coffee machine to brew a cup of coffee. A nice way to start the day in our smart home! All the code, scripts, descriptions, etc. that feature in this tutorial are available in full in the examples download that accompanies this tutorial. Please explore the contents of this download. The download is in the format of an Eclipse project. It is recommend to use the Eclipse IDE (available atrg.oseipcl.ewwwto follow the examples in this tutorial.)
2.1 How to create and deploy the services First we must construct the services we are going to use – the radio and the coffee machine. Below is the listing of some simple Java code for these services. These listings can be found in full in the src\examples\alarmclock folder of the examples download. The radio interface: packageexamples.alarmclock; public interfaceFmRadio { voidswitchOn(); voidswitchOff(); voidincreaseVolume(); voiddecreaseVolume(); voidfindNextStation(); } The radio implementation: packageexamples.alarmclock; public classFmRadioServiceimplementsFmRadio { private intvolume = 5; private double= { 88.6, 99.5, 100.8, 102.5 };[] stations private intcurrentStation = 0; private booleanswitchedOn =false; public voidswitchOn() { if(!switchedOn) { switchedOn =true; System.out.println("The FM Radio has been switched on."); } } public voidswitchOff() { if(switchedOn) { switchedOn =false; System.out.println("The FM Radio has been switched off."); Amigo IST-2004-004182
4/27
October 2007
} } public voiddecreaseVolume() { if(volume > 0) { --volume; } System.out.println("Volume decreased to "+ volume +"."); } public voidincreaseVolume() { if(volume < 10) { ++volume; } System.out.println("Volume increased to "+ volume +"."); } public voidfindNextStation() { currentStation = (currentStation + 1) % stations.length; System.out.println("Found station "+ stations[currentStation] +" FM."); } } The coffee machine interface: packageexamples.alarmclock; public interfaceCoffeeMachine { voidswitchOn(); voidswitchOff(); voidbrew(); voidserve(); } And the coffee machine implementation: packageexamples.alarmclock; public classCoffeeMachineServiceimplementsCoffeeMachine { private booleanswitchedOn; private booleanbrewed; public voidswitchOn() { if(!switchedOn) { switchedOn =true; System.out.println( "The Coffee Machine has been switched on."); } } public voidswitchOff() { if(switchedOn) { switchedOn =false; System.out.println( Amigo IST-2004-004182
Public
5/27
October 2007
Public
"The Coffee Machine has been switched off."); } } public voidbrew() { if(brewed) { System.out.println("The coffee is already brewed!"); }else{ brewed =true; } } public voidserve() { if(!brewed) { System.out.println( "Please brew the coffee first, before serving."); }else{ brewed =false;  System.out.println("The coffee is being served."); } } } Once we have these classes compiling and running, we must make them into web services. In this tutorial we will use Apache Tomcat and Apache Axis to host web services, and Active Endpoints ActiveBPEL to executed composed semantic service applications. If you do not already have these installed, grab them fromhtt:p//tomcat.apache.or/g, http://ws.apache.org/axis/andpt/:tha.tcw/wwendpive-s.coointm/respectively. Get Apache Tomcat 5.5, Apache Axis 1.4 and ActiveBPEL 2.1.1. If you are unfamiliar with these projects, documentation is available at the project pages. Here, we’ll go over the essentials for using them with the Amigo Semantic Services middleware. For debugging for Tomcat or Axis install however, consult the documentation. In the examples, Tomcat is installed as a Windows service on port 9080. If you install Tomcat on a different port, please update the examples appropriately. OK – were ready to turn make our services available. Make sure Axis is running, and deploy the services using the scripts provided: cd axis axisDeploy.bat CoffeeMachineDeploy.wsdd axisDeploy.txt FmRadioDeploy.wsdd Take a look at the .bat script and the .wsdd files and understand what is going on. You will be able to use the script and the .wsdd files as templates for your own services. Now copy your class files up into the Axis classes folder. This folder will typically be … \Tomcat 5.5\webapps\axis\WEB-INF\classes. Now go to the Axis page in your browser:
Amigo IST-2004-004182
6/27
October 2007
And click on the “List” option:
Amigo  IST-2004-040812
Public
7/27
October 2007
Public
This lists all the services that are currently deployed on the local Axis instance. We can see the FM radio and coffee machine services. To create a semantic service description for our services, we need to have the Web Services Description Language (WSDL) file for it. Fortunately, Axis provides these for us! Click on the “(wsdl)” link beside the FM radio service:
This is the WSDL for the service. Save this file locally, giving it a .wsdl extension. Then, go back to the services listing and do the same to get the WSDL for the coffee machine service. Note that Example WSDL files for the services are already included in the \wsdl folder of the examples download for reference. Make sure to use your own for the services installed on your machine! We have finished created and deploying our services!
2.2 How to create semantic service descriptions We have created and deployed our services, but as they are, we can only use them as ordinary web services. In order to use them as Amigo Semantic Services, we must create semantic service descriptions for them. First of all, we must create the semantic concepts we need for the services, their methods – or rather, theirscpaabilitie– as well as their return types. The file \owl\AlarmClock.owl contains the ontology files that describe each of these features. We’ll look at piece-by-piece below: <?xmlversion="1.0"?> <!DOCTYPEuridef[  <!ENTITYxsd"MX/1002/amehcSLhttp://www.w3.org">     <!ENTITYprocess"se.swol1.1/Procs/owl-s/httww.w:p//.orgdamlvice/ser"> Amigo IST-2004-0041828/27
October 2007
Public
    <!ENTITYobjList "servorg/aml.ww.d1.g/s-1/o/lwcisew//:ptthecbjistLeren/Oicwo.tl">     <!ENTITYwsdl"ivres/siffoC/secinchMaeeehttp://l9:80/0xacolaohts"> ]> <rdf:RDF   xmlns:amigo="httpmigo://aofg..egrirnirf.awl/omi/A.ogo#wl"   xmlns:lang="thtp://amigo.gforglw#S-o.imogwl/Afr/oria.e.in"   mxestilibipacas:ln="g.ogima//:ptthl#owlitiei.slwC/pabaria.fr/oforge.in"   xmlns:conselec="nortcelE#lwo.sciowl/.fr/umerConsfgrogi.ornaiegi.:pttma//h"   xmlns:process="wl.o#s-lw1.1/orP/ssecl.org/services/othpt/:w/wwd.ma"   xmlns:service="ad.wo.lms/grivrehp:ttww//vrci.ewo#lces/owl-s/1.1/Se"   xmlns:profile="d.www//:/gro.lmatphtorif1.P/lw#elo.icesserv-s/1/owl"   xmlns:grounding="#lwo.gniww//daw.hp:tt1/Groundowl-s/1.reivec/slmo.grs/"   xmlns:objList=":/tphtwl-es/orvic/ges.lrod.maw/ww s/1.1/generic/ObjectList.owl#"   xmlns:xsd="ma#Scheht:/tpww/w.3w./gro1002LMX/"   xmlns:rdf="httww.w:p///1rg.ow3/2029/99ys-fdr-2#sn-xatn"   xmlns:rdfs="hw.w3.orgttp://wwfdr/hcs-002/10/0a#em"   xmlns:owl="w..3w/wwpt/:thowl#/07/2002org/"   xmlns:daml="h#lio.1o/m0l0d/a2wr.glw+wa/m//pd:0t3t"   xmlns:dc="lemed//c1/1.nestp://htt.orgpurl/"   xmlns="go.ywo#l/AlarmClockOntolol//hlac:tso0809hp:tt"   xml:base="l.ywologoOktnlCcormla/A8090t:oslhacol//:ptth">  <owl:Ontologyrdf:about="">  <owl:imports rdf:resource="//amigo.http:ge.igfor.fr/nriamAgiwo/ll.owo"/>  <owl:importsrdf:resource="/Awlgomi-http://amigo.gofgr.eniir.arfo/ S.owl"/>  <owl:imports rdf:resource="o.lw/rf.airni.egrofgestilibipaCal/owigo.//amttp:h"/>  <owl:imports rdf:resource="ctithnow/o/.:splErertcegCeoolr/nurm.nisi.gfiaamgofwor./l"/>  </owl:Ontology> So far, this is just standard header material – it links to the other ontology files we require. We have additionally included the consumer electronics ontology, and added a namespace declaration and import statement appropriately.  <owl:Classrdf:ID="FmRadio">  <rdfs:subClassOf rdf:resource="wo/loCsnmurelEcetronics.owl#Audioo.igam//p:tth/rf.airni.egrofg RenderDevice"/>  </owl:Class>  <owl:Classrdf:ID="CoffeeMachine">  <rdfs:subClassOf rdf:resource="insctcorErelusem/Con/owla.frinri.egrofg.ogima//:tphtsuwl.oon#C merElectronicsDevice"/>  </owl:Class>  <owl:Classrdf:ID="AlarmClock">  <rdfs:subClassOf rdf:resource="tp:/htwl#ConsuemEreltcorinsco.a.ri/ofr/Cwlsuonima/g.oggrofni.e merElectronicsDevice"/>  </owl:Class> Here we define the concepts for each of the services and for the application as well. Note that an ontology should describe ashareddata model – sharing a common data model between Amigo IST-2004-0041829/27
October 2007
Public
different applications and systems is one of the key strengths of using OWL – so first you should search the ontologies available in the Amigo project to see of the concepts you need already exist. After searching the ontologies, we discover that a Radio does not exist, however an AudioRenderDevice concept, and while neither a Coffee Machine nor Alarm Clock exist, a ConsumerElectronicsDevice concept does. As such, the FmRadio concept is created to be a subclass of AudioRenderDevice, and CoffeeMachine and AlarmClock to be subclasses of ConsumerElectronicsDevice.
 <!--Input and ouput semantics.-->  <owl:Classrdf:ID="Void"/> Next, we define the input and output semantics we require. In simple example, we only require a “void” type for capability outputs.
 <!--Capability semantics for FmRadio.-->  <owl:Classrdf:ID="FmRadioSwitchOn">  <rdfs:subClassOfrdf:resource= "fra.riinap/Cwl/oeitilibaeS#lwo.seCaprvicityabilthpt.gforge.://amigo"/>  </owl:Class>  <owl:Classrdf:ID="FmRadioSwitchOff">  <rdfs:subClassOfrdf:resource= ".gfomigo://ahttpows.ieitilabap/Clwo/rf.airni.egrityCepabali#leSvrci"/>  </owl:Class>  <owl:Classrdf:ID="ReaFmncredioIolumaseV">  <rdfs:subClassOfrdf:resource= "//:ptthaif./rwo/laCapibamigo.gforge.inraCecibapytiltili.oes#Swlvier"/>  </owl:Class>  <owl:Classrdf:ID="easeVolumeFRmdaoieDrc">  <rdfs:subClassOfrdf:resource= "e.inforgfr/oria.pt/:thogg.a/imilityCecibapa#lwovreSitils.ie/Cwlabap"/>  </owl:Class>  <owl:Classrdf:ID="atStxeNdniFoidaRFmtion">  <rdfs:subClassOfrdf:resource= "Cepavrcitiybaliirnirf.alwo/paC/ilabieitows.Sel#thpt://amigo.gforge."/>  </owl:Class> Above, we define the semantics for each of the capabilities for the FM radio service.
 <!--Capability semantics for CoffeeMachine.-->  <owl:Classrdf:ID="CoffeMachineSwitchOn">  <rdfs:subClassOfrdf:resource= "nr.i.fiaowr/Cal///:pgimafg.oegroerviceCapabilityapibilitseo.lwS#htt"/>  </owl:Class>  <owl:Classrdf:ID="ffctOhSeiwhcnifeMaCof">  <rdfs:subClassOfrdf:resource= ".eniir.aogg.ofgrtp://amihtlwC/rfo/litipabaowl#ies.iceCServtilibapay"/>  </owl:Class>  <owl:Classrdf:ID="CoffeMachineBrew">  <rdfs:subClassOfrdf:resource= "ilityiceCapabtp:/ht.eniofgrogg.a/imabap/Cwl/ofra.rivreS#lwo.seitili"/> Amigo IST-2004-004182
10/27
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents