Mentions légales du service

Skip to content
Snippets Groups Projects
Commit c4bb8811 authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- integrated the first version of a Jade server

parent cc6757b8
No related branches found
No related tags found
No related merge requests found
Manifest-Version: 1.0 Manifest-Version: 1.0
Created-By: Jerome.Euzenat@inrialpes.fr 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 Main-Class: fr/inrialpes/exmo/align/service/AlignmentService
File added
File added
File added
...@@ -24,6 +24,8 @@ import fr.inrialpes.exmo.queryprocessor.QueryProcessor; ...@@ -24,6 +24,8 @@ import fr.inrialpes.exmo.queryprocessor.QueryProcessor;
import fr.inrialpes.exmo.queryprocessor.Result; import fr.inrialpes.exmo.queryprocessor.Result;
import fr.inrialpes.exmo.queryprocessor.Type; 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.parser.AlignmentParser;
import fr.inrialpes.exmo.align.impl.BasicParameters; import fr.inrialpes.exmo.align.impl.BasicParameters;
...@@ -172,6 +174,19 @@ public class AlignmentService { ...@@ -172,6 +174,19 @@ public class AlignmentService {
// Create them // Create them
// init( params ) -- parameters must be passed // 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")); if ( debug > 0 ) System.err.println("AServ launched on http://localhost:"+params.getParameter("htmlport"));
try { System.in.read(); } catch( Throwable t ) {}; try { System.in.read(); } catch( Throwable t ) {};
......
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(){
}
}
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);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment