Bug 52161 - Enable plugins to add own translation rules in addition to upgrade.properties
Summary: Enable plugins to add own translation rules in addition to upgrade.properties
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.5.1
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-09 13:50 UTC by stef
Modified: 2011-11-16 12:25 UTC (History)
2 users (show)



Attachments
NameUpdater update (2.55 KB, patch)
2011-11-11 08:22 UTC, stef
Details | Diff
New Interface to add to src/core/org/apache/jmeter/util (150 bytes, application/octet-stream)
2011-11-11 08:23 UTC, stef
Details
NameUpdater update (2.63 KB, patch)
2011-11-16 08:26 UTC, stef
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description stef 2011-11-09 13:50:47 UTC
Could it be possible to add this method in org.apache.jmeter.util.NameUpdater.java :

public static Object setProperty(String key, String value)  {
    return nameMap.setProperty(String key, String value);
}

This would allow plugins to add their own translation rules, without having to modify the properties file.

Stef
Comment 1 Sebb 2011-11-09 14:12:46 UTC
I don't think that is a good idea; the intention is for the namemap to be immutable once created.
Comment 2 stef 2011-11-09 15:01:35 UTC
(In reply to comment #1)
> I don't think that is a good idea; the intention is for the namemap to be
> immutable once created.

Yes I agree the existing implementation ensured that.
Could it be possible to add an additional map and to fetch data first look in namemap and if (and only if) not found look in the second one?

Stef
Comment 3 Sebb 2011-11-09 15:09:56 UTC
It would be better if the additional entries could be provided at class load time.
Comment 4 stef 2011-11-09 16:38:12 UTC
(In reply to comment #3)
> It would be better if the additional entries could be provided at class load
> time.

Yes that would be the ideal solution. Is it feasible?

Stef
Comment 5 stef 2011-11-11 08:22:04 UTC
Created attachment 27926 [details]
NameUpdater update

Load additional items to nameMap
Comment 6 stef 2011-11-11 08:23:45 UTC
Created attachment 27927 [details]
New Interface to add to src/core/org/apache/jmeter/util

Plugins need to implement this interface to add additional entries in nameMap
Comment 7 stef 2011-11-11 11:12:14 UTC
Hi Sebb,

Do you think this implementation could be he right approach?

Stef
Comment 8 Sebb 2011-11-11 12:54:54 UTC
(In reply to comment #7)
> Hi Sebb,
> 
> Do you think this implementation could be he right approach?
> 
> Stef

That would work, but it is quite involved. 

I was thinking more on the lines of reading an additional properties file, e.g. use ClassLoader#getResources(String name) to find all resources with a particular name, where the name is something like
META-INF/resources/org.apache.jmeter.nameupdater.properties

This would also be easier for the plugins to provide.
Comment 9 stef 2011-11-12 11:59:12 UTC
Yes that will be much simpler, I will look at this.

Stef
Comment 10 Philippe Mouawad 2011-11-12 15:15:01 UTC
*** Bug 29603 has been marked as a duplicate of this bug. ***
Comment 11 Sebb 2011-11-14 01:18:23 UTC
(In reply to comment #10)
> *** Bug 29603 has been marked as a duplicate of this bug. ***

Np longer marked as such. That is about messages.properties; this is about upgrade.properties.
Comment 12 stef 2011-11-16 08:25:28 UTC
(In reply to comment #8)

Hi Sebb,

Please find attached the patch following your recommendations.

Stef
Comment 13 stef 2011-11-16 08:26:57 UTC
Created attachment 27946 [details]
NameUpdater update

The new proposal using ClassLoader#getResources
Comment 14 Sebb 2011-11-16 12:25:30 UTC
Thanks!

Had to replace the stringPropertyNames() method call as that requires Java 1.6; JMeter still targets 1.5+. Also added a log message for each properties file found.


URL: http://svn.apache.org/viewvc?rev=1202658&view=rev
Log:
Bug 52161 - Enable plugins to add own translation rules in addition to upgrade.properties.

Modified:
   jmeter/trunk/src/core/org/apache/jmeter/util/NameUpdater.java
   jmeter/trunk/xdocs/changes.xml
Comment 15 The ASF infrastructure team 2022-09-24 20:37:48 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2642