Well I did it at last, got my hands wet with annotations.
Work being work we're still well stuck in the j2sdk1.4 era because of the stuff we don't have the balls to upgrade too quickly :-)
James being James we tend to stick like glue to the oldest JDK we can until we have a justification for requiring an upgrade, as opposed to just a half-arsed reason for it, which is what we usually manage.
So yesterday, after a few weeks of debate on the mailet-api@james list about how we would deal with satisfying mailets' dependance on arbitrary services, I had a go with annotations.
We'd originally toyed with the idea of the service location pattern using JNDI. I built a POC for that out of the Apache Directory naming stuff, which is pretty comprehensively top-notch in both the "it works" and "its easy" categories. But that really seemed to be a cop-out since James has long espoused IoC. So the feeling on the list which incidentally includes some non-james people interested in the API, was that dependance injection should be specified where possible in the API, and Annotations used to let the container know what the Mailet is expecting.
Working on a sandbox fork of James, which I'm doing so I can get away with this stuff *and* let other people see it before I accidentally delete it, I created a custom annotation type and annotated a mutator ("setter").
The idea being that, in this case, the annotation would contain a String name parameter of a pre-configured datasource (javax.sql.Datasource) and on finding the annotation James' mailet loader would lookup the service (in this case in the JNDI context as it happens) and inject it into the mailet by calling the annotated method.
Although I did it with DataSource's which aren't quite the same as Services will be, it was relatively easy to programme James to sort this stuff out, and extremely nice and easy to annotate the method.
Whats more, and this is the big selling point for me, it worked first time.
I know it counts for nothing but it output this reassuring message to the console...
ToRepository Mailet requires datasource maildb
maildb is org.apache.james.util.dbcp.JdbcDataSource@652552
mailet got datasource :-) org.apache.james.util.dbcp.JdbcDataSource@652552
So now, having proven it, I guess I have to get to grips with the niceties of Annotations and design the annotations we want to use.
Danny Angus
blog.killerbees.co.uk
Labels
Passim
-
▼
2007
(174)
-
▼
January
(23)
- ApacheconEU07
- The past is another country; but you can see it fr...
- Criteria for judging proposed "solutions" to the p...
- Is spam going to kill SMTP?
- jSPF passes all the tests
- Mailet API getting some independance
- 123 - I love you
- Consumer hell
- Batman!
- labels and post by email
- USB Turntable
- .. and finally ... how I got it all together (or w...
- Demolition III
- ... From my phone, at last!
- blog by mail from my mobile
- New address same old nonsense
- Mailet Annotations - Proof of concept.
- VERP, Mailet, and James
- More Uninformative Exceptions (in the sense of mo...
- I want a phoney Phd
- ClassCastException - why so coy?
- Did I ever do that? How about searchable commit me...
- Apache James at Apachecon EU 2007 ?
-
▼
January
(23)
Tuesday, January 09, 2007
Mailet Annotations - Proof of concept.
Further Reading
-
Is Verisign a monopoly? Does it matter? - Senator Elizabeth Warren and Rep. Jerry Nadler recently wrote a latter complaining that VeriSign overcharges for for .com domains due to its market power...4 weeks ago
-
[ANNOUNCE] Apache NetBeans 18 Released - The Apache NetBeans team is pleased to announce that Apache NetBeans 18 was released on May 30, 2023. What's in the Apache NetBeans 18 release: https://...1 year ago
-
-
ApacheCon Europe 2019 – Day 1 - Plain Schwarz has added a photo to the pool: [image: ApacheCon Europe 2019 – Day 1] Day one of #ACEU19 kicked-off with a Barcamp and a couple of exciting...5 years ago
-
-
Export to JSON from MySQL All Ready for MongoDB - This post walks through how to export data from MySQL® into JSON format, ready to ingest into MongoDB®. Starting from MySQL 5.7+, there is native support ...6 years ago
-
ApacheCon Seville 2016 – Building a Container Solution on Top of Apache CloudStack- Steve Roles - Building a Container Solution on Top of Apache CloudStack- Steve Roles Cloud native applications running in containerised environments look set to create a...7 years ago
-
Nóirín Plunkett - https://www.flickr.com/photos/robertburrelldonkin/5729816462 smiles and socks retreating in co. wicklow now empty whiskey and secrets bar camping in ox...9 years ago
-
Hello world! - Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!9 years ago
-
Debugging MySQL Slow Queries With Many Joins - This week I encountered an issue that I hadn’t seen in a while. The ORM in a CMS project that I work on automatically joins to many subclass tables, causin...11 years ago
-
You’re invited to help us celebrate an unlikely pairing in open source - We are just days away from reaching a significant milestone for our team and the open source and open standards communities: the first anniversary of Micro...11 years ago
-
Boat For Sale - Boat For Sale: Price: £150 Terms and Conditions Oracle reserve the right to alter the web price of this acticle even after purchase. Price does n...18 years ago
-
-
-
-
I know nothing, I'm not a fortune teller, and you'd be insane to think that I am. This disclaimer was cribbed from an email footer I once received. It is so ridiculous I had to have it for myself.
Statements in this blog that are not purely historical are forward-looking statements including, without limitation, statements regarding my expectations, objectives, anticipations, plans, hopes, beliefs, intentions or strategies regarding the future. Factors that could cause actual results to differ materially from the forward looking statements include risks and uncertainties such as any unforeseen event or any unforeseen system failures, and other risks. It is important to note that actual outcomes could differ materially from those in such forward-looking statements.
Danny Angus Copyright © 2006-2013 (OMG that's seven years of this nonsense)
Comments: