users@glassfish.java.net

Re: Management rule & MBean

From: Pankaj Jairath <Pankaj.Jairath_at_Sun.COM>
Date: Thu, 19 Jun 2008 15:10:41 +0530

First thing would be validate that you have got the event and action
invocation working. Could you change the logs service level for
self-management and management-event to fine/finest. Check if you are
able to see the lifecycle event being fired. Also verify the addition of
this rule binding by the self management service.

regards
Pankaj

真嶌 晋 wrote:
> Hello Forks,
>
> I'm tryimg to set up management rules.
>
> I write MBean interface and MBean listed below.
>
> package asap.action;
>
> public interface SendMailActionMBean {
>
> }
>
> package asap.action;
>
> import java.util.Date;
> import java.util.Properties;
> import java.util.logging.Logger;
>
> import javax.mail.Session;
> import javax.mail.Transport;
> import javax.mail.internet.InternetAddress;
> import javax.mail.internet.MimeMessage;
> import javax.management.Notification;
> import javax.management.NotificationListener;
>
> import javax.mail.Message;
>
>
>
> public class SendMailAction implements SendMailActionMBean,
> NotificationListener {
>
> @Override
> public void handleNotification(Notification notification, Object handback) {
> Logger log = Logger.getLogger("SendMailAction");
> log.info("SendMailAction");
>
> try {
> Properties props = System.getProperties();
> // set SMTP address
> props.put("mail.smtp.host","localhost");
> Session session = Session.getDefaultInstance(props, null);
> MimeMessage mimeMessage = new MimeMessage(session);
> // send from
> mimeMessage.setFrom(
> new InternetAddress("glasssfish_at_lab-wtomcat102d.db.xxxx.co.jp", "glassfish", "iso-2022-jp"));
> mimeMessage.setRecipients(Message.RecipientType.TO, "susumu.majima_at_mail.xxxx.co.jp");
> mimeMessage.setHeader("Content-type", "text/plain");
> mimeMessage.setSubject("Message from GlassFish", "iso-2022-jp");
> mimeMessage.setText("This is send by MBean");
> mimeMessage.setSentDate(new Date());
> Transport.send(mimeMessage);
> } catch (Exception ex) {
> ex.printStackTrace();
> }
>
> }
>
> }
>
>
> I change parts of my company name to xxxx.
>
>
>
>
> I registered it by asadmin create-mbean command.
> I create a management rule by admin console.
>
> Rule Name:LifeCycleRule
> Event Type:lifecycle
> Event:ready
> Action:SendMailActionBean(It's I registred)
>
> I start up domain but nothing happen. No log,No mail I recieved.
>
> Does someone try to this kind of management rule ?
>
>
> Regards,
>
> Susumu Majima
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>