I am trying to follow the tutorial at
http://docs.codehaus.org/display/SM/Spring+Client+Toolkit
I got almost everything fixed but have 2 problems/questions.
1. When I run everything seems to get deployed correctly but the timer
component is not able to find the logger component. I cannot figure out
what is wrong. This is the code for timer component and logger component.
public class TimerComponent extends TimerTask implements
ServiceLifeCycleImplementation {
TimerComponent
==============
private Timer timer;
private ServiceContext serviceContext;
.........
.........
public void run() {
try {
InOnly inOnly = serviceContext.createInOnly(
new QName("http://tempuri.org/logger", "log"));
if(inOnly == null)
{
System.out.println("inOnly is NULLLLLLLLL");
}
NormalizedMessage message = inOnly.createMessage();
message.setContent(new StreamSource(new StringReader(
"<hello>world</hello>")));
serviceContext.done(inOnly);
} catch (MessagingException e) {
e.printStackTrace();
}
}
LoggerComponent
===============
package org.servicemix.tutorial;
public class LoggerComponent implements ServiceInterfaceImplementation {
public QName getInterfaceName() {
return new QName("http://tempuri.org/logger", "log");
}
...................
...................
}
When I try to start servicemix (version 1.0.1) I get following error:
inOnly is NULLLLLLLLL
Exception in thread "Timer-3" java.lang.NullPointerException
at
org.servicemix.tutorial.TimerComponent.run(TimerComponent.java:48)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
I will keep checking the config files etc but if somebody knows where to
look that will be helpful.
2. The second problem is that at conceptual level this seems wrong to
me. Here the timer component has HARDCODED next component where the
message is supposed to go. This is very inflexible. Shouldnt't the next
component be dictated dynamically? So basically in a running system when
I want to add an interceptor between timer and logging component, I will
need to change the code and redeploy? This sounds really wrong. I am
sure I have it all wrong, isnt it? Can somebody explain?
Thanks
Ravi