a simple jsdl example to test.
authorSuresh Marru <smarru@apache.org>
Sat, 24 Nov 2012 22:23:42 +0000 (22:23 +0000)
committerSuresh Marru <smarru@apache.org>
Sat, 24 Nov 2012 22:23:42 +0000 (22:23 +0000)
git-svn-id: https://svn.apache.org/repos/asf/airavata/sandbox@1413279 13f79535-47bb-0310-9956-ffa450edef68

grid-tools/jsdl-generator/pom.xml
grid-tools/jsdl-generator/src/main/java/org/apache/airavata/gridtools/jsdl/GenerateJSDLExample.java [new file with mode: 0644]
grid-tools/jsdl-generator/src/main/resources/jsdl-posix.xsd [new file with mode: 0644]

index 5069d78..fa47df0 100644 (file)
@@ -1,58 +1,75 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<!--Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file 
-    distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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. -->
+<!--Licensed to the Apache Software Foundation (ASF) under one or more contributor 
+       license agreements. See the NOTICE file distributed with this work for additional 
+       information regarding copyright ownership. The ASF licenses this file to 
+       you 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. -->
 
 <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.apache.airavata</groupId>
-    <artifactId>airavata-jsdl-generator</artifactId>
-    <name>Airavata JSDL Generator</name>
-    <description>Standalone bean library to generate jsdl.</description>
-    <version>0.1-SNAPSHOT</version>
-    <packaging>jar</packaging>
-    <url>http://airavata.apache.org/</url>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>javax.xml.bind</groupId>
-            <artifactId>jaxb-api</artifactId>
-            <version>2.2.7</version>
-        </dependency>
-
-    </dependencies>
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.0</version>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>jaxb2-maven-plugin</artifactId>
-                <version>1.5</version>
-                <executions>
-                    <execution>
-                        <id>xjc</id>
-                        <goals>
-                            <goal>xjc</goal>
-                        </goals>
-                    </execution>
-                </executions>
-                <configuration>
-                    <schemaDirectory>src/main/resources</schemaDirectory>      
-                    <packageName>org.ogf.jsdl</packageName>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
+       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.apache.airavata</groupId>
+       <artifactId>airavata-jsdl-generator</artifactId>
+       <name>Airavata JSDL Generator</name>
+       <description>Standalone bean library to generate jsdl.</description>
+       <version>0.1-SNAPSHOT</version>
+       <packaging>jar</packaging>
+       <url>http://airavata.apache.org/</url>
+
+       <dependencies>
+
+               <dependency>
+                       <groupId>javax.xml.bind</groupId>
+                       <artifactId>jaxb-api</artifactId>
+                       <version>2.2.7</version>
+               </dependency>
+
+               <dependency>
+                       <groupId>com.sun.xml.bind</groupId>
+                       <artifactId>jaxb-impl</artifactId>
+                       <version>2.2.7-b41</version>
+               </dependency>
+
+               <dependency>
+                       <groupId>com.sun.xml.bind</groupId>
+                       <artifactId>jaxb-xjc</artifactId>
+                       <version>2.2.7-b41</version>
+               </dependency>
+
+       </dependencies>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                               <version>3.0</version>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>jaxb2-maven-plugin</artifactId>
+                               <version>1.5</version>
+                               <executions>
+                                       <execution>
+                                               <id>jsdl-schemas</id>
+                                               <goals>
+                                                       <goal>xjc</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                               <configuration>
+                                       <schemaDirectory>src/main/resources</schemaDirectory>
+                                       <packageName>org.ogf.jsdl</packageName>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+
 </project>
diff --git a/grid-tools/jsdl-generator/src/main/java/org/apache/airavata/gridtools/jsdl/GenerateJSDLExample.java b/grid-tools/jsdl-generator/src/main/java/org/apache/airavata/gridtools/jsdl/GenerateJSDLExample.java
new file mode 100644 (file)
index 0000000..b00bed5
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.gridtools.jsdl;
+
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+
+import org.ogf.jsdl.ApplicationType;
+import org.ogf.jsdl.FileNameType;
+import org.ogf.jsdl.JobDefinitionType;
+import org.ogf.jsdl.JobDescriptionType;
+import org.ogf.jsdl.JobIdentificationType;
+import org.ogf.jsdl.ObjectFactory;
+import org.ogf.jsdl.POSIXApplicationType;
+
+public class GenerateJSDLExample {
+
+    /**
+     * @param args
+     */
+    public static void main(String[] args) {
+
+        try {
+
+            ObjectFactory jsdlObjFact = new ObjectFactory();
+            JobDefinitionType jsdlJobDefType = jsdlObjFact.createJobDefinitionType();
+            JobDescriptionType jsdlJobDescType = jsdlObjFact.createJobDescriptionType();
+            
+            
+            JobIdentificationType jsdlJobIdenType = jsdlObjFact.createJobIdentificationType();
+            jsdlJobIdenType.setJobName("Airavata Test");
+            jsdlJobIdenType.setDescription("Airavata JSDL Test Job");
+            jsdlJobDescType.setJobIdentification(jsdlJobIdenType);
+            
+            POSIXApplicationType jsdlPosixAppType = jsdlObjFact.createPOSIXApplicationType();
+            FileNameType execFileType = jsdlObjFact.createFileNameType();
+            execFileType.setValue("/bin/date");
+            jsdlPosixAppType.setExecutable(execFileType);
+            JAXBElement<POSIXApplicationType> jsdlPosixApp = jsdlObjFact.createPOSIXApplication(jsdlPosixAppType);
+            
+            ApplicationType jsdlAppType = jsdlObjFact.createApplicationType();
+            jsdlAppType.setApplicationName("Test Date");
+            jsdlAppType.setApplicationVersion("v1.0");
+            jsdlAppType.setDescription("Testing Date");
+            jsdlAppType.getAny().add(jsdlPosixApp);
+            jsdlJobDescType.setApplication(jsdlAppType);          
+            
+            jsdlJobDefType.setJobDescription(jsdlJobDescType);
+            JAXBElement<JobDefinitionType> jsdlJobDef = jsdlObjFact.createJobDefinition(jsdlJobDefType);
+
+            //generate the required jsdl
+            JAXBContext jaxbContext = JAXBContext.newInstance(new Class[] { JobDefinitionType.class });
+            StringWriter jsdlXMLString = new StringWriter();
+            Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
+            jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+            jaxbMarshaller.marshal(jsdlJobDef, jsdlXMLString);
+            System.out.println(jsdlXMLString.toString());
+         
+        } catch (JAXBException e) {
+            e.printStackTrace();
+        }
+
+    }
+
+}
diff --git a/grid-tools/jsdl-generator/src/main/resources/jsdl-posix.xsd b/grid-tools/jsdl-generator/src/main/resources/jsdl-posix.xsd
new file mode 100644 (file)
index 0000000..f65f037
--- /dev/null
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+The GGF takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this specification can be obtained from the GGF Secretariat.\r
+\r
+The GGF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights which may cover technology that may be required to practice this recommendation. Please address the information to the GGF Executive Director.\r
+\r
+Copyright (C) Global Grid Forum (2003-2005). All Rights Reserved.\r
+\r
+This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the GGF or other organizations, except as needed for the purpose of developing Grid Recommendations in which case the procedures for copyrights defined in the GGF Document process must be followed, or as required to translate it into languages other than English.\r
+\r
+The limited permissions granted above are perpetual and will not be revoked by the GGF or its successors or assigns.\r
+This document and the information contained herein is provided on an "AS IS" basis and THE GLOBAL GRID FORUM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE."\r
+\r
+-->\r
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.ggf.org/jsdl/2005/11/jsdl-posix" xmlns:jsdl-posix="http://schemas.ggf.org/jsdl/2005/11/jsdl-posix" targetNamespace="http://schemas.ggf.org/jsdl/2005/11/jsdl-posix" elementFormDefault="qualified">\r
+       <!--========================================================================-->\r
+       <xsd:complexType name="Environment_Type">\r
+               <xsd:simpleContent>\r
+                       <xsd:extension base="xsd:string">\r
+                               <xsd:attribute name="name" type="xsd:NCName" use="required"/>\r
+                               <xsd:attribute name="filesystemName" type="xsd:NCName" use="optional"/>\r
+                               <xsd:anyAttribute namespace="##other" processContents="lax"/>\r
+                       </xsd:extension>\r
+               </xsd:simpleContent>\r
+       </xsd:complexType>\r
+       <!--========================================================================-->\r
+       <xsd:complexType name="Argument_Type">\r
+               <xsd:simpleContent>\r
+                       <xsd:extension base="xsd:normalizedString">\r
+                               <xsd:attribute name="filesystemName" type="xsd:NCName" use="optional"/>\r
+                               <xsd:anyAttribute namespace="##other" processContents="lax"/>\r
+                       </xsd:extension>\r
+               </xsd:simpleContent>\r
+       </xsd:complexType>\r
+       <!--========================================================================-->\r
+       <xsd:complexType name="FileName_Type">\r
+               <xsd:simpleContent>\r
+                       <xsd:extension base="xsd:string">\r
+                               <xsd:attribute name="filesystemName" type="xsd:NCName" use="optional"/>\r
+                               <xsd:anyAttribute namespace="##other" processContents="lax"/>\r
+                       </xsd:extension>\r
+               </xsd:simpleContent>\r
+       </xsd:complexType>\r
+       <!--========================================================================-->\r
+       <xsd:complexType name="DirectoryName_Type">\r
+               <xsd:simpleContent>\r
+                       <xsd:extension base="xsd:string">\r
+                               <xsd:attribute name="filesystemName" type="xsd:NCName" use="optional"/>\r
+                               <xsd:anyAttribute namespace="##other" processContents="lax"/>\r
+                       </xsd:extension>\r
+               </xsd:simpleContent>\r
+       </xsd:complexType>\r
+       <!--========================================================================-->\r
+       <xsd:complexType name="Limits_Type">\r
+               <xsd:simpleContent>\r
+                       <xsd:extension base="xsd:nonNegativeInteger">\r
+                               <xsd:anyAttribute namespace="##other" processContents="lax"/>\r
+                       </xsd:extension>\r
+               </xsd:simpleContent>\r
+       </xsd:complexType>\r
+       <!--========================================================================-->\r
+       <xsd:complexType name="UserName_Type">\r
+               <xsd:simpleContent>\r
+                       <xsd:extension base="xsd:string">\r
+                               <xsd:anyAttribute namespace="##other" processContents="lax"/>\r
+                       </xsd:extension>\r
+               </xsd:simpleContent>\r
+       </xsd:complexType>\r
+       <!--========================================================================-->\r
+       <xsd:complexType name="GroupName_Type">\r
+               <xsd:simpleContent>\r
+                       <xsd:extension base="xsd:string">\r
+                               <xsd:anyAttribute namespace="##other" processContents="lax"/>\r
+                       </xsd:extension>\r
+               </xsd:simpleContent>\r
+       </xsd:complexType>\r
+       <!--========================================================================-->\r
+       <xsd:complexType name="POSIXApplication_Type">\r
+               <xsd:sequence>\r
+                       <xsd:element ref="jsdl-posix:Executable" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:Argument" minOccurs="0" maxOccurs="unbounded"/>\r
+                       <xsd:element ref="jsdl-posix:Input" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:Output" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:Error" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:WorkingDirectory" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:Environment" minOccurs="0" maxOccurs="unbounded"/>\r
+                       <xsd:element ref="jsdl-posix:WallTimeLimit" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:FileSizeLimit" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:CoreDumpLimit" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:DataSegmentLimit" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:LockedMemoryLimit" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:MemoryLimit" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:OpenDescriptorsLimit" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:PipeSizeLimit" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:StackSizeLimit" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:CPUTimeLimit" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:ProcessCountLimit" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:VirtualMemoryLimit" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:ThreadCountLimit" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:UserName" minOccurs="0"/>\r
+                       <xsd:element ref="jsdl-posix:GroupName" minOccurs="0"/>\r
+               </xsd:sequence>\r
+               <xsd:attribute name="name" type="xsd:NCName" use="optional"/>\r
+               <xsd:anyAttribute namespace="##other" processContents="lax"/>\r
+       </xsd:complexType>\r
+       <!--========================================================================-->\r
+       <xsd:element name="POSIXApplication" type="POSIXApplication_Type"/>\r
+       <xsd:element name="Executable" type="jsdl-posix:FileName_Type"/>\r
+       <xsd:element name="Argument" type="jsdl-posix:Argument_Type"/>\r
+       <xsd:element name="Input" type="jsdl-posix:FileName_Type"/>\r
+       <xsd:element name="Output" type="jsdl-posix:FileName_Type"/>\r
+       <xsd:element name="Error" type="jsdl-posix:FileName_Type"/>\r
+       <xsd:element name="WorkingDirectory" type="jsdl-posix:DirectoryName_Type"/>\r
+       <xsd:element name="Environment" type="jsdl-posix:Environment_Type"/>\r
+       <xsd:element name="WallTimeLimit" type="jsdl-posix:Limits_Type"/>\r
+       <xsd:element name="FileSizeLimit" type="jsdl-posix:Limits_Type"/>\r
+       <xsd:element name="CoreDumpLimit" type="jsdl-posix:Limits_Type"/>\r
+       <xsd:element name="DataSegmentLimit" type="jsdl-posix:Limits_Type"/>\r
+       <xsd:element name="LockedMemoryLimit" type="jsdl-posix:Limits_Type"/>\r
+       <xsd:element name="MemoryLimit" type="jsdl-posix:Limits_Type"/>\r
+       <xsd:element name="OpenDescriptorsLimit" type="jsdl-posix:Limits_Type"/>\r
+       <xsd:element name="PipeSizeLimit" type="jsdl-posix:Limits_Type"/>\r
+       <xsd:element name="StackSizeLimit" type="jsdl-posix:Limits_Type"/>\r
+       <xsd:element name="CPUTimeLimit" type="jsdl-posix:Limits_Type"/>\r
+       <xsd:element name="ProcessCountLimit" type="jsdl-posix:Limits_Type"/>\r
+       <xsd:element name="VirtualMemoryLimit" type="jsdl-posix:Limits_Type"/>\r
+       <xsd:element name="ThreadCountLimit" type="jsdl-posix:Limits_Type"/>\r
+       <xsd:element name="UserName" type="jsdl-posix:UserName_Type"/>\r
+       <xsd:element name="GroupName" type="jsdl-posix:GroupName_Type"/>\r
+</xsd:schema>\r