Skip to content

Commit

Permalink
[#1802] Quickly move all JSF related modules to jakarta (this needs t…
Browse files Browse the repository at this point in the history
…o be verified later. for now it just compiles)
  • Loading branch information
grgrzybek committed Nov 14, 2023
1 parent 829f544 commit b56a48f
Show file tree
Hide file tree
Showing 31 changed files with 118 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,6 @@ protected Option[] paxWebCore() {
// .versionAsInProject().startLevel(START_LEVEL_TEST_BUNDLE - 2).noStart(),
mavenBundle("jakarta.servlet", "jakarta.servlet-api")
.versionAsInProject().startLevel(START_LEVEL_TEST_BUNDLE - 1),
// mavenBundle("org.osgi", "org.osgi.service.servlet")
// .versionAsInProject().startLevel(START_LEVEL_TEST_BUNDLE - 1).start(),
mavenBundle("org.ops4j.pax.web", "pax-web-api")
.versionAsInProject().startLevel(START_LEVEL_TEST_BUNDLE - 1).start(),
mavenBundle("org.ops4j.pax.web", "pax-web-spi")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,7 @@
*/
package org.ops4j.pax.web.itest.container.war.jsf;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Collection;
import javax.faces.application.Resource;
import javax.faces.context.FacesContext;

import jakarta.faces.application.Resource;
import org.junit.Test;
import org.ops4j.pax.web.itest.container.AbstractContainerTestBase;
import org.ops4j.pax.web.itest.utils.WaitCondition;
Expand All @@ -47,6 +36,16 @@
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Collection;

import static org.junit.Assert.fail;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.web.itest.utils.assertion.Assert.assertThat;
Expand Down Expand Up @@ -113,7 +112,7 @@ public void testServiceOverride() {
* </ul>
* </li>
* <li>
* Test {@link org.ops4j.pax.web.resources.jsf.OsgiResource#userAgentNeedsUpdate(FacesContext)}
* Test {@code org.ops4j.pax.web.resources.jsf.OsgiResource#userAgentNeedsUpdate(FacesContext)}
* with an If-Modified-Since header
* </li>
* <li>Test servletmapping with prefix (faces/*) rather than extension for both, page and image serving</li>
Expand Down Expand Up @@ -225,11 +224,11 @@ protected boolean isFulfilled() {
resp -> resp.contains("/osgi-resourcehandler-myfaces/faces/javax.faces.resource/images/iceland.jpg?type=osgi&amp;ln=default&amp;lv=2_0"))
.doGETandExecuteTest(pageUrlWithPrefixMapping);

try {
testResourceUnavailble();
fail("Expected IOException");
} catch (IOException ignored) {
}
// try {
// testResourceUnavailble();
// fail("Expected IOException");
// } catch (IOException ignored) {
// }
}

/**
Expand All @@ -244,7 +243,7 @@ protected boolean isFulfilled() {
* <p>
* According to the spec, IOException is the only one catched later on.
*/
// @Test(expected = IOException.class)
@Test(expected = IOException.class)
public void testResourceUnavailble() throws Exception {
ServiceReference<OsgiResourceLocator> sr = context.getServiceReference(OsgiResourceLocator.class);
OsgiResourceLocator resourceLocator = context.getService(sr);
Expand Down
2 changes: 1 addition & 1 deletion pax-web-resources/pax-web-resources-jsf/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ The implementation makes use of the standard JSF-ResourceHandler-API. Just enabl
A service with the interface `org.ops4j.pax.web.resource.api.OsgiResourceLocator` must be available in the framework. The default implementation is provided via [pax-web-resources-extender](../pax-web-resources-extender).


There is no coupling to Myfaces, nor Mojarra. Only `javax.faces` is used.
There is no coupling to Myfaces, nor Mojarra. Only `jakarta.faces` is used.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.faces.application.ProjectStage;
import javax.faces.application.Resource;
import javax.faces.application.ResourceHandler;
import javax.faces.context.FacesContext;
import jakarta.faces.application.ProjectStage;
import jakarta.faces.application.Resource;
import jakarta.faces.application.ResourceHandler;
import jakarta.faces.context.FacesContext;

import org.apache.commons.lang3.StringUtils;
import org.ops4j.pax.web.resources.jsf.internal.FacesServletMapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
import java.util.Optional;
import java.util.function.Function;

import javax.faces.application.Resource;
import javax.faces.application.ResourceHandler;
import javax.faces.application.ResourceHandlerWrapper;
import javax.faces.application.ViewResource;
import javax.faces.context.FacesContext;
import jakarta.faces.application.Resource;
import jakarta.faces.application.ResourceHandler;
import jakarta.faces.application.ResourceHandlerWrapper;
import jakarta.faces.application.ViewResource;
import jakarta.faces.context.FacesContext;
import jakarta.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import java.util.Optional;
import java.util.PropertyResourceBundle;

import javax.faces.application.Resource;
import javax.faces.application.ResourceHandler;
import javax.faces.application.ResourceWrapper;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import jakarta.faces.application.Resource;
import jakarta.faces.application.ResourceHandler;
import jakarta.faces.application.ResourceWrapper;
import jakarta.faces.context.ExternalContext;
import jakarta.faces.context.FacesContext;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletResponseWrapper;
import jakarta.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -152,9 +152,9 @@ public static String calculateResourceBasePath(FacesContext facesContext) {
if (mapping.isExtensionMapping()) {
// Mapping using a suffix. In this case we have to strip
// the suffix. If we have a url like:
// http://localhost:8080/testjsf20/javax.faces.resource/imagen.jpg.jsf?ln=dojo
// http://localhost:8080/testjsf20/jakarta.faces.resource/imagen.jpg.jsf?ln=dojo
//
// The servlet path is /javax.faces.resource/imagen.jpg.jsf
// The servlet path is /jakarta.faces.resource/imagen.jpg.jsf
//
// For obtain the resource name we have to remove the .jsf
// suffix and
Expand All @@ -167,10 +167,10 @@ public static String calculateResourceBasePath(FacesContext facesContext) {
} else {
// Mapping using prefix. In this case we have to strip
// the prefix used for mapping. If we have a url like:
// http://localhost:8080/testjsf20/faces/javax.faces.resource/imagen.jpg?ln=dojo
// http://localhost:8080/testjsf20/faces/jakarta.faces.resource/imagen.jpg?ln=dojo
//
// The servlet path is /faces
// and the path info is /javax.faces.resource/imagen.jpg
// and the path info is /jakarta.faces.resource/imagen.jpg
//
// For obtain the resource name we have to remove the /faces
// prefix and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.ops4j.pax.web.resources.jsf.internal;

import javax.faces.context.ExternalContext;
import jakarta.faces.context.ExternalContext;

/**
* Utilities to handle web.xml
Expand Down
5 changes: 5 additions & 0 deletions samples/samples-jsf/jsf-primefaces-embedded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>

<!-- Other -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
*/
package org.ops4j.pax.web.samples.primefaces;

// According to "5.4 Managed Bean Annotations" of JSF 2.3 specification,javax.faces.bean package
// According to "5.4 Managed Bean Annotations" of JSF 2.3 specification,jakarta.faces.bean package
// is deprecated and the recommended annotations should be taken from CDI 1.2

@SuppressWarnings("deprecation")
@javax.faces.bean.ManagedBean(name = "helloWorld")
@javax.faces.bean.SessionScoped
public class HelloWorldController {
import java.io.Serializable;

@jakarta.inject.Named("helloWorld")
@jakarta.enterprise.context.SessionScoped
public class HelloWorldController implements Serializable {

private String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
</servlet>

<servlet-mapping>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<Bundle-SymbolicName>jsf-resourcehandler-myfaces</Bundle-SymbolicName>
<Import-Package>
org.ops4j.pax.web.resources.jsf,
javax.faces.webapp
jakarta.faces.webapp
</Import-Package>
<Require-Bundle>
org.apache.myfaces.core.impl
Expand Down Expand Up @@ -90,6 +90,12 @@
<dependency>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>

<!-- Other -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
*/
package org.ops4j.pax.web.jsf.resourcehandler.itest.application.myfaces;

@SuppressWarnings("deprecation")
@javax.faces.bean.ManagedBean
@javax.faces.bean.SessionScoped
public class SomeBean {
import java.io.Serializable;

@jakarta.inject.Named
@jakarta.enterprise.context.SessionScoped
public class SomeBean implements Serializable {

public String getHello() {
return "Hello Bean";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# limitations under the License.
#

javax.faces.resource.localePrefix=germany
jakarta.faces.resource.localePrefix=germany
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# limitations under the License.
#

javax.faces.resource.localePrefix=iceland
jakarta.faces.resource.localePrefix=iceland
8 changes: 4 additions & 4 deletions samples/samples-jsf/war-jsf23-cdi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@

javax.enterprise.context,
javax.inject,
javax.faces.annotation,
javax.faces.bean,
javax.faces.view,
javax.faces.webapp,
jakarta.faces.annotation,
jakarta.faces.bean,
jakarta.faces.view,
jakarta.faces.webapp,
org.osgi.service.url,
org.osgi.service.cdi.annotations,
org.ops4j.pax.web.service.spi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import org.osgi.service.cdi.annotations.Bean;

import javax.enterprise.context.ApplicationScoped;
import javax.faces.annotation.FacesConfig;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.faces.annotation.FacesConfig;

@ApplicationScoped
// see:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import org.osgi.service.cdi.annotations.Reference;
import org.osgi.service.url.URLStreamHandlerService;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import java.io.Serializable;

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
Expand Down
5 changes: 5 additions & 0 deletions samples/samples-jsf/war-jsf23-embedded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>

<!-- Other -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
import java.io.IOException;
import java.util.Properties;

// According to "5.4 Managed Bean Annotations" of JSF 2.3 specification,javax.faces.bean package
// According to "5.4 Managed Bean Annotations" of JSF 2.3 specification,jakarta.faces.bean package
// is deprecated and the recommended annotations should be taken from CDI 1.2

@SuppressWarnings("deprecation")
@javax.faces.bean.ManagedBean
@javax.faces.bean.RequestScoped
@jakarta.inject.Named
@jakarta.enterprise.context.RequestScoped
public class Hello {

private String what;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
Expand Down
7 changes: 6 additions & 1 deletion samples/samples-jsf/war-jsf23-wired/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<instructions>
<Import-Package>
<!-- This is one of the required "wires" - to ensure that this WAB is "wired" to MyFaces -->
javax.faces.webapp
jakarta.faces.webapp
</Import-Package>
<Require-Bundle>
<!--
Expand Down Expand Up @@ -95,6 +95,11 @@
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>

<!-- Other -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<!-- Use JSP views by default -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-name>jakarta.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsp</param-value>
</context-param>

Expand All @@ -36,7 +36,7 @@

<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
</servlet>

<!-- Use prefix mapping for Facelets pages, e.g. http://localhost:8080/webapp/faces/mypage.jsf -->
Expand Down
Loading

0 comments on commit b56a48f

Please sign in to comment.