On 23/04/2008, Claus Ibsen <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED]:port/[EMAIL PROTECTED] > > > > 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:[EMAIL PROTECTED]:port/[EMAIL PROTECTED]" will not configure > the destination as [EMAIL PROTECTED] > > 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
