This is an automated email from the ASF dual-hosted git repository.
ffang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 10a503016b1 [CAMEL-21548]camel-cxf - Upgrade to 4.1
10a503016b1 is described below
commit 10a503016b160ab70923d97fbd3f8999bcb51713
Author: Freeman Fang <[email protected]>
AuthorDate: Mon Dec 16 09:54:46 2024 -0500
[CAMEL-21548]camel-cxf - Upgrade to 4.1
---
.../cxf/jaxrs/testbean/CustomerService.java | 105 ++-------------------
...stomerService.java => CustomerServiceImpl.java} | 33 ++-----
parent/pom.xml | 2 +-
3 files changed, 20 insertions(+), 120 deletions(-)
diff --git
a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java
b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java
index ae95e743fe7..789d6a29132 100644
---
a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java
+++
b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java
@@ -16,11 +16,7 @@
*/
package org.apache.camel.component.cxf.jaxrs.testbean;
-import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
@@ -32,122 +28,39 @@ import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Response;
-import org.apache.cxf.common.util.StringUtils;
-
@Path("/customerservice/")
-public class CustomerService {
- private final AtomicLong currentId = new AtomicLong(123L);
- private final Map<Long, Customer> customers = new ConcurrentHashMap<>();
- private final Map<Long, Order> orders = new ConcurrentHashMap<>();
-
- public CustomerService() {
- init();
- }
+public interface CustomerService {
@GET
@Path("/customers/{id}/")
- public Customer getCustomer(@PathParam("id") String id) {
- long idNumber = Long.parseLong(id);
- Customer c = customers.get(idNumber);
- return c;
- }
+ public Customer getCustomer(@PathParam("id") String id);
@GET
@Path("/customers")
- public Customer getCustomerByQueryParam(@QueryParam("id") String id) {
- long idNumber = Long.parseLong(id);
- Customer c = customers.get(idNumber);
- return c;
- }
+ public Customer getCustomerByQueryParam(@QueryParam("id") String id);
@GET
@Path("/customers/")
@Produces("application/xml")
- public List<Customer> getCustomers() {
- List<Customer> list = new ArrayList<>(customers.values());
- return list;
- }
+ public List<Customer> getCustomers();
@PUT
@Path("/customers/")
- public Response updateCustomer(Customer customer) {
- Customer c = customers.get(customer.getId());
- Response r;
- if (c != null) {
- customers.put(customer.getId(), customer);
- r = Response.ok().build();
- } else {
- r = Response.status(406).entity("Cannot find the
customer!").build();
- }
-
- return r;
- }
+ public Response updateCustomer(Customer customer);
@POST
@Path("/customers/")
- public Response addCustomer(Customer customer) {
- if (StringUtils.isEmpty(customer.getName())) {
- return Response.status(422).build();
- }
-
- customer.setId(currentId.incrementAndGet());
-
- customers.put(customer.getId(), customer);
-
- return Response.ok(customer).build();
- }
+ public Response addCustomer(Customer customer);
@POST
@Path("/customersUniqueResponseCode/")
- public Response addCustomerUniqueResponseCode(Customer customer) {
- customer.setId(currentId.incrementAndGet());
-
- customers.put(customer.getId(), customer);
-
- return Response.status(201).entity(customer).build();
- }
+ public Response addCustomerUniqueResponseCode(Customer customer);
@DELETE
@Path("/customers/{id}/")
- public Response deleteCustomer(@PathParam("id") String id) {
- long idNumber = Long.parseLong(id);
- Customer c = customers.get(idNumber);
-
- Response r;
- if (c != null) {
- r = Response.ok().build();
- customers.remove(idNumber);
- } else {
- r = Response.notModified().build();
- }
- if (idNumber == currentId.get()) {
- currentId.decrementAndGet();
- }
- return r;
- }
+ public Response deleteCustomer(@PathParam("id") String id);
@Path("/orders/{orderId}/")
- public Order getOrder(@PathParam("orderId") String orderId) {
- long idNumber = Long.parseLong(orderId);
- Order c = orders.get(idNumber);
- return c;
- }
-
- final void init() {
- Customer c = new Customer();
- c.setName("John");
- c.setId(123);
- customers.put(c.getId(), c);
-
- c = new Customer();
- c.setName("Dan");
- c.setId(113);
- customers.put(c.getId(), c);
-
- Order o = new Order();
- o.setDescription("order 223");
- o.setId(223);
- orders.put(o.getId(), o);
- }
+ public Order getOrder(@PathParam("orderId") String orderId);
}
diff --git
a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java
b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceImpl.java
similarity index 88%
copy from
components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java
copy to
components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceImpl.java
index ae95e743fe7..94001858d26 100644
---
a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java
+++
b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceImpl.java
@@ -22,54 +22,44 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
-import jakarta.ws.rs.DELETE;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Response;
import org.apache.cxf.common.util.StringUtils;
@Path("/customerservice/")
-public class CustomerService {
+public class CustomerServiceImpl implements CustomerService {
private final AtomicLong currentId = new AtomicLong(123L);
private final Map<Long, Customer> customers = new ConcurrentHashMap<>();
private final Map<Long, Order> orders = new ConcurrentHashMap<>();
- public CustomerService() {
+ public CustomerServiceImpl() {
init();
}
- @GET
- @Path("/customers/{id}/")
+ @Override
public Customer getCustomer(@PathParam("id") String id) {
long idNumber = Long.parseLong(id);
Customer c = customers.get(idNumber);
return c;
}
- @GET
- @Path("/customers")
+ @Override
public Customer getCustomerByQueryParam(@QueryParam("id") String id) {
long idNumber = Long.parseLong(id);
Customer c = customers.get(idNumber);
return c;
}
- @GET
- @Path("/customers/")
- @Produces("application/xml")
+ @Override
public List<Customer> getCustomers() {
List<Customer> list = new ArrayList<>(customers.values());
return list;
}
- @PUT
- @Path("/customers/")
+ @Override
public Response updateCustomer(Customer customer) {
Customer c = customers.get(customer.getId());
Response r;
@@ -83,8 +73,7 @@ public class CustomerService {
return r;
}
- @POST
- @Path("/customers/")
+ @Override
public Response addCustomer(Customer customer) {
if (StringUtils.isEmpty(customer.getName())) {
return Response.status(422).build();
@@ -97,8 +86,7 @@ public class CustomerService {
return Response.ok(customer).build();
}
- @POST
- @Path("/customersUniqueResponseCode/")
+ @Override
public Response addCustomerUniqueResponseCode(Customer customer) {
customer.setId(currentId.incrementAndGet());
@@ -107,8 +95,7 @@ public class CustomerService {
return Response.status(201).entity(customer).build();
}
- @DELETE
- @Path("/customers/{id}/")
+ @Override
public Response deleteCustomer(@PathParam("id") String id) {
long idNumber = Long.parseLong(id);
Customer c = customers.get(idNumber);
@@ -126,7 +113,7 @@ public class CustomerService {
return r;
}
- @Path("/orders/{orderId}/")
+ @Override
public Order getOrder(@PathParam("orderId") String orderId) {
long idNumber = Long.parseLong(orderId);
Order c = orders.get(idNumber);
diff --git a/parent/pom.xml b/parent/pom.xml
index 624e575fb3a..da69752bf49 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -125,7 +125,7 @@
<cobertura-maven-plugin-version>2.7</cobertura-maven-plugin-version>
<couchbase-client-version>3.7.6</couchbase-client-version>
<curator-version>5.7.1</curator-version>
- <cxf-version>4.0.6</cxf-version>
+ <cxf-version>4.1.0</cxf-version>
<cxf-codegen-plugin-version>4.0.6</cxf-codegen-plugin-version>
<!-- cxf-xjc is not released as often -->
<cxf-xjc-plugin-version>4.0.2</cxf-xjc-plugin-version>