camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Strachan <james.strac...@gmail.com>
Subject Re: Endpoint construction
Date Thu, 28 Oct 2010 09:47:40 GMT
On 28 October 2010 10:25, Bruno Dusausoy <bdusausoy@yp5.be> wrote:
> On Thu, 28 Oct 2010 11:04:49 +0200, Claus Ibsen <claus.ibsen@gmail.com>
> wrote:
> [...]
>>
>> You could most likely use setEndpointUriIfNotSpecified to set a pseudo
>> id, to differentiate the 2 of them
>>
> Indeed, it works.
>
> I've searched the reason why it worked like this and found that the
> toString() method in DefaultEndpoint is :
>
>    @Override
>    public String toString() {
>        return "Endpoint[" + getEndpointUri() + "]";
>    }
>
>    public String getEndpointUri() {
>        if (endpointUri == null) {
>            endpointUri = createEndpointUri();
>            if (endpointUri == null) {
>                throw new IllegalArgumentException("endpointUri is not
> specified and " + getClass().getName()
>                        + " does not implement createEndpointUri() to
> create a default value");
>            }
>        }
>        return endpointUri;
>    }
>
> And in FileEndpoint :
>
>    @Override
>    protected String createEndpointUri() {
>        return "file://" + getFile().getAbsolutePath();
>    }
>
> So indeed, it creates the same endpoint URI for both.

BTW there's also a constructor for most Endpoints which let you pass
in a URI of your choosing.

-- 
James
-------
FuseSource
Email: james@fusesource.com
Web: http://fusesource.com
Twitter: jstrachan
Blog: http://macstrac.blogspot.com/

Open Source Integration

Mime
View raw message