You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by hi...@apache.org on 2006/01/26 13:18:17 UTC

svn commit: r372516 [6/12] - in /webservices/muse/trunk/wsdm-jmx: ./ src/ src/examples/ src/examples/requestcounter/ src/examples/requestcounter/config/ src/examples/requestcounter/requests/ src/examples/requestcounter/src/ src/examples/requestcounter/...

Added: webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/JmxSubscriptionResource.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/JmxSubscriptionResource.java?rev=372516&view=auto
==============================================================================
--- webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/JmxSubscriptionResource.java (added)
+++ webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/JmxSubscriptionResource.java Thu Jan 26 04:14:27 2006
@@ -0,0 +1,257 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.muws.jmx.notification;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.addressing.EndpointReference;
+import org.apache.ws.muws.jmx.notification.monitor.AttributeChangeMonitorMBeanResource;
+import org.apache.ws.muws.jmx.notification.monitor.InvalidMonitorPreconditionException;
+import org.apache.ws.muws.jmx.notification.monitor.JmxMonitorMBeanResource;
+import org.apache.ws.muws.jmx.notification.monitor.JmxMonitorType;
+import org.apache.ws.muws.jmx.notification.monitor.MonitorMBeanResource;
+import org.apache.ws.muws.jmx.resource.AbstractMBeanResource;
+import org.apache.ws.muws.jmx.resource.properties.PropertyValue;
+import org.apache.ws.muws.jmx.util.CapabilityTopicUtils;
+import org.apache.ws.muws.jmx.util.WsdmJmxConstants;
+import org.apache.ws.muws.v1_0.topics.impl.XmlBeansManagementEventTopicImpl;
+import org.apache.ws.notification.base.v2004_06.impl.SubscriptionResource;
+import org.apache.ws.notification.topics.Topic;
+import org.apache.ws.notification.topics.TopicSpaceSet;
+import org.apache.ws.notification.topics.expression.TopicExpression;
+import org.apache.ws.notification.topics.impl.ResourcePropertyValueChangeTopicImpl;
+import org.apache.ws.notification.topics.impl.SubscriptionTopicListener;
+import org.apache.ws.notification.topics.impl.TopicImpl;
+
+/**
+ * A {@link SubscriptionResource} for monitoring MBean.
+ *
+ * @author Hideharu Kato
+ * 
+ */
+public class JmxSubscriptionResource extends SubscriptionResource
+{
+    private static final Log LOG = LogFactory.getLog(JmxSubscriptionResource.class);
+    
+    private ArrayList m_monitorMBeanResourceList = new ArrayList();
+      
+    /**
+     * Creates a new {@link JmxSubscriptionResource} object.
+     * 
+     * @param consumerReference     The WS-Addressing endpoint reference of the consumer
+     * @param producerReference     The WS-Addressing endpoint reference of the producer
+     * @param producerId            The resource id of the producer resource
+     * @param producerHomeLocation  The JNDI location of the home of the producer resource
+     * @param topicExpression       The topic expression for this subscription
+     */    
+    public JmxSubscriptionResource( EndpointReference consumerReference,
+            EndpointReference producerReference,
+            Object            producerId,
+            String            producerHomeLocation,
+            TopicExpression   topicExpression ) 
+    {
+            super(consumerReference, producerReference, producerId, producerHomeLocation, topicExpression);
+            
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.resource.Resource#destroy()
+     */
+    public void destroy()
+    {
+        super.destroy();
+        
+        synchronized(m_monitorMBeanResourceList)
+        {
+            MonitorMBeanResource monitorMBeanResource = null;
+            for(Iterator it = m_monitorMBeanResourceList.iterator(); it.hasNext();)
+            {
+                monitorMBeanResource = (MonitorMBeanResource) it.next();
+
+                try
+                {
+                    monitorMBeanResource.unsubscribe();
+                }
+                catch (Exception e)
+                {
+                    LOG.warn("Unable to destroy an MonitorMBeanResource. Cause: " + e.getLocalizedMessage());
+                    
+                    if(LOG.isDebugEnabled())
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            }
+            m_monitorMBeanResourceList.clear();
+        }
+    }
+    
+    
+    /**
+     * Starts monitoring.
+     * In case monitoring using JMX MonitorMBean, monitorType must be specified.
+     * 
+     * @param monitorType {@link JmxMonitorType} object used for this monitoring
+     * @throws Exception 
+     */
+    void subscribe(JmxMonitorType monitorType) throws  Exception
+    { 
+        try
+        {
+            TopicSpaceSet topicSpaceSet = getProducerResource().getTopicSpaceSet();
+            Topic[] topics = topicSpaceSet.evaluateTopicExpression(getTopicExpression());
+            
+            ArrayList observedPropertyList = getObservedPropertyList(topics);
+            
+            AbstractMBeanResource producerResource = (AbstractMBeanResource) getProducerResource();
+            
+            // In case jmx monitor precondition
+            if(monitorType != null)
+            {  
+                QName observedResourcePropertyName = monitorType.getObservedPropertyName();
+                
+                if(!observedPropertyList.contains(observedResourcePropertyName))
+                {
+                    throw new InvalidMonitorPreconditionException();
+                }
+                
+                PropertyValue observedPropertyValue = 
+                    producerResource.getPropertyValue(observedResourcePropertyName);
+                
+                if(observedPropertyValue == null)
+                {
+                    throw new InvalidMonitorPreconditionException();
+                }
+                
+                // Creates a TopicImpl object for sending a Monitor Notification.
+                // This topic is different from the topics resolved from the specified topic expression.
+                Topic[] targetTopics = new Topic[]{new TopicImpl((String) getID())};
+                
+                JmxMonitorMBeanResource monitorMBeanResource = 
+                    new JmxMonitorMBeanResource(
+                            this, 
+                            observedPropertyValue, 
+                            targetTopics, 
+                            monitorType);
+                
+                monitorMBeanResource.subscribe(); 
+                m_monitorMBeanResourceList.add(monitorMBeanResource);
+                
+                // Adds a SubscriptionTopicListener to the target Topic
+                targetTopics[0].addTopicListener(new SubscriptionTopicListener(this));
+            }
+            else
+            {   
+                QName observedResourcePropertyName = null;
+                PropertyValue observedPropertyValue = null;
+                Topic[] targetTopics = null;
+                
+                Long monitoringPeriod = WsdmJmxConstants.getValueChangeMonitoringPeriod();
+                
+                AttributeChangeMonitorMBeanResource monitorMBeanResource = null;
+                
+                for(Iterator it = observedPropertyList.iterator(); it.hasNext();)
+                {
+                    observedResourcePropertyName = (QName) it.next();
+                    observedPropertyValue = 
+                        producerResource.getPropertyValue(observedResourcePropertyName);
+                    
+                    // In case the observed property is associated with MBean
+                    if(observedPropertyValue != null)
+                    {
+                        // Target topics are the topics associated with the observed RP and
+                        // the subset of the topics resolved from the specified topic expression.
+                        // When the value of the observed RP changed, 
+                        // only target topics are published.
+                        targetTopics = 
+                            CapabilityTopicUtils.selectTopicsContainsResourceProperty(
+                                    topics, 
+                                    observedResourcePropertyName
+                                    );
+                                    
+                        monitorMBeanResource = 
+                            new AttributeChangeMonitorMBeanResource(
+                                    this, 
+                                    observedPropertyValue, 
+                                    targetTopics);
+                        
+                        if(monitoringPeriod != null)
+                        {
+                            monitorMBeanResource.setGranularityPeriod(monitoringPeriod.longValue());
+                        }
+                
+                        monitorMBeanResource.subscribe();                          
+                        m_monitorMBeanResourceList.add(monitorMBeanResource);
+                    }
+                    
+                    // Adds SubscriptionTopicListener to Topics
+                    SubscriptionTopicListener subscriptionTopicListener = new SubscriptionTopicListener(this);
+                    for ( int i = 0; i < topics.length; i++ )
+                    {
+                        topics[i].addTopicListener(subscriptionTopicListener);
+                    }
+                }
+            }
+        }
+        catch(InvalidMonitorPreconditionException e)
+        {
+            LOG.warn(e.getLocalizedMessage());
+            throw e;
+        }
+    }
+
+    private ArrayList getObservedPropertyList(Topic[] topics)
+    {
+        ArrayList observedPropertyList = new ArrayList();
+        
+        ArrayList propList = null;
+        String topicNamespace = null;
+        String topicName = null;
+        QName propName = null;
+        
+        // Observed properties are determined by topics
+        for(int i = 0; i < topics.length; i++)
+        {
+            propList = new ArrayList();
+            topicNamespace = topics[i].getTopicSpace().getTargetNamespace();
+            topicName = topics[i].getName();
+        
+            // In case Capability topic
+            if(topics[i] instanceof XmlBeansManagementEventTopicImpl)
+            {
+                propList = 
+                    (ArrayList) CapabilityTopicUtils.toResourcePropertyListFromCapabilityTopic(
+                            new QName(topicNamespace, topicName));
+                
+                observedPropertyList.addAll(propList);
+            }
+            // In case ResourceProperty topic
+            else if(topics[i] instanceof ResourcePropertyValueChangeTopicImpl)
+            {
+                propName = new QName(topicNamespace, topicName);
+                observedPropertyList.add(propName);
+            }
+        }
+        
+        return observedPropertyList;
+    }
+}

Added: webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/MonitorDialectEvaluator.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/MonitorDialectEvaluator.java?rev=372516&view=auto
==============================================================================
--- webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/MonitorDialectEvaluator.java (added)
+++ webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/MonitorDialectEvaluator.java Thu Jan 26 04:14:27 2006
@@ -0,0 +1,174 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.muws.jmx.notification;
+
+import java.math.BigInteger;
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.muse.museMonitor.CounterMonitorType;
+import org.apache.ws.muse.museMonitor.GaugeMonitorType;
+import org.apache.ws.muse.museMonitor.StringMonitorType;
+import org.apache.ws.muws.jmx.notification.monitor.JmxCounterMonitorType;
+import org.apache.ws.muws.jmx.notification.monitor.JmxGaugeMonitorType;
+import org.apache.ws.muws.jmx.notification.monitor.JmxMonitorType;
+import org.apache.ws.muws.jmx.notification.monitor.JmxStringMonitorType;
+import org.apache.ws.muws.jmx.resource.InvalidSchemaException;
+import org.apache.ws.muws.jmx.util.WsdmJmxConstants;
+import org.apache.ws.resource.properties.ResourcePropertySet;
+import org.apache.ws.resource.properties.query.ExpressionEvaluator;
+import org.apache.ws.resource.properties.query.InvalidQueryExpressionException;
+import org.apache.ws.resource.properties.query.QueryEvaluationErrorException;
+import org.apache.ws.resource.properties.query.QueryExpression;
+import org.apache.ws.resource.properties.query.UnknownQueryExpressionDialectException;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * An ExpressionEvaluator for monitor dialect ("http://ws.apache.org/muse/monitor") precondition.
+ *
+ * @author Hideharu Kato
+ * 
+ */
+public class MonitorDialectEvaluator implements ExpressionEvaluator
+{
+    private static final Log LOG = LogFactory.getLog(MonitorDialectEvaluator.class);
+    private static final URI[] SUPPORTED_DIALECTS = new URI[]{WsdmJmxConstants.DIALECT_URI_MONITOR};
+    
+    /**
+     * Creates a new {@link JmxMonitorType} object.
+     * 
+     * @param precondition  The monitor dialect precondition
+     * @return The instance of {@link JmxMonitorType} created from the specified precondition
+     * @throws InvalidSchemaException
+     */
+    JmxMonitorType createMonitorType(QueryExpression precondition) throws InvalidSchemaException 
+    {   
+        JmxMonitorType monitorType = null;
+        XmlObject content = (XmlObject) precondition.getContent();
+        
+        if(!content.validate())
+        {
+            LOG.warn("Given monitor precondition did not match the schema.");
+            throw new InvalidSchemaException(WsdmJmxConstants.BASE_URI_MUSE_MONITOR);
+        }
+        
+        String localpart = XmlBeanUtils.getName(content).getLocalPart();
+        
+        if(localpart.equals("GaugeMonitor"))
+        {
+            monitorType = new JmxGaugeMonitorType();
+            GaugeMonitorType gaugeMonitor = (GaugeMonitorType)content;
+            
+            long gPeriod = gaugeMonitor.getGranularityPeriod();
+            QName observedProperty = gaugeMonitor.getObservedProperty();         
+            
+            boolean diffMode = gaugeMonitor.getDifferenceMode();                 
+            Number highThreshold = new Double(gaugeMonitor.getHighThreshold());  
+            Number lowThreshold = new Double(gaugeMonitor.getLowThreshold());    
+            boolean notifyHigh = gaugeMonitor.getNotifyHigh();                   
+            boolean notifyLow = gaugeMonitor.getNotifyLow();                     
+            
+            monitorType.setGranularityPeriod(gPeriod);
+            monitorType.setObservedPropertyName(observedProperty);
+            ((JmxGaugeMonitorType) monitorType).setDifferenceMode(diffMode);
+            ((JmxGaugeMonitorType) monitorType).setHighThreshold(highThreshold);
+            ((JmxGaugeMonitorType) monitorType).setLowThreshold(lowThreshold);
+            ((JmxGaugeMonitorType) monitorType).setNotifyHigh(notifyHigh);
+            ((JmxGaugeMonitorType) monitorType).setNotifyLow(notifyLow); 
+        }
+        else if(localpart.equals("CounterMonitor"))
+        {    
+            monitorType = new JmxCounterMonitorType();
+            CounterMonitorType counterMonitor = (CounterMonitorType)content;
+            
+            long gPeriod = counterMonitor.getGranularityPeriod();
+            QName observedProperty = counterMonitor.getObservedProperty();
+            
+            boolean diffMode = counterMonitor.getDifferenceMode();
+            BigInteger modulus = counterMonitor.getModulus();
+            boolean notify = counterMonitor.getNotify();
+            BigInteger offset =  counterMonitor.getOffset();
+            BigInteger threshold = counterMonitor.getThreshold();
+                        
+            monitorType.setGranularityPeriod(gPeriod);
+            monitorType.setObservedPropertyName(observedProperty);
+            ((JmxCounterMonitorType) monitorType).setDifferenceMode(diffMode);
+            ((JmxCounterMonitorType) monitorType).setModulus(modulus);
+            ((JmxCounterMonitorType) monitorType).setNotify(notify);
+            ((JmxCounterMonitorType) monitorType).setOffset(offset);
+            ((JmxCounterMonitorType) monitorType).setThreshold(threshold);    
+        }
+        else if(localpart.equals("StringMonitor"))
+        {    
+            monitorType = new JmxStringMonitorType();
+            StringMonitorType strMonitor = (StringMonitorType)content;
+            
+            long gPeriod = strMonitor.getGranularityPeriod();
+            QName observedProperty = strMonitor.getObservedProperty();
+            
+            boolean notifyMatch = strMonitor.getNotifyMatch();
+            boolean notifyDiffer = strMonitor.getNotifyDiffer();
+            String strToCompare = strMonitor.getStringToCompare();
+
+            monitorType.setGranularityPeriod(gPeriod);
+            monitorType.setObservedPropertyName(observedProperty);
+            ((JmxStringMonitorType) monitorType).setNotifyMatch(notifyMatch);
+            ((JmxStringMonitorType) monitorType).setNotifyDiffer(notifyDiffer);
+            ((JmxStringMonitorType) monitorType).setStringToCompare(strToCompare);
+        }
+        
+        LOG.debug(monitorType.getClass().getName() + " is created.");
+        
+        return monitorType;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.resource.properties.query.ExpressionEvaluator#getSupportedDialects()
+     */
+    public URI[] getSupportedDialects() 
+    {
+        return SUPPORTED_DIALECTS;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.resource.properties.query.ExpressionEvaluator#evaluate(org.apache.ws.resource.properties.query.QueryExpression, org.apache.ws.resource.properties.ResourcePropertySet)
+     */
+    public Object evaluate(QueryExpression queryExpr, ResourcePropertySet resourcePropertySet) 
+        throws UnknownQueryExpressionDialectException, 
+            QueryEvaluationErrorException, 
+            InvalidQueryExpressionException 
+    {
+        return Boolean.TRUE;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.resource.properties.query.ExpressionEvaluator#evaluate(org.apache.ws.resource.properties.query.QueryExpression, java.lang.Object)
+     */
+    public Object evaluate(QueryExpression queryExpr, Object evalContext) 
+        throws UnknownQueryExpressionDialectException, 
+            QueryEvaluationErrorException, 
+            InvalidQueryExpressionException 
+    {
+        return Boolean.TRUE;
+    }
+}

Added: webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/MonitorDialectEvaluatorNotFoundException.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/MonitorDialectEvaluatorNotFoundException.java?rev=372516&view=auto
==============================================================================
--- webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/MonitorDialectEvaluatorNotFoundException.java (added)
+++ webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/MonitorDialectEvaluatorNotFoundException.java Thu Jan 26 04:14:27 2006
@@ -0,0 +1,31 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.muws.jmx.notification;
+
+/**
+ * An exception to be thrown in {@link JmxNotificationProducerPortTypeImpl#subscribe(SubscribeDocument)}
+ * when {@link MonitorDialectEvaluator is not found}.
+ * 
+ * @author Hideharu Kato
+ *
+ */
+public class MonitorDialectEvaluatorNotFoundException extends Exception
+{
+    public MonitorDialectEvaluatorNotFoundException()
+    {
+        super(MonitorDialectEvaluator.class.getName() + " not found.");
+    }
+}

Added: webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/AttributeChangeMonitorMBeanResource.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/AttributeChangeMonitorMBeanResource.java?rev=372516&view=auto
==============================================================================
--- webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/AttributeChangeMonitorMBeanResource.java (added)
+++ webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/AttributeChangeMonitorMBeanResource.java Thu Jan 26 04:14:27 2006
@@ -0,0 +1,283 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.muws.jmx.notification.monitor;
+
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import javax.management.AttributeChangeNotification;
+import javax.management.Notification;
+import javax.management.ObjectName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.muws.impl.CategoryImpl;
+import org.apache.ws.muws.jmx.notification.JmxSubscriptionResource;
+import org.apache.ws.muws.jmx.resource.properties.PropertyValue;
+import org.apache.ws.muws.jmx.util.DataTypeUtils;
+import org.apache.ws.muws.v1_0.MuwsConstants;
+import org.apache.ws.muws.v1_0.events.Situation;
+import org.apache.ws.muws.v1_0.events.impl.LangStringImpl;
+import org.apache.ws.muws.v1_0.events.impl.SituationImpl;
+import org.apache.ws.notification.topics.Topic;
+
+/**
+ * Provides methods for monitoring MBean attribute change event.
+ * {@link AttributeChangeMonitorMBeanResource} monitors an MBean attribute value periodically.
+ *
+ * @author Hideharu Kato
+ * 
+ */
+public class AttributeChangeMonitorMBeanResource extends MonitorMBeanResource
+{
+    private static final Log LOG = LogFactory.getLog(AttributeChangeMonitorMBeanResource.class);
+    private static final String EVENT_MESSAGE = "Value changed";
+    
+    private Timer m_timer;
+    private MBeanAttributeMonitorTask m_task;
+    private boolean m_active;
+    private long m_granularityPeriod = 60000;
+
+    /**
+     * Creates a new {@link AttributeChangeMonitorMBeanResource} object.
+     * 
+     * @param subscription          Subscription resource associated with this {@link AttributeChangeMonitorMBeanResource}
+     * @param observedPropertyValue PropertyValue object represents the observed resource property
+     * @param targetTopics          Topic objects relating with the observed resource properties
+     */
+    public AttributeChangeMonitorMBeanResource(
+            JmxSubscriptionResource subscription, 
+            PropertyValue observedPropertyValue, 
+            Topic[] targetTopics
+            )
+    {
+        super(subscription, observedPropertyValue, targetTopics);
+        
+        m_timer = new Timer(true);
+        
+        LOG.debug("A new AttributeChangeMonitorMBeanResource object is created. " +
+                "Associated subscription resource id = " + subscription.getID());
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.notification.monitor.MonitorMBeanResource#subscribe()
+     */
+    public void subscribe()
+    {
+        start();
+        
+        LOG.debug("AttributeChangeMonitor started." +
+                " Observed Object = [" + getObservedObject() +"]," +
+                " Observed Attribute Name = " + getObservedAttribute() + 
+                " Type = " + getObservedAttributeType() + "," +
+                " GranularityPeriod = " + m_granularityPeriod);
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.notification.monitor.MonitorMBeanResource#unsubscribe()
+     */
+    public void unsubscribe()
+    {
+        stop();
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.notification.monitor.MonitorMBeanResource#pause()
+     */
+    public void pause()
+    {
+        stop();
+        
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.notification.monitor.MonitorMBeanResource#resume()
+     */
+    public void resume()
+    {
+        start();
+    }
+    
+    /**
+     * Returns false if this {@link AttributeChangeMonitorMBeanResource} is not monitoring.
+     * 
+     * @return false if this {@link AttributeChangeMonitorMBeanResource} is not monitoring
+     */
+    public boolean isActive()
+    {
+        return m_active;
+    }
+    
+    /**
+     * Sets the monitoring perid.
+     * 
+     * @param gPeriod
+     */
+    public void setGranularityPeriod(long gPeriod)
+    {
+        m_granularityPeriod = gPeriod;
+    }
+    
+    /**
+     * Returns the monitoring period.
+     * 
+     * @return The monitoring period
+     */
+    public long getGranularityPeriod()
+    {
+        return m_granularityPeriod;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.monitorresource.MonitorMBeanResource#createSituation(javax.management.Notification)
+     */
+    Situation createSituation(Notification notification)
+    {
+        if(notification == null)
+        {
+            throw new IllegalArgumentException("notification must not be null.");
+        }
+        
+        CategoryImpl category = new CategoryImpl(MuwsConstants.SITUATION_REPORT);
+        
+        Situation situation = new SituationImpl(category);
+        Calendar situationTime = Calendar.getInstance();
+        situationTime.setTimeInMillis(notification.getTimeStamp());
+        situation.setSituationTime(situationTime);
+        
+        String message = notification.getMessage();
+        if(message != null)
+        {
+            situation.setMessage(new LangStringImpl(message, "en"));
+        }
+        
+        return situation;
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.monitorresource.MonitorMBeanResource#getObservedObject(javax.management.Notification)
+     */
+    ObjectName getObservedObject(Notification notification)
+    {
+        ObjectName observedObject = 
+            (ObjectName) ((AttributeChangeNotification) notification).getSource();
+        return observedObject;
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.monitorresource.MonitorMBeanResource#getObservedAttribute(javax.management.Notification)
+     */
+    String getObservedAttribute(Notification notification)
+    {
+        String observedAttribute = ((AttributeChangeNotification) notification).getAttributeName();
+        return observedAttribute;
+    }
+    
+    private void start()
+    {
+        if(m_task == null)
+        {
+            m_task = new MBeanAttributeMonitorTask();
+        }
+        
+        m_timer.scheduleAtFixedRate(m_task, 0, m_granularityPeriod );
+        m_active = true;
+    }
+
+    private void stop()
+    {
+        m_task.cancel();
+        m_task = null;
+        m_active = false;
+    }
+    
+    private class MBeanAttributeMonitorTask extends TimerTask
+    {
+        Object oldValue;
+        Object newValue;
+        Object[] oldValues;
+        Object[] newValues;
+        
+        AttributeChangeNotification notification;
+        boolean valueChanged;
+        int i;
+        
+        public void run() 
+        {   
+            try 
+            {
+                newValue = getMBeanServerConnection().getAttribute(getObservedObject(), getObservedAttribute());
+                
+                if(newValue.getClass().isArray())
+                {
+                    if(oldValue != null)
+                    {
+                        oldValues = DataTypeUtils.toObjectArray(oldValue);
+                        newValues = DataTypeUtils.toObjectArray(newValue);
+                    
+                        if(!Arrays.equals(oldValues, newValues))
+                        {
+                            valueChanged = true;
+                        }
+                    }
+                }
+                else
+                {
+                    if( (oldValue != null) && (!newValue.equals(oldValue)))
+                    {
+                        valueChanged = true;
+                    }
+                }
+                
+                if(valueChanged)
+                {
+                    notification = new AttributeChangeNotification(
+                            getObservedObject(),    
+                            i++, 
+                            Calendar.getInstance().getTimeInMillis(), 
+                            EVENT_MESSAGE, 
+                            getObservedAttribute(), 
+                            getObservedAttributeType(),
+                            oldValue,
+                            newValue);
+                
+                    handleNotification(notification, null);
+                    valueChanged = false;
+                }
+                
+                oldValue = newValue;    
+            } 
+            catch (Exception e)
+            {
+                LOG.error("Exception occurred while monitoring MBean attribute.");
+                if(LOG.isDebugEnabled())
+                {
+                    e.printStackTrace();
+                }
+                stop();
+            }
+        }
+    }
+}

Added: webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/InvalidMonitorNotificationReceivedException.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/InvalidMonitorNotificationReceivedException.java?rev=372516&view=auto
==============================================================================
--- webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/InvalidMonitorNotificationReceivedException.java (added)
+++ webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/InvalidMonitorNotificationReceivedException.java Thu Jan 26 04:14:27 2006
@@ -0,0 +1,32 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.muws.jmx.notification.monitor;
+
+import javax.management.Notification;
+
+/**
+ * An exception to be thrown by {@link JmxMonitorType#createSituation(Notification)}.
+ * 
+ * @author Hideharu Kato
+ * 
+ */
+public class InvalidMonitorNotificationReceivedException extends Exception 
+{
+    public InvalidMonitorNotificationReceivedException(Notification notification) 
+    {
+        super("The type of the received notification is invalid. " + notification);
+    }
+}

Added: webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/InvalidMonitorPreconditionException.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/InvalidMonitorPreconditionException.java?rev=372516&view=auto
==============================================================================
--- webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/InvalidMonitorPreconditionException.java (added)
+++ webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/InvalidMonitorPreconditionException.java Thu Jan 26 04:14:27 2006
@@ -0,0 +1,31 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.muws.jmx.notification.monitor;
+
+/**
+ * An exception to be thrown when the given monitor precondition is invalid.
+ * 
+ * @author Hideharu Kato
+ *
+ */
+public class InvalidMonitorPreconditionException extends Exception
+{
+    public InvalidMonitorPreconditionException()
+    {
+        super("The observed property specified in the monitor precondition is invalid." +
+                "Not included in the specified topic definition or not associated with MBean attributes.");
+    }
+}

Added: webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxCounterMonitorType.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxCounterMonitorType.java?rev=372516&view=auto
==============================================================================
--- webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxCounterMonitorType.java (added)
+++ webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxCounterMonitorType.java Thu Jan 26 04:14:27 2006
@@ -0,0 +1,223 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.muws.jmx.notification.monitor;
+
+import java.math.BigInteger;
+import java.util.Calendar;
+
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.MBeanServerConnection;
+import javax.management.Notification;
+import javax.management.monitor.CounterMonitor;
+import javax.management.monitor.MonitorNotification;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.muws.impl.CategoryImpl;
+import org.apache.ws.muws.jmx.util.WsdmJmxConstants;
+import org.apache.ws.muws.v1_0.MuwsConstants;
+import org.apache.ws.muws.v1_0.events.Situation;
+import org.apache.ws.muws.v1_0.events.impl.LangStringImpl;
+import org.apache.ws.muws.v1_0.events.impl.SituationImpl;
+
+/**
+ * Provides methods for creating MonitorMBean and receiving MonitorNotification
+ * regarding JMX CounterMonitor.
+ * 
+ * @author Hideharu Kato
+ *
+ */
+public class JmxCounterMonitorType extends JmxMonitorType
+{
+    private static final Log LOG = LogFactory.getLog(JmxCounterMonitorType.class);
+    
+    public static final String MONITORMBEAN_CLASS_NAME = CounterMonitor.class.getName();
+    
+    private boolean m_diffMode;
+    private BigInteger m_modulus;
+    private boolean m_notify;
+    private BigInteger m_offset;
+    private BigInteger m_threshold;
+    
+    /**
+     * Sets DifferenceMode value of JMX CounterMonitor.
+     * 
+     * @param diffMode
+     */
+    public void setDifferenceMode(boolean diffMode)
+    {
+        m_diffMode = diffMode;
+    }
+
+    /**
+     * Sets Modulus value of JMX CounterMonitor.
+     * 
+     * @param modulus
+     */
+    public void setModulus(BigInteger modulus)
+    {
+        m_modulus = modulus;
+    }
+
+    /**
+     * Sets Notify value of JMX CounterMonitor.
+     * 
+     * @param notify
+     */
+    public void setNotify(boolean notify)
+    {
+        m_notify = notify;
+    }
+
+    /**
+     * Sets Offset value of JMX CounterMonitor.
+     * 
+     * @param offset
+     */
+    public void setOffset(BigInteger offset)
+    {
+        m_offset = offset;
+    }
+
+    /**
+     * Sets Threshold value of JMX CounterMonitor.
+     * 
+     * @param threshold
+     */
+    public void setThreshold(BigInteger threshold)
+    {
+        m_threshold = threshold;
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.monitorresource.JmxMonitorType#subscribe()
+     */
+    protected void subscribe() throws MonitorSubscriptionFailedException 
+    {    
+        try
+        {  
+            super.subscribe();
+            
+            MBeanServerConnection mbs = getMBeanServerConnection();
+            
+            mbs.createMBean(JmxCounterMonitorType.MONITORMBEAN_CLASS_NAME, getMonitorObjectName());    
+            LOG.debug("Created CounterMonitor. ObjectName = [" + getMonitorObjectName() + "]");
+            
+            mbs.addNotificationListener(getMonitorObjectName(), getMonitorMBeanResource(), null, null);
+            LOG.debug("Added JmxMonitorMBeanResource as NotificationListener to [" + getMonitorObjectName() + "]");
+            
+            AttributeList al = new AttributeList();
+            
+            al.add(new Attribute("ObservedObject", getObservedObject()));
+            al.add(new Attribute("ObservedAttribute", getObservedAttribute()));
+            al.add(new Attribute("GranularityPeriod", new Long(getGranularityPeriod())));
+                
+            if(getObservedAttributeType().equals("java.lang.Integer") 
+                      || getObservedAttributeType().equals("int"))
+            {
+                al.add( new Attribute( "Modulus", new Integer( m_modulus.intValue() ) ) );
+                al.add( new Attribute( "Offset", new Integer( m_offset.intValue() ) ) );
+                al.add( new Attribute( "Threshold" , new Integer( m_threshold.intValue() ) ) );
+            }
+            else if(getObservedAttributeType().equals("java.lang.Long") 
+                      || getObservedAttributeType().equals("long"))
+            {
+                al.add( new Attribute( "Modulus", new Long( m_modulus.longValue() ) ) );
+                al.add( new Attribute( "Offset", new Long( m_offset.longValue() ) ) );
+                al.add( new Attribute( "Threshold" , new Long( m_threshold.longValue() ) ) );    
+            }
+            else if(getObservedAttributeType().equals("java.lang.Short") 
+                      || getObservedAttributeType().equals("short"))
+            {
+                al.add( new Attribute( "Modulus", new Short( m_modulus.shortValue() ) ) );
+                al.add( new Attribute( "Offset", new Short( m_offset.shortValue() ) ) );
+                al.add( new Attribute( "Threshold" , new Short( m_threshold.shortValue() ) ) ); 
+            }
+            else if(getObservedAttributeType().equals("java.lang.Byte") 
+                      || getObservedAttributeType().equals("byte"))
+            {
+                al.add( new Attribute( "Modulus", new Byte( m_modulus.byteValue() ) ) );
+                al.add( new Attribute( "Offset", new Byte( m_offset.byteValue() ) ) );
+                al.add( new Attribute( "Threshold" , new Byte( m_threshold.byteValue() ) ) );
+            }
+            al.add(new Attribute("DifferenceMode",new Boolean(m_diffMode)));
+            al.add(new Attribute("Notify", new Boolean(m_notify)));
+            
+            mbs.setAttributes(getMonitorObjectName(), al);
+            
+            mbs.invoke(getMonitorObjectName(), "start", null, null);
+            
+            LOG.debug("CounterMonitor [" + getMonitorObjectName() + "] started." +
+                    " Observed Object = [" + getObservedObject() +"]," +
+                    " Observed Attribute Name = " + getObservedAttribute() + 
+                    " Type = " + getObservedAttributeType() + "," +
+                    " GranularityPeriod = " + getGranularityPeriod() + "," +
+                    " DifferenceMode = " + m_diffMode + "," +
+                    " Modulus = " + m_modulus + "," +
+                    " Offset = " + m_offset + "," +
+                    " Notify = " + m_notify + "," +
+                    " Threshold = " + m_threshold);
+        }
+        catch(Exception e)
+        {
+            LOG.error("Subscribe JmxCounterMonitor failed. Cause: " + e.getLocalizedMessage());
+            
+            throw new MonitorSubscriptionFailedException("Subscribe JmxCounterMonitor failed", e);
+        }
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.monitorresource.JmxMonitorType#createSituation(javax.management.Notification)
+     */
+    protected Situation createSituation(Notification notification) 
+        throws InvalidMonitorNotificationReceivedException
+    {
+        String type = notification.getType();
+        if(type == null)
+        {
+            LOG.warn("Received a notification with null type.");
+            throw new InvalidMonitorNotificationReceivedException(notification);
+        }
+        CategoryImpl category = null;
+        QName situationName = null;
+        String situationMessage = null;
+        
+        if(type.equals(MonitorNotification.THRESHOLD_VALUE_EXCEEDED))
+        {
+            situationName = new QName( WsdmJmxConstants.BASE_URI_MUSE_MONITOR, "CounterSituation", "mm" );
+            situationMessage = "Exceeded the threshold.";
+        }
+        else
+        {
+            LOG.warn("Received a notification with unexpected type.");
+            throw new InvalidMonitorNotificationReceivedException(notification);
+        }
+        category = new CategoryImpl(situationName);
+        category.setGeneralization(new CategoryImpl(MuwsConstants.SITUATION_REPORT)); 
+        
+        Situation situation = new SituationImpl(category);
+        Calendar situationTime = Calendar.getInstance();
+        situationTime.setTimeInMillis(notification.getTimeStamp());
+        situation.setSituationTime(situationTime);
+        situation.setMessage(new LangStringImpl(situationMessage, "en"));
+        
+        return situation;
+    }
+}

Added: webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxGaugeMonitorType.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxGaugeMonitorType.java?rev=372516&view=auto
==============================================================================
--- webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxGaugeMonitorType.java (added)
+++ webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxGaugeMonitorType.java Thu Jan 26 04:14:27 2006
@@ -0,0 +1,280 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.muws.jmx.notification.monitor;
+
+import java.util.Calendar;
+
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.MBeanServerConnection;
+import javax.management.Notification;
+import javax.management.monitor.GaugeMonitor;
+import javax.management.monitor.MonitorNotification;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.muws.impl.CategoryImpl;
+import org.apache.ws.muws.jmx.util.WsdmJmxConstants;
+import org.apache.ws.muws.v1_0.MuwsConstants;
+import org.apache.ws.muws.v1_0.events.Situation;
+import org.apache.ws.muws.v1_0.events.impl.LangStringImpl;
+import org.apache.ws.muws.v1_0.events.impl.SituationImpl;
+
+/**
+ * Provides methods for creating MonitorMBean and receiving MonitorNotification
+ * regarding JMX GaugeMonitor.
+ * 
+ * @author Hideharu Kato
+ * 
+ */
+public class JmxGaugeMonitorType extends JmxMonitorType
+{
+    private static final Log LOG = LogFactory.getLog(JmxGaugeMonitorType.class);
+    
+    public static final String MONITORMBEAN_CLASS_NAME = GaugeMonitor.class.getName();
+    
+    private boolean m_diffMode;
+    private Number m_highThreshold;
+    private Number m_lowThreshold;
+    private boolean m_notifyHigh;
+    private boolean m_notifyLow;
+    
+    /**
+     * Sets DifferenceMode value of JMX GaugeMonitor.
+     * 
+     * @param diffMode
+     */
+    public void setDifferenceMode(boolean diffMode)
+    {
+        m_diffMode = diffMode;
+    }
+
+    /**
+     * Sets HighThreshold value of JMX GaugeMonitor.
+     * 
+     * @param highThreshold
+     */
+    public void setHighThreshold(Number highThreshold)
+    {
+        m_highThreshold = highThreshold;
+    }
+
+    /**
+     * Sets LowThreshold value of JMX GaugeMonitor.
+     * 
+     * @param lowThreshold
+     */
+    public void setLowThreshold(Number lowThreshold)
+    {
+        m_lowThreshold = lowThreshold;
+    }
+
+    /**
+     * Sets NotifyHigh value of JMX GaugeMonitor.
+     * 
+     * @param notifyHigh
+     */
+    public void setNotifyHigh(boolean notifyHigh)
+    {
+        m_notifyHigh = notifyHigh;
+    }
+    
+    /**
+     * Sets NotifyLow value of JMX GaugeMonitor.
+     * 
+     * @param notifyLow
+     */
+    public void setNotifyLow(boolean notifyLow)
+    {
+        m_notifyLow = notifyLow;
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.monitorresource.JmxMonitorType#subscribe()
+     */
+    protected void subscribe() throws MonitorSubscriptionFailedException 
+    {    
+        try
+        {
+            super.subscribe();
+            
+            MBeanServerConnection mbs = getMBeanServerConnection();
+            
+            mbs.createMBean(JmxGaugeMonitorType.MONITORMBEAN_CLASS_NAME, getMonitorObjectName());
+            LOG.debug("Created GaugeMonitor. ObjectName = [" + getMonitorObjectName() + "]");
+            
+            mbs.addNotificationListener(getMonitorObjectName(), getMonitorMBeanResource(), null, null);
+            LOG.debug("Added JmxMonitorMBeanResource as NotificationListener to [" + getMonitorObjectName() + "]");
+            
+            AttributeList al = new AttributeList();
+            
+            al.add(new Attribute("ObservedObject", getObservedObject()));
+            al.add(new Attribute("ObservedAttribute", getObservedAttribute()));
+                
+            al.add(new Attribute("GranularityPeriod", new Long(getGranularityPeriod())));
+            al.add(new Attribute("DifferenceMode", new Boolean(m_diffMode)));
+            al.add(new Attribute("NotifyHigh", new Boolean(m_notifyHigh)));
+            al.add(new Attribute("NotifyLow", new Boolean(m_notifyLow)));
+                
+            mbs.setAttributes(getMonitorObjectName(), al);
+                  
+            if(getObservedAttributeType().equals("java.lang.Integer") 
+                      || getObservedAttributeType().equals("int"))
+            {
+                mbs.invoke(
+                        getMonitorObjectName(), 
+                        "setThresholds",
+                        new Object[]{
+                                new Integer(m_highThreshold.intValue()), 
+                                new Integer(m_lowThreshold.intValue())
+                        },
+                        new String[]{"java.lang.Number", "java.lang.Number"}
+                );
+            }
+            else if(getObservedAttributeType().equals("java.lang.Double") 
+                      || getObservedAttributeType().equals("double"))
+            {
+                mbs.invoke(
+                        getMonitorObjectName(), 
+                        "setThresholds", 
+                        new Object[]{
+                                new Double(m_highThreshold.doubleValue()), 
+                                new Double(m_lowThreshold.doubleValue())
+                        },
+                        new String[]{"java.lang.Number", "java.lang.Number"}
+                );    
+            }
+            else if(getObservedAttributeType().equals("java.lang.Float") 
+                    || getObservedAttributeType().equals("float"))
+            {
+                mbs.invoke(
+                        getMonitorObjectName(), 
+                        "setThresholds", 
+                        new Object[]{
+                                new Float(m_highThreshold.floatValue()), 
+                                new Float(m_lowThreshold.floatValue())
+                        },
+                        new String[]{"java.lang.Number", "java.lang.Number"}
+                );    
+            }
+            else if(getObservedAttributeType().equals("java.lang.Long") 
+                      || getObservedAttributeType().equals("long"))
+            {
+                mbs.invoke(
+                        getMonitorObjectName(), 
+                        "setThresholds", 
+                        new Object[]{
+                                new Long(m_highThreshold.longValue()), 
+                                new Long(m_lowThreshold.longValue())
+                        },
+                        new String[]{"java.lang.Number", "java.lang.Number"}
+                );    
+            }
+            else if(getObservedAttributeType().equals("java.lang.Short") 
+                    || getObservedAttributeType().equals("short"))
+            {
+                mbs.invoke(
+                        getMonitorObjectName(), 
+                        "setThresholds", 
+                        new Object[]{
+                                new Short(m_highThreshold.shortValue()), 
+                                new Short(m_lowThreshold.shortValue())
+                        },
+                        new String[]{"java.lang.Number", "java.lang.Number"}
+                );    
+            }
+            else if(getObservedAttributeType().equals("java.lang.Byte") 
+                      || getObservedAttributeType().equals("byte"))
+            {
+                mbs.invoke(
+                        getMonitorObjectName(), 
+                        "setThresholds", 
+                        new Object[]{
+                                  new Byte(m_highThreshold.byteValue()), 
+                                  new Byte(m_lowThreshold.byteValue())
+                          },
+                          new String[]{"java.lang.Number", "java.lang.Number"}
+                  );
+            }
+            
+            mbs.invoke(getMonitorObjectName(), "start", null, null);                
+
+            LOG.debug("GaugeMonitor [" + getMonitorObjectName() + "] started." +
+                    " Observed Object = [" + getObservedObject() +"]," +
+                    " Observed Attribute Name = " + getObservedAttribute() + 
+                    " Type = " + getObservedAttributeType() + "," +
+                    " GranularityPeriod = " + getGranularityPeriod() + "," +
+                    " DifferenceMode = " + m_diffMode + "," +
+                    " NotifyHigh = " + m_notifyHigh + "," +
+                    " NotifyLow = " + m_notifyLow + "," +
+                    " HighThreshold = " + m_highThreshold + "," +
+                    " LowThreshold = " + m_lowThreshold);
+        }
+        catch(Exception e)
+        {
+            LOG.error("Subscribe JmxGaugeMonitor failed. Cause: " + e.getLocalizedMessage());
+            
+            throw new MonitorSubscriptionFailedException("Subscribe JmxGaugeMonitor failed", e);
+        }
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.monitorresource.JmxMonitorType#createSituation(javax.management.Notification)
+     */
+    protected Situation createSituation(Notification notification) 
+        throws InvalidMonitorNotificationReceivedException
+    {        
+        String type = notification.getType();
+        if(type == null)
+        {
+            LOG.warn("Received a notification with null type.");
+            throw new InvalidMonitorNotificationReceivedException(notification);
+        }
+        
+        CategoryImpl category = null;
+        QName situationName = null;
+        String situationMessage = null;
+        
+        if(type.equals(MonitorNotification.THRESHOLD_HIGH_VALUE_EXCEEDED))
+        {
+            situationName = new QName( WsdmJmxConstants.BASE_URI_MUSE_MONITOR, "GaugeHighSituation", "mm" );
+            situationMessage = "Exceeded the high threshold.";
+        }
+        else if(type.equals(MonitorNotification.THRESHOLD_LOW_VALUE_EXCEEDED))
+        {
+            situationName = new QName( WsdmJmxConstants.BASE_URI_MUSE_MONITOR, "GaugeLowSituation", "mm" );
+            situationMessage = "Exceeded the low threshold.";
+        }
+        else
+        {
+            LOG.warn("Received a notification with unexpected type.");
+            throw new InvalidMonitorNotificationReceivedException(notification);
+        }
+        category = new CategoryImpl(situationName);
+        category.setGeneralization(new CategoryImpl(MuwsConstants.SITUATION_REPORT)); 
+        
+        Situation situation = new SituationImpl(category);
+        Calendar situationTime = Calendar.getInstance();
+        situationTime.setTimeInMillis(notification.getTimeStamp());
+        situation.setSituationTime(situationTime);
+        situation.setMessage(new LangStringImpl(situationMessage, "en"));
+        
+        return situation;
+    }
+}

Added: webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxMonitorMBeanResource.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxMonitorMBeanResource.java?rev=372516&view=auto
==============================================================================
--- webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxMonitorMBeanResource.java (added)
+++ webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxMonitorMBeanResource.java Thu Jan 26 04:14:27 2006
@@ -0,0 +1,149 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.muws.jmx.notification.monitor;
+
+import javax.management.Notification;
+import javax.management.ObjectName;
+import javax.management.monitor.MonitorNotification;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.muws.jmx.notification.JmxSubscriptionResource;
+import org.apache.ws.muws.jmx.resource.properties.PropertyValue;
+import org.apache.ws.muws.v1_0.events.Situation;
+import org.apache.ws.notification.topics.Topic;
+
+/**
+ * Provides methods for accessing to JMX MonitorMBean.
+ *
+ * @author Hideharu Kato
+ * 
+ */
+public class JmxMonitorMBeanResource extends MonitorMBeanResource
+{
+    private static final Log LOG = LogFactory.getLog(JmxMonitorMBeanResource.class);
+    
+    /**
+     * Represents a type of JMX MonitorMBean.
+     */
+    private JmxMonitorType m_monitorType;
+    
+    /**
+     * Creates a new {@link JmxMonitorMBeanResource} object.
+     * 
+     * @param subscription          Subscription resource associated with this {@link JmxMonitorMBeanResource}
+     * @param observedPropertyValue PropertyValue object represents the observed resource property
+     * @param targetTopics          Topic objects relating with the observed resource properties
+     * @param monitorType           {@link JmxMonitorType} object used for this monitoring
+     */
+    public JmxMonitorMBeanResource(
+            JmxSubscriptionResource subscription, 
+            PropertyValue observedPropertyValue, 
+            Topic[] targetTopics, 
+            JmxMonitorType monitorType)
+    {
+        super(subscription, observedPropertyValue, targetTopics);
+        
+        m_monitorType = monitorType;        
+        m_monitorType.setMonitorMBeanResource(this);
+        
+        LOG.debug("A new JmxMonitorMBeanResource object is created. " +
+                "Associated subscription resource id = " + subscription.getID());
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.monitorresource.MonitorMBeanResource#subscribe()
+     */
+    public void subscribe() throws MonitorSubscriptionFailedException
+    {   
+        m_monitorType.subscribe();
+
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.monitorresource.MonitorMBeanResource#unsubscribe()
+     */
+    public void unsubscribe() throws MonitorSubscriptionFailedException
+    {
+        m_monitorType.unsubscribe();
+   
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.notification.monitor.MonitorMBeanResource#pause()
+     */
+    public void pause() throws MonitorSubscriptionFailedException
+    {
+        m_monitorType.pause();
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.notification.monitor.MonitorMBeanResource#resume()
+     */
+    public void resume() throws MonitorSubscriptionFailedException
+    {
+        m_monitorType.resume();
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.monitorresource.MonitorMBeanResource#createSituation(javax.management.Notification)
+     */
+    Situation createSituation(Notification notification) 
+        throws InvalidMonitorNotificationReceivedException
+    {
+        if(notification == null)
+        {
+            throw new IllegalArgumentException("notification MUST NOT be null.");
+        }
+        
+        return m_monitorType.createSituation(notification);
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.monitorresource.MonitorMBeanResource#getObservedObject(javax.management.Notification)
+     */
+    ObjectName getObservedObject(Notification notification)
+    {
+        if(notification == null)
+        {
+            throw new IllegalArgumentException("notification MUST NOT be null.");
+        }
+        
+        ObjectName observedObject = ((MonitorNotification) notification).getObservedObject();
+        return observedObject;
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.monitorresource.MonitorMBeanResource#getObservedAttribute(javax.management.Notification)
+     */
+    String getObservedAttribute(Notification notification)
+    {
+        if(notification == null)
+        {
+            throw new IllegalArgumentException("notification MUST NOT be null.");
+        }
+        
+        String observedAttribute = ((MonitorNotification) notification).getObservedAttribute();
+        return observedAttribute;
+    }
+}

Added: webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxMonitorType.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxMonitorType.java?rev=372516&view=auto
==============================================================================
--- webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxMonitorType.java (added)
+++ webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxMonitorType.java Thu Jan 26 04:14:27 2006
@@ -0,0 +1,241 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.muws.jmx.notification.monitor;
+
+import java.util.Hashtable;
+
+import javax.management.MBeanServerConnection;
+import javax.management.MalformedObjectNameException;
+import javax.management.Notification;
+import javax.management.ObjectName;
+import javax.xml.namespace.QName;
+
+import org.apache.ws.muws.jmx.resource.MBeanServerAccessFailedException;
+import org.apache.ws.muws.v1_0.events.Situation;
+
+/**
+ * Represents a type of JMX MonitorMBean associated with {@link JmxMonitorMBeanResource}.
+ * {@link JmxMonitorType} is abstract class for {@link JmxCounterMonitorType}, 
+ * {@link JmxGaugeMonitorType} and {@link JmxStringMonitorType}.
+ * 
+ * @author Hideharu Kato
+ * 
+ */
+public abstract class JmxMonitorType
+{
+    private long m_gPeriod;
+    private QName m_observedPropertyName;
+    private JmxMonitorMBeanResource m_monitorMBeanResource;
+    private ObjectName m_monitorObjectName;
+
+    /**
+     * Sets GranularityPeriod value of JMX MonitorMBean.
+     * 
+     * @param gPeriod
+     */
+    public void setGranularityPeriod(long gPeriod)
+    {
+        m_gPeriod = gPeriod;
+    }
+
+    /**
+     * Sets the observed ResourceProperty QName.
+     * 
+     * @param observedPropertyName
+     */
+    public void setObservedPropertyName(QName observedPropertyName)
+    {
+        m_observedPropertyName = observedPropertyName;
+    }
+    
+    /**
+     * Returns the observed ResourceProperty name.
+     * 
+     * @return QName of the observed ResourceProperty
+     */
+    public QName getObservedPropertyName()
+    {
+        return m_observedPropertyName;
+    }
+
+    /**
+     * Starts monitoring.
+     * @throws MBeanServerAccessFailedException 
+     * @throws MonitorSubscriptionFailedException 
+     * 
+     * @throws Exception
+     */
+    protected void subscribe() throws MonitorSubscriptionFailedException
+    {       
+        Hashtable props = new Hashtable();
+        props.put("id", (String)m_monitorMBeanResource.getSubscription().getID());              
+        props.put("attribute", getObservedAttribute());
+        
+        try
+        {
+            m_monitorObjectName = 
+                    new ObjectName(MonitorMBeanResource.MONITOR_DOMAIN, props);
+        }
+        catch (MalformedObjectNameException e)
+        {
+            throw new MonitorSubscriptionFailedException(e);
+        }
+    }
+
+    /**
+     * Stops monitoring.
+     * @throws MonitorSubscriptionFailedException 
+     * 
+     * @throws Exception
+     */
+    protected void unsubscribe() throws MonitorSubscriptionFailedException
+    {
+        try
+        {
+            MBeanServerConnection mbs = getMBeanServerConnection();
+            mbs.removeNotificationListener(m_monitorObjectName, m_monitorMBeanResource);
+            mbs.unregisterMBean(m_monitorObjectName);
+        }   
+        catch (Exception e)
+        {
+            throw new MonitorSubscriptionFailedException("Unsubscribe failed", e);
+        }
+    }
+    
+    /**
+     * Returns the GranularityPeriod value.
+     * 
+     * @return The GranularityPeriod value
+     */
+    protected long getGranularityPeriod()
+    {
+        return m_gPeriod;
+    }
+    
+    /**
+     * Returns the object name of the MonitorMBean used for this {@link JmxMonitorType}.
+     * 
+     * @return ObjectName
+     */
+    protected ObjectName getMonitorObjectName()
+    {
+        return m_monitorObjectName;
+    }
+    
+    /**
+     * Returns the {@link JmxMonitorMBeanResource} associated with this {@link JmxMonitorType}.
+     * 
+     * @return The {@link JmxMonitorMBeanResource} associated with this {@link JmxMonitorType}
+     */
+    protected JmxMonitorMBeanResource getMonitorMBeanResource()
+    {
+        return m_monitorMBeanResource;
+    }
+    
+    /**
+     * Returns the observed object name.
+     * 
+     * @return The observed ObjectName
+     */
+    protected ObjectName getObservedObject()
+    {
+        return m_monitorMBeanResource.getObservedObject();
+    }
+    
+    /**
+     * Returns the observed attribute name.
+     * 
+     * @return The observed attribute name
+     */
+    protected String getObservedAttribute()
+    {
+        return m_monitorMBeanResource.getObservedAttribute();
+    }
+    
+    /**
+     * Returns the observed attribute type.
+     * 
+     * @return The observed attribute type
+     */
+    protected String getObservedAttributeType()
+    {
+        return m_monitorMBeanResource.getObservedAttributeType();
+    }
+    
+    /**
+     * Returns the instance of MBeanServerConnection used for this {@link JmxMonitorType}.
+     * 
+     * @return The instance of MBeanServerConnection used for this {@link JmxMonitorType}
+     */
+    protected MBeanServerConnection getMBeanServerConnection()
+    { 
+        return m_monitorMBeanResource.getMBeanServerConnection();
+    }
+    
+    /**
+     * Pause monitoring.
+     * 
+     * @throws MonitorSubscriptionFailedException
+     */
+    protected void pause() throws MonitorSubscriptionFailedException
+    {
+        try
+        {
+            getMBeanServerConnection().invoke(getMonitorObjectName(), "stop", null, null);
+        }
+        catch(Exception e)
+        {
+            throw new MonitorSubscriptionFailedException(e);
+        }      
+    }
+
+    /**
+     * Resumse monitoring.
+     * 
+     * @throws MonitorSubscriptionFailedException
+     */
+    protected void resume() throws MonitorSubscriptionFailedException
+    {
+        try
+        {
+            getMBeanServerConnection().invoke(getMonitorObjectName(), "start", null, null);  
+        }
+        catch(Exception e)
+        {
+            throw new MonitorSubscriptionFailedException(e);
+        }
+    }
+
+    /**
+     * Sets {@link MonitorMBeanResource} associated with this {@link JmxMonitorType}.
+     * 
+     * @param monitorMBeanResource {@link MonitorMBeanResource} associated with this {@link JmxMonitorType}
+     */
+    void setMonitorMBeanResource(JmxMonitorMBeanResource monitorMBeanResource)
+    {
+        m_monitorMBeanResource = monitorMBeanResource;
+    }
+
+    /**
+     * Returns Situation for the specified Notification.
+     * 
+     * @param notification
+     * @return Situation for the specified Notification
+     * @throws InvalidMonitorNotificationReceivedException
+     */
+    protected abstract Situation createSituation(Notification notification) 
+        throws InvalidMonitorNotificationReceivedException;
+}

Added: webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxStringMonitorType.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxStringMonitorType.java?rev=372516&view=auto
==============================================================================
--- webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxStringMonitorType.java (added)
+++ webservices/muse/trunk/wsdm-jmx/src/java/org/apache/ws/muws/jmx/notification/monitor/JmxStringMonitorType.java Thu Jan 26 04:14:27 2006
@@ -0,0 +1,176 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.muws.jmx.notification.monitor;
+
+import java.util.Calendar;
+
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.MBeanServerConnection;
+import javax.management.Notification;
+import javax.management.monitor.MonitorNotification;
+import javax.management.monitor.StringMonitor;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.muws.impl.CategoryImpl;
+import org.apache.ws.muws.jmx.util.WsdmJmxConstants;
+import org.apache.ws.muws.v1_0.MuwsConstants;
+import org.apache.ws.muws.v1_0.events.Situation;
+import org.apache.ws.muws.v1_0.events.impl.LangStringImpl;
+import org.apache.ws.muws.v1_0.events.impl.SituationImpl;
+
+/**
+ * Provides methods for creating MonitorMBean and receiving MonitorNotification
+ * regarding JMX StringMonitor.
+ * 
+ * @author Hideharu Kato
+ * 
+ */
+public class JmxStringMonitorType extends JmxMonitorType
+{
+    private static final Log LOG = LogFactory.getLog(JmxStringMonitorType.class);
+    
+    public static final String STRINGMONITOR_CLASS_NAME = StringMonitor.class.getName();
+    
+    private boolean m_notifyMatch;
+    private boolean m_notifyDiffer;
+    private String m_strToCompare;
+    
+    /**
+     * Sets NotifyMatch value of JMX StringMonitor.
+     * 
+     * @param notifyMatch
+     */
+    public void setNotifyMatch(boolean notifyMatch)
+    {
+        m_notifyMatch = notifyMatch;
+    }
+
+    /**
+     * Sets NotifyDiffer value of JMX StriingMonitor.
+     * 
+     * @param notifyDiffer
+     */
+    public void setNotifyDiffer(boolean notifyDiffer)
+    {
+        m_notifyDiffer = notifyDiffer;
+    }
+
+    /**
+     * Sets StringToCompare value of JMX StringMonitor.
+     * 
+     * @param strToCompare
+     */
+    public void setStringToCompare(String strToCompare)
+    {
+        m_strToCompare = strToCompare;
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.monitorresource.JmxMonitorType#subscribe()
+     */
+    protected void subscribe() throws MonitorSubscriptionFailedException 
+    {    
+        try
+        {     
+            super.subscribe();
+            
+            MBeanServerConnection mbs = getMBeanServerConnection();
+            
+            mbs.createMBean(JmxStringMonitorType.STRINGMONITOR_CLASS_NAME, getMonitorObjectName());
+            LOG.debug("Created StringMonitor. ObjectName = [" + getMonitorObjectName() + "]");
+            
+            mbs.addNotificationListener(getMonitorObjectName(), getMonitorMBeanResource(), null, null);
+            LOG.debug("Added JmxMonitorMBeanResource as NotificationListener to [" + getMonitorObjectName() + "]");
+            
+            AttributeList al = new AttributeList();
+            
+            al.add(new Attribute("ObservedObject", getObservedObject()));
+            al.add(new Attribute("ObservedAttribute", getObservedAttribute()));
+            al.add(new Attribute("GranularityPeriod", new Long(getGranularityPeriod())));
+            al.add(new Attribute("NotifyMatch", new Boolean(m_notifyMatch)));
+            al.add(new Attribute("NotifyDiffer", new Boolean(m_notifyDiffer)));
+            al.add(new Attribute("StringToCompare", m_strToCompare));
+                      
+            mbs.setAttributes(getMonitorObjectName(), al);
+            
+            mbs.invoke(getMonitorObjectName(), "start", null, null);
+            
+            LOG.debug("StringMonitor [" + getMonitorObjectName() + "] started." +
+                    " Observed Object = [" + getObservedObject() +"]," +
+                    " Observed Attribute Name = " + getObservedAttribute() + 
+                    " Type = " + getObservedAttributeType() + "," +
+                    " GranularityPeriod = " + getGranularityPeriod() + "," +
+                    " NotifyMatch = " + m_notifyMatch + "," +
+                    " NotifyDiffer = " + m_notifyDiffer + "," +
+                    " StringToCompare = " + m_strToCompare);   
+        }
+        catch(Exception e)
+        {
+            LOG.error("Subscribe JmxStringMonitor failed. Cause: " + e.getLocalizedMessage());
+            
+            throw new MonitorSubscriptionFailedException("Subscribe JmxStringMonitor failed", e);
+        }
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.apache.ws.muws.jmx.monitorresource.JmxMonitorType#createSituation(javax.management.Notification)
+     */
+    protected Situation createSituation(Notification notification) 
+        throws InvalidMonitorNotificationReceivedException
+    {
+        String type = notification.getType();
+        if(type == null)
+        {
+            LOG.warn("Received a notification with null type.");
+            throw new InvalidMonitorNotificationReceivedException(notification);
+        }
+        
+        CategoryImpl category = null;
+        QName situationName = null;
+        String situationMessage = null;
+        
+        if(type.equals(MonitorNotification.STRING_TO_COMPARE_VALUE_MATCHED))
+        {
+            situationName = new QName( WsdmJmxConstants.BASE_URI_MUSE_MONITOR, "StringMatchSituation", "mm" );
+            situationMessage = "Matched the string to compare.";
+        }
+        else if(type.equals(MonitorNotification.STRING_TO_COMPARE_VALUE_DIFFERED))
+        {
+            situationName = new QName( WsdmJmxConstants.BASE_URI_MUSE_MONITOR, "StringDifferSituation", "mm" );
+            situationMessage = "Differed from the string to compare.";
+        }
+        else
+        {
+            LOG.warn("Received a notification with unexpected type.");
+            throw new InvalidMonitorNotificationReceivedException(notification);
+        }
+        category = new CategoryImpl(situationName);
+        category.setGeneralization(new CategoryImpl(MuwsConstants.SITUATION_REPORT)); 
+        
+        Situation situation = new SituationImpl(category);
+        Calendar situationTime = Calendar.getInstance();
+        situationTime.setTimeInMillis(notification.getTimeStamp());
+        situation.setSituationTime(situationTime);
+        situation.setMessage(new LangStringImpl(situationMessage, "en"));
+        
+        return situation;
+    }
+}