Skip to content

Commit

Permalink
Jakarta Namespace - Faces 3.0.0 Complete with ShowCase
Browse files Browse the repository at this point in the history
  • Loading branch information
GedMarc committed Nov 12, 2020
1 parent 30b8739 commit 8a2bff7
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/jre11/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import com.guicedee.guicedservlets.jsf.implementations.GuicedJSFModuleInclusions;

open module com.guicedee.guicedservlets.jsf {
exports com.guicedee.guicedservlets.jsf;

requires transitive jakarta.faces;

requires com.guicedee.guicedinjection;

requires jakarta.el;
requires jakarta.enterprise.cdi;
requires java.desktop;
Expand All @@ -14,6 +18,8 @@
provides com.guicedee.guicedservlets.services.IGuiceSiteBinder with com.guicedee.guicedservlets.jsf.GuicedServletJSFModule;
provides com.guicedee.guicedservlets.undertow.services.UndertowDeploymentConfigurator with com.guicedee.guicedservlets.jsf.implementations.GuicedJSFDeploymentInfoConfiguration;
provides com.guicedee.guicedinjection.interfaces.IGuiceModule with com.guicedee.guicedservlets.jsf.implementations.JsfNamedBinder;
provides com.guicedee.guicedinjection.interfaces.IGuiceScanModuleInclusions with GuicedJSFModuleInclusions;

requires org.apache.commons.beanutils;
requires org.apache.commons.collections4;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.guicedee.guicedservlets.jsf.implementations;

import com.guicedee.guicedinjection.interfaces.IGuiceScanModuleInclusions;
import jakarta.validation.constraints.NotNull;

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

public class GuicedJSFModuleInclusions implements IGuiceScanModuleInclusions<GuicedJSFModuleInclusions> {
@Override
public @NotNull Set<String> includeModules() {
Set<String> moduleScanningAllowed = new HashSet<>();
moduleScanningAllowed.add("com.guicedee.guicedservlets.jsf");
return moduleScanningAllowed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.RequestScoped;
import jakarta.enterprise.context.SessionScoped;
import jakarta.faces.bean.ManagedBean;

public class JsfNamedBinder
extends AbstractModule
Expand Down Expand Up @@ -59,6 +60,52 @@ else if (applicationScoped)
}
}

for (ClassInfo classInfo : GuiceContext.instance()
.getScanResult()
.getClassesWithAnnotation(jakarta.faces.bean.ApplicationScoped.class.getCanonicalName()))
{
if (classInfo.isInterfaceOrAnnotation()
|| classInfo.hasAnnotation("jakarta.enterprise.context.Dependent"))
{
continue;
}
Class<?> clazz = classInfo.loadClass();
jakarta.faces.bean.ApplicationScoped nn = clazz.getAnnotation(jakarta.faces.bean.ApplicationScoped.class);
String name = NamedBindings.cleanName(classInfo,"");
NamedBindings.bindToScope(binder(), clazz, name, Singleton.class);
}

for (ClassInfo classInfo : GuiceContext.instance()
.getScanResult()
.getClassesWithAnnotation(jakarta.faces.bean.SessionScoped.class.getCanonicalName()))
{
if (classInfo.isInterfaceOrAnnotation()
|| classInfo.hasAnnotation("jakarta.enterprise.context.Dependent"))
{
continue;
}
Class<?> clazz = classInfo.loadClass();
jakarta.faces.bean.SessionScoped nn = clazz.getAnnotation(jakarta.faces.bean.SessionScoped.class);
String name = NamedBindings.cleanName(classInfo,"");
NamedBindings.bindToScope(binder(), clazz, name, com.google.inject.servlet.SessionScoped.class);
}

for (ClassInfo classInfo : GuiceContext.instance()
.getScanResult()
.getClassesWithAnnotation(jakarta.faces.bean.RequestScoped.class.getCanonicalName()))
{
if (classInfo.isInterfaceOrAnnotation()
|| classInfo.hasAnnotation("jakarta.enterprise.context.Dependent"))
{
continue;
}
Class<?> clazz = classInfo.loadClass();
jakarta.faces.bean.RequestScoped nn = clazz.getAnnotation(jakarta.faces.bean.RequestScoped.class);
String name = NamedBindings.cleanName(classInfo,"");
NamedBindings.bindToScope(binder(), clazz, name, com.google.inject.servlet.RequestScoped.class);
}


super.configure();
}

Expand Down

0 comments on commit 8a2bff7

Please sign in to comment.