You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-dev@ws.apache.org by sc...@apache.org on 2005/03/25 20:38:15 UTC

svn commit: r159049 - in incubator/muse/trunk/src/java/org/apache/ws/muws: impl/ v1_0/ v1_0/events/ v1_0/events/impl/ v1_0/topics/ v1_0/topics/impl/

Author: scamp
Date: Fri Mar 25 11:38:14 2005
New Revision: 159049

URL: http://svn.apache.org/viewcvs?view=rev&rev=159049
Log: (empty)


Added:
    incubator/muse/trunk/src/java/org/apache/ws/muws/impl/CategoryImpl.java
    incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/events/impl/
    incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/topics/ManagementEventTopic.java
    incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/topics/impl/XmlBeansManagementEventTopicImpl.java
Removed:
    incubator/muse/trunk/src/java/org/apache/ws/muws/impl/AbstractCategory.java
    incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/events/XmlBeansManagementEvent.java
    incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/topics/impl/ManagementEventTopicImpl.java
Modified:
    incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/MuwsConstants.java
    incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/events/ManagementEvent.java

Added: incubator/muse/trunk/src/java/org/apache/ws/muws/impl/CategoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/muse/trunk/src/java/org/apache/ws/muws/impl/CategoryImpl.java?view=auto&rev=159049
==============================================================================
--- incubator/muse/trunk/src/java/org/apache/ws/muws/impl/CategoryImpl.java (added)
+++ incubator/muse/trunk/src/java/org/apache/ws/muws/impl/CategoryImpl.java Fri Mar 25 11:38:14 2005
@@ -0,0 +1,77 @@
+/*=============================================================================*
+ *  Copyright 2005 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.impl;
+
+import org.apache.ws.muws.Category;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.ws.XmlObjectWrapper;
+import org.apache.xmlbeans.XmlObject;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.CategoryType;
+
+import javax.xml.namespace.QName;
+
+/**
+ * An XMLBeans-based implementation of a MUWS {@link Category}.
+ */
+public class CategoryImpl implements Category, XmlObjectWrapper
+{
+
+    private QName m_name;
+    private Category m_generalization;
+
+    public CategoryImpl( QName name )
+    {
+        m_name = name;
+    }
+
+    public CategoryImpl( QName name, Category generalization )
+    {
+        m_name = name;
+        m_generalization = generalization;
+    }
+
+    public QName getName()
+    {
+        return m_name;
+    }
+
+    public Category getGeneralization()
+    {
+        return m_generalization;
+    }
+
+    public boolean hasGeneralization()
+    {
+        return m_generalization != null;
+    }
+
+    public void setGeneralization( Category category )
+    {
+        m_generalization = category;
+    }
+
+    public XmlObject getXmlObject()
+    {
+        XmlObject categoryXBean = XmlObject.Factory.newInstance();
+        XmlObject xBean = categoryXBean;
+        for ( Category category = this; category != null; category = category.getGeneralization() )
+        {
+            xBean = XmlBeanUtils.addChildElement( xBean, category.getName() );
+        }
+        return categoryXBean;
+    }
+
+}

Modified: incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/MuwsConstants.java
URL: http://svn.apache.org/viewcvs/incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/MuwsConstants.java?view=diff&r1=159048&r2=159049
==============================================================================
--- incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/MuwsConstants.java (original)
+++ incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/MuwsConstants.java Fri Mar 25 11:38:14 2005
@@ -15,6 +15,8 @@
  */
 package org.apache.ws.muws.v1_0;
 
+import javax.xml.namespace.QName;
+
 /**
  * Constants for names defined by the MUWS 1.0 specifications.
  */
@@ -80,5 +82,21 @@
      * Namespace prefix for MUWS Part 2 topics.
      */
     String NSPREFIX_MUWS_PART2_TOPICS = "muws-p2-events";
+
+    /**
+     * Situation QNames
+     */
+    QName SITUATION_AVAILABILITY = new QName(NSURI_MUWS_PART2_SCHEMA, "AvailabilitySituation" ,NSPREFIX_MUWS_PART2_SCHEMA);
+    QName SITUATION_CAPABILITY = new QName(NSURI_MUWS_PART2_SCHEMA, "CapabilitySituation" ,NSPREFIX_MUWS_PART2_SCHEMA);
+    QName SITUATION_CONFIGURATION = new QName(NSURI_MUWS_PART2_SCHEMA, "ConfigurationSituation" ,NSPREFIX_MUWS_PART2_SCHEMA);
+    QName SITUATION_STOP = new QName(NSURI_MUWS_PART2_SCHEMA, "StopSituation" ,NSPREFIX_MUWS_PART2_SCHEMA);
+    QName SITUATION_START = new QName(NSURI_MUWS_PART2_SCHEMA, "StartSituation" ,NSPREFIX_MUWS_PART2_SCHEMA);
+    QName SITUATION_REQUEST = new QName(NSURI_MUWS_PART2_SCHEMA, "RequestSituation" ,NSPREFIX_MUWS_PART2_SCHEMA);
+    QName SITUATION_DESTROY = new QName(NSURI_MUWS_PART2_SCHEMA, "DestroySituation" ,NSPREFIX_MUWS_PART2_SCHEMA);
+    QName SITUATION_CREATE = new QName(NSURI_MUWS_PART2_SCHEMA, "CreateSituation" ,NSPREFIX_MUWS_PART2_SCHEMA);
+    QName SITUATION_DEPENDENCY = new QName(NSURI_MUWS_PART2_SCHEMA, "DependencySituation" ,NSPREFIX_MUWS_PART2_SCHEMA);
+    QName SITUATION_CONNECT = new QName(NSURI_MUWS_PART2_SCHEMA, "ConnectSituation" ,NSPREFIX_MUWS_PART2_SCHEMA);
+    QName SITUATION_REPORT = new QName(NSURI_MUWS_PART2_SCHEMA, "ReportSituation" ,NSPREFIX_MUWS_PART2_SCHEMA);
+    QName SITUATION_OTHER = new QName(NSURI_MUWS_PART2_SCHEMA, "OtherSituation" ,NSPREFIX_MUWS_PART2_SCHEMA);
 
 }

Modified: incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/events/ManagementEvent.java
URL: http://svn.apache.org/viewcvs/incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/events/ManagementEvent.java?view=diff&r1=159048&r2=159049
==============================================================================
--- incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/events/ManagementEvent.java (original)
+++ incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/events/ManagementEvent.java Fri Mar 25 11:38:14 2005
@@ -21,12 +21,11 @@
 
     void setSourceResourceId(String sourceResourceId);
 
-    void setEventId(String eventId);
-
     void setReporterComponentAddresses(Object[] reporterComponentAddresses);
 
     void setSourceComponentAddresses(Object[] sourceComponentAddresses);
 
     void setAny(Object[] any);
-     
+
+    Situation getSituation();
 }

Added: incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/topics/ManagementEventTopic.java
URL: http://svn.apache.org/viewcvs/incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/topics/ManagementEventTopic.java?view=auto&rev=159049
==============================================================================
--- incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/topics/ManagementEventTopic.java (added)
+++ incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/topics/ManagementEventTopic.java Fri Mar 25 11:38:14 2005
@@ -0,0 +1,16 @@
+package org.apache.ws.muws.v1_0.topics;
+
+import org.apache.ws.muws.v1_0.events.ManagementEvent;
+
+/**
+ * @author Sal Campana
+ */
+public interface ManagementEventTopic
+{
+    /**
+     * This method is used to send a ManagementEvent to subscribers to this topic.
+     *
+     * @param me
+     */
+    void publish(ManagementEvent me);
+}

Added: incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/topics/impl/XmlBeansManagementEventTopicImpl.java
URL: http://svn.apache.org/viewcvs/incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/topics/impl/XmlBeansManagementEventTopicImpl.java?view=auto&rev=159049
==============================================================================
--- incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/topics/impl/XmlBeansManagementEventTopicImpl.java (added)
+++ incubator/muse/trunk/src/java/org/apache/ws/muws/v1_0/topics/impl/XmlBeansManagementEventTopicImpl.java Fri Mar 25 11:38:14 2005
@@ -0,0 +1,125 @@
+package org.apache.ws.muws.v1_0.topics.impl;
+
+import org.apache.ws.XmlObjectWrapper;
+import org.apache.ws.muws.impl.CategoryImpl;
+import org.apache.ws.muws.v1_0.MuwsConstants;
+import org.apache.ws.muws.v1_0.events.ManagementEvent;
+import org.apache.ws.muws.v1_0.events.Situation;
+import org.apache.ws.muws.v1_0.events.impl.SituationImpl;
+import org.apache.ws.muws.v1_0.events.impl.XmlBeansManagementEvent;
+import org.apache.ws.muws.v1_0.topics.ManagementEventTopic;
+import org.apache.ws.notification.topics.ResourcePropertyValueChangeTopic;
+import org.apache.ws.notification.topics.impl.TopicImpl;
+import org.apache.ws.resource.properties.ResourcePropertyValueChangeEvent;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlObject;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ManagementEventDocument;
+
+
+/**
+ * @author Sal Campana
+ */
+public class XmlBeansManagementEventTopicImpl extends TopicImpl implements ResourcePropertyValueChangeTopic, ManagementEventTopic
+{
+    private ManagementEvent m_propChangeManagementEvent;
+
+
+    public XmlBeansManagementEventTopicImpl( String capabilityName )
+    {
+        super( capabilityName );
+
+    }
+
+    /**
+     * This operation is used to set the default ManagementEvent to
+     * be used when sending Property Changed Management Events.
+     *
+     * Note: The object must implement XmlObjectWrapper,  the getXmlObject() operation will be used to get a new instance
+     *       of the Management Event for use to throw the event.
+     *
+     * @param me
+     */
+    public void setPropChangeManagemntEvent (ManagementEvent me)
+    {
+        if(!(me instanceof XmlObjectWrapper))
+        {
+            throw new IllegalArgumentException("The Management Event must implement the XmlObjectWrpper interface.");
+        }
+        m_propChangeManagementEvent = me;
+    }
+
+    public void propertyChanged(ResourcePropertyValueChangeEvent event)
+    {
+        XmlObject me = buildManagementEvent(event);
+
+       Object msg;
+        if ( event instanceof XmlObjectWrapper )
+        {
+            msg = ((XmlObjectWrapper)event).getXmlObject();
+        }
+        else
+        {
+            msg = event;
+        }
+        try
+        {
+            publish( msg );
+        }
+        catch ( Exception e )
+        {
+            // TODO: do we want to throw this and cause the SetRP request to fault?
+            e.printStackTrace();
+        }
+    }
+
+    private XmlObject buildManagementEvent(ResourcePropertyValueChangeEvent event)
+    {
+        ManagementEventDocument me;
+        if(m_propChangeManagementEvent != null)
+        {
+            me = (ManagementEventDocument) ((XmlObjectWrapper)m_propChangeManagementEvent).getXmlObject();
+        }
+        else
+        {
+            Situation situation = new SituationImpl(new CategoryImpl(MuwsConstants.SITUATION_OTHER));
+            XmlBeansManagementEvent xme = new XmlBeansManagementEvent(situation);
+            me = (ManagementEventDocument) ((XmlObjectWrapper)xme).getXmlObject();
+        }
+
+        org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ManagementEventType managementEvent = me.getManagementEvent();
+        XmlBeanUtils.addChildElement(managementEvent, ((XmlObjectWrapper)event).getXmlObject());
+        return me;
+    }
+
+
+    /**
+     * This method is used to send a ManagementEvent to subscribers to this topic.
+     *
+     * precondition: The param ManagementEvent should be complete and not rely on
+     *              any setters in this topic.
+     *
+     * @param me
+     */
+    public void publish(ManagementEvent me)
+    {
+       Object msg;
+        if ( me instanceof XmlObjectWrapper )
+        {
+            msg = ((XmlObjectWrapper)me).getXmlObject();
+        }
+        else
+        {
+            msg = me;
+        }
+        try
+        {
+            publish( msg );
+        }
+        catch ( Exception e )
+        {
+            // TODO: do we want to throw this and cause the SetRP request to fault?
+            e.printStackTrace();
+        }
+    }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: muse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-dev-help@ws.apache.org