Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

help, access to configuration parameters across services

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.

0 votes



5 answers

Permanent link
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.

0 votes


Permanent link
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.

0 votes


Permanent link
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?

0 votes


Permanent link
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

0 votes


Permanent link
bump.. anyone have any ideas?

my direct mail is the same userid, on gmail

Sam

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,939

Question asked: Sep 30 '11, 1:05 p.m.

Question was seen: 5,483 times

Last updated: Sep 30 '11, 1:05 p.m.

Confirmation Cancel Confirm