diff --git a/distrib/MANIFEST-svc.MF b/distrib/MANIFEST-svc.MF index 2eec990a79b0b118a6ff7bf4fbc1dfd0c5c14894..84085b0eaad61a3b5b3dca87a209603cd7f314ba 100644 --- a/distrib/MANIFEST-svc.MF +++ b/distrib/MANIFEST-svc.MF @@ -1,4 +1,4 @@ Manifest-Version: 1.0 Created-By: Jerome.Euzenat@inrialpes.fr -Class-Path: api.jar impl.jar io.jar rdfparser.jar getopt.jar commons-logging.jar log4j.jar rdfapi.jar align.jar procalign.jar +Class-Path: api.jar impl.jar io.jar rdfparser.jar getopt.jar commons-logging.jar log4j.jar rdfapi.jar align.jar procalign.jar jade.jar iiop.jar http.jar Main-Class: fr/inrialpes/exmo/align/service/AlignmentService diff --git a/lib/http.jar b/lib/http.jar new file mode 100755 index 0000000000000000000000000000000000000000..5f2a253d0d193e759671ed6b3425bd04d2d71d0f Binary files /dev/null and b/lib/http.jar differ diff --git a/lib/iiop.jar b/lib/iiop.jar new file mode 100755 index 0000000000000000000000000000000000000000..20b39f7e1b36893602a10fd40c21fb8d4797b635 Binary files /dev/null and b/lib/iiop.jar differ diff --git a/lib/jade.jar b/lib/jade.jar new file mode 100755 index 0000000000000000000000000000000000000000..b761ab2532aff328a105c582f18573f1debe3b3c Binary files /dev/null and b/lib/jade.jar differ diff --git a/src/fr/inrialpes/exmo/align/service/AlignmentService.java b/src/fr/inrialpes/exmo/align/service/AlignmentService.java index eaf87878f86f61d9843ab9d7316d7c0b3b6b7ece..f8b871eb1095c522ba6e053cc2e3c6b9068000b8 100644 --- a/src/fr/inrialpes/exmo/align/service/AlignmentService.java +++ b/src/fr/inrialpes/exmo/align/service/AlignmentService.java @@ -24,6 +24,8 @@ import fr.inrialpes.exmo.queryprocessor.QueryProcessor; import fr.inrialpes.exmo.queryprocessor.Result; import fr.inrialpes.exmo.queryprocessor.Type; +import fr.inrialpes.exmo.align.service.jade.JadeFIPAAServProfile; + import fr.inrialpes.exmo.align.parser.AlignmentParser; import fr.inrialpes.exmo.align.impl.BasicParameters; @@ -172,6 +174,19 @@ public class AlignmentService { // Create them // init( params ) -- parameters must be passed + // Launch jADE Server (this will have to be changed) + // To a more generic way by launching all the requested + // profile or all the available profiles + // TODO Auto-generated method stub + JadeFIPAAServProfile JADEServeur=new JadeFIPAAServProfile(); + try{ JADEServeur.init(8888); } + //catch ( AServException e ) { + // System.err.println( "Couldn't start server:\n" + e ); + // System.exit( -1 ); + // not good + //} + catch (Exception e) {e.printStackTrace();} + if ( debug > 0 ) System.err.println("AServ launched on http://localhost:"+params.getParameter("htmlport")); try { System.in.read(); } catch( Throwable t ) {}; diff --git a/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServProfile.java b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServProfile.java new file mode 100755 index 0000000000000000000000000000000000000000..cb565b727e1f5ead5ca3895bd05b4e3a38516c9f --- /dev/null +++ b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServProfile.java @@ -0,0 +1,55 @@ +package fr.inrialpes.exmo.align.service.jade; + +import java.io.IOException; + +import fr.inrialpes.exmo.align.service.jade.JadeFIPAAServiceAgent; + +import jade.core.Runtime; +import jade.core.Profile; +import jade.core.ProfileImpl; +import jade.util.leap.Properties; +import jade.wrapper.*; + + +public class JadeFIPAAServProfile { + + public void init( int port ) throws IOException { + + Properties props = new Properties(); + try { + + // Get a hold on JADE runtime + Runtime rt = Runtime.instance(); + + // Exit the JVM when there are no more containers around + rt.setCloseVM(true); + + // Launch a complete platform on the 8888 port + +/** Profile with no MTP( Message Transfer Protocol + props.setProperty("nomtp", "true"); + Profile pMain = new ProfileImpl(props); + **/ + // create a default Profile + Profile pMain = new ProfileImpl(null, 8888, null); + + System.out.println("Launching a whole in-process platform..."+pMain); + AgentContainer mc = rt.createMainContainer(pMain); + + AgentController custom = mc.createNewAgent("JadeFIPAAServiceAgent", JadeFIPAAServiceAgent.class.getName(), null); + custom.start(); + + } + catch(Exception e) { + e.printStackTrace(); + } + + } + + + + + public void close(){ + + } +} diff --git a/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java new file mode 100755 index 0000000000000000000000000000000000000000..085e605470b071061ea647ea2af610f83e10591d --- /dev/null +++ b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java @@ -0,0 +1,77 @@ +package fr.inrialpes.exmo.align.service.jade; + +import jade.core.Agent; +import jade.core.Profile; +import jade.core.behaviours.*; +import jade.lang.acl.*; + +import jade.domain.*; +import jade.domain.FIPAAgentManagement.*; + +import jade.util.Logger; + +public class JadeFIPAAServiceAgent extends Agent { + + public static final String SERVICE_NAME = "Alignment"; + public static final String SERVICE_TYPE = "Alignment-service"; + + private Logger myLogger = Logger.getMyLogger(getClass().getName()); + + protected void setup() { + myLogger.log(Logger.INFO, "Hallo World! My name is "+getAID().getName()); + + // Read arguments + Object[] args = getArguments(); + if (args != null) { + for (int i = 0; i < args.length; ++i) { + myLogger.log(Logger.INFO, "Arg-"+i+" = "+args[i]); + } + } + + // Add initial behaviours + addBehaviour(new CyclicBehaviour(this) { + public void action() { + ACLMessage msg = myAgent.receive(); + if (msg != null) { + myLogger.log(Logger.INFO, "Received message: "+msg); + ACLMessage reply = msg.createReply(); + reply.setPerformative(ACLMessage.NOT_UNDERSTOOD); + myAgent.send(reply); + } + else { + block(); + } + } + }); + + + // Register with the DF + registerWithDF(); + } + + protected void takeDown() { + + myLogger.log(Logger.INFO, "Bye bye!!!"); + } + + private void registerWithDF() { + DFAgentDescription dfd = new DFAgentDescription(); + dfd.setName(getAID()); + ServiceDescription sd = new ServiceDescription(); + sd.setName(getLocalName()+'-'+SERVICE_NAME); + sd.setType(SERVICE_TYPE); + dfd.addServices(sd); + try { + myLogger.log(Logger.INFO, "Registering with DF..."); + DFService.register(this, dfd); + myLogger.log(Logger.INFO, "Registration OK."); + } + catch (FIPAException fe) { + myLogger.log(Logger.WARNING, "Error registering with DF.", fe); + } + } + + + + +}