Remove dependency on glassfish

This commit is contained in:
Marian Koncek 2019-09-12 16:30:15 +02:00
parent 18200fb9b5
commit 27a252c000
2 changed files with 207 additions and 7 deletions

View File

@ -0,0 +1,196 @@
From 24db1069d977dc45c5f6abab667346d35cb4ec3d Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Wed, 7 Nov 2018 14:26:24 +0100
Subject: [PATCH] Remove support for optional features
---
.../eclipse/sisu/inject/Implementations.java | 94 +------------------
.../sisu/space/QualifiedTypeBinder.java | 28 ------
2 files changed, 2 insertions(+), 120 deletions(-)
diff --git a/sisu-inject/org.eclipse.sisu.inject/src/org/eclipse/sisu/inject/Implementations.java b/sisu-inject/org.eclipse.sisu.inject/src/org/eclipse/sisu/inject/Implementations.java
index 523c9b2..867f3ce 100644
--- a/sisu-inject/org.eclipse.sisu.inject/src/org/eclipse/sisu/inject/Implementations.java
+++ b/sisu-inject/org.eclipse.sisu.inject/src/org/eclipse/sisu/inject/Implementations.java
@@ -32,43 +32,6 @@ import com.google.inject.spi.UntargettedBinding;
*/
final class Implementations
{
- // ----------------------------------------------------------------------
- // Static initialization
- // ----------------------------------------------------------------------
-
- static
- {
- boolean hasGuiceServlet;
- try
- {
- hasGuiceServlet = BindingTargetVisitor.class.isInstance( ServletFinder.THIS );
- }
- catch ( final LinkageError e )
- {
- hasGuiceServlet = false;
- }
- HAS_GUICE_SERVLET = hasGuiceServlet;
-
- boolean hasJsr250Priority;
- try
- {
- hasJsr250Priority = javax.annotation.Priority.class.isAnnotation();
- }
- catch ( final LinkageError e )
- {
- hasJsr250Priority = false;
- }
- HAS_JSR250_PRIORITY = hasJsr250Priority;
- }
-
- // ----------------------------------------------------------------------
- // Constants
- // ----------------------------------------------------------------------
-
- private static final boolean HAS_GUICE_SERVLET;
-
- private static final boolean HAS_JSR250_PRIORITY;
-
// ----------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------
@@ -105,8 +68,7 @@ final class Implementations
final boolean isPriority = Priority.class.equals( annotationType );
// peek behind servlet/filter extension bindings when checking priority, so we can order them by rank
- final Class<?> implementation =
- binding.acceptTargetVisitor( HAS_GUICE_SERVLET && isPriority ? ServletFinder.THIS : ClassFinder.THIS );
+ final Class<?> implementation = binding.acceptTargetVisitor( ClassFinder.THIS );
T annotation = null;
if ( null != implementation )
@@ -114,11 +76,7 @@ final class Implementations
annotation = implementation.getAnnotation( annotationType );
if ( null == annotation )
{
- if ( HAS_JSR250_PRIORITY && isPriority )
- {
- annotation = adaptJsr250( binding, implementation );
- }
- else if ( Description.class.equals( annotationType ) )
+ if ( Description.class.equals( annotationType ) )
{
annotation = adaptLegacy( binding, implementation );
}
@@ -131,13 +89,6 @@ final class Implementations
// Implementation methods
// ----------------------------------------------------------------------
- @SuppressWarnings( "unchecked" )
- private static <T extends Annotation> T adaptJsr250( final Binding<?> binding, final Class<?> clazz )
- {
- final javax.annotation.Priority jsr250 = clazz.getAnnotation( javax.annotation.Priority.class );
- return null != jsr250 ? (T) new PrioritySource( binding.getSource(), jsr250.value() ) : null;
- }
-
@SuppressWarnings( { "unchecked", "deprecation" } )
private static <T extends Annotation> T adaptLegacy( final Binding<?> binding, final Class<?> clazz )
{
@@ -215,45 +166,4 @@ final class Implementations
return binding.getPrivateElements().getInjector().getBinding( binding.getKey() ).acceptTargetVisitor( this );
}
}
-
- /**
- * {@link ClassFinder} that can also peek behind servlet/filter bindings.
- */
- static final class ServletFinder
- extends ClassFinder
- implements com.google.inject.servlet.ServletModuleTargetVisitor<Object, Class<?>>
- {
- // ----------------------------------------------------------------------
- // Constants
- // ----------------------------------------------------------------------
-
- @SuppressWarnings( "hiding" )
- static final BindingTargetVisitor<Object, Class<?>> THIS = new ServletFinder();
-
- // ----------------------------------------------------------------------
- // Public methods
- // ----------------------------------------------------------------------
-
- public Class<?> visit( final com.google.inject.servlet.InstanceFilterBinding binding )
- {
- return binding.getFilterInstance().getClass();
- }
-
- public Class<?> visit( final com.google.inject.servlet.InstanceServletBinding binding )
- {
- return binding.getServletInstance().getClass();
- }
-
- public Class<?> visit( final com.google.inject.servlet.LinkedFilterBinding binding )
- {
- // this assumes only one level of indirection: api-->impl
- return binding.getLinkedKey().getTypeLiteral().getRawType();
- }
-
- public Class<?> visit( final com.google.inject.servlet.LinkedServletBinding binding )
- {
- // this assumes only one level of indirection: api-->impl
- return binding.getLinkedKey().getTypeLiteral().getRawType();
- }
- }
}
diff --git a/sisu-inject/org.eclipse.sisu.inject/src/org/eclipse/sisu/space/QualifiedTypeBinder.java b/sisu-inject/org.eclipse.sisu.inject/src/org/eclipse/sisu/space/QualifiedTypeBinder.java
index 4b34436..d213e19 100644
--- a/sisu-inject/org.eclipse.sisu.inject/src/org/eclipse/sisu/space/QualifiedTypeBinder.java
+++ b/sisu-inject/org.eclipse.sisu.inject/src/org/eclipse/sisu/space/QualifiedTypeBinder.java
@@ -39,32 +39,12 @@ import com.google.inject.name.Names;
public final class QualifiedTypeBinder
implements QualifiedTypeListener
{
- // ----------------------------------------------------------------------
- // Static initialization
- // ----------------------------------------------------------------------
-
- static
- {
- boolean hasJsr299Typed;
- try
- {
- hasJsr299Typed = javax.enterprise.inject.Typed.class.isAnnotation();
- }
- catch ( final LinkageError e )
- {
- hasJsr299Typed = false;
- }
- HAS_JSR299_TYPED = hasJsr299Typed;
- }
-
// ----------------------------------------------------------------------
// Constants
// ----------------------------------------------------------------------
private static final TypeLiteral<Object> OBJECT_TYPE_LITERAL = TypeLiteral.get( Object.class );
- private static final boolean HAS_JSR299_TYPED;
-
// ----------------------------------------------------------------------
// Implementation fields
// ----------------------------------------------------------------------
@@ -377,14 +357,6 @@ public final class QualifiedTypeBinder
{
for ( Class<?> c = clazz; null != c && c != Object.class; c = c.getSuperclass() )
{
- if ( HAS_JSR299_TYPED )
- {
- final javax.enterprise.inject.Typed typed = c.getAnnotation( javax.enterprise.inject.Typed.class );
- if ( null != typed )
- {
- return typed.value().length > 0 ? typed.value() : c.getInterfaces();
- }
- }
final org.eclipse.sisu.Typed typed = c.getAnnotation( org.eclipse.sisu.Typed.class );
if ( null != typed )
{
--
2.21.0

View File

@ -16,16 +16,14 @@ Source101: sisu-inject.pom
Source102: sisu-plexus.pom Source102: sisu-plexus.pom
Patch0: sisu-OSGi-import-guava.patch Patch0: sisu-OSGi-import-guava.patch
Patch2: sisu-ignored-tests.patch Patch1: sisu-ignored-tests.patch
Patch3: sisu-osgi-api.patch Patch2: sisu-osgi-api.patch
Patch3: 0001-Remove-support-for-optional-features.patch
BuildRequires: maven-local BuildRequires: maven-local
BuildRequires: mvn(com.google.inject.extensions:guice-servlet) BuildRequires: mvn(com.google.inject.extensions:guice-servlet)
BuildRequires: mvn(com.google.inject:guice::no_aop:) BuildRequires: mvn(com.google.inject:guice::no_aop:)
BuildRequires: mvn(javax.annotation:javax.annotation-api)
BuildRequires: %{?module_prefix}mvn(javax.enterprise:cdi-api)
BuildRequires: mvn(javax.inject:javax.inject)
BuildRequires: mvn(javax.servlet:servlet-api)
BuildRequires: mvn(junit:junit) BuildRequires: mvn(junit:junit)
BuildRequires: %{?module_prefix}mvn(org.codehaus.plexus:plexus-classworlds) BuildRequires: %{?module_prefix}mvn(org.codehaus.plexus:plexus-classworlds)
BuildRequires: %{?module_prefix}mvn(org.codehaus.plexus:plexus-component-annotations) BuildRequires: %{?module_prefix}mvn(org.codehaus.plexus:plexus-component-annotations)
@ -53,8 +51,9 @@ cp %{SOURCE101} sisu-inject/pom.xml
cp %{SOURCE102} sisu-plexus/pom.xml cp %{SOURCE102} sisu-plexus/pom.xml
%patch0 %patch0
%patch1
%patch2 %patch2
%patch3 %patch3 -p1
%pom_xpath_set -r /pom:project/pom:version %{version} %pom_xpath_set -r /pom:project/pom:version %{version}
@ -63,6 +62,11 @@ cp %{SOURCE102} sisu-plexus/pom.xml
%mvn_package : __noinstall %mvn_package : __noinstall
%mvn_alias :org.eclipse.sisu.plexus org.sonatype.sisu:sisu-inject-plexus %mvn_alias :org.eclipse.sisu.plexus org.sonatype.sisu:sisu-inject-plexus
%pom_remove_dep :javax.inject sisu-inject
%pom_remove_dep :cdi-api sisu-inject
%pom_remove_dep :javax.annotation-api sisu-inject
%pom_remove_dep :servlet-api sisu-inject
%build %build
%mvn_build %mvn_build