Hi, Luciano.
1) Did you use the Tuscany launcher to run your class? The launcher will
bootstrap the Tuscany runtime then CurrentCompositeContext.getContext() will
return an non-null instance.
2) With @Context annoation, the Tuscany runtime will inject the context to
the field and you don't have to call
"CurrentCompositeContext.getContext();".
Thanks,
Raymond
----- Original Message -----
From: "Luciano Resende" <[EMAIL PROTECTED]>
To: "tuscany-dev" <[email protected]>
Sent: Thursday, October 05, 2006 7:17 PM
Subject: Consuming simple SCA service
I have created a simple schedule service (SchedulerService interface and
SchedulerServiceImpl)...
And I was trying to build a simple java client to consume the service like
this :
public class SchedulerServiceClient {
@Context
CompositeContext compositeContext;
/**
* @param args
*/
public static void main(String[] args) {
try {
CompositeContext context =
CurrentCompositeContext.getContext();
SchedulerService schedulerService = context.locateService(
SchedulerService.class, "SchedulerServiceComponent");
String[] courseWeekdays = { "Mon", "Wed" };
Course course = new Course(courseWeekdays, "CSCI-E-280", new
Date(), new Date(), "Database course");
List scheduleDates = schedulerService.processCourseSchedule
(course);
Iterator scheduleIterator = scheduleDates.iterator();
while (scheduleIterator.hasNext()) {
Date d = (Date) scheduleIterator.next();
System.out.println(d.toString());
}
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
}
The issue is that i keep getting NPE trying to get a reference to
context...
Any ideas on what i'm doing wrong ? Should i be using it in a different
way
?
- Luciano
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]