You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Marco Tedone <mt...@jemos.org> on 2003/05/10 14:53:21 UTC
Deploying a Mailet
Hi, I've got a couple of questions for the experts:
1) Does the MailAddress.getName() method returns mtedone from an email
address 'mtedone@foo.com' ?
2) Supposed I have got an XML configuration file to parse from within my
Mailet:
2a) Is it SAR-INF the best location to put it?
2b) Which string shall I specify to a Mailet as a path to that file?
3) Supposed I have got a Mailet ready to test, is it correct for the
deployment to do the following?
3a) Create a jar file with all the code
3b) Modify the config.xml to specify also the package of this new Mailet
3c) Place the XML configuration file under SAR-INF
Am I missing any step?
Regards,
Marco
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org
Re: Deploying a Mailet
Posted by Marco Tedone <mt...@jemos.org>.
>
> If you would like for me to provide you with a code outline, let me know.
>
> --- Noel
What does it mean?
--Marco
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: james-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org
RE: Deploying a Mailet
Posted by "Noel J. Bergman" <no...@devtech.com>.
> The design points behind my architecture were (because now I'm not so
sure)
> to create a structure in which to deliver a new Mailet as needed.
I can appreciate that intent, but I believe that you are going about it
solving it wrong.
For James v3 (maybe James v2), I have proposed that we add a class attribute
to the processor element. This would allow new processor types to be added
to the spool. Along with that change, we'd move some of the initialization
code from the spooler into the processor (you'd have to look at the code to
see what I mean). Once done, you could provide a processor class that
supported an API (perhaps keyed by JMX or even a custom mailet) that caused
it to reload its configuration.
But I don't believe that it makes sense to build the entire infrastructure
inside a mailet just because you want to support dynamic reconfiguration.
> utility methods (like getting a MailServer, group the common activity
> done in the init() method
Utility methods are good, but in the long run we don't want to get the
MailServer. We do that now only because of lacks in the Mailet environment.
>> - Spooler: manages flow of messages through message processors
>> - Processor: addressable set message processing instructions
>> A Mailet Processor manages the flow of messages
>> through its matchers and mailets
>> - Matcher: returns a collection of matching message recipients
>> - Mailet: processes messages
> If I can see your point, a Matcher should return a collection of addresses
> who have exceeded the maximum storage amount, and a mailet would address
> their email to a specified processor. Is that correct?
Correct.
>> Hence my comment that you create a base class that implements the core
>> functionality, and use derived classes to implement the mapping.
> Ok, I'll study something.
If you would like for me to provide you with a code outline, let me know.
--- Noel
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org
Re: Deploying a Mailet
Posted by Marco Tedone <mt...@jemos.org>.
----- Original Message -----
From: "Noel J. Bergman" <no...@devtech.com>
To: "James Developers List" <ja...@jakarta.apache.org>
Sent: Sunday, May 11, 2003 5:22 PM
Subject: RE: Deploying a Mailet
> > > Why mix the two? We already have a ToProcessor mailet. If it were
me,
> I
> > > would just write a matcher. And since there are many ways that
someone
> > > might want to map quotas, it makes sense to separate the mapping from
> the
> > > rest of the matcher behavior.
>
> > Well, part is due to my ignorance about Matchers, but I had a look at
the
> > ToProcessor class, and at the end what it does is to set the mail state
to
> a
> > processor passed as parameter. It has been implemented in the
ManageSize
> > Mailet in the same way (roughly copied).
>
> Well, it might help if you reviewed and understood the architecture. For
> example, you wrote in another message:
>
> > It's true that the architecture I'm designing wouldn't be
> > a plug and play for James users (you should remember that
> > I'm developing it as part of a separate project
>
> What are the design points behind your architecture? From what I can see
so
> far, you are almost ignoring the existing architecture.
>
The design points behind my architecture were (because now I'm not so sure)
to create a structure in which to deliver a new Mailet as needed. For this
reason I created a project and a build process and for that reason I wanted
some framework classes to service utility methods (like getting a
MailServer, group the common activity done in the init() method, providing a
ServiceFactory to get services instead of writing the code inside each
class. It seems to me clear that, should I deliver one only Mailet, a
framework like the one I thought wouldn't have any sense.
> > The actual work then, would be done by the framework, and the mailets
> would
> > act as a proxy. If you know Struts, the Mailet would be the Action (part
> of
> > the controller), while the framework would do the actual work, hided to
> > user.
>
> Mailets are already the Action. Consider:
>
> - Spooler: manages flow of messages through message processors
> - Processor: addressable set message processing instructions
> A Mailet Processor manages the flow of messages
> through its matchers and mailets
> - Matcher: returns a collection of matching message recipients
> - Mailet: processes messages
>
> You seem to be replicating parts of the architecture within your mailet.
>
If I can see your point, a Matcher should return a collection of addresses
who have exceeded the maximum storage amount, and a mailet would address
their email to a specified processor. Is that correct?
> > I felt the necessity to have something dynamic not binded
> > as a name/value pair, which could not be obtained from a
> > properties file.
>
> Hence my comment that you create a base class that implements the core
> functionality, and use derived classes to implement the mapping.
>
Ok, I'll study something.
> > I had a look to a Matcher now and I saw what it does. So your
> > idea is to realize a matcher which returns true/false depending
> > if user has used all the storage and then, by using a Mailet
> > class="ToProcessor" sending the mail to that processor.
>
> Not quite ... small detail difference: that's not what a Matcher does. A
> matcher returns a Collection of addresses. The mailet processor uses that
> collection to separate matching and non-matching addresses as necessary,
and
> invokes the assocated mailet class to process the message with matching
> addresses.
>
> Yes, we could subclass GenericRecipientMatcher for this purpose, and the
> matchRecipient method does return a boolean. That is probably what caught
> your eye, and it isn't wrong, but it is important to understand what is
> really going in.
>
> > I implemented a matcher inside a mailet.
>
> So I saw.
>
> > someway we should implement the code to:
> > 1) Get the mail recipients;
> > 2) Get the configuration information (in whatever format)
> > 3) Verify that the actual storage used doesn't exceed the maximum
>
> Correct.
>
> > It seems to me that you would like this code to be in a matcher.
>
> Correct.
>
> > unless you wouldn't come out with a better way to address the
> > three points shown above, I would keep the actual design.
>
> I thought I had. Not everyone will want to use your XML approach to
> specifying quotas.
>
> --- Noel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: james-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org
RE: Deploying a Mailet
Posted by "Noel J. Bergman" <no...@devtech.com>.
> > Why mix the two? We already have a ToProcessor mailet. If it were me,
I
> > would just write a matcher. And since there are many ways that someone
> > might want to map quotas, it makes sense to separate the mapping from
the
> > rest of the matcher behavior.
> Well, part is due to my ignorance about Matchers, but I had a look at the
> ToProcessor class, and at the end what it does is to set the mail state to
a
> processor passed as parameter. It has been implemented in the ManageSize
> Mailet in the same way (roughly copied).
Well, it might help if you reviewed and understood the architecture. For
example, you wrote in another message:
> It's true that the architecture I'm designing wouldn't be
> a plug and play for James users (you should remember that
> I'm developing it as part of a separate project
What are the design points behind your architecture? From what I can see so
far, you are almost ignoring the existing architecture.
> The actual work then, would be done by the framework, and the mailets
would
> act as a proxy. If you know Struts, the Mailet would be the Action (part
of
> the controller), while the framework would do the actual work, hided to
> user.
Mailets are already the Action. Consider:
- Spooler: manages flow of messages through message processors
- Processor: addressable set message processing instructions
A Mailet Processor manages the flow of messages
through its matchers and mailets
- Matcher: returns a collection of matching message recipients
- Mailet: processes messages
You seem to be replicating parts of the architecture within your mailet.
> I felt the necessity to have something dynamic not binded
> as a name/value pair, which could not be obtained from a
> properties file.
Hence my comment that you create a base class that implements the core
functionality, and use derived classes to implement the mapping.
> I had a look to a Matcher now and I saw what it does. So your
> idea is to realize a matcher which returns true/false depending
> if user has used all the storage and then, by using a Mailet
> class="ToProcessor" sending the mail to that processor.
Not quite ... small detail difference: that's not what a Matcher does. A
matcher returns a Collection of addresses. The mailet processor uses that
collection to separate matching and non-matching addresses as necessary, and
invokes the assocated mailet class to process the message with matching
addresses.
Yes, we could subclass GenericRecipientMatcher for this purpose, and the
matchRecipient method does return a boolean. That is probably what caught
your eye, and it isn't wrong, but it is important to understand what is
really going in.
> I implemented a matcher inside a mailet.
So I saw.
> someway we should implement the code to:
> 1) Get the mail recipients;
> 2) Get the configuration information (in whatever format)
> 3) Verify that the actual storage used doesn't exceed the maximum
Correct.
> It seems to me that you would like this code to be in a matcher.
Correct.
> unless you wouldn't come out with a better way to address the
> three points shown above, I would keep the actual design.
I thought I had. Not everyone will want to use your XML approach to
specifying quotas.
--- Noel
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org
Re: Deploying a Mailet
Posted by Marco Tedone <mt...@jemos.org>.
----- Original Message -----
From: "Noel J. Bergman" <no...@devtech.com>
To: "James Developers List" <ja...@jakarta.apache.org>
Sent: Saturday, May 10, 2003 5:16 PM
Subject: RE: Deploying a Mailet
> > Noel, your mail depressed me.
>
> That certainly wasn't my intention. You asked for some input, so I gave
you
> what I thought were constructive ideas.
>
> > A Mailet ran for all the mails will execute the Mailet with the
following
> > parameters
> > a) processor
> > b) xmlURI
>
> Why mix the two? We already have a ToProcessor mailet. If it were me, I
> would just write a matcher. And since there are many ways that someone
> might want to map quotas, it makes sense to separate the mapping from the
> rest of the matcher behavior.
Well, part is due to my ignorance about Matchers, but I had a look at the
ToProcessor class, and at the end what it does is to set the mail state to a
processor passed as parameter. It has been implemented in the ManageSize
Mailet in the same way (roughly copied). I felt the necessity to have
something dynamic not binded as a name/value pair, which could not be
obtained from a properties file. Aaaah, I had a look to a Matcher now and I
saw what it does. So your idea is to realize a matcher which returns
true/false depending if user has used all the storage and then, by using a
Mailet class="ToProcessor" sending the mail to that processor. Hhmmm. I
implemented a matcher inside a mailet. But ATEOD (At The End Of Days) in
someway we should implement the code to:
1) Get the mail recipients;
2) Get the configuration information (in whatever format)
3) Verify that the actual storage used doesn't exceed the maximum specified
per user
It seems to me that you would like this code to be in a matcher. For me it
wouldn't be a problem: I should simply move the code from a Mailet to a
Matcher but unless you wouldn't come out with a better way to address the
three points shown above, I would keep the actual design.
>
> > I used Apache commons-digester project to parse the XML configuration
file
> > and to build a Vector representing the structure of the XML
configuration
> > file.
>
> That would be one way to implement a particular mapping.
>
> I'm not entirely following what else you're doing, but perhaps when I see
> the code it will make more sense.
>
> --- Noel
>
>
Marco
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: james-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org
Re: Deploying a Mailet
Posted by Marco Tedone <mt...@jemos.org>.
Noel, here attached you will find the code, plus the XML configuration file,
plus a zargo project related to the Mailet I developed. If you want there is
also a PDF installation manual (916 Kb) which I could send. It explains how
to built the Mailet and there is also a section dedicated to Eclipse 2.1 if
you're using this IDE.
WFYI,
Marco
----- Original Message -----
From: "Noel J. Bergman" <no...@devtech.com>
To: "James Developers List" <ja...@jakarta.apache.org>
Sent: Saturday, May 10, 2003 5:16 PM
Subject: RE: Deploying a Mailet
> > Noel, your mail depressed me.
>
> That certainly wasn't my intention. You asked for some input, so I gave
you
> what I thought were constructive ideas.
>
> > A Mailet ran for all the mails will execute the Mailet with the
following
> > parameters
> > a) processor
> > b) xmlURI
>
> Why mix the two? We already have a ToProcessor mailet. If it were me, I
> would just write a matcher. And since there are many ways that someone
> might want to map quotas, it makes sense to separate the mapping from the
> rest of the matcher behavior.
>
> > I used Apache commons-digester project to parse the XML configuration
file
> > and to build a Vector representing the structure of the XML
configuration
> > file.
>
> That would be one way to implement a particular mapping.
>
> I'm not entirely following what else you're doing, but perhaps when I see
> the code it will make more sense.
>
> --- Noel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: james-dev-help@jakarta.apache.org
>
>
RE: Deploying a Mailet
Posted by "Noel J. Bergman" <no...@devtech.com>.
> Noel, your mail depressed me.
That certainly wasn't my intention. You asked for some input, so I gave you
what I thought were constructive ideas.
> A Mailet ran for all the mails will execute the Mailet with the following
> parameters
> a) processor
> b) xmlURI
Why mix the two? We already have a ToProcessor mailet. If it were me, I
would just write a matcher. And since there are many ways that someone
might want to map quotas, it makes sense to separate the mapping from the
rest of the matcher behavior.
> I used Apache commons-digester project to parse the XML configuration file
> and to build a Vector representing the structure of the XML configuration
> file.
That would be one way to implement a particular mapping.
I'm not entirely following what else you're doing, but perhaps when I see
the code it will make more sense.
--- Noel
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org
Re: Deploying a Mailet
Posted by Marco Tedone <mt...@jemos.org>.
Noel, your mail depressed me. I'm so far from your vision. I've done the
following right now following your previous suggestions:
A Mailet ran for all the mails will execute the Mailet with the following
parameters:
a) processor: the processor to send the mail to if the user's used storage
exceeded the maximum allowed (specified in the XML configuration file)
b) xmlURI: the relative/absolute (you can help me in deciding it) path to
the XML configuration file
Because this Mailet is now part of the Jamailet project (unless you would
suggest to make it part of the James project) I created a 'Mailet Framework'
ready to contain not only this Mailet but also all future Mailets, which
comes as a CVS distribution and to be built by means of Ant.
I used Apache commons-digester project to parse the XML configuration file
and to build a Vector representing the structure of the XML configuration
file. Then the framework defines a Service which defines the contract to
clients and which parse the XML configuration file and returns a Vector and
also a ServiceFactory is defined (the actual object used by the Mailet). The
Mailet subclass a GenericJamailet class (which defines a series of utility
methods) which subclass GenericMailet class.
The Mailet, in its init() method, sets the parameters from the config.xml
file and, using the XML Service, sets a Vector containing all the
configuration elements contained in the Jamailet configuration file.
Then, in its service() method, for each recipient of the Mail, if he has
been defined in the XML configuration file, a manageSize(String user) method
is executed (this method set the mail state to the processor if user
exceeded the maximum allowed quota).
I'll be back shortly with an ArgoUML diagram showing a draft of the design.
Marco
----- Original Message -----
From: "Noel J. Bergman" <no...@devtech.com>
To: "James Developers List" <ja...@jakarta.apache.org>
Sent: Saturday, May 10, 2003 3:25 PM
Subject: RE: Deploying a Mailet
> > 1) Does the MailAddress.getName() method returns mtedone from an email
> > address 'mtedone@foo.com' ?
>
> There is no such method. If you mean Mail.getName(), see the javadocs.
Sorry, I was meaning getUser()
>
> > 2) Supposed I have got an XML configuration file to parse from within my
> > Mailet
>
> I suggest that you do it a bit differently. Create a base class, e.g.,
> AbstractQuotaMatcher, that defines a shared interface. In your case,
> something like:
>
> abstract protected long getQuota(String user);
>
> Then a subclass can implement how that is mapped, e.g., via a file, via a
> database table, via JNDI/LDAP, etc.
>
Noe
> > 2a) Is it SAR-INF the best location to put it?
>
> Not in my opinion. Why should the deployment of a new version of James
have
> any impact on the administrative files? I would keep the file elsewhere.
> But others may have a different view.
>
> > 2b) Which string shall I specify to a Mailet as a path to that file?
>
> You don't. The elements of the <mailet> tag are for mailets, and this
would
> be a matcher, so you use the matcher condition, e.g.,
>
> <mailet match="FileQuotaMatcher=file://<path>/<quotafile>"
> class="ToProcessor">
> <processor>overQuota</processor>
> </mailet>
>
> <mailet match="FixedQuotaMatcher=10485760" class="ToProcessor">
> <processor>overQuota</processor>
> </mailet>
>
> > 3) Supposed I have got a Mailet ready to test, is it correct for the
> > deployment to do the following?
>
> Personally, I'd just build it into the main source tree, and then when you
> have it ready, submit it for inclusion in the James release. It is an
often
> enough request.
>
> --- Noel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: james-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org
Re: Deploying a Mailet
Posted by Serge Knystautas <se...@lokitech.com>.
Noel J. Bergman wrote:
>>1) Does the MailAddress.getName() method returns mtedone from an email
>> address 'mtedone@foo.com' ?
>
> There is no such method. If you mean Mail.getName(), see the javadocs.
MailAddress.getUser() will return mtadone from email address
'mtedone@foo.com'
--
Serge Knystautas
President
Lokitech >> software . strategy . design >> http://www.lokitech.com/
p. 1.301.656.5501
e. sergek@lokitech.com
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org
RE: Deploying a Mailet
Posted by "Noel J. Bergman" <no...@devtech.com>.
> 1) Does the MailAddress.getName() method returns mtedone from an email
> address 'mtedone@foo.com' ?
There is no such method. If you mean Mail.getName(), see the javadocs.
> 2) Supposed I have got an XML configuration file to parse from within my
> Mailet
I suggest that you do it a bit differently. Create a base class, e.g.,
AbstractQuotaMatcher, that defines a shared interface. In your case,
something like:
abstract protected long getQuota(String user);
Then a subclass can implement how that is mapped, e.g., via a file, via a
database table, via JNDI/LDAP, etc.
> 2a) Is it SAR-INF the best location to put it?
Not in my opinion. Why should the deployment of a new version of James have
any impact on the administrative files? I would keep the file elsewhere.
But others may have a different view.
> 2b) Which string shall I specify to a Mailet as a path to that file?
You don't. The elements of the <mailet> tag are for mailets, and this would
be a matcher, so you use the matcher condition, e.g.,
<mailet match="FileQuotaMatcher=file://<path>/<quotafile>"
class="ToProcessor">
<processor>overQuota</processor>
</mailet>
<mailet match="FixedQuotaMatcher=10485760" class="ToProcessor">
<processor>overQuota</processor>
</mailet>
> 3) Supposed I have got a Mailet ready to test, is it correct for the
> deployment to do the following?
Personally, I'd just build it into the main source tree, and then when you
have it ready, submit it for inclusion in the James release. It is an often
enough request.
--- Noel
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org