... private class LoggingSliceImpl implements Service.Slice { public Service getService() { return LoggingService.this; } public Node getNode() throws ServiceException { try { return LoggingService.this.getLocalNode() ; } catch (IMTPException imtpe) { // Should never happen as this is a local call throw new ServiceException("Unexpected error retrieving local node") ; } } public VerticalCommand serve (HorizontalCommand cmd) { if (cmd.getName().equals(LoggingSlice.H_LOGMESSAGE)) { Object[] params = cmd.getParams() ; System.out.println(params [0]) ; } } } ... ================================================ ... private ServiceSlice localSlice = new LoggingSliceImpl() ; ... public Class getHorizontalInterface() { return LoggingSlice.class; } public Service.Slice getLocalSlice() { return localSlice; } ... ================================================ ... private class OutgoingLoggingFilter extends Filter { public boolean accept (VerticalCommand cmd) { if (cmd.getName().equals (MessagingSlice.SEND_MESSAGE)) { Object[] params = cmd.getParams() ; AID sender = (AID) params [0] ; GenericMessage gMsg = (GenericMessage) params[1] ; ACLMessage msg = gMsg.getACLMessage() ; AID receiver = (AID) params[2] ; // Prepare the log record String logRecord = "Message from "+sender+" to "+receiver+": \n" ; if (verbose) { logRecord = logRecord+msg; } else { logRecord = logRecord+ACLMessage.getPerformative(msg.getPerformative()); } // Send the log record to the logging slice on the Main Container try { LoggingSlice mainSlice = (LoggingSlice) getSlice(MAIN_SLICE) ; mainSlice.logMessage (logRecord) ; } catch (ServiceException se) { System.out.println("Error retrieving Main LoggingSlice") ; se.printStackTrace() ; } catch (IMTPException impte) { System.out.println("Error contacting Main LoggingSlice") ; se.printStacktrace() ; } } // Never block a command return true; } }