You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Claus Ibsen <ci...@silverbullet.dk> on 2008/04/23 07:01:09 UTC

Mail component - what is this strange code doing (Sorry James the SVN annotations tells its you)

Hi

 

I am working on CAMEL-335 and digging into the mail component code to:

- improve the documentation

- improve the unit tests

- and improve the mail component itself with suggestions from Lars Heinemann who coded the mail component in ServiceMix

 

I am puzzled with this code

 

 

class MailConfiguration

method: configure

 

        // we can either be invoked with

        // mailto:address

        // or

        // smtp:user@host:port/name@address

 

        String fragment = uri.getFragment();

        if (fragment == null || fragment.length() == 0) {

            fragment = userInfo + "@" + host;

        } else {

            setFolderName(fragment);

        }

        setDestination(fragment);

 

 

1)

Why is uri fragments used for URI configuration of this component?

http://java.sun.com/j2se/1.5.0/docs/api/java/net/URI.html

 

According to http://java.sun.com/j2se/1.5.0/docs/api/java/net/URI.html the fragment is the part after the # 

Should we use fragments at all it seems confusing since the mail component is the only component in Camel that uses this.

 

 

2)

The comments above do not stand true. 

URI as "smtp:user@host:port/name@address" will not configure the destination as name@address.

And mailto using the fluent builder will not be recognized as the mail component so is the comment wrong?

 

3)

Why is the foldername set with the fragment part? This is really confusing?

Isn't folderName only used for polling? And it should be INBOX, DRAFTS or whatever the names can be?

 

 

I am included to rewrite this part of the configuration based on the stuff from ServiceMix but wanted to get a clue why the code is as it is.

 

 

 

 

 

 

Med venlig hilsen

 

Claus Ibsen

......................................

Silverbullet

Skovsgårdsvænget 21

8362 Hørning

Tlf. +45 2962 7576

Web: www.silverbullet.dk

 


Re: Mail component - what is this strange code doing (Sorry James the SVN annotations tells its you)

Posted by James Strachan <ja...@gmail.com>.
On 23/04/2008, Claus Ibsen <ci...@silverbullet.dk> wrote:
> Hi
>
>
>
>  I am working on CAMEL-335 and digging into the mail component code to:
>
>  - improve the documentation
>
>  - improve the unit tests
>
>  - and improve the mail component itself with suggestions from Lars Heinemann who coded the mail component in ServiceMix
>
>
>
>  I am puzzled with this code
>
>
>
>
>
>  class MailConfiguration
>
>  method: configure
>
>
>
>         // we can either be invoked with
>
>         // mailto:address
>
>         // or
>
>         // smtp:user@host:port/name@address
>
>
>
>         String fragment = uri.getFragment();
>
>         if (fragment == null || fragment.length() == 0) {
>
>             fragment = userInfo + "@" + host;
>
>         } else {
>
>             setFolderName(fragment);
>
>         }
>
>         setDestination(fragment);
>
>
>
>
>
>  1)
>
>  Why is uri fragments used for URI configuration of this component?
>
>  http://java.sun.com/j2se/1.5.0/docs/api/java/net/URI.html
>
>
>
>  According to http://java.sun.com/j2se/1.5.0/docs/api/java/net/URI.html the fragment is the part after the #

Doh! My bad :)

>  Should we use fragments at all it seems confusing since the mail component is the only component in Camel that uses this.

Yeah - I think I was thinking of the remaining part of the URI (the
bit after the colon)


>  2)
>
>  The comments above do not stand true.
>
>  URI as "smtp:user@host:port/name@address" will not configure the destination as name@address.
>
>  And mailto using the fluent builder will not be recognized as the mail component so is the comment wrong?

My bad. Currently the MailComponentTest only looks at configuring the
user/host/port etc on the component - not the destination


>  3)
>
>  Why is the foldername set with the fragment part? This is really confusing?
>
>  Isn't folderName only used for polling? And it should be INBOX, DRAFTS or whatever the names can be?


Yeah, the folderName is only used for polling AFAIK. Would it be less
confusing as a parameter?

>  I am included to rewrite this part of the configuration based on the stuff from ServiceMix but wanted to get a clue why the code is as it is.

Great stuff.

BTW another approach to simplify things is to just configure Endpoint
instances as beans (say in a Spring XML) as coming up with great URI
configurations is sometimes a little tricky :) But hopefully we can
nail the mail component so its got nicer URI handling. Sorry for my
lousy code :)

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com