It's all about the answers!

Ask a question

help, access to configuration parameters across services


sam detweiler (12.5k6195201) | asked Sep 30 '11, 1:05 p.m.
I am working on enhancement 176360, email templates
https://jazz.net/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/176360

I added config parameters to the jts.mailer service plugin to define the location of the templates, and which template to be used for each function (mention, change, approval)..

I now need to access those parms from the code generating the mail text, but that code is running in a different 'service' (plugin) context..

is there any way to do this across plugins?

getStringConfigProperty("notification.mail.template.directory")

thanks for any guidance.

5 answers



permanent link
John Vasta (2.6k15) | answered Sep 30 '11, 3:20 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
I think the best approach would be to define accessor methods on the service that "owns" the configuration properties. Then other services can get a handle to the owning service (via AbstractService.getService()) and call the accessor methods to get property values.

I am working on enhancement 176360, email templates
https://jazz.net/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/176360

I added config parameters to the jts.mailer service plugin to define the location of the templates, and which template to be used for each function (mention, change, approval)..

I now need to access those parms from the code generating the mail text, but that code is running in a different 'service' (plugin) context..

is there any way to do this across plugins?

getStringConfigProperty("notification.mail.template.directory")

thanks for any guidance.

permanent link
sam detweiler (12.5k6195201) | answered Oct 01 '11, 8:58 a.m.
thanks.. I was 'hoping' that functionality already existed.

the message builder already does a getService() for the mailer, but accesses the Interface level class

	private IMailerService getMailerService() {

synchronized (this) {
if (fMailerService == null) {
fMailerService= getService(IMailerService.class);
}
return fMailerService;
}
}


course iMailerService doesn't have these accessor methods.. worried about changing the interface definition and having to recompile all those classes. easy for the dev team on a full release.

this should really be an AbstractService function.

permanent link
sam detweiler (12.5k6195201) | answered Oct 01 '11, 10:13 a.m.
so, continuing on..

I added a method to the IInternalMailerService in
com.ibm.team.repository.service.jts.mailer
and implemented in MailerService.

the IInternalmailerService was already exported in the plugin, and this is where the config parms are defined.

       <serviceProvider

componentId="com.ibm.team.repository"
implementationClass="com.ibm.team.repository.service.jts.internal.mailer.MailerService">
<provides>
<providedService
interface="com.ibm.team.repository.service.jts.internal.mailer.IInternalMailerService">
</providedService>

In the ChangeEventMailNotifier class
I added an import for the interface
and this code to connect and get the parm.
(added the service as a required service to plugin.xml)
		String templatePath="/jts/templates";

IInternalMailerService im = getService(IInternalMailerService.class);
if(im!=null)
{
templatePath=(String)im.getConfigProperty("notification.mail.template.directory");
}


the connect works, and the call to the service works.. BUT..

I get back the DEFAULT config parm value, not its CURRENT value.
                   <configurationProperty

accessPolicy="OPEN"
description="Mail template directory"
displayableName="Mail template directory"
name="notification.mail.template.directory"
required="true"
type="STRING"
default="conf/jts/templates"
updatePolicy="NO_RESTART_REQUIRED"/>

I have done this config parm service on another plugin which works correctly, both inside the server and from a client..

in the server admin panel it shows like this
Mail template directory 	/jts/templates

Default Value
conf/jts/templates


my getConfigProperty method hides the parm type details

	public Object getConfigProperty(String id)

{
Object x=null;

for(int l=0;l<4;l++)
{
try
{
switch (l)
{
case 0:
x =getStringConfigProperty(id);
break;
case 1:
x = getIntegerConfigProperty(id);
break;
case 2:
x = getLongConfigProperty(id);
break;
case 3:
x = getBooleanConfigProperty(id);
break;
}
}
catch (ClassCastException ex)
{
continue;
}
break;
}
return x;
}


what subtle difference did I miss?

permanent link
sam detweiler (12.5k6195201) | answered Oct 03 '11, 1:56 p.m.
Ok, the problem with the wrong config property value is caused by the fact that the *jts* plugins are also deployed in the CCM application, so getService(classname) is finding the one nearest to the caller.

com.ibm.team.repository.service.jts.mailer_3.0.1.v20110524_1821
is in ...../server/conf/ccm/sites/update-site/plugins altho its only used in Jts

hmmmm

Sam

permanent link
sam detweiler (12.5k6195201) | answered Oct 05 '11, 8:57 a.m.
bump.. anyone have any ideas?

my direct mail is the same userid, on gmail

Sam

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.