public void shutDown() { // Avoid two parallel shut-downs synchronized (this) { if (terminating) { return; } else { terminating = true; } } // Forward the exit command to the FrontEnd try { myFrontEnd.exit(false); } catch (IMTPException imtpe) { // The FrontEnd is disconnected. Force the shutdown of the connection myConnectionManager.shutdown(); } // "Kill" all agent images killAgentImages(); if (theBEManager != null) { theBEManager.deregister(myNodeDescriptor); } super.shutDown(); }
public void resumeAgentOnFE(String name) throws IMTPException, NotFoundException { try { myFrontEnd.resumeAgent(name); } catch (PostponedException pe) { // Hide the delivery delay to the rest of the platform resumedAgent(name); } }
/** * Dispatch a message to an agent in the FrontEnd. If this method is called by a thread that is * serving a message sent by an agent in the FrontEnd too, nothing is done as the dispatch has * already taken place in the FrontEnd (see messageOut()). */ public boolean postMessageToLocalAgent(ACLMessage msg, AID receiverID) { // Try first in the LADT boolean found = super.postMessageToLocalAgent(msg, receiverID); if (found) { return found; } else { // The receiver must be in the FrontEnd AgentImage image = (AgentImage) agentImages.get(receiverID); if (image != null) { if (agentImages.containsKey(msg.getSender()) && isExplicitReceiver(msg, receiverID)) { // The message was sent by an agent living in the FrontEnd. The // receiverID (living in the FrontEnd too) has already received // the message. // The second part of the condition ensures that, if the // message was not directly sent to the receiver (e.g. it was sent to a topic // or an alias), message delivery occurs normally. // FIXME: This does not take into account that an agent not living // in the FrontEnd may send a message on behalf of an agent living // in the FrontEnd. return true; } try { // Forward the message to the FrontEnd int size; if (msg.hasByteSequenceContent()) { size = msg.getByteSequenceContent().length; } else { size = msg.getContent() != null ? msg.getContent().length() : 0; } myLogger.log( Logger.INFO, getID() + " - Delivering IN message " + ACLMessage.getPerformative(msg.getPerformative()) + ", size=" + size); myFrontEnd.messageIn(msg, receiverID.getLocalName()); handlePosted(receiverID, msg); return true; } catch (NotFoundException nfe) { System.out.println("WARNING: Missing agent in FrontEnd"); return false; } catch (IMTPException imtpe) { System.out.println("WARNING: Can't deliver message to FrontEnd"); return false; } } else { // Agent not found System.out.println("WARNING: Agent " + receiverID + " not found on BackEnd container"); return false; } } }
public static RBTerm makeJava(Object o) { if ((o instanceof Object[])) { Object[] array = (Object[]) o; RBTerm[] terms = new RBTerm[array.length]; for (int i = 0; i < array.length; i++) { terms[i] = makeJava(array[i]); } return FrontEnd.makeList(terms); } if ((o instanceof UppedTerm)) { return ((UppedTerm) o).down(); } return new RBJavaObjectCompoundTerm(o); }
public class RBQuoted extends RBAbstractPair { private static final RBTerm quotedName = FrontEnd.makeName("{}"); public RBQuoted(RBTerm listOfParts) { super(quotedName, listOfParts); } public Object up() { return quotedToString(); } public String toString() { return "{" + getQuotedParts().quotedToString() + "}"; } public String quotedToString() { return getQuotedParts().quotedToString(); } public RBTerm getQuotedParts() { return getCdr(); } protected Type getType(TypeEnv env) throws TypeModeError { return Factory.makeSubAtomicType(Factory.makeTypeConstructor(String.class)); } public Object accept(TermVisitor v) { return v.visit(this); } /** @see tyRuBa.util.TwoLevelKey#getFirst() */ public String getFirst() { return getCdr().getFirst(); } /** @see tyRuBa.util.TwoLevelKey#getSecond() */ public Object getSecond() { return getCdr().getSecond(); } }
/////////////////////////////////////////////// // Methods called by the BEManagementService /////////////////////////////////////////////// public void createAgentOnFE(String name, String className, String[] args) throws IMTPException { myFrontEnd.createAgent(name, className, args); }
// Shutdown hook public static void shutdown() { if (DebugContext.frontEnd != null) { frontEnd.onVmShutdown(); } }
@Override protected void exec(FrontEnd frontEnd) { frontEnd.setScore(score); }