Occasionally, your
components may also want to access the JBI bus directly at programming API-level,
and we can do that using the numerous APIs provided by ServiceMix and JBI.
POJO Binding Using JSR181
[ 174 ]
The preferred mechanism to access JBI from your component is to first get the
ComponentContext implementation and from there traverse the other JBI APIs.
serviceInterface="some.Interface">
Correspondingly, we will now have our Pojo (Oh, yes; our POJOs are getting
bulkier here!) class into which the JBI container can inject a reference of the
ComponentContext. The pojo class is reproduced in the following code:
public class Pojo
{
private javax.jbi.component.ComponentContext context;
public void setContext(javax.jbi.component.ComponentContext
context)
{
this.context = context;
}
}
ComponentContext is the JBI API using which we can access the underlying
DeliveryChannel. This is shown in the following code:
public interface ComponentContext
{
public DeliveryChannel getDeliveryChannel()throws
MessagingException;
}
DeliveryChannel can be used to send messages to the JBI bus.
Pages:
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252