001/* 002 * jPOS Project [http://jpos.org] 003 * Copyright (C) 2000-2026 jPOS Software SRL 004 * 005 * This program is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Affero General Public License as 007 * published by the Free Software Foundation, either version 3 of the 008 * License, or (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Affero General Public License for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License 016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 017 */ 018 019package org.jpos.q2; 020 021 022/** 023 * An interface describing a Q2 service MBean. 024 * 025 * @author <a href="mailto:apr@cs.com.uy">Alejandro P. Revilla</a> 026 * @author <a href="mailto:taherkordy@dpi2.dpi.net.ir">Alireza Taherkordi</a> 027 * @version $Revision$ $Date$ 028 * @see QPersist 029 */ 030public interface QBean { 031 032 // State 033 int STOPPED = 0; 034 int STOPPING = 1; 035 int STARTING = 2; 036 int STARTED = 3; 037 int FAILED = 4; 038 int DESTROYED = 5; 039 040 String stateString[] = { 041 "Stopped", "Stopping", "Starting", "Started", "Failed", "Destroyed" 042 }; 043 044 /** 045 * init the service 046 * @throws Exception on error 047 */ 048 void init () throws Exception; 049 050 /** 051 * start the service 052 * @throws Exception on error 053 */ 054 void start () throws Exception; 055 056 /** 057 * stop the service 058 * @throws Exception on error 059 */ 060 void stop () throws Exception; 061 062 /** 063 * destroy the service 064 * @throws Exception on error 065 */ 066 void destroy () throws Exception; 067 068 /** 069 * @return state (STARTING, STARTED, FAILED, DESTROYED ...) 070 */ 071 int getState (); 072 073 /** 074 * @return state (STARTING, STARTED, FAILED, DESTROYED ...) 075 */ 076 default String getStateAsString () { 077 return getState() >= 0 ? stateString[getState()] : "Unknown"; 078 } 079}