savara SVN: r485 - trunk/bundles/org.jboss.savara.core.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-11-19 06:52:18 -0500 (Fri, 19 Nov 2010)
New Revision: 485
Modified:
trunk/bundles/org.jboss.savara.core/
Log:
Property changes on: trunk/bundles/org.jboss.savara.core
___________________________________________________________________
Name: svn:ignore
+ target
15 years, 5 months
savara SVN: r484 - in trunk: bundles/org.jboss.savara.bpel/META-INF and 31 other directories.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-11-19 06:47:22 -0500 (Fri, 19 Nov 2010)
New Revision: 484
Added:
trunk/bundles/org.jboss.savara.core/
trunk/bundles/org.jboss.savara.core/.classpath
trunk/bundles/org.jboss.savara.core/.project
trunk/bundles/org.jboss.savara.core/.settings/
trunk/bundles/org.jboss.savara.core/.settings/org.eclipse.jdt.core.prefs
trunk/bundles/org.jboss.savara.core/.settings/org.eclipse.pde.core.prefs
trunk/bundles/org.jboss.savara.core/META-INF/
trunk/bundles/org.jboss.savara.core/META-INF/MANIFEST.MF
trunk/bundles/org.jboss.savara.core/build.properties
trunk/bundles/org.jboss.savara.core/pom.xml
trunk/bundles/org.jboss.savara.core/src/
trunk/bundles/org.jboss.savara.core/src/java/
trunk/bundles/org.jboss.savara.core/src/java/org/
trunk/bundles/org.jboss.savara.core/src/java/org/jboss/
trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/
trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/core/
trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/core/osgi/
trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/core/osgi/Activator.java
trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/resources/
trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/resources/Resource.java
trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/util/
trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/util/XMLUtils.java
trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/WSDLGeneratorFactory.java
trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/impl/
trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/impl/WSDLGeneratorImpl.java
trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/util/WSDLGeneratorUtil.java
Removed:
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/util/
trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/tools/wsdl/generator/
trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/WSDLGeneratorUtil.java
trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/util/XMLUtils.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/AbstractBuildSystem.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/AntBuildSystem.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/BuildSystem.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/MavenBuildSystem.java
trunk/tools/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/generator/
Modified:
trunk/bundles/org.jboss.savara.bpel/META-INF/MANIFEST.MF
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/export/BPELLanguageModelStreamExportRule.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ConversationInteractionModelChangeRule.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/IfModelChangeRule.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELElement.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Invoke.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Process.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Scope.java
trunk/bundles/org.jboss.savara.wsdl/META-INF/MANIFEST.MF
trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/WSDLGenerator.java
trunk/bundles/pom.xml
trunk/tools/features/org.jboss.savara.tools.feature/feature.xml
trunk/tools/plugins/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/dialogs/GenerateDialog.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
trunk/tools/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/actions/GenerateAction.java
trunk/tools/tests/org.jboss.savara.tools.bpel.tests/META-INF/MANIFEST.MF
trunk/tools/tests/org.jboss.savara.tools.bpel.tests/src/java/org/jboss/savara/bpel/util/XMLUtilsTest.java
trunk/tools/tests/org.jboss.savara.tools.bpel.tests/src/java/org/jboss/savara/tools/bpel/generator/GeneratorTest.java
trunk/tools/tests/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java
Log:
Create savara core OSGi bundle - initially just with XML utils. Change WSDL generator to be an interface with separate factory and implementation. Issue is that WSDL tests are in separate plugin (for Tycho tests), and so need visibility of implementation package.
Modified: trunk/bundles/org.jboss.savara.bpel/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/META-INF/MANIFEST.MF 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/bundles/org.jboss.savara.bpel/META-INF/MANIFEST.MF 2010-11-19 11:47:22 UTC (rev 484)
@@ -16,7 +16,8 @@
org.scribble.expression.xpath;bundle-version="[1.0.0,2.0.0)",
org.jboss.savara.pi4soa.cdm;resolution:=optional,
org.jboss.savara.contract.model,
- org.jboss.savara.wsdl
+ org.jboss.savara.wsdl,
+ org.jboss.savara.core
Scribble-Extensions: org.jboss.savara.bpel.parser.BPELTokenizer,
org.jboss.savara.bpel.parser.BPELModelParserRule,
org.jboss.savara.bpel.model.BPELNotation,
@@ -30,5 +31,4 @@
org.jboss.savara.bpel.model.change.ConversationInteractionModelChangeRule
Export-Package: org.jboss.savara.bpel.model;x-friends:="org.jboss.savara.tools.bpel.tests",
org.jboss.savara.bpel.model.change;x-friends:="org.jboss.savara.tools.bpel.tests",
- org.jboss.savara.bpel.model.component;x-friends:="org.jboss.savara.tools.bpel.tests",
- org.jboss.savara.bpel.util;x-friends:="org.jboss.savara.tools.bpel.tests"
+ org.jboss.savara.bpel.model.component;x-friends:="org.jboss.savara.tools.bpel.tests"
Modified: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/export/BPELLanguageModelStreamExportRule.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/export/BPELLanguageModelStreamExportRule.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/export/BPELLanguageModelStreamExportRule.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -21,7 +21,7 @@
import org.jboss.savara.bpel.model.BPELLanguageModel;
import org.jboss.savara.bpel.model.BPELNotation;
-import org.jboss.savara.bpel.util.XMLUtils;
+import org.jboss.savara.util.XMLUtils;
import org.scribble.export.ExportRule;
import org.scribble.export.ExporterContext;
import org.scribble.export.Formatter;
Modified: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ConversationInteractionModelChangeRule.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ConversationInteractionModelChangeRule.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -22,7 +22,7 @@
import org.jboss.savara.bpel.model.*;
import org.jboss.savara.bpel.model.component.*;
import org.jboss.savara.bpel.model.util.*;
-import org.jboss.savara.wsdl.generator.WSDLGeneratorUtil;
+import org.jboss.savara.wsdl.util.WSDLGeneratorUtil;
import org.scribble.model.*;
import org.scribble.model.change.*;
import org.jboss.savara.contract.model.Contract;
Modified: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/IfModelChangeRule.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/IfModelChangeRule.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/IfModelChangeRule.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -22,7 +22,7 @@
import org.jboss.savara.bpel.model.*;
import org.jboss.savara.bpel.model.component.*;
import org.jboss.savara.bpel.model.util.InteractionUtil;
-import org.jboss.savara.wsdl.generator.WSDLGeneratorUtil;
+import org.jboss.savara.wsdl.util.WSDLGeneratorUtil;
import org.scribble.model.*;
import org.scribble.model.change.*;
import org.jboss.savara.contract.model.Contract;
Modified: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELElement.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELElement.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELElement.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -21,7 +21,7 @@
import org.scribble.model.admin.ModelListener;
import org.apache.commons.logging.*;
import org.jboss.savara.bpel.model.*;
-import org.jboss.savara.bpel.util.XMLUtils;
+import org.jboss.savara.util.XMLUtils;
/**
* This is the generic BPEL element class.
Modified: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Invoke.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Invoke.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Invoke.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -22,7 +22,7 @@
import org.scribble.model.admin.ModelListener;
import org.jboss.savara.bpel.model.*;
import org.jboss.savara.bpel.model.util.TypeReferenceUtil;
-import org.jboss.savara.bpel.util.XMLUtils;
+import org.jboss.savara.util.XMLUtils;
/**
* This class represents an unsupported (or custom) action within
Modified: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Process.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Process.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Process.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -30,7 +30,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.savara.bpel.model.*;
import org.jboss.savara.bpel.model.util.InteractionUtil;
-import org.jboss.savara.bpel.util.XMLUtils;
+import org.jboss.savara.util.XMLUtils;
/**
* This class represents a BPEL process.
Modified: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Scope.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Scope.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Scope.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -22,7 +22,7 @@
import org.scribble.model.admin.ModelListener;
import org.jboss.savara.bpel.model.*;
import org.jboss.savara.bpel.model.util.InteractionUtil;
-import org.jboss.savara.bpel.util.XMLUtils;
+import org.jboss.savara.util.XMLUtils;
/**
* This class represents a scope grouping activity.
Added: trunk/bundles/org.jboss.savara.core/.classpath
===================================================================
--- trunk/bundles/org.jboss.savara.core/.classpath (rev 0)
+++ trunk/bundles/org.jboss.savara.core/.classpath 2010-11-19 11:47:22 UTC (rev 484)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/bundles/org.jboss.savara.core/.project
===================================================================
--- trunk/bundles/org.jboss.savara.core/.project (rev 0)
+++ trunk/bundles/org.jboss.savara.core/.project 2010-11-19 11:47:22 UTC (rev 484)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.savara.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/bundles/org.jboss.savara.core/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/bundles/org.jboss.savara.core/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/bundles/org.jboss.savara.core/.settings/org.eclipse.jdt.core.prefs 2010-11-19 11:47:22 UTC (rev 484)
@@ -0,0 +1,8 @@
+#Thu Nov 18 14:28:42 GMT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: trunk/bundles/org.jboss.savara.core/.settings/org.eclipse.pde.core.prefs
===================================================================
--- trunk/bundles/org.jboss.savara.core/.settings/org.eclipse.pde.core.prefs (rev 0)
+++ trunk/bundles/org.jboss.savara.core/.settings/org.eclipse.pde.core.prefs 2010-11-19 11:47:22 UTC (rev 484)
@@ -0,0 +1,5 @@
+#Thu Nov 18 14:28:45 GMT 2010
+eclipse.preferences.version=1
+pluginProject.equinox=false
+pluginProject.extensions=false
+resolve.requirebundle=false
Added: trunk/bundles/org.jboss.savara.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.jboss.savara.core/META-INF/MANIFEST.MF (rev 0)
+++ trunk/bundles/org.jboss.savara.core/META-INF/MANIFEST.MF 2010-11-19 11:47:22 UTC (rev 484)
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JBoss SAVARA Core
+Bundle-SymbolicName: org.jboss.savara.core
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.jboss.savara.core.osgi.Activator
+Bundle-Vendor: www.savara.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.scribble.core;bundle-version="[1.0.0,2.0.0)"
+Export-Package: org.jboss.savara.util
Added: trunk/bundles/org.jboss.savara.core/build.properties
===================================================================
--- trunk/bundles/org.jboss.savara.core/build.properties (rev 0)
+++ trunk/bundles/org.jboss.savara.core/build.properties 2010-11-19 11:47:22 UTC (rev 484)
@@ -0,0 +1,4 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added: trunk/bundles/org.jboss.savara.core/pom.xml
===================================================================
--- trunk/bundles/org.jboss.savara.core/pom.xml (rev 0)
+++ trunk/bundles/org.jboss.savara.core/pom.xml 2010-11-19 11:47:22 UTC (rev 484)
@@ -0,0 +1,16 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.savara.bundles</groupId>
+ <artifactId>org.jboss.savara.core</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Bundles::Core</name>
+
+ <parent>
+ <groupId>org.jboss.savara</groupId>
+ <artifactId>bundles</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+</project>
Added: trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/core/osgi/Activator.java
===================================================================
--- trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/core/osgi/Activator.java (rev 0)
+++ trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/core/osgi/Activator.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -0,0 +1,30 @@
+package org.jboss.savara.core.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/resources/Resource.java
===================================================================
--- trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/resources/Resource.java (rev 0)
+++ trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/resources/Resource.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.savara.resources;
+
+/**
+ * This interface represents a context independent resource, that can be used by
+ * Savara capabilities.
+ *
+ */
+public interface Resource {
+
+ /**
+ * This method returns the resource name.
+ *
+ * @return The resource name
+ */
+ public String getName();
+
+ /**
+ * This method returns an input stream that can be used to read
+ * the contents of the resource.
+ *
+ * @return The contents as an input stream
+ * @throws Exception Failed to get the contents
+ */
+ public java.io.InputStream getContents() throws Exception;
+
+ /**
+ * This method sets the contents of the resource based on the information
+ * contained in the supplied input stream.
+ *
+ * @param is The contents to be written to the resource
+ * @throws Exception Failed to set the contents
+ */
+ public void setContents(java.io.InputStream is) throws Exception;
+
+}
Added: trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/util/XMLUtils.java
===================================================================
--- trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/util/XMLUtils.java (rev 0)
+++ trunk/bundles/org.jboss.savara.core/src/java/org/jboss/savara/util/XMLUtils.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -0,0 +1,300 @@
+/*
+ * 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.jboss.savara.util;
+
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.scribble.model.ModelObject;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * This class defines a set of XML related utility functions.
+ */
+public final class XMLUtils {
+
+ private static final String NS_LABEL = "ns";
+
+ /**
+ * This class converts a DOM representation node to text.
+ * @param node
+ * @return
+ * @throws Exception
+ */
+ public static final String toText(Node node) throws Exception {
+ String ret = null;
+ try {
+ // Transform the DOM represent to text
+ ByteArrayOutputStream xmlstr= new ByteArrayOutputStream();
+ DOMSource source=new DOMSource(node);
+ //source.setNode(node);
+
+ StreamResult result=new StreamResult(xmlstr);
+ Transformer trans= TransformerFactory.newInstance().newTransformer();
+ trans.transform(source, result);
+
+ xmlstr.close();
+
+ ret = new String(xmlstr.toByteArray());
+
+ if ((node instanceof Document) == false) {
+ // Strip off any <?xml> header
+ int index=ret.indexOf("<?xml");
+ if (index != -1) {
+ index = ret.indexOf("<", 1);
+ if (index != -1) {
+ ret = ret.substring(index);
+ } else {
+ index = ret.indexOf("?>");
+ if (index != -1) {
+ index += 2;
+
+ // Remove any trailing whitespaces after XML header
+ while (index < ret.length() &&
+ Character.isWhitespace(ret.charAt(index))) {
+ index++;
+ }
+
+ ret = ret.substring(index);
+ }
+ }
+ }
+ }
+
+ } catch(Exception e) {
+ throw new Exception("Failed to transform DOM representation into text", e);
+ }
+ if (ret != null) {
+ return format(ret);
+ }
+ return ret;
+ }
+
+
+ /**
+ * Format the xml to well print.
+ *
+ * @param xmltext
+ * @return
+ */
+ public static final String format(String xmltext) {
+ String ret=xmltext;
+ int pos=0;
+ int prevpos=0;
+ StringBuffer buf=new StringBuffer();
+ int level=0;
+
+ while ((pos=ret.indexOf('<', prevpos)) != -1) {
+
+ if (prevpos < pos &&
+ ret.substring(prevpos, pos).trim().length() > 0 &&
+ ret.charAt(prevpos-1) != '?') {
+
+ if (ret.charAt(prevpos) == '\r' &&
+ ret.charAt(prevpos+1) == '\n') {
+ prevpos += 2;
+ }
+ for (int i=0; i < level; i++) {
+ buf.append(" ");
+ }
+
+ buf.append(ret.substring(prevpos, pos).trim());
+ buf.append("\r\n");
+ }
+
+ int endpos=ret.indexOf('>', pos);
+
+ if (endpos > 0) {
+ boolean noreturn=false;
+
+ if (pos > 0 && ret.charAt(pos+1) == '/') {
+ level--;
+ }
+
+ for (int i=0; i < level; i++) {
+ buf.append(" ");
+ }
+ buf.append(ret.substring(pos, endpos+1));
+
+ if (ret.charAt(endpos-1)== '?') {
+ //noreturn = true;
+
+ } else if (ret.charAt(endpos-1) == '/') {
+ // Ignore
+ } else if (pos > 0 && ret.charAt(pos+1) == '/') {
+ // Ignore
+
+ } else if (pos > 0 && ret.charAt(pos+1) == '!') {
+ // Ignore
+
+ } else {
+ level++;
+ }
+
+ if (noreturn == false) {
+ buf.append("\r\n");
+ }
+
+ pos = endpos+1;
+ }
+
+ prevpos = pos;
+ }
+
+ if (prevpos != -1 &&
+ ret.substring(prevpos).trim().length() > 0) {
+ buf.append(ret.substring(prevpos));
+ }
+
+ ret = buf.toString();
+
+ return(ret);
+ }
+
+ public static Node getNode(String text) throws Exception {
+ Node ret=null;
+
+ // Transform the text representation to DOM
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ java.io.InputStream xmlstr=
+ new java.io.ByteArrayInputStream(text.getBytes());
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+ org.w3c.dom.Document doc=builder.parse(xmlstr);
+
+ ret = doc.getDocumentElement();
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the localname part of the supplied
+ * qualified name.
+ *
+ * @param qname The qualified name
+ * @return The localname part
+ */
+ public static String getLocalname(String qname) {
+ String ret=qname;
+ int pos=0;
+
+ if (qname != null && ((pos=qname.indexOf(':')) != -1)) {
+ ret = qname.substring(pos+1);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the prefix associated with the supplied namespace.
+ *
+ * @param namespace The namespace
+ * @param nsMap The existing namespace prefix mappings
+ * @return The prefix
+ */
+ public static String getPrefix(String namespace, java.util.Map<String,String> nsMap) {
+ String prefix=null;
+
+ prefix = nsMap.get(namespace);
+
+ if (prefix == null) {
+ prefix = NS_LABEL+(nsMap.size()+1);
+ nsMap.put(namespace, prefix);
+ }
+
+ return(prefix);
+ }
+
+ /**
+ * This method calculates the start and end position of a supplied DOM element, within
+ * the supplied text contents, and sets the values on the supplied ModelObject.
+ *
+ * @param obj The ModelObject to be initialized
+ * @param contents The text contents
+ * @param elem The DOM element to be located in the text
+ */
+ public static void setStartAndEndPosition(ModelObject obj, String contents, org.w3c.dom.Element elem) {
+
+ if (contents != null) {
+ org.w3c.dom.NodeList nl=elem.getOwnerDocument().getElementsByTagName(elem.getNodeName());
+ int elempos=-1;
+
+ for (int i=0; elempos == -1 && i < nl.getLength(); i++) {
+ if (nl.item(i) == elem) {
+ elempos = i;
+ }
+ }
+
+ if (elempos != -1) {
+ int startpos=-1;
+
+ for (int i=0; i <= elempos; i++) {
+ int val1=contents.indexOf("<"+elem.getNodeName()+">", startpos+1);
+ int val2=contents.indexOf("<"+elem.getNodeName()+" ", startpos+1);
+
+ if (val1 == -1 && val2 != -1) {
+ startpos = val2;
+ } else if (val1 != -1 && val2 == -1) {
+ startpos = val1;
+ } else if (val1 == -1 && val2 == -1) {
+ // TODO: Error condition
+ break;
+ } else if (val1 > val2) {
+ startpos = val2;
+ } else {
+ startpos = val1;
+ }
+ }
+
+ if (startpos != -1) {
+ obj.getSource().setStartPosition(startpos);
+
+ // Check if single node
+ int p1=contents.indexOf('>', startpos);
+
+ if (p1 != -1 && contents.charAt(p1-1) == '/') {
+ obj.getSource().setEndPosition(p1);
+ } else {
+
+ org.w3c.dom.NodeList enl=elem.getElementsByTagName(elem.getNodeName());
+
+ int endpos=startpos;
+ String nodetxt="</"+elem.getNodeName()+">";
+
+ for (int i=0; endpos != -1 && i <= enl.getLength(); i++) {
+ endpos = contents.indexOf(nodetxt, endpos+1);
+ }
+
+ if (endpos != -1) {
+ obj.getSource().setEndPosition(endpos+nodetxt.length()-1);
+ }
+ }
+ }
+ }
+ }
+ }
+}
Modified: trunk/bundles/org.jboss.savara.wsdl/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.jboss.savara.wsdl/META-INF/MANIFEST.MF 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/bundles/org.jboss.savara.wsdl/META-INF/MANIFEST.MF 2010-11-19 11:47:22 UTC (rev 484)
@@ -14,4 +14,6 @@
org.scribble.eclipse;bundle-version="[1.0.0,2.0.0)",
org.scribble.conversation.model;bundle-version="[1.0.0,2.0.0)"
Export-Package: org.jboss.savara.wsdl.generator,
- org.jboss.savara.wsdl.generator.soap
+ org.jboss.savara.wsdl.generator.impl,
+ org.jboss.savara.wsdl.generator.soap,
+ org.jboss.savara.wsdl.util
Modified: trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/WSDLGenerator.java
===================================================================
--- trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/WSDLGenerator.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/WSDLGenerator.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -17,32 +17,12 @@
*/
package org.jboss.savara.wsdl.generator;
-import javax.wsdl.Part;
-import javax.xml.namespace.QName;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.savara.contract.model.FaultDetails;
-import org.jboss.savara.contract.model.Interface;
-import org.jboss.savara.contract.model.Namespace;
-import org.jboss.savara.contract.model.RequestResponseMEP;
-import org.jboss.savara.contract.model.Type;
-import org.jboss.savara.contract.model.TypeDefinition;
-import org.scribble.model.TypeReference;
-
/**
- * This class generates a WSDL definition from a Contract model.
+ * This interface generates a WSDL definition from a Contract model.
*
*/
-public class WSDLGenerator {
+public interface WSDLGenerator {
- public static final String BINDING_SUFFIX = "Binding";
-
- private static Log logger = LogFactory.getLog(WSDLGenerator.class);
-
- public WSDLGenerator() {
- }
-
/**
* This method generates a WSDL definition from a Scribble contract model.
*
@@ -50,486 +30,7 @@
* @param wsdlBinding The WSDL binding to use, or null if no binding
* @return The WSDL definition
*/
- public java.util.List<javax.wsdl.Definition> generateDefinitions(org.jboss.savara.contract.model.Contract contract,
- WSDLBinding wsdlBinding) {
- java.util.List<javax.wsdl.Definition> ret=new java.util.Vector<javax.wsdl.Definition>();
-
- try {
- // Create definition for contract's target namespace
- javax.wsdl.Definition main=getDefinition(ret, contract, contract.getNamespace(), wsdlBinding);
-
- // If no definition, then return
- if (main == null) {
- return(ret);
- }
-
- // Create service
- javax.wsdl.Service service=main.createService();
- service.setQName(new javax.xml.namespace.QName(contract.getNamespace(),
- contract.getName()+"Service"));
+ public java.util.List<javax.wsdl.Definition> generate(org.jboss.savara.contract.model.Contract contract,
+ WSDLBinding wsdlBinding);
- main.addService(service);
-
- // Define a port type per interface
- java.util.Iterator<Interface> iter=contract.getInterfaces().iterator();
-
- while (iter.hasNext()) {
- Interface intf=iter.next();
-
- javax.wsdl.PortType portType=
- createPortType(ret, contract, intf, wsdlBinding);
-
- javax.wsdl.Binding binding=
- createBinding(ret, contract, intf, portType, wsdlBinding);
-
- // Create service port for interface
- javax.wsdl.Port port=main.createPort();
-
- port.setName(intf.getName()+"Port");
- port.setBinding(binding);
-
- service.addPort(port);
-
- if (wsdlBinding != null) {
- wsdlBinding.updatePort(main, port);
- }
- }
-
- } catch(Exception e) {
- logger.error("Failed to generate WSDL", e);
- }
-
- return(ret);
- }
-
- /**
- * This method returns the definition associated with the supplied target namespace.
- *
- * @param wsdls The list of current WSDL definitions
- * @param contract The contract
- * @param targetNamespace The target namespace
- * @param wsdlBinding The WSDL binding to use, or null if no binding
- * @return The WSDL definition for the target namespace, or null if unable to find or create
- */
- protected javax.wsdl.Definition getDefinition(java.util.List<javax.wsdl.Definition> wsdls,
- org.jboss.savara.contract.model.Contract contract, String targetNamespace,
- WSDLBinding wsdlBinding) {
- javax.wsdl.Definition ret=null;
-
- if (targetNamespace != null) {
- for (int i=0; ret == null && i < wsdls.size(); i++) {
- ret = wsdls.get(i);
-
- if (ret.getTargetNamespace() == null ||
- ret.getTargetNamespace().equals(targetNamespace) == false) {
- ret = null;
- }
- }
-
- if (ret == null) {
- ret = createDefinition(contract, targetNamespace);
-
- if (ret != null) {
-
- // Initialize definition using the WSDL binding
- if (wsdlBinding != null) {
- wsdlBinding.initDefinition(ret);
- }
-
- wsdls.add(ret);
- }
- }
- }
-
- return(ret);
- }
-
- /**
- * This method creates a new WSDL definition associated with the supplied
- * target namespace.
- *
- * @param contract The contract
- * @param targetNamespace The target namespace
- * @return The WSDL definition
- */
- protected javax.wsdl.Definition createDefinition(org.jboss.savara.contract.model.Contract contract,
- String targetNamespace) {
- javax.wsdl.Definition ret=null;
-
- try {
- javax.wsdl.factory.WSDLFactory fact=
- javax.wsdl.factory.WSDLFactory.newInstance();
-
- ret = fact.newDefinition();
-
- // Set details on the definition
- if (contract.getName() != null) {
- ret.setQName(new javax.xml.namespace.QName(contract.getName()));
- }
- ret.setTargetNamespace(targetNamespace);
-
- // Set up namespace mappings
- java.util.Iterator<Namespace> iter=contract.getNamespaces().iterator();
-
- while (iter.hasNext()) {
- Namespace ns=iter.next();
-
- ret.addNamespace(ns.getPrefix(), ns.getURI());
- }
-
- } catch(Exception e) {
- logger.error("Failed to create WSDL definition for target namespace '"+targetNamespace+"'", e);
- }
-
- return(ret);
- }
-
- /**
- * This method generates a port type, using the supplied WSDL definition,
- * based on the information in the supplied interface definition.
- *
- * @param wsdls The list of current WSDL definitions
- * @param contract The contract
- * @param intf The interface model
- * @return The WSDL port type
- */
- public javax.wsdl.PortType createPortType(java.util.List<javax.wsdl.Definition> wsdls,
- org.jboss.savara.contract.model.Contract contract,
- org.jboss.savara.contract.model.Interface intf,
- WSDLBinding wsdlBinding) {
- javax.wsdl.PortType ret=null;
-
- if (intf != null) {
- javax.wsdl.Definition defn=getDefinition(wsdls, contract, intf.getNamespace(), wsdlBinding);
-
- if (defn != null) {
- ret = defn.createPortType();
- ret.setUndefined(false);
-
- if (intf.getName() != null) {
- ret.setQName(new javax.xml.namespace.QName(intf.getNamespace(), intf.getName()));
- }
-
- for (int i=0; i < intf.getMessageExchangePatterns().size(); i++) {
- createOperation(wsdls, contract, ret,
- intf.getMessageExchangePatterns().get(i), wsdlBinding);
- }
-
- // Only add portType to definition if they have atleast one operation
- if (ret != null && ret.getOperations().size() > 0) {
- defn.addPortType(ret);
- }
- }
- }
-
- return(ret);
- }
-
- /**
- * This method generates a port type binding, using the supplied WSDL definition,
- * based on the information in the supplied interface definition.
- *
- * @param wsdls The list of current WSDL definitions
- * @param contract The contract
- * @param intf The interface model
- * @param portType The port type
- * @return The WSDL port type binding
- */
- public javax.wsdl.Binding createBinding(java.util.List<javax.wsdl.Definition> wsdls,
- org.jboss.savara.contract.model.Contract contract,
- org.jboss.savara.contract.model.Interface intf,
- javax.wsdl.PortType portType,
- WSDLBinding wsdlBinding) {
- javax.wsdl.Binding ret=null;
-
- if (intf != null) {
- javax.wsdl.Definition defn=getDefinition(wsdls, contract, intf.getNamespace(), wsdlBinding);
-
- if (defn != null) {
- ret = defn.createBinding();
- ret.setUndefined(false);
-
- // Check if WSDL binding details
- if (wsdlBinding != null) {
- wsdlBinding.updateBinding(defn, ret);
- }
-
- if (intf.getName() != null) {
- ret.setQName(new javax.xml.namespace.QName(intf.getNamespace(),
- intf.getName()+BINDING_SUFFIX));
- }
-
- ret.setPortType(portType);
-
- for (int i=0; i < intf.getMessageExchangePatterns().size(); i++) {
- createBindingOperation(wsdls, contract, ret,
- intf.getMessageExchangePatterns().get(i), wsdlBinding);
- }
-
- // Only add portType to definition if they have atleast one operation
- if (ret != null && ret.getBindingOperations().size() > 0) {
- defn.addBinding(ret);
- }
- }
- }
-
- return(ret);
- }
-
- /**
- * This method generates an operation, using the supplied WSDL definition,
- * based on the information in the supplied message exchange pattern.
- *
- * @param wsdls The list of current WSDL definitions
- * @param contract The contract
- * @param portType The port type
- * @param mep The message exchange pattern
- * @return The WSDL operation
- */
- public javax.wsdl.Operation createOperation(java.util.List<javax.wsdl.Definition> wsdls,
- org.jboss.savara.contract.model.Contract contract, javax.wsdl.PortType portType,
- org.jboss.savara.contract.model.MessageExchangePattern mep,
- WSDLBinding wsdlBinding) {
- javax.wsdl.Operation ret=null;
-
- javax.wsdl.Definition defn=null;
-
- if (portType != null) {
- defn = getDefinition(wsdls, contract, portType.getQName().getNamespaceURI(), wsdlBinding);
- }
-
- if (defn != null && mep != null) {
- ret = defn.createOperation();
- ret.setUndefined(false);
-
- ret.setName(mep.getOperation());
-
- QName msgname=WSDLGeneratorUtil.getRequestMessageType(portType.getQName().getNamespaceURI(),
- mep.getOperation());
-
- javax.wsdl.Message mesg=getMessage(wsdls, contract, msgname,
- mep.getTypes(), wsdlBinding);
-
- if (mesg != null) {
- javax.wsdl.Input input=defn.createInput();
- input.setMessage(mesg);
- ret.setInput(input);
- }
-
- // Check if a request/response MEP
- if (mep instanceof RequestResponseMEP) {
- RequestResponseMEP rr=(RequestResponseMEP)mep;
-
- msgname=WSDLGeneratorUtil.getResponseMessageType(portType.getQName().getNamespaceURI(),
- mep.getOperation());
-
- javax.wsdl.Message om=getMessage(wsdls, contract, msgname,
- rr.getResponseTypes(), wsdlBinding);
- if (om != null) {
- javax.wsdl.Output output=defn.createOutput();
- output.setMessage(om);
- ret.setOutput(output);
- }
-
- // Generate fault details
- if (rr.getFaultDetails() != null) {
- for (int i=0; i < rr.getFaultDetails().size(); i++) {
- FaultDetails fd=rr.getFaultDetails().get(i);
-
- msgname = WSDLGeneratorUtil.getFaultMessageType(portType.getQName().getNamespaceURI(),
- fd.getName());
-
- javax.wsdl.Message fm=getMessage(wsdls, contract, msgname,
- fd.getTypes(), wsdlBinding);
- if (fm != null) {
- javax.wsdl.Fault fault=defn.createFault();
- fault.setName(fd.getName());
- fault.setMessage(fm);
-
- ret.addFault(fault);
- }
- }
- }
- }
-
- portType.addOperation(ret);
- }
-
- return(ret);
- }
-
- /**
- * This method generates a binding operation, using the supplied WSDL definition,
- * based on the information in the supplied message exchange pattern.
- *
- * @param wsdls The list of current WSDL definitions
- * @param contract The contract
- * @param binding The port type binding
- * @param mep The message exchange pattern
- * @return The WSDL binding operation
- */
- public javax.wsdl.BindingOperation createBindingOperation(java.util.List<javax.wsdl.Definition> wsdls,
- org.jboss.savara.contract.model.Contract contract, javax.wsdl.Binding binding,
- org.jboss.savara.contract.model.MessageExchangePattern mep,
- WSDLBinding wsdlBinding) {
- javax.wsdl.BindingOperation ret=null;
-
- javax.wsdl.Definition defn=null;
-
- if (binding != null) {
- defn = getDefinition(wsdls, contract, binding.getQName().getNamespaceURI(), wsdlBinding);
- }
-
- if (defn != null && mep != null) {
- ret = defn.createBindingOperation();
- //ret.setUndefined(false);
-
- // Check if WSDL operation details
- if (wsdlBinding != null) {
- wsdlBinding.updateOperation(defn, mep, ret);
- }
-
- ret.setName(mep.getOperation());
-
- QName msgname=WSDLGeneratorUtil.getRequestMessageType(binding.getQName().getNamespaceURI(),
- mep.getOperation());
-
- javax.wsdl.Message mesg=getMessage(wsdls, contract,msgname,
- mep.getTypes(), wsdlBinding);
-
- if (mesg != null) {
- javax.wsdl.BindingInput input=defn.createBindingInput();
-
- // Check if WSDL operation details
- if (wsdlBinding != null) {
- wsdlBinding.updateInput(defn, input);
- }
-
- ret.setBindingInput(input);
- }
-
- // Check if a request/response MEP
- if (mep instanceof RequestResponseMEP) {
- RequestResponseMEP rr=(RequestResponseMEP)mep;
-
- msgname=WSDLGeneratorUtil.getResponseMessageType(binding.getQName().getNamespaceURI(),
- mep.getOperation());
-
- javax.wsdl.Message om=getMessage(wsdls, contract, msgname,
- rr.getResponseTypes(), wsdlBinding);
- if (om != null) {
- javax.wsdl.BindingOutput output=defn.createBindingOutput();
-
- // Check if WSDL operation details
- if (wsdlBinding != null) {
- wsdlBinding.updateOutput(defn, output);
- }
-
- ret.setBindingOutput(output);
- }
-
- // Generate fault details
- if (rr.getFaultDetails() != null) {
- for (int i=0; i < rr.getFaultDetails().size(); i++) {
- FaultDetails fd=rr.getFaultDetails().get(i);
-
- msgname = WSDLGeneratorUtil.getFaultMessageType(binding.getQName().getNamespaceURI(),
- fd.getName());
-
- javax.wsdl.Message fm=getMessage(wsdls, contract, msgname,
- fd.getTypes(), wsdlBinding);
- if (fm != null) {
- javax.wsdl.BindingFault fault=defn.createBindingFault();
- fault.setName(fd.getName());
-
- // Check if WSDL operation details
- if (wsdlBinding != null) {
- wsdlBinding.updateFault(defn, fault);
- }
-
- ret.addBindingFault(fault);
- }
- }
- }
- }
-
- binding.addBindingOperation(ret);
- }
-
- return(ret);
- }
-
- /**
- * This method returns a message, using the supplied WSDL definition,
- * based on the information supplied in the list of type references. If
- * a single type reference is supplied, this will be the message type,
- * if multiple type references are supplied, then these will be considered
- * the message parts.<p>
- * <p>
- * The returned message will be part of the supplied definition. If it
- * does not exist prior to the call to this method, then it will be
- * created and added to the definition upon returning the message.
- *
- * @param wsdls The list of current WSDL definitions
- * @param contract The contract
- * @param msgname The message name
- * @param types The list of type references
- * @return The WSDL message
- */
- public javax.wsdl.Message getMessage(java.util.List<javax.wsdl.Definition> wsdls,
- org.jboss.savara.contract.model.Contract contract,
- javax.xml.namespace.QName msgname,
- java.util.List<org.jboss.savara.contract.model.Type> types,
- WSDLBinding wsdlBinding) {
- javax.wsdl.Message ret=null;
-
- if (types == null || types.size() == 0) {
- throw new UnsupportedOperationException("Expecting single type reference");
- } else if (types.size() > 1) {
- throw new UnsupportedOperationException("Currently only supports single type reference");
- } else {
- Type ref=types.get(0);
-
- java.util.Iterator<TypeDefinition> iter=ref.getTypeDefinitions().iterator();
- boolean f_done=false;
-
- while (f_done == false && iter.hasNext()) {
- TypeDefinition td=iter.next();
-
- if (TypeDefinition.XSD_ELEMENT.equals(td.getTypeSystem()) ||
- TypeDefinition.XSD_TYPE.equals(td.getTypeSystem())) {
- javax.xml.namespace.QName qname=
- new javax.xml.namespace.QName(td.getNamespace(),td.getName());
- javax.wsdl.Definition defn=
- getDefinition(wsdls, contract, msgname.getNamespaceURI(), wsdlBinding);
-
- if (defn != null && qname != null &&
- (ret = defn.getMessage(msgname)) == null) {
- ret = defn.createMessage();
- ret.setUndefined(false);
-
- ret.setQName(msgname);
-
- // Create single part for type or element
- Part part=defn.createPart();
- part.setName("content");
-
- if (TypeDefinition.XSD_ELEMENT.equals(td.getTypeSystem())) {
- part.setElementName(qname);
- } else {
- part.setTypeName(qname);
- }
-
- ret.addPart(part);
-
- defn.addMessage(ret);
-
- f_done = true;
- }
- }
- }
- }
-
- return(ret);
- }
}
Added: trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/WSDLGeneratorFactory.java
===================================================================
--- trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/WSDLGeneratorFactory.java (rev 0)
+++ trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/WSDLGeneratorFactory.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -0,0 +1,37 @@
+/*
+ * 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.jboss.savara.wsdl.generator;
+
+import org.jboss.savara.wsdl.generator.impl.WSDLGeneratorImpl;
+
+/**
+ * This class provides a factory for WSDL Generators.
+ *
+ */
+public class WSDLGeneratorFactory {
+
+ /**
+ * This method returns a WSDL generator.
+ *
+ * @return The WSDL generator
+ */
+ public static WSDLGenerator getWSDLGenerator() {
+ return(new WSDLGeneratorImpl());
+ }
+
+}
Deleted: trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/WSDLGeneratorUtil.java
===================================================================
--- trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/WSDLGeneratorUtil.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/WSDLGeneratorUtil.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -1,62 +0,0 @@
-/*
- * 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.jboss.savara.wsdl.generator;
-
-/**
- * This class provides general utility functions for
- * use when generating artefacts.
- */
-public class WSDLGeneratorUtil {
-
- private static final String RESPONSE = "Response";
- private static final String FAULT = "Fault";
- private static final String REQUEST = "Request";
-
- /**
- * This method returns the request message type QName.
- *
- * @param intfNamespace The interface namespace
- * @param op The operation name
- * @return The request message type
- */
- public static javax.xml.namespace.QName getRequestMessageType(String intfNamespace, String op) {
- return(new javax.xml.namespace.QName(intfNamespace, op+REQUEST));
- }
-
- /**
- * This method returns the response message type QName.
- *
- * @param intfNamespace The interface namespace
- * @param op The operation name
- * @return The response message type
- */
- public static javax.xml.namespace.QName getResponseMessageType(String intfNamespace, String op) {
- return(new javax.xml.namespace.QName(intfNamespace, op+RESPONSE));
- }
-
- /**
- * This method returns the fault message type QName.
- *
- * @param intfNamespace The interface namespace
- * @param faultName The fault name
- * @return The fault message type
- */
- public static javax.xml.namespace.QName getFaultMessageType(String intfNamespace, String faultName) {
- return(new javax.xml.namespace.QName(intfNamespace, faultName+FAULT));
- }
-}
Added: trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/impl/WSDLGeneratorImpl.java
===================================================================
--- trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/impl/WSDLGeneratorImpl.java (rev 0)
+++ trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/impl/WSDLGeneratorImpl.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -0,0 +1,537 @@
+/*
+ * 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.jboss.savara.wsdl.generator.impl;
+
+import javax.wsdl.Part;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.savara.contract.model.FaultDetails;
+import org.jboss.savara.contract.model.Interface;
+import org.jboss.savara.contract.model.Namespace;
+import org.jboss.savara.contract.model.RequestResponseMEP;
+import org.jboss.savara.contract.model.Type;
+import org.jboss.savara.contract.model.TypeDefinition;
+import org.jboss.savara.wsdl.generator.WSDLBinding;
+import org.jboss.savara.wsdl.generator.WSDLGenerator;
+import org.jboss.savara.wsdl.util.WSDLGeneratorUtil;
+
+/**
+ * This class generates a WSDL definition from a Contract model.
+ *
+ */
+public class WSDLGeneratorImpl implements WSDLGenerator {
+
+ public static final String BINDING_SUFFIX = "Binding";
+
+ private static Log logger = LogFactory.getLog(WSDLGeneratorImpl.class);
+
+ public WSDLGeneratorImpl() {
+ }
+
+ /**
+ * This method generates a WSDL definition from a Scribble contract model.
+ *
+ * @param contract The contract model
+ * @param wsdlBinding The WSDL binding to use, or null if no binding
+ * @return The WSDL definition
+ */
+ public java.util.List<javax.wsdl.Definition> generate(org.jboss.savara.contract.model.Contract contract,
+ WSDLBinding wsdlBinding) {
+ java.util.List<javax.wsdl.Definition> ret=new java.util.Vector<javax.wsdl.Definition>();
+
+ try {
+ // Create definition for contract's target namespace
+ javax.wsdl.Definition main=getDefinition(ret, contract, contract.getNamespace(), wsdlBinding);
+
+ // If no definition, then return
+ if (main == null) {
+ return(ret);
+ }
+
+ // Create service
+ javax.wsdl.Service service=main.createService();
+ service.setQName(new javax.xml.namespace.QName(contract.getNamespace(),
+ contract.getName()+"Service"));
+
+ main.addService(service);
+
+ // Define a port type per interface
+ java.util.Iterator<Interface> iter=contract.getInterfaces().iterator();
+
+ while (iter.hasNext()) {
+ Interface intf=iter.next();
+
+ javax.wsdl.PortType portType=
+ createPortType(ret, contract, intf, wsdlBinding);
+
+ javax.wsdl.Binding binding=
+ createBinding(ret, contract, intf, portType, wsdlBinding);
+
+ // Create service port for interface
+ javax.wsdl.Port port=main.createPort();
+
+ port.setName(intf.getName()+"Port");
+ port.setBinding(binding);
+
+ service.addPort(port);
+
+ if (wsdlBinding != null) {
+ wsdlBinding.updatePort(main, port);
+ }
+ }
+
+ } catch(Exception e) {
+ logger.error("Failed to generate WSDL", e);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the definition associated with the supplied target namespace.
+ *
+ * @param wsdls The list of current WSDL definitions
+ * @param contract The contract
+ * @param targetNamespace The target namespace
+ * @param wsdlBinding The WSDL binding to use, or null if no binding
+ * @return The WSDL definition for the target namespace, or null if unable to find or create
+ */
+ protected javax.wsdl.Definition getDefinition(java.util.List<javax.wsdl.Definition> wsdls,
+ org.jboss.savara.contract.model.Contract contract, String targetNamespace,
+ WSDLBinding wsdlBinding) {
+ javax.wsdl.Definition ret=null;
+
+ if (targetNamespace != null) {
+ for (int i=0; ret == null && i < wsdls.size(); i++) {
+ ret = wsdls.get(i);
+
+ if (ret.getTargetNamespace() == null ||
+ ret.getTargetNamespace().equals(targetNamespace) == false) {
+ ret = null;
+ }
+ }
+
+ if (ret == null) {
+ ret = createDefinition(contract, targetNamespace);
+
+ if (ret != null) {
+
+ // Initialize definition using the WSDL binding
+ if (wsdlBinding != null) {
+ wsdlBinding.initDefinition(ret);
+ }
+
+ wsdls.add(ret);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method creates a new WSDL definition associated with the supplied
+ * target namespace.
+ *
+ * @param contract The contract
+ * @param targetNamespace The target namespace
+ * @return The WSDL definition
+ */
+ protected javax.wsdl.Definition createDefinition(org.jboss.savara.contract.model.Contract contract,
+ String targetNamespace) {
+ javax.wsdl.Definition ret=null;
+
+ try {
+ javax.wsdl.factory.WSDLFactory fact=
+ javax.wsdl.factory.WSDLFactory.newInstance();
+
+ ret = fact.newDefinition();
+
+ // Set details on the definition
+ if (contract.getName() != null) {
+ ret.setQName(new javax.xml.namespace.QName(contract.getName()));
+ }
+ ret.setTargetNamespace(targetNamespace);
+
+ // Set up namespace mappings
+ java.util.Iterator<Namespace> iter=contract.getNamespaces().iterator();
+
+ while (iter.hasNext()) {
+ Namespace ns=iter.next();
+
+ ret.addNamespace(ns.getPrefix(), ns.getURI());
+ }
+
+ } catch(Exception e) {
+ logger.error("Failed to create WSDL definition for target namespace '"+targetNamespace+"'", e);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method generates a port type, using the supplied WSDL definition,
+ * based on the information in the supplied interface definition.
+ *
+ * @param wsdls The list of current WSDL definitions
+ * @param contract The contract
+ * @param intf The interface model
+ * @return The WSDL port type
+ */
+ public javax.wsdl.PortType createPortType(java.util.List<javax.wsdl.Definition> wsdls,
+ org.jboss.savara.contract.model.Contract contract,
+ org.jboss.savara.contract.model.Interface intf,
+ WSDLBinding wsdlBinding) {
+ javax.wsdl.PortType ret=null;
+
+ if (intf != null) {
+ javax.wsdl.Definition defn=getDefinition(wsdls, contract, intf.getNamespace(), wsdlBinding);
+
+ if (defn != null) {
+ ret = defn.createPortType();
+ ret.setUndefined(false);
+
+ if (intf.getName() != null) {
+ ret.setQName(new javax.xml.namespace.QName(intf.getNamespace(), intf.getName()));
+ }
+
+ for (int i=0; i < intf.getMessageExchangePatterns().size(); i++) {
+ createOperation(wsdls, contract, ret,
+ intf.getMessageExchangePatterns().get(i), wsdlBinding);
+ }
+
+ // Only add portType to definition if they have atleast one operation
+ if (ret != null && ret.getOperations().size() > 0) {
+ defn.addPortType(ret);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method generates a port type binding, using the supplied WSDL definition,
+ * based on the information in the supplied interface definition.
+ *
+ * @param wsdls The list of current WSDL definitions
+ * @param contract The contract
+ * @param intf The interface model
+ * @param portType The port type
+ * @return The WSDL port type binding
+ */
+ public javax.wsdl.Binding createBinding(java.util.List<javax.wsdl.Definition> wsdls,
+ org.jboss.savara.contract.model.Contract contract,
+ org.jboss.savara.contract.model.Interface intf,
+ javax.wsdl.PortType portType,
+ WSDLBinding wsdlBinding) {
+ javax.wsdl.Binding ret=null;
+
+ if (intf != null) {
+ javax.wsdl.Definition defn=getDefinition(wsdls, contract, intf.getNamespace(), wsdlBinding);
+
+ if (defn != null) {
+ ret = defn.createBinding();
+ ret.setUndefined(false);
+
+ // Check if WSDL binding details
+ if (wsdlBinding != null) {
+ wsdlBinding.updateBinding(defn, ret);
+ }
+
+ if (intf.getName() != null) {
+ ret.setQName(new javax.xml.namespace.QName(intf.getNamespace(),
+ intf.getName()+BINDING_SUFFIX));
+ }
+
+ ret.setPortType(portType);
+
+ for (int i=0; i < intf.getMessageExchangePatterns().size(); i++) {
+ createBindingOperation(wsdls, contract, ret,
+ intf.getMessageExchangePatterns().get(i), wsdlBinding);
+ }
+
+ // Only add portType to definition if they have atleast one operation
+ if (ret != null && ret.getBindingOperations().size() > 0) {
+ defn.addBinding(ret);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method generates an operation, using the supplied WSDL definition,
+ * based on the information in the supplied message exchange pattern.
+ *
+ * @param wsdls The list of current WSDL definitions
+ * @param contract The contract
+ * @param portType The port type
+ * @param mep The message exchange pattern
+ * @return The WSDL operation
+ */
+ public javax.wsdl.Operation createOperation(java.util.List<javax.wsdl.Definition> wsdls,
+ org.jboss.savara.contract.model.Contract contract, javax.wsdl.PortType portType,
+ org.jboss.savara.contract.model.MessageExchangePattern mep,
+ WSDLBinding wsdlBinding) {
+ javax.wsdl.Operation ret=null;
+
+ javax.wsdl.Definition defn=null;
+
+ if (portType != null) {
+ defn = getDefinition(wsdls, contract, portType.getQName().getNamespaceURI(), wsdlBinding);
+ }
+
+ if (defn != null && mep != null) {
+ ret = defn.createOperation();
+ ret.setUndefined(false);
+
+ ret.setName(mep.getOperation());
+
+ QName msgname=WSDLGeneratorUtil.getRequestMessageType(portType.getQName().getNamespaceURI(),
+ mep.getOperation());
+
+ javax.wsdl.Message mesg=getMessage(wsdls, contract, msgname,
+ mep.getTypes(), wsdlBinding);
+
+ if (mesg != null) {
+ javax.wsdl.Input input=defn.createInput();
+ input.setMessage(mesg);
+ ret.setInput(input);
+ }
+
+ // Check if a request/response MEP
+ if (mep instanceof RequestResponseMEP) {
+ RequestResponseMEP rr=(RequestResponseMEP)mep;
+
+ msgname=WSDLGeneratorUtil.getResponseMessageType(portType.getQName().getNamespaceURI(),
+ mep.getOperation());
+
+ javax.wsdl.Message om=getMessage(wsdls, contract, msgname,
+ rr.getResponseTypes(), wsdlBinding);
+ if (om != null) {
+ javax.wsdl.Output output=defn.createOutput();
+ output.setMessage(om);
+ ret.setOutput(output);
+ }
+
+ // Generate fault details
+ if (rr.getFaultDetails() != null) {
+ for (int i=0; i < rr.getFaultDetails().size(); i++) {
+ FaultDetails fd=rr.getFaultDetails().get(i);
+
+ msgname = WSDLGeneratorUtil.getFaultMessageType(portType.getQName().getNamespaceURI(),
+ fd.getName());
+
+ javax.wsdl.Message fm=getMessage(wsdls, contract, msgname,
+ fd.getTypes(), wsdlBinding);
+ if (fm != null) {
+ javax.wsdl.Fault fault=defn.createFault();
+ fault.setName(fd.getName());
+ fault.setMessage(fm);
+
+ ret.addFault(fault);
+ }
+ }
+ }
+ }
+
+ portType.addOperation(ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method generates a binding operation, using the supplied WSDL definition,
+ * based on the information in the supplied message exchange pattern.
+ *
+ * @param wsdls The list of current WSDL definitions
+ * @param contract The contract
+ * @param binding The port type binding
+ * @param mep The message exchange pattern
+ * @return The WSDL binding operation
+ */
+ public javax.wsdl.BindingOperation createBindingOperation(java.util.List<javax.wsdl.Definition> wsdls,
+ org.jboss.savara.contract.model.Contract contract, javax.wsdl.Binding binding,
+ org.jboss.savara.contract.model.MessageExchangePattern mep,
+ WSDLBinding wsdlBinding) {
+ javax.wsdl.BindingOperation ret=null;
+
+ javax.wsdl.Definition defn=null;
+
+ if (binding != null) {
+ defn = getDefinition(wsdls, contract, binding.getQName().getNamespaceURI(), wsdlBinding);
+ }
+
+ if (defn != null && mep != null) {
+ ret = defn.createBindingOperation();
+ //ret.setUndefined(false);
+
+ // Check if WSDL operation details
+ if (wsdlBinding != null) {
+ wsdlBinding.updateOperation(defn, mep, ret);
+ }
+
+ ret.setName(mep.getOperation());
+
+ QName msgname=WSDLGeneratorUtil.getRequestMessageType(binding.getQName().getNamespaceURI(),
+ mep.getOperation());
+
+ javax.wsdl.Message mesg=getMessage(wsdls, contract,msgname,
+ mep.getTypes(), wsdlBinding);
+
+ if (mesg != null) {
+ javax.wsdl.BindingInput input=defn.createBindingInput();
+
+ // Check if WSDL operation details
+ if (wsdlBinding != null) {
+ wsdlBinding.updateInput(defn, input);
+ }
+
+ ret.setBindingInput(input);
+ }
+
+ // Check if a request/response MEP
+ if (mep instanceof RequestResponseMEP) {
+ RequestResponseMEP rr=(RequestResponseMEP)mep;
+
+ msgname=WSDLGeneratorUtil.getResponseMessageType(binding.getQName().getNamespaceURI(),
+ mep.getOperation());
+
+ javax.wsdl.Message om=getMessage(wsdls, contract, msgname,
+ rr.getResponseTypes(), wsdlBinding);
+ if (om != null) {
+ javax.wsdl.BindingOutput output=defn.createBindingOutput();
+
+ // Check if WSDL operation details
+ if (wsdlBinding != null) {
+ wsdlBinding.updateOutput(defn, output);
+ }
+
+ ret.setBindingOutput(output);
+ }
+
+ // Generate fault details
+ if (rr.getFaultDetails() != null) {
+ for (int i=0; i < rr.getFaultDetails().size(); i++) {
+ FaultDetails fd=rr.getFaultDetails().get(i);
+
+ msgname = WSDLGeneratorUtil.getFaultMessageType(binding.getQName().getNamespaceURI(),
+ fd.getName());
+
+ javax.wsdl.Message fm=getMessage(wsdls, contract, msgname,
+ fd.getTypes(), wsdlBinding);
+ if (fm != null) {
+ javax.wsdl.BindingFault fault=defn.createBindingFault();
+ fault.setName(fd.getName());
+
+ // Check if WSDL operation details
+ if (wsdlBinding != null) {
+ wsdlBinding.updateFault(defn, fault);
+ }
+
+ ret.addBindingFault(fault);
+ }
+ }
+ }
+ }
+
+ binding.addBindingOperation(ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns a message, using the supplied WSDL definition,
+ * based on the information supplied in the list of type references. If
+ * a single type reference is supplied, this will be the message type,
+ * if multiple type references are supplied, then these will be considered
+ * the message parts.<p>
+ * <p>
+ * The returned message will be part of the supplied definition. If it
+ * does not exist prior to the call to this method, then it will be
+ * created and added to the definition upon returning the message.
+ *
+ * @param wsdls The list of current WSDL definitions
+ * @param contract The contract
+ * @param msgname The message name
+ * @param types The list of type references
+ * @return The WSDL message
+ */
+ public javax.wsdl.Message getMessage(java.util.List<javax.wsdl.Definition> wsdls,
+ org.jboss.savara.contract.model.Contract contract,
+ javax.xml.namespace.QName msgname,
+ java.util.List<org.jboss.savara.contract.model.Type> types,
+ WSDLBinding wsdlBinding) {
+ javax.wsdl.Message ret=null;
+
+ if (types == null || types.size() == 0) {
+ throw new UnsupportedOperationException("Expecting single type reference");
+ } else if (types.size() > 1) {
+ throw new UnsupportedOperationException("Currently only supports single type reference");
+ } else {
+ Type ref=types.get(0);
+
+ java.util.Iterator<TypeDefinition> iter=ref.getTypeDefinitions().iterator();
+ boolean f_done=false;
+
+ while (f_done == false && iter.hasNext()) {
+ TypeDefinition td=iter.next();
+
+ if (TypeDefinition.XSD_ELEMENT.equals(td.getTypeSystem()) ||
+ TypeDefinition.XSD_TYPE.equals(td.getTypeSystem())) {
+ javax.xml.namespace.QName qname=
+ new javax.xml.namespace.QName(td.getNamespace(),td.getName());
+ javax.wsdl.Definition defn=
+ getDefinition(wsdls, contract, msgname.getNamespaceURI(), wsdlBinding);
+
+ if (defn != null && qname != null &&
+ (ret = defn.getMessage(msgname)) == null) {
+ ret = defn.createMessage();
+ ret.setUndefined(false);
+
+ ret.setQName(msgname);
+
+ // Create single part for type or element
+ Part part=defn.createPart();
+ part.setName("content");
+
+ if (TypeDefinition.XSD_ELEMENT.equals(td.getTypeSystem())) {
+ part.setElementName(qname);
+ } else {
+ part.setTypeName(qname);
+ }
+
+ ret.addPart(part);
+
+ defn.addMessage(ret);
+
+ f_done = true;
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+}
Copied: trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/util/WSDLGeneratorUtil.java (from rev 478, trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/generator/WSDLGeneratorUtil.java)
===================================================================
--- trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/util/WSDLGeneratorUtil.java (rev 0)
+++ trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/util/WSDLGeneratorUtil.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -0,0 +1,62 @@
+/*
+ * 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.jboss.savara.wsdl.util;
+
+/**
+ * This class provides general utility functions for
+ * use when generating artefacts.
+ */
+public class WSDLGeneratorUtil {
+
+ private static final String RESPONSE = "Response";
+ private static final String FAULT = "Fault";
+ private static final String REQUEST = "Request";
+
+ /**
+ * This method returns the request message type QName.
+ *
+ * @param intfNamespace The interface namespace
+ * @param op The operation name
+ * @return The request message type
+ */
+ public static javax.xml.namespace.QName getRequestMessageType(String intfNamespace, String op) {
+ return(new javax.xml.namespace.QName(intfNamespace, op+REQUEST));
+ }
+
+ /**
+ * This method returns the response message type QName.
+ *
+ * @param intfNamespace The interface namespace
+ * @param op The operation name
+ * @return The response message type
+ */
+ public static javax.xml.namespace.QName getResponseMessageType(String intfNamespace, String op) {
+ return(new javax.xml.namespace.QName(intfNamespace, op+RESPONSE));
+ }
+
+ /**
+ * This method returns the fault message type QName.
+ *
+ * @param intfNamespace The interface namespace
+ * @param faultName The fault name
+ * @return The fault message type
+ */
+ public static javax.xml.namespace.QName getFaultMessageType(String intfNamespace, String faultName) {
+ return(new javax.xml.namespace.QName(intfNamespace, faultName+FAULT));
+ }
+}
Deleted: trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/util/XMLUtils.java
===================================================================
--- trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/util/XMLUtils.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/bundles/org.jboss.savara.wsdl/src/java/org/jboss/savara/wsdl/util/XMLUtils.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -1,300 +0,0 @@
-/*
- * 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.jboss.savara.wsdl.util;
-
-import java.io.ByteArrayOutputStream;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.scribble.model.ModelObject;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-/**
- * This class defines a set of XML related utility functions.
- */
-public final class XMLUtils {
-
- private static final String NS_LABEL = "ns";
-
- /**
- * This class converts a DOM representation node to text.
- * @param node
- * @return
- * @throws Exception
- */
- public static final String toText(Node node) throws Exception {
- String ret = null;
- try {
- // Transform the DOM represent to text
- ByteArrayOutputStream xmlstr= new ByteArrayOutputStream();
- DOMSource source=new DOMSource(node);
- //source.setNode(node);
-
- StreamResult result=new StreamResult(xmlstr);
- Transformer trans= TransformerFactory.newInstance().newTransformer();
- trans.transform(source, result);
-
- xmlstr.close();
-
- ret = new String(xmlstr.toByteArray());
-
- if ((node instanceof Document) == false) {
- // Strip off any <?xml> header
- int index=ret.indexOf("<?xml");
- if (index != -1) {
- index = ret.indexOf("<", 1);
- if (index != -1) {
- ret = ret.substring(index);
- } else {
- index = ret.indexOf("?>");
- if (index != -1) {
- index += 2;
-
- // Remove any trailing whitespaces after XML header
- while (index < ret.length() &&
- Character.isWhitespace(ret.charAt(index))) {
- index++;
- }
-
- ret = ret.substring(index);
- }
- }
- }
- }
-
- } catch(Exception e) {
- throw new Exception("Failed to transform DOM representation into text", e);
- }
- if (ret != null) {
- return format(ret);
- }
- return ret;
- }
-
-
- /**
- * Format the xml to well print.
- *
- * @param xmltext
- * @return
- */
- public static final String format(String xmltext) {
- String ret=xmltext;
- int pos=0;
- int prevpos=0;
- StringBuffer buf=new StringBuffer();
- int level=0;
-
- while ((pos=ret.indexOf('<', prevpos)) != -1) {
-
- if (prevpos < pos &&
- ret.substring(prevpos, pos).trim().length() > 0 &&
- ret.charAt(prevpos-1) != '?') {
-
- if (ret.charAt(prevpos) == '\r' &&
- ret.charAt(prevpos+1) == '\n') {
- prevpos += 2;
- }
- for (int i=0; i < level; i++) {
- buf.append(" ");
- }
-
- buf.append(ret.substring(prevpos, pos).trim());
- buf.append("\r\n");
- }
-
- int endpos=ret.indexOf('>', pos);
-
- if (endpos > 0) {
- boolean noreturn=false;
-
- if (pos > 0 && ret.charAt(pos+1) == '/') {
- level--;
- }
-
- for (int i=0; i < level; i++) {
- buf.append(" ");
- }
- buf.append(ret.substring(pos, endpos+1));
-
- if (ret.charAt(endpos-1)== '?') {
- //noreturn = true;
-
- } else if (ret.charAt(endpos-1) == '/') {
- // Ignore
- } else if (pos > 0 && ret.charAt(pos+1) == '/') {
- // Ignore
-
- } else if (pos > 0 && ret.charAt(pos+1) == '!') {
- // Ignore
-
- } else {
- level++;
- }
-
- if (noreturn == false) {
- buf.append("\r\n");
- }
-
- pos = endpos+1;
- }
-
- prevpos = pos;
- }
-
- if (prevpos != -1 &&
- ret.substring(prevpos).trim().length() > 0) {
- buf.append(ret.substring(prevpos));
- }
-
- ret = buf.toString();
-
- return(ret);
- }
-
- public static Node getNode(String text) throws Exception {
- Node ret=null;
-
- // Transform the text representation to DOM
- DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
- fact.setNamespaceAware(true);
-
- java.io.InputStream xmlstr=
- new java.io.ByteArrayInputStream(text.getBytes());
-
- DocumentBuilder builder=fact.newDocumentBuilder();
- org.w3c.dom.Document doc=builder.parse(xmlstr);
-
- ret = doc.getDocumentElement();
-
- return(ret);
- }
-
- /**
- * This method returns the localname part of the supplied
- * qualified name.
- *
- * @param qname The qualified name
- * @return The localname part
- */
- public static String getLocalname(String qname) {
- String ret=qname;
- int pos=0;
-
- if (qname != null && ((pos=qname.indexOf(':')) != -1)) {
- ret = qname.substring(pos+1);
- }
-
- return(ret);
- }
-
- /**
- * This method returns the prefix associated with the supplied namespace.
- *
- * @param namespace The namespace
- * @param nsMap The existing namespace prefix mappings
- * @return The prefix
- */
- public static String getPrefix(String namespace, java.util.Map<String,String> nsMap) {
- String prefix=null;
-
- prefix = nsMap.get(namespace);
-
- if (prefix == null) {
- prefix = NS_LABEL+(nsMap.size()+1);
- nsMap.put(namespace, prefix);
- }
-
- return(prefix);
- }
-
- /**
- * This method calculates the start and end position of a supplied DOM element, within
- * the supplied text contents, and sets the values on the supplied ModelObject.
- *
- * @param obj The ModelObject to be initialized
- * @param contents The text contents
- * @param elem The DOM element to be located in the text
- */
- public static void setStartAndEndPosition(ModelObject obj, String contents, org.w3c.dom.Element elem) {
-
- if (contents != null) {
- org.w3c.dom.NodeList nl=elem.getOwnerDocument().getElementsByTagName(elem.getNodeName());
- int elempos=-1;
-
- for (int i=0; elempos == -1 && i < nl.getLength(); i++) {
- if (nl.item(i) == elem) {
- elempos = i;
- }
- }
-
- if (elempos != -1) {
- int startpos=-1;
-
- for (int i=0; i <= elempos; i++) {
- int val1=contents.indexOf("<"+elem.getNodeName()+">", startpos+1);
- int val2=contents.indexOf("<"+elem.getNodeName()+" ", startpos+1);
-
- if (val1 == -1 && val2 != -1) {
- startpos = val2;
- } else if (val1 != -1 && val2 == -1) {
- startpos = val1;
- } else if (val1 == -1 && val2 == -1) {
- // TODO: Error condition
- break;
- } else if (val1 > val2) {
- startpos = val2;
- } else {
- startpos = val1;
- }
- }
-
- if (startpos != -1) {
- obj.getSource().setStartPosition(startpos);
-
- // Check if single node
- int p1=contents.indexOf('>', startpos);
-
- if (p1 != -1 && contents.charAt(p1-1) == '/') {
- obj.getSource().setEndPosition(p1);
- } else {
-
- org.w3c.dom.NodeList enl=elem.getElementsByTagName(elem.getNodeName());
-
- int endpos=startpos;
- String nodetxt="</"+elem.getNodeName()+">";
-
- for (int i=0; endpos != -1 && i <= enl.getLength(); i++) {
- endpos = contents.indexOf(nodetxt, endpos+1);
- }
-
- if (endpos != -1) {
- obj.getSource().setEndPosition(endpos+nodetxt.length()-1);
- }
- }
- }
- }
- }
- }
-}
Modified: trunk/bundles/pom.xml
===================================================================
--- trunk/bundles/pom.xml 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/bundles/pom.xml 2010-11-19 11:47:22 UTC (rev 484)
@@ -31,6 +31,7 @@
</properties>
<modules>
+ <module>org.jboss.savara.core</module>
<module>org.jboss.savara.wsdl</module>
<module>org.jboss.savara.bpel</module>
</modules>
Modified: trunk/tools/features/org.jboss.savara.tools.feature/feature.xml
===================================================================
--- trunk/tools/features/org.jboss.savara.tools.feature/feature.xml 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/tools/features/org.jboss.savara.tools.feature/feature.xml 2010-11-19 11:47:22 UTC (rev 484)
@@ -194,6 +194,13 @@
unpack="false"/>
<plugin
+ id="org.jboss.savara.core"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
id="org.jboss.savara.tools.bpel"
download-size="0"
install-size="0"
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF 2010-11-19 11:47:22 UTC (rev 484)
@@ -24,7 +24,8 @@
org.eclipse.wst.common.frameworks,
org.eclipse.wst.common.project.facet.core,
org.jboss.savara.wsdl,
- org.jboss.savara.bpel
+ org.jboss.savara.bpel,
+ org.jboss.savara.core
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: www.jboss.org
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/dialogs/GenerateDialog.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/dialogs/GenerateDialog.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/dialogs/GenerateDialog.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -47,9 +47,6 @@
m_file = file;
- m_buildSystems.add(new AntBuildSystem());
- m_buildSystems.add(new MavenBuildSystem());
-
initialize(m_file);
}
@@ -227,27 +224,6 @@
}
});
- label = new Label(group, SWT.RIGHT);
- label.setText("Build: ");
-
- gd = new GridData();
- gd.horizontalSpan = 1;
- gd.widthHint = 100;
- label.setLayoutData(gd);
-
- m_build=new Combo(group, SWT.DROP_DOWN);
-
- for (int i=0; i < m_buildSystems.size(); i++) {
- m_build.add(m_buildSystems.get(i).getName());
- }
-
- m_build.select(0);
-
- gd = new GridData();
- gd.horizontalSpan = 1;
- gd.widthHint = 100;
- m_build.setLayoutData(gd);
-
return(composite);
}
@@ -324,8 +300,7 @@
public void okPressed() {
try {
- Generator generator=new Generator(m_file,
- getSelectedBuildSystem());
+ Generator generator=new Generator(m_file);
for (int i=0; i < m_localModelRefs.size(); i++) {
@@ -341,10 +316,6 @@
}
}
- protected BuildSystem getSelectedBuildSystem() {
- return(m_buildSystems.get(m_build.getSelectionIndex()));
- }
-
/**
* This method is used to report an error.
*
@@ -370,6 +341,4 @@
private java.util.List<ModelReference> m_localModelRefs=null;
private java.util.List<Button> m_roleButtons=new java.util.Vector<Button>();
private java.util.List<Text> m_projectNames=new java.util.Vector<Text>();
- private Combo m_build=null;
- private java.util.List<BuildSystem> m_buildSystems=new java.util.Vector<BuildSystem>();
}
Deleted: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/AbstractBuildSystem.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/AbstractBuildSystem.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/AbstractBuildSystem.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -1,58 +0,0 @@
-/*
- * 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.jboss.savara.tools.bpel.generator;
-
-/**
- * This class represents an abstract build system.
- */
-public abstract class AbstractBuildSystem implements BuildSystem {
-
- private static final String TEMPLATE_SUFFIX = ".template";
- private static final String TEMPLATE_PREFIX = "template/";
-
- /**
- * This method returns the contents for the build
- * configuration file.
- *
- * @param projectName The project name
- * @return The build file contents
- */
- public String getBuildFileContents(String projectName) {
- String ret=null;
-
- java.io.InputStream is=
- AbstractBuildSystem.class.getResourceAsStream(
- TEMPLATE_PREFIX+getName()+TEMPLATE_SUFFIX);
-
- if (is != null) {
-
- try {
- byte[] b=new byte[is.available()];
- is.read(b);
-
- ret = new String(b);
-
- ret = ret.replaceAll("%PROJECT%", projectName);
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- return(ret);
- }
-}
Deleted: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/AntBuildSystem.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/AntBuildSystem.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/AntBuildSystem.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -1,59 +0,0 @@
-/*
- * 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.jboss.savara.tools.bpel.generator;
-
-/**
- * This class represents the Ant build system.
- */
-public class AntBuildSystem extends AbstractBuildSystem {
-
- private static final String BUILD_FILE = "build.xml";
- private static final String ANT = "Ant";
- private static final String BPEL_PATH = "bpelContent";
-
- /**
- * This method represents the name of the build
- * system.
- *
- * @return The name
- */
- public String getName() {
- return(ANT);
- }
-
- /**
- * This method returns the build configuration file
- * path.
- *
- * @return The build configuration file path
- */
- public String getBuildFilePath() {
- return(BUILD_FILE);
- }
-
- /**
- * This method returns the BPEL file
- * path.
- *
- * @return The BPEL file path
- */
- public String getBPELFilePath() {
- return(BPEL_PATH);
- }
-
-}
Deleted: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/BuildSystem.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/BuildSystem.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/BuildSystem.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -1,58 +0,0 @@
-/*
- * 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.jboss.savara.tools.bpel.generator;
-
-/**
- * This interface represents a build system used when
- * generating the ESB projects.
- */
-public interface BuildSystem {
-
- /**
- * This method represents the name of the build
- * system.
- *
- * @return The name
- */
- public String getName();
-
- /**
- * This method returns the build configuration file
- * path.
- *
- * @return The build configuration file path
- */
- public String getBuildFilePath();
-
- /**
- * This method returns the contents for the build
- * configuration file.
- *
- * @param projectName The project name
- * @return The build file contents
- */
- public String getBuildFileContents(String projectName);
-
- /**
- * This method returns the BPEL file path.
- *
- * @return The BPEL file path
- */
- public String getBPELFilePath();
-
-}
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -30,10 +30,10 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
-import org.jboss.savara.tools.bpel.generator.BuildSystem;
import org.jboss.savara.bpel.model.*;
import org.jboss.savara.bpel.model.component.PartnerLink;
-import org.jboss.savara.bpel.util.XMLUtils;
+import org.jboss.savara.util.XMLUtils;
+import org.jboss.savara.wsdl.generator.WSDLGeneratorFactory;
import org.jboss.savara.wsdl.generator.soap.SOAPDocLitWSDLBinding;
import org.jboss.savara.contract.model.Contract;
import org.jboss.savara.contract.model.Interface;
@@ -105,13 +105,14 @@
private static final String XMLNS_PLNK = "xmlns:plnk";
+ private static final String BPEL_PATH = "bpelContent";
+
/**
* This is the constructor for the generator.
*
*/
- public Generator(IFile file, BuildSystem buildSystem) {
+ public Generator(IFile file) {
m_file = file;
- m_buildSystem = buildSystem;
initialize(m_file);
}
@@ -239,7 +240,7 @@
// Store BPEL configuration
IPath bpelPath=proj.getFullPath().append(
- new Path(getBuildSystem().getBPELFilePath())).
+ new Path(BPEL_PATH)).
append(localcm.getModelName().getName()+"_"+
localcm.getModelName().getRole().getName()+".bpel");
@@ -281,19 +282,19 @@
javax.wsdl.xml.WSDLWriter writer=
javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
org.jboss.savara.wsdl.generator.WSDLGenerator generator=
- new org.jboss.savara.wsdl.generator.WSDLGenerator();
+ WSDLGeneratorFactory.getWSDLGenerator();
Contract contract=(Contract)role.getAnnotations().get(Contract.class.getName());
// Generate BPEL folder
IPath bpelFolderPath=proj.getFullPath().append(
- new Path(getBuildSystem().getBPELFilePath()));
+ new Path(BPEL_PATH));
IFolder wsdlFolder=proj.getProject().getWorkspace().getRoot().getFolder(bpelFolderPath);
createFolder(wsdlFolder);
// Generate definition
- java.util.List<javax.wsdl.Definition> defns=generator.generateDefinitions(contract,
+ java.util.List<javax.wsdl.Definition> defns=generator.generate(contract,
new SOAPDocLitWSDLBinding());
// Check if contract has atleast one message exchange pattern
@@ -639,7 +640,7 @@
String filename=getWSDLFileName(role, localcm.getModelName().getName(), "Artifacts");
IPath wsdlPath=proj.getFullPath().append(
- new Path(getBuildSystem().getBPELFilePath())).
+ new Path(BPEL_PATH)).
append(filename);
IFile wsdlFile=proj.getProject().getWorkspace().getRoot().getFile(wsdlPath);
@@ -745,7 +746,7 @@
// Write partner link types to file
IPath wsdlPath=proj.getFullPath().append(
- new Path(getBuildSystem().getBPELFilePath())).
+ new Path(BPEL_PATH)).
append(BPEL_DEPLOY_DESCRIPTOR_FILENAME);
IFile wsdlFile=proj.getProject().getWorkspace().getRoot().getFile(wsdlPath);
@@ -849,14 +850,16 @@
}
}
+ /*
public BuildSystem getBuildSystem() {
return(m_buildSystem);
}
+ */
private static Log logger = LogFactory.getLog(Generator.class);
private IFile m_file=null;
private java.util.List<ModelReference> m_localModelRefs=null;
private ConversationModel m_conversationModel=null;
- private BuildSystem m_buildSystem=null;
+ //private BuildSystem m_buildSystem=null;
}
Deleted: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/MavenBuildSystem.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/MavenBuildSystem.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/MavenBuildSystem.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -1,59 +0,0 @@
-/*
- * 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.jboss.savara.tools.bpel.generator;
-
-/**
- * This class represents the Ant build system.
- */
-public class MavenBuildSystem extends AbstractBuildSystem {
-
- private static final String BUILD_FILE = "pom.xml";
- private static final String MAVEN = "Maven";
- private static final String BPEL_PATH = "src/main/resources/bpelContent";
-
- /**
- * This method represents the name of the build
- * system.
- *
- * @return The name
- */
- public String getName() {
- return(MAVEN);
- }
-
- /**
- * This method returns the build configuration file
- * path.
- *
- * @return The build configuration file path
- */
- public String getBuildFilePath() {
- return(BUILD_FILE);
- }
-
- /**
- * This method returns the BPEL file
- * path.
- *
- * @return The BPEL file path
- */
- public String getBPELFilePath() {
- return(BPEL_PATH);
- }
-
-}
Modified: trunk/tools/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/actions/GenerateAction.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/actions/GenerateAction.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/tools/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/actions/GenerateAction.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -30,6 +30,7 @@
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.jboss.savara.tools.wsdl.util.XMLUtils;
+import org.jboss.savara.wsdl.generator.WSDLGeneratorFactory;
import org.jboss.savara.wsdl.generator.soap.SOAPDocLitWSDLBinding;
import javax.xml.transform.Transformer;
@@ -133,14 +134,14 @@
javax.wsdl.xml.WSDLWriter writer=
javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
org.jboss.savara.wsdl.generator.WSDLGenerator generator=
- new org.jboss.savara.wsdl.generator.WSDLGenerator();
+ WSDLGeneratorFactory.getWSDLGenerator();
Contract contract=(Contract)ref.getAnnotations().get(Contract.class.getName());
// Generate WSDL folder
IPath wsdlFolderPath=cdmResource.getParent().getFullPath();
// Generate definition
- java.util.List<javax.wsdl.Definition> defns=generator.generateDefinitions(contract,
+ java.util.List<javax.wsdl.Definition> defns=generator.generate(contract,
new SOAPDocLitWSDLBinding());
// Check if contract has atleast one message exchange pattern
Modified: trunk/tools/tests/org.jboss.savara.tools.bpel.tests/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/tests/org.jboss.savara.tools.bpel.tests/META-INF/MANIFEST.MF 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/tools/tests/org.jboss.savara.tools.bpel.tests/META-INF/MANIFEST.MF 2010-11-19 11:47:22 UTC (rev 484)
@@ -28,4 +28,5 @@
org.eclipse.wst.common.frameworks,
org.eclipse.wst.common.project.facet.core,
org.scribble.conversation.projector;bundle-version="[1.0.0,2.0.0)",
- org.jboss.savara.bpel
+ org.jboss.savara.bpel,
+ org.jboss.savara.core
Modified: trunk/tools/tests/org.jboss.savara.tools.bpel.tests/src/java/org/jboss/savara/bpel/util/XMLUtilsTest.java
===================================================================
--- trunk/tools/tests/org.jboss.savara.tools.bpel.tests/src/java/org/jboss/savara/bpel/util/XMLUtilsTest.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/tools/tests/org.jboss.savara.tools.bpel.tests/src/java/org/jboss/savara/bpel/util/XMLUtilsTest.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -17,7 +17,7 @@
*/
package org.jboss.savara.bpel.util;
-import org.jboss.savara.bpel.util.XMLUtils;
+import org.jboss.savara.util.XMLUtils;
import org.scribble.model.ModelObject;
import junit.framework.TestCase;
Modified: trunk/tools/tests/org.jboss.savara.tools.bpel.tests/src/java/org/jboss/savara/tools/bpel/generator/GeneratorTest.java
===================================================================
--- trunk/tools/tests/org.jboss.savara.tools.bpel.tests/src/java/org/jboss/savara/tools/bpel/generator/GeneratorTest.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/tools/tests/org.jboss.savara.tools.bpel.tests/src/java/org/jboss/savara/tools/bpel/generator/GeneratorTest.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -24,7 +24,7 @@
import org.jboss.savara.bpel.model.BPELNotation;
import org.jboss.savara.bpel.model.DefaultBPELLanguageModel;
-import org.jboss.savara.bpel.util.XMLUtils;
+import org.jboss.savara.util.XMLUtils;
import org.jboss.savara.pi4soa.cdm.model.CDMNotation;
import org.scribble.extensions.RegistryFactory;
import org.scribble.model.Definition;
Modified: trunk/tools/tests/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java
===================================================================
--- trunk/tools/tests/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java 2010-11-18 14:10:07 UTC (rev 483)
+++ trunk/tools/tests/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java 2010-11-19 11:47:22 UTC (rev 484)
@@ -21,6 +21,8 @@
import javax.xml.namespace.QName;
import org.jboss.savara.wsdl.generator.WSDLGenerator;
+import org.jboss.savara.wsdl.generator.WSDLGeneratorFactory;
+import org.jboss.savara.wsdl.generator.impl.WSDLGeneratorImpl;
import org.jboss.savara.contract.model.*;
import junit.framework.TestCase;
@@ -43,9 +45,9 @@
c.setName(TEST_NAME);
c.setNamespace(TEST_NAME_SPACE);
- WSDLGenerator gen=new WSDLGenerator();
+ WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
- java.util.List<javax.wsdl.Definition> defns=gen.generateDefinitions(c, null);
+ java.util.List<javax.wsdl.Definition> defns=gen.generate(c, null);
if (defns.size() != 1) {
fail("Only one Definition found: "+defns.size());
@@ -80,7 +82,7 @@
src.setName(TEST_NAME);
src.setNamespace(TEST_NAME_SPACE);
- WSDLGenerator gen=new WSDLGenerator();
+ WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
@@ -117,7 +119,7 @@
src.setName(TEST_NAME);
src.setNamespace(TEST_NAME_SPACE);
- WSDLGenerator gen=new WSDLGenerator();
+ WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
@@ -143,7 +145,7 @@
fail("QName localpart not set");
}
- if (result.getQName().getLocalPart().equals(TEST_NAME+WSDLGenerator.BINDING_SUFFIX) == false) {
+ if (result.getQName().getLocalPart().equals(TEST_NAME+WSDLGeneratorImpl.BINDING_SUFFIX) == false) {
fail("QName localpart not correct: "+result.getQName().getLocalPart());
}
}
@@ -213,9 +215,9 @@
c.getInterfaces().add(i2);
c.getInterfaces().add(i3);
- WSDLGenerator gen=new WSDLGenerator();
+ WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
- java.util.List<javax.wsdl.Definition> defns=gen.generateDefinitions(c, null);
+ java.util.List<javax.wsdl.Definition> defns=gen.generate(c, null);
if (defns.size() != 1) {
fail("Only one Definition found: "+defns.size());
@@ -261,7 +263,7 @@
tref.setName(ref.getName());
src.getTypes().add(tref);
- WSDLGenerator gen=new WSDLGenerator();
+ WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
defns.add(defn);
@@ -352,7 +354,7 @@
src.getFaultDetails().add(fd2);
- WSDLGenerator gen=new WSDLGenerator();
+ WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
defns.add(defn);
@@ -409,7 +411,7 @@
java.util.List<Type> refs=new java.util.Vector<Type>();
refs.add(t);
- WSDLGenerator gen=new WSDLGenerator();
+ WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
@@ -529,9 +531,9 @@
c.getInterfaces().add(i2);
c.getInterfaces().add(i3);
- WSDLGenerator gen=new WSDLGenerator();
+ WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
- java.util.List<javax.wsdl.Definition> defns=gen.generateDefinitions(c, null);
+ java.util.List<javax.wsdl.Definition> defns=gen.generate(c, null);
if (defns.size() != 2) {
fail("Two Definitions expected, but got: "+defns.size());
15 years, 5 months
savara SVN: r483 - trunk/tools/plugins/org.jboss.savara.pi4soa.cdm.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-11-18 09:10:07 -0500 (Thu, 18 Nov 2010)
New Revision: 483
Modified:
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/
Log:
Property changes on: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm
___________________________________________________________________
Name: svn:ignore
+ bin
15 years, 5 months
savara SVN: r482 - in trunk/tools/plugins: org.jboss.savara.pi4soa.cdm and 14 other directories.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-11-18 09:07:09 -0500 (Thu, 18 Nov 2010)
New Revision: 482
Added:
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.classpath
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.project
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/Copyright.txt
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/build.properties
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/pom.xml
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/CDMDefinitions.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/CDMEditorManager.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/CDMNotation.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/osgi/
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/osgi/Activator.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMModelParserRule.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMTokenizer.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/AssignConverterRuleImpl.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationModelConverterRuleImpl.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterContext.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRule.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRuleFactory.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterUtil.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizeConverterRuleImpl.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizerHandlerConverterRuleImpl.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfConverterRuleImpl.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfOrWhenConverterRuleImpl.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ParallelConverterRuleImpl.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/SequenceConverterRuleImpl.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhenConverterRuleImpl.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhileConverterRuleImpl.java
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/validation/
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/validation/TypeReferenceValidationRule.java
Log:
Re-commit the pi4soa cdm plugin.
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.classpath
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.classpath (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.classpath 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.project
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.project (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.project 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.savara.pi4soa.cdm</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/Copyright.txt
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/Copyright.txt (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/Copyright.txt 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,17 @@
+/*
+ * 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.
+ */
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JBoss SAVARA pi4soa CDM
+Bundle-SymbolicName: org.jboss.savara.pi4soa.cdm
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.jboss.savara.pi4soa.cdm.osgi.Activator
+Bundle-Vendor: www.jboss.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.pi4soa.cdl,
+ org.pi4soa.common,
+ org.scribble.core;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.conversation.model;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.conversation.parser;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.ui;resolution:=optional,
+ org.eclipse.core.resources;resolution:=optional,
+ org.eclipse.core.runtime;resolution:=optional,
+ org.pi4soa.designer;resolution:=optional,
+ org.eclipse.ui.views.properties.tabbed;resolution:=optional,
+ org.scribble.expression.xpath;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.eclipse;bundle-version="[1.0.0,2.0.0)";resolution:=optional,
+ org.jboss.savara.contract.model
+Scribble-Extensions: org.jboss.savara.pi4soa.cdm.parser.CDMTokenizer,
+ org.jboss.savara.pi4soa.cdm.parser.CDMModelParserRule,
+ org.jboss.savara.pi4soa.cdm.model.CDMNotation,
+ org.jboss.savara.pi4soa.cdm.model.SCNNotation,
+ org.jboss.savara.pi4soa.cdm.validation.TypeReferenceValidationRule,
+ org.jboss.savara.pi4soa.cdm.editor.CDMEditorManager,
+ org.jboss.savara.pi4soa.cdm.editor.SCNEditorManager
+Export-Package: org.jboss.savara.pi4soa.cdm.model,
+ org.jboss.savara.pi4soa.cdm.parser
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/build.properties
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/build.properties (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/build.properties 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,4 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/pom.xml
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/pom.xml (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/pom.xml 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,26 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.savara.tools</groupId>
+ <artifactId>org.jboss.savara.pi4soa.cdm</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Tools::Plugins::Pi4SOACDM</name>
+
+ <parent>
+ <groupId>org.jboss.savara.tools</groupId>
+ <artifactId>plugins</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+<!--
+ <dependencies>
+ <dependency>
+ <groupId></groupId>
+ <artifactId></artifactId>
+ <version></version>
+ </dependency>
+ </dependencies>
+-->
+
+</project>
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/CDMDefinitions.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/CDMDefinitions.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/CDMDefinitions.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 17 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm;
+
+/**
+ * This class provides common definitions used in the Scribble
+ * transformation of the CDM file.
+ */
+public class CDMDefinitions {
+
+ public static final String CDM_NOTATION="cdm";
+
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/CDMEditorManager.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/CDMEditorManager.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/CDMEditorManager.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.editor;
+
+import org.eclipse.emf.ecore.EValidator;
+import org.jboss.savara.pi4soa.cdm.model.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+import org.scribble.model.SourceRef;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.editor.*;
+
+/**
+ * This is the CDM designer's implementation of the EditorManager
+ * interface.
+ */
+(a)RegistryInfo(extension=EditorManager.class,notation=CDMNotation.NOTATION_CODE) //preference=10,
+public class CDMEditorManager extends AbstractEditorManager {
+
+ /**
+ * This method focuses the editor on the specified source,
+ * identified by the model reference and source reference.
+ *
+ * @param mref The model reference
+ * @param sref The component source reference
+ * @param prop Additional properties
+ */
+ public void focus(ModelReference mref, SourceRef sref,
+ java.util.Map<String,Object> props) {
+ String uri=null;
+ org.eclipse.core.resources.IFile file=
+ org.scribble.eclipse.model.admin.OSGIModelRepository.getFile(mref);
+
+ if (file == null || file.exists() == false) {
+ file = org.scribble.eclipse.model.admin.OSGIModelRepository.getGlobalFile(mref);
+ }
+
+ if (file != null && file.exists()) {
+ uri = file.getFullPath().toPortableString();
+ }
+
+ if (uri != null) {
+ org.eclipse.ui.IWorkbenchPage page=
+ org.eclipse.ui.PlatformUI.getWorkbench().
+ getActiveWorkbenchWindow().getActivePage();
+
+ org.eclipse.core.resources.IResource res=
+ org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().findMember(uri);
+
+ if (res instanceof org.eclipse.core.resources.IFile) {
+ org.eclipse.ui.part.FileEditorInput input=
+ new org.eclipse.ui.part.FileEditorInput(
+ (org.eclipse.core.resources.IFile)res);
+
+ try {
+ org.eclipse.ui.IEditorPart part=page.openEditor(input,
+ "org.pi4soa.designer.Pi4SOADesignerID");
+
+ if (part instanceof org.pi4soa.designer.editor.ChoreographyDescriptionEditor) {
+ org.pi4soa.designer.editor.ChoreographyDescriptionEditor editor=
+ (org.pi4soa.designer.editor.ChoreographyDescriptionEditor)part;
+
+ /* Other approach using marker - can be used if editor does not
+ * provide alternative way to focus on component.
+ org.eclipse.core.resources.IMarker marker=res.createMarker(EValidator.MARKER);
+ marker.setAttribute(EValidator.URI_ATTRIBUTE, ref.getComponentURI());
+ editor.gotoMarker(marker);
+ marker.delete();
+ */
+
+ editor.showComponent(sref.getComponentURI());
+ }
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /**
+ * This method enriches the set of properties required
+ * by the editor, using the properties associated with
+ * the model issue.
+ *
+ * @param issue The model issue
+ */
+ @Override
+ public void enrich(ModelIssue issue) {
+
+ if (issue.getModelObject() != null) {
+ // Set the EMF URI attribute
+ issue.getProperties().put(EValidator.URI_ATTRIBUTE,
+ issue.getModelObject().getSource().getComponentURI());
+ }
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.editor;
+
+import org.eclipse.emf.ecore.EValidator;
+import org.jboss.savara.pi4soa.cdm.model.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+import org.scribble.model.SourceRef;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.editor.*;
+
+/**
+ * This is the CDM designer's implementation of the EditorManager
+ * interface.
+ */
+(a)RegistryInfo(extension=EditorManager.class,notation=SCNNotation.NOTATION_CODE) //preference=10,
+public class SCNEditorManager extends AbstractEditorManager {
+
+ /**
+ * This method focuses the editor on the specified source,
+ * identified by the model reference and source reference.
+ *
+ * @param mref The model reference
+ * @param sref The component source reference
+ * @param prop Additional properties
+ */
+ public void focus(ModelReference mref, SourceRef sref,
+ java.util.Map<String,Object> props) {
+ String uri=null;
+ org.eclipse.core.resources.IFile file=
+ org.scribble.eclipse.model.admin.OSGIModelRepository.getFile(mref);
+
+ if (file == null || file.exists() == false) {
+ file = org.scribble.eclipse.model.admin.OSGIModelRepository.getGlobalFile(mref);
+ }
+
+ if (file != null && file.exists()) {
+ uri = file.getFullPath().toPortableString();
+ }
+
+ if (uri != null) {
+ org.eclipse.ui.IWorkbenchPage page=
+ org.eclipse.ui.PlatformUI.getWorkbench().
+ getActiveWorkbenchWindow().getActivePage();
+
+ org.eclipse.core.resources.IResource res=
+ org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().findMember(uri);
+
+ if (res instanceof org.eclipse.core.resources.IFile) {
+ org.eclipse.ui.part.FileEditorInput input=
+ new org.eclipse.ui.part.FileEditorInput(
+ (org.eclipse.core.resources.IFile)res);
+
+ try {
+ org.eclipse.ui.IEditorPart part=page.openEditor(input,
+ "org.pi4soa.scenario.designer.Pi4SOAScenarioDesignerID");
+
+ if (part instanceof org.pi4soa.designer.editor.ChoreographyDescriptionEditor) {
+ org.pi4soa.designer.editor.ChoreographyDescriptionEditor editor=
+ (org.pi4soa.designer.editor.ChoreographyDescriptionEditor)part;
+
+ /* Other approach using marker - can be used if editor does not
+ * provide alternative way to focus on component.
+ org.eclipse.core.resources.IMarker marker=res.createMarker(EValidator.MARKER);
+ marker.setAttribute(EValidator.URI_ATTRIBUTE, ref.getComponentURI());
+ editor.gotoMarker(marker);
+ marker.delete();
+ */
+
+ editor.showComponent(sref.getComponentURI());
+ }
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /**
+ * This method enriches the set of properties required
+ * by the editor, using the properties associated with
+ * the model issue.
+ *
+ * @param issue The model issue
+ */
+ @Override
+ public void enrich(ModelIssue issue) {
+
+ if (issue.getModelObject() != null) {
+ // Set the EMF URI attribute
+ issue.getProperties().put(EValidator.URI_ATTRIBUTE,
+ issue.getModelObject().getSource().getComponentURI());
+ }
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/CDMNotation.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/CDMNotation.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/CDMNotation.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 17 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.model;
+
+import org.scribble.extensions.*;
+import org.scribble.model.ModelReference;
+import org.scribble.model.Notation;
+
+/**
+ * This class represents the CDM notation implementation.
+ */
+(a)RegistryInfo(extension=org.scribble.model.Notation.class)
+public class CDMNotation extends org.scribble.model.AbstractNotation {
+
+ public static final String NOTATION_CODE="cdm";
+
+ /**
+ * This is the constructor for the CDM notation.
+ */
+ public CDMNotation() {
+ super(NOTATION_CODE, "CDM", false);
+ }
+
+ /**
+ * This method returns the initial description associated
+ * with the supplied reference.
+ *
+ * @param ref The reference
+ * @return The initial description, or null if no description
+ */
+ public String getInitialDescription(ModelReference ref) {
+ StringBuffer buf=new StringBuffer();
+
+ return(buf.toString());
+ }
+
+ /**
+ * This method returns the optional 'super' notation.
+ * If defined, then this notation is a derived notation
+ * from the 'super' notation.
+ *
+ * @return The optional 'super' notation
+ */
+ @Override
+ public Notation getSuperNotation() {
+ return(m_superNotation);
+ }
+
+ private Notation m_superNotation=new org.scribble.conversation.model.ConversationNotation();
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 17 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.model;
+
+import org.scribble.extensions.*;
+import org.scribble.model.ModelReference;
+import org.scribble.model.Notation;
+
+/**
+ * This class represents the SCN notation implementation.
+ */
+(a)RegistryInfo(extension=org.scribble.model.Notation.class)
+public class SCNNotation extends org.scribble.model.AbstractNotation {
+
+ public static final String NOTATION_CODE="scn";
+
+ /**
+ * This is the constructor for the CDM notation.
+ */
+ public SCNNotation() {
+ super(NOTATION_CODE, "SCN", false);
+ }
+
+ /**
+ * This method returns the initial description associated
+ * with the supplied reference.
+ *
+ * @param ref The reference
+ * @return The initial description, or null if no description
+ */
+ public String getInitialDescription(ModelReference ref) {
+ StringBuffer buf=new StringBuffer();
+
+ return(buf.toString());
+ }
+
+ /**
+ * This method returns the optional 'super' notation.
+ * If defined, then this notation is a derived notation
+ * from the 'super' notation.
+ *
+ * @return The optional 'super' notation
+ */
+ @Override
+ public Notation getSuperNotation() {
+ return(m_superNotation);
+ }
+
+ private Notation m_superNotation=new org.scribble.conversation.model.ConversationNotation();
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/osgi/Activator.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/osgi/Activator.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/osgi/Activator.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,22 @@
+package org.jboss.savara.pi4soa.cdm.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ }
+
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMModelParserRule.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMModelParserRule.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMModelParserRule.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2007-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 May 2009 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.jboss.savara.pi4soa.cdm.model.CDMNotation;
+import org.jboss.savara.pi4soa.cdm.parser.rules.ConverterContext;
+import org.jboss.savara.pi4soa.cdm.parser.rules.ConverterRule;
+import org.jboss.savara.pi4soa.cdm.parser.rules.ConverterRuleFactory;
+import org.jboss.savara.pi4soa.cdm.parser.rules.DefaultConverterContext;
+import org.scribble.conversation.model.ConversationModel;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.Model;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.ParserContext;
+import org.scribble.parser.ParserRule;
+import org.scribble.parser.Token;
+
+/**
+ * This class provides the model parser for the CDM notation.
+ *
+ */
+(a)RegistryInfo(extension=ParserRule.class,notation=CDMNotation.NOTATION_CODE)
+public class CDMModelParserRule extends org.scribble.conversation.parser.ConversationModelParserRule {
+
+ /**
+ * The default constructor.
+ */
+ public CDMModelParserRule() {
+ //super(ParserRuleType.File);
+ }
+
+ /**
+ * This method determines whether the parser rules is
+ * appropriate to return a model object of the required
+ * type.
+ *
+ * @param type The required type
+ * @return Whether the parser rule returns a
+ * model object of the required type
+ */
+ public boolean isSupported(Class<?> type) {
+ return(type.isAssignableFrom(Model.class));
+ }
+
+ /**
+ * This method parses the description to obtain
+ * a model object of the appropriate type.
+ *
+ * @param context The context
+ * @param l The listener
+ * @return The model object
+ */
+ public Object parse(ParserContext context, ModelListener l) {
+ ConversationModel ret=null;
+
+ Token t=context.nextToken();
+
+ if (t != null && t.getObject() instanceof org.pi4soa.cdl.Package) {
+ try {
+ org.pi4soa.cdl.Package cdlpack=
+ (org.pi4soa.cdl.Package)t.getObject();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(ConversationModel.class,
+ cdlpack);
+
+ if (rule != null) {
+ ConverterContext cctxt=
+ new DefaultConverterContext(context.getSource());
+
+ ret = (ConversationModel)rule.convert(cctxt,
+ ConversationModel.class, cdlpack);
+ }
+
+ } catch(Exception e) {
+ logger.log(Level.SEVERE,
+ "Failed to load model", e);
+ }
+
+ if (logger.isLoggable(java.util.logging.Level.FINEST)) {
+
+ org.scribble.export.Exporter exporter=
+ (org.scribble.export.Exporter)
+ RegistryFactory.getRegistry().getExtension(
+ org.scribble.export.Exporter.class, null);
+
+ try {
+ org.scribble.export.text.TextFormatter formatter=
+ new org.scribble.export.text.TextFormatter();
+
+ java.io.ByteArrayOutputStream os=
+ new java.io.ByteArrayOutputStream();
+
+ formatter.setOutputStream(os);
+
+ exporter.export(context.getSource(), ret, formatter);
+
+ String str=new String(os.toByteArray());
+
+ System.out.println("EXPORTED CDM TEXT:");
+ System.out.println(str);
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser");
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMTokenizer.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMTokenizer.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMTokenizer.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 May 2009 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser;
+
+import org.jboss.savara.pi4soa.cdm.model.CDMNotation;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+import org.scribble.parser.*;
+
+/**
+ * This is the CDM based implementation of the tokenizer
+ * interface.
+ */
+(a)RegistryInfo(extension=Tokenizer.class,notation=CDMNotation.NOTATION_CODE)
+public class CDMTokenizer extends DefaultTokenizer {
+
+ /**
+ * The default constructor.
+ */
+ public CDMTokenizer() {
+ }
+
+ /**
+ * This method obtains a list of tokens based on the
+ * contents of the input stream.
+ *
+ * @param ref The model reference for the input source
+ * @param is The input stream
+ * @return The list of tokens
+ * @throws java.io.IOException Failed to derive
+ */
+ public java.util.List<Token> getTokens(ModelReference ref,
+ java.io.InputStream is) throws java.io.IOException {
+ java.util.List<Token> ret=new java.util.Vector<Token>();
+
+ org.pi4soa.cdl.Package cdlpack=
+ org.pi4soa.cdl.CDLManager.load(is);
+
+ if (cdlpack != null) {
+ Token t=new Token(cdlpack);
+ ret.add(t);
+ }
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/AssignConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/AssignConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/AssignConverterRuleImpl.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 3 Jun 2009 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.pi4soa.cdl.util.PackageUtil;
+import org.pi4soa.common.xml.XMLUtils;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class AssignConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Assign);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.model.Block ret=
+ new org.scribble.model.Block();
+ org.pi4soa.cdl.Assign cdl=(org.pi4soa.cdl.Assign)cdlType;
+ java.util.List<Raise> exceptions=new java.util.Vector<Raise>();
+
+ for (int i=0; i < cdl.getCopyDetails().size(); i++) {
+ org.pi4soa.cdl.CopyDetails details=cdl.getCopyDetails().get(i);
+
+ Assignment assign=new Assignment();
+
+ assign.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(details));
+
+ // Set role
+ Role role=new Role();
+
+ if (cdl.getParticipant() != null) {
+ role.setName(cdl.getParticipant().getName());
+ } else if (cdl.getRoleType() != null) {
+ org.pi4soa.cdl.ParticipantType ptype=
+ PackageUtil.getParticipantForRoleType(cdl.getRoleType());
+
+ if (ptype != null) {
+ role.setName(ptype.getName());
+ }
+ }
+
+ assign.getRoles().add(role);
+
+ // Set variable
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(details.getTargetVariable().getName());
+
+ assign.setVariable(var);
+
+ org.scribble.expression.xpath.model.XPathExpression expr=
+ new org.scribble.expression.xpath.model.XPathExpression();
+
+ if (details.getSourceExpression() != null) {
+ expr.setQuery(details.getSourceExpression());
+ } else if (details.getSourceVariable() != null) {
+ expr.setQuery("cdl:getVariable('"+details.getSourceVariable().getName()+"','','')");
+ }
+
+ assign.setExpression(expr);
+
+ ret.getContents().add(assign);
+
+ if (details.getCauseException() != null &&
+ details.getCauseException().trim().length() > 0) {
+ Raise raise=new Raise();
+
+ Role raiseRole=new Role();
+ raiseRole.setName(role.getName());
+ raise.getRoles().add(raiseRole);
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(details.getCauseException()));
+ raise.setType(tref);
+
+ exceptions.add(raise);
+ }
+ }
+
+ if (exceptions.size() > 0) {
+ ret.getContents().addAll(exceptions);
+ }
+
+ if (ret.getContents().size() > 1) {
+ return(ret);
+ } else if (ret.getContents().size() == 1) {
+ return(ret.getContents().get(0));
+ } else {
+ return(null);
+ }
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,781 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.Interaction;
+import org.pi4soa.cdl.interfaces.InterfaceDefinition;
+import org.pi4soa.cdl.interfaces.InterfaceVisitor;
+import org.pi4soa.cdl.interfaces.MessageDefinition;
+import org.pi4soa.cdl.interfaces.OperationDefinition;
+import org.pi4soa.cdl.interfaces.RoleTypeDefinition;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.pi4soa.cdl.util.PackageUtil;
+import org.pi4soa.common.util.NamesUtil;
+import org.pi4soa.common.xml.XMLUtils;
+import org.scribble.model.*;
+import org.jboss.savara.contract.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.expression.xpath.model.*;
+
+public class ConversationConverterRuleImpl implements ConverterRule {
+
+ private static final String CONVERSATION_TYPE = "conversationType";
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == Conversation.class &&
+ cdlType instanceof Choreography);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ Conversation ret=new Conversation();
+ Choreography choreo=(Choreography)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(choreo));
+
+ context.pushScope();
+
+ LocatedName modelName=new LocatedName();
+ modelName.setName(choreo.getName());
+
+ ret.setLocatedName(modelName);
+
+ // Define roles
+ defineRoles(context, choreo, ret);
+
+ // Check if root, then need to project other sibling choreos
+ if (choreo.getRoot() == Boolean.TRUE) {
+
+ java.util.Iterator<Choreography> citer=
+ choreo.getPackage().getChoreographies().iterator();
+
+ while (citer.hasNext()) {
+ Choreography subchoreo=citer.next();
+
+ if (subchoreo != choreo) {
+ Conversation subconv=(Conversation)
+ convert(context, Conversation.class, subchoreo);
+
+ ret.getBlock().getContents().add(subconv);
+
+ context.addConversation(subconv);
+ }
+
+ for (int i=0; i < subchoreo.getFinalizers().size(); i++) {
+ FinalizerHandler finalizer=subchoreo.getFinalizers().get(i);
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ Conversation.class, finalizer);
+
+ if (rule != null) {
+
+ Conversation subconv=(Conversation)
+ rule.convert(context, Conversation.class, finalizer);
+
+ ret.getBlock().getContents().add(subconv);
+
+ context.addConversation(subconv);
+ }
+ }
+ }
+ }
+
+ // Process any sub-choreographies
+ java.util.Iterator<Choreography> citer=
+ choreo.getEnclosedChoreographies().iterator();
+
+ while (citer.hasNext()) {
+ Choreography subchoreo=citer.next();
+
+ Conversation subconv=(Conversation)
+ convert(context, Conversation.class, subchoreo);
+
+ ret.getBlock().getContents().add(subconv);
+
+ context.addConversation(subconv);
+
+ for (int i=0; i < subchoreo.getFinalizers().size(); i++) {
+ FinalizerHandler finalizer=subchoreo.getFinalizers().get(i);
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ Conversation.class, finalizer);
+
+ if (rule != null) {
+
+ subconv = (Conversation)
+ rule.convert(context, Conversation.class, finalizer);
+
+ ret.getBlock().getContents().add(subconv);
+
+ context.addConversation(subconv);
+ }
+ }
+ }
+
+ // Convert variables
+ convertVariables(context, choreo, ret.getBlock());
+
+ // Define identities
+ convertIdentities(context, choreo, ret);
+
+ // Check if exception handlers have been defined
+ // and/or completion condition
+ if (NamesUtil.isSet(choreo.getCompletionCondition()) ||
+ (choreo.getExceptionHandler() != null &&
+ choreo.getExceptionHandler().getExceptionWorkUnits().size() > 0)) {
+
+ TryEscape te=new TryEscape();
+ ret.getBlock().getContents().add(te);
+
+ // Process all of the activities within the
+ // choreography
+ convertActivities(context, choreo.getActivities(),
+ te.getBlock());
+
+ for (int i=0; choreo.getExceptionHandler() != null &&
+ i < choreo.getExceptionHandler().
+ getExceptionWorkUnits().size(); i++) {
+ ExceptionWorkUnit ewu=choreo.getExceptionHandler().
+ getExceptionWorkUnits().get(i);
+
+ CatchBlock catchPath=new CatchBlock();
+
+ if (NamesUtil.isSet(ewu.getExceptionType())) {
+ TypeReference ref=new TypeReference();
+ ref.setLocalpart(XMLUtils.getLocalname(ewu.getExceptionType()));
+ ref.setNamespace(CDLTypeUtil.getNamespace(
+ ewu.getExceptionType(), choreo));
+
+ catchPath.setType(ref);
+ }
+
+ te.getEscapeBlocks().add(catchPath);
+
+ convertActivities(context, ewu.getActivities(),
+ catchPath);
+ }
+
+ if (NamesUtil.isSet(choreo.getCompletionCondition())) {
+ InterruptBlock interrupt=new InterruptBlock();
+
+ te.getEscapeBlocks().add(interrupt);
+
+ // Set expression from completion condition
+ // using xpath
+ XPathExpression exp=new XPathExpression();
+
+ exp.setQuery(choreo.getCompletionCondition());
+
+ interrupt.setExpression(exp);
+
+ // No activities
+ }
+ } else {
+
+ // Process all of the activities within the
+ // choreography
+ convertActivities(context, choreo.getActivities(), ret.getBlock());
+ }
+
+ // Transfer sub-conversations to end of block
+ if (ret.getBlock().getContents().size() > 0) {
+ org.scribble.model.Activity lastAct=
+ ret.getBlock().getContents().get(ret.getBlock().getContents().size()-1);
+ int pos=0;
+ while (ret.getBlock().getContents().get(pos) != lastAct) {
+ if (ret.getBlock().getContents().get(pos) instanceof Conversation) {
+ Conversation c=(Conversation)ret.getBlock().getContents().get(pos);
+
+ ret.getBlock().getContents().remove(pos);
+ ret.getBlock().getContents().add(c);
+
+ context.removeConversation(c);
+ } else {
+ pos++;
+ }
+ }
+ }
+
+ context.popScope();
+
+ return(ret);
+ }
+
+
+ protected void defineRoles(ConverterContext context,
+ final Choreography choreo, Conversation conv) {
+
+ org.pi4soa.cdl.interfaces.InterfaceDeriver intfDeriver=
+ org.pi4soa.cdl.interfaces.InterfaceFactory.getInterfaceDeriver();
+
+ final java.util.List<ParticipantType> partTypes=new java.util.Vector<ParticipantType>();
+ final java.util.List<Participant> partInstances=new java.util.Vector<Participant>();
+
+ choreo.visit(new DefaultCDLVisitor() {
+
+ public void interaction(Interaction interaction) {
+
+ if (interaction.getEnclosingChoreography() != choreo) {
+ return;
+ }
+
+ if (interaction.getFromParticipant() != null) {
+ if (partInstances.contains(interaction.getFromParticipant()) == false) {
+ partInstances.add(interaction.getFromParticipant());
+ }
+ } else {
+ ParticipantType ptype=
+ org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+ interaction.getFromRoleType());
+
+ if (ptype != null &&
+ partTypes.contains(ptype) == false) {
+ partTypes.add(ptype);
+ }
+ }
+
+ if (interaction.getToParticipant() != null) {
+ if (partInstances.contains(interaction.getToParticipant()) == false) {
+ partInstances.add(interaction.getToParticipant());
+ }
+ } else {
+ ParticipantType ptype=
+ org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+ interaction.getToRoleType());
+
+ if (ptype != null &&
+ partTypes.contains(ptype) == false) {
+ partTypes.add(ptype);
+ }
+ }
+ }
+ });
+
+ // Define roles
+ java.util.Iterator<Participant> piter=partInstances.iterator();
+
+ RoleList roleList=null;
+
+ while (piter.hasNext()) {
+ Role role=new Role();
+ Participant pinst=piter.next();
+ role.setName(pinst.getName());
+
+ if (roleList == null) {
+ roleList = new RoleList();
+ conv.getBlock().getContents().add(roleList);
+ }
+
+ roleList.getRoles().add(role);
+
+ context.setState(role.getName(), role);
+
+ registerRole(context, choreo, conv, roleList, role, pinst);
+
+ // Setup interfaces
+ for (int i=0; i < pinst.getRoleTypes().size(); i++) {
+ Contract contract=null;
+
+ if (role.getAnnotations().containsKey(Contract.class.getName())) {
+ contract = (Contract)role.getAnnotations().get(
+ Contract.class.getName());
+ } else {
+ contract = new Contract();
+
+ java.util.List<?> ptypes=
+ PackageUtil.getParticipantsForRoleTypes(choreo.getPackage(),
+ pinst.getRoleTypes());
+
+ if (ptypes.size() == 1) {
+ ParticipantType pt=(ParticipantType)ptypes.get(0);
+
+ contract.setName(XMLUtils.getLocalname(pt.getName()));
+ contract.setNamespace(CDLTypeUtil.getNamespace(pt.getName(), pt));
+ } else {
+
+ logger.warning("Could not find single participant type for participant instance '"+
+ pinst.getName()+"'");
+ contract.setName(XMLUtils.getLocalname(pinst.getName()));
+ contract.setNamespace(CDLTypeUtil.getNamespace(pinst.getName(), pinst));
+ }
+
+ // Setup namespace to prefix mappings
+ java.util.List<NameSpace> nspaces=pinst.getPackage().getTypeDefinitions().getNameSpaces();
+
+ for (int j=0; j < nspaces.size(); j++) {
+ org.jboss.savara.contract.model.Namespace ns=
+ new org.jboss.savara.contract.model.Namespace();
+
+ ns.setPrefix(nspaces.get(j).getPrefix());
+ ns.setURI(nspaces.get(j).getURI());
+ ns.setSchemaLocation(nspaces.get(j).getSchemaLocation());
+
+ contract.getNamespaces().add(ns);
+ }
+
+ role.getAnnotations().put(Contract.class.getName(),
+ contract);
+ }
+
+ setupInterfaces((org.pi4soa.cdl.RoleType)pinst.getRoleTypes().get(i),
+ contract, intfDeriver);
+ }
+ }
+
+ java.util.Iterator<ParticipantType> ptiter=partTypes.iterator();
+
+ if (choreo.getRoot() != Boolean.TRUE) {
+ roleList = null;
+ } else {
+ ptiter = choreo.getPackage().getTypeDefinitions().getParticipantTypes().iterator();
+ }
+
+ while (ptiter.hasNext()) {
+ Role role=new Role();
+ ParticipantType ptype=ptiter.next();
+ role.setName(XMLUtils.getLocalname(ptype.getName()));
+
+ if (roleList == null) {
+ roleList = new RoleList();
+
+ roleList.setOpen(choreo.getRoot() != Boolean.TRUE);
+
+ conv.getBlock().getContents().add(roleList);
+ }
+
+ roleList.getRoles().add(role);
+
+ context.setState(role.getName(), role);
+
+ if (choreo.getRoot() == Boolean.TRUE) {
+ registerRole(context, choreo, conv, roleList, role, ptype);
+
+ // Setup interfaces
+ for (int i=0; i < ptype.getRoleTypes().size(); i++) {
+ Contract contract=null;
+
+ if (role.getAnnotations().containsKey(Contract.class.getName())) {
+ contract = (Contract)role.getAnnotations().get(
+ Contract.class.getName());
+ } else {
+ contract = new Contract();
+
+ contract.setName(XMLUtils.getLocalname(ptype.getName()));
+ contract.setNamespace(CDLTypeUtil.getNamespace(ptype.getName(), ptype, true));
+
+ // Setup namespace to prefix mappings
+ java.util.List<NameSpace> nspaces=ptype.getPackage().getTypeDefinitions().getNameSpaces();
+
+ for (int j=0; j < nspaces.size(); j++) {
+ org.jboss.savara.contract.model.Namespace ns=
+ new org.jboss.savara.contract.model.Namespace();
+
+ ns.setPrefix(nspaces.get(j).getPrefix());
+ ns.setURI(nspaces.get(j).getURI());
+ ns.setSchemaLocation(nspaces.get(j).getSchemaLocation());
+
+ contract.getNamespaces().add(ns);
+ }
+
+ role.getAnnotations().put(Contract.class.getName(),
+ contract);
+ }
+
+ setupInterfaces((org.pi4soa.cdl.RoleType)ptype.getRoleTypes().get(i),
+ contract, intfDeriver);
+ }
+ }
+ }
+ }
+
+ protected void setupInterfaces(org.pi4soa.cdl.RoleType roleType, Contract contract,
+ org.pi4soa.cdl.interfaces.InterfaceDeriver intfDeriver) {
+
+ org.pi4soa.cdl.interfaces.RoleTypeDefinition rtd=
+ intfDeriver.getRoleTypeDefinition(roleType);
+
+ InterfaceVisitorImpl iv=new InterfaceVisitorImpl(contract);
+
+ rtd.visit(iv);
+ }
+
+ protected void convertVariables(ConverterContext context,
+ Choreography choreo, Block block) {
+
+ java.util.List<org.pi4soa.cdl.Variable> vars=
+ choreo.getVariableDefinitions();
+
+ for (int i=0; i < vars.size(); i++) {
+ org.pi4soa.cdl.Variable var=(org.pi4soa.cdl.Variable)vars.get(i);
+
+ if (var.getType() instanceof InformationType) {
+ java.util.List<RoleType> roleTypes=var.getRoleTypes();
+
+ if (roleTypes.size() == 0) {
+ roleTypes = choreo.getPackage().getTypeDefinitions().getRoleTypes();
+ }
+
+ VariableList vlist=new VariableList();
+ TypeReference ref=new TypeReference();
+
+ String qname=((InformationType)var.getType()).getElementName();
+
+ if (NamesUtil.isSet(qname)==false) {
+ qname=((InformationType)var.getType()).getTypeName();
+ }
+
+ ref.setNamespace(CDLTypeUtil.getNamespace(qname, var));
+ ref.setLocalpart(XMLUtils.getLocalname(qname));
+
+ vlist.setType(ref);
+
+ /* TODO: See if variables should be located?
+ for (int j=0; j < roleTypes.size(); j++) {
+ org.scribble.conversation.model.Variable newVar=
+ new org.scribble.conversation.model.Variable();
+
+ newVar.setName(var.getName());
+ }
+ */
+
+ org.scribble.conversation.model.Variable newVar=
+ new org.scribble.conversation.model.Variable();
+
+ newVar.setName(var.getName());
+
+ vlist.getVariables().add(newVar);
+
+ block.getContents().add(vlist);
+
+ } else if (var.getType() instanceof ChannelType) {
+
+ // TODO: Only convert if channel is explicitly defined
+
+
+ }
+ }
+ }
+
+ protected void convertActivities(ConverterContext context,
+ java.util.List<org.pi4soa.cdl.Activity> acts, Block block) {
+
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ acts.iterator();
+
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+
+ if (activity instanceof Block) {
+ block.getContents().addAll(((Block)activity).getContents());
+ } else {
+ block.getContents().add(activity);
+ }
+ }
+ }
+ }
+ }
+
+ protected void convertIdentities(ConverterContext context,
+ Choreography choreo, Conversation conv) {
+
+ // Define identities
+ java.util.List<org.pi4soa.cdl.Variable> vars=
+ choreo.getVariableDefinitions();
+ java.util.List<org.scribble.conversation.model.Identity> ids=
+ new java.util.Vector<org.scribble.conversation.model.Identity>();
+
+ for (int i=0; i < vars.size(); i++) {
+ if (vars.get(i).getType() instanceof org.pi4soa.cdl.ChannelType) {
+ org.pi4soa.cdl.ChannelType ctype=
+ (org.pi4soa.cdl.ChannelType)vars.get(i).getType();
+
+ java.util.Iterator<org.pi4soa.cdl.Identity> cids=
+ ctype.getIdentities().iterator();
+
+ while (cids.hasNext()) {
+ org.pi4soa.cdl.Identity cid=cids.next();
+ org.scribble.conversation.model.Identity id=
+ new org.scribble.conversation.model.Identity();
+
+ if (cid.getType() == KeyType.ASSOCIATION) {
+ id.setIdentityType(IdentityType.Association);
+ } else if (cid.getType() == KeyType.DERIVED) {
+ id.setIdentityType(IdentityType.Derived);
+ } else {
+ id.setIdentityType(IdentityType.Primary);
+ }
+
+ for (int j=0; j < cid.getTokens().size(); j++) {
+ id.getNames().add(cid.getTokens().get(j).getName());
+ }
+
+ if (ids.contains(id) == false) {
+ ids.add(id);
+ }
+ }
+ }
+ }
+
+ conv.getIdentities().addAll(ids);
+ }
+
+ private void registerRole(ConverterContext context,
+ Choreography choreo,
+ Conversation conv, RoleList roleList,
+ Role role, CDLType cdlType) {
+
+ if (cdlType.getSemanticAnnotations().size() > 0) {
+ java.util.Iterator<SemanticAnnotation> iter=
+ cdlType.getSemanticAnnotations().iterator();
+
+ while (iter.hasNext()) {
+ SemanticAnnotation annotation=iter.next();
+
+ if (annotation.getName() != null &&
+ annotation.getName().equals(CONVERSATION_TYPE)) {
+ String convType=annotation.getAnnotation();
+
+ if (convType != null) {
+ int index=convType.indexOf('@');
+
+ if (index != -1) {
+ ConformanceReference ref=
+ new ConformanceReference(ConversationNotation.NOTATION_CODE);
+
+ ref.setLocatedRole(convType.substring(index+1));
+
+ String mainpart=convType.substring(0, index);
+
+ index = mainpart.lastIndexOf(".");
+
+ String namespace="";
+ String localpart=mainpart;
+
+ if (index != -1) {
+ namespace=mainpart.substring(0, index);
+ localpart=mainpart.substring(index+1);
+ }
+
+ String[] elems=localpart.split("\\$");
+ if (elems.length > 1) {
+ localpart = elems[0];
+
+ for (int i=1; i < elems.length; i++) {
+ ref.getSubDefinitionPath().addPathElement(elems[i]);
+ }
+ }
+
+ ref.setNamespace(namespace);
+ ref.setLocalpart(localpart);
+
+ ref.setFullyQualified(true);
+
+ conv.getConformsTo().add(ref);
+
+ ModelReference sref=context.getSource();
+
+ // If not the root choreography, then
+ // identify the sub definition path
+ // in the source reference
+ if (choreo.getRoot() != Boolean.TRUE) {
+ sref = new ModelReference(sref);
+ Choreography sub=choreo;
+
+ while (sub != null && sub.getRoot() != Boolean.TRUE) {
+ sref.getSubDefinitionPath().addPathElement(0, sub.getName());
+
+ sub = sub.getParent().getEnclosingChoreography();
+ }
+ }
+
+ // Establish 'conforms to' dependency
+ // between source (which could be a
+ // sub definition) and the identified
+ // conversation type
+
+ // GPB: TO REMOVE dm.recordDependency(sref, ref,
+ // DependencyType.ConformsTo);
+
+ } else {
+ logger.warning("Conversation type '"+
+ convType+"' does not " +
+ "contain '@' located role separator");
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+
+ public static class InterfaceVisitorImpl implements InterfaceVisitor,
+ java.io.Serializable {
+
+ private static final long serialVersionUID = 4068744630125720449L;
+
+ private org.jboss.savara.contract.model.Contract m_contract=null;
+ private org.jboss.savara.contract.model.Interface m_currentInterface=null;
+ private org.jboss.savara.contract.model.MessageExchangePattern m_currentMEP=null;
+
+ public InterfaceVisitorImpl(Contract contract) {
+ m_contract = contract;
+ }
+
+ public Contract getContract() {
+ return(m_contract);
+ }
+
+ public void interfaceEnd(InterfaceDefinition defn) {
+ m_currentInterface = null;
+ }
+
+ public void interfaceStart(InterfaceDefinition defn) {
+ m_currentInterface = new org.jboss.savara.contract.model.Interface();
+
+ m_currentInterface.setNamespace(defn.getNamespace());
+
+ if (defn.getInterfaceName() != null &&
+ defn.getInterfaceName().trim().length() > 0) {
+ m_currentInterface.setName(defn.getInterfaceName());
+ } else {
+ m_currentInterface.setName(defn.getBehaviorName());
+ }
+
+ m_contract.getInterfaces().add(m_currentInterface);
+ }
+
+ public void message(MessageDefinition defn) {
+
+ if (defn.getClassification() == MessageDefinition.INPUT) {
+ m_currentMEP.getTypes().add(createType(defn));
+
+ } else if (m_currentMEP instanceof RequestResponseMEP) {
+ RequestResponseMEP mep=(RequestResponseMEP)m_currentMEP;
+
+ if (defn.getClassification() == MessageDefinition.OUTPUT) {
+ mep.getResponseTypes().add(createType(defn));
+
+ } else if (defn.getClassification() == MessageDefinition.OUTFAULT) {
+ FaultDetails fault=new FaultDetails();
+
+ fault.setName(defn.getFaultName());
+ fault.setNamespace(defn.getFaultNamespace());
+
+ fault.getTypes().add(createType(defn));
+
+ mep.getFaultDetails().add(fault);
+ }
+ }
+ }
+
+ protected Type createType(MessageDefinition defn) {
+ Type ret=new Type();
+ TypeDefinition td=new TypeDefinition();
+ ret.getTypeDefinitions().add(td);
+
+ if (defn.getElement() != null && defn.getElement().trim().length() > 0) {
+ td.setName(defn.getElement());
+
+ if (defn.getElementNamespace() != null) {
+ td.setNamespace(defn.getElementNamespace());
+ }
+
+ td.setTypeSystem(TypeDefinition.XSD_ELEMENT);
+
+ } else if (defn.getType() != null && defn.getType().trim().length() > 0) {
+ td.setName(defn.getType());
+
+ if (defn.getTypeNamespace() != null) {
+ td.setNamespace(defn.getTypeNamespace());
+ }
+
+ td.setTypeSystem(TypeDefinition.XSD_TYPE);
+ }
+
+ ret.setName(td.getName());
+
+ return(ret);
+ }
+
+ public void operationEnd(OperationDefinition defn) {
+ m_currentMEP = null;
+ }
+
+ public void operationStart(OperationDefinition defn) {
+ if (defn.getMessages().size() == 1 &&
+ ((MessageDefinition)defn.getMessages().get(0)).getClassification()
+ == MessageDefinition.INPUT) {
+ m_currentMEP = new OneWayRequestMEP();
+ } else {
+ m_currentMEP = new RequestResponseMEP();
+ }
+
+ m_currentMEP.setOperation(defn.getOperationName());
+
+ m_currentInterface.getMessageExchangePatterns().add(m_currentMEP);
+ }
+
+ public void roleTypeEnd(RoleTypeDefinition defn) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void roleTypeStart(RoleTypeDefinition defn) {
+ // TODO Auto-generated method stub
+
+ }
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,698 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.Interaction;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.expression.xpath.model.XPathExpression;
+import org.pi4soa.cdl.util.*;
+import org.pi4soa.common.util.NamesUtil;
+import org.pi4soa.common.xml.NameSpaceUtil;
+import org.pi4soa.common.xml.XMLUtils;
+
+public class ConversationInteractionConverterRuleImpl implements ConverterRule {
+
+ private static final String INTERFACE_NAME = "interfaceName";
+ private static final String FAULT_NAME = "faultName";
+ private static final String MESSAGE_TYPE_LOCALPART = "messageTypeLocalPart";
+ private static final String MESSAGE_TYPE_NAMESPACE = "messageTypeNameSpace";
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Interaction);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.model.Block ret=new org.scribble.model.Block();
+ org.pi4soa.cdl.Interaction cdl=
+ (org.pi4soa.cdl.Interaction)cdlType;
+ Role fromRole=null;
+ Role toRole=null;
+
+ if (cdl.getFromParticipant() != null) {
+ fromRole = (Role)
+ context.getState(XMLUtils.getLocalname(cdl.getFromParticipant().getName()));
+
+ if (fromRole == null) {
+ logger.severe("Failed to get 'from' role '"+XMLUtils.getLocalname(cdl.getFromParticipant().getName())+"'");
+ }
+ } else if (cdl.getFromRoleType() != null) {
+ ParticipantType ptype=
+ PackageUtil.getParticipantForRoleType(cdl.getFromRoleType());
+
+ fromRole = (Role)
+ context.getState(XMLUtils.getLocalname(ptype.getName()));
+
+ if (fromRole == null) {
+ logger.severe("Failed to get 'from' role '"+XMLUtils.getLocalname(ptype.getName())+"'");
+ }
+ }
+
+ if (cdl.getToParticipant() != null) {
+ toRole = (Role)
+ context.getState(XMLUtils.getLocalname(cdl.getToParticipant().getName()));
+
+ if (toRole == null) {
+ logger.severe("Failed to get 'to' role '"+XMLUtils.getLocalname(cdl.getFromParticipant().getName())+"'");
+ }
+ } else if (cdl.getToRoleType() != null) {
+ ParticipantType ptype=
+ PackageUtil.getParticipantForRoleType(cdl.getToRoleType());
+
+ toRole = (Role)
+ context.getState(XMLUtils.getLocalname(ptype.getName()));
+
+ if (toRole == null) {
+ logger.severe("Failed to get 'to' role '"+XMLUtils.getLocalname(ptype.getName())+"'");
+ }
+ }
+
+ // Determine if interaction may result in
+ // a timeout
+ Block block=ret;
+
+ if (NamesUtil.isSet(cdl.getTimeToComplete())) {
+ TryEscape te=new TryEscape();
+
+ ret.getContents().add(te);
+
+ block = te.getBlock();
+
+ InterruptBlock interrupt=new InterruptBlock();
+
+ te.getEscapeBlocks().add(interrupt);
+
+ // Set expression from 'time to complete'
+ // using xpath
+ XPathExpression exp=new XPathExpression();
+
+ exp.setQuery("cdl:hasDurationPassed('"+
+ cdl.getTimeToComplete()+"')");
+
+ interrupt.setExpression(exp);
+
+ // Perform assignments associated with timeout
+ for (int i=0; i < cdl.getRecordDetails().size(); i++) {
+ org.pi4soa.cdl.RecordDetails rd=
+ cdl.getRecordDetails().get(i);
+
+ if (rd.getWhen() == WhenType.TIMEOUT) {
+
+ // TODO: Record variable - but which role??? May need to
+ // be part of the following conditions, so depends on
+ // whether the record details are in the from/to timeout record details
+
+ if (cdl.getTimeoutFromRoleTypeRecordDetails().contains(rd)) {
+
+ if (rd.getCauseException() != null &&
+ rd.getCauseException().trim().length() > 0) {
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(fromRole.getName()));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+ raise.setType(tref);
+
+ interrupt.getContents().add(raise);
+ }
+ }
+
+ if (cdl.getTimeoutToRoleTypeRecordDetails().contains(rd)) {
+
+ if (rd.getCauseException() != null &&
+ rd.getCauseException().trim().length() > 0) {
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(toRole.getName()));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+ raise.setType(tref);
+
+ interrupt.getContents().add(raise);
+ }
+ }
+ }
+ }
+ }
+
+ java.util.Iterator<ExchangeDetails> iter=
+ cdl.getExchangeDetails().iterator();
+ java.util.List<ConditionalBlock> cbs=
+ new java.util.Vector<ConditionalBlock>();
+
+ while (iter.hasNext()) {
+ ExchangeDetails details=iter.next();
+ ConditionalBlock cb=new ConditionalBlock();
+
+ // Convert 'before' send and receive record details
+ for (int i=0; i < details.getSendRecordDetails().size(); i++) {
+ RecordDetails rd=details.getSendRecordDetails().get(i);
+
+ if (rd.getWhen() == WhenType.BEFORE) {
+ String fromRoleName=(details.getAction() == ExchangeActionType.REQUEST?
+ fromRole.getName():toRole.getName());
+
+ // Define record expression
+ Assignment assign=new Assignment();
+
+ assign.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(rd));
+
+ // Set role
+ Role role=new Role(fromRoleName);
+
+ assign.getRoles().add(role);
+
+ // Set variable
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(rd.getTargetVariable().getName());
+
+ assign.setVariable(var);
+
+ org.scribble.expression.xpath.model.XPathExpression expr=
+ new org.scribble.expression.xpath.model.XPathExpression();
+
+ if (rd.getSourceExpression() != null) {
+ expr.setQuery(rd.getSourceExpression());
+ } else if (rd.getSourceVariable() != null) {
+ expr.setQuery("cdl:getVariable('"+rd.getSourceVariable().getName()+"','','')");
+ }
+
+ assign.setExpression(expr);
+
+ cb.getContents().add(assign);
+
+ // Check for cause exception
+ if (rd.getCauseException() != null &&
+ rd.getCauseException().trim().length() > 0) {
+
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(fromRoleName));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+ }
+ }
+
+ for (int i=0; i < details.getReceiveRecordDetails().size(); i++) {
+ RecordDetails rd=details.getReceiveRecordDetails().get(i);
+
+ if (rd.getWhen() == WhenType.BEFORE) {
+ String toRoleName=(details.getAction() == ExchangeActionType.REQUEST?
+ toRole.getName():fromRole.getName());
+
+ // Define record expression
+ Assignment assign=new Assignment();
+
+ assign.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(rd));
+
+ // Set role
+ Role role=new Role(toRoleName);
+
+ assign.getRoles().add(role);
+
+ // Set variable
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(rd.getTargetVariable().getName());
+
+ assign.setVariable(var);
+
+ org.scribble.expression.xpath.model.XPathExpression expr=
+ new org.scribble.expression.xpath.model.XPathExpression();
+
+ if (rd.getSourceExpression() != null) {
+ expr.setQuery(rd.getSourceExpression());
+ } else if (rd.getSourceVariable() != null) {
+ expr.setQuery("cdl:getVariable('"+rd.getSourceVariable().getName()+"','','')");
+ }
+
+ assign.setExpression(expr);
+
+ cb.getContents().add(assign);
+
+ // Check for cause exception
+ if (rd.getCauseException() != null &&
+ rd.getCauseException().trim().length() > 0) {
+
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(toRoleName));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+ }
+ }
+
+ // Convert the interaction
+ ConversationInteraction interaction=
+ new ConversationInteraction();
+
+ interaction.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(details));
+
+ // Check if interaction's channel has been explicitly defined
+ Object ch=context.getState(cdl.getChannelVariable().getName());
+
+ if (ch instanceof Channel) {
+ interaction.setChannel((Channel)ch);
+ }
+
+ // Define message signature
+ MessageSignature ms=new MessageSignature();
+ ms.setOperation(cdl.getOperation());
+
+ if (NamesUtil.isSet(details.getFaultName())) {
+ ms.getAnnotations().put(FAULT_NAME,
+ details.getFaultName());
+ }
+
+ interaction.setMessageSignature(ms);
+
+ // Define interaction message type
+ if (details.getType() instanceof InformationType) {
+ InformationType itype=(InformationType)details.getType();
+
+ TypeReference ref=ConverterUtil.getTypeReference(itype);
+
+ ms.getTypes().add(ref);
+
+ if (NamesUtil.isSet(itype.getTypeName())) {
+ String ns=CDLTypeUtil.getNamespace(itype.getTypeName(),
+ cdl);
+ String lp=XMLUtils.getLocalname(itype.getTypeName());
+
+ if (lp != null) {
+ ms.getAnnotations().put(MESSAGE_TYPE_LOCALPART,
+ lp);
+ }
+ if (ns != null) {
+ ms.getAnnotations().put(MESSAGE_TYPE_NAMESPACE,
+ ns);
+ }
+ } else if (NamesUtil.isSet(itype.getElementName())) {
+ String ns=CDLTypeUtil.getNamespace(itype.getElementName(),
+ cdl);
+ String lp=XMLUtils.getLocalname(itype.getElementName());
+
+ if (lp != null) {
+ ms.getAnnotations().put(MESSAGE_TYPE_LOCALPART,
+ lp);
+ }
+ if (ns != null) {
+ ms.getAnnotations().put(MESSAGE_TYPE_NAMESPACE,
+ ns);
+ }
+ }
+ }
+
+ cb.getContents().add(interaction);
+
+ // Set interface name
+ if (cdl.getToRoleType() != null) {
+ // TODO: Deal with interfaces that have multiple behaviours
+ interaction.getAnnotations().put(INTERFACE_NAME,
+ getInterfaceName(cdl));
+ }
+
+ if (details.getAction() == ExchangeActionType.REQUEST) {
+ interaction.setFromRole(fromRole);
+ interaction.setToRole(toRole);
+
+ if (details.getSendVariable() != null) {
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(details.getSendVariable().getName());
+ interaction.setFromVariable(var);
+ }
+
+ if (details.getReceiveVariable() != null) {
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(details.getReceiveVariable().getName());
+ interaction.setToVariable(var);
+ }
+
+ // Check if request has response/fault exchanges
+ java.util.List<ExchangeDetails> resps=
+ InteractionUtil.getResponseExchangeDetails(details);
+
+ if (resps != null && resps.size() > 0) {
+ interaction.setRequestLabel(getLabel(details));
+ }
+
+ // Check if fault thrown
+ if (details.getSendCauseException() != null &&
+ details.getSendCauseException().trim().length() > 0) {
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(fromRole.getName()));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(details.getSendCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+
+ if (details.getReceiveCauseException() != null &&
+ details.getReceiveCauseException().trim().length() > 0) {
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(toRole.getName()));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(details.getReceiveCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+ } else {
+ interaction.setFromRole(toRole);
+ interaction.setToRole(fromRole);
+
+ if (details.getReceiveVariable() != null) {
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(details.getReceiveVariable().getName());
+ interaction.setFromVariable(var);
+ }
+
+ if (details.getSendVariable() != null) {
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(details.getSendVariable().getName());
+ interaction.setToVariable(var);
+ }
+
+ if (details.getAction() == ExchangeActionType.RESPOND) {
+ interaction.setReplyToLabel(getLabel(details));
+ }
+
+ // Check if fault thrown
+ if (details.getSendCauseException() != null &&
+ details.getSendCauseException().trim().length() > 0) {
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(toRole.getName()));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(details.getSendCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+
+ if (details.getReceiveCauseException() != null &&
+ details.getReceiveCauseException().trim().length() > 0) {
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(fromRole.getName()));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(details.getReceiveCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+ }
+
+ // Convert 'after' send and receive record details
+ for (int i=0; i < details.getSendRecordDetails().size(); i++) {
+ RecordDetails rd=details.getSendRecordDetails().get(i);
+
+ if (rd.getWhen() == WhenType.AFTER) {
+ String fromRoleName=(details.getAction() == ExchangeActionType.REQUEST?
+ fromRole.getName():toRole.getName());
+
+ // Define record expression
+ Assignment assign=new Assignment();
+
+ assign.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(rd));
+
+ // Set role
+ Role role=new Role(fromRoleName);
+
+ assign.getRoles().add(role);
+
+ // Set variable
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(rd.getTargetVariable().getName());
+
+ assign.setVariable(var);
+
+ org.scribble.expression.xpath.model.XPathExpression expr=
+ new org.scribble.expression.xpath.model.XPathExpression();
+
+ if (rd.getSourceExpression() != null) {
+ expr.setQuery(rd.getSourceExpression());
+ } else if (rd.getSourceVariable() != null) {
+ expr.setQuery("cdl:getVariable('"+rd.getSourceVariable().getName()+"','','')");
+ }
+
+ assign.setExpression(expr);
+
+ cb.getContents().add(assign);
+
+ // Check for cause exception
+ if (rd.getCauseException() != null &&
+ rd.getCauseException().trim().length() > 0) {
+
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(fromRoleName));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+ }
+ }
+
+ for (int i=0; i < details.getReceiveRecordDetails().size(); i++) {
+ RecordDetails rd=details.getReceiveRecordDetails().get(i);
+
+ if (rd.getWhen() == WhenType.AFTER) {
+ String toRoleName=(details.getAction() == ExchangeActionType.REQUEST?
+ toRole.getName():fromRole.getName());
+
+ // Define record expression
+ Assignment assign=new Assignment();
+
+ assign.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(rd));
+
+ // Set role
+ Role role=new Role(toRoleName);
+
+ assign.getRoles().add(role);
+
+ // Set variable
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+ var.setName(rd.getTargetVariable().getName());
+
+ assign.setVariable(var);
+
+ // If target variable is a channel, then make explicit
+ if (rd.getTargetVariable().getType() instanceof ChannelType) {
+ Object state=context.getState(rd.getTargetVariable().getName());
+
+ if (state == null) {
+ Channel newch=new Channel();
+ newch.setName(rd.getTargetVariable().getName());
+
+ context.setState(newch.getName(), newch);
+
+ //
+ }
+ }
+
+ // Convert source expression
+ org.scribble.expression.xpath.model.XPathExpression expr=
+ new org.scribble.expression.xpath.model.XPathExpression();
+
+ if (rd.getSourceExpression() != null) {
+ expr.setQuery(rd.getSourceExpression());
+ } else if (rd.getSourceVariable() != null) {
+ expr.setQuery("cdl:getVariable('"+rd.getSourceVariable().getName()+"','','')");
+ }
+
+ assign.setExpression(expr);
+
+ cb.getContents().add(assign);
+
+ // Check for cause exception
+ if (rd.getCauseException() != null &&
+ rd.getCauseException().trim().length() > 0) {
+
+ Raise raise=new Raise();
+ raise.getRoles().add(new Role(toRoleName));
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+ raise.setType(tref);
+
+ cb.getContents().add(raise);
+ }
+ }
+ }
+
+ cbs.add(cb);
+ }
+
+ if (cbs.size() > 2) {
+ block.getContents().addAll(cbs.remove(0).getContents());
+
+ If choice=new If();
+
+ choice.getRoles().add(new Role(toRole.getName()));
+
+ for (int i=0; i < cbs.size(); i++) {
+ ConditionalBlock cb=cbs.get(i);
+
+ choice.getConditionalBlocks().add(cb);
+ }
+
+ block.getContents().add(choice);
+ } else {
+ for (int i=0; i < cbs.size(); i++) {
+ ConditionalBlock cb=cbs.get(i);
+ block.getContents().addAll(cb.getContents());
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method creates a label appropriate for the request
+ * response correlation associated with the supplied exchange.
+ *
+ * @param details The exchange
+ * @return The label
+ */
+ protected String getLabel(ExchangeDetails details) {
+ String ret=null;
+
+ if (details.getInteraction() != null) {
+ ret = details.getInteraction().getOperation();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the interface name associated with the
+ * supplied role type.
+ *
+ * @param interaction The interaction
+ * @return The interface name
+ */
+ protected String getInterfaceName(org.pi4soa.cdl.Interaction interaction) {
+ String ret=null;
+
+ if (interaction != null) {
+ String intfName=getInterface(interaction);
+
+ String ns=CDLTypeUtil.getNamespace(intfName, interaction, true);
+ String lp=XMLUtils.getLocalname(intfName);
+
+ ret = NameSpaceUtil.getFullyQualifiedName(ns, lp);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the interaction's interface.
+ *
+ * @param interaction The interaction
+ * @return The interface
+ */
+ public static String getInterface(Interaction interaction) {
+ String ret=null;
+
+ if (interaction != null &&
+ interaction.getChannelVariable() != null &&
+ interaction.getChannelVariable().getType() instanceof
+ ChannelType) {
+ ChannelType ctype=(ChannelType)
+ interaction.getChannelVariable().getType();
+
+ if (ctype.getBehavior() != null) {
+ ret = ctype.getBehavior().getInterface();
+
+ if (NamesUtil.isSet(ret)==false) {
+ ret = ctype.getBehavior().getName();
+ }
+ } else if (ctype.getRoleType() != null) {
+
+ // Attempt to find default behavior
+ org.pi4soa.cdl.Behavior behavior=
+ ctype.getRoleType().getBehavior(null);
+
+ if (behavior != null) {
+ ret = behavior.getInterface();
+
+ if (NamesUtil.isSet(ret)==false) {
+ ret = behavior.getName();
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationModelConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationModelConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationModelConverterRuleImpl.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 31 Jul 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class ConversationModelConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == ConversationModel.class &&
+ cdlType instanceof org.pi4soa.cdl.Package);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ ConversationModel ret=new ConversationModel();
+ org.pi4soa.cdl.Package cdlpack=(org.pi4soa.cdl.Package)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdlpack));
+
+ ret.setNamespace(getNamespace(cdlpack));
+
+ // Convert token locators
+ java.util.Iterator<TokenLocator> locators=
+ cdlpack.getTypeDefinitions().getTokenLocators().iterator();
+
+ while (locators.hasNext()) {
+ TokenLocator locator=locators.next();
+
+ IdentityLocator idLocator=new IdentityLocator();
+ idLocator.setLocator(locator.getToken().getName(),
+ locator.getQuery());
+
+ TypeReference typeRef=ConverterUtil.getTypeReference(locator.getInformationType());
+ idLocator.setType(typeRef);
+
+ ret.getIdentityLocators().add(idLocator);
+ }
+
+ // Convert root choreography
+ java.util.Iterator<org.pi4soa.cdl.Choreography> iter=
+ cdlpack.getChoreographies().iterator();
+ org.pi4soa.cdl.Choreography choreo=null;
+
+ while (choreo == null && iter.hasNext()) {
+ choreo = iter.next();
+
+ if (choreo.getRoot() != Boolean.TRUE) {
+ choreo = null;
+ }
+ }
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(Conversation.class,
+ choreo);
+
+ if (rule != null) {
+ ret.setConversation((Conversation)rule.convert(context,
+ Conversation.class, choreo));
+ } else {
+ logger.severe("Failed to find conversation conversion rule");
+ }
+
+ // Clear the inner definition for any Compose activities
+ // The inner definitions are temporarily established to
+ // help internal analysis, e.g. to determine initiator
+ // roles
+ for (int i=0; i < context.getComposeActivities().size(); i++) {
+ // Save parent
+ Definition defn=context.getComposeActivities().get(i).getInlineDefinition();
+ ModelObject parent=defn.getParent();
+
+ context.getComposeActivities().get(i).setInlineDefinition(null);
+
+ // Re-establish parent
+ defn.setParent(parent);
+ }
+
+ return(ret);
+ }
+
+
+ /**
+ * This method generates a namespace associated with
+ * the supplied CDL package.
+ *
+ * @param cdlpack The choreography package
+ * @return The namespace
+ */
+ protected static org.scribble.model.Namespace getNamespace(
+ org.pi4soa.cdl.Package cdlpack) {
+ org.scribble.model.Namespace ret=new org.scribble.model.Namespace();
+
+ String ns=cdlpack.getTargetNamespace()+"/"+cdlpack.getName();
+
+ if (ns.startsWith("http://")) {
+ ns = ns.substring(7);
+ }
+
+ if (ns.startsWith("www.")) {
+ ns = ns.substring(4);
+ }
+
+ java.util.StringTokenizer st=new java.util.StringTokenizer(ns, "/");
+ boolean f_first=true;
+ String namespace=null;
+
+ while (st.hasMoreTokens()) {
+ String token=st.nextToken();
+
+ if (f_first) {
+ java.util.StringTokenizer innerst=
+ new java.util.StringTokenizer(token, ".");
+ while (innerst.hasMoreTokens()) {
+ if (namespace == null) {
+ namespace = innerst.nextToken();
+ } else {
+ namespace = innerst.nextToken()+"."+namespace;
+ }
+ }
+
+ f_first = false;
+ } else {
+ namespace += "."+token;
+ }
+ }
+
+ if (namespace != null) {
+ ret.setName(namespace.toLowerCase());
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterContext.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterContext.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterContext.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public interface ConverterContext {
+
+ /**
+ * This method returns the source model reference.
+ *
+ * @return The source model reference
+ */
+ public ModelReference getSource();
+
+ /**
+ * This method returns the declaration associated
+ * with the supplied name.
+ *
+ * @param name The name
+ * @return The declaration, or null if not found
+ */
+ public Object getState(String name);
+
+ /**
+ * This method sets the declaration associated with
+ * the supplied name.
+ *
+ * @param name The name
+ * @param decl The declaration
+ */
+ public void setState(String name, Object decl);
+
+ /**
+ * This method pushes the scope, to clear the current
+ * state associated with a parent scope.
+ */
+ public void pushScope();
+
+ /**
+ * This method pops the scope associated with a parent
+ * conversation.
+ *
+ */
+ public void popScope();
+
+ /**
+ * This method pushes the current state onto a stack,
+ * to create a local scope where further roles or
+ * variables may be declared.
+ */
+ public void pushState();
+
+ /**
+ * This method pops a previous state from the stack
+ * to clear any local declarations made within a
+ * local scope as part of a conversation definition.
+ */
+ public void popState();
+
+ /**
+ * This method adds a conversation to the context,
+ * for use when processing activities within its
+ * scope.
+ *
+ * @param conv The conversation
+ */
+ public void addConversation(Conversation conv);
+
+ /**
+ * This method removes the conversation from the
+ * context.
+ *
+ * @param conv The conversation
+ */
+ public void removeConversation(Conversation conv);
+
+ /**
+ * This method retrieves the conversation associated
+ * with the supplied model reference.
+ *
+ * @param ref The model reference
+ * @return The conversation
+ */
+ public Conversation getConversation(ModelReference ref);
+
+ /**
+ * This method returns the list of Compose activities
+ * within the model.
+ *
+ * @return The list of compose activities
+ */
+ public java.util.List<Compose> getComposeActivities();
+
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRule.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRule.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRule.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+/**
+ * This interface represents a CDM to Scribble conversation
+ * rule.
+ */
+public interface ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ org.pi4soa.cdl.CDLType cdlType);
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public org.scribble.model.ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, org.pi4soa.cdl.CDLType cdlType);
+
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRuleFactory.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRuleFactory.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRuleFactory.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+/**
+ * This class represents a factory for converter rules.
+ */
+public class ConverterRuleFactory {
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converter rule, or null if not found
+ */
+ public static ConverterRule getConverter(Class<?> scribbleType,
+ org.pi4soa.cdl.CDLType cdlType) {
+ ConverterRule ret=null;
+
+ for (int i=0; ret == null && i < m_rules.length; i++) {
+ if (m_rules[i].isSupported(scribbleType, cdlType)) {
+ ret = m_rules[i];
+ }
+ }
+
+ return(ret);
+ }
+
+ private static ConverterRule[] m_rules={
+ new ConversationModelConverterRuleImpl(),
+ new ConversationConverterRuleImpl(),
+ new ParallelConverterRuleImpl(),
+ new IfOrWhenConverterRuleImpl(),
+ new IfConverterRuleImpl(),
+ new WhenConverterRuleImpl(),
+ new WhileConverterRuleImpl(),
+ new ConversationInteractionConverterRuleImpl(),
+ new FinalizeConverterRuleImpl(),
+ new FinalizerHandlerConverterRuleImpl(),
+ new AssignConverterRuleImpl(),
+ new SequenceConverterRuleImpl(),
+ new PerformConverterRuleImpl()
+ };
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterUtil.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterUtil.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterUtil.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 31 Jul 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.scribble.model.*;
+
+/**
+ * This class defines some converter utility functions.
+ */
+public class ConverterUtil {
+
+ /**
+ * This method converts the supplied information type into a
+ * type reference.
+ *
+ * @param infoType The information type
+ * @return The type reference
+ */
+ public static TypeReference getTypeReference(org.pi4soa.cdl.InformationType infoType) {
+ TypeReference ret=new TypeReference();
+
+ // TODO: Establish 'implements' dependency between
+ // XML type and an abstract type derived from the
+ // XML namespace and localpart.
+
+ org.pi4soa.common.xml.XMLPrefixResolver resolver=
+ org.pi4soa.cdl.util.CDLTypeUtil.getPrefixResolver(infoType.getPackage());
+ String typeName=null;
+
+ // TODO: Need to have general way to convert
+ // namespace scoped type into a type reference
+
+ if (org.pi4soa.common.util.NamesUtil.isSet(infoType.getTypeName())) {
+ typeName = infoType.getTypeName();
+ } else if (org.pi4soa.common.util.NamesUtil.isSet(infoType.getElementName())) {
+ typeName = infoType.getElementName();
+ }
+
+ if (typeName != null) {
+ ret.setLocalpart(org.pi4soa.common.xml.XMLUtils.getLocalname(typeName));
+ ret.setNamespace(org.pi4soa.common.xml.XMLUtils.getNamespace(typeName, resolver, null));
+ }
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,184 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+import org.scribble.util.Scope;
+
+import org.scribble.conversation.model.Compose;
+import org.scribble.conversation.model.Conversation;
+import org.scribble.model.*;
+
+/**
+ * The default implementation of the converter context.
+ */
+public class DefaultConverterContext implements ConverterContext {
+
+ /**
+ * Default constructor.
+ */
+ public DefaultConverterContext() {
+ }
+
+ /**
+ * This is the constructor for the converter context, initialized
+ * with the source reference.
+ *
+ * @param ref The source model reference
+ */
+ public DefaultConverterContext(ModelReference ref) {
+ m_source = ref;
+ }
+
+ /**
+ * This method returns the source model reference.
+ *
+ * @return The source model reference
+ */
+ public ModelReference getSource() {
+ return(m_source);
+ }
+
+ /**
+ * This method returns the declaration associated
+ * with the supplied name.
+ *
+ * @param name The name
+ * @return The declaration, or null if not found
+ */
+ public Object getState(String name) {
+ return(m_scope.getState(name));
+ }
+
+ /**
+ * This method sets the declaration associated with
+ * the supplied name.
+ *
+ * @param name The name
+ * @param decl The declaration
+ */
+ public void setState(String name, Object decl) {
+ m_scope.setState(name, decl);
+ }
+
+ /**
+ * This method pushes the current state onto a stack.
+ */
+ public void pushState() {
+ m_scope.pushState();
+ }
+
+ /**
+ * This method pops the current state from the stack.
+ */
+ public void popState() {
+ m_scope.popState();
+ }
+
+ /**
+ * This method pushes the current scope onto a stack.
+ */
+ public void pushScope() {
+ m_scopeStack.add(0, m_scope);
+ m_scope = new Scope();
+ }
+
+ /**
+ * This method pops the current scope from the stack.
+ */
+ public void popScope() {
+ if (m_scopeStack.size() > 0) {
+ m_scope = m_scopeStack.remove(0);
+ } else {
+ logger.severe("No state entry to pop from stack");
+ }
+ }
+
+ /**
+ * This method adds a conversation to the context,
+ * for use when processing activities within its
+ * scope.
+ *
+ * @param conv The conversation
+ */
+ public void addConversation(Conversation conv) {
+ m_conversations.add(conv);
+ }
+
+ /**
+ * This method removes the conversation from the
+ * context.
+ *
+ * @param conv The conversation
+ */
+ public void removeConversation(Conversation conv) {
+ m_conversations.remove(conv);
+ }
+
+ /**
+ * This method retrieves the conversation associated
+ * with the supplied model reference.
+ *
+ * @param ref The model reference
+ * @return The conversation
+ */
+ public Conversation getConversation(ModelReference ref) {
+ Conversation ret=null;
+
+ for (int i=0; ret == null && i < m_conversations.size(); i++) {
+ Conversation subconv=(Conversation)
+ m_conversations.get(i);
+
+ if (subconv.getLocatedName() != null &&
+ subconv.getLocatedName().getName() != null &&
+ ref.getAlias().equals(
+ subconv.getLocatedName().getName()) &&
+ ((ref.getLocatedRole() == null &&
+ subconv.getLocatedName().getRole() == null) ||
+ ((ref.getLocatedRole() != null &&
+ subconv.getLocatedName().getRole() != null &&
+ ref.getLocatedRole().equals(
+ subconv.getLocatedName().getRole().getName()))))) {
+
+ ret = subconv;
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of Compose activities
+ * within the model.
+ *
+ * @return The list of compose activities
+ */
+ public java.util.List<Compose> getComposeActivities() {
+ return(m_composeActivities);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+
+ private ModelReference m_source=null;
+ private Scope m_scope=new Scope();
+ private java.util.List<Scope> m_scopeStack=new java.util.Vector<Scope>();
+ private java.util.List<Compose> m_composeActivities=new java.util.Vector<Compose>();
+ private java.util.List<Conversation> m_conversations=new java.util.Vector<Conversation>();
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizeConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizeConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizeConverterRuleImpl.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 1 Jun 2009 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class FinalizeConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Finalize);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.conversation.model.Run ret=
+ new org.scribble.conversation.model.Run();
+ org.pi4soa.cdl.Finalize cdl=(org.pi4soa.cdl.Finalize)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+
+ ConversationReference ref=new ConversationReference();
+ ref.setLocalpart(cdl.getChoreography().getName()+"_"+cdl.getFinalizer().getName());
+ ref.setInner(true);
+
+ ret.setReference(ref);
+
+ // Find conversation related to reference, and use
+ // as inner definition initially - to help with
+ // subsequent processing (e.g. locating initiator
+ // roles). The inner definition will be cleared when
+ // the model is fully converted.
+ Conversation conv=context.getConversation(ref);
+
+ if (conv != null) {
+ ret.setInlineDefinition(conv);
+ context.getComposeActivities().add(ret);
+
+ // Bind roles
+ java.util.List<Role> roles=conv.getRoles();
+
+ for (int i=0; i < roles.size(); i++) {
+ Role role=roles.get(i);
+
+ Object decl=context.getState(role.getName());
+
+ if (decl instanceof Declaration) {
+ ret.getBindings().add(new DeclarationBinding((Declaration)decl, role.getName()));
+ }
+ }
+ }
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizerHandlerConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizerHandlerConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizerHandlerConverterRuleImpl.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,316 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 1 Jun 2009 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.Interaction;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.pi4soa.common.util.NamesUtil;
+import org.pi4soa.common.xml.XMLUtils;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.expression.xpath.model.*;
+
+public class FinalizerHandlerConverterRuleImpl implements ConverterRule {
+
+ private static final String CONVERSATION_TYPE = "conversationType";
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == Conversation.class &&
+ cdlType instanceof FinalizerHandler);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ Conversation ret=new Conversation();
+ FinalizerHandler choreo=(FinalizerHandler)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(choreo));
+
+ context.pushScope();
+
+ LocatedName modelName=new LocatedName();
+ modelName.setName(choreo.getEnclosingChoreography().getName()+"_"+choreo.getName());
+
+ ret.setLocatedName(modelName);
+
+ // Define roles
+ defineRoles(context, choreo, ret);
+
+ // Convert variables
+ convertVariables(context, choreo, ret.getBlock());
+
+ // Define identities
+ convertIdentities(context, choreo, ret);
+
+ // Process all of the activities within the
+ // choreography
+ convertActivities(context, choreo.getActivities(), ret.getBlock());
+
+ context.popScope();
+
+ return(ret);
+ }
+
+
+ protected void defineRoles(ConverterContext context,
+ final FinalizerHandler choreo, Conversation conv) {
+
+ final java.util.List<ParticipantType> partTypes=new java.util.Vector<ParticipantType>();
+ final java.util.List<Participant> partInstances=new java.util.Vector<Participant>();
+
+ choreo.visit(new DefaultCDLVisitor() {
+
+ public void interaction(Interaction interaction) {
+
+ if (interaction.getEnclosingChoreography() != choreo.getEnclosingChoreography()) {
+ return;
+ }
+
+ if (interaction.getFromParticipant() != null) {
+ if (partInstances.contains(interaction.getFromParticipant()) == false) {
+ partInstances.add(interaction.getFromParticipant());
+ }
+ } else {
+ ParticipantType ptype=
+ org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+ interaction.getFromRoleType());
+
+ if (ptype != null &&
+ partTypes.contains(ptype) == false) {
+ partTypes.add(ptype);
+ }
+ }
+
+ if (interaction.getToParticipant() != null) {
+ if (partInstances.contains(interaction.getToParticipant()) == false) {
+ partInstances.add(interaction.getToParticipant());
+ }
+ } else {
+ ParticipantType ptype=
+ org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+ interaction.getToRoleType());
+
+ if (ptype != null &&
+ partTypes.contains(ptype) == false) {
+ partTypes.add(ptype);
+ }
+ }
+ }
+ });
+
+ // Define roles
+ java.util.Iterator<Participant> piter=partInstances.iterator();
+
+ RoleList roleList=null;
+
+ while (piter.hasNext()) {
+ Role role=new Role();
+ Participant pinst=piter.next();
+ role.setName(pinst.getName());
+
+ if (roleList == null) {
+ roleList = new RoleList();
+ conv.getBlock().getContents().add(roleList);
+ }
+
+ roleList.getRoles().add(role);
+
+ context.setState(role.getName(), role);
+ }
+
+ java.util.Iterator<ParticipantType> ptiter=partTypes.iterator();
+
+ /*
+ if (choreo.getRoot() != Boolean.TRUE) {
+ roleList = null;
+ } else {
+ ptiter = choreo.getPackage().getTypeDefinitions().getParticipantTypes().iterator();
+ }
+ */
+
+ while (ptiter.hasNext()) {
+ Role role=new Role();
+ ParticipantType ptype=ptiter.next();
+ role.setName(ptype.getName());
+
+ if (roleList == null) {
+ roleList = new RoleList();
+
+ roleList.setOpen(choreo.getEnclosingChoreography().getRoot() != Boolean.TRUE);
+
+ conv.getBlock().getContents().add(roleList);
+ }
+
+ roleList.getRoles().add(role);
+
+ context.setState(role.getName(), role);
+ }
+ }
+
+ protected void convertVariables(ConverterContext context,
+ FinalizerHandler choreo, Block block) {
+
+ java.util.List<org.pi4soa.cdl.Variable> vars=
+ choreo.getEnclosingChoreography().getVariableDefinitions();
+
+ for (int i=0; i < vars.size(); i++) {
+ org.pi4soa.cdl.Variable var=(org.pi4soa.cdl.Variable)vars.get(i);
+
+ if (var.getType() instanceof InformationType) {
+ java.util.List<RoleType> roleTypes=var.getRoleTypes();
+
+ if (roleTypes.size() == 0) {
+ roleTypes = choreo.getPackage().getTypeDefinitions().getRoleTypes();
+ }
+
+ VariableList vlist=new VariableList();
+ TypeReference ref=new TypeReference();
+
+ String qname=((InformationType)var.getType()).getElementName();
+
+ if (NamesUtil.isSet(qname)==false) {
+ qname=((InformationType)var.getType()).getTypeName();
+ }
+
+ ref.setNamespace(CDLTypeUtil.getNamespace(qname, var));
+ ref.setLocalpart(XMLUtils.getLocalname(qname));
+
+ vlist.setType(ref);
+
+ /* TODO: See if variables should be located?
+ for (int j=0; j < roleTypes.size(); j++) {
+ org.scribble.conversation.model.Variable newVar=
+ new org.scribble.conversation.model.Variable();
+
+ newVar.setName(var.getName());
+ }
+ */
+
+ org.scribble.conversation.model.Variable newVar=
+ new org.scribble.conversation.model.Variable();
+
+ newVar.setName(var.getName());
+
+ vlist.getVariables().add(newVar);
+
+ block.getContents().add(vlist);
+ }
+ }
+ }
+
+ protected void convertActivities(ConverterContext context,
+ java.util.List<org.pi4soa.cdl.Activity> acts, Block block) {
+
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ acts.iterator();
+
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+
+ if (activity instanceof Block) {
+ block.getContents().addAll(((Block)activity).getContents());
+ } else {
+ block.getContents().add(activity);
+ }
+ }
+ }
+ }
+ }
+
+ protected void convertIdentities(ConverterContext context,
+ FinalizerHandler choreo, Conversation conv) {
+
+ // Define identities
+ java.util.List<org.pi4soa.cdl.Variable> vars=
+ choreo.getEnclosingChoreography().getVariableDefinitions();
+ java.util.List<org.scribble.conversation.model.Identity> ids=
+ new java.util.Vector<org.scribble.conversation.model.Identity>();
+
+ for (int i=0; i < vars.size(); i++) {
+ if (vars.get(i).getType() instanceof org.pi4soa.cdl.ChannelType) {
+ org.pi4soa.cdl.ChannelType ctype=
+ (org.pi4soa.cdl.ChannelType)vars.get(i).getType();
+
+ java.util.Iterator<org.pi4soa.cdl.Identity> cids=
+ ctype.getIdentities().iterator();
+
+ while (cids.hasNext()) {
+ org.pi4soa.cdl.Identity cid=cids.next();
+ org.scribble.conversation.model.Identity id=
+ new org.scribble.conversation.model.Identity();
+
+ if (cid.getType() == KeyType.ASSOCIATION) {
+ id.setIdentityType(IdentityType.Association);
+ } else if (cid.getType() == KeyType.DERIVED) {
+ id.setIdentityType(IdentityType.Derived);
+ } else {
+ id.setIdentityType(IdentityType.Primary);
+ }
+
+ for (int j=0; j < cid.getTokens().size(); j++) {
+ id.getNames().add(cid.getTokens().get(j).getName());
+ }
+
+ if (ids.contains(id) == false) {
+ ids.add(id);
+ }
+ }
+ }
+ }
+
+ conv.getIdentities().addAll(ids);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfConverterRuleImpl.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.expression.xpath.model.XPathExpression;
+
+public class IfConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Conditional);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.conversation.model.If ret=
+ new org.scribble.conversation.model.If();
+ org.pi4soa.cdl.Conditional cdl=(org.pi4soa.cdl.Conditional)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+
+ ConditionalBlock block=new ConditionalBlock();
+ ret.getConditionalBlocks().add(block);
+
+ context.pushState();
+
+ // Set the expression if defined in the 'conditional'
+ if (cdl.getExpression() != null) {
+ XPathExpression exp=new XPathExpression();
+
+ exp.setQuery(cdl.getExpression());
+
+ block.setExpression(exp);
+ }
+
+ // Process all of the activities within the
+ // choreography
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ cdl.getActivities().iterator();
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+ if (activity instanceof Block) {
+ block.getContents().addAll(((Block)activity).getContents());
+ } else {
+ block.getContents().add(activity);
+ }
+ }
+ }
+ }
+
+ // Get initiator role(s) for first activity in body and
+ // associated with If
+ ret.getRoles().addAll(block.getInitiatorRoles());
+
+ context.popState();
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfOrWhenConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfOrWhenConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfOrWhenConverterRuleImpl.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class IfOrWhenConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Choice);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.model.Activity ret=null;
+ org.pi4soa.cdl.Choice cdl=(org.pi4soa.cdl.Choice)cdlType;
+ java.util.List<ConditionalBlock> blocks=new java.util.Vector<ConditionalBlock>();
+ boolean f_when=false;
+
+ // Process all of the activities within the
+ // choreography
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ cdl.getActivities().iterator();
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+
+ context.pushState();
+
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+ if (activity instanceof If) {
+ blocks.addAll(((If)activity).getConditionalBlocks());
+ } else if (activity instanceof
+ org.scribble.conversation.model.When) {
+ blocks.addAll(((org.scribble.conversation.model.When)activity).getConditionalBlocks());
+ f_when = true;
+ } else {
+ ConditionalBlock block=new ConditionalBlock();
+
+ if (activity instanceof Block) {
+ block.getContents().addAll(((Block)activity).getContents());
+ } else {
+ block.getContents().add(activity);
+ }
+
+ blocks.add(block);
+ }
+ }
+
+ context.popState();
+ }
+ }
+
+ // Build up initiator role list
+ java.util.List<Role> roles=null;
+
+ for (int i=0; i < blocks.size(); i++) {
+ Block b=blocks.get(i);
+
+ java.util.List<Role> blockRoles=
+ b.getInitiatorRoles();
+
+ if (blockRoles != null) {
+ if (roles == null) {
+ roles = blockRoles;
+ } else {
+ for (int j=0; j < blockRoles.size(); j++) {
+ if (roles.contains(blockRoles.get(j)) == false) {
+ roles.add(blockRoles.get(j));
+ }
+ }
+ }
+ }
+ }
+
+ if (f_when) {
+ ret = new org.scribble.conversation.model.When();
+ ((org.scribble.conversation.model.When)ret).
+ getConditionalBlocks().addAll(blocks);
+
+ if (roles != null) {
+ ((org.scribble.conversation.model.When)ret).
+ getRoles().addAll(roles);
+ }
+ } else {
+ ret = new org.scribble.conversation.model.If();
+ ((org.scribble.conversation.model.If)ret).
+ getConditionalBlocks().addAll(blocks);
+
+ if (roles != null) {
+ ((org.scribble.conversation.model.If)ret).
+ getRoles().addAll(roles);
+ }
+ }
+
+ if (ret != null) {
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+ }
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ParallelConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ParallelConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ParallelConverterRuleImpl.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+
+public class ParallelConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Parallel);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.conversation.model.Parallel ret=
+ new org.scribble.conversation.model.Parallel();
+ org.pi4soa.cdl.Parallel cdl=(org.pi4soa.cdl.Parallel)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+
+ // Process all of the activities within the
+ // choreography
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ cdl.getActivities().iterator();
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+
+ context.pushState();
+
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+ if (activity instanceof Block) {
+ ret.getBlocks().add((Block)activity);
+ } else {
+ Block block=new Block();
+ block.getContents().add(activity);
+ ret.getBlocks().add(block);
+ }
+ }
+
+ context.popState();
+ }
+ }
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 27 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class PerformConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Perform);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.conversation.model.Compose ret=null;
+ org.pi4soa.cdl.Perform cdl=(org.pi4soa.cdl.Perform)cdlType;
+
+ if (cdl.getWaitForCompletion() == Boolean.TRUE) {
+ ret = new org.scribble.conversation.model.Run();
+ } else {
+ ret = new org.scribble.conversation.model.Spawn();
+ }
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+
+ ConversationReference ref=new ConversationReference();
+ ref.setLocalpart(cdl.getChoreography().getName());
+ ref.setInner(true);
+
+ ret.setReference(ref);
+
+ // Find conversation related to reference, and use
+ // as inner definition initially - to help with
+ // subsequent processing (e.g. locating initiator
+ // roles). The inner definition will be cleared when
+ // the model is fully converted.
+ Conversation conv=context.getConversation(ref);
+
+ if (conv != null) {
+ ret.setInlineDefinition(conv);
+ context.getComposeActivities().add(ret);
+
+ // Bind roles
+ java.util.List<Role> roles=conv.getRoles();
+
+ for (int i=0; i < roles.size(); i++) {
+ Role role=roles.get(i);
+
+ Object decl=context.getState(role.getName());
+
+ if (decl instanceof Declaration) {
+ ret.getBindings().add(new DeclarationBinding((Declaration)decl, role.getName()));
+ }
+ }
+ }
+
+ // Convert binding parameters
+ java.util.List<BindDetails> bds=cdl.getBindDetails();
+
+ for (int i=0; i < bds.size(); i++) {
+
+ // Only convert if a variable, not a channel
+ // TODO: Need to also convert explicit channels
+ if (bds.get(i).getThisVariable() instanceof org.pi4soa.cdl.Variable) {
+ DeclarationBinding db=new DeclarationBinding();
+
+ Object state=context.getState(bds.get(i).getThisVariable().getName());
+
+ if (state instanceof Declaration) {
+ db.setDeclaration((Declaration)state);
+ db.setBoundName(bds.get(i).getFreeVariable().getName());
+
+ ret.getBindings().add(db);
+ } else {
+ logger.finer("State not found for '"+bds.get(i).getThisVariable().getName()+"'");
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/SequenceConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/SequenceConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/SequenceConverterRuleImpl.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+
+public class SequenceConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.Sequence);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.model.Block ret=
+ new org.scribble.model.Block();
+ org.pi4soa.cdl.Sequence cdl=(org.pi4soa.cdl.Sequence)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+
+ context.pushState();
+
+ // Process all of the activities within the
+ // choreography
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ cdl.getActivities().iterator();
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+ if (activity instanceof Block) {
+ ret.getContents().addAll(
+ ((Block)activity).getContents());
+ } else {
+ ret.getContents().add(activity);
+ }
+ }
+ }
+ }
+
+ context.popState();
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhenConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhenConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhenConverterRuleImpl.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.expression.xpath.model.XPathExpression;
+
+public class WhenConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.When);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.conversation.model.When ret=
+ new org.scribble.conversation.model.When();
+ org.pi4soa.cdl.When cdl=(org.pi4soa.cdl.When)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+
+ ConditionalBlock block=new ConditionalBlock();
+ ret.getConditionalBlocks().add(block);
+
+ context.pushState();
+
+ // Set the expression if defined in the 'when'
+ if (cdl.getExpression() != null) {
+ XPathExpression exp=new XPathExpression();
+
+ exp.setQuery(cdl.getExpression());
+
+ block.setExpression(exp);
+ }
+
+ // Process all of the activities within the
+ // choreography
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ cdl.getActivities().iterator();
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+ if (activity instanceof Block) {
+ block.getContents().addAll(((Block)activity).getContents());
+ } else {
+ block.getContents().add(activity);
+ }
+ }
+ }
+ }
+
+ // Get initiator role(s) for first activity in body and
+ // associated with When
+ ret.getRoles().addAll(block.getInitiatorRoles());
+
+ context.popState();
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhileConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhileConverterRuleImpl.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhileConverterRuleImpl.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.expression.xpath.model.XPathExpression;
+import org.scribble.model.*;
+
+public class WhileConverterRuleImpl implements ConverterRule {
+
+ /**
+ * This method determines whether the rule can be applied
+ * to the supplied CDL type.
+ *
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type
+ * @return Whether the rule is appropriate to convert
+ * the CDL type
+ */
+ public boolean isSupported(Class<?> scribbleType,
+ CDLType cdlType) {
+ return(scribbleType == org.scribble.model.Activity.class &&
+ cdlType instanceof org.pi4soa.cdl.While);
+ }
+
+ /**
+ * This method converts the supplied CDL type into a
+ * Scribble model object.
+ *
+ * @param context The converters context
+ * @param scribbleType The Scribble target type
+ * @param cdlType The CDL type to be converted
+ * @return The converted Scribble model object
+ */
+ public ModelObject convert(ConverterContext context,
+ Class<?> scribbleType, CDLType cdlType) {
+ org.scribble.conversation.model.While ret=
+ new org.scribble.conversation.model.While();
+ org.pi4soa.cdl.While cdl=(org.pi4soa.cdl.While)cdlType;
+
+ ret.getSource().setComponentURI(
+ CDLTypeUtil.getURIFragment(cdl));
+
+ context.pushState();
+
+ // Set the expression if defined in the 'while'
+ if (cdl.getExpression() != null &&
+ cdl.getExpression().trim().length() > 0) {
+ XPathExpression exp=new XPathExpression();
+
+ exp.setQuery(cdl.getExpression());
+
+ ret.getBlock().setExpression(exp);
+ }
+
+ // Process all of the activities within the
+ // choreography
+ java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+ cdl.getActivities().iterator();
+ while (actiter.hasNext()) {
+ org.pi4soa.cdl.Activity act=actiter.next();
+
+ ConverterRule rule=ConverterRuleFactory.getConverter(
+ org.scribble.model.Activity.class, act);
+
+ if (rule != null) {
+ org.scribble.model.Activity activity=
+ (org.scribble.model.Activity)
+ rule.convert(context,
+ org.scribble.model.Activity.class, act);
+
+ if (activity != null) {
+ if (activity instanceof Block) {
+ ret.getBlock().getContents().addAll(((Block)activity).getContents());
+ } else {
+ ret.getBlock().getContents().add(activity);
+ }
+ }
+ }
+ }
+
+ // Get initiator role(s) for first activity in body and
+ // associated with While
+ ret.getRoles().addAll(ret.getBlock().getInitiatorRoles());
+
+ context.popState();
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/validation/TypeReferenceValidationRule.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/validation/TypeReferenceValidationRule.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/validation/TypeReferenceValidationRule.java 2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 2 Nov 2007 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.validation;
+
+import org.jboss.savara.pi4soa.cdm.model.CDMNotation;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.validation.*;
+
+/**
+ * This class implements the validation rule for the
+ * type reference. This rule overrides the type
+ * reference validation in the core scribble plugin.
+ */
+(a)RegistryInfo(extension=ValidationRule.class,notation=CDMNotation.NOTATION_CODE)
+public class TypeReferenceValidationRule extends org.scribble.validation.TypeReferenceValidationRule {
+
+ /**
+ * This is the default constructor.
+ */
+ public TypeReferenceValidationRule() {
+ }
+
+ /**
+ * This method determines whether the rule is appropriate for
+ * the supplied model object.
+ *
+ * @param obj The model object
+ * @return Whether the rule is appropriate
+ */
+ public boolean isSupported(ModelObject obj) {
+ return(obj.getClass() == TypeReference.class);
+ }
+
+ /**
+ * This method validates the supplied model object.
+ *
+ * @param obj The model object
+ * @param context The context
+ * @param l The listener
+ */
+ public void validate(ModelObject obj, ValidationContext context,
+ ModelListener l) {
+ // Ignore type references - these will be represented
+ // as XML type or elements
+
+ // TODO: Eventually may want to validate if the XML
+ // schemas are located in the project
+ }
+}
15 years, 5 months
savara SVN: r481 - in trunk/tools/plugins: org.jboss.savara.contract.model and 1 other directory.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-11-18 09:02:24 -0500 (Thu, 18 Nov 2010)
New Revision: 481
Removed:
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/
Modified:
trunk/tools/plugins/org.jboss.savara.contract.model/
Log:
Temporarily remove pi4soa cdm plugin to cleanup svn metadata.
Property changes on: trunk/tools/plugins/org.jboss.savara.contract.model
___________________________________________________________________
Name: svn:ignore
+ bin
15 years, 5 months
savara SVN: r480 - in trunk/tools/plugins: org.jboss.savara.contract.model and 9 other directories.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-11-18 08:58:27 -0500 (Thu, 18 Nov 2010)
New Revision: 480
Added:
trunk/tools/plugins/org.jboss.savara.contract.model/
trunk/tools/plugins/org.jboss.savara.contract.model/.classpath
trunk/tools/plugins/org.jboss.savara.contract.model/.project
trunk/tools/plugins/org.jboss.savara.contract.model/Copyright.txt
trunk/tools/plugins/org.jboss.savara.contract.model/META-INF/
trunk/tools/plugins/org.jboss.savara.contract.model/META-INF/MANIFEST.MF
trunk/tools/plugins/org.jboss.savara.contract.model/build.properties
trunk/tools/plugins/org.jboss.savara.contract.model/pom.xml
trunk/tools/plugins/org.jboss.savara.contract.model/src/
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Contract.java
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/FaultDetails.java
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Interface.java
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/MessageExchangePattern.java
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Namespace.java
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/OneWayRequestMEP.java
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/RequestResponseMEP.java
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Type.java
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/TypeDefinition.java
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/osgi/
trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/osgi/Activator.java
Log:
Add contract model plugin back.
Added: trunk/tools/plugins/org.jboss.savara.contract.model/.classpath
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/.classpath (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/.classpath 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/tools/plugins/org.jboss.savara.contract.model/.project
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/.project (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/.project 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.savara.contract.model</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/tools/plugins/org.jboss.savara.contract.model/Copyright.txt
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/Copyright.txt (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/Copyright.txt 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,17 @@
+/*
+ * 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.
+ */
Added: trunk/tools/plugins/org.jboss.savara.contract.model/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/META-INF/MANIFEST.MF 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JBoss SAVARA Contract Model
+Bundle-SymbolicName: org.jboss.savara.contract.model
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.jboss.savara.contract.model.osgi.Activator
+Bundle-Vendor: www.jboss.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework
+Require-Bundle: org.scribble.core;bundle-version="[1.0.0,2.0.0)"
+Export-Package: org.jboss.savara.contract.model
Added: trunk/tools/plugins/org.jboss.savara.contract.model/build.properties
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/build.properties (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/build.properties 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,4 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added: trunk/tools/plugins/org.jboss.savara.contract.model/pom.xml
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/pom.xml (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/pom.xml 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,16 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.savara.tools</groupId>
+ <artifactId>org.jboss.savara.contract.model</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Tools::Plugins::ContractModel</name>
+
+ <parent>
+ <groupId>org.jboss.savara.tools</groupId>
+ <artifactId>plugins</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+</project>
Added: trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Contract.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Contract.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Contract.java 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,118 @@
+/*
+ * 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.jboss.savara.contract.model;
+
+/**
+ * This class represents the contract.
+ */
+public class Contract {
+
+ private String m_name=null;
+ private String m_namespace=null;
+ private java.util.Set<Interface> m_interfaces=
+ new java.util.HashSet<Interface>();
+ private java.util.Set<Namespace> m_namespaces=
+ new java.util.HashSet<Namespace>();
+
+ /**
+ * The default constructor.
+ */
+ public Contract() {
+ }
+
+ /**
+ * This method returns the name associated with the
+ * contract.
+ *
+ * @return The name
+ */
+ public String getName() {
+ return(m_name);
+ }
+
+ /**
+ * This method sets the name of the contract.
+ *
+ * @param name The name
+ */
+ public void setName(String name) {
+ m_name = name;
+ }
+
+ /**
+ * This method returns the namespace associated with the
+ * contract.
+ *
+ * @return The namespace
+ */
+ public String getNamespace() {
+ return(m_namespace);
+ }
+
+ /**
+ * This method sets the namespace of the contract.
+ *
+ * @param namespace The namespace
+ */
+ public void setNamespace(String namespace) {
+ m_namespace = namespace;
+ }
+
+ /**
+ * This method returns the list of interfaces.
+ *
+ * @return The list of interfaces
+ */
+ public java.util.Set<Interface> getInterfaces() {
+ return(m_interfaces);
+ }
+
+ /**
+ * This method returns the interface associated
+ * with the supplied name.
+ *
+ * @param name The interface name
+ * @return The interface, or null if not found.
+ */
+ public Interface getInterface(String name) {
+ Interface ret=null;
+
+ java.util.Iterator<Interface> iter=getInterfaces().iterator();
+ while (ret == null && iter.hasNext()) {
+ ret = iter.next();
+
+ if (ret.getName().equals(name) == false) {
+ ret = null;
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of namespaces.
+ * If a namespace is used in the contract that does
+ * not exist in this list, then a dynamic prefix should
+ * be created for the namespace.
+ *
+ * @return The list of namespaces
+ */
+ public java.util.Set<Namespace> getNamespaces() {
+ return(m_namespaces);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/FaultDetails.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/FaultDetails.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/FaultDetails.java 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,82 @@
+/*
+ * 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.jboss.savara.contract.model;
+
+/**
+ * This class represents the fault details.
+ */
+public class FaultDetails {
+
+ private String m_name=null;
+ private String m_namespace=null;
+ private java.util.List<Type> m_types=
+ new java.util.Vector<Type>();
+
+ /**
+ * The default constructor.
+ */
+ public FaultDetails() {
+ }
+
+ /**
+ * This method returns the name associated with the
+ * fault.
+ *
+ * @return The name
+ */
+ public String getName() {
+ return(m_name);
+ }
+
+ /**
+ * This method sets the name of the fault.
+ *
+ * @param name The name
+ */
+ public void setName(String name) {
+ m_name = name;
+ }
+
+ /**
+ * This method returns the namespace associated with the
+ * fault.
+ *
+ * @return The namespace
+ */
+ public String getNamespace() {
+ return(m_namespace);
+ }
+
+ /**
+ * This method sets the namespace of the fault.
+ *
+ * @param namespace The namespace
+ */
+ public void setNamespace(String namespace) {
+ m_namespace = namespace;
+ }
+
+ /**
+ * This method returns the list of types.
+ *
+ * @return The list of types
+ */
+ public java.util.List<Type> getTypes() {
+ return(m_types);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Interface.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Interface.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Interface.java 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,106 @@
+/*
+ * 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.jboss.savara.contract.model;
+
+/**
+ * This class represents an interface, as part of a contract.
+ *
+ */
+public class Interface {
+
+ private String m_name=null;
+ private String m_namespace=null;
+ private java.util.List<MessageExchangePattern> m_messageExchangePatterns=
+ new java.util.Vector<MessageExchangePattern>();
+
+ /**
+ * The default constructor.
+ */
+ public Interface() {
+ }
+
+ /**
+ * This method returns the name associated with the
+ * interface.
+ *
+ * @return The name
+ */
+ public String getName() {
+ return(m_name);
+ }
+
+ /**
+ * This method sets the name of the interface.
+ *
+ * @param name The name
+ */
+ public void setName(String name) {
+ m_name = name;
+ }
+
+ /**
+ * This method returns the namespace associated with the
+ * interface.
+ *
+ * @return The namespace
+ */
+ public String getNamespace() {
+ return(m_namespace);
+ }
+
+ /**
+ * This method sets the namespace of the interface.
+ *
+ * @param namespace The namespace
+ */
+ public void setNamespace(String namespace) {
+ m_namespace = namespace;
+ }
+
+ /**
+ * This method returns the list of message exchange patterns.
+ *
+ * @return The list of message exchange patterns
+ */
+ public java.util.List<MessageExchangePattern> getMessageExchangePatterns() {
+ return(m_messageExchangePatterns);
+ }
+
+ /**
+ * This method retrieves an existing message exchange pattern,
+ * associated with the supplied operation name, if one exists.
+ *
+ * @param op The operation
+ * @return The message exchange pattern, or null if not found
+ */
+ public MessageExchangePattern getMessageExchangePatternForOperation(String op) {
+ MessageExchangePattern ret=null;
+
+ java.util.Iterator<MessageExchangePattern> iter=getMessageExchangePatterns().iterator();
+
+ while (ret == null && iter.hasNext()) {
+ ret = iter.next();
+
+ if (op.equals(ret.getOperation()) == false) {
+ ret = null;
+ }
+ }
+
+ return(ret);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/MessageExchangePattern.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/MessageExchangePattern.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/MessageExchangePattern.java 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,63 @@
+/*
+ * 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.jboss.savara.contract.model;
+
+/**
+ * This class represents the message exchange pattern.
+ */
+public abstract class MessageExchangePattern {
+
+ private String m_operation=null;
+ private java.util.List<Type> m_types=
+ new java.util.Vector<Type>();
+
+ /**
+ * The default constructor.
+ */
+ public MessageExchangePattern() {
+ }
+
+ /**
+ * This method returns the optional operation.
+ *
+ * @return The optional operation
+ */
+ public String getOperation() {
+ return(m_operation);
+ }
+
+ /**
+ * This method sets the operation.
+ *
+ * @param operation The operation
+ */
+ public void setOperation(String operation) {
+ m_operation = operation;
+ }
+
+ /**
+ * This method returns the list of types. If
+ * no operation name is defined, then only one type
+ * should be defined.
+ *
+ * @return The list of types
+ */
+ public java.util.List<Type> getTypes() {
+ return(m_types);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Namespace.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Namespace.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Namespace.java 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,91 @@
+/*
+ * 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.jboss.savara.contract.model;
+
+/**
+ * This class represents the namespace.
+ */
+public class Namespace {
+
+ private String m_prefix=null;
+ private String m_uri=null;
+ private String m_schemaLocation=null;
+
+ /**
+ * The default constructor.
+ */
+ public Namespace() {
+ }
+
+ /**
+ * This method returns the prefix associated with the
+ * prefix.
+ *
+ * @return The name
+ */
+ public String getPrefix() {
+ return(m_prefix);
+ }
+
+ /**
+ * This method sets the prefix of the namespace.
+ *
+ * @param prefix The prefix
+ */
+ public void setPrefix(String prefix) {
+ m_prefix = prefix;
+ }
+
+ /**
+ * This method returns the URI associated with the
+ * namespace.
+ *
+ * @return The URI
+ */
+ public String getURI() {
+ return(m_uri);
+ }
+
+ /**
+ * This method sets the URI of the namespace.
+ *
+ * @param uri The URI
+ */
+ public void setURI(String uri) {
+ m_uri = uri;
+ }
+
+ /**
+ * This method returns the schema location associated with the
+ * namespace.
+ *
+ * @return The URI
+ */
+ public String getSchemaLocation() {
+ return(m_schemaLocation);
+ }
+
+ /**
+ * This method sets the schema location of the namespace.
+ *
+ * @param schemaLocation The optional schema location
+ */
+ public void setSchemaLocation(String schemaLocation) {
+ m_schemaLocation = schemaLocation;
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/OneWayRequestMEP.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/OneWayRequestMEP.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/OneWayRequestMEP.java 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,31 @@
+/*
+ * 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.jboss.savara.contract.model;
+
+/**
+ * This class represents the one-way message exchange pattern.
+ */
+public class OneWayRequestMEP extends MessageExchangePattern {
+
+ /**
+ * The default constructor.
+ */
+ public OneWayRequestMEP() {
+ }
+
+}
Added: trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/RequestResponseMEP.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/RequestResponseMEP.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/RequestResponseMEP.java 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,53 @@
+/*
+ * 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.jboss.savara.contract.model;
+
+/**
+ * This class represents the request response message exchange pattern.
+ */
+public class RequestResponseMEP extends MessageExchangePattern {
+
+ private java.util.List<Type> m_responseTypes=
+ new java.util.Vector<Type>();
+ private java.util.List<FaultDetails> m_faultDetails=
+ new java.util.Vector<FaultDetails>();
+
+ /**
+ * The default constructor.
+ */
+ public RequestResponseMEP() {
+ }
+
+ /**
+ * This method returns the list of response types.
+ *
+ * @return The list of response types
+ */
+ public java.util.List<Type> getResponseTypes() {
+ return(m_responseTypes);
+ }
+
+ /**
+ * This method returns the list of fault details.
+ *
+ * @return The list of fault details
+ */
+ public java.util.List<FaultDetails> getFaultDetails() {
+ return(m_faultDetails);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Type.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Type.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/Type.java 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,62 @@
+/*
+ * 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.jboss.savara.contract.model;
+
+/**
+ * This class represents a type associated with information passed by the contract.
+ */
+public class Type {
+
+ private String m_name=null;
+ private java.util.Set<TypeDefinition> m_typeDefinitions=
+ new java.util.HashSet<TypeDefinition>();
+
+ /**
+ * The default constructor.
+ */
+ public Type() {
+ }
+
+ /**
+ * This method returns the name associated with the
+ * type.
+ *
+ * @return The name
+ */
+ public String getName() {
+ return(m_name);
+ }
+
+ /**
+ * This method sets the name of the type.
+ *
+ * @param name The name
+ */
+ public void setName(String name) {
+ m_name = name;
+ }
+
+ /**
+ * This method returns the list of type definitions.
+ *
+ * @return The list of type definitions
+ */
+ public java.util.Set<TypeDefinition> getTypeDefinitions() {
+ return(m_typeDefinitions);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/TypeDefinition.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/TypeDefinition.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/TypeDefinition.java 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,95 @@
+/*
+ * 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.jboss.savara.contract.model;
+
+/**
+ * This class represents a type definition within
+ */
+public class TypeDefinition {
+
+ public static final String XSD_ELEMENT="##XSDElement";
+ public static final String XSD_TYPE="##XSDType";
+
+ private String m_name=null;
+ private String m_namespace=null;
+ private String m_typeSystem=null;
+
+ /**
+ * The default constructor.
+ */
+ public TypeDefinition() {
+ }
+
+ /**
+ * This method returns the name associated with the
+ * type.
+ *
+ * @return The name
+ */
+ public String getName() {
+ return(m_name);
+ }
+
+ /**
+ * This method returns the namespace associated with the
+ * type definition.
+ *
+ * @return The namespace
+ */
+ public String getNamespace() {
+ return(m_namespace);
+ }
+
+ /**
+ * This method sets the namespace of the type definition.
+ *
+ * @param namespace The namespace
+ */
+ public void setNamespace(String namespace) {
+ m_namespace = namespace;
+ }
+
+ /**
+ * This method sets the name of the type.
+ *
+ * @param name The name
+ */
+ public void setName(String name) {
+ m_name = name;
+ }
+
+ /**
+ * This method returns the type system associated with the
+ * type definition.
+ *
+ * @return The type system
+ */
+ public String getTypeSystem() {
+ return(m_typeSystem);
+ }
+
+ /**
+ * This method sets the type system associated with the
+ * type definition.
+ *
+ * @param typeSystem The type system
+ */
+ public void setTypeSystem(String typeSystem) {
+ m_typeSystem = typeSystem;
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/osgi/Activator.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/osgi/Activator.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.contract.model/src/java/org/jboss/savara/contract/model/osgi/Activator.java 2010-11-18 13:58:27 UTC (rev 480)
@@ -0,0 +1,39 @@
+/*
+ * 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.jboss.savara.contract.model.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ }
+
+}
15 years, 5 months
savara SVN: r479 - trunk/tools/plugins.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-11-18 08:53:07 -0500 (Thu, 18 Nov 2010)
New Revision: 479
Removed:
trunk/tools/plugins/org.jboss.savara.contract.model/
Log:
Temporarily remove contract model plugin to cleanup svn metadata.
15 years, 5 months