Serge Knystautas wrote:
>
> I've written an Avalon block wrapper to go around the DNS code,
> effectively making a DNS Server block. I put this in the conf file at
> the same level as the JamesMailServer block (right after it), and
> created a simple log service by basically cutting and pasting.
>
> Now the question is, how do I get access to that block from my mailet
> within the JamesMailServer. The DNS server upon init sets itself as
> "DNS_SERVER", and then I try to the component for that in my mailet, and
> I can't find it. I've tried to look for similar cases in the code, but
> couldn't figure it out.
Ok. That's not so easy...
First check your conf. Should look like:
<avalon>
<servicesmap>
<service name="JamesMailServer">
<resource type="org.apache.avalon.blocks.Logger"
mapTo="JamesLogger"/>
...
<resource type="org.apache.avalon.blocks.[DNSInterfaceName]"
mapTo="[DNSBlockName]"/>
</service>
<service name="[DNSBlockName]">
<resource type="org.apache.avalon.blocks.Logger"
mapTo="ApacheDefaultLogger"/>
...
</service>
...
</servicesmap>
<blocks>
<block class="[DNSClassName}"
name="[DNSBlockName]"
implementedInterface="org.apache.avalon.blocks.[DNSInterfaceName]">
...
Since the DNS is in James resources definition it should be available
from the ComponentManager.
Second I just checked and the mailet CM inherit serivces from the
ProcessorMailet CM wich iherit from JamesSpoolManager CM wich inherit
from James CM wich inherit from avalon... :-) at the end it should be
visible. If you can't find out the bug send me the code. Maybe in two we
can do it!
And now a problem/question back.
Bocks are "avalon aware" that means they can access any other block
defined in their <service> by calling the ComponentManager. Any other
Component or Block's child is not, as a general rule, avalon aware. The
SMTPServer, POP3Server, etc are provided by james with a private
ComponentManager. In the specific case james CM is constructed with new
SimpleComponentManager(comp) thus it inherit services from avalon CM.
So if you ask for a Component to james CM it will try to resolve it on
its own or call back its parent CM if the service is not available at
its level.
This way James's direct children share for example the SPOOL_REPOSITORY
wich is not an avalon service but it's created by james without
affecting all other blocks.
The point is that in general I don't want mailet to be avalon aware.
Being avalon aware means they will run only on james and it will be
almost impossible to make a "standard" in the strong meaning of the word
of Mailets.
That's why I was thinking we shoud define a set of services provided by
the mailet engine (not by avalon) to mailet and decouple mailets CM from
avalon's one.
If you think this makes sense we can define a set of resources and
services and some way to keep it flexible.
Opinions?
>
> Assuming I can get this working, that'll mean I can remove
> SmartTransport as that code gets pushed into the DNS Server block and
> some into RemoteDelivery servlet. Makes the code even easier, and more
> in step with the Avalon framework. Also it's nice because then other
> parts of the system can make DNS lookup calls (like validating a
> sender's domain to reduce spam), and whatever else people can come up.
> Also wrote a RelayLimit match that works nicely. Getting close to the
> basic pieces to make JAMES not open for relaying and spammers.
>
This sound really good.
I was thinking to do the same with UserManager. An User Manager Block
should be really usefull for many things.
Federico Barbieri
<[EMAIL PROTECTED]>
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/>
Problems?: [EMAIL PROTECTED]