Hello,

I am currently using this capability.  It did take me a few times to get it
working but it is working.

Here is parts of my code



>       private javax.jbi.component.ComponentContext context;
> 
>       //
>       // jbi context
>       //
>       public void setContext(javax.jbi.component.ComponentContext context) {
>               this.context = context;
>               log.info(context);
>       }
> 

just as it is on the webpage

Then, I use it in the following statements so that I can create new messages
and introduce them into the  delivery channel.



> 
> private void someMethod(String event, Object payload) {
>               ServiceMixClient client = new ServiceMixClientFacade(context);
> 
>               QName service = new QName("someNamespace",
>                               "someServiceName", "somePrefix");
> 
>               EndpointResolver er = client.createResolverForService(service);
> 
>               InOnly exchange;
>               try {
>                       exchange = client.createInOnlyExchange(er);
>               } catch (JBIException e) {
>                       e.printStackTrace();
>                       throw new MessagingException(e);
>               }
> 
>               NormalizedMessage msg = exchange.getMessage("in");
> 
>               msg.setContent(new XStreamSource(event));
> 
>               msg.setProperty("event", event);
>               msg.setProperty("msgId", msgId);
>               msg.setProperty("operatingData", operatingData);
> 
>               XStream xs = new XStream(new XStreamXppDriver());
>               String xml = xs.toXML(payload);
>               msg.setProperty("payloadXML", xml);
> 
>               client.sendSync(exchange);
> }
> 

then, in my jsr-181 xbean.xml definition I have



>       <jsr181:endpoint service="sm:JSR181-service"
>               annotations="jsr181" endpoint="JSR181-service-endpoint">
>               <jsr181:pojo>
>                       <bean
>                               class="HttpImpl">
>                               <property name="context" ref="context" />
>                       </bean>
>               </jsr181:pojo>
>       </jsr181:endpoint>
> 


I hope this helps.

James

-- 
View this message in context: 
http://www.nabble.com/Error-Accessing-JBI-Container-from-JSR181-Component---Is-it-Possible--tf3281290s12049.html#a9127513
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to