1 /** 2 * $RCSfile: Module.java,v $ 3 * $Revision: 1.4 $ 4 * $Date: 2004/12/05 05:37:06 $ 5 * 6 * Copyright (C) 2004 Jive Software. All rights reserved. 7 * 8 * This software is published under the terms of the GNU Public License (GPL), 9 * a copy of which is included in this distribution. 10 */ 11 12 package org.jivesoftware.messenger.container; 13 14 import org.jivesoftware.messenger.XMPPServer; 15 16 /** 17 * Logical, server-managed entities must implement this interface. A module 18 * represents an operational unit and may contain zero or more services 19 * and rely on zero or more services that may be hosted by the container. 20 * <p/> 21 * In order to be hosted in the Jive server container, all modules must: 22 * </p> 23 * <ul> 24 * <li>Implement the Module interface</li> 25 * <li>Have a public no-arg constructor</li> 26 * </ul> 27 * <p/> 28 * The Jive container will run all modules through a simple lifecycle: 29 * <pre> 30 * constructor -> initialize() -> start() -> stop() -> destroy() -> finalizer 31 * |<-----------------------| ^ 32 * | | 33 * V-----------------------------------> 34 * </pre> 35 * </p> 36 * <p/> 37 * The Module interface is intended to provide the simplest mechanism 38 * for creating, deploying, and managing server modules. 39 * </p> 40 * 41 * @author Iain Shigeoka 42 */ 43 public interface Module { 44 45 /** 46 * <p>Obtain the name of the module for display in administration interfaces.</p> 47 * 48 * @return The name of the module. 49 */ 50 String getName(); 51 52 /** 53 * Initialize the module with the container. 54 * Modules may be initialized and never started, so modules 55 * should be prepared for a call to destroy() to follow initialize(). 56 * 57 * @param server the server hosting this module. 58 */ 59 void initialize(XMPPServer server); 60 61 /** 62 * Start the module (must return quickly). Any long running 63 * operations should spawn a thread and allow the method to return 64 * immediately. 65 */ 66 void start(); 67 68 /** 69 * Stop the module. The module should attempt to free up threads 70 * and prepare for either another call to initialize (reconfigure the module) 71 * or for destruction. 72 */ 73 void stop(); 74 75 /** 76 * Module should free all resources and prepare for deallocation. 77 */ 78 void destroy(); 79 } 80