Skip to content

Commit

Permalink
Merge pull request #247 from erdlet/246-remove-cxf
Browse files Browse the repository at this point in the history
246 remove cxf
  • Loading branch information
Tobias Erdle committed Apr 17, 2021
2 parents a8cfb03 + 4d976d4 commit 96a839e
Show file tree
Hide file tree
Showing 24 changed files with 79 additions and 572 deletions.
14 changes: 0 additions & 14 deletions .travis/docker-tomee.sh

This file was deleted.

43 changes: 14 additions & 29 deletions .travis/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,13 @@ elif [[ ${1} == tck-wildfly22* ]]; then
mvn -B -V -Dtck-env=wildfly verify ${BUILD_PROFILE}
popd

elif [ "${1}" == "tck-tomee" ]; then

mvn -B -V -DskipTests clean install ${BUILD_PROFILE}
pushd tck
mvn -B -V -Dtck-env=tomee verify ${BUILD_PROFILE}
popd

elif [ "${1}" == "tck-liberty" ]; then

source .travis/install-liberty.sh
mvn -B -V -DskipTests clean install ${BUILD_PROFILE}
pushd tck
mvn -B -V -Dtck-env=liberty -Dliberty.home=${LIBERTY_HOME} verify ${BUILD_PROFILE}
popd
#elif [ "${1}" == "tck-liberty" ]; then
#
# source .travis/install-liberty.sh
# mvn -B -V -DskipTests clean install ${BUILD_PROFILE}
# pushd tck
# mvn -B -V -Dtck-env=liberty -Dliberty.home=${LIBERTY_HOME} verify ${BUILD_PROFILE}
# popd

elif [[ ${1} == testsuite-wildfly ]]; then

Expand All @@ -120,21 +113,13 @@ elif [[ ${1} == testsuite-payara ]]; then
echo "Running test suite on Payara"
mvn -P${TYPE} --projects testsuite clean verify ${BUILD_PROFILE}

elif [[ ${1} == testsuite-tomee ]]; then

source .travis/docker-tomee.sh
echo "Building Krazo..."
mvn -B -V -DskipTests clean install ${BUILD_PROFILE}
echo "Running test suite on TomEE"
mvn -P${TYPE} --projects testsuite clean verify ${BUILD_PROFILE}

elif [[ ${1} == testsuite-liberty ]]; then

source .travis/install-liberty.sh && mvn -P${TYPE} -Dliberty.home=${LIBERTY_HOME} --projects testsuite clean verify ${BUILD_PROFILE}
echo "Building Krazo..."
mvn -B -V -DskipTests clean install ${BUILD_PROFILE}
echo "Running test suite on Liberty"
mvn -P${TYPE} -Dliberty.home=${LIBERTY_HOME} --projects testsuite clean verify ${BUILD_PROFILE}
# elif [[ ${1} == testsuite-liberty ]]; then
#
# source .travis/install-liberty.sh && mvn -P${TYPE} -Dliberty.home=${LIBERTY_HOME} --projects testsuite clean verify ${BUILD_PROFILE}
# echo "Building Krazo..."
# mvn -B -V -DskipTests clean install ${BUILD_PROFILE}
# echo "Running test suite on Liberty"
# mvn -P${TYPE} -Dliberty.home=${LIBERTY_HOME} --projects testsuite clean verify ${BUILD_PROFILE}

elif [[ ${1} == testsuite-glassfish ]]; then

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Thanks for your interest in this project.
## Project description

Eclipse Krazo is an implementation of action-based MVC specifiec by MVC 1.0 (JSR-371).
It builds on top of JAX-RS and currently contains support for RESTEasy, Jersey and CXF
It builds on top of JAX-RS and currently contains support for RESTEasy and Jersey
with a well-defined SPI for other implementations.

## Developer resources
Expand Down
24 changes: 5 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Eclipse Krazo

Eclipse Krazo is an implementation of action-based MVC specified by Jakarta MVC 2.0. It builds on top of Jakarta RESTful Webservices
and currently contains support for RESTEasy, Jersey and CXF with a well-defined SPI for other implementations.
and currently contains support for RESTEasy and Jersey with a well-defined SPI for other implementations.

## Running the testsuite

Expand All @@ -12,8 +12,7 @@ The following sections describe how you test Eclipse Krazo against them. At the

- Glassfish 8
- WildFly 22.x.x
- TomEE 10.x
- OpenLiberty 20.0.0.12
- OpenLiberty 21.*

### Preconditions
- JDK 11
Expand All @@ -33,25 +32,12 @@ To run the Krazo testsuite with WildFly, you need to follow these steps:
2. Start WildFly with `sh standalone.sh --debug`. This enables you to remote-debug the Arquillian tests.
3. Go into the `testsuite` package of Eclipse Krazo and execute `mvn clean integration-test -Ptestsuite-wildfly`

### TomEE
To run the Krazo testsuite with TomEE, you need to follow these steps:
1. Download TomEE from the TomEE [download page](https://tomee.apache.org/download-ng.html) and unzip it somewhere you'll find it again.
2. Overwrite or enable the following settings in `${TOMEE_HOME}/conf/system.properties` to get Arquillian to run:
```
tomee.remote.support=true
tomee.serialization.class.blacklist=-
openejb.system.apps = true
```
3. Start TomEE with `sh catalina.sh jpda start`. This enables you to remote-debug the Arquillian tests.
4. Go into the `testsuite` package of Eclipse Krazo and execute `mvn clean integration-test -Ptestsuite-tomee`

### OpenLiberty
To run the Krazo testsuite with OpenLiberty, you need to follow these steps. Please note that this process has been tested with 20.x only.

1. Download OpenLiberty from the [official download page](https://openliberty.io/downloads/) and unzip it.
2. Replace the file `wlp/templates/servers/defaultServer/server.xml` with `.travis/wlp-server-template.xml` from the Eclipse Krazo repository.
3. Go into the `testsuite` package of Eclipse Krazo and execute `mvn clean integration-test -Ptestsuite-glassfish -Dliberty.home=c:/somewhere/wlp/`.
Please make sure to replace `c:/somewhere/wlp/` with the absolute path to the unpacked OpenLiberty distribution.
Download OpenLiberty from the official download page and unzip it.
Replace the file `wlp/templates/servers/defaultServer/server.xml` with `.travis/wlp-server-template.xml` from the Eclipse Krazo repository.
Go into the testsuite package of Eclipse Krazo and execute `mvn clean integration-test -Ptestsuite-liberty -Dliberty.home=c:/somewhere/wlp/`. Please make sure to replace c:/somewhere/wlp/ with the absolute path to the unpacked OpenLiberty distribution.

### Troubleshooting

Expand Down
6 changes: 0 additions & 6 deletions archetype/src/main/resources/archetype-resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@
<artifactId>krazo-resteasy</artifactId>
<version>\${krazo.version}</version>
</dependency>
#elseif (${krazoImpl} == 'cxf')
<dependency>
<groupId>org.eclipse.krazo</groupId>
<artifactId>krazo-cxf</artifactId>
<version>\${krazo.version}</version>
</dependency>
#else
<dependency>
<groupId>org.eclipse.krazo</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019 Eclipse Krazo committers and contributors
* Copyright (c) 2018, 2021 Eclipse Krazo committers and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,12 +47,6 @@ public boolean configure(FeatureContext context) {
// RESTEasy seems to ignore @ConstrainedTo in some cases
if (context.getConfiguration().getRuntimeType() == RuntimeType.SERVER) {

// https://issues.apache.org/jira/browse/CXF-7501
// https://issues.apache.org/jira/browse/TOMEE-2122
if (servletContext == null) {
log.warning("The ServletContext wasn't injected into the JAX-RS Feature class");
}

Initializer.initialize(context, servletContext);
return true;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019 Eclipse Krazo committers and contributors
* Copyright (c) 2018, 2021 Eclipse Krazo committers and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,10 @@
*/
package org.eclipse.krazo.bootstrap;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import org.eclipse.krazo.binding.convert.MvcConverterProvider;
import org.eclipse.krazo.core.ViewResponseFilter;
import org.eclipse.krazo.core.ViewableWriter;
Expand All @@ -26,13 +30,8 @@
import org.eclipse.krazo.security.CsrfExceptionMapper;
import org.eclipse.krazo.security.CsrfProtectFilter;
import org.eclipse.krazo.security.CsrfValidateFilter;
import org.eclipse.krazo.util.CdiUtils;

import jakarta.ws.rs.core.FeatureContext;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* Implementation of ConfigProvider which registers all providers of the core module.
Expand Down Expand Up @@ -61,30 +60,7 @@ public void configure(FeatureContext context) {
}

private void register(FeatureContext context, Class<?> providerClass) {

boolean isCxf = context.getClass().getName().startsWith("org.apache.cxf");

/*
* With CXF there is no CDI injection if JAX-RS providers are registered via
* context.register(Class). So we try to lookup provider instances from CDI
* and register them instead.
* See: https://issues.apache.org/jira/browse/CXF-7501
*/
if (isCxf) {
List<?> providerInstances = CdiUtils.getApplicationBeans(providerClass);
if (!providerInstances.isEmpty()) {
context.register(providerInstances.get(0));
} else {
context.register(providerClass);
}
}

// will work for all other containers
else {
context.register(providerClass);
}


context.register(providerClass);
}

}
12 changes: 5 additions & 7 deletions core/src/main/java/org/eclipse/krazo/bootstrap/Initializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@
*/
package org.eclipse.krazo.bootstrap;

import java.util.Objects;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.eclipse.krazo.core.ViewResponseFilter;
import org.eclipse.krazo.servlet.KrazoContainerInitializer;
import org.eclipse.krazo.util.ServiceLoaders;

import jakarta.servlet.ServletContext;
import jakarta.ws.rs.core.Configuration;
import jakarta.ws.rs.core.FeatureContext;
import java.util.Objects;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* Main class for triggering initialization of Eclipse Krazo
Expand Down Expand Up @@ -71,9 +72,6 @@ private static boolean isAlreadyInitialized(Configuration config) {
return config.isRegistered(ViewResponseFilter.class);
}

/**
* Note: ServletContext may be null here, because CXF doesn't inject it correctly
*/
private static boolean isMvcApplication(ServletContext servletContext) {

// we fall back to enable Krazo if detection didn't work
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import static org.eclipse.krazo.util.PathUtils.noPrefix;
import static org.eclipse.krazo.util.PathUtils.noStartingSlash;

import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URI;
import java.util.Arrays;
Expand All @@ -37,6 +36,11 @@
import java.util.logging.Logger;
import java.util.stream.Collectors;

import org.eclipse.krazo.KrazoConfig;
import org.eclipse.krazo.engine.Viewable;
import org.eclipse.krazo.event.ControllerRedirectEventImpl;
import org.eclipse.krazo.lifecycle.RequestLifecycle;

import jakarta.annotation.Priority;
import jakarta.enterprise.event.Event;
import jakarta.inject.Inject;
Expand All @@ -60,11 +64,6 @@
import jakarta.ws.rs.core.UriInfo;
import jakarta.ws.rs.core.Variant;

import org.eclipse.krazo.KrazoConfig;
import org.eclipse.krazo.engine.Viewable;
import org.eclipse.krazo.event.ControllerRedirectEventImpl;
import org.eclipse.krazo.lifecycle.RequestLifecycle;

/**
* <p>A JAX-RS response filter that fires a {@link jakarta.mvc.event.AfterControllerEvent}
* event. It also verifies the static return type of the controller method is correct,
Expand Down Expand Up @@ -155,7 +154,6 @@ public void filter(ContainerRequestContext requestContext,
// If the entity is null the status will be set to 204 by Jersey. For void methods we need to
// set the status to 200 unless no other status was set by e.g. throwing an Exception.

// Don't use equals() on the result of getStatusInfo(), because it doesn't work on CXF
if (responseContext.getStatusInfo().getStatusCode() == Response.Status.NO_CONTENT.getStatusCode()) {
responseContext.setStatusInfo(Response.Status.OK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
package org.eclipse.krazo.jaxrs;

import org.eclipse.krazo.util.CdiUtils;

import jakarta.annotation.Priority;
import jakarta.mvc.Controller;
import jakarta.servlet.http.HttpServletRequest;
Expand All @@ -30,7 +28,6 @@
import jakarta.ws.rs.core.Configuration;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.UriInfo;
import java.io.IOException;

/**
* Post-Matching ContainerRequestFilter
Expand Down Expand Up @@ -59,16 +56,12 @@ public class PostMatchingRequestFilter implements ContainerRequestFilter {
@Context
private ResourceInfo resourceInfo;

@Context
private JaxRsContextProducer contextProducer;

@Override
public void filter(ContainerRequestContext requestContext) {

/*
* Please note that we CANNOT inject JaxRsContextProducer here, because this will
* fail on TomEE/CXF/OWB because processing @Context fails for some reason.
*/
JaxRsContextProducer contextProducer = CdiUtils.getApplicationBean(JaxRsContextProducer.class)
.orElseThrow(() -> new IllegalStateException("Cannot find CDI managed JaxRsContextProducer"));

// store JAX-RS context objects so we can produce them via CDI
contextProducer.setConfiguration(configuration);
contextProducer.setRequest(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,12 @@ public class PreMatchingRequestFilter implements ContainerRequestFilter {
@Context
private UriInfo uriInfo;

@Context
private JaxRsContextProducer contextProducer;

@Override
public void filter(ContainerRequestContext requestContext) {

/*
* Please note that we CANNOT inject JaxRsContextProducer here, because this will
* fail on TomEE/CXF/OWB because processing @Context fails for some reason.
*/
JaxRsContextProducer contextProducer = CdiUtils.getApplicationBean(JaxRsContextProducer.class)
.orElseThrow(() -> new IllegalStateException("Cannot find CDI managed JaxRsContextProducer"));

// store JAX-RS context objects so we can produce them via CDI
contextProducer.setConfiguration(configuration);
contextProducer.setRequest(request);
Expand Down
Loading

0 comments on commit 96a839e

Please sign in to comment.