diff --git a/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServProfile.java b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServProfile.java index a4ab81df5281745d70227802a0c76d3d02ddcf26..14c7e28500053b75ef40dc2d9a3c4835661f012a 100755 --- a/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServProfile.java +++ b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServProfile.java @@ -1,5 +1,5 @@ /* - * $Id: AlignmentService.java 335 2006-10-05 10:02:02Z euzenat $ + * $Id: JadeFIPAAServProfile.java 335 2006-10-05 10:02:02Z euzenat $ * * Copyright (C) Orange R&D, 2006 * Copyright (C) INRIA Rhône-Alpes, 2006 @@ -33,51 +33,63 @@ import org.semanticweb.owl.align.Parameters; import jade.core.Runtime; import jade.core.Profile; import jade.core.ProfileImpl; +import jade.util.Logger; import jade.util.leap.Properties; -// JE: find them +//JE: find them import jade.wrapper.*; public class JadeFIPAAServProfile implements AlignmentServiceProfile { - public void init( Parameters params, AServProtocolManager manager ) throws AServException { - int port = 8888; - int debug = 0; - - if ( params.getParameter( "jade" ) != null ) - port = Integer.parseInt( (String)params.getParameter( "jade" ) ); - if ( params.getParameter( "debug" ) != null ) - debug = ((Integer)params.getParameter( "debug" )).intValue() - 1; - /** + private AgentContainer mc; + private AgentController algagentcontroller; + private Logger myLogger = Logger.getMyLogger(getClass().getName()); + + public void init( Parameters params, AServProtocolManager manager ) throws AServException { + int port = 8888; + int debug = 0; + + if ( params.getParameter( "jade" ) != null ) + port = Integer.parseInt( (String)params.getParameter( "jade" ) ); + if ( params.getParameter( "debug" ) != null ) + debug = ((Integer)params.getParameter( "debug" )).intValue() - 1; + + /** Properties props = new Properties(); - **/ - try { - // Get a hold on JADE runtime - Runtime rt = Runtime.instance(); + **/ + try { + // Get a hold on JADE runtime + Runtime rt = Runtime.instance(); - // Exit the JVM when there are no more containers around - rt.setCloseVM(true); + // Exit the JVM when there are no more containers around + rt.setCloseVM(true); - /** Profile with no MTP( Message Transfer Protocol + /** 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, port, null); - - if ( debug > 0 ) - 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) { - throw new AServException ( "Cannot launch Jade Server" , e ); + **/ + // create a default Profile + Profile pMain = new ProfileImpl(null, port, null); + + if ( debug > 0 ) + System.out.println("Launching a whole in-process platform..."+pMain); + mc = rt.createMainContainer(pMain); + algagentcontroller = mc.createNewAgent("JadeFIPAAServiceAgent", JadeFIPAAServiceAgent.class.getName(), null); + algagentcontroller.start(); + } + catch(Exception e) { + throw new AServException ( "Cannot launch Jade Server" , e ); + } } - } - public void close(){ - } + public void close(){ + try{ + algagentcontroller.kill(); + mc.kill(); + myLogger.log(Logger.INFO, "Agent Alignement close"); + } + catch (ControllerException e){myLogger.log(Logger.WARNING, "Error killing the alignment agent."); } + } + } diff --git a/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java index 085e605470b071061ea647ea2af610f83e10591d..5c8abdcbbb8a1a62a921c973d66237bce6eba79a 100755 --- a/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java +++ b/src/fr/inrialpes/exmo/align/service/jade/JadeFIPAAServiceAgent.java @@ -1,3 +1,25 @@ +/* + * $Id: JadeFIPAAServiceAgent.java 335 2006-10-05 10:02:02Z euzenat $ + * + * Copyright (C) Orange R&D, 2006 + * Copyright (C) INRIA Rhône-Alpes, 2006 + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + + package fr.inrialpes.exmo.align.service.jade; import jade.core.Agent; @@ -51,7 +73,8 @@ public class JadeFIPAAServiceAgent extends Agent { protected void takeDown() { - myLogger.log(Logger.INFO, "Bye bye!!!"); + myLogger.log(Logger.INFO, "Agent Alignement Service close"); + this.doDelete(); } private void registerWithDF() {