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.cli.deploy; 020 021import javax.management.ObjectName; 022import org.jpos.q2.CLICommand; 023import org.jpos.q2.CLIContext; 024import org.jpos.q2.Q2; 025import org.jpos.q2.QBean; 026 027import java.util.Set; 028import java.util.Iterator; 029import javax.management.MBeanServer; 030import javax.management.ObjectInstance; 031/** 032* CLI implementation - Deploy subsystem 033* 034* @author Felipph Calado - luizfelipph@gmail.com 035*/ 036public class PS implements CLICommand { 037 /** Default constructor; no instance state to initialise. */ 038 public PS() {} 039 040 @Override 041 public void exec(CLIContext ctx, String[] args) throws Exception { 042 final ObjectName on = new ObjectName("Q2:type=qbean,service=*"); 043 MBeanServer server = ctx.getCLI().getQ2().getMBeanServer(); 044 Set<ObjectInstance> b = server.queryMBeans(on, null); 045 Iterator<ObjectInstance> it = b.iterator(); 046 while (it.hasNext()) { 047 ObjectInstance instance = it.next(); 048 int status = (Integer) server.getAttribute(instance.getObjectName(), "State"); 049 if (status == QBean.STARTED) { 050 ctx.println(instance.getObjectName().getKeyProperty("service") + "\t\t" + instance.getClassName()); 051 } 052 053 } 054 055 } 056 057}