diff options
Diffstat (limited to 'winery/org.eclipse.winery.generators.ia/src/main/resources')
6 files changed, 464 insertions, 0 deletions
diff --git a/winery/org.eclipse.winery.generators.ia/src/main/resources/template/java/AbstractIAService.java.template b/winery/org.eclipse.winery.generators.ia/src/main/resources/template/java/AbstractIAService.java.template new file mode 100644 index 0000000..4d4d2a4 --- /dev/null +++ b/winery/org.eclipse.winery.generators.ia/src/main/resources/template/java/AbstractIAService.java.template @@ -0,0 +1,86 @@ +package IA_PACKAGE; + +import java.util.HashMap; +import java.util.List; +import java.util.Map.Entry; + +import javax.annotation.Resource; +import javax.xml.ws.WebServiceContext; + +import org.apache.cxf.headers.Header; +import org.apache.cxf.helpers.CastUtils; +import org.apache.cxf.jaxws.context.WrappedMessageContext; +import org.apache.cxf.message.Message; +import org.w3c.dom.Node; + +import org.eclipse.winery.highlevelrestapi.HighLevelRestApi; + +public abstract class AbstractIAService { + + @Resource + private WebServiceContext context; + + protected void sendResponse (HashMap<String,String> returnParameters) { + + // Extract message + WrappedMessageContext wrappedContext = (WrappedMessageContext) context.getMessageContext(); + Message message = wrappedContext.getWrappedMessage(); + + // Extract headers from message + List<Header> headers = CastUtils.cast((List<?>) message.get(Header.HEADER_LIST)); + + // Find ReplyTo and MessageID SOAP Header + String replyTo = null; + String messageID = null; + for (Header iter : headers) { + + Object headerObject = iter.getObject(); + + // Unmarshall to org.w3c.dom.Node + if (headerObject instanceof Node) { + Node node = (Node) headerObject; + String localPart = iter.getName().getLocalPart(); + String content = node.getTextContent(); + + // Extract ReplyTo Header value + if ("ReplyTo".equals(localPart)) { + replyTo = content; + } + + // Extract MessageID Header value + if ("MessageID".equals(localPart)) { + messageID = content; + } + } + } + + // Create asynchronous SOAP Response Message + StringBuilder builder = new StringBuilder(); + + builder.append("<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:sch='http://siserver.org/schema'>"); + builder.append(" <soapenv:Header/>"); + builder.append(" <soapenv:Body>"); + builder.append(" <sch:invokeResponse>"); + builder.append(" <sch:MessageID>" + messageID + "</sch:MessageID>"); + + // Insert return parameters into asynchronous SOAP Response Message + for (Entry<String, String> paramIter : returnParameters.entrySet()) { + + String key = paramIter.getKey(); + String value = paramIter.getValue(); + + builder.append(" <" + key + ">" + value + "</" + key +">"); + } + + builder.append(" </sch:invokeResponse>"); + builder.append(" </soapenv:Body>"); + builder.append("</soapenv:Envelope>"); + + // Send SOAP Response Message back to requester + if(replyTo == null) { + System.err.println("No 'ReplyTo' header found!\nTherefore, reply message is printed here:\n" + builder.toString()); + } else { + HighLevelRestApi.Post(replyTo, builder.toString(), ""); + } + } +} diff --git a/winery/org.eclipse.winery.generators.ia/src/main/resources/template/java/TemplateService.java.template b/winery/org.eclipse.winery.generators.ia/src/main/resources/template/java/TemplateService.java.template new file mode 100644 index 0000000..692905e --- /dev/null +++ b/winery/org.eclipse.winery.generators.ia/src/main/resources/template/java/TemplateService.java.template @@ -0,0 +1,17 @@ +package IA_PACKAGE; + +import java.util.HashMap; + +import javax.jws.Oneway; +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; +import javax.xml.bind.annotation.XmlElement; + +@WebService +public class IA_CLASS_NAME extends AbstractIAService { + +GENERATED_WEBSERVICE_METHODS + +}
\ No newline at end of file diff --git a/winery/org.eclipse.winery.generators.ia/src/main/resources/template/project/README.txt b/winery/org.eclipse.winery.generators.ia/src/main/resources/template/project/README.txt new file mode 100644 index 0000000..bce220d --- /dev/null +++ b/winery/org.eclipse.winery.generators.ia/src/main/resources/template/project/README.txt @@ -0,0 +1,61 @@ +########################################################################### +GENERATED IMPLEMENTATION ARTIFACT SKELETON FOR IA_CLASS_NAME + +Interface Name: IA_CLASS_NAME +Namespace: IA_NAMESPACE +Java Package: IA_PACKAGE +URL: IA_ARTIFACT_TEMPLATE_UPLOAD_URL../ +########################################################################### + +##### Preconditions +To develop and build this Implementation Artifact you need Maven and Eclipse. ++ How to install maven is described at the end of this file ++ If you use an Eclipse workspace for the first time with a maven project you've to run this command before starting eclipse: + mvn -Declipse.workspace="<your_workspace_location>" eclipse:configure-workspace + - When using Windows: Make sure you replace '\' (backslashes) with '/' ('slashes') + - It doesn't hurt to run it multiple times + - This command must not be executed in a particular folder + +##### Preparations ++ Unzip the archive generated by Winery into a location of your choice. ++ Note: All following maven commands are executed on a shell in the root folder of the Implementation Artifact. + +##### Create eclipse project +- Run: mvn eclipse:eclipse +- Open Eclipse +- 'File' -> 'Import' -> 'Existing Project into Workspace' -> click 'Next' +- Click 'Browse' and select folder where you unzipped the generated Implementation Artifact +- Select the project from the list and click 'Finish' + +##### Test your Implementation Artifact +- Run: mvn clean package tomcat7:run-war + (more information: http://tomcat.apache.org/maven-plugin-trunk/tomcat7-maven-plugin/plugin-info.html) +- Open this page to see the list of available services: http://localhost:9090/services/ +- This page also links the WSDL +- With the WSDL your're able to test your IA using SOAPui or other tools. + +##### Upload your Implementation Artifact +You have to options to do this: + +### 1) Automatically (to the Winery instance this IA project was generated with) +- Run: mvn deploy +- The WAR is directly uploaded into the correct ArtifactTemplate. Previous versions are overwritten. + +### 2) Manually +- Run: mvn clean package +- Locate the WAR file in the /target folder +- Open Winery in your browser, locate the NodeType and then click through to the Implementation of the respective Interface, its Implementation Artifacts and lastly to the ArtifactTemplate representing this IA. +- Upload the WAR file by clicking on the "Attach file..." button + + +##### Install Maven +- Download latest release of Maven: http://maven.apache.org/download.cgi (Binary zip) +- Unzip into directory of your choice +- Set environment variables (in system environment variables, not the ones for the user account): + + Check that the variables JAVA_HOME and JRE_HOME are set. If not create them and enter the path to your JDK, e.g., C:\Program Files (x86)\Java\jdk1.6.0_21 + + Create the following environment variables + M2_HOME = C:\Path\where\your\maven\was\unzipped\to (no backslash at the end) + M2 = %M2_HOME%\bin + MAVEN_OPTS = -Xms256m -Xmx512m + + Append ;%M2% to the 'Path' environment variable. Make sure to separate the new entry with a semicolon (;) from the last one. +- After that you have to open a new command line windows (if you already opened one) to let the changes take effect.
\ No newline at end of file diff --git a/winery/org.eclipse.winery.generators.ia/src/main/resources/template/project/pom.xml b/winery/org.eclipse.winery.generators.ia/src/main/resources/template/project/pom.xml new file mode 100644 index 0000000..1a0b715 --- /dev/null +++ b/winery/org.eclipse.winery.generators.ia/src/main/resources/template/project/pom.xml @@ -0,0 +1,251 @@ +<?xml version="1.0" encoding="UTF-8"?> +<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>IA_PACKAGE</groupId> + <artifactId>IA_CLASS_NAME</artifactId> + <packaging>war</packaging> + <version>1.0-SNAPSHOT</version> + <name>Implementation Artifact IA_CLASS_NAME</name> + + <repositories> + <repository> + <id>2471.de</id> + <url>http://2471.de/maven2</url> + </repository> + </repositories> + + <properties> + <run.HttpPort>9090</run.HttpPort> + <winery.upload.url>IA_ARTIFACT_TEMPLATE_UPLOAD_URL</winery.upload.url> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <cxf.version>2.7.6</cxf.version> + <highlevelrestapi.version>0.1.6</highlevelrestapi.version> + </properties> + + <dependencies> + <!-- LIBRARIES ADDED FOR IMPLEMENTATION ARTIFACT IMPLEMENTATION --> + + + <!-- END - LIBRARIES ADDED FOR IMPLEMENTATION ARTIFACT IMPLEMENTATION --> + + <dependency> + <groupId>org.eclipse.winery</groupId> + <artifactId>org.eclipse.winery.highlevelrestapi</artifactId> + <version>${highlevelrestapi.version}</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>3.0.7.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>3.0.7.RELEASE</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxws</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-simple</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http</artifactId> + <version>${cxf.version}</version> + </dependency> + </dependencies> + <build> + <finalName>IA_CLASS_NAME</finalName> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.0</version> + <configuration> + <source>1.6</source> + <target>1.6</target> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-eclipse-plugin</artifactId> + <version>2.9</version> + <configuration> + <downloadSources>false</downloadSources> + <downloadJavadocs>true</downloadJavadocs> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-java2ws-plugin</artifactId> + <version>${cxf.version}</version> + <dependencies> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxws</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-simple</artifactId> + <version>${cxf.version}</version> + </dependency> + </dependencies> + <executions> + <execution> + <id>process-classes</id> + <phase>process-classes</phase> + <configuration> + <className>IA_PACKAGE.IA_CLASS_NAME</className> + <outputFile>${basedir}/src/main/webapp/wsdl/IA_CLASS_NAME.wsdl</outputFile> + <genWsdl>true</genWsdl> + <verbose>true</verbose> + </configuration> + <goals> + <goal>java2ws</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <version>2.3</version> + <configuration> + <webXml>src/main/webapp/WEB-INF/web.xml</webXml> + </configuration> + </plugin> + + <!-- Inspired by: http://giallone.blogspot.de/2013/02/post-file-to-web-page-as-part-of-maven.html --> + <plugin> + <groupId>org.codehaus.gmaven</groupId> + <artifactId>gmaven-plugin</artifactId> + <version>1.4</version> + <dependencies> + <dependency> + <groupId>org.codehaus.gmaven.runtime</groupId> + <artifactId>gmaven-runtime-1.7</artifactId> + <version>1.2</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpmime</artifactId> + <version>4.2.1</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore</artifactId> + <version>4.2.1</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>4.2.1</version> + </dependency> + </dependencies> + <executions> + <execution> + <id>upload2winery</id> + <!-- In this mvn phase... --> + <phase>deploy</phase> + <!-- ...run the execute goal of this plugin --> + <goals> + <goal>execute</goal> + </goals> + <configuration> + <providerSelection>1.7</providerSelection> + <source> + import org.apache.http.impl.client.DefaultHttpClient + import org.apache.http.client.methods.HttpPost + import org.apache.http.entity.mime.MultipartEntity + import org.apache.http.entity.mime.content.FileBody + + // Get WAR file + def name = "target/${project.build.finalName}.war" + println "Archive file: $name" + def f = new File(name) + + // POST file + DefaultHttpClient httpclient = new DefaultHttpClient() + println "Upload URL: ${winery.upload.url}" + def post = new HttpPost("${winery.upload.url}") + def entity = new MultipartEntity() + def fileBody = new FileBody(f) + entity.addPart("files[]", fileBody) + post.setEntity(entity) + + // Process response + def response = httpclient.execute(post) + def status = response.getStatusLine() + if( !(status ==~ /.*Created.*/) ) + fail("IA upload to Winery FAILED, please upload manually. (HTTP status code: $status)" ) + else + println "IA upload finished sucessfully (HTTP status code $status)" + </source> + </configuration> + </execution> + </executions> + </plugin> + + </plugins> + + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.tomcat.maven</groupId> + <artifactId>tomcat7-maven-plugin</artifactId> + <version>2.1</version> + <configuration> + <!-- http port --> + <port>${run.HttpPort}</port> + <!-- application path always starts with / --> + <path>/</path> + <!-- if you want to use test dependencies rather than only runtime --> + <useTestClasspath>false</useTestClasspath> + </configuration> + </plugin> + + <!-- Disable default install phase, because we don't install into maven + repo but into Winery (during deploy phase). --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-install-plugin</artifactId> + <executions> + <execution> + <id>default-install</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + + <!-- Disable default deploy phase, because we don't deploy into remote + maven repo but into remote Winery. --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <executions> + <execution> + <id>default-deploy</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + </plugins> + </pluginManagement> + + </build> +</project>
\ No newline at end of file diff --git a/winery/org.eclipse.winery.generators.ia/src/main/resources/template/project/src/main/webapp/WEB-INF/beans.xml b/winery/org.eclipse.winery.generators.ia/src/main/resources/template/project/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000..2a926f2 --- /dev/null +++ b/winery/org.eclipse.winery.generators.ia/src/main/resources/template/project/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> + <import resource="classpath:META-INF/cxf/cxf.xml" /> + <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> + <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> + <jaxws:endpoint xmlns:tns="IA_NAMESPACE" + id="IA_CLASS_NAME" implementor="IA_PACKAGE.IA_CLASS_NAME" + wsdlLocation="wsdl/IA_CLASS_NAME.wsdl" endpointName="tns:IA_CLASS_NAMEPort" + serviceName="tns:IA_CLASS_NAMEService" address="/IA_CLASS_NAMEPort"> + <jaxws:features> + <bean class="org.apache.cxf.feature.LoggingFeature" /> + </jaxws:features> + </jaxws:endpoint> +</beans> diff --git a/winery/org.eclipse.winery.generators.ia/src/main/resources/template/project/src/main/webapp/WEB-INF/web.xml b/winery/org.eclipse.winery.generators.ia/src/main/resources/template/project/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..f7bd1bf --- /dev/null +++ b/winery/org.eclipse.winery.generators.ia/src/main/resources/template/project/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> + <display-name>IA_CLASS_NAME</display-name> + <welcome-file-list> + <welcome-file>index.html</welcome-file> + <welcome-file>index.htm</welcome-file> + <welcome-file>index.jsp</welcome-file> + <welcome-file>default.html</welcome-file> + <welcome-file>default.htm</welcome-file> + <welcome-file>default.jsp</welcome-file> + </welcome-file-list> + <servlet> + <description>Apache CXF Endpoint</description> + <display-name>cxf</display-name> + <servlet-name>cxf</servlet-name> + <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>cxf</servlet-name> + <url-pattern>/services/*</url-pattern> + </servlet-mapping> + <session-config> + <session-timeout>60</session-timeout> + </session-config> + <context-param> + <param-name>contextConfigLocation</param-name> + <param-value>WEB-INF/beans.xml</param-value> + </context-param> + <listener> + <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> + </listener> +</web-app> |