Update to upstream version 4.0

This commit is contained in:
Mikolaj Izdebski 2015-05-14 14:30:28 +02:00
parent 4b93d82c75
commit 2dbb62e729
6 changed files with 1237 additions and 18 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@
/google-guice-3.2.4.tar.xz /google-guice-3.2.4.tar.xz
/google-guice-3.2.5.tar.xz /google-guice-3.2.5.tar.xz
/google-guice-3.2.6.tar.xz /google-guice-3.2.6.tar.xz
/google-guice-4.0.tar.xz

View File

@ -0,0 +1,153 @@
Description: Provide built-in injection of SLF4J loggers
Author: Stuart McCulloch <mcculls@gmail.com>
Bug-Google: http://code.google.com/p/google-guice/issues/detail?id=492
Last-Update: 2014-11-07
diff --git a/common.xml b/common.xml
index a23eb90..2d3d9b3 100644
--- a/common.xml
+++ b/common.xml
@@ -44,6 +44,10 @@
<property name="Export-Package" value="!${module}.internal.*,${module}.*;version=${api.version}"/>
+ <condition property="DynamicImport-Package" value="org.slf4j">
+ <equals arg1="${module}" arg2="com.google.inject"/>
+ </condition>
+
<condition property="Eclipse-ExtensibleAPI" value="true">
<equals arg1="${module}" arg2="com.google.inject"/>
</condition>
diff --git a/core/pom.xml b/core/pom.xml
index 33e6dcc..edfa724 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -15,6 +15,12 @@
<dependencies>
<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.4</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
@@ -91,6 +97,12 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!--
+ | Run core tests without SLF4J on the classpath
+ -->
+ <classpathDependencyExcludes>
+ <exclude>org.slf4j:slf4j-api</exclude>
+ </classpathDependencyExcludes>
+ <!--
| Temporarily excluded tests
-->
<excludes>
@@ -113,6 +125,7 @@
<Bundle-Name>${project.artifactId}$(if;$(classes;NAMED;*.MethodAspect);; (no_aop))</Bundle-Name>
<Import-Package>!net.sf.cglib.*,!org.objectweb.asm.*,!com.google.inject.*,*</Import-Package>
<Eclipse-ExtensibleAPI>true</Eclipse-ExtensibleAPI>
+ <DynamicImport-Package>org.slf4j</DynamicImport-Package>
</instructions>
</configuration>
</plugin>
diff --git a/core/src/com/google/inject/internal/InjectorShell.java b/core/src/com/google/inject/internal/InjectorShell.java
index 6100879..56b13b3 100644
--- a/core/src/com/google/inject/internal/InjectorShell.java
+++ b/core/src/com/google/inject/internal/InjectorShell.java
@@ -251,6 +251,15 @@ final class InjectorShell {
new ProviderInstanceBindingImpl<Logger>(injector, key,
SourceProvider.UNKNOWN_SOURCE, loggerFactory, Scoping.UNSCOPED,
loggerFactory, ImmutableSet.<InjectionPoint>of()));
+
+ try {
+ Key<org.slf4j.Logger> slf4jKey = Key.get(org.slf4j.Logger.class);
+ SLF4JLoggerFactory slf4jLoggerFactory = new SLF4JLoggerFactory(injector);
+ injector.state.putBinding(slf4jKey,
+ new ProviderInstanceBindingImpl<org.slf4j.Logger>(injector, slf4jKey,
+ SourceProvider.UNKNOWN_SOURCE, slf4jLoggerFactory, Scoping.UNSCOPED,
+ slf4jLoggerFactory, ImmutableSet.<InjectionPoint>of()));
+ } catch (Throwable e) {}
}
private static class LoggerFactory implements InternalFactory<Logger>, Provider<Logger> {
@@ -270,6 +279,44 @@ final class InjectorShell {
}
}
+ private static class SLF4JLoggerFactory implements InternalFactory<org.slf4j.Logger>, Provider<org.slf4j.Logger> {
+ private final Injector injector;
+
+ private org.slf4j.ILoggerFactory loggerFactory;
+
+ SLF4JLoggerFactory(Injector injector) {
+ this.injector = injector;
+ }
+
+ org.slf4j.ILoggerFactory loggerFactory() {
+ if (loggerFactory == null) {
+ try {
+ loggerFactory = injector.getInstance(org.slf4j.ILoggerFactory.class);
+ } catch (Throwable e) {}
+ if (loggerFactory == null) {
+ loggerFactory = org.slf4j.LoggerFactory.getILoggerFactory();
+ }
+ }
+ return loggerFactory;
+ }
+
+ public org.slf4j.Logger get(Errors errors, InternalContext context, Dependency<?> dependency, boolean linked) {
+ InjectionPoint injectionPoint = dependency.getInjectionPoint();
+ if (injectionPoint != null) {
+ return loggerFactory().getLogger(injectionPoint.getMember().getDeclaringClass().getName());
+ }
+ return loggerFactory().getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
+ }
+
+ public org.slf4j.Logger get() {
+ return loggerFactory().getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
+ }
+
+ public String toString() {
+ return "Provider<org.slf4j.Logger>";
+ }
+ }
+
private static void bindStage(InjectorImpl injector, Stage stage) {
Key<Stage> key = Key.get(Stage.class);
InstanceBindingImpl<Stage> stageBinding = new InstanceBindingImpl<Stage>(
diff --git a/extensions/persist/pom.xml b/extensions/persist/pom.xml
index a560f38..e909927 100644
--- a/extensions/persist/pom.xml
+++ b/extensions/persist/pom.xml
@@ -29,7 +29,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <version>1.6.1</version>
+ <version>1.6.4</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/lib/build/slf4j-api-1.6.4.jar b/lib/build/slf4j-api-1.6.4.jar
new file mode 100644
index 0000000..76ef305
Binary files /dev/null and b/lib/build/slf4j-api-1.6.4.jar differ
diff --git a/pom.xml b/pom.xml
index 37305d0..5834d49 100644
--- a/pom.xml
+++ b/pom.xml
@@ -283,7 +283,7 @@ See the Apache License Version 2.0 for the specific language governing permissio
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<!--<argLine>-Dguice_include_stack_traces=OFF</argLine>-->

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,13 @@
#!/bin/sh #!/bin/sh
set -e -x set -e -x
test $# -eq 1 test $# -eq 1
test ! -d sisu-guice test ! -d guice
git clone git://github.com/sonatype/sisu-guice.git git clone git://github.com/google/guice.git
cd ./sisu-guice cd ./guice
git checkout sisu-guice-${1} git checkout ${1}
git branch unbundled-guice-${1} git branch unbundled-${1}
git checkout unbundled-guice-${1} git checkout unbundled-${1}
rm -rf $(ls . | grep -E -v 'core|extensions|pom|bom|jdk8-tests|COPYING') rm -rf $(ls . | grep -E -v 'core|extensions|pom|bom|jdk8-tests|COPYING|common.xml')
find . -name "*.jar" -delete find . -name "*.jar" -delete
find . -name "*.class" -delete find . -name "*.class" -delete
git commit -a -m "Remove unneeded stuff" git commit -a -m "Remove unneeded stuff"

View File

@ -5,19 +5,26 @@
%global short_name guice %global short_name guice
Name: google-%{short_name} Name: google-%{short_name}
Version: 3.2.6 Version: 4.0
Release: 1%{?dist} Release: 1%{?dist}
Summary: Lightweight dependency injection framework for Java 5 and above Summary: Lightweight dependency injection framework for Java 5 and above
License: ASL 2.0 License: ASL 2.0
URL: https://github.com/sonatype/sisu-%{short_name} URL: https://github.com/google/%{short_name}
BuildArch: noarch
# ./create-tarball.sh %%{version} # ./create-tarball.sh %%{version}
Source0: %{name}-%{version}.tar.xz Source0: %{name}-%{version}.tar.xz
Source1: create-tarball.sh Source1: create-tarball.sh
BuildArch: noarch
# Rejected upstream: https://github.com/google/guice/issues/492
Patch100: https://raw.githubusercontent.com/sonatype/sisu-guice/master/PATCHES/GUICE_492_slf4j_logger_injection.patch
# Forwarded upstream: https://github.com/google/guice/issues/618
Patch101: https://raw.githubusercontent.com/sonatype/sisu-guice/master/PATCHES/GUICE_618_extensible_filter_pipeline.patch
BuildRequires: maven-local >= 3.2.4-2 BuildRequires: maven-local >= 3.2.4-2
BuildRequires: maven-remote-resources-plugin BuildRequires: maven-remote-resources-plugin
BuildRequires: munge-maven-plugin BuildRequires: munge-maven-plugin
BuildRequires: maven-gpg-plugin
BuildRequires: apache-resource-bundles BuildRequires: apache-resource-bundles
BuildRequires: aopalliance BuildRequires: aopalliance
BuildRequires: atinject BuildRequires: atinject
@ -168,6 +175,8 @@ This package provides %{summary}.
%prep %prep
%setup -q -n %{name}-%{version} %setup -q -n %{name}-%{version}
%patch100 -p1
%patch101 -p1
# We don't have struts2 in Fedora yet. # We don't have struts2 in Fedora yet.
%pom_disable_module struts2 extensions %pom_disable_module struts2 extensions
@ -191,7 +200,8 @@ This package provides %{summary}.
%pom_remove_dep :guava-testlib extensions %pom_remove_dep :guava-testlib extensions
%pom_xpath_remove "pom:dependency[pom:classifier[text()='tests']]" extensions %pom_xpath_remove "pom:dependency[pom:classifier[text()='tests']]" extensions
%pom_set_parent org.sonatype.sisu.inject:guice-parent:%{version} jdk8-tests %pom_remove_parent
%pom_set_parent com.google.inject:guice-parent:%{version} jdk8-tests
# Don't try to build extension modules unless they are needed # Don't try to build extension modules unless they are needed
%if %{without extensions} %if %{without extensions}
@ -202,22 +212,21 @@ This package provides %{summary}.
%build %build
%if %{with extensions} %if %{with extensions}
%mvn_alias ":guice-{assistedinject,grapher,jmx,jndi,multibindings,persist,\ %mvn_alias "com.google.inject.extensions:" "org.sonatype.sisu.inject:"
servlet,spring,throwingproviders}" "com.google.inject.extensions:guice-@1"
%endif # with extensions %endif # with extensions
%mvn_package :::no_aop: sisu-guice %mvn_package :::no_aop: guice
%mvn_file ":guice-{*}" %{short_name}/guice-@1 %mvn_file ":guice-{*}" %{short_name}/guice-@1
%mvn_file ":sisu-guice" %{short_name}/%{name} %{name} %mvn_file ":guice" %{short_name}/%{name} %{name}
%mvn_alias ":sisu-guice" "com.google.inject:guice" %mvn_alias ":guice" "org.sonatype.sisu:sisu-guice"
# Skip tests because of missing dependency guice-testlib # Skip tests because of missing dependency guice-testlib
%mvn_build -f -s %mvn_build -f -s
%install %install
%mvn_install %mvn_install
%files -f .mfiles-sisu-guice %files -f .mfiles-guice
%dir %{_javadir}/%{short_name} %dir %{_javadir}/%{short_name}
%files -n %{short_name}-parent -f .mfiles-guice-parent %files -n %{short_name}-parent -f .mfiles-guice-parent
@ -243,6 +252,9 @@ servlet,spring,throwingproviders}" "com.google.inject.extensions:guice-@1"
%changelog %changelog
* Thu May 14 2015 Mikolaj Izdebski <mizdebsk@redhat.com> - 4.0-1
- Update to upstream version 4.0
* Mon Apr 27 2015 Mikolaj Izdebski <mizdebsk@redhat.com> - 3.2.6-1 * Mon Apr 27 2015 Mikolaj Izdebski <mizdebsk@redhat.com> - 3.2.6-1
- Update to upstream version 3.2.6 - Update to upstream version 3.2.6

View File

@ -1 +1 @@
adb14ad8a47d3e2f92fd030a9b34e53b google-guice-3.2.6.tar.xz bf431704d50d3548b85e3e9031005f05 google-guice-4.0.tar.xz