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.
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
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.
thanks.. I was 'hoping' that functionality already existed.
the message builder already does a getService() for the mailer, but accesses the Interface level class
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.
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.
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.
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)
the connect works, and the call to the service works.. BUT..
I get back the DEFAULT config parm value, not its CURRENT value.
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
my getConfigProperty method hides the parm type details
what subtle difference did I miss?
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?
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
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