|
What this is
Other links
The source code
/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.j2ee.deployment.impl.ui;
import java.awt.event.ActionEvent;
import java.lang.reflect.Constructor;
import java.rmi.RemoteException;
import java.util.*;
import javax.management.*;
import javax.management.j2ee.Management;
import javax.management.j2ee.ListenerRegistration;
import javax.swing.AbstractAction;
import javax.swing.Action;
import org.openide.DialogDisplayer;
import org.openide.ErrorManager;
import org.openide.NotifyDescriptor;
import org.openide.NotifyDescriptor.Message;
import org.openide.nodes.Node.Cookie;
import org.openide.util.NbBundle;
import org.openide.util.HelpCtx;
import org.openide.nodes.*;
import org.openide.util.actions.Presenter;
import org.openide.awt.*;
import javax.swing.*;
import java.beans.PropertyDescriptor;
/**
*
* @author Nam Nguyen
*/
public class ManagedObject implements Cookie {
public static final String OP_START = "start";
public static final String OP_START_RECURSIVE = "startRecursive";
public static final String OP_STOP = "stop";
public static final String OP_RESTART = "restart";
public static final String OP_UNDEPLOY = "undeploy";
public static final String OP_REDEPLOY = "redeploy";
private MFolderNode parentFolder;
private Management mejb;
private ObjectName mobj;
private OperationAction[] expertActions;
private OperationAction[] standardActions;
/** Creates a new instance of ManagedObject */
public ManagedObject(Management mgmt, ObjectName obj) {
mejb = mgmt;
mobj = obj;
}
public ManagedObject(Management mgmt, ObjectName obj, MFolderNode parent) {
this(mgmt, obj);
parentFolder = parent;
}
public String getDisplayName() {
String name = mobj.getKeyProperty("name"); // NOI18N
if (name == null) {
// Tomcat loggers don't have name attribute
name = mobj.getKeyProperty("type"); // NOI18N
}
return name;
}
static final String EJB_MOD = "EJBModule";
static final String WEB_MOD = "WebModule";
static final String APPCLIENT_MOD = "AppClientModule";
static final String RAR_MOD = "ResourceAdapterModule";
static Set moduleTypes = new HashSet();
static {
moduleTypes.add(EJB_MOD);
moduleTypes.add(WEB_MOD);
moduleTypes.add(APPCLIENT_MOD);
moduleTypes.add(RAR_MOD);
}
static Map iconBases = null;
static Map getIconBases() {
if (iconBases == null) {
iconBases = new HashMap();
iconBases.put("J2EEApplication", "org/netbeans/modules/j2ee/deployment/impl/ui/resources/Application"); //NOI18N
iconBases.put(EJB_MOD, "org/netbeans/modules/j2ee/deployment/impl/ui/resources/EjbModule"); //NOI18N
iconBases.put(WEB_MOD, "org/netbeans/modules/j2ee/deployment/impl/ui/resources/WebModule"); //NOI18N
iconBases.put(APPCLIENT_MOD, "org/netbeans/modules/j2ee/deployment/impl/ui/resources/AppClient"); //NOI18N
iconBases.put(RAR_MOD,"org/netbeans/modules/j2ee/deployment/impl/ui/resources/Connector"); //NOI18N
iconBases.put("EntityBean","org/netbeans/modules/j2ee/deployment/impl/ui/resources/Ejb"); //NOI18N
iconBases.put("StatefulSessionBean","org/netbeans/modules/j2ee/deployment/impl/ui/resources/Ejb"); //NOI18N
iconBases.put("StatelessSessionBean","org/netbeans/modules/j2ee/deployment/impl/ui/resources/Ejb"); //NOI18N
iconBases.put("MessageDrivenBean","org/netbeans/modules/j2ee/deployment/impl/ui/resources/Ejb"); //NOI18N
iconBases.put("JDBCResource","org/netbeans/modules/j2ee/deployment/impl/ui/resources/J2eeResource"); //NOI18N
iconBases.put("JMSResource","org/netbeans/modules/j2ee/deployment/impl/ui/resources/J2eeResource"); //NOI18N
iconBases.put("JavaMailResource","org/netbeans/modules/j2ee/deployment/impl/ui/resources/J2eeResource"); //NOI18N
}
return iconBases;
}
public String getIconBase() {
String type = mobj.getKeyProperty("j2eeType"); //NOI18N
return (String) getIconBases().get(type);
}
Management getManagement() {
return mejb;
}
MBeanAttributeInfo[] getAttributes() throws IntrospectionException, InstanceNotFoundException, ReflectionException, RemoteException {
MBeanInfo info = mejb.getMBeanInfo(mobj);
return (info != null)? info.getAttributes(): new MBeanAttributeInfo [0];
}
AttributeList getAttributeList(String[] attributeNames) throws RemoteException, InstanceNotFoundException, ReflectionException {
return mejb.getAttributes(mobj, attributeNames);
}
/*PropertyDescriptor[] getPropertyDescriptors() {
MBeanInfo minfo = mejb.getMBeanInfo(mobj);
if (minfo instanceof BeanInfo) {
BeanInfo info = (BeanInfo) minfo;
return info.getPropertyDescriptors();
} else { //Convert attribute info into prop descriptor
MBeanAttributeInfo[] attrs = getAttributes();
PropertyDescriptor[] descs = new PropertyDescriptor[attrs.length];
for (int i=0; i |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.