[savara-commits] savara SVN: r599 - in branches/experimental/2.0.x/bundles: org.savara.common/src/main/java/org/savara/common/model/annotation and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Jan 21 10:36:03 EST 2011


Author: objectiser
Date: 2011-01-21 10:36:02 -0500 (Fri, 21 Jan 2011)
New Revision: 599

Added:
   branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/annotation/
   branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/annotation/Annotation.java
   branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/util/AnnotationDefinitions.java
Modified:
   branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/util/InteractionUtil.java
   branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/util/PropertyName.java
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtil.java
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/InteractionConverterRuleImpl.java
   branches/experimental/2.0.x/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/impl/WSDLGeneratorImpl.java
   branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/java/org/savara/wsdl/generator/WSDLGeneratorTest.java
Log:
Change specific properties to be annotations, as these will have more structure (in general) and be applicable potentially through to monitoring.

Added: branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/annotation/Annotation.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/annotation/Annotation.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/annotation/Annotation.java	2011-01-21 15:36:02 UTC (rev 599)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008-11, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.common.model.annotation;
+
+/**
+ * This class represents a named annotation with a set of named
+ * properties.
+ *
+ */
+public class Annotation {
+
+	private String m_name=null;
+	private java.util.Map<String,Object> m_properties=
+				new java.util.HashMap<String, Object>();
+	
+	/**
+	 * The constructor initialized with the annotation name.
+	 * 
+	 * @param name The name
+	 */
+	public Annotation(String name) {
+		m_name = name;
+	}
+	
+	/**
+	 * This method returns the name.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(m_name);
+	}
+	
+	/**
+	 * This method sets the name.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {
+		m_name = name;
+	}
+	
+	/**
+	 * This method returns the properties associated
+	 * with this annotation.
+	 * 
+	 * @return The properties
+	 */
+	public java.util.Map<String,Object> getProperties() {
+		return(m_properties);
+	}
+	
+}

Added: branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/util/AnnotationDefinitions.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/util/AnnotationDefinitions.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/util/AnnotationDefinitions.java	2011-01-21 15:36:02 UTC (rev 599)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.common.model.util;
+
+public class AnnotationDefinitions {
+
+	// Annotations
+	public static final String INTERFACE = "Interface";
+	
+	public static final String FAULT = "Fault";
+	
+	// XSD sub types
+	public static final String XSD_ELEMENT = "XSDElement";
+	public static final String XSD_TYPE = "XSDType";
+	
+	
+	// Annotation property names
+	public static final String NAME="name";
+	
+}

Modified: branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/util/InteractionUtil.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/util/InteractionUtil.java	2011-01-19 23:31:05 UTC (rev 598)
+++ branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/util/InteractionUtil.java	2011-01-21 15:36:02 UTC (rev 599)
@@ -17,6 +17,7 @@
  */
 package org.savara.common.model.util;
 
+import org.savara.common.model.annotation.Annotation;
 import org.scribble.protocol.model.*;
 
 /**
@@ -220,7 +221,7 @@
 		
 		if (isResponse(interaction) &&
 				interaction.getMessageSignature().getProperties().
-						keySet().contains(PropertyName.FAULT_NAME)) {
+						keySet().contains(AnnotationDefinitions.FAULT)) {
 			ret = true;
 		}
 
@@ -239,7 +240,7 @@
 		
 		if (InteractionUtil.isResponse(interaction) &&
 				interaction.getMessageSignature().getProperties().
-						keySet().contains(PropertyName.FAULT_NAME)) {
+						keySet().contains(AnnotationDefinitions.FAULT)) {
 			ret = true;
 		}
 
@@ -254,8 +255,15 @@
 	 * @return The fault name, or null if not found
 	 */
 	public static String getFaultName(Interaction interaction) {
-		return((String)interaction.
-			getMessageSignature().getProperties().get(PropertyName.FAULT_NAME));
+		String ret=null;
+		Annotation annotation=(Annotation)interaction.
+			getMessageSignature().getProperties().get(AnnotationDefinitions.FAULT);
+		
+		if (annotation != null) {
+			ret = (String)annotation.getProperties().get(AnnotationDefinitions.NAME);
+		}
+		
+		return(ret);
 	}
 	
 	/**
@@ -266,8 +274,15 @@
 	 * @return The fault name, or null if not found
 	 */
 	public static String getFaultName(When interaction) {
-		return((String)interaction.
-			getMessageSignature().getProperties().get(PropertyName.FAULT_NAME));
+		String ret=null;
+		Annotation annotation=(Annotation)interaction.
+			getMessageSignature().getProperties().get(AnnotationDefinitions.FAULT);
+		
+		if (annotation != null) {
+			ret = (String)annotation.getProperties().get(AnnotationDefinitions.NAME);
+		}
+		
+		return(ret);
 	}
 	
 }

Modified: branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/util/PropertyName.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/util/PropertyName.java	2011-01-19 23:31:05 UTC (rev 598)
+++ branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/util/PropertyName.java	2011-01-21 15:36:02 UTC (rev 599)
@@ -25,15 +25,7 @@
 	
 	public static final String NAMESPACE = "Namespace";
 	
-	public static final String INTERFACE_NAME = "InterfaceName";
-	
-	public static final String FAULT_NAME = "FaultName";
-	
 	public static final String REQUEST_LABEL = "RequestLabel";
 	public static final String REPLY_TO_LABEL = "ReplyToLabel";
 
-	// XSD sub types
-	public static final String XSD_ELEMENT = "XSDElement";
-	public static final String XSD_TYPE = "XSDType";
-	
 }

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtil.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtil.java	2011-01-19 23:31:05 UTC (rev 598)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtil.java	2011-01-21 15:36:02 UTC (rev 599)
@@ -29,6 +29,8 @@
 import org.pi4soa.cdl.ParticipantType;
 import org.pi4soa.cdl.util.CDLTypeUtil;
 import org.pi4soa.common.xml.XMLUtils;
+import org.savara.common.model.annotation.Annotation;
+import org.savara.common.model.util.AnnotationDefinitions;
 import org.savara.common.model.util.PropertyName;
 import org.savara.common.model.util.TypeSystem;
 import org.scribble.protocol.model.*;
@@ -61,10 +63,12 @@
 		
 		if (org.pi4soa.common.util.NamesUtil.isSet(infoType.getTypeName())) {
 			typeName = infoType.getTypeName();
-			ret.getProperties().put(PropertyName.XSD_TYPE, "true");
+			ret.getProperties().put(AnnotationDefinitions.XSD_TYPE,
+									new Annotation(AnnotationDefinitions.XSD_TYPE));
 		} else if (org.pi4soa.common.util.NamesUtil.isSet(infoType.getElementName())) {
 			typeName = infoType.getElementName();
-			ret.getProperties().put(PropertyName.XSD_ELEMENT, "true");
+			ret.getProperties().put(AnnotationDefinitions.XSD_ELEMENT,
+					new Annotation(AnnotationDefinitions.XSD_ELEMENT));
 		}
 		
 		if (typeName != null) {

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/InteractionConverterRuleImpl.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/InteractionConverterRuleImpl.java	2011-01-19 23:31:05 UTC (rev 598)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/InteractionConverterRuleImpl.java	2011-01-21 15:36:02 UTC (rev 599)
@@ -25,6 +25,8 @@
 
 import org.pi4soa.cdl.*;
 import org.pi4soa.cdl.Interaction;
+import org.savara.common.model.annotation.Annotation;
+import org.savara.common.model.util.AnnotationDefinitions;
 import org.savara.common.model.util.PropertyName;
 import org.savara.common.model.util.TypeSystem;
 import org.scribble.protocol.model.*;
@@ -348,9 +350,10 @@
 
 			// Set interface name
 			if (cdl.getToRoleType() != null) {
-				// TODO: Deal with interfaces that have multiple behaviours
-				interaction.getProperties().put(PropertyName.INTERFACE_NAME,
-						getInterfaceName(cdl));
+				// TODO: Deal with interfaces that have multiple behaviours	
+				Annotation annotation=new Annotation(AnnotationDefinitions.INTERFACE);
+				annotation.getProperties().put(AnnotationDefinitions.NAME, getInterfaceName(cdl));
+				interaction.getProperties().put(annotation.getName(), annotation);
 			}
 			
 			interaction.setFromRole(new Role(getFromRole(context, details)));
@@ -730,8 +733,10 @@
 		ms.setOperation(cdl.getOperation());
 		
 		if (NamesUtil.isSet(details.getFaultName())) {
-			ms.getProperties().put(PropertyName.FAULT_NAME,
-					details.getFaultName());
+			Annotation annotation=new Annotation(AnnotationDefinitions.FAULT);
+			annotation.getProperties().put(AnnotationDefinitions.NAME, details.getFaultName());
+
+			ms.getProperties().put(annotation.getName(), annotation);
 		}
 
 		// Define interaction message type

Modified: branches/experimental/2.0.x/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/impl/WSDLGeneratorImpl.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/impl/WSDLGeneratorImpl.java	2011-01-19 23:31:05 UTC (rev 598)
+++ branches/experimental/2.0.x/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/impl/WSDLGeneratorImpl.java	2011-01-21 15:36:02 UTC (rev 599)
@@ -22,6 +22,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.savara.common.model.util.AnnotationDefinitions;
 import org.savara.common.model.util.PropertyName;
 import org.savara.common.model.util.TypeSystem;
 import org.savara.contract.model.FaultDetails;
@@ -513,7 +514,7 @@
 					Part part=defn.createPart();
 					part.setName("content");
 					
-					if (td.getProperties().containsKey(PropertyName.XSD_ELEMENT)) {
+					if (td.getProperties().containsKey(AnnotationDefinitions.XSD_ELEMENT)) {
 						part.setElementName(qname);					
 					} else {
 						part.setTypeName(qname);

Modified: branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/java/org/savara/wsdl/generator/WSDLGeneratorTest.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/java/org/savara/wsdl/generator/WSDLGeneratorTest.java	2011-01-19 23:31:05 UTC (rev 598)
+++ branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/java/org/savara/wsdl/generator/WSDLGeneratorTest.java	2011-01-21 15:36:02 UTC (rev 599)
@@ -20,6 +20,8 @@
 import javax.wsdl.Part;
 import javax.xml.namespace.QName;
 
+import org.savara.common.model.annotation.Annotation;
+import org.savara.common.model.util.AnnotationDefinitions;
 import org.savara.common.model.util.PropertyName;
 import org.savara.common.model.util.TypeSystem;
 import org.savara.contract.model.*;
@@ -177,7 +179,7 @@
 		ref1.setName(TEST_TYPE_LP);
 		ref1.setDataType(new QName(TEST_NAME_SPACE,TEST_TYPE_LP).toString());
 		ref1.setTypeSystem(TypeSystem.XSD);
-		ref1.getProperties().put(PropertyName.XSD_TYPE, "true");
+		ref1.getProperties().put(AnnotationDefinitions.XSD_TYPE, new Annotation(AnnotationDefinitions.XSD_TYPE));
 		c.getTypeDefinitions().add(ref1);
 		
 		i1.getMessageExchangePatterns().add(m1);
@@ -279,7 +281,7 @@
 		ref.setName(TEST_TYPE_LP);
 		ref.setDataType(new QName(TEST_TYPE_NS,TEST_TYPE_LP).toString());
 		ref.setTypeSystem(TypeSystem.XSD);
-		ref.getProperties().put(PropertyName.XSD_TYPE, "true");
+		ref.getProperties().put(AnnotationDefinitions.XSD_TYPE, new Annotation(AnnotationDefinitions.XSD_TYPE));
 		c.getTypeDefinitions().add(ref);
 
 		/*
@@ -349,7 +351,7 @@
 		ref1.setName(TEST_TYPE_LP);
 		ref1.setDataType(new QName(TEST_TYPE_NS,TEST_TYPE_LP).toString());
 		ref1.setTypeSystem(TypeSystem.XSD);
-		ref1.getProperties().put(PropertyName.XSD_TYPE, "true");
+		ref1.getProperties().put(AnnotationDefinitions.XSD_TYPE, new Annotation(AnnotationDefinitions.XSD_TYPE));
 		c.getTypeDefinitions().add(ref1);
 
 		/*
@@ -465,7 +467,7 @@
 		src.setName(TEST_TYPE_LP);
 		src.setDataType(new QName(TEST_TYPE_NS,TEST_TYPE_LP).toString());
 		src.setTypeSystem(TypeSystem.XSD);
-		src.getProperties().put(PropertyName.XSD_TYPE, "true");
+		src.getProperties().put(AnnotationDefinitions.XSD_TYPE, new Annotation(AnnotationDefinitions.XSD_TYPE));
 		c.getTypeDefinitions().add(src);
 
 		Type t=new Type();
@@ -551,7 +553,7 @@
 		ref1.setName(TEST_TYPE_LP);
 		ref1.setDataType(new QName(TEST_NAME_SPACE,TEST_TYPE_LP).toString());
 		ref1.setTypeSystem(TypeSystem.XSD);
-		ref1.getProperties().put(PropertyName.XSD_TYPE, "true");
+		ref1.getProperties().put(AnnotationDefinitions.XSD_TYPE, new Annotation(AnnotationDefinitions.XSD_TYPE));
 		c.getTypeDefinitions().add(ref1);
 		
 		/*
@@ -580,7 +582,7 @@
 		ref2.setName(TEST_TYPE_LP2);
 		ref2.setDataType(new QName(TEST_NAME_SPACE2,TEST_TYPE_LP).toString());
 		ref2.setTypeSystem(TypeSystem.XSD);
-		ref2.getProperties().put(PropertyName.XSD_TYPE, "true");
+		ref2.getProperties().put(AnnotationDefinitions.XSD_TYPE, new Annotation(AnnotationDefinitions.XSD_TYPE));
 		c.getTypeDefinitions().add(ref2);
 		
 		/*
@@ -608,7 +610,7 @@
 		ref3.setName(TEST_TYPE_LP3);
 		ref3.setDataType(new QName(TEST_NAME_SPACE3,TEST_TYPE_LP).toString());
 		ref3.setTypeSystem(TypeSystem.XSD);
-		ref3.getProperties().put(PropertyName.XSD_TYPE, "true");
+		ref3.getProperties().put(AnnotationDefinitions.XSD_TYPE, new Annotation(AnnotationDefinitions.XSD_TYPE));
 		c.getTypeDefinitions().add(ref3);
 		
 		/*



More information about the savara-commits mailing list