It is not a mailet!

I join the expications that Steve give me(very good explication and I can't
do better).

(after read explications)
Now, I don't limit the log in one mailet(I use it in a lot of mailets use by
the spoolmanager to follow the evolution of mails that arrive on the
server).
To do this, I must call :

try {
            // Instantiate the a tracking service
            tracking = (Tracking)
compMgr.lookup("org.apache.james.services.Tracking");
        } catch (ComponentException cnfe) {
            log("Failed to retrieve Tracking component:" +
cnfe.getMessage());
        } catch (Exception e) {
            log("Failed to retrieve Tracking component:" + e.getMessage());
        }}

in each init method of each mailet.
So I search to not do that at each time(do only one time when James start).
In this case, is it possible?

Are this explications more clearly?

Thanks,

-Pierre





-----Message d'origine-----
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Envoy� : jeudi 27 f�vrier 2003 14:52
� : James Developers List
Objet : Re: User-Log


Pierre -
No problem with the 'English' - just nice to hear from you.

The work you and Steve have done, could you describe for me
what the mailet actually does and how you are tracking a
mail from begining to end ?

Also, can you also describe -

"I initialise this service into every maillet(into the
method initialise() of the maillet)"

- this process too ??

Thanks,
Alan



> Hi,
>
> I try to create a service of User Logging (Keep all the
> path following by mails incoming in James).
> For the moment, I have create (with the help of Steve
> Short) a service Tracking that can : - Follow the
> evolution of a mail in the spoolmanager.
>                       - Log into a Database (can see
> result with Log5Factor).
>
> My question is : I initialise this service into every
> maillet(into the method initialise() of the maillet).
> Can I initialise only one time this service at start of
> James and only call this service in maillets (only one
> call)? If yes, Where?
>
> Have a nice day,
>
> -Pierre
>
> ps: Sorry for my english , I'm Belgian.
>
>
> ----------------------------------------------------------
> ----------- To unsubscribe, e-mail:
> [EMAIL PROTECTED] For additional
> commands, e-mail: [EMAIL PROTECTED]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

_____________________________________________________________________
Envie de discuter en "live" avec vos amis ? T�l�charger MSN Messenger
http://www.ifrance.com/_reloc/m la 1�re messagerie instantan�e de France
Create Tracking service
-----------------------


Some notes and issues: 

        - I just added a call to the tracking service from within the RemoteDelivery 
mailet, 
          but I have not taken into account the possility of partial deliveries, i.e. 
I have 
          not added appropriate handling for javax.mail.SendFailedException. 
          
        - Although the tracking service supports multiple detail levels, the log level 
for 
          'tracking' must be set to INFO or greater for any logging to occur. 

        - the only difference between minimum and maximum tracking levels is that the 
latter 
              includes the message subject. 
          
        - tracking messages and other log messages and errors from the tracking 
service are 
          all contained in one file, tracking.log. 

        - having used the service interface approach - it would now be easy to create 
          a service implementation class that logged to a database with no code 
changes 
              required anywhere else - just change the config files.  In which case 
the maximum 
              tracking level could store the actual message itself as a blob in the 
database. 

And now the steps (note lots of lines missed out for brevity). 

1.  Create a new service interface for tracking, Tracking.java 

        package org.apache.james.services; 
        ... 
        public interface Tracking { 
            /** 
             * The component role used by components implementing this service 
             */ 
            String ROLE = "org.apache.james.services.Tracking"; 

            public static final int TRACKING_OFF        = 0; 
            public static final int TRACKING_MINIMUM    = 1; 
            public static final int TRACKING_MAXIMUM    = 2; 

            public void trackMessage(Collection recipients, Mail mail); 
        } 

2.  Create a tracking class that implements the tracking service interface, 
LogTracker.java. 

        package org.apache.james.tracking; 
        ... 
        public class LogTracker 
            extends AbstractLogEnabled 
            implements Configurable, Initializable, 
            org.apache.james.services.Tracking { 
        
            private int trackingLevel = TRACKING_OFF; 
            
            public void configure( final Configuration configuration ) { ... } 

            public void initialize() { ... } 

            public int getTrackingLevel() { ... } 

            public void trackMessage(Collection recipients, Mail mail) { ... } 
        } 
        
3.  Create a block info file for the tracking service, LogTracker.xinfo, in same 
source directory 
    as LogTracker.java. 

        <?xml version="1.0"?> 
        
        <blockinfo> 
        
          <!-- section to describe block --> 
          <block> 
            <version>1.0</version> 
          </block> 
        
          <!-- services that are offered by this block --> 
          <services> 
            <service name="org.apache.james.services.Tracking" version="1.0"/> 
          </services> 
        
        </blockinfo> 
        
4.  Update James block info, james.xinfo,  file to declare new dependency on Tracking 
service: 
        
        ... 
        <dependency> 
            <service name="org.apache.james.services.Tracking" version="1.0"/> 
        </dependency> 
        ... 
5.  Update James assembly config file to define a LogTracker instance to 
   satisfy James dependency on a Tracking service: 
   
        <assembly> 
        ... 
          <!-- The James block  --> 
          <block name="James" class="org.apache.james.James" > 
                ... 
            <provide name="tracking" role="org.apache.james.services.Tracking"/> 
          </block> 
        ... 
        </assembly> 

6.  Update James config file to configure tracking service: 

        ... 
        <!-- Tracking Service Block --> 
        <tracking> 
            <trackingLevel>1</trackingLevel> 
        </tracking> 
        ... 

7.  Update James server config file to configure a logger: 

        ... 
        <categories> 
        ... 
            <category name="tracking" log-level="INFO"> 
                <log-target id-ref="tracking-target"/> 
            </category> 
        </categories> 
        ... 
        <targets> 
            ... 
            <file id="tracking-target"> 
                <filename>${app.home}/logs/tracking.log</filename> 
                <format>%{time:dd/MM/yy HH:mm:ss} %5.5{priority} %{category}: 
%{message}\n%{throwable}</format> 
                <append>true</append> 
            </file> 
      </targets> 
... 

8.  Write your mailet to invoke the tracking service.  For testing purposes I just 
threw it into RemoteDelivery: 

    Look up the service in the init() method: 
    
        try { 
            // Instantiate the a tracking service 
            tracking = (Tracking) 
compMgr.lookup("org.apache.james.services.Tracking"); 
        } catch (ComponentException cnfe) { 
            log("Failed to retrieve Tracking component:" + cnfe.getMessage()); 
        } catch (Exception e) { 
            log("Failed to retrieve Tracking component:" + e.getMessage()); 
        } 

    And call the tracking service at the appropriate point (right after 
transport.sendMessage() 
    in my case: 
    
        // Update tracking service 
        tracking.trackMessage(recipients, mail); 

9.  Build James and test. 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to