You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Steve973 <st...@gmail.com> on 2012/04/07 06:21:25 UTC
Mina endpoint getEndpointUri() results in error?
Due to a design consideration, we are creating endpoints by using a factory.
A client specifies the type of endpoint it wants by submitting a
configuration, but as the server, we want to be able to control what
resources we provide and how we provide them.
In the case of our Mina endpoints, we use a MinaConfiguration and then we
create an endpoint from the resultant component, much like they show in the
"Factory Approach" at http://camel.apache.org/mina.html but by using Java
instead of XML. At this point, we want to send a message to our client's
endpoint to inform them about the endpoint we have created for them.
However, when I try to do that with a MinaEndpoint, instead of providing me
with a URI that describes the configuration that I used to create the
endpoint, it gives me an error complaining that the URI wasn't set, and that
MinaEndpoint does not implement the method that creates a default URI.
How can I get this URI to send to the client? Thanks in advance.
--
View this message in context: http://camel.465427.n5.nabble.com/Mina-endpoint-getEndpointUri-results-in-error-tp5624093p5624093.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Mina endpoint getEndpointUri() results in error?
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
If you use Spring then you can register your codec in Spring registry
in the XML file
<bean id="myCodec" class="com.foo.MyCodec"/>
And then yes you can refer to that from the Camel mina endpoint using
the # lookup.
On Sat, Apr 7, 2012 at 6:28 PM, Steve973 <st...@gmail.com> wrote:
> I think I may have found the answer, so please correct me if I am wrong.
> Should I register a bean definition created from the codec instance into the
> context, and then refer to it by the name it is registered under? Something
> like:
>
> DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory)
> applicationContext.getBeanFactory();
> beanFactory.registerBeanDefinition("myCodec",
> BeanDefinitionBuilder.rootBeanDefinition(MyCodec.class.getName()).getBeanDefinition());
>
> Then, I would create my URI like:
> "mina:tcp://localhost:18001?codec=#myCodec" if I understand correctly.
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Mina-endpoint-getEndpointUri-results-in-error-tp5624093p5624817.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Mina endpoint getEndpointUri() results in error?
Posted by Steve973 <st...@gmail.com>.
I think I may have found the answer, so please correct me if I am wrong.
Should I register a bean definition created from the codec instance into the
context, and then refer to it by the name it is registered under? Something
like:
DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory)
applicationContext.getBeanFactory();
beanFactory.registerBeanDefinition("myCodec",
BeanDefinitionBuilder.rootBeanDefinition(MyCodec.class.getName()).getBeanDefinition());
Then, I would create my URI like:
"mina:tcp://localhost:18001?codec=#myCodec" if I understand correctly.
--
View this message in context: http://camel.465427.n5.nabble.com/Mina-endpoint-getEndpointUri-results-in-error-tp5624093p5624817.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Mina endpoint getEndpointUri() results in error?
Posted by Steve973 <st...@gmail.com>.
Thanks for the reply. How do you specify the URI for a Mina endpoint when
you might not know the coded that you're using until runtime? If you
already know the coded and you specify it as a spring bean, you can just
specify it like #codecBeanName. Is there another way to do it?
--
View this message in context: http://camel.465427.n5.nabble.com/Mina-endpoint-getEndpointUri-results-in-error-tp5624093p5624779.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Mina endpoint getEndpointUri() results in error?
Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Apr 7, 2012 at 6:21 AM, Steve973 <st...@gmail.com> wrote:
> Due to a design consideration, we are creating endpoints by using a factory.
> A client specifies the type of endpoint it wants by submitting a
> configuration, but as the server, we want to be able to control what
> resources we provide and how we provide them.
>
> In the case of our Mina endpoints, we use a MinaConfiguration and then we
> create an endpoint from the resultant component, much like they show in the
> "Factory Approach" at http://camel.apache.org/mina.html but by using Java
> instead of XML. At this point, we want to send a message to our client's
> endpoint to inform them about the endpoint we have created for them.
> However, when I try to do that with a MinaEndpoint, instead of providing me
> with a URI that describes the configuration that I used to create the
> endpoint, it gives me an error complaining that the URI wasn't set, and that
> MinaEndpoint does not implement the method that creates a default URI.
>
> How can I get this URI to send to the client? Thanks in advance.
>
When you create endpoint manually then some endpoints cannot compute
their uri automatically if not provided. Then you need to manually do
this using the setEndpointUriIfNotSpecified method.
> --
> View this message in context: http://camel.465427.n5.nabble.com/Mina-endpoint-getEndpointUri-results-in-error-tp5624093p5624093.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/