cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [2/4] cxf git commit: Created a jaxrs_spring_boot example
Date Fri, 22 May 2015 13:40:13 GMT
Created  a jaxrs_spring_boot  example

jaxrs spring boot simple example developed.


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/1214338f
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/1214338f
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/1214338f

Branch: refs/heads/master
Commit: 1214338f24a3a7973f2bd72ca01fc57644bcc45a
Parents: 34e083d
Author: elans3 <elans3.java@gmail.com>
Authored: Thu May 21 23:30:21 2015 -0500
Committer: elans3 <elans3.java@gmail.com>
Committed: Thu May 21 23:30:21 2015 -0500

----------------------------------------------------------------------
 .../release/samples/jaxrs_spring_boot/README    |  13 ++
 .../release/samples/jaxrs_spring_boot/pom.xml   | 129 +++++++++++++++++++
 .../java/sample/rs/service/HelloService.java    |  18 +++
 .../rs/service/SampleRestWSApplication.java     |  56 ++++++++
 4 files changed, 216 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/1214338f/distribution/src/main/release/samples/jaxrs_spring_boot/README
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxrs_spring_boot/README b/distribution/src/main/release/samples/jaxrs_spring_boot/README
new file mode 100644
index 0000000..c9487d7
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxrs_spring_boot/README
@@ -0,0 +1,13 @@
+== Spring Boot - Samples - CXF Rest Web Services 
+
+This sample project demonstrates how to use http://projects.spring.io/spring-rs-cxf/[CXF
Rest Web Services]
+with Spring Boot. 
+
+The sample uses Maven. It can be built and run from the command line:
+
+----
+$ mvn spring-boot:run
+----
+
+http://localhost:8080/services/helloservice/sayHello/Elan  will now display the output in
the browser
+like "Hello Elan, Welcome to CXF RS Spring Boot World!!!"

http://git-wip-us.apache.org/repos/asf/cxf/blob/1214338f/distribution/src/main/release/samples/jaxrs_spring_boot/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxrs_spring_boot/pom.xml b/distribution/src/main/release/samples/jaxrs_spring_boot/pom.xml
new file mode 100644
index 0000000..0cb276d
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxrs_spring_boot/pom.xml
@@ -0,0 +1,129 @@
+<?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/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-samples</artifactId>
+		<version>1.3.0.BUILD-SNAPSHOT</version>
+	</parent>
+	<artifactId>spring-boot-sample-rs-cxf</artifactId>
+	<name>Spring Boot Web Services Sample</name>
+	<description>Spring Boot CXF Restful Web Services Sample</description>
+	<url>http://projects.spring.io/spring-boot/</url>
+	<properties>
+		<main.basedir>${basedir}/../..</main.basedir>
+		<cxf.version>3.0.0</cxf.version>
+		<spring.version>4.2.0.BUILD-SNAPSHOT</spring.version>
+		<jackson.version>2.3.0</jackson.version>
+		<jetty.version>8.1.5.v20120716</jetty.version>
+		<java.version>1.7</java.version>
+		<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
+	</properties>
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-context</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-web</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-beans</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-core</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-rt-frontend-jaxrs</artifactId>
+			<version>${cxf.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-rt-transports-http</artifactId>
+			<version>${cxf.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>com.fasterxml.jackson.core</groupId>
+			<artifactId>jackson-core</artifactId>
+			<version>${jackson.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>com.fasterxml.jackson.core</groupId>
+			<artifactId>jackson-databind</artifactId>
+			<version>${jackson.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>com.fasterxml.jackson.jaxrs</groupId>
+			<artifactId>jackson-jaxrs-json-provider</artifactId>
+			<version>${jackson.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>com.fasterxml.jackson.core</groupId>
+			<artifactId>jackson-annotations</artifactId>
+			<version>${jackson.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-bundle-jaxrs</artifactId>
+			<version>2.7.14</version>
+		</dependency>
+		<dependency>
+			<groupId>org.eclipse.jetty</groupId>
+			<artifactId>jetty-server</artifactId>
+			<version>${jetty.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.eclipse.jetty</groupId>
+			<artifactId>jetty-servlet</artifactId>
+			<version>${jetty.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.eclipse.jetty</groupId>
+			<artifactId>jetty-webapp</artifactId>
+			<version>${jetty.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.eclipse.jetty</groupId>
+			<artifactId>jetty-servlets</artifactId>
+			<version>${jetty.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-web</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-rt-rs-service-description</artifactId>
+			<version>3.0.0-milestone1</version>
+		</dependency>
+	</dependencies>
+	<build>
+		<plugins>
+
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
+</project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/1214338f/distribution/src/main/release/samples/jaxrs_spring_boot/src/main/java/sample/rs/service/HelloService.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxrs_spring_boot/src/main/java/sample/rs/service/HelloService.java
b/distribution/src/main/release/samples/jaxrs_spring_boot/src/main/java/sample/rs/service/HelloService.java
new file mode 100644
index 0000000..72e2a66
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxrs_spring_boot/src/main/java/sample/rs/service/HelloService.java
@@ -0,0 +1,18 @@
+package sample.rs.service;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+ 
+@Path("/sayHello")
+public class HelloService {
+ 
+    @GET
+    @Path("/{a}")
+    @Produces(MediaType.TEXT_PLAIN)
+    public String sayHello(@PathParam("a") String a) {
+        return "Hello "+a+", Welcome to CXF RS Spring Boot World!!!";
+    }
+    
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/1214338f/distribution/src/main/release/samples/jaxrs_spring_boot/src/main/java/sample/rs/service/SampleRestWSApplication.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxrs_spring_boot/src/main/java/sample/rs/service/SampleRestWSApplication.java
b/distribution/src/main/release/samples/jaxrs_spring_boot/src/main/java/sample/rs/service/SampleRestWSApplication.java
new file mode 100644
index 0000000..5bd90db
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxrs_spring_boot/src/main/java/sample/rs/service/SampleRestWSApplication.java
@@ -0,0 +1,56 @@
+package sample.rs.service;
+import org.apache.cxf.Bus;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.transport.servlet.CXFServlet;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
+import org.springframework.boot.context.embedded.ServletRegistrationBean;
+import org.springframework.boot.context.web.SpringBootServletInitializer;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.ImportResource;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.bus.spring.SpringBus;
+import sample.rs.service.HelloService;
+import org.apache.cxf.jaxrs.JAXRSBindingFactory;
+
+@Configuration
+@EnableAutoConfiguration
+@ImportResource({ "classpath:META-INF/cxf/cxf.xml" })
+public class SampleRestWSApplication extends SpringBootServletInitializer {
+ 
+    @Autowired
+    private ApplicationContext applicationContext;
+ 
+    public static void main(String[] args) {
+        SpringApplication.run(SampleRestWSApplication.class, args);
+    }
+ 
+    @Bean
+    public ServletRegistrationBean servletRegistrationBean(ApplicationContext context) {
+        return new ServletRegistrationBean(new CXFServlet(), "/services/*");
+    }
+ 
+    
+    @Bean
+    public Server rsServer() {
+        Bus bus = (Bus) applicationContext.getBean(Bus.DEFAULT_BUS_ID);
+        JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
+        endpoint.setServiceBean(new HelloService());
+        endpoint.setAddress("/helloservice");
+        endpoint.setBus(bus);
+        return endpoint.create();
+    }
+ 
+    @Override
+	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+		return application.sources(SampleRestWSApplication.class);
+	}
+ 
+}
\ No newline at end of file


Mime
View raw message