Re: [JMeter] evolution request - handle BeanDescriptor.hidden flag in JMeter
sebb <[email protected]> Wed, 9 Nov 2011 10:48:22 +0000
| Newsgroups | gmane.comp.jakarta.cactus.devel |
|---|---|
| Message-ID | <CAOGo0VYvudL168G5RwiW-C9GR43xDw571XVuSS-qifpEvwPcmA@mail.gmail.com> |
2011/11/9 St=E9phane Hoblingre <[email protected]>: > Thank you Sebb for your quick response! > > I know about not_in_menu configuration, but we would like to avoid JMeter > users to edit propertie file from JMeter to install the plugins. So this = is > why we would like to do it from the plugin code itself. I did the > modification in MenuFactory.java from trunk (r1199633), please find attac= hed > the patch / file. > > The modification is very light (in bold): > > if (name.endsWith("JMeterTreeNode") // $NON-NLS-1$ > =A0=A0=A0=A0=A0=A0=A0 || name.endsWith("TestBeanGUI")) {// $NON-NLS-1$ > =A0=A0=A0 continue;// Don't try to instantiate these > } > >>//Handle BeanDescriptor hidden property >>boolean isHiddenBean =3D false; > > JMeterGUIComponent item; > try { > =A0=A0=A0 Class<?> c =3D Class.forName(name); > =A0=A0=A0 if (TestBean.class.isAssignableFrom(c)) { > =A0=A0=A0=A0=A0=A0=A0 item =3D new TestBeanGUI(c); >>=A0=A0=A0=A0=A0=A0=A0 try { >> =A0=A0=A0=A0=A0=A0=A0=A0=A0 isHiddenBean =3D >> Introspector.getBeanInfo(c).getBeanDescriptor().isHidden(); >>=A0=A0=A0=A0=A0=A0=A0 } catch (IntrospectionException e) { >>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 log.warn("Cannot get bean info from cla= ss " + name + "."); >>=A0=A0=A0=A0=A0=A0=A0 } > > =A0=A0=A0 } else { > =A0=A0=A0=A0=A0=A0=A0 item =3D (JMeterGUIComponent) c.newInstance(); > =A0=A0=A0 } > } catch (NoClassDefFoundError e) { > =A0=A0=A0 log.warn("Missing jar? Could not create " + name + ". " + e); > =A0=A0=A0 continue; > } catch (Throwable e) { > =A0=A0=A0 log.warn("Could not instantiate " + name, e); > =A0=A0=A0 if (e instanceof Error){ > =A0=A0=A0=A0=A0=A0=A0 throw (Error) e; > =A0=A0=A0 } > =A0=A0=A0 if (e instanceof RuntimeException){ > =A0=A0=A0=A0=A0=A0=A0 throw (RuntimeException) e; > =A0=A0=A0 } > =A0=A0=A0 continue; > } >> if (elementsToSkip.contains(name) || >> elementsToSkip.contains(item.getStaticLabel()) || isHiddenBean) { > =A0=A0=A0 log.info("Skipping " + name); > =A0=A0=A0 continue; > } > > Could this be added in the next version of JMeter? If you provide a patch as a Bugzilla enhancement we will take a look. > Thanks, > > Stef > > On Wed, Nov 9, 2011 at 12:06 AM, sebb <[email protected]> wrote: >> >> 2011/11/8 St=E9phane Hoblingre <[email protected]>: >> > Dear JMeter dev team, >> > >> > I have an evolution request for JMeter which will help plugin >> > developers. >> > In our plugins, we implemented one component using TestBeans. We have >> > now >> > rewrote this component and use regular test elements, so we need to hi= de >> > the previous one from jmeter add menus (backward jmx compatibility). T= he >> > only way I found is very dirty, that is setting its name to null. But = in >> >> You can also edit the JMeter property: >> >> not_in_menu >> >> see jmeter.properties. >> >> You might also be able to make use of upgrade.properties and dispense >> with the old class altogether. >> >> > BeanDescriptor class, there is one attribute: >> > >> > isHidden >> > public boolean isHidden() >> > =A0 =A0The "hidden" flag is used to identify features that are intende= d only >> > for tool use, and which should not be exposed to humans. >> > >> > While building the add component menu, could you check the hidden flag >> > and >> > if true not add it in the menu? That would allow to plugin developers = to >> > hide properly it. >> > >> > Is it possible? Do you want me to open a bug for it? >> >> If it can be done without affecting the existing API, then I suppose >> it would be possible to interpret the isHidden() status as meaning >> that the TestBean is not added to the display. >> >> If you provide a patch as a Bugzilla enhancement we will take a look. >> >> > Thanks, >> > >> > Stef >> > JMeter Plugins - http://code.google.com/p/jmeter-plugins >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] >