|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--mx4j.tools.mail.SMTP
This MBean is meant to send a mail given certain situation. It may be used to listen to a monitor or timer and send a mail. To use it you need to add to your classpath the mail.jar from the JavaMail API and the activation.jar from the Java Activation Framework. Besides you need to configure all the required fields, at least the serverHost and To fields and if your server requires login also the serverUsername and serverPassword fields The subject and content fields are subject to keyword expansions, i.e. some keyworks put between $ signs will be exapnded this can be used to give a more informative message. The current available expansions are $date$ -> Current date formatted with locale format $time$ -> Current tim formatted with locale format $datetime$ -> Current date and time formatted with locale format $notification$ -> Notification type $observed$ -> ObjectName of the observed object $objectname$ -> This MBean's objectname
Constructor Summary | |
---|---|
SMTP()
|
Method Summary | |
---|---|
java.lang.String |
getBCC()
Gets a comma separated list of addresses set in the BCC field |
java.lang.String |
getCC()
Gets a comma separated list of addresses set in the CC field |
java.lang.String |
getContent()
Returns the content of the mail |
java.lang.String |
getFromAddress()
Gets the from address attached to mails |
java.lang.String |
getFromName()
Gets the from name presented on the mail |
java.lang.String |
getMimeType()
Gets the MIME type set to the mail |
java.lang.String |
getNotificationName()
Returns the notification which will trigger the mail sending |
ObjectName |
getObservedObject()
Gets the MBean's objectname which is being listened |
java.lang.String |
getServerHost()
Gets the server's host as name or IP |
int |
getServerPort()
Gets the server's port, by default is 25 |
java.lang.String |
getServerUsername()
Gets the username to log to the server |
java.lang.String |
getSubject()
Gets the mail subject |
int |
getTimeout()
Returns the timeout used when sending mails |
java.lang.String |
getTo()
Gets a comma separated list of addresses set in the TO field |
void |
handleNotification(Notification notification,
java.lang.Object handback)
Called when a notification occurs. |
boolean |
isLoginToServer()
Indicates whether login to the SMTP server will be attpemted |
void |
postDeregister()
Called upon after the MBean has been de-registered. |
void |
postRegister(java.lang.Boolean registrationDone)
Called upon after a registration ( successful or not ). |
void |
preDeregister()
Called upon before an MBean will be de-registered by
the MBeanServer . |
ObjectName |
preRegister(MBeanServer server,
ObjectName name)
Gathers some basic data |
protected void |
registerListener()
|
void |
sendMail()
This will directly execute the send mail. |
void |
setBCC(java.lang.String bccAddresses)
Sets a comma separated list of address which will go in the BCC mail field |
void |
setCC(java.lang.String ccAddresses)
Sets a comma separated list of address which will go in the CC mail field |
void |
setContent(java.lang.String content)
Sets the content of the mail |
void |
setFromAddress(java.lang.String fromAddress)
Sets the form address set to mail |
void |
setFromName(java.lang.String fromName)
Sets the from name presented on the mail |
void |
setLoginToServer(boolean login)
Sets whether to login to the SMTP server |
void |
setMimeType(java.lang.String mimeType)
Sets the MIME type, by default it is text/plain |
void |
setNotificationName(java.lang.String notificationName)
Sets the notification name which will trigger the mail sending. |
void |
setObservedObject(ObjectName targetMBeanName)
Sets the observed object. |
void |
setServerHost(java.lang.String host)
Sets the server's host, it can be set as name or IP |
void |
setServerPassword(java.lang.String password)
Sets server's passowrd, use with setLoginToServer(true) and setServerUsername |
void |
setServerPort(int port)
Sets the server's port. |
void |
setServerUsername(java.lang.String username)
Sets server's username, use with setLoginToServer(true) |
void |
setSubject(java.lang.String subject)
Sets the mail's subject, by default is Empty subject. |
void |
setTimeout(int timeout)
Sets the send timeout, by default it is 10 secs |
void |
setTo(java.lang.String toAddresses)
Sets a comma separated list of address which will go in the TO mail field |
protected void |
unregisterListener()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SMTP()
Method Detail |
public void handleNotification(Notification notification, java.lang.Object handback)
NotificationListener
handleNotification
in interface NotificationListener
notification
- The notification objecthandback
- Helps in associating information regarding the listener.public void sendMail()
SMTPMBean
sendMail
in interface SMTPMBean
public java.lang.String getBCC()
SMTPMBean
getBCC
in interface SMTPMBean
public void setBCC(java.lang.String bccAddresses)
SMTPMBean
setBCC
in interface SMTPMBean
public void setCC(java.lang.String ccAddresses)
SMTPMBean
setCC
in interface SMTPMBean
public java.lang.String getCC()
SMTPMBean
getCC
in interface SMTPMBean
public java.lang.String getFromAddress()
SMTPMBean
getFromAddress
in interface SMTPMBean
public void setFromAddress(java.lang.String fromAddress)
SMTPMBean
setFromAddress
in interface SMTPMBean
public void setServerHost(java.lang.String host)
SMTPMBean
setServerHost
in interface SMTPMBean
public java.lang.String getServerHost()
SMTPMBean
getServerHost
in interface SMTPMBean
public void setServerPort(int port)
SMTPMBean
setServerPort
in interface SMTPMBean
public int getServerPort()
SMTPMBean
getServerPort
in interface SMTPMBean
public void setServerUsername(java.lang.String username)
SMTPMBean
setServerUsername
in interface SMTPMBean
public java.lang.String getServerUsername()
SMTPMBean
getServerUsername
in interface SMTPMBean
public void setServerPassword(java.lang.String password)
SMTPMBean
setServerPassword
in interface SMTPMBean
public void setLoginToServer(boolean login)
SMTPMBean
setLoginToServer
in interface SMTPMBean
public boolean isLoginToServer()
SMTPMBean
isLoginToServer
in interface SMTPMBean
public java.lang.String getFromName()
SMTPMBean
getFromName
in interface SMTPMBean
public void setFromName(java.lang.String fromName)
SMTPMBean
setFromName
in interface SMTPMBean
public java.lang.String getMimeType()
SMTPMBean
getMimeType
in interface SMTPMBean
public void setMimeType(java.lang.String mimeType)
SMTPMBean
setMimeType
in interface SMTPMBean
public java.lang.String getNotificationName()
SMTPMBean
getNotificationName
in interface SMTPMBean
public void setNotificationName(java.lang.String notificationName)
SMTPMBean
setNotificationName
in interface SMTPMBean
public java.lang.String getSubject()
SMTPMBean
getSubject
in interface SMTPMBean
public void setSubject(java.lang.String subject)
SMTPMBean
setSubject
in interface SMTPMBean
public java.lang.String getContent()
SMTPMBean
getContent
in interface SMTPMBean
public void setContent(java.lang.String content)
SMTPMBean
setContent
in interface SMTPMBean
public void setTimeout(int timeout)
SMTPMBean
setTimeout
in interface SMTPMBean
public int getTimeout()
SMTPMBean
getTimeout
in interface SMTPMBean
public void setObservedObject(ObjectName targetMBeanName)
SMTPMBean
setObservedObject
in interface SMTPMBean
public ObjectName getObservedObject()
SMTPMBean
getObservedObject
in interface SMTPMBean
public java.lang.String getTo()
SMTPMBean
getTo
in interface SMTPMBean
public void setTo(java.lang.String toAddresses)
SMTPMBean
setTo
in interface SMTPMBean
public ObjectName preRegister(MBeanServer server, ObjectName name) throws java.lang.Exception
preRegister
in interface MBeanRegistration
server
- The MBeanServer on which the MBean will be registered.name
- The ObjectName
of the MBean.
java.lang.Exception
- Exception of the operation. Note that this is caught
by the MBeanServer
and re-thrown as an
MBeanRegistrationException
.public void postRegister(java.lang.Boolean registrationDone)
MBeanRegistration
postRegister
in interface MBeanRegistration
registrationDone
- Evaluates to true of the registrations
is successful, false otherwise.public void preDeregister() throws java.lang.Exception
MBeanRegistration
MBean
will be de-registered by
the MBeanServer
.
preDeregister
in interface MBeanRegistration
java.lang.Exception
- Would be caught by the MBeanServer
and rethrown as an MBeanRegistrationException.public void postDeregister()
MBeanRegistration
postDeregister
in interface MBeanRegistration
protected void registerListener()
protected void unregisterListener()
|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |