You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by sebb <se...@gmail.com> on 2013/12/19 01:08:18 UTC

Re: creating a resource bundle for a custom jmeter listener

On 17 December 2013 01:12, saurabh gandotra
<sa...@hotmail.com> wrote:
> Hi All -
> I've created a custom JMeter listener however I'm having trouble creating a resource bundle for locale specific title / other label's.
> For eg:
> <code>public class CustomReport extends AbstractVisualizer implements Clearable, ActionListener, TableModelListener {....
> @Override    public String getLabelResource() {        return "custom_summary_report";  //$NON-NLS-1$    }
> </code>
>
> the method getLabelResource, uses JMeterUtils.getResString to read the locale specific resource located @  org / apache / jmeter / resources / messages.properties.
> If i append this property to the existing messages_X.properties , the title is set properly however, I want to be able to specify a custom property bundle and package it with the jar which contains the custom listener.
> Is there a way to override this behavior and provide my own properties file which gets appended to the existing?

You can override getStaticLabel()

Alternatively, recode as a TestBean and you can provide your own
properties file.

> Thanks,saurabh gandotra

Re: creating a resource bundle for a custom jmeter listener

Posted by Michael Lück <mi...@lueckonline.net>.
Hi,

we just wrote a custom resource loader which is basically an adopted 
ResourceLoader from JMeter. Additionally to the ressource key the 
ResourceLoader takes an Class Object as reference from which it takes 
the package name and uses that for the ResourceLoading.

With that we're able to put the properties in out jar package and don't 
need to manipulate the org.apache.jmeter.resource.message.properties.

It basically comes done to the line
     ResourceBundle bundle = 
ResourceBundle.getBundle(clazz.getCanonicalName() + "Resources");

where clazz is the parameter of type "Class<?>".

For example for class "org.example.MySamplerGui" you need to create the 
File "MySamplerGuiResources.properties" under the path "org/example"

Hoping this will help,
Michael

Am 27.02.2014 00:38, schrieb Zhaoxia Yang:
> I also have similar issue. Except TestBean framework, Can I do as below work to define my properties file for my GUI labels?
> Add my own ResourceBundleManager;
> Then register it as a Jmeter's LocaleChangeListener. JMeterUtils.addLocaleChangeListener(…).
> Thus, Once the JMeter global Locale changes, my ResourceBundleManager can react accordingly.
> Is this feasible? Looks like it's a easier way than recoding to TestBean.
>
> Thanks.
> Zhaoxia Yang
>
> On 19/12/2013, at 11:08 AM, sebb <se...@gmail.com> wrote:
>
>> On 17 December 2013 01:12, saurabh gandotra
>> <sa...@hotmail.com> wrote:
>>> Hi All -
>>> I've created a custom JMeter listener however I'm having trouble creating a resource bundle for locale specific title / other label's.
>>> For eg:
>>> <code>public class CustomReport extends AbstractVisualizer implements Clearable, ActionListener, TableModelListener {....
>>> @Override    public String getLabelResource() {        return "custom_summary_report";  //$NON-NLS-1$    }
>>> </code>
>>>
>>> the method getLabelResource, uses JMeterUtils.getResString to read the locale specific resource located @  org / apache / jmeter / resources / messages.properties.
>>> If i append this property to the existing messages_X.properties , the title is set properly however, I want to be able to specify a custom property bundle and package it with the jar which contains the custom listener.
>>> Is there a way to override this behavior and provide my own properties file which gets appended to the existing?
>> You can override getStaticLabel()
>>
>> Alternatively, recode as a TestBean and you can provide your own
>> properties file.
>>
>>> Thanks,saurabh gandotra
>



Re: creating a resource bundle for a custom jmeter listener

Posted by Zhaoxia Yang <ya...@gmail.com>.
I also have similar issue. Except TestBean framework, Can I do as below work to define my properties file for my GUI labels?
Add my own ResourceBundleManager;
Then register it as a Jmeter's LocaleChangeListener. JMeterUtils.addLocaleChangeListener(…). 
Thus, Once the JMeter global Locale changes, my ResourceBundleManager can react accordingly.
Is this feasible? Looks like it's a easier way than recoding to TestBean.

Thanks.
Zhaoxia Yang

On 19/12/2013, at 11:08 AM, sebb <se...@gmail.com> wrote:

> On 17 December 2013 01:12, saurabh gandotra
> <sa...@hotmail.com> wrote:
>> Hi All -
>> I've created a custom JMeter listener however I'm having trouble creating a resource bundle for locale specific title / other label's.
>> For eg:
>> <code>public class CustomReport extends AbstractVisualizer implements Clearable, ActionListener, TableModelListener {....
>> @Override    public String getLabelResource() {        return "custom_summary_report";  //$NON-NLS-1$    }
>> </code>
>> 
>> the method getLabelResource, uses JMeterUtils.getResString to read the locale specific resource located @  org / apache / jmeter / resources / messages.properties.
>> If i append this property to the existing messages_X.properties , the title is set properly however, I want to be able to specify a custom property bundle and package it with the jar which contains the custom listener.
>> Is there a way to override this behavior and provide my own properties file which gets appended to the existing?
> 
> You can override getStaticLabel()
> 
> Alternatively, recode as a TestBean and you can provide your own
> properties file.
> 
>> Thanks,saurabh gandotra