KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > ant > cluster > MailCluster


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2005 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Initial developer: Benoit Pelletier
22  * --------------------------------------------------------------------------
23  * $Id: MailCluster.java,v 1.1 2005/06/07 08:21:27 pelletib Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas.ant.cluster;
28
29 import java.io.File JavaDoc;
30
31 import org.objectweb.jonas.ant.jonasbase.Mail;
32
33 /**
34  * Define MailCluster task
35  * @author Benoit Pelletier
36  */

37 public class MailCluster extends ClusterTasks {
38
39     /**
40      * Info for the logger
41      */

42     private static final String JavaDoc INFO = "[MailCluster] ";
43
44
45     /**
46      * Type of factory (Session or MimePartDataSource)
47      */

48     private String JavaDoc type = null;
49
50     /**
51      * Name of the factory
52      */

53     private String JavaDoc name = null;
54
55     /**
56      * Recipient (TO) of MimePartDataSource factory
57      */

58     private String JavaDoc mailTo = null;
59
60     /**
61      * Subject of MimePartDataSource factory
62      */

63     private String JavaDoc subject = null;
64
65     /**
66      * Sets the recipient (MimePartDataSource)
67      * @param mailTo recipient.
68      */

69     public void setMailTo(String JavaDoc mailTo) {
70         this.mailTo = mailTo;
71     }
72
73     /**
74      * Sets the name
75      * @param name name of the factory
76      */

77     public void setName(String JavaDoc name) {
78         this.name = name;
79     }
80
81     /**
82      * Sets the subject (MimePartDataSource)
83      * @param subject of the mail
84      */

85     public void setSubject(String JavaDoc subject) {
86         this.subject = subject;
87     }
88
89     /**
90      * Sets the type of factory
91      * @param type of factory
92      */

93     public void setType(String JavaDoc type) {
94         this.type = type;
95     }
96
97     /**
98      * Default constructor
99      */

100     public MailCluster() {
101         super();
102     }
103
104     /**
105      * Generates the mail tasks for each JOnAS's instances
106      */

107     public void generatesTasks() {
108
109         for (int i = getDestDirSuffixIndFirst(); i <= getDestDirSuffixIndLast(); i++) {
110
111             String JavaDoc destDir = getDestDir(getDestDirPrefix(), i);
112
113             // creation of the Mail task
114
Mail mail = new Mail();
115
116             log(INFO + "tasks generation for " + destDir);
117
118             mail.setMailTo(mailTo);
119             mail.setName(name);
120             mail.setSubject(subject);
121             mail.setType(type);
122
123             mail.setDestDir(new File JavaDoc(destDir));
124
125             addTask(mail);
126
127         }
128     }
129 }
Popular Tags