- How to initialize one tapestry5 service at startup? Use Eager Load for this. eg: bind(MyServiceInterface.class, MyServiceImpl.class).eagerLoad();
Pass the service through the contructor, which will prevent from getting null pointer exceptions.
3. How to use multiple versions of a same service concurrently?
Can be done by using withId and withMarker attributes.
eg:@Target(
{ PARAMETER, FIELD }) @Retention(RUNTIME) @Documented public @interface Clustered { } @Target( { PARAMETER, FIELD }) @Retention(RUNTIME) @Documented public @interface InProcess { } public class MyModule { public static void bind(ServiceBinder binder) { binder.bind(JobScheduler.class, ClusteredJobSchedulerImpl.class).withId("ClusteredJobScheduler").withMarker(Clustered.class); binder.bind(JobScheduler.class, SimpleJobSchedulerImpl.class).withId("InProcessJobScheduler").withMarker(InProcess.class); } }
No comments:
Post a Comment