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 038 @Override 039 public void exec(CLIContext ctx, String[] args) throws Exception { 040 final ObjectName on = new ObjectName("Q2:type=qbean,service=*"); 041 MBeanServer server = ctx.getCLI().getQ2().getMBeanServer(); 042 Set<ObjectInstance> b = server.queryMBeans(on, null); 043 Iterator<ObjectInstance> it = b.iterator(); 044 while (it.hasNext()) { 045 ObjectInstance instance = it.next(); 046 int status = (Integer) server.getAttribute(instance.getObjectName(), "State"); 047 if (status == QBean.STARTED) { 048 ctx.println(instance.getObjectName().getKeyProperty("service") + "\t\t" + instance.getClassName()); 049 } 050 051 } 052 053 } 054 055}