You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Guillaume Nodet <gn...@gmail.com> on 2007/03/02 15:18:25 UTC

Creating dynamic http consumer endpoints

While your code snippet could work, it would cause problems
with classloaders, as the HttpEndpoint class will not be available
from another component classloader.

I would prefer a more JBI compliant approach of this.
See https://issues.apache.org/activemq/browse/SM-283
Some dicussions already took place, but no one took the lead
and did it.
See http://www.nabble.com/Dynamically-adding-and-removing-http-endpoints-tf1369390s12049.html#a3672868


On 3/2/07, Guillaume Nodet <gn...@gmail.com> wrote:
> Using servicemix trunk, you can now define
>
> public void setContainer(JBIContainer container) {
> }
>
> and a reference to the ServiceMix container will be injected.
>
> See http://issues.apache.org/activemq/browse/SM-858
>
> On 2/23/07, jmdev <jh...@yahoo.com> wrote:
> >
> > I am attempting to access the JBI Container within a JSR181 POJO as
> > documented on the site:
> >
> >
> >
> > > If you want to send a request to another service from your POJO, you can
> > > add the following method on your POJO:
> > >
> > > private javax.jbi.component.ComponentContext context;
> > >
> > > public void setContext(javax.jbi.component.ComponentContext context) {
> > >   this.context = context;
> > > }
> > >
> >
> > However, when I retrieve the context inside the POJO, it is of type
> > EndpointComponentContext, not ComponentContext.  As such I get a
> > ClassCastException when trying to cast it as indicated in this
> > documentation:
> >
> > http://incubator.apache.org/servicemix/how-can-i-access-the-jbicontainer-from-inside-a-component-.html
> >
> > Is there any way for me to get access to the container from within the
> > JSR181 endpoint?
> >
> > What follows is the ClassCastException:
> >
> >
> > : java.lang.ClassCastException:
> > org.apache.servicemix.common.EndpointComponentContext
> > at com.mystuff.MyServiceImpl.createEndpoint(MyServiceImpl.java:38)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> > at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > at java.lang.reflect.Method.invoke(Method.java:585)
> > at
> > org.codehaus.xfire.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:54)
> > at
> > org.codehaus.xfire.service.binding.ServiceInvocationHandler.sendMessage(ServiceInvocationHandler.java:271)
> > at
> > org.codehaus.xfire.service.binding.ServiceInvocationHandler$1.run(ServiceInvocationHandler.java:84)
> > at
> > org.codehaus.xfire.service.binding.ServiceInvocationHandler.execute(ServiceInvocationHandler.java:132)
> > at
> > org.codehaus.xfire.service.binding.ServiceInvocationHandler.invoke(ServiceInvocationHandler.java:107)
> > at
> > org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
> > at
> > org.codehaus.xfire.transport.DefaultEndpoint.onReceive(DefaultEndpoint.java:64)
> > at
> > org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38)
> > at
> > org.apache.servicemix.jsr181.Jsr181ExchangeProcessor.process(Jsr181ExchangeProcessor.java:110)
> > at
> > org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:489)
> > at
> > org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:441)
> > at
> > org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
> > at
> > org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:593)
> > at
> > org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:174)
> > at
> > org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:176)
> > at
> > org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
> > at
> > edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
> > at
> > edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
> > at java.lang.Thread.run(Thread.java:595)
> >
> >
> >
> > --
> > View this message in context: http://www.nabble.com/Error-Accessing-JBI-Container-from-JSR181-Component---Is-it-Possible--tf3281290s12049.html#a9126947
> > Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >
> >
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Architect, LogicBlaze (http://www.logicblaze.com/)
> Blog: http://gnodet.blogspot.com/
>


-- 
Cheers,
Guillaume Nodet
------------------------
Architect, LogicBlaze (http://www.logicblaze.com/)
Blog: http://gnodet.blogspot.com/

Re: Creating dynamic http consumer endpoints

Posted by Guillaume Nodet <gn...@gmail.com>.
Sorry, I meant to reply to
  http://www.nabble.com/forum/ViewPost.jtp?post=9269968&framed=y&skin=12049

On 3/2/07, Guillaume Nodet <gn...@gmail.com> wrote:
> While your code snippet could work, it would cause problems
> with classloaders, as the HttpEndpoint class will not be available
> from another component classloader.
>
> I would prefer a more JBI compliant approach of this.
> See https://issues.apache.org/activemq/browse/SM-283
> Some dicussions already took place, but no one took the lead
> and did it.
> See http://www.nabble.com/Dynamically-adding-and-removing-http-endpoints-tf1369390s12049.html#a3672868
>
>
> On 3/2/07, Guillaume Nodet <gn...@gmail.com> wrote:
> > Using servicemix trunk, you can now define
> >
> > public void setContainer(JBIContainer container) {
> > }
> >
> > and a reference to the ServiceMix container will be injected.
> >
> > See http://issues.apache.org/activemq/browse/SM-858
> >
> > On 2/23/07, jmdev <jh...@yahoo.com> wrote:
> > >
> > > I am attempting to access the JBI Container within a JSR181 POJO as
> > > documented on the site:
> > >
> > >
> > >
> > > > If you want to send a request to another service from your POJO, you can
> > > > add the following method on your POJO:
> > > >
> > > > private javax.jbi.component.ComponentContext context;
> > > >
> > > > public void setContext(javax.jbi.component.ComponentContext context) {
> > > >   this.context = context;
> > > > }
> > > >
> > >
> > > However, when I retrieve the context inside the POJO, it is of type
> > > EndpointComponentContext, not ComponentContext.  As such I get a
> > > ClassCastException when trying to cast it as indicated in this
> > > documentation:
> > >
> > > http://incubator.apache.org/servicemix/how-can-i-access-the-jbicontainer-from-inside-a-component-.html
> > >
> > > Is there any way for me to get access to the container from within the
> > > JSR181 endpoint?
> > >
> > > What follows is the ClassCastException:
> > >
> > >
> > > : java.lang.ClassCastException:
> > > org.apache.servicemix.common.EndpointComponentContext
> > > at com.mystuff.MyServiceImpl.createEndpoint(MyServiceImpl.java:38)
> > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > at
> > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> > > at
> > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > > at java.lang.reflect.Method.invoke(Method.java:585)
> > > at
> > > org.codehaus.xfire.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:54)
> > > at
> > > org.codehaus.xfire.service.binding.ServiceInvocationHandler.sendMessage(ServiceInvocationHandler.java:271)
> > > at
> > > org.codehaus.xfire.service.binding.ServiceInvocationHandler$1.run(ServiceInvocationHandler.java:84)
> > > at
> > > org.codehaus.xfire.service.binding.ServiceInvocationHandler.execute(ServiceInvocationHandler.java:132)
> > > at
> > > org.codehaus.xfire.service.binding.ServiceInvocationHandler.invoke(ServiceInvocationHandler.java:107)
> > > at
> > > org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
> > > at
> > > org.codehaus.xfire.transport.DefaultEndpoint.onReceive(DefaultEndpoint.java:64)
> > > at
> > > org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38)
> > > at
> > > org.apache.servicemix.jsr181.Jsr181ExchangeProcessor.process(Jsr181ExchangeProcessor.java:110)
> > > at
> > > org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:489)
> > > at
> > > org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:441)
> > > at
> > > org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
> > > at
> > > org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:593)
> > > at
> > > org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:174)
> > > at
> > > org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:176)
> > > at
> > > org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
> > > at
> > > edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
> > > at
> > > edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
> > > at java.lang.Thread.run(Thread.java:595)
> > >
> > >
> > >
> > > --
> > > View this message in context: http://www.nabble.com/Error-Accessing-JBI-Container-from-JSR181-Component---Is-it-Possible--tf3281290s12049.html#a9126947
> > > Sent from the ServiceMix - User mailing list archive at Nabble.com.
> > >
> > >
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> > ------------------------
> > Architect, LogicBlaze (http://www.logicblaze.com/)
> > Blog: http://gnodet.blogspot.com/
> >
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Architect, LogicBlaze (http://www.logicblaze.com/)
> Blog: http://gnodet.blogspot.com/
>


-- 
Cheers,
Guillaume Nodet
------------------------
Architect, LogicBlaze (http://www.logicblaze.com/)
Blog: http://gnodet.blogspot.com/