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 Rauno Palosaari <ra...@rauno.com> on 2001/11/27 11:50:10 UTC

Getting mailet attributes from a Matcher

Hi all.

Is it possible to get mailet-parameters from a Matcher, I wrote a matcher and a mailet:
(assembly.xml)
<mailet match="IsCustomer" class="DoStuff">
     <connection>jdbc:mysql:///whatever</connection>
     <username>user</username>
     <password>something</password>
     <query>select domain from customer</query>
</mailet>

(What I want to do is to get the Matcher conditions from a db.)

DoStuff.java (mailet) has no problems getting connection, username, etc.
I want to access the parameters from my matcher as well.
getMatcherConfig().getMailetContext().getAttribute("connection"); doesn't do the job unless somebody sets the attribute first, I guess.

Is there any way around this, i.e. other than passing the parameters in the matcher condition part (well, it does the job but it's ugly): 
<mailet match="IsCustomer=jdbc:mysql:///whatever,user,something,select domain from customer" class="DoStuff">
</mailet>

Regards,
Rauno

Re: Getting mailet attributes from a Matcher

Posted by Rauno Palosaari <ra...@rauno.com>.
Yup, solved it almost as you suggested. I realized that it was a somewhat awkward approach to what I was looking for.

Thanks,
Rauno

----- Original Message ----- 
From: "Serge Knystautas" <se...@lokitech.com>
To: "James Developers List" <ja...@jakarta.apache.org>; "Rauno Palosaari" <ra...@rauno.com>
Sent: Wednesday, November 28, 2001 4:47 PM
Subject: Re: Getting mailet attributes from a Matcher


> Rauno,
> 
> Mailet context is supposed to be server-wide, so that's not really what
> you're looking for.  I think what you'd really want is for MatcherConfig to
> have a getMailetConfig() parameter.  While this isn't too hard to do, it
> ties our hands in terms of making the matchers more flexibly configured in
> the conf file, i.e., how would getMailetConfig() work if you had something
> like...
> 
> if (matcher1 && matcher2) {
>    if (matcher3) {
>      mailet1;
>    } else {
>      mailet2;
>   }
> }
> 
> Not that we have a clear vision for how this works or plan to implement this
> anytime soon, but as we may want to move this way.
> 
> Is there a reason you need to abstract the SQL from your matcher?  I can
> understand needing to abstract the jdbc conn definition, but that's easier
> to address by using datasource that's defined elsewhere, and just passing
> the datasource's name.
> 
> Serge Knystautas
> Loki Technologies - Unstoppable Websites
> http://www.lokitech.com/
> ----- Original Message -----
> From: "Rauno Palosaari" <ra...@rauno.com>
> To: <ja...@jakarta.apache.org>
> Sent: Tuesday, November 27, 2001 5:50 AM
> Subject: Getting mailet attributes from a Matcher
> 
> 
> Hi all.
> 
> Is it possible to get mailet-parameters from a Matcher, I wrote a matcher
> and a mailet:
> (assembly.xml)
> <mailet match="IsCustomer" class="DoStuff">
>      <connection>jdbc:mysql:///whatever</connection>
>      <username>user</username>
>      <password>something</password>
>      <query>select domain from customer</query>
> </mailet>
> 
> (What I want to do is to get the Matcher conditions from a db.)
> 
> DoStuff.java (mailet) has no problems getting connection, username, etc.
> I want to access the parameters from my matcher as well.
> getMatcherConfig().getMailetContext().getAttribute("connection"); doesn't do
> the job unless somebody sets the attribute first, I guess.
> 
> Is there any way around this, i.e. other than passing the parameters in the
> matcher condition part (well, it does the job but it's ugly):
> <mailet match="IsCustomer=jdbc:mysql:///whatever,user,something,select
> domain from customer" class="DoStuff">
> </mailet>
> 
> Regards,
> Rauno
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Getting mailet attributes from a Matcher

Posted by Serge Knystautas <se...@lokitech.com>.
Rauno,

Mailet context is supposed to be server-wide, so that's not really what
you're looking for.  I think what you'd really want is for MatcherConfig to
have a getMailetConfig() parameter.  While this isn't too hard to do, it
ties our hands in terms of making the matchers more flexibly configured in
the conf file, i.e., how would getMailetConfig() work if you had something
like...

if (matcher1 && matcher2) {
   if (matcher3) {
     mailet1;
   } else {
     mailet2;
  }
}

Not that we have a clear vision for how this works or plan to implement this
anytime soon, but as we may want to move this way.

Is there a reason you need to abstract the SQL from your matcher?  I can
understand needing to abstract the jdbc conn definition, but that's easier
to address by using datasource that's defined elsewhere, and just passing
the datasource's name.

Serge Knystautas
Loki Technologies - Unstoppable Websites
http://www.lokitech.com/
----- Original Message -----
From: "Rauno Palosaari" <ra...@rauno.com>
To: <ja...@jakarta.apache.org>
Sent: Tuesday, November 27, 2001 5:50 AM
Subject: Getting mailet attributes from a Matcher


Hi all.

Is it possible to get mailet-parameters from a Matcher, I wrote a matcher
and a mailet:
(assembly.xml)
<mailet match="IsCustomer" class="DoStuff">
     <connection>jdbc:mysql:///whatever</connection>
     <username>user</username>
     <password>something</password>
     <query>select domain from customer</query>
</mailet>

(What I want to do is to get the Matcher conditions from a db.)

DoStuff.java (mailet) has no problems getting connection, username, etc.
I want to access the parameters from my matcher as well.
getMatcherConfig().getMailetContext().getAttribute("connection"); doesn't do
the job unless somebody sets the attribute first, I guess.

Is there any way around this, i.e. other than passing the parameters in the
matcher condition part (well, it does the job but it's ugly):
<mailet match="IsCustomer=jdbc:mysql:///whatever,user,something,select
domain from customer" class="DoStuff">
</mailet>

Regards,
Rauno



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>