/** * Create, register, and return an MBean for this * <code>ContextResource</code> object. * * @param resource The ContextResource to be managed * @return a new MBean * @exception Exception if an MBean cannot be created or registered */ public static DynamicMBean createMBean(ContextResource resource) throws Exception { String mname = createManagedName(resource); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { Exception e = new Exception("ManagedBean is not found with "+mname); throw new MBeanException(e); } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); DynamicMBean mbean = managed.createMBean(resource); ObjectName oname = createObjectName(domain, resource); if( mserver.isRegistered( oname )) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); return mbean; }
public static ManagedBean test = new ManagedBean() { @Override public String name() { return "test"; } @Override public boolean eager() { return false; } @Override public Class<? extends Annotation> annotationType() { return ManagedBean.class; } };
AttributeInfo attrs[] = getAttributes(); MBeanAttributeInfo attributes[] = new MBeanAttributeInfo[attrs.length]; attributes[i] = attrs[i].createAttributeInfo(); OperationInfo opers[] = getOperations(); MBeanOperationInfo operations[] = new MBeanOperationInfo[opers.length]; NotificationInfo notifs[] = getNotifications(); MBeanNotificationInfo notifications[] = new MBeanNotificationInfo[notifs.length]; info = new MBeanInfo(getClassName(), getDescription(), attributes, new MBeanConstructorInfo[] {},
Class realClass, String type) ManagedBean mbean= new ManagedBean(); ai.setWriteable(false); if( sm!=null || gm!=null ) mbean.addAttribute(ai); op.addParameter(pi); mbean.addOperation(op); } else { log.error("Null arg " + name + " " + m ); mbean.setName( type );
ManagedBean managed=new ManagedBean(); DomUtil.setAttributes(managed, mbeanN); Node firstN; managed.addAttribute( ai ); if (log.isTraceEnabled()) { log.trace("Create attribute " + ai); managed.addNotification( ni ); if (log.isTraceEnabled()) { log.trace("Created notification " + ni); managed.addOperation( oi ); if( log.isTraceEnabled()) { log.trace("Create operation " + oi);
ManagedBean managed=new ManagedBean(); DomUtil.setAttributes(managed, mbeanN); Node firstN; managed.addAttribute( ci );
/** * Create and return a <code>ModelMBean</code> that has been * preconfigured with the <code>ModelMBeanInfo</code> information * for this managed bean, but is not associated with any particular * managed resource. The returned <code>ModelMBean</code> will * <strong>NOT</strong> have been registered with our * <code>MBeanServer</code>. * * @exception InstanceNotFoundException if the managed resource * object cannot be found * @exception javax.management.modelmbean.InvalidTargetObjectTypeException * if our MBean cannot handle object references (should never happen) * @exception MBeanException if a problem occurs instantiating the * <code>ModelMBean</code> instance * @exception RuntimeOperationsException if a JMX runtime error occurs */ public DynamicMBean createMBean() throws InstanceNotFoundException, MBeanException, RuntimeOperationsException { return (createMBean(null)); }
/** * @return the MBean Names of all authorized roles for this group. */ public String[] getRoles() { Group group = (Group) this.resource; List<String> results = new ArrayList<>(); Iterator<Role> roles = group.getRoles(); while (roles.hasNext()) { Role role = null; try { role = roles.next(); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), role); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException( "Cannot create object name for role " + role); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
/** Constructor. Will add default attributes. * */ public ManagedBean() { AttributeInfo ai=new AttributeInfo(); ai.setName("modelerType"); ai.setDescription("Type of the modeled resource. Can be set only once"); ai.setType("java.lang.String"); ai.setWriteable(false); addAttribute(ai); }
Method m=managedBean.getGetter(name, this, resource); Object result = null; try {
Method method= managedBean.getInvoke(name, params, signature, this, resource);
if(getClassName().equals(BASE_MBEAN)) { Exception ex = null; try { clazz = Class.forName(getClassName()); } catch (Exception e) { ClassLoader cl= Thread.currentThread().getContextClassLoader(); if ( cl != null) clazz= cl.loadClass(getClassName()); } catch (Exception e) { ex=e; (ex, "Cannot load ModelMBean class " + getClassName()); throw new MBeanException (e, "Cannot instantiate ModelMBean of class " + getClassName());
Class<?> realClass, String type) ManagedBean mbean= new ManagedBean(); ai.setWriteable(false); if( sm!=null || gm!=null ) mbean.addAttribute(ai); op.addParameter(pi); mbean.addOperation(op); } else { log.error("Null arg " + name + " " + m ); mbean.setName( type );
ManagedBean managed=new ManagedBean(); DomUtil.setAttributes(managed, mbeanN); Node firstN; managed.addAttribute( ai ); if (log.isTraceEnabled()) { log.trace("Create attribute " + ai); managed.addNotification( ni ); if (log.isTraceEnabled()) { log.trace("Created notification " + ni); managed.addOperation( oi ); if( log.isTraceEnabled()) { log.trace("Create operation " + oi);
ManagedBean managed=new ManagedBean(); DomUtil.setAttributes(managed, mbeanN); Node firstN; managed.addAttribute( ci );
/** * Create and return a <code>ModelMBean</code> that has been * preconfigured with the <code>ModelMBeanInfo</code> information * for this managed bean, but is not associated with any particular * managed resource. The returned <code>ModelMBean</code> will * <strong>NOT</strong> have been registered with our * <code>MBeanServer</code>. * * @exception InstanceNotFoundException if the managed resource * object cannot be found * @exception javax.management.modelmbean.InvalidTargetObjectTypeException * if our MBean cannot handle object references (should never happen) * @exception MBeanException if a problem occurs instantiating the * <code>ModelMBean</code> instance * @exception RuntimeOperationsException if a JMX runtime error occurs */ public DynamicMBean createMBean() throws InstanceNotFoundException, MBeanException, RuntimeOperationsException { return (createMBean(null)); }
/** * @return the MBean Names of all users that are members of this group. */ public String[] getUsers() { Group group = (Group) this.resource; List<String> results = new ArrayList<>(); Iterator<User> users = group.getUsers(); while (users.hasNext()) { User user = null; try { user = users.next(); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), user); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException( "Cannot create object name for user " + user); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
/** Constructor. Will add default attributes. * */ public ManagedBean() { AttributeInfo ai=new AttributeInfo(); ai.setName("modelerType"); ai.setDescription("Type of the modeled resource. Can be set only once"); ai.setType("java.lang.String"); ai.setWriteable(false); addAttribute(ai); }
Method m=managedBean.getGetter(name, this, resource); Object result = null; try {
Method method= managedBean.getInvoke(name, params, signature, this, resource);