use of javax.management.NotCompliantMBeanException in project jdk8u_jdk by JetBrains.
the class MBeanAnalyzer method initMaps.
// Introspect the mbeanInterface and initialize this object's maps.
//
private void initMaps(Class<?> mbeanType, MBeanIntrospector<M> introspector) throws Exception {
final List<Method> methods1 = introspector.getMethods(mbeanType);
final List<Method> methods = eliminateCovariantMethods(methods1);
/* Run through the methods to detect inconsistencies and to enable
us to give getter and setter together to visitAttribute. */
for (Method m : methods) {
final String name = m.getName();
final int nParams = m.getParameterTypes().length;
final M cm = introspector.mFrom(m);
String attrName = "";
if (name.startsWith("get"))
attrName = name.substring(3);
else if (name.startsWith("is") && m.getReturnType() == boolean.class)
attrName = name.substring(2);
if (attrName.length() != 0 && nParams == 0 && m.getReturnType() != void.class) {
// It's a getter
// Check we don't have both isX and getX
AttrMethods<M> am = attrMap.get(attrName);
if (am == null)
am = new AttrMethods<M>();
else {
if (am.getter != null) {
final String msg = "Attribute " + attrName + " has more than one getter";
throw new NotCompliantMBeanException(msg);
}
}
am.getter = cm;
attrMap.put(attrName, am);
} else if (name.startsWith("set") && name.length() > 3 && nParams == 1 && m.getReturnType() == void.class) {
// It's a setter
attrName = name.substring(3);
AttrMethods<M> am = attrMap.get(attrName);
if (am == null)
am = new AttrMethods<M>();
else if (am.setter != null) {
final String msg = "Attribute " + attrName + " has more than one setter";
throw new NotCompliantMBeanException(msg);
}
am.setter = cm;
attrMap.put(attrName, am);
} else {
// It's an operation
List<M> cms = opMap.get(name);
if (cms == null)
cms = newList();
cms.add(cm);
opMap.put(name, cms);
}
}
/* Check that getters and setters are consistent. */
for (Map.Entry<String, AttrMethods<M>> entry : attrMap.entrySet()) {
AttrMethods<M> am = entry.getValue();
if (!introspector.consistent(am.getter, am.setter)) {
final String msg = "Getter and setter for " + entry.getKey() + " have inconsistent types";
throw new NotCompliantMBeanException(msg);
}
}
}
use of javax.management.NotCompliantMBeanException in project smscgateway by RestComm.
the class HttpUsersManagement method registerHttpUserMbean.
private void registerHttpUserMbean(HttpUser httpUser) {
try {
ObjectName httpUserObjNname = new ObjectName(SmscManagement.JMX_DOMAIN + ":layer=HttpUser,name=" + httpUser.getUserName());
StandardMBean httpUserMxBean = new StandardMBean(httpUser, HttpUserMBean.class, true);
if (this.mbeanServer != null)
this.mbeanServer.registerMBean(httpUserMxBean, httpUserObjNname);
} catch (InstanceAlreadyExistsException e) {
logger.error(String.format("Error while registering MBean for HttpUser %s", httpUser.getUserName()), e);
} catch (MBeanRegistrationException e) {
logger.error(String.format("Error while registering MBean for HttpUser %s", httpUser.getUserName()), e);
} catch (NotCompliantMBeanException e) {
logger.error(String.format("Error while registering MBean for HttpUser %s", httpUser.getUserName()), e);
} catch (MalformedObjectNameException e) {
logger.error(String.format("Error while registering MBean for HttpUser %s", httpUser.getUserName()), e);
}
}
use of javax.management.NotCompliantMBeanException in project jspwiki by apache.
the class DefaultAdminBeanManager method reload.
// FIXME: Should unload the beans first.
private void reload() {
m_allBeans = new ArrayList<AdminBean>();
try {
registerAdminBean(new CoreBean(m_engine));
registerAdminBean(new UserBean(m_engine));
registerAdminBean(new SearchManagerBean(m_engine));
registerAdminBean(new PluginBean(m_engine));
registerAdminBean(new FilterBean(m_engine));
} catch (NotCompliantMBeanException e) {
log.error(e.getMessage(), e);
}
registerBeans(m_engine.getEditorManager().modules());
registerBeans(m_engine.getPluginManager().modules());
registerBeans(m_engine.getFilterManager().modules());
}
use of javax.management.NotCompliantMBeanException in project controller by opendaylight.
the class AbstractMXBean method registerMBean.
/**
* Registers this bean with the platform MBean server with the domain defined by
* {@link #BASE_JMX_PREFIX}.
*
* @return true is successfully registered, false otherwise.
*/
public boolean registerMBean() {
boolean registered = false;
try {
// Object to identify MBean
final ObjectName mbeanName = this.getMBeanObjectName();
LOG.debug("Register MBean {}", mbeanName);
// unregistered if already registered
if (server.isRegistered(mbeanName)) {
LOG.debug("MBean {} found to be already registered", mbeanName);
try {
unregisterMBean(mbeanName);
} catch (MBeanRegistrationException | InstanceNotFoundException e) {
LOG.warn("unregister mbean {} resulted in exception {} ", mbeanName, e);
}
}
server.registerMBean(this, mbeanName);
registered = true;
LOG.debug("MBean {} registered successfully", mbeanName.getCanonicalName());
} catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException | MalformedObjectNameException e) {
LOG.error("registration failed {}", e);
}
return registered;
}
use of javax.management.NotCompliantMBeanException in project wicket by apache.
the class Initializer method init.
@Override
public void init(final org.apache.wicket.Application application) {
try {
String name = application.getName();
String agentId = null;
try {
agentId = System.getProperty("wicket.mbean.server.agentid");
} catch (SecurityException e) {
// Ignore - we're not allowed to read this property.
log.warn("not allowed to read property wicket.mbean.server.agentid due to security settings; ignoring");
}
if (agentId != null) {
ArrayList<MBeanServer> mbeanServers = MBeanServerFactory.findMBeanServer(agentId);
if (!mbeanServers.isEmpty()) {
// get first
mbeanServer = mbeanServers.get(0);
} else {
log.error("unable to find mbean server with agent id " + agentId);
}
}
if (mbeanServer == null) {
String impl = null;
try {
impl = System.getProperty("wicket.mbean.server.class");
} catch (SecurityException e) {
// Ignore - we're not allowed to read this property.
log.warn("not allowed to read property wicket.mbean.server.class due to security settings; ignoring");
}
if (impl != null) {
ArrayList<MBeanServer> mbeanServers = MBeanServerFactory.findMBeanServer(null);
if (!mbeanServers.isEmpty()) {
for (MBeanServer mbs : mbeanServers) {
if (mbs.getClass().getName().equals(impl)) {
mbeanServer = mbs;
break;
}
}
}
if (mbeanServer == null) {
log.error("unable to find mbean server of type '{}'", impl);
}
}
}
if (mbeanServer == null) {
mbeanServer = ManagementFactory.getPlatformMBeanServer();
// never null
}
log.info("registering Wicket mbeans with server '{}'", mbeanServer);
// register top level application object, but first check whether
// multiple instances of the same application (name) are running and
// if so adjust the name
String domain = "org.apache.wicket.app." + name;
ObjectName appBeanName = new ObjectName(domain + ":type=Application");
String tempDomain = domain;
int i = 0;
while (mbeanServer.isRegistered(appBeanName)) {
tempDomain = name + "-" + i++;
appBeanName = new ObjectName(tempDomain + ":type=Application");
}
domain = tempDomain;
Application appBean = new Application(application);
register(application, appBean, appBeanName);
register(application, new ApplicationSettings(application), new ObjectName(domain + ":type=Application,name=ApplicationSettings"));
register(application, new DebugSettings(application), new ObjectName(domain + ":type=Application,name=DebugSettings"));
register(application, new MarkupSettings(application), new ObjectName(domain + ":type=Application,name=MarkupSettings"));
register(application, new ResourceSettings(application), new ObjectName(domain + ":type=Application,name=ResourceSettings"));
register(application, new PageSettings(application), new ObjectName(domain + ":type=Application,name=PageSettings"));
register(application, new RequestCycleSettings(application), new ObjectName(domain + ":type=Application,name=RequestCycleSettings"));
register(application, new SecuritySettings(application), new ObjectName(domain + ":type=Application,name=SecuritySettings"));
register(application, new SessionSettings(application), new ObjectName(domain + ":type=Application,name=SessionSettings"));
register(application, new StoreSettings(application), new ObjectName(domain + ":type=Application,name=StoreSettings"));
RequestLogger sessionsBean = new RequestLogger(application);
ObjectName sessionsBeanName = new ObjectName(domain + ":type=RequestLogger");
register(application, sessionsBean, sessionsBeanName);
} catch (MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) {
throw new WicketRuntimeException(e);
}
}
Aggregations