sisu-guice-sisu-guice-3.1.1/0000755000175000017500000000000011704661106014412 5ustar tonytonysisu-guice-sisu-guice-3.1.1/uploadJavadocs.sh0000755000175000017500000000054411704661106017713 0ustar tonytonyrm -rf build/docs svn rm latest-javadoc javadoc svn ci -m "Removed old Javadocs." latest-javadoc javadoc ant javadoc cp -r build/docs/javadoc latest-javadoc cp -r latest-javadoc javadoc mv build/docs/guice-*.xml lib/build svn add latest-javadoc javadoc lib/build/guice-*.xml svn ci -m "Added updated Javadocs." latest-javadoc javadoc lib/build/guice-*.xml sisu-guice-sisu-guice-3.1.1/uploadApiDiffs.sh0000644000175000017500000000105511704661106017641 0ustar tonytonyrm -rf build/docs CV=3.0 # remove old api-diffs svn rm latest-api-diffs/$CV svn ci -m "Removed old $CV api diffs." latest-api-diffs/$CV # create new api-diffs ant jdiff cp -r build/docs/latest-api-diffs latest-api-diffs/$CV cp lib/build/jdiff/*.gif latest-api-diffs/$CV mv latest-api-diffs/$CV/$CV.xml latest-api-diffs # capture current javadoc snapshot ant javadoc cp -r build/docs/javadoc latest-api-diffs/$CV/javadoc # commit changes svn add latest-api-diffs/$CV svn ci -m "Added updated $CV api diffs." latest-api-diffs/$CV latest-api-diffs/$CV.xml sisu-guice-sisu-guice-3.1.1/pom.xml0000644000175000017500000002527311704661106015740 0ustar tonytony 4.0.0 org.sonatype.forge forge-parent 10 pom org.sonatype.sisu.inject guice-parent 3.1.1 Sisu Guice Patched build of Guice: a lightweight dependency injection framework for Java 5 and above http://code.google.com/p/google-guice/ 2006 Google, Inc. http://www.google.com Guice Users List http://groups.google.com/group/google-guice/topics google-guice+subscribe@googlegroups.com google-guice+unsubscribe@googlegroups.com http://groups.google.com/group/google-guice/post Guice Developers List http://groups.google.com/group/google-guice-dev/topics google-guice-dev+subscribe@googlegroups.com google-guice-dev+unsubscribe@googlegroups.com http://groups.google.com/group/google-guice-dev/post scm:git:git@github.com:sonatype/sisu-guice.git scm:git:git@github.com:sonatype/sisu-guice.git http://github.com/sonatype/sisu-guice Google Code http://code.google.com/p/google-guice/issues/ Hudson https://builds.sonatype.org/job/sisu-guice/ The Apache Software License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt repo core extensions 3.0 1.4 UTF-8 true true org.testng testng 6.3 test ${project.basedir}/src false ${project.basedir}/src **/*.java ${project.basedir}/test false ${project.basedir}/test **/*.java maven-remote-resources-plugin 1.2.1 process org.apache:apache-jar-resource-bundle:1.4 maven-compiler-plugin 2.3.2 org.codehaus.mojo animal-sniffer-maven-plugin 1.7 org.codehaus.mojo.signature java15 1.0 check-java-1.5-compat process-classes check maven-surefire-plugin 2.10 true org.apache.felix maven-bundle-plugin 2.3.6 ${project.artifactId} $(maven-symbolicname);singleton:=true Copyright (C) 2006 Google Inc. http://code.google.com/p/google-guice/ Sonatype, Inc. J2SE-1.5,JavaSE-1.6 <_exportcontents>!*.internal.*,*;version=${guice.api.version} !com.google.*,* <_nouses>true <_removeheaders> Embed-Dependency,Embed-Transitive, Built-By,Tool,Created-By,Build-Jdk, Originally-Created-By,Archiver-Version, Include-Resource,Private-Package, Ignore-Package,Bnd-LastModified true prepare-package manifest maven-jar-plugin 2.3.2 ${project.build.outputDirectory}/META-INF/MANIFEST.MF false package test-jar maven-javadoc-plugin 2.8 com.google.doclava.Doclava ${project.basedir}/../lib/build/doclava.jar: ${project.basedir}/../../lib/build/doclava.jar ${sun.boot.class.path} *.internal -quiet -federate JDK http://download.oracle.com/javase/6/docs/api/index.html? -federationxml JDK http://doclava.googlecode.com/svn/static/api/openjdk-6.xml -hdf project.name "${project.name} (patched build of Google Guice)" -d ${project.build.directory}/apidocs false -J-Xmx1024m maven-site-plugin 3.0 maven-source-plugin 2.1.2 maven-gpg-plugin 1.4 maven-release-plugin 2.2.1 true maven-deploy-plugin 2.7 sisu-guice-sisu-guice-3.1.1/lib/0000755000175000017500000000000012273115427015162 5ustar tonytonysisu-guice-sisu-guice-3.1.1/lib/build/0000755000175000017500000000000012273115427016261 5ustar tonytonysisu-guice-sisu-guice-3.1.1/lib/build/jdiff/0000755000175000017500000000000012273115427017343 5ustar tonytonysisu-guice-sisu-guice-3.1.1/lib/build/jdiff/new.gif0000755000175000017500000000016411704661106020625 0ustar tonytonyGIF89a ‘РРРџџ!љ, EŒo‚Š!мтyЯбDЋ“6ћџq@‘РifЄЦ ч“–*лІцыКБ8ТБ"ёzАмЬ‰ШŠС"2ЙIA-ЬХЊШ ДMTR;sisu-guice-sisu-guice-3.1.1/lib/build/jdiff/black.gif0000755000175000017500000000143711704661106021114 0ustar tonytonyGIF89aїџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ,;sisu-guice-sisu-guice-3.1.1/lib/build/jdiff/background.gif0000755000175000017500000000105711704661106022155 0ustar tonytonyGIF89ahh€ѕѕѕ!љ,hhџ„ЉЫэЃœДк‹ГоМћ†тH–ц‰ІъЪЖю ЧђLзічњЮїў ‡ФЂёˆL*—ЬІѓ JЇдЊѕŠЭjЗмЎї ‹ЧфВљŒNЋзьЖћ ЫчєК§ŽЯыїќОџ(8HXhxˆ˜ЈИШишј)9IYiy‰™ЉЙЩйщљ *:JZjzŠšЊКЪкъњ +;K[k{‹›ЋЛЫлыћ ,N^n~ŽžЎОЮоюў/?O_oŸЏПЯпяџ0 Р <ˆ0ЁТ… :|1ЂФ‰+ZМˆ1ЃЦџ;zќ2ЄШ‘$Kš<‰2ЅЪ•,[К| 3ІЬ™4kкМ‰3ЇЮ<{њќ 4ЈаЁD‹=Š4ЉвЅL›:} 5ЊдЉTЋZНŠ5Ћж­\Лz§ 6ЌиБdЫš=‹6­кЕlлК} 7ЎмЙtыкН‹7ЏоН|ћњ§ 8АрС„ >Œ8БтХŒ;~ 9ВфЩ”+[ОŒ9ГцЭœ;{ў :ДшбЄK›>:ЕъеЌ[Л~ ;ЖьйДkлО;ЗюнМ{ћў <И№сФ‹?Ž<ЙђхЬ›;=КєщдЋ[ПŽ=ЛіэмЛ{џ>МјёфЫ›?>НњѕьлЛ?ОќљєылП?Пў§ќћћџ O;sisu-guice-sisu-guice-3.1.1/lib/build/jdiff/Null.java0000755000175000017500000000040011704661106021113 0ustar tonytony/** * This class is used only as a "null" argument for Javadoc when comparing * two API files. Javadoc has to have a package, .java or .class file as an * argument, even though JDiff doesn't use it. */ public class Null { public Null() { } } sisu-guice-sisu-guice-3.1.1/lib/build/guice-3.0.xml0000755000175000017500000073101111704661106020401 0ustar tonytony sisu-guice-sisu-guice-3.1.1/lib/build/guice-2.0.xml0000644000175000017500000044201711704661106020402 0ustar tonytony sisu-guice-sisu-guice-3.1.1/lib/build/guice-1.0.xml0000644000175000017500000017416311704661106020405 0ustar tonytony sisu-guice-sisu-guice-3.1.1/lib/build/README0000644000175000017500000000005311704661106017135 0ustar tonytonyThese libraries are not needed at runtime. sisu-guice-sisu-guice-3.1.1/latest-javadoc/0000755000175000017500000000000011704661106017313 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/packages.html0000755000175000017500000003422411704661106021767 0ustar tonytony Package Index | Guice

Package Index

com.google.inject Google Guice (pronounced "juice") is an ultra-lightweight dependency injection framework. 
com.google.inject.assistedinject Extension for combining factory interfaces with injection; this extension requires guice-assistedinject-3.0.jar
com.google.inject.binder Interfaces which make up Binder's expression language. 
com.google.inject.grapher  
com.google.inject.grapher.graphviz  
com.google.inject.jndi JNDI integration; this extension requires guice-jndi-3.0.jar
com.google.inject.matcher Used for matching things. 
com.google.inject.multibindings Extension for binding multiple instances in a collection; this extension requires guice-multibindings-3.0.jar
com.google.inject.name Support for binding to string-based names. 
com.google.inject.persist Guice Persist: a lightweight persistence library for Guice; this extension requires guice-persist-3.0.jar
com.google.inject.persist.finder Dynamic Finder API for Guice Persist. 
com.google.inject.persist.jpa guice-persist's Java Persistence API (JPA) support. 
com.google.inject.servlet Servlet API scopes, bindings and registration; this extension requires guice-servlet-3.0.jar
com.google.inject.spi Guice service provider interface  
com.google.inject.spring Spring integration; this extension requires guice-spring-3.0.jar
com.google.inject.throwingproviders Extension for injecting objects that may throw at provision time; this extension requires guice-throwingproviders-3.0.jar
com.google.inject.tools.jmx JMX integration; this extension requires guice-jmx-3.0.jar
com.google.inject.util Helper methods for working with Guice. 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/package-list0000755000175000017500000000075311704661106021612 0ustar tonytonycom.google.inject com.google.inject.assistedinject com.google.inject.binder com.google.inject.grapher com.google.inject.grapher.graphviz com.google.inject.jndi com.google.inject.matcher com.google.inject.multibindings com.google.inject.name com.google.inject.persist com.google.inject.persist.finder com.google.inject.persist.jpa com.google.inject.servlet com.google.inject.spi com.google.inject.spring com.google.inject.throwingproviders com.google.inject.tools.jmx com.google.inject.util sisu-guice-sisu-guice-3.1.1/latest-javadoc/lists.js0000755000175000017500000006144611704661106021025 0ustar tonytonyvar DATA = [ { id:0, label:"com.google.inject", link:"com/google/inject/package-summary.html", type:"package" }, { id:1, label:"com.google.inject.AbstractModule", link:"com/google/inject/AbstractModule.html", type:"class" }, { id:2, label:"com.google.inject.Binder", link:"com/google/inject/Binder.html", type:"class" }, { id:3, label:"com.google.inject.Binding", link:"com/google/inject/Binding.html", type:"class" }, { id:4, label:"com.google.inject.BindingAnnotation", link:"com/google/inject/BindingAnnotation.html", type:"class" }, { id:5, label:"com.google.inject.ConfigurationException", link:"com/google/inject/ConfigurationException.html", type:"class" }, { id:6, label:"com.google.inject.CreationException", link:"com/google/inject/CreationException.html", type:"class" }, { id:7, label:"com.google.inject.Exposed", link:"com/google/inject/Exposed.html", type:"class" }, { id:8, label:"com.google.inject.Guice", link:"com/google/inject/Guice.html", type:"class" }, { id:9, label:"com.google.inject.ImplementedBy", link:"com/google/inject/ImplementedBy.html", type:"class" }, { id:10, label:"com.google.inject.Inject", link:"com/google/inject/Inject.html", type:"class" }, { id:11, label:"com.google.inject.Injector", link:"com/google/inject/Injector.html", type:"class" }, { id:12, label:"com.google.inject.Key", link:"com/google/inject/Key.html", type:"class" }, { id:13, label:"com.google.inject.MembersInjector", link:"com/google/inject/MembersInjector.html", type:"class" }, { id:14, label:"com.google.inject.Module", link:"com/google/inject/Module.html", type:"class" }, { id:15, label:"com.google.inject.OutOfScopeException", link:"com/google/inject/OutOfScopeException.html", type:"class" }, { id:16, label:"com.google.inject.PrivateBinder", link:"com/google/inject/PrivateBinder.html", type:"class" }, { id:17, label:"com.google.inject.PrivateModule", link:"com/google/inject/PrivateModule.html", type:"class" }, { id:18, label:"com.google.inject.ProvidedBy", link:"com/google/inject/ProvidedBy.html", type:"class" }, { id:19, label:"com.google.inject.Provider", link:"com/google/inject/Provider.html", type:"class" }, { id:20, label:"com.google.inject.Provides", link:"com/google/inject/Provides.html", type:"class" }, { id:21, label:"com.google.inject.ProvisionException", link:"com/google/inject/ProvisionException.html", type:"class" }, { id:22, label:"com.google.inject.Scope", link:"com/google/inject/Scope.html", type:"class" }, { id:23, label:"com.google.inject.ScopeAnnotation", link:"com/google/inject/ScopeAnnotation.html", type:"class" }, { id:24, label:"com.google.inject.Scopes", link:"com/google/inject/Scopes.html", type:"class" }, { id:25, label:"com.google.inject.Singleton", link:"com/google/inject/Singleton.html", type:"class" }, { id:26, label:"com.google.inject.Stage", link:"com/google/inject/Stage.html", type:"class" }, { id:27, label:"com.google.inject.TypeLiteral", link:"com/google/inject/TypeLiteral.html", type:"class" }, { id:28, label:"com.google.inject.assistedinject", link:"com/google/inject/assistedinject/package-summary.html", type:"package" }, { id:29, label:"com.google.inject.assistedinject.Assisted", link:"com/google/inject/assistedinject/Assisted.html", type:"class" }, { id:30, label:"com.google.inject.assistedinject.AssistedInject", link:"com/google/inject/assistedinject/AssistedInject.html", type:"class" }, { id:31, label:"com.google.inject.assistedinject.AssistedInjectBinding", link:"com/google/inject/assistedinject/AssistedInjectBinding.html", type:"class" }, { id:32, label:"com.google.inject.assistedinject.AssistedInjectTargetVisitor", link:"com/google/inject/assistedinject/AssistedInjectTargetVisitor.html", type:"class" }, { id:33, label:"com.google.inject.assistedinject.AssistedMethod", link:"com/google/inject/assistedinject/AssistedMethod.html", type:"class" }, { id:34, label:"com.google.inject.assistedinject.FactoryModuleBuilder", link:"com/google/inject/assistedinject/FactoryModuleBuilder.html", type:"class" }, { id:35, label:"com.google.inject.assistedinject.FactoryProvider", link:"com/google/inject/assistedinject/FactoryProvider.html", type:"class" }, { id:36, label:"com.google.inject.binder", link:"com/google/inject/binder/package-summary.html", type:"package" }, { id:37, label:"com.google.inject.binder.AnnotatedBindingBuilder", link:"com/google/inject/binder/AnnotatedBindingBuilder.html", type:"class" }, { id:38, label:"com.google.inject.binder.AnnotatedConstantBindingBuilder", link:"com/google/inject/binder/AnnotatedConstantBindingBuilder.html", type:"class" }, { id:39, label:"com.google.inject.binder.AnnotatedElementBuilder", link:"com/google/inject/binder/AnnotatedElementBuilder.html", type:"class" }, { id:40, label:"com.google.inject.binder.ConstantBindingBuilder", link:"com/google/inject/binder/ConstantBindingBuilder.html", type:"class" }, { id:41, label:"com.google.inject.binder.LinkedBindingBuilder", link:"com/google/inject/binder/LinkedBindingBuilder.html", type:"class" }, { id:42, label:"com.google.inject.binder.ScopedBindingBuilder", link:"com/google/inject/binder/ScopedBindingBuilder.html", type:"class" }, { id:43, label:"com.google.inject.grapher", link:"com/google/inject/grapher/package-summary.html", type:"package" }, { id:44, label:"com.google.inject.grapher.BindingEdge", link:"com/google/inject/grapher/BindingEdge.html", type:"class" }, { id:45, label:"com.google.inject.grapher.BindingEdge.Factory", link:"com/google/inject/grapher/BindingEdge.Factory.html", type:"class" }, { id:46, label:"com.google.inject.grapher.BindingEdge.Type", link:"com/google/inject/grapher/BindingEdge.Type.html", type:"class" }, { id:47, label:"com.google.inject.grapher.DependencyEdge", link:"com/google/inject/grapher/DependencyEdge.html", type:"class" }, { id:48, label:"com.google.inject.grapher.DependencyEdge.Factory", link:"com/google/inject/grapher/DependencyEdge.Factory.html", type:"class" }, { id:49, label:"com.google.inject.grapher.GrapherModule", link:"com/google/inject/grapher/GrapherModule.html", type:"class" }, { id:50, label:"com.google.inject.grapher.GraphingVisitor", link:"com/google/inject/grapher/GraphingVisitor.html", type:"class" }, { id:51, label:"com.google.inject.grapher.ImplementationNode", link:"com/google/inject/grapher/ImplementationNode.html", type:"class" }, { id:52, label:"com.google.inject.grapher.ImplementationNode.Factory", link:"com/google/inject/grapher/ImplementationNode.Factory.html", type:"class" }, { id:53, label:"com.google.inject.grapher.InjectorGrapher", link:"com/google/inject/grapher/InjectorGrapher.html", type:"class" }, { id:54, label:"com.google.inject.grapher.InterfaceNode", link:"com/google/inject/grapher/InterfaceNode.html", type:"class" }, { id:55, label:"com.google.inject.grapher.InterfaceNode.Factory", link:"com/google/inject/grapher/InterfaceNode.Factory.html", type:"class" }, { id:56, label:"com.google.inject.grapher.NameFactory", link:"com/google/inject/grapher/NameFactory.html", type:"class" }, { id:57, label:"com.google.inject.grapher.NodeAliasFactory", link:"com/google/inject/grapher/NodeAliasFactory.html", type:"class" }, { id:58, label:"com.google.inject.grapher.NodeIdFactory", link:"com/google/inject/grapher/NodeIdFactory.html", type:"class" }, { id:59, label:"com.google.inject.grapher.Renderer", link:"com/google/inject/grapher/Renderer.html", type:"class" }, { id:60, label:"com.google.inject.grapher.ShortNameFactory", link:"com/google/inject/grapher/ShortNameFactory.html", type:"class" }, { id:61, label:"com.google.inject.grapher.StringNodeIdFactory", link:"com/google/inject/grapher/StringNodeIdFactory.html", type:"class" }, { id:62, label:"com.google.inject.grapher.TransitiveDependencyVisitor", link:"com/google/inject/grapher/TransitiveDependencyVisitor.html", type:"class" }, { id:63, label:"com.google.inject.grapher.graphviz", link:"com/google/inject/grapher/graphviz/package-summary.html", type:"package" }, { id:64, label:"com.google.inject.grapher.graphviz.ArrowType", link:"com/google/inject/grapher/graphviz/ArrowType.html", type:"class" }, { id:65, label:"com.google.inject.grapher.graphviz.BindingEdgeFactory", link:"com/google/inject/grapher/graphviz/BindingEdgeFactory.html", type:"class" }, { id:66, label:"com.google.inject.grapher.graphviz.BindingEdgeFactory.GraphvizEdgeAdaptor", link:"com/google/inject/grapher/graphviz/BindingEdgeFactory.GraphvizEdgeAdaptor.html", type:"class" }, { id:67, label:"com.google.inject.grapher.graphviz.CompassPoint", link:"com/google/inject/grapher/graphviz/CompassPoint.html", type:"class" }, { id:68, label:"com.google.inject.grapher.graphviz.DependencyEdgeFactory", link:"com/google/inject/grapher/graphviz/DependencyEdgeFactory.html", type:"class" }, { id:69, label:"com.google.inject.grapher.graphviz.DependencyEdgeFactory.GraphvizEdgeAdaptor", link:"com/google/inject/grapher/graphviz/DependencyEdgeFactory.GraphvizEdgeAdaptor.html", type:"class" }, { id:70, label:"com.google.inject.grapher.graphviz.EdgeStyle", link:"com/google/inject/grapher/graphviz/EdgeStyle.html", type:"class" }, { id:71, label:"com.google.inject.grapher.graphviz.GraphvizEdge", link:"com/google/inject/grapher/graphviz/GraphvizEdge.html", type:"class" }, { id:72, label:"com.google.inject.grapher.graphviz.GraphvizModule", link:"com/google/inject/grapher/graphviz/GraphvizModule.html", type:"class" }, { id:73, label:"com.google.inject.grapher.graphviz.GraphvizNode", link:"com/google/inject/grapher/graphviz/GraphvizNode.html", type:"class" }, { id:74, label:"com.google.inject.grapher.graphviz.GraphvizRenderer", link:"com/google/inject/grapher/graphviz/GraphvizRenderer.html", type:"class" }, { id:75, label:"com.google.inject.grapher.graphviz.ImplementationNodeFactory", link:"com/google/inject/grapher/graphviz/ImplementationNodeFactory.html", type:"class" }, { id:76, label:"com.google.inject.grapher.graphviz.ImplementationNodeFactory.GraphvizNodeAdaptor", link:"com/google/inject/grapher/graphviz/ImplementationNodeFactory.GraphvizNodeAdaptor.html", type:"class" }, { id:77, label:"com.google.inject.grapher.graphviz.InterfaceNodeFactory", link:"com/google/inject/grapher/graphviz/InterfaceNodeFactory.html", type:"class" }, { id:78, label:"com.google.inject.grapher.graphviz.InterfaceNodeFactory.GraphvizNodeAdaptor", link:"com/google/inject/grapher/graphviz/InterfaceNodeFactory.GraphvizNodeAdaptor.html", type:"class" }, { id:79, label:"com.google.inject.grapher.graphviz.NodeShape", link:"com/google/inject/grapher/graphviz/NodeShape.html", type:"class" }, { id:80, label:"com.google.inject.grapher.graphviz.NodeStyle", link:"com/google/inject/grapher/graphviz/NodeStyle.html", type:"class" }, { id:81, label:"com.google.inject.grapher.graphviz.PortIdFactory", link:"com/google/inject/grapher/graphviz/PortIdFactory.html", type:"class" }, { id:82, label:"com.google.inject.grapher.graphviz.PortIdFactoryImpl", link:"com/google/inject/grapher/graphviz/PortIdFactoryImpl.html", type:"class" }, { id:83, label:"com.google.inject.jndi", link:"com/google/inject/jndi/package-summary.html", type:"package" }, { id:84, label:"com.google.inject.jndi.JndiIntegration", link:"com/google/inject/jndi/JndiIntegration.html", type:"class" }, { id:85, label:"com.google.inject.matcher", link:"com/google/inject/matcher/package-summary.html", type:"package" }, { id:86, label:"com.google.inject.matcher.AbstractMatcher", link:"com/google/inject/matcher/AbstractMatcher.html", type:"class" }, { id:87, label:"com.google.inject.matcher.Matcher", link:"com/google/inject/matcher/Matcher.html", type:"class" }, { id:88, label:"com.google.inject.matcher.Matchers", link:"com/google/inject/matcher/Matchers.html", type:"class" }, { id:89, label:"com.google.inject.multibindings", link:"com/google/inject/multibindings/package-summary.html", type:"package" }, { id:90, label:"com.google.inject.multibindings.MapBinder", link:"com/google/inject/multibindings/MapBinder.html", type:"class" }, { id:91, label:"com.google.inject.multibindings.MapBinderBinding", link:"com/google/inject/multibindings/MapBinderBinding.html", type:"class" }, { id:92, label:"com.google.inject.multibindings.Multibinder", link:"com/google/inject/multibindings/Multibinder.html", type:"class" }, { id:93, label:"com.google.inject.multibindings.MultibinderBinding", link:"com/google/inject/multibindings/MultibinderBinding.html", type:"class" }, { id:94, label:"com.google.inject.multibindings.MultibindingsTargetVisitor", link:"com/google/inject/multibindings/MultibindingsTargetVisitor.html", type:"class" }, { id:95, label:"com.google.inject.name", link:"com/google/inject/name/package-summary.html", type:"package" }, { id:96, label:"com.google.inject.name.Named", link:"com/google/inject/name/Named.html", type:"class" }, { id:97, label:"com.google.inject.name.Names", link:"com/google/inject/name/Names.html", type:"class" }, { id:98, label:"com.google.inject.persist", link:"com/google/inject/persist/package-summary.html", type:"package" }, { id:99, label:"com.google.inject.persist.PersistFilter", link:"com/google/inject/persist/PersistFilter.html", type:"class" }, { id:100, label:"com.google.inject.persist.PersistModule", link:"com/google/inject/persist/PersistModule.html", type:"class" }, { id:101, label:"com.google.inject.persist.PersistService", link:"com/google/inject/persist/PersistService.html", type:"class" }, { id:102, label:"com.google.inject.persist.Transactional", link:"com/google/inject/persist/Transactional.html", type:"class" }, { id:103, label:"com.google.inject.persist.UnitOfWork", link:"com/google/inject/persist/UnitOfWork.html", type:"class" }, { id:104, label:"com.google.inject.persist.finder", link:"com/google/inject/persist/finder/package-summary.html", type:"package" }, { id:105, label:"com.google.inject.persist.finder.DynamicFinder", link:"com/google/inject/persist/finder/DynamicFinder.html", type:"class" }, { id:106, label:"com.google.inject.persist.finder.Finder", link:"com/google/inject/persist/finder/Finder.html", type:"class" }, { id:107, label:"com.google.inject.persist.finder.FirstResult", link:"com/google/inject/persist/finder/FirstResult.html", type:"class" }, { id:108, label:"com.google.inject.persist.finder.MaxResults", link:"com/google/inject/persist/finder/MaxResults.html", type:"class" }, { id:109, label:"com.google.inject.persist.jpa", link:"com/google/inject/persist/jpa/package-summary.html", type:"package" }, { id:110, label:"com.google.inject.persist.jpa.JpaPersistModule", link:"com/google/inject/persist/jpa/JpaPersistModule.html", type:"class" }, { id:111, label:"com.google.inject.servlet", link:"com/google/inject/servlet/package-summary.html", type:"package" }, { id:112, label:"com.google.inject.servlet.GuiceFilter", link:"com/google/inject/servlet/GuiceFilter.html", type:"class" }, { id:113, label:"com.google.inject.servlet.GuiceServletContextListener", link:"com/google/inject/servlet/GuiceServletContextListener.html", type:"class" }, { id:114, label:"com.google.inject.servlet.InstanceFilterBinding", link:"com/google/inject/servlet/InstanceFilterBinding.html", type:"class" }, { id:115, label:"com.google.inject.servlet.InstanceServletBinding", link:"com/google/inject/servlet/InstanceServletBinding.html", type:"class" }, { id:116, label:"com.google.inject.servlet.LinkedFilterBinding", link:"com/google/inject/servlet/LinkedFilterBinding.html", type:"class" }, { id:117, label:"com.google.inject.servlet.LinkedServletBinding", link:"com/google/inject/servlet/LinkedServletBinding.html", type:"class" }, { id:118, label:"com.google.inject.servlet.RequestParameters", link:"com/google/inject/servlet/RequestParameters.html", type:"class" }, { id:119, label:"com.google.inject.servlet.RequestScoped", link:"com/google/inject/servlet/RequestScoped.html", type:"class" }, { id:120, label:"com.google.inject.servlet.ServletModule", link:"com/google/inject/servlet/ServletModule.html", type:"class" }, { id:121, label:"com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder", link:"com/google/inject/servlet/ServletModule.FilterKeyBindingBuilder.html", type:"class" }, { id:122, label:"com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder", link:"com/google/inject/servlet/ServletModule.ServletKeyBindingBuilder.html", type:"class" }, { id:123, label:"com.google.inject.servlet.ServletModuleBinding", link:"com/google/inject/servlet/ServletModuleBinding.html", type:"class" }, { id:124, label:"com.google.inject.servlet.ServletModuleTargetVisitor", link:"com/google/inject/servlet/ServletModuleTargetVisitor.html", type:"class" }, { id:125, label:"com.google.inject.servlet.ServletScopes", link:"com/google/inject/servlet/ServletScopes.html", type:"class" }, { id:126, label:"com.google.inject.servlet.SessionScoped", link:"com/google/inject/servlet/SessionScoped.html", type:"class" }, { id:127, label:"com.google.inject.servlet.UriPatternType", link:"com/google/inject/servlet/UriPatternType.html", type:"class" }, { id:128, label:"com.google.inject.spi", link:"com/google/inject/spi/package-summary.html", type:"package" }, { id:129, label:"com.google.inject.spi.BindingScopingVisitor", link:"com/google/inject/spi/BindingScopingVisitor.html", type:"class" }, { id:130, label:"com.google.inject.spi.BindingTargetVisitor", link:"com/google/inject/spi/BindingTargetVisitor.html", type:"class" }, { id:131, label:"com.google.inject.spi.ConstructorBinding", link:"com/google/inject/spi/ConstructorBinding.html", type:"class" }, { id:132, label:"com.google.inject.spi.ConvertedConstantBinding", link:"com/google/inject/spi/ConvertedConstantBinding.html", type:"class" }, { id:133, label:"com.google.inject.spi.DefaultBindingScopingVisitor", link:"com/google/inject/spi/DefaultBindingScopingVisitor.html", type:"class" }, { id:134, label:"com.google.inject.spi.DefaultBindingTargetVisitor", link:"com/google/inject/spi/DefaultBindingTargetVisitor.html", type:"class" }, { id:135, label:"com.google.inject.spi.DefaultElementVisitor", link:"com/google/inject/spi/DefaultElementVisitor.html", type:"class" }, { id:136, label:"com.google.inject.spi.Dependency", link:"com/google/inject/spi/Dependency.html", type:"class" }, { id:137, label:"com.google.inject.spi.DisableCircularProxiesOption", link:"com/google/inject/spi/DisableCircularProxiesOption.html", type:"class" }, { id:138, label:"com.google.inject.spi.Element", link:"com/google/inject/spi/Element.html", type:"class" }, { id:139, label:"com.google.inject.spi.ElementVisitor", link:"com/google/inject/spi/ElementVisitor.html", type:"class" }, { id:140, label:"com.google.inject.spi.Elements", link:"com/google/inject/spi/Elements.html", type:"class" }, { id:141, label:"com.google.inject.spi.ExposedBinding", link:"com/google/inject/spi/ExposedBinding.html", type:"class" }, { id:142, label:"com.google.inject.spi.HasDependencies", link:"com/google/inject/spi/HasDependencies.html", type:"class" }, { id:143, label:"com.google.inject.spi.InjectionListener", link:"com/google/inject/spi/InjectionListener.html", type:"class" }, { id:144, label:"com.google.inject.spi.InjectionPoint", link:"com/google/inject/spi/InjectionPoint.html", type:"class" }, { id:145, label:"com.google.inject.spi.InjectionRequest", link:"com/google/inject/spi/InjectionRequest.html", type:"class" }, { id:146, label:"com.google.inject.spi.InstanceBinding", link:"com/google/inject/spi/InstanceBinding.html", type:"class" }, { id:147, label:"com.google.inject.spi.InterceptorBinding", link:"com/google/inject/spi/InterceptorBinding.html", type:"class" }, { id:148, label:"com.google.inject.spi.LinkedKeyBinding", link:"com/google/inject/spi/LinkedKeyBinding.html", type:"class" }, { id:149, label:"com.google.inject.spi.MembersInjectorLookup", link:"com/google/inject/spi/MembersInjectorLookup.html", type:"class" }, { id:150, label:"com.google.inject.spi.Message", link:"com/google/inject/spi/Message.html", type:"class" }, { id:151, label:"com.google.inject.spi.PrivateElements", link:"com/google/inject/spi/PrivateElements.html", type:"class" }, { id:152, label:"com.google.inject.spi.ProviderBinding", link:"com/google/inject/spi/ProviderBinding.html", type:"class" }, { id:153, label:"com.google.inject.spi.ProviderInstanceBinding", link:"com/google/inject/spi/ProviderInstanceBinding.html", type:"class" }, { id:154, label:"com.google.inject.spi.ProviderKeyBinding", link:"com/google/inject/spi/ProviderKeyBinding.html", type:"class" }, { id:155, label:"com.google.inject.spi.ProviderLookup", link:"com/google/inject/spi/ProviderLookup.html", type:"class" }, { id:156, label:"com.google.inject.spi.ProviderWithDependencies", link:"com/google/inject/spi/ProviderWithDependencies.html", type:"class" }, { id:157, label:"com.google.inject.spi.ProviderWithExtensionVisitor", link:"com/google/inject/spi/ProviderWithExtensionVisitor.html", type:"class" }, { id:158, label:"com.google.inject.spi.RequireExplicitBindingsOption", link:"com/google/inject/spi/RequireExplicitBindingsOption.html", type:"class" }, { id:159, label:"com.google.inject.spi.ScopeBinding", link:"com/google/inject/spi/ScopeBinding.html", type:"class" }, { id:160, label:"com.google.inject.spi.StaticInjectionRequest", link:"com/google/inject/spi/StaticInjectionRequest.html", type:"class" }, { id:161, label:"com.google.inject.spi.Toolable", link:"com/google/inject/spi/Toolable.html", type:"class" }, { id:162, label:"com.google.inject.spi.TypeConverter", link:"com/google/inject/spi/TypeConverter.html", type:"class" }, { id:163, label:"com.google.inject.spi.TypeConverterBinding", link:"com/google/inject/spi/TypeConverterBinding.html", type:"class" }, { id:164, label:"com.google.inject.spi.TypeEncounter", link:"com/google/inject/spi/TypeEncounter.html", type:"class" }, { id:165, label:"com.google.inject.spi.TypeListener", link:"com/google/inject/spi/TypeListener.html", type:"class" }, { id:166, label:"com.google.inject.spi.TypeListenerBinding", link:"com/google/inject/spi/TypeListenerBinding.html", type:"class" }, { id:167, label:"com.google.inject.spi.UntargettedBinding", link:"com/google/inject/spi/UntargettedBinding.html", type:"class" }, { id:168, label:"com.google.inject.spring", link:"com/google/inject/spring/package-summary.html", type:"package" }, { id:169, label:"com.google.inject.spring.SpringIntegration", link:"com/google/inject/spring/SpringIntegration.html", type:"class" }, { id:170, label:"com.google.inject.throwingproviders", link:"com/google/inject/throwingproviders/package-summary.html", type:"package" }, { id:171, label:"com.google.inject.throwingproviders.CheckedProvider", link:"com/google/inject/throwingproviders/CheckedProvider.html", type:"class" }, { id:172, label:"com.google.inject.throwingproviders.CheckedProvides", link:"com/google/inject/throwingproviders/CheckedProvides.html", type:"class" }, { id:173, label:"com.google.inject.throwingproviders.ThrowingProvider", link:"com/google/inject/throwingproviders/ThrowingProvider.html", type:"class" }, { id:174, label:"com.google.inject.throwingproviders.ThrowingProviderBinder", link:"com/google/inject/throwingproviders/ThrowingProviderBinder.html", type:"class" }, { id:175, label:"com.google.inject.throwingproviders.ThrowingProviderBinder.SecondaryBinder", link:"com/google/inject/throwingproviders/ThrowingProviderBinder.SecondaryBinder.html", type:"class" }, { id:176, label:"com.google.inject.tools.jmx", link:"com/google/inject/tools/jmx/package-summary.html", type:"package" }, { id:177, label:"com.google.inject.tools.jmx.ManagedBindingMBean", link:"com/google/inject/tools/jmx/ManagedBindingMBean.html", type:"class" }, { id:178, label:"com.google.inject.tools.jmx.Manager", link:"com/google/inject/tools/jmx/Manager.html", type:"class" }, { id:179, label:"com.google.inject.util", link:"com/google/inject/util/package-summary.html", type:"package" }, { id:180, label:"com.google.inject.util.Modules", link:"com/google/inject/util/Modules.html", type:"class" }, { id:181, label:"com.google.inject.util.Modules.OverriddenModuleBuilder", link:"com/google/inject/util/Modules.OverriddenModuleBuilder.html", type:"class" }, { id:182, label:"com.google.inject.util.Providers", link:"com/google/inject/util/Providers.html", type:"class" }, { id:183, label:"com.google.inject.util.Types", link:"com/google/inject/util/Types.html", type:"class" } ]; sisu-guice-sisu-guice-3.1.1/latest-javadoc/index.html0000755000175000017500000000014711704661106021315 0ustar tonytony sisu-guice-sisu-guice-3.1.1/latest-javadoc/hierarchy.html0000755000175000017500000007542511704661106022177 0ustar tonytony Class Hierarchy | Guice

Class Hierarchy

Class Interfaces
 
AbstractModule Module     
GrapherModule  
GraphvizModule  
PersistModule  
JpaPersistModule  
ServletModule  
Guice  
Key  
PrivateModule Module     
Scopes  
TypeLiteral  
FactoryModuleBuilder  
FactoryProvider Provider    HasDependencies     
GraphingVisitor BindingTargetVisitor     
InjectorGrapher  
ShortNameFactory NameFactory     
StringNodeIdFactory NodeIdFactory     
TransitiveDependencyVisitor BindingTargetVisitor     
BindingEdgeFactory BindingEdge.Factory     
BindingEdgeFactory.GraphvizEdgeAdaptor BindingEdge     
DependencyEdgeFactory DependencyEdge.Factory     
DependencyEdgeFactory.GraphvizEdgeAdaptor DependencyEdge     
GraphvizEdge  
GraphvizNode  
GraphvizRenderer NodeAliasFactory    Renderer     
ImplementationNodeFactory ImplementationNode.Factory     
ImplementationNodeFactory.GraphvizNodeAdaptor ImplementationNode     
InterfaceNodeFactory InterfaceNode.Factory     
InterfaceNodeFactory.GraphvizNodeAdaptor InterfaceNode     
PortIdFactoryImpl PortIdFactory     
JndiIntegration  
AbstractMatcher Matcher     
Matchers  
MapBinder  
Multibinder  
Names  
PersistFilter  
DynamicFinder  
GuiceFilter  
GuiceServletContextListener  
ServletScopes  
DefaultBindingScopingVisitor BindingScopingVisitor     
DefaultBindingTargetVisitor BindingTargetVisitor     
DefaultElementVisitor ElementVisitor     
Dependency  
DisableCircularProxiesOption Element     
Elements  
InjectionPoint  
InjectionRequest Element     
InterceptorBinding Element     
MembersInjectorLookup Element     
Message Element    Serializable     
ProviderLookup Element     
RequireExplicitBindingsOption Element     
ScopeBinding Element     
StaticInjectionRequest Element     
TypeConverterBinding Element     
TypeListenerBinding Element     
SpringIntegration  
ThrowingProviderBinder  
ThrowingProviderBinder.SecondaryBinder  
Manager  
Modules  
Providers  
Types  
sisu-guice-sisu-guice-3.1.1/latest-javadoc/current.xml0000755000175000017500000074006011704661106021531 0ustar tonytony sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/0000755000175000017500000000000011704661106020071 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/0000755000175000017500000000000011704661106021345 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/0000755000175000017500000000000011704661106022621 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/util/0000755000175000017500000000000011704661106023576 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/util/package-summary.html0000755000175000017500000002732011704661106027561 0ustar tonytony com.google.inject.util | Guice
package

com.google.inject.util

Classes | Description

Helper methods for working with Guice.

more...

Interfaces

Modules.OverriddenModuleBuilder See the EDSL example at override()

Classes

Modules Static utility methods for creating and working with instances of Module
Providers Static utility methods for creating and working with instances of Provider
Types Static methods for working with types. 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/util/package-descr.html0000755000175000017500000002361511704661106027167 0ustar tonytony com.google.inject.util Details | Guice
package

com.google.inject.util

Classes | Description

Helper methods for working with Guice.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/util/Types.html0000755000175000017500000007321611704661106025604 0ustar tonytony Types | Guice
public final class

Types

extends Object
java.lang.Object
   ↳ com.google.inject.util.Types

Class Overview

Static methods for working with types.

Summary

Public Methods
static GenericArrayType arrayOf(Type componentType)
Returns an array type whose elements are all instances of componentType.
static ParameterizedType listOf(Type elementType)
Returns a type modelling a List whose elements are of type elementType.
static ParameterizedType mapOf(Type keyType, Type valueType)
Returns a type modelling a Map whose keys are of type keyType and whose values are of type valueType.
static ParameterizedType newParameterizedType(Type rawType, Type... typeArguments)
Returns a new parameterized type, applying typeArguments to rawType.
static ParameterizedType newParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments)
Returns a new parameterized type, applying typeArguments to rawType and enclosed by ownerType.
static ParameterizedType providerOf(Type providedType)
Returns a type modelling a Provider that provides elements of type elementType.
static ParameterizedType setOf(Type elementType)
Returns a type modelling a Set whose elements are of type elementType.
static WildcardType subtypeOf(Type bound)
Returns a type that represents an unknown type that extends bound.
static WildcardType supertypeOf(Type bound)
Returns a type that represents an unknown supertype of bound.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static GenericArrayType arrayOf (Type componentType)

Returns an array type whose elements are all instances of componentType.

Returns
  • a java.io.Serializable serializable generic array type.

public static ParameterizedType listOf (Type elementType)

Returns a type modelling a List whose elements are of type elementType.

Returns
  • a java.io.Serializable serializable parameterized type.

public static ParameterizedType mapOf (Type keyType, Type valueType)

Returns a type modelling a Map whose keys are of type keyType and whose values are of type valueType.

Returns
  • a java.io.Serializable serializable parameterized type.

public static ParameterizedType newParameterizedType (Type rawType, Type... typeArguments)

Returns a new parameterized type, applying typeArguments to rawType. The returned type does not have an owner type.

Returns
  • a java.io.Serializable serializable parameterized type.

public static ParameterizedType newParameterizedTypeWithOwner (Type ownerType, Type rawType, Type... typeArguments)

Returns a new parameterized type, applying typeArguments to rawType and enclosed by ownerType.

Returns
  • a java.io.Serializable serializable parameterized type.

public static ParameterizedType providerOf (Type providedType)

Returns a type modelling a Provider that provides elements of type elementType.

Returns
  • a java.io.Serializable serializable parameterized type.

public static ParameterizedType setOf (Type elementType)

Returns a type modelling a Set whose elements are of type elementType.

Returns
  • a java.io.Serializable serializable parameterized type.

public static WildcardType subtypeOf (Type bound)

Returns a type that represents an unknown type that extends bound. For example, if bound is CharSequence.class, this returns ? extends CharSequence. If bound is Object.class, this returns ?, which is shorthand for ? extends Object.

public static WildcardType supertypeOf (Type bound)

Returns a type that represents an unknown supertype of bound. For example, if bound is String.class, this returns ? super String.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/util/Providers.html0000755000175000017500000004631011704661106026450 0ustar tonytony Providers | Guice
public final class

Providers

extends Object
java.lang.Object
   ↳ com.google.inject.util.Providers

Class Overview

Static utility methods for creating and working with instances of Provider.

Summary

Public Methods
static <T> Provider<T> guicify(Provider<T> provider)
Returns a Guice-friendly com.google.inject.Provider for the given JSR-330 javax.inject.Provider.
static <T> Provider<T> of(T instance)
Returns a provider which always provides instance.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Provider<T> guicify (Provider<T> provider)

Returns a Guice-friendly com.google.inject.Provider for the given JSR-330 javax.inject.Provider. The converse method is unnecessary, since Guice providers directly implement the JSR-330 interface.

public static Provider<T> of (T instance)

Returns a provider which always provides instance. This should not be necessary to use in your application, but is helpful for several types of unit tests.

Parameters
instance the instance that should always be provided. This is also permitted to be null, to enable aggressive testing, although in real life a Guice-supplied Provider will never return null.
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/util/Modules.html0000755000175000017500000006410011704661106026100 0ustar tonytony Modules | Guice
public final class

Modules

extends Object
java.lang.Object
   ↳ com.google.inject.util.Modules

Class Overview

Static utility methods for creating and working with instances of Module.

Summary

Nested Classes
interface Modules.OverriddenModuleBuilder See the EDSL example at override()
Constants
Module EMPTY_MODULE
Public Methods
static Module combine(Module... modules)
Returns a new module that installs all of modules.
static Module combine(Iterable<? extends Module> modules)
Returns a new module that installs all of modules.
static Modules.OverriddenModuleBuilder override(Module... modules)
Returns a builder that creates a module that overlays override modules over the given modules.
static Modules.OverriddenModuleBuilder override(Iterable<? extends Module> modules)
Returns a builder that creates a module that overlays override modules over the given modules.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final Module EMPTY_MODULE

Public Methods

public static Module combine (Module... modules)

Returns a new module that installs all of modules.

public static Module combine (Iterable<? extends Module> modules)

Returns a new module that installs all of modules.

public static Modules.OverriddenModuleBuilder override (Module... modules)

Returns a builder that creates a module that overlays override modules over the given modules. If a key is bound in both sets of modules, only the binding from the override modules is kept. If a single PrivateModule is supplied or all elements are from a single PrivateBinder, then this will overwrite the private bindings. Otherwise, private bindings will not be overwritten unless they are exposed. This can be used to replace the bindings of a production module with test bindings:

 Module functionalTestModule
     = Modules.override(new ProductionModule()).with(new TestModule());
 

Prefer to write smaller modules that can be reused and tested without overrides.

Parameters
modules the modules whose bindings are open to be overridden

public static Modules.OverriddenModuleBuilder override (Iterable<? extends Module> modules)

Returns a builder that creates a module that overlays override modules over the given modules. If a key is bound in both sets of modules, only the binding from the override modules is kept. If a single PrivateModule is supplied or all elements are from a single PrivateBinder, then this will overwrite the private bindings. Otherwise, private bindings will not be overwritten unless they are exposed. This can be used to replace the bindings of a production module with test bindings:

 Module functionalTestModule
     = Modules.override(getProductionModules()).with(getTestModules());
 

Prefer to write smaller modules that can be reused and tested without overrides.

Parameters
modules the modules whose bindings are open to be overridden
././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/util/Modules.OverriddenModuleBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/util/Modules.OverriddenModuleBuilder.ht0000755000175000017500000003470311704661106032332 0ustar tonytony Modules.OverriddenModuleBuilder | Guice
public static interface

Modules.OverriddenModuleBuilder

com.google.inject.util.Modules.OverriddenModuleBuilder

Class Overview

See the EDSL example at override().

Summary

Public Methods
abstract Module with(Module... overrides)
See the EDSL example at override().
abstract Module with(Iterable<? extends Module> overrides)
See the EDSL example at override().

Public Methods

public abstract Module with (Module... overrides)

See the EDSL example at override().

public abstract Module with (Iterable<? extends Module> overrides)

See the EDSL example at override().

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/tools/0000755000175000017500000000000011704661106023761 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/tools/jmx/0000755000175000017500000000000011704661106024557 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/tools/jmx/package-summary.html0000755000175000017500000002536011704661106030544 0ustar tonytony com.google.inject.tools.jmx | Guice
package

com.google.inject.tools.jmx

Classes | Description

JMX integration; this extension requires guice-jmx-3.0.jar.

more...

Interfaces

ManagedBindingMBean JMX interface to bindings. 

Classes

Manager Provides a JMX interface to Guice. 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/tools/jmx/package-descr.html0000755000175000017500000002346711704661106030155 0ustar tonytony com.google.inject.tools.jmx Details | Guice
package

com.google.inject.tools.jmx

Classes | Description

JMX integration; this extension requires guice-jmx-3.0.jar.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/tools/jmx/Manager.html0000755000175000017500000005266311704661106027036 0ustar tonytony Manager | Guice
public class

Manager

extends Object
java.lang.Object
   ↳ com.google.inject.tools.jmx.Manager

Class Overview

Provides a JMX interface to Guice.

Summary

Public Constructors
Manager()
Public Methods
static void main(String[] args)
Run with no arguments for usage instructions.
static void manage(String domain, Injector injector)
Registers all the bindings of an Injector with the platform MBean server.
static void manage(MBeanServer server, String domain, Injector injector)
Registers all the bindings of an Injector with the given MBean server.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Manager ()

Public Methods

public static void main (String[] args)

Run with no arguments for usage instructions.

Throws
Exception

public static void manage (String domain, Injector injector)

Registers all the bindings of an Injector with the platform MBean server. Consider using the name of your root Module class as the domain.

public static void manage (MBeanServer server, String domain, Injector injector)

Registers all the bindings of an Injector with the given MBean server. Consider using the name of your root Module class as the domain.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/tools/jmx/ManagedBindingMBean.html0000755000175000017500000003422111704661106031204 0ustar tonytony ManagedBindingMBean | Guice
public interface

ManagedBindingMBean

com.google.inject.tools.jmx.ManagedBindingMBean

Class Overview

JMX interface to bindings.

Summary

Public Methods
abstract String getKey()
Gets the binding key.
abstract String getProvider()
Gets the provider to which this binding is bound.
abstract String getSource()
Gets the source of this binding.

Public Methods

public abstract String getKey ()

Gets the binding key.

public abstract String getProvider ()

Gets the provider to which this binding is bound.

public abstract String getSource ()

Gets the source of this binding.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/throwingproviders/0000755000175000017500000000000011704661106026420 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/throwingproviders/package-summary.html0000755000175000017500000003115411704661106032403 0ustar tonytony com.google.inject.throwingproviders | Guice
package

com.google.inject.throwingproviders

Classes | Description

Extension for injecting objects that may throw at provision time; this extension requires guice-throwingproviders-3.0.jar.

more...

Interfaces

CheckedProvider<T> Alternative to the Guice Provider that throws a checked Exception. 
ThrowingProvider<T, E extends Exception> This interface is deprecated. use CheckedProvider instead.  

Classes

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/throwingproviders/package-descr.html0000755000175000017500000002501711704661106032007 0ustar tonytony com.google.inject.throwingproviders Details | Guice
package

com.google.inject.throwingproviders

Classes | Description

Extension for injecting objects that may throw at provision time; this extension requires guice-throwingproviders-3.0.jar.

././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/throwingproviders/ThrowingProviderBinder.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/throwingproviders/ThrowingProviderBinde0000755000175000017500000005436211704661106032636 0ustar tonytony ThrowingProviderBinder | Guice
public class

ThrowingProviderBinder

extends Object
java.lang.Object
   ↳ com.google.inject.throwingproviders.ThrowingProviderBinder

Class Overview

Builds a binding for a CheckedProvider.

You can use a fluent API and custom providers:

ThrowingProviderBinder.create(binder())
    .bind(RemoteProvider.class, Customer.class)
    .to(RemoteCustomerProvider.class)
    .in(RequestScope.class);
 
or, you can use throwing provider methods:
class MyModule extends AbstractModule {
   configure() {
     ThrowingProviderBinder.install(this, binder());
   }
   
   @CheckedProvides(RemoteProvider.class)
   @RequestScope
   Customer provideCustomer(FlakyCustomerCreator creator) throws RemoteException {
     return creator.getCustomerOrThrow();
   }
 }
 

Summary

Nested Classes
class ThrowingProviderBinder.SecondaryBinder<P extends CheckedProvider>  
Public Methods
<P extends CheckedProvider> SecondaryBinder<P> bind(Class<P> interfaceType, Type valueType)
static ThrowingProviderBinder create(Binder binder)
static Module forModule(Module module)
Returns a module that installs @CheckedProvides methods.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public SecondaryBinder<P> bind (Class<P> interfaceType, Type valueType)

public static ThrowingProviderBinder create (Binder binder)

public static Module forModule (Module module)

Returns a module that installs @CheckedProvides methods.

././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/throwingproviders/ThrowingProviderBinder.SecondaryBinder.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/throwingproviders/ThrowingProviderBinde0000755000175000017500000006144511704661106032636 0ustar tonytony ThrowingProviderBinder.SecondaryBinder | Guice
public class

ThrowingProviderBinder.SecondaryBinder

extends Object
java.lang.Object
   ↳ com.google.inject.throwingproviders.ThrowingProviderBinder.SecondaryBinder<P extends com.google.inject.throwingproviders.CheckedProvider>

Summary

Public Constructors
ThrowingProviderBinder.SecondaryBinder(Class<P> interfaceType, Type valueType)
Public Methods
SecondaryBinder<P> annotatedWith(Class<? extends Annotation> annotationType)
SecondaryBinder<P> annotatedWith(Annotation annotation)
ScopedBindingBuilder to(P target)
ScopedBindingBuilder to(Key<? extends P> targetKey)
ScopedBindingBuilder to(Class<? extends P> targetType)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ThrowingProviderBinder.SecondaryBinder (Class<P> interfaceType, Type valueType)

Public Methods

public SecondaryBinder<P> annotatedWith (Class<? extends Annotation> annotationType)

public SecondaryBinder<P> annotatedWith (Annotation annotation)

public ScopedBindingBuilder to (P target)

public ScopedBindingBuilder to (Key<? extends P> targetKey)

public ScopedBindingBuilder to (Class<? extends P> targetType)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/throwingproviders/ThrowingProvider.html0000755000175000017500000003741311704661106032635 0ustar tonytony ThrowingProvider | Guice
public interface

ThrowingProvider

implements CheckedProvider<T>
com.google.inject.throwingproviders.ThrowingProvider<T, E extends java.lang.Exception>

This interface is deprecated.
use CheckedProvider instead.

Class Overview

Alternative to the Guice Provider that throws a checked Exception. Users may not inject T directly.

This interface must be extended to use application-specific exception types. Such subinterfaces may not define new methods:

 public interface RemoteProvider<T> extends ThrowingProvider<T, RemoteException> { }
 

When this type is bound using ThrowingProviderBinder, the value returned or exception thrown by get() will be scoped. As a consequence, get() will invoked at most once within each scope.

Summary

Public Methods
abstract T get()
[Expand]
Inherited Methods
From interface com.google.inject.throwingproviders.CheckedProvider

Public Methods

public abstract T get ()

Throws
Exception
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/throwingproviders/CheckedProvides.html0000755000175000017500000003472611704661106032367 0ustar tonytony CheckedProvides | Guice
public abstract @interface

CheckedProvides

implements Annotation
com.google.inject.throwingproviders.CheckedProvides

Class Overview

Annotates methods of a Module to create a CheckedProvider method binding that can throw exceptions. The method's return type is bound to a CheckedProvider that can be injected. Guice will pass dependencies to the method as parameters. Install @CheckedProvides methods by using forModule(com.google.inject.Module) on the module where the methods are declared.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/throwingproviders/CheckedProvider.html0000755000175000017500000003624311704661106032362 0ustar tonytony CheckedProvider | Guice
public interface

CheckedProvider

com.google.inject.throwingproviders.CheckedProvider<T>
Known Indirect Subclasses

Class Overview

Alternative to the Guice Provider that throws a checked Exception. Users may not inject T directly.

This interface must be extended to use application-specific exception types. Such subinterfaces may not define new methods, but may narrow the exception type.

 public interface RemoteProvider<T> extends CheckedProvider<T> { 
   T get() throws CustomExceptionOne, CustomExceptionTwo;
 }
 

When this type is bound using ThrowingProviderBinder, the value returned or exception thrown by get() will be scoped. As a consequence, get() will invoked at most once within each scope.

Summary

Public Methods
abstract T get()

Public Methods

public abstract T get ()

Throws
Exception
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spring/0000755000175000017500000000000011704661106024123 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spring/package-summary.html0000755000175000017500000002403011704661106030101 0ustar tonytony com.google.inject.spring | Guice
package

com.google.inject.spring

Classes | Description

Spring integration; this extension requires guice-spring-3.0.jar.

more...

Classes

SpringIntegration Integrates Guice with Spring. 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spring/package-descr.html0000755000175000017500000002300011704661106027500 0ustar tonytony com.google.inject.spring Details | Guice
package

com.google.inject.spring

Classes | Description

Spring integration; this extension requires guice-spring-3.0.jar.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spring/SpringIntegration.html0000755000175000017500000004542611704661106030475 0ustar tonytony SpringIntegration | Guice
public class

SpringIntegration

extends Object
java.lang.Object
   ↳ com.google.inject.spring.SpringIntegration

Class Overview

Integrates Guice with Spring.

Summary

Public Methods
static void bindAll(Binder binder, ListableBeanFactory beanFactory)
Binds all Spring beans from the given factory by name.
static <T> Provider<T> fromSpring(Class<T> type, String name)
Creates a provider which looks up objects from Spring using the given name.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static void bindAll (Binder binder, ListableBeanFactory beanFactory)

Binds all Spring beans from the given factory by name. For a Spring bean named "foo", this method creates a binding to the bean's type and @Named("foo").

public static Provider<T> fromSpring (Class<T> type, String name)

Creates a provider which looks up objects from Spring using the given name. Expects a binding to org.springframework.beans.factory.BeanFactory. Example usage:

 bind(DataSource.class)
   .toProvider(fromSpring(DataSource.class, "dataSource"));
 

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/0000755000175000017500000000000011704661106023414 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/package-summary.html0000755000175000017500000006707111704661106027406 0ustar tonytony com.google.inject.spi | Guice
package

com.google.inject.spi

Classes | Description

Guice service provider interface

Interfaces

BindingScopingVisitor<V> Visits each of the strategies used to scope an injection. 
BindingTargetVisitor<T, V> Visits each of the strategies used to find an instance to satisfy an injection. 
ConstructorBinding<T> A binding to the constructor of a concrete clss. 
ConvertedConstantBinding<T> A binding created from converting a bound instance to a new type. 
Element A core component of a module or injector. 
ElementVisitor<V> Visit elements. 
ExposedBinding<T> A binding to a key exposed from an enclosed private environment. 
HasDependencies Implemented by bindings, providers and instances that expose their dependencies explicitly. 
InjectionListener<I> Listens for injections into instances of type I
InstanceBinding<T> A binding to a single instance. 
LinkedKeyBinding<T> A binding to a linked key. 
PrivateElements A private collection of elements that are hidden from the enclosing injector or module by default. 
ProviderBinding<T extends Provider<?>> A binding to a Provider that delegates to the binding for the provided type. 
ProviderInstanceBinding<T> A binding to a provider instance. 
ProviderKeyBinding<T> A binding to a provider key. 
ProviderWithDependencies<T> A provider with dependencies on other injected types. 
ProviderWithExtensionVisitor<T> A Provider that is part of an extension which supports a custom BindingTargetVisitor. 
TypeConverter Converts constant string values to a different type. 
TypeEncounter<I> Context of an injectable type encounter. 
TypeListener Listens for Guice to encounter injectable types. 
UntargettedBinding<T> An untargetted binding. 

Classes

DefaultBindingScopingVisitor<V> No-op visitor for subclassing. 
DefaultBindingTargetVisitor<T, V> No-op visitor for subclassing. 
DefaultElementVisitor<V> No-op visitor for subclassing. 
Dependency<T> A variable that can be resolved by an injector. 
DisableCircularProxiesOption A request to disable circular proxies. 
Elements Exposes elements of a module so they can be inspected, validated or rewritten
InjectionPoint A constructor, field or method that can receive injections. 
InjectionRequest<T> A request to inject the instance fields and methods of an instance. 
InterceptorBinding Registration of interceptors for matching methods of matching classes. 
MembersInjectorLookup<T> A lookup of the members injector for a type. 
Message An error message and the context in which it occured. 
ProviderLookup<T> A lookup of the provider for a type. 
RequireExplicitBindingsOption A request to require explicit bindings. 
ScopeBinding Registration of a scope annotation with the scope that implements it. 
StaticInjectionRequest A request to inject the static fields and methods of a type. 
TypeConverterBinding Registration of type converters for matching target types. 
TypeListenerBinding Binds types (picked using a Matcher) to an type listener. 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/package-descr.html0000755000175000017500000003577511704661106027017 0ustar tonytony com.google.inject.spi Details | Guice
package

com.google.inject.spi

Classes | Description

Guice service provider interface

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/UntargettedBinding.html0000755000175000017500000005454311704661106030101 0ustar tonytony UntargettedBinding | Guice
public interface

UntargettedBinding

implements Binding<T>
com.google.inject.spi.UntargettedBinding<T>

Class Overview

An untargetted binding. This binding indicates that the injector should use its implicit binding strategies to resolve injections.

Summary

[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/TypeListenerBinding.html0000755000175000017500000007704311704661106030242 0ustar tonytony TypeListenerBinding | Guice
public final class

TypeListenerBinding

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.TypeListenerBinding

Class Overview

Binds types (picked using a Matcher) to an type listener. Registrations are created explicitly in a module using bindListener(Matcher, TypeListener) statements:

     register(only(new TypeLiteral<PaymentService<CreditCard>>() {}), listener);

Summary

Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
TypeListener getListener()
Returns the registered listener.
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
Matcher<? super TypeLiteral<?>> getTypeMatcher()
Returns the type matcher which chooses which types the listener should be notified of.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public TypeListener getListener ()

Returns the registered listener.

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

public Matcher<? super TypeLiteral<?>> getTypeMatcher ()

Returns the type matcher which chooses which types the listener should be notified of.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/TypeListener.html0000755000175000017500000004565011704661106026746 0ustar tonytony TypeListener | Guice
public interface

TypeListener

com.google.inject.spi.TypeListener

Class Overview

Listens for Guice to encounter injectable types. If a given type has its constructor injected in one situation but only its methods and fields injected in another, Guice will notify this listener once.

Useful for extra type checking, registering injection listeners, and binding method interceptors.

Summary

Public Methods
abstract <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter)
Invoked when Guice encounters a new type eligible for constructor or members injection.

Public Methods

public abstract void hear (TypeLiteral<I> type, TypeEncounter<I> encounter)

Invoked when Guice encounters a new type eligible for constructor or members injection. Called during injector creation (or afterwords if Guice encounters a type at run time and creates a JIT binding).

Parameters
type encountered by Guice
encounter context of this encounter, enables reporting errors, registering injection listeners and binding method interceptors for type.
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/TypeEncounter.html0000755000175000017500000010374011704661106027116 0ustar tonytony TypeEncounter | Guice
public interface

TypeEncounter

com.google.inject.spi.TypeEncounter<I>

Class Overview

Context of an injectable type encounter. Enables reporting errors, registering injection listeners and binding method interceptors for injectable type I. It is an error to use an encounter after the hear() method has returned.

Summary

Public Methods
abstract void addError(Message message)
Records an error message to be presented to the user at a later time.
abstract void addError(String message, Object... arguments)
Records an error message for type I which will be presented to the user at a later time.
abstract void addError(Throwable t)
Records an exception for type I, the full details of which will be logged, and the message of which will be presented to the user at a later time.
abstract void bindInterceptor(Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)
Binds method interceptor[s] to methods matched in type I and its supertypes.
abstract <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral)
Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
abstract <T> MembersInjector<T> getMembersInjector(Class<T> type)
Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
abstract <T> Provider<T> getProvider(Key<T> key)
Returns the provider used to obtain instances for the given injection key.
abstract <T> Provider<T> getProvider(Class<T> type)
Returns the provider used to obtain instances for the given injection type.
abstract void register(MembersInjector<? super I> membersInjector)
Registers a members injector for type I.
abstract void register(InjectionListener<? super I> listener)
Registers an injection listener for type I.

Public Methods

public abstract void addError (Message message)

Records an error message to be presented to the user at a later time.

public abstract void addError (String message, Object... arguments)

Records an error message for type I which will be presented to the user at a later time. Unlike throwing an exception, this enable us to continue configuring the Injector and discover more errors. Uses format(String, Object[]) to insert the arguments into the message.

public abstract void addError (Throwable t)

Records an exception for type I, the full details of which will be logged, and the message of which will be presented to the user at a later time. If your type listener calls something that you worry may fail, you should catch the exception and pass it to this method.

public abstract void bindInterceptor (Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)

Binds method interceptor[s] to methods matched in type I and its supertypes. A method is eligible for interception if:

  • Guice created the instance the method is on
  • Neither the enclosing type nor the method is final
  • And the method is package-private or more accessible

Parameters
methodMatcher matches methods the interceptor should apply to. For example: annotatedWith(Transactional.class).
interceptors to bind

public abstract MembersInjector<T> getMembersInjector (TypeLiteral<T> typeLiteral)

Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. The returned members injector will not be valid until the main injector has been created. The members injector will throw an IllegalStateException if you try to use it beforehand.

Parameters
typeLiteral type to get members injector for

public abstract MembersInjector<T> getMembersInjector (Class<T> type)

Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. The returned members injector will not be valid until the main injector has been created. The members injector will throw an IllegalStateException if you try to use it beforehand.

Parameters
type type to get members injector for

public abstract Provider<T> getProvider (Key<T> key)

Returns the provider used to obtain instances for the given injection key. The returned provider will not be valid until the injector has been created. The provider will throw an IllegalStateException if you try to use it beforehand.

public abstract Provider<T> getProvider (Class<T> type)

Returns the provider used to obtain instances for the given injection type. The returned provider will not be valid until the injetor has been created. The provider will throw an IllegalStateException if you try to use it beforehand.

public abstract void register (MembersInjector<? super I> membersInjector)

Registers a members injector for type I. Guice will use the members injector after its performed its own injections on an instance of I.

public abstract void register (InjectionListener<? super I> listener)

Registers an injection listener for type I. Guice will notify the listener after all injections have been performed on an instance of I.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/TypeConverterBinding.html0000755000175000017500000010452511704661106030420 0ustar tonytony TypeConverterBinding | Guice
public final class

TypeConverterBinding

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.TypeConverterBinding

Class Overview

Registration of type converters for matching target types. Instances are created explicitly in a module using convertToTypes() statements:

     convertToTypes(Matchers.only(TypeLiteral.get(DateTime.class)), new DateTimeConverter());

Summary

Public Constructors
TypeConverterBinding(Object source, Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter typeConverter)
Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
TypeConverter getTypeConverter()
Matcher<? super TypeLiteral<?>> getTypeMatcher()
String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Constructors

public TypeConverterBinding (Object source, Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter typeConverter)

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

public TypeConverter getTypeConverter ()

public Matcher<? super TypeLiteral<?>> getTypeMatcher ()

public String toString ()

Since: API Level

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/TypeConverter.html0000755000175000017500000004300411704661106027117 0ustar tonytony TypeConverter | Guice
public interface

TypeConverter

com.google.inject.spi.TypeConverter

Class Overview

Converts constant string values to a different type.

Summary

Public Methods
abstract Object convert(String value, TypeLiteral<?> toType)
Converts a string value.

Public Methods

public abstract Object convert (String value, TypeLiteral<?> toType)

Converts a string value. Throws an exception if a conversion error occurs.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/Toolable.html0000755000175000017500000004642211704661106026056 0ustar tonytony Toolable | Guice
public abstract @interface

Toolable

implements Annotation
com.google.inject.spi.Toolable

Class Overview

Instructs an Injector running in TOOL that a method should be injected. This is typically useful for for extensions to Guice that perform additional validation in an injected method or field. This only applies to objects that are already constructed when bindings are created (ie., something bound using toProvider, toInstance, or requestInjection.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/StaticInjectionRequest.html0000755000175000017500000010011111704661106030742 0ustar tonytony StaticInjectionRequest | Guice
public final class

StaticInjectionRequest

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.StaticInjectionRequest

Class Overview

A request to inject the static fields and methods of a type. Requests are created explicitly in a module using requestStaticInjection() statements:

     requestStaticInjection(MyLegacyService.class);

Summary

Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Set<InjectionPoint> getInjectionPoints()
Returns the static methods and fields of type that will be injected to fulfill this request.
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
Class<?> getType()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Set<InjectionPoint> getInjectionPoints ()

Returns the static methods and fields of type that will be injected to fulfill this request.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

public Class<?> getType ()

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/ScopeBinding.html0000755000175000017500000007552011704661106026662 0ustar tonytony ScopeBinding | Guice
public final class

ScopeBinding

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.ScopeBinding

Class Overview

Registration of a scope annotation with the scope that implements it. Instances are created explicitly in a module using bindScope() statements:

     Scope recordScope = new RecordScope();
     bindScope(RecordScoped.class, new RecordScope());

Summary

Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Class<? extends Annotation> getAnnotationType()
Scope getScope()
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Class<? extends Annotation> getAnnotationType ()

public Scope getScope ()

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/RequireExplicitBindingsOption.html0000755000175000017500000007060011704661106032275 0ustar tonytony RequireExplicitBindingsOption | Guice
public final class

RequireExplicitBindingsOption

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.RequireExplicitBindingsOption

Class Overview

A request to require explicit bindings.

Summary

Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/ProviderWithExtensionVisitor.html0000755000175000017500000005476111704661106032225 0ustar tonytony ProviderWithExtensionVisitor | Guice
public interface

ProviderWithExtensionVisitor

implements Provider<T>
com.google.inject.spi.ProviderWithExtensionVisitor<T>

Class Overview

A Provider that is part of an extension which supports a custom BindingTargetVisitor.

When an extension binds a provider instance, the provider can implement this interface to allow users using the acceptTargetVisitor(BindingTargetVisitor) method to visit a custom visitor designed for that extension. A typical implementation within the extension would look like

 
 <V, B> V acceptExtensionVisitor(BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding) {
   if(visitor instanceof MyCustomExtensionVisitor) {
     return ((MyCustomExtensionVisitor<B, V>)visitor).visitCustomExtension(customProperties, binding);
   } else {
     return visitor.visit(binding);
   }
 }
'MyCustomExtensionVisitor' in the example above would be an interface the extension provides that users can implement in order to be notified of custom extension information. These visitor interfaces must extend from BindingTargetVisitor.

Summary

Public Methods
abstract <B, V> V acceptExtensionVisitor(BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding)
Instructs the extension determine if the visitor is an instance of a custom extension visitor, and if so, visit it using that method.
[Expand]
Inherited Methods
From interface com.google.inject.Provider
From interface javax.inject.Provider

Public Methods

public abstract V acceptExtensionVisitor (BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding)

Instructs the extension determine if the visitor is an instance of a custom extension visitor, and if so, visit it using that method. If the visitor is not an instance of the custom extension visitor, this method MUST call visitor.visit(binding).

Due to issues with generics, the type parameters of this method do not relate to the type of the provider. In practice, the 'B' type will always be a supertype of 'T'.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/ProviderWithDependencies.html0000755000175000017500000005114611704661106031251 0ustar tonytony ProviderWithDependencies | Guice
public interface

ProviderWithDependencies

implements Provider<T> HasDependencies
com.google.inject.spi.ProviderWithDependencies<T>

Class Overview

A provider with dependencies on other injected types. If a Provider has dependencies that aren't specified in injections, this interface should be used to expose all dependencies.

Summary

[Expand]
Inherited Methods
From interface com.google.inject.Provider
From interface com.google.inject.spi.HasDependencies
From interface javax.inject.Provider
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/ProviderLookup.html0000755000175000017500000010724411704661106027301 0ustar tonytony ProviderLookup | Guice
public final class

ProviderLookup

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.ProviderLookup<T>

Class Overview

A lookup of the provider for a type. Lookups are created explicitly in a module using getProvider() statements:

     Provider<PaymentService> paymentServiceProvider
         = getProvider(PaymentService.class);

Summary

Public Constructors
ProviderLookup(Object source, Key<T> key)
Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Provider<T> getDelegate()
Returns the delegate provider, or null if it has not yet been initialized.
Key<T> getKey()
Provider<T> getProvider()
Returns the looked up provider.
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
void initializeDelegate(Provider<T> delegate)
Sets the actual provider.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Constructors

public ProviderLookup (Object source, Key<T> key)

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Provider<T> getDelegate ()

Returns the delegate provider, or null if it has not yet been initialized. The delegate will be initialized when this element is processed, or otherwise used to create an injector.

public Key<T> getKey ()

public Provider<T> getProvider ()

Returns the looked up provider. The result is not valid until this lookup has been initialized, which usually happens when the injector is created. The provider will throw an IllegalStateException if you try to use it beforehand.

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

public void initializeDelegate (Provider<T> delegate)

Sets the actual provider.

Throws
IllegalStateException if the delegate is already set
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/ProviderKeyBinding.html0000755000175000017500000006026711704661106030056 0ustar tonytony ProviderKeyBinding | Guice
public interface

ProviderKeyBinding

implements Binding<T>
com.google.inject.spi.ProviderKeyBinding<T>

Class Overview

A binding to a provider key. To resolve injections, the provider key is first resolved, then that provider's get method is invoked.

Summary

Public Methods
abstract Key<? extends Provider<? extends T>> getProviderKey()
Returns the key used to resolve the provider's binding.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element

Public Methods

public abstract Key<? extends Provider<? extends T>> getProviderKey ()

Returns the key used to resolve the provider's binding. That binding can be retrieved from an injector using Injector.getBinding(providerKey)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/ProviderInstanceBinding.html0000755000175000017500000006615311704661106031072 0ustar tonytony ProviderInstanceBinding | Guice
public interface

ProviderInstanceBinding

implements Binding<T> HasDependencies
com.google.inject.spi.ProviderInstanceBinding<T>

Class Overview

A binding to a provider instance. The provider's get method is invoked to resolve injections.

Summary

Public Methods
abstract Set<InjectionPoint> getInjectionPoints()
Returns the field and method injection points of the provider, injected at injector-creation time only.
abstract Provider<? extends T> getProviderInstance()
Returns the user-supplied, unscoped provider.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element
From interface com.google.inject.spi.HasDependencies

Public Methods

public abstract Set<InjectionPoint> getInjectionPoints ()

Returns the field and method injection points of the provider, injected at injector-creation time only.

Returns
  • a possibly empty set

public abstract Provider<? extends T> getProviderInstance ()

Returns the user-supplied, unscoped provider.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/ProviderBinding.html0000755000175000017500000006071611704661106027404 0ustar tonytony ProviderBinding | Guice
public interface

ProviderBinding

implements Binding<T>
com.google.inject.spi.ProviderBinding<T extends com.google.inject.Provider<?>>

Class Overview

A binding to a Provider that delegates to the binding for the provided type. This binding is used whenever a Provider<T> is injected (as opposed to injecting T directly).

Summary

Public Methods
abstract Key<?> getProvidedKey()
Returns the key whose binding is used to provide instances.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element

Public Methods

public abstract Key<?> getProvidedKey ()

Returns the key whose binding is used to provide instances. That binding can be retrieved from an injector using Injector.getBinding(providedKey)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/PrivateElements.html0000755000175000017500000006264711704661106027433 0ustar tonytony PrivateElements | Guice
public interface

PrivateElements

implements Element
com.google.inject.spi.PrivateElements

Class Overview

A private collection of elements that are hidden from the enclosing injector or module by default. See PrivateModule for details.

Summary

Public Methods
abstract List<Element> getElements()
Returns the configuration information in this private environment.
abstract Set<Key<?>> getExposedKeys()
Returns the unique exposed keys for these private elements.
abstract Object getExposedSource(Key<?> key)
Returns an arbitrary object containing information about the "place" where this key was exposed.
abstract Injector getInjector()
Returns the child injector that hosts these private elements, or null if the elements haven't been used to create an injector.
[Expand]
Inherited Methods
From interface com.google.inject.spi.Element

Public Methods

public abstract List<Element> getElements ()

Returns the configuration information in this private environment.

public abstract Set<Key<?>> getExposedKeys ()

Returns the unique exposed keys for these private elements.

public abstract Object getExposedSource (Key<?> key)

Returns an arbitrary object containing information about the "place" where this key was exposed. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

Parameters
key one of the keys exposed by this module.

public abstract Injector getInjector ()

Returns the child injector that hosts these private elements, or null if the elements haven't been used to create an injector.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/Message.html0000755000175000017500000011473111704661106025700 0ustar tonytony Message | Guice
public final class

Message

extends Object
implements Element Serializable
java.lang.Object
   ↳ com.google.inject.spi.Message

Class Overview

An error message and the context in which it occured. Messages are usually created internally by Guice and its extensions. Messages can be created explicitly in a module using addError() statements:

     try {
       bindPropertiesFromFile();
     } catch (IOException e) {
       addError(e);
     }

Summary

Public Constructors
Message(Object source, String message)
Message(String message)
Message(List<Object> sources, String message, Throwable cause)
Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
boolean equals(Object o)
Throwable getCause()
Returns the throwable that caused this message, or null if this message was not caused by a throwable.
String getMessage()
Gets the error message text.
String getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
List<Object> getSources()
int hashCode()
String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Constructors

public Message (Object source, String message)

public Message (String message)

public Message (List<Object> sources, String message, Throwable cause)

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public boolean equals (Object o)

Since: API Level

public Throwable getCause ()

Returns the throwable that caused this message, or null if this message was not caused by a throwable.

public String getMessage ()

Gets the error message text.

public String getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

public List<Object> getSources ()

public int hashCode ()

Since: API Level

public String toString ()

Since: API Level

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/MembersInjectorLookup.html0000755000175000017500000011031411704661106030567 0ustar tonytony MembersInjectorLookup | Guice
public final class

MembersInjectorLookup

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.MembersInjectorLookup<T>

Class Overview

A lookup of the members injector for a type. Lookups are created explicitly in a module using getMembersInjector() statements:

     MembersInjector<PaymentService> membersInjector
         = getMembersInjector(PaymentService.class);

Summary

Public Constructors
MembersInjectorLookup(Object source, TypeLiteral<T> type)
Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
MembersInjector<T> getDelegate()
Returns the delegate members injector, or null if it has not yet been initialized.
MembersInjector<T> getMembersInjector()
Returns the looked up members injector.
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
TypeLiteral<T> getType()
Gets the type containing the members to be injected.
void initializeDelegate(MembersInjector<T> delegate)
Sets the actual members injector.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Constructors

public MembersInjectorLookup (Object source, TypeLiteral<T> type)

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public MembersInjector<T> getDelegate ()

Returns the delegate members injector, or null if it has not yet been initialized. The delegate will be initialized when this element is processed, or otherwise used to create an injector.

public MembersInjector<T> getMembersInjector ()

Returns the looked up members injector. The result is not valid until this lookup has been initialized, which usually happens when the injector is created. The members injector will throw an IllegalStateException if you try to use it beforehand.

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

public TypeLiteral<T> getType ()

Gets the type containing the members to be injected.

public void initializeDelegate (MembersInjector<T> delegate)

Sets the actual members injector.

Throws
IllegalStateException if the delegate is already set
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/LinkedKeyBinding.html0000755000175000017500000006001611704661106027462 0ustar tonytony LinkedKeyBinding | Guice
public interface

LinkedKeyBinding

implements Binding<T>
com.google.inject.spi.LinkedKeyBinding<T>

Class Overview

A binding to a linked key. The other key's binding is used to resolve injections.

Summary

Public Methods
abstract Key<? extends T> getLinkedKey()
Returns the linked key used to resolve injections.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element

Public Methods

public abstract Key<? extends T> getLinkedKey ()

Returns the linked key used to resolve injections. That binding can be retrieved from an injector using Injector.getBinding(key).

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/InterceptorBinding.html0000755000175000017500000010117211704661106030100 0ustar tonytony InterceptorBinding | Guice
public final class

InterceptorBinding

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.InterceptorBinding

Class Overview

Registration of interceptors for matching methods of matching classes. Instances are created explicitly in a module using bindInterceptor() statements:

     bindInterceptor(Matchers.subclassesOf(MyAction.class),
         Matchers.annotatedWith(Transactional.class),
         new MyTransactionInterceptor());
or from an injectable type listener using TypeEncounter.bindInterceptor().

Summary

Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Matcher<? super Class<?>> getClassMatcher()
List<MethodInterceptor> getInterceptors()
Matcher<? super Method> getMethodMatcher()
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Matcher<? super Class<?>> getClassMatcher ()

public List<MethodInterceptor> getInterceptors ()

public Matcher<? super Method> getMethodMatcher ()

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/InstanceBinding.html0000755000175000017500000006547211704661106027362 0ustar tonytony InstanceBinding | Guice
public interface

InstanceBinding

implements Binding<T> HasDependencies
com.google.inject.spi.InstanceBinding<T>

Class Overview

A binding to a single instance. The same instance is returned for every injection.

Summary

Public Methods
abstract Set<InjectionPoint> getInjectionPoints()
Returns the field and method injection points of the instance, injected at injector-creation time only.
abstract T getInstance()
Returns the user-supplied instance.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element
From interface com.google.inject.spi.HasDependencies

Public Methods

public abstract Set<InjectionPoint> getInjectionPoints ()

Returns the field and method injection points of the instance, injected at injector-creation time only.

Returns
  • a possibly empty set

public abstract T getInstance ()

Returns the user-supplied instance.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/InjectionRequest.html0000755000175000017500000010461411704661106027606 0ustar tonytony InjectionRequest | Guice
public final class

InjectionRequest

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.InjectionRequest<T>

Class Overview

A request to inject the instance fields and methods of an instance. Requests are created explicitly in a module using requestInjection() statements:

     requestInjection(serviceInstance);

Summary

Public Constructors
InjectionRequest(Object source, TypeLiteral<T> type, T instance)
Public Methods
<R> R acceptVisitor(ElementVisitor<R> visitor)
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Set<InjectionPoint> getInjectionPoints()
Returns the instance methods and fields of instance that will be injected to fulfill this request.
T getInstance()
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
TypeLiteral<T> getType()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Constructors

public InjectionRequest (Object source, TypeLiteral<T> type, T instance)

Public Methods

public R acceptVisitor (ElementVisitor<R> visitor)

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Set<InjectionPoint> getInjectionPoints ()

Returns the instance methods and fields of instance that will be injected to fulfill this request.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on the class of instance, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public T getInstance ()

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

public TypeLiteral<T> getType ()

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/InjectionPoint.html0000755000175000017500000014436111704661106027252 0ustar tonytony InjectionPoint | Guice
public final class

InjectionPoint

extends Object
java.lang.Object
   ↳ com.google.inject.spi.InjectionPoint

Class Overview

A constructor, field or method that can receive injections. Typically this is a member with the @Inject annotation. For non-private, no argument constructors, the member may omit the annotation.

Summary

Public Methods
boolean equals(Object o)
static <T> InjectionPoint forConstructor(Constructor<T> constructor)
Returns a new injection point for the specified constructor.
static <T> InjectionPoint forConstructor(Constructor<T> constructor, TypeLiteral<? extends T> type)
Returns a new injection point for the specified constructor of type.
static InjectionPoint forConstructorOf(TypeLiteral<?> type)
Returns a new injection point for the injectable constructor of type.
static InjectionPoint forConstructorOf(Class<?> type)
Returns a new injection point for the injectable constructor of type.
static Set<InjectionPoint> forInstanceMethodsAndFields(TypeLiteral<?> type)
Returns all instance method and field injection points on type.
static Set<InjectionPoint> forInstanceMethodsAndFields(Class<?> type)
Returns all instance method and field injection points on type.
static Set<InjectionPoint> forStaticMethodsAndFields(TypeLiteral<?> type)
Returns all static method and field injection points on type.
static Set<InjectionPoint> forStaticMethodsAndFields(Class<?> type)
Returns all static method and field injection points on type.
TypeLiteral<?> getDeclaringType()
Returns the generic type that defines this injection point.
List<Dependency<?>> getDependencies()
Returns the dependencies for this injection point.
Member getMember()
Returns the injected constructor, field, or method.
int hashCode()
boolean isOptional()
Returns true if this injection point shall be skipped if the injector cannot resolve bindings for all required dependencies.
boolean isToolable()
Returns true if the element is annotated with @Toolable.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public boolean equals (Object o)

Since: API Level

public static InjectionPoint forConstructor (Constructor<T> constructor)

Returns a new injection point for the specified constructor. If the declaring type of constructor is parameterized (such as List<T>), prefer the overload that includes a type literal.

Parameters
constructor any single constructor present on type.

public static InjectionPoint forConstructor (Constructor<T> constructor, TypeLiteral<? extends T> type)

Returns a new injection point for the specified constructor of type.

Parameters
constructor any single constructor present on type.
type the concrete type that defines constructor.

public static InjectionPoint forConstructorOf (TypeLiteral<?> type)

Returns a new injection point for the injectable constructor of type.

Parameters
type a concrete type with exactly one constructor annotated @Inject, or a no-arguments constructor that is not private.
Throws
ConfigurationException if there is no injectable constructor, more than one injectable constructor, or if parameters of the injectable constructor are malformed, such as a parameter with multiple binding annotations.

public static InjectionPoint forConstructorOf (Class<?> type)

Returns a new injection point for the injectable constructor of type.

Parameters
type a concrete type with exactly one constructor annotated @Inject, or a no-arguments constructor that is not private.
Throws
ConfigurationException if there is no injectable constructor, more than one injectable constructor, or if parameters of the injectable constructor are malformed, such as a parameter with multiple binding annotations.

public static Set<InjectionPoint> forInstanceMethodsAndFields (TypeLiteral<?> type)

Returns all instance method and field injection points on type.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public static Set<InjectionPoint> forInstanceMethodsAndFields (Class<?> type)

Returns all instance method and field injection points on type.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public static Set<InjectionPoint> forStaticMethodsAndFields (TypeLiteral<?> type)

Returns all static method and field injection points on type.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public static Set<InjectionPoint> forStaticMethodsAndFields (Class<?> type)

Returns all static method and field injection points on type.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public TypeLiteral<?> getDeclaringType ()

Returns the generic type that defines this injection point. If the member exists on a parameterized type, the result will include more type information than the member's raw declaring class.

public List<Dependency<?>> getDependencies ()

Returns the dependencies for this injection point. If the injection point is for a method or constructor, the dependencies will correspond to that member's parameters. Field injection points always have a single dependency for the field itself.

Returns
  • a possibly-empty list

public Member getMember ()

Returns the injected constructor, field, or method.

public int hashCode ()

Since: API Level

public boolean isOptional ()

Returns true if this injection point shall be skipped if the injector cannot resolve bindings for all required dependencies. Both explicit bindings (as specified in a module), and implicit bindings (@ImplementedBy, default constructors etc.) may be used to satisfy optional injection points.

public boolean isToolable ()

Returns true if the element is annotated with @Toolable.

public String toString ()

Since: API Level

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/InjectionListener.html0000755000175000017500000004323411704661106027743 0ustar tonytony InjectionListener | Guice
public interface

InjectionListener

com.google.inject.spi.InjectionListener<I>

Class Overview

Listens for injections into instances of type I. Useful for performing further injections, post-injection initialization, and more.

Summary

Public Methods
abstract void afterInjection(I injectee)
Invoked by Guice after it injects the fields and methods of instance.

Public Methods

public abstract void afterInjection (I injectee)

Invoked by Guice after it injects the fields and methods of instance.

Parameters
injectee instance that Guice injected dependencies into
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/HasDependencies.html0000755000175000017500000005420211704661106027332 0ustar tonytony HasDependencies | Guice
public interface

HasDependencies

com.google.inject.spi.HasDependencies
Known Indirect Subclasses

Class Overview

Implemented by bindings, providers and instances that expose their dependencies explicitly.

Summary

Public Methods
abstract Set<Dependency<?>> getDependencies()
Returns the known dependencies for this type.

Public Methods

public abstract Set<Dependency<?>> getDependencies ()

Returns the known dependencies for this type. If this has dependencies whose values are not known statically, a dependency for the Injector will be included in the returned set.

Returns
  • a possibly empty set
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/ExposedBinding.html0000755000175000017500000006572411704661106027225 0ustar tonytony ExposedBinding | Guice
public interface

ExposedBinding

implements Binding<T> HasDependencies
com.google.inject.spi.ExposedBinding<T>

Class Overview

A binding to a key exposed from an enclosed private environment.

Summary

Public Methods
abstract void applyTo(Binder binder)
Unsupported.
abstract PrivateElements getPrivateElements()
Returns the enclosed environment that holds the original binding.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element
From interface com.google.inject.spi.HasDependencies

Public Methods

public abstract void applyTo (Binder binder)

Unsupported. Always throws UnsupportedOperationException.

Parameters
binder to apply configuration element to

public abstract PrivateElements getPrivateElements ()

Returns the enclosed environment that holds the original binding.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/Elements.html0000755000175000017500000007463611704661106026101 0ustar tonytony Elements | Guice
public final class

Elements

extends Object
java.lang.Object
   ↳ com.google.inject.spi.Elements

Class Overview

Exposes elements of a module so they can be inspected, validated or rewritten.

Summary

Public Constructors
Elements()
Public Methods
static List<Element> getElements(Module... modules)
Records the elements executed by modules.
static List<Element> getElements(Stage stage, Module... modules)
Records the elements executed by modules.
static List<Element> getElements(Stage stage, Iterable<? extends Module> modules)
Records the elements executed by modules.
static List<Element> getElements(Iterable<? extends Module> modules)
Records the elements executed by modules.
static Module getModule(Iterable<? extends Element> elements)
Returns the module composed of elements.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Elements ()

Public Methods

public static List<Element> getElements (Module... modules)

Records the elements executed by modules.

public static List<Element> getElements (Stage stage, Module... modules)

Records the elements executed by modules.

public static List<Element> getElements (Stage stage, Iterable<? extends Module> modules)

Records the elements executed by modules.

public static List<Element> getElements (Iterable<? extends Module> modules)

Records the elements executed by modules.

public static Module getModule (Iterable<? extends Element> elements)

Returns the module composed of elements.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/ElementVisitor.html0000755000175000017500000010777511704661106027277 0ustar tonytony ElementVisitor | Guice
public interface

ElementVisitor

com.google.inject.spi.ElementVisitor<V>
Known Indirect Subclasses

Class Overview

Visit elements.

Summary

Public Methods
abstract <T> V visit(Binding<T> binding)
Visit a mapping from a key (type and optional annotation) to the strategy for getting instances of the type.
abstract V visit(DisableCircularProxiesOption option)
Visit a disable circular proxies command.
abstract V visit(InjectionRequest<?> request)
Visit a request to inject the instance fields and methods of an instance.
abstract V visit(InterceptorBinding binding)
Visit a registration of interceptors for matching methods of matching classes.
abstract <T> V visit(MembersInjectorLookup<T> lookup)
Visit a lookup of the members injector.
abstract V visit(Message message)
Visit an error message and the context in which it occured.
abstract V visit(PrivateElements elements)
Visit a collection of configuration elements for a private binder.
abstract <T> V visit(ProviderLookup<T> lookup)
Visit a lookup of the provider for a type.
abstract V visit(RequireExplicitBindingsOption option)
Visit a require explicit bindings command.
abstract V visit(ScopeBinding binding)
Visit a registration of a scope annotation with the scope that implements it.
abstract V visit(StaticInjectionRequest request)
Visit a request to inject the static fields and methods of type.
abstract V visit(TypeConverterBinding binding)
Visit a registration of type converters for matching target types.
abstract V visit(TypeListenerBinding binding)
Visit an injectable type listener binding.

Public Methods

public abstract V visit (Binding<T> binding)

Visit a mapping from a key (type and optional annotation) to the strategy for getting instances of the type.

public abstract V visit (DisableCircularProxiesOption option)

Visit a disable circular proxies command.

public abstract V visit (InjectionRequest<?> request)

Visit a request to inject the instance fields and methods of an instance.

public abstract V visit (InterceptorBinding binding)

Visit a registration of interceptors for matching methods of matching classes.

public abstract V visit (MembersInjectorLookup<T> lookup)

Visit a lookup of the members injector.

public abstract V visit (Message message)

Visit an error message and the context in which it occured.

public abstract V visit (PrivateElements elements)

Visit a collection of configuration elements for a private binder.

public abstract V visit (ProviderLookup<T> lookup)

Visit a lookup of the provider for a type.

public abstract V visit (RequireExplicitBindingsOption option)

Visit a require explicit bindings command.

public abstract V visit (ScopeBinding binding)

Visit a registration of a scope annotation with the scope that implements it.

public abstract V visit (StaticInjectionRequest request)

Visit a request to inject the static fields and methods of type.

public abstract V visit (TypeConverterBinding binding)

Visit a registration of type converters for matching target types.

public abstract V visit (TypeListenerBinding binding)

Visit an injectable type listener binding.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/Element.html0000755000175000017500000010103711704661106025700 0ustar tonytony Element | Guice
public interface

Element

com.google.inject.spi.Element
Known Indirect Subclasses

Class Overview

A core component of a module or injector.

The elements of a module can be inspected, validated and rewritten. Use Elements.getElements() to read the elements from a module, and Elements.getModule() to rewrite them. This can be used for static analysis and generation of Guice modules.

The elements of an injector can be inspected and exercised. Use Injector.getBindings() to reflect on Guice injectors.

Summary

Public Methods
abstract <T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
abstract void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
abstract Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.

Public Methods

public abstract T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public abstract void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to
Throws
UnsupportedOperationException if the applyTo method is not supported by this element.

public abstract Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/DisableCircularProxiesOption.html0000755000175000017500000007057111704661106032112 0ustar tonytony DisableCircularProxiesOption | Guice
public final class

DisableCircularProxiesOption

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.DisableCircularProxiesOption

Class Overview

A request to disable circular proxies.

Summary

Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/Dependency.html0000755000175000017500000010112511704661106026363 0ustar tonytony Dependency | Guice
public final class

Dependency

extends Object
java.lang.Object
   ↳ com.google.inject.spi.Dependency<T>

Class Overview

A variable that can be resolved by an injector.

Use get(Key) to build a freestanding dependency, or InjectionPoint to build one that's attached to a constructor, method or field.

Summary

Public Methods
boolean equals(Object o)
static Set<Dependency<?>> forInjectionPoints(Set<InjectionPoint> injectionPoints)
Returns the dependencies from the given injection points.
static <T> Dependency<T> get(Key<T> key)
Returns a new dependency that is not attached to an injection point.
InjectionPoint getInjectionPoint()
Returns the injection point to which this dependency belongs, or null if this dependency isn't attached to a particular injection point.
Key<T> getKey()
Returns the key to the binding that satisfies this dependency.
int getParameterIndex()
Returns the index of this dependency in the injection point's parameter list, or -1 if this dependency does not belong to a parameter list.
int hashCode()
boolean isNullable()
Returns true if null is a legal value for this dependency.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public boolean equals (Object o)

Since: API Level

public static Set<Dependency<?>> forInjectionPoints (Set<InjectionPoint> injectionPoints)

Returns the dependencies from the given injection points.

public static Dependency<T> get (Key<T> key)

Returns a new dependency that is not attached to an injection point. The returned dependency is nullable.

public InjectionPoint getInjectionPoint ()

Returns the injection point to which this dependency belongs, or null if this dependency isn't attached to a particular injection point.

public Key<T> getKey ()

Returns the key to the binding that satisfies this dependency.

public int getParameterIndex ()

Returns the index of this dependency in the injection point's parameter list, or -1 if this dependency does not belong to a parameter list. Only method and constuctor dependencies are elements in a parameter list.

public int hashCode ()

Since: API Level

public boolean isNullable ()

Returns true if null is a legal value for this dependency.

public String toString ()

Since: API Level

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/DefaultElementVisitor.html0000755000175000017500000014753711704661106030604 0ustar tonytony DefaultElementVisitor | Guice
public abstract class

DefaultElementVisitor

extends Object
implements ElementVisitor<V>
java.lang.Object
   ↳ com.google.inject.spi.DefaultElementVisitor<V>

Class Overview

No-op visitor for subclassing. All interface methods simply delegate to visitOther(Element), returning its result.

Summary

Public Constructors
DefaultElementVisitor()
Public Methods
<T> V visit(Binding<T> binding)
Visit a mapping from a key (type and optional annotation) to the strategy for getting instances of the type.
V visit(DisableCircularProxiesOption option)
Visit a disable circular proxies command.
V visit(InjectionRequest<?> injectionRequest)
Visit a request to inject the instance fields and methods of an instance.
V visit(InterceptorBinding interceptorBinding)
Visit a registration of interceptors for matching methods of matching classes.
<T> V visit(MembersInjectorLookup<T> lookup)
Visit a lookup of the members injector.
V visit(Message message)
Visit an error message and the context in which it occured.
V visit(PrivateElements privateElements)
Visit a collection of configuration elements for a private binder.
<T> V visit(ProviderLookup<T> providerLookup)
Visit a lookup of the provider for a type.
V visit(RequireExplicitBindingsOption option)
Visit a require explicit bindings command.
V visit(ScopeBinding scopeBinding)
Visit a registration of a scope annotation with the scope that implements it.
V visit(StaticInjectionRequest staticInjectionRequest)
Visit a request to inject the static fields and methods of type.
V visit(TypeConverterBinding typeConverterBinding)
Visit a registration of type converters for matching target types.
V visit(TypeListenerBinding binding)
Visit an injectable type listener binding.
Protected Methods
V visitOther(Element element)
Default visit implementation.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.ElementVisitor

Public Constructors

public DefaultElementVisitor ()

Public Methods

public V visit (Binding<T> binding)

Visit a mapping from a key (type and optional annotation) to the strategy for getting instances of the type.

public V visit (DisableCircularProxiesOption option)

Visit a disable circular proxies command.

public V visit (InjectionRequest<?> injectionRequest)

Visit a request to inject the instance fields and methods of an instance.

public V visit (InterceptorBinding interceptorBinding)

Visit a registration of interceptors for matching methods of matching classes.

public V visit (MembersInjectorLookup<T> lookup)

Visit a lookup of the members injector.

public V visit (Message message)

Visit an error message and the context in which it occured.

public V visit (PrivateElements privateElements)

Visit a collection of configuration elements for a private binder.

public V visit (ProviderLookup<T> providerLookup)

Visit a lookup of the provider for a type.

public V visit (RequireExplicitBindingsOption option)

Visit a require explicit bindings command.

public V visit (ScopeBinding scopeBinding)

Visit a registration of a scope annotation with the scope that implements it.

public V visit (StaticInjectionRequest staticInjectionRequest)

Visit a request to inject the static fields and methods of type.

public V visit (TypeConverterBinding typeConverterBinding)

Visit a registration of type converters for matching target types.

public V visit (TypeListenerBinding binding)

Visit an injectable type listener binding.

Protected Methods

protected V visitOther (Element element)

Default visit implementation. Returns null.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/DefaultBindingTargetVisitor.html0000755000175000017500000013320611704661106031720 0ustar tonytony DefaultBindingTargetVisitor | Guice
public abstract class

DefaultBindingTargetVisitor

extends Object
implements BindingTargetVisitor<T, V>
java.lang.Object
   ↳ com.google.inject.spi.DefaultBindingTargetVisitor<T, V>

Class Overview

No-op visitor for subclassing. All interface methods simply delegate to visitOther(Binding), returning its result.

Summary

Public Constructors
DefaultBindingTargetVisitor()
Public Methods
V visit(ConstructorBinding<? extends T> constructorBinding)
Visit a constructor binding.
V visit(ConvertedConstantBinding<? extends T> convertedConstantBinding)
Visit a binding created from converting a bound instance to a new type.
V visit(ExposedBinding<? extends T> exposedBinding)
Visit a binding to a key exposed from an enclosed private environment.
V visit(InstanceBinding<? extends T> instanceBinding)
Visit a instance binding.
V visit(LinkedKeyBinding<? extends T> linkedKeyBinding)
Visit a linked key binding.
V visit(ProviderBinding<? extends T> providerBinding)
Visit a binding to a Provider that delegates to the binding for the provided type.
V visit(ProviderInstanceBinding<? extends T> providerInstanceBinding)
Visit a provider instance binding.
V visit(ProviderKeyBinding<? extends T> providerKeyBinding)
Visit a provider key binding.
V visit(UntargettedBinding<? extends T> untargettedBinding)
Visit an untargetted binding.
Protected Methods
V visitOther(Binding<? extends T> binding)
Default visit implementation.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.BindingTargetVisitor

Public Constructors

public DefaultBindingTargetVisitor ()

Public Methods

public V visit (ConstructorBinding<? extends T> constructorBinding)

Visit a constructor binding. To resolve injections, an instance is instantiated by invoking constructor. This target is found only on injector bindings.

public V visit (ConvertedConstantBinding<? extends T> convertedConstantBinding)

Visit a binding created from converting a bound instance to a new type. The source binding has the same binding annotation but a different type. This target is found only on injector bindings.

public V visit (ExposedBinding<? extends T> exposedBinding)

Visit a binding to a key exposed from an enclosed private environment. This target is only found in injector bindings.

public V visit (InstanceBinding<? extends T> instanceBinding)

Visit a instance binding. The same instance is returned for every injection. This target is found in both module and injector bindings.

public V visit (LinkedKeyBinding<? extends T> linkedKeyBinding)

Visit a linked key binding. The other key's binding is used to resolve injections. This target is found in both module and injector bindings.

public V visit (ProviderBinding<? extends T> providerBinding)

Visit a binding to a Provider that delegates to the binding for the provided type. This target is found only on injector bindings.

public V visit (ProviderInstanceBinding<? extends T> providerInstanceBinding)

Visit a provider instance binding. The provider's get method is invoked to resolve injections. This target is found in both module and injector bindings.

public V visit (ProviderKeyBinding<? extends T> providerKeyBinding)

Visit a provider key binding. To resolve injections, the provider key is first resolved, then that provider's get method is invoked. This target is found in both module and injector bindings.

public V visit (UntargettedBinding<? extends T> untargettedBinding)

Visit an untargetted binding. This target is found only on module bindings. It indicates that the injector should use its implicit binding strategies to resolve injections.

Protected Methods

protected V visitOther (Binding<? extends T> binding)

Default visit implementation. Returns null.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/DefaultBindingScopingVisitor.html0000755000175000017500000010123411704661106032070 0ustar tonytony DefaultBindingScopingVisitor | Guice
public class

DefaultBindingScopingVisitor

extends Object
implements BindingScopingVisitor<V>
java.lang.Object
   ↳ com.google.inject.spi.DefaultBindingScopingVisitor<V>

Class Overview

No-op visitor for subclassing. All interface methods simply delegate to visitOther(), returning its result.

Summary

Public Constructors
DefaultBindingScopingVisitor()
Public Methods
V visitEagerSingleton()
Visit an eager singleton or single instance.
V visitNoScoping()
Visit an unspecified or unscoped strategy.
V visitScope(Scope scope)
Visit a scope instance.
V visitScopeAnnotation(Class<? extends Annotation> scopeAnnotation)
Visit a scope annotation.
Protected Methods
V visitOther()
Default visit implementation.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.BindingScopingVisitor

Public Constructors

public DefaultBindingScopingVisitor ()

Public Methods

public V visitEagerSingleton ()

Visit an eager singleton or single instance. This scope strategy is found on both module and injector bindings.

public V visitNoScoping ()

Visit an unspecified or unscoped strategy. On a module, this strategy indicates that the injector should use scoping annotations to find a scope. On an injector, it indicates that no scope is applied to the binding. An unscoped binding will behave like a scoped one when it is linked to a scoped binding.

public V visitScope (Scope scope)

Visit a scope instance. This scope strategy is found on both module and injector bindings.

public V visitScopeAnnotation (Class<? extends Annotation> scopeAnnotation)

Visit a scope annotation. This scope strategy is found only on module bindings. The instance that implements this scope is registered by Binder.bindScope().

Protected Methods

protected V visitOther ()

Default visit implementation. Returns null.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/ConvertedConstantBinding.html0000755000175000017500000007322211704661106031251 0ustar tonytony ConvertedConstantBinding | Guice
public interface

ConvertedConstantBinding

implements Binding<T> HasDependencies
com.google.inject.spi.ConvertedConstantBinding<T>

Class Overview

A binding created from converting a bound instance to a new type. The source binding has the same binding annotation but a different type.

Summary

Public Methods
abstract Set<Dependency<?>> getDependencies()
Returns a singleton set containing only the converted key.
abstract Key<String> getSourceKey()
Returns the key for the source binding.
abstract TypeConverterBinding getTypeConverterBinding()
Returns the type converter binding used to convert the constant.
abstract T getValue()
Returns the converted value.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element
From interface com.google.inject.spi.HasDependencies

Public Methods

public abstract Set<Dependency<?>> getDependencies ()

Returns a singleton set containing only the converted key.

Returns
  • a possibly empty set

public abstract Key<String> getSourceKey ()

Returns the key for the source binding. That binding can e retrieved from an injector using Injector.getBinding(key).

public abstract TypeConverterBinding getTypeConverterBinding ()

Returns the type converter binding used to convert the constant.

public abstract T getValue ()

Returns the converted value.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/ConstructorBinding.html0000755000175000017500000007141011704661106030130 0ustar tonytony ConstructorBinding | Guice
public interface

ConstructorBinding

implements Binding<T> HasDependencies
com.google.inject.spi.ConstructorBinding<T>

Class Overview

A binding to the constructor of a concrete clss. To resolve injections, an instance is instantiated by invoking the constructor.

Summary

Public Methods
abstract InjectionPoint getConstructor()
Gets the constructor this binding injects.
abstract Set<InjectionPoint> getInjectableMembers()
Returns all instance method and field injection points on type.
abstract Map<Method, List<MethodInterceptor>> getMethodInterceptors()
Returns the interceptors applied to each method, in the order that they will be applied.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element
From interface com.google.inject.spi.HasDependencies

Public Methods

public abstract InjectionPoint getConstructor ()

Gets the constructor this binding injects.

public abstract Set<InjectionPoint> getInjectableMembers ()

Returns all instance method and field injection points on type.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.

public abstract Map<Method, List<MethodInterceptor>> getMethodInterceptors ()

Returns the interceptors applied to each method, in the order that they will be applied.

Returns
  • a possibly empty map
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/BindingTargetVisitor.html0000755000175000017500000010716111704661106030414 0ustar tonytony BindingTargetVisitor | Guice
public interface

BindingTargetVisitor

com.google.inject.spi.BindingTargetVisitor<T, V>
Known Indirect Subclasses

Class Overview

Visits each of the strategies used to find an instance to satisfy an injection.

Summary

Public Methods
abstract V visit(ConstructorBinding<? extends T> binding)
Visit a constructor binding.
abstract V visit(ConvertedConstantBinding<? extends T> binding)
Visit a binding created from converting a bound instance to a new type.
abstract V visit(ExposedBinding<? extends T> binding)
Visit a binding to a key exposed from an enclosed private environment.
abstract V visit(InstanceBinding<? extends T> binding)
Visit a instance binding.
abstract V visit(LinkedKeyBinding<? extends T> binding)
Visit a linked key binding.
abstract V visit(ProviderBinding<? extends T> binding)
Visit a binding to a Provider that delegates to the binding for the provided type.
abstract V visit(ProviderInstanceBinding<? extends T> binding)
Visit a provider instance binding.
abstract V visit(ProviderKeyBinding<? extends T> binding)
Visit a provider key binding.
abstract V visit(UntargettedBinding<? extends T> binding)
Visit an untargetted binding.

Public Methods

public abstract V visit (ConstructorBinding<? extends T> binding)

Visit a constructor binding. To resolve injections, an instance is instantiated by invoking constructor. This target is found only on injector bindings.

public abstract V visit (ConvertedConstantBinding<? extends T> binding)

Visit a binding created from converting a bound instance to a new type. The source binding has the same binding annotation but a different type. This target is found only on injector bindings.

public abstract V visit (ExposedBinding<? extends T> binding)

Visit a binding to a key exposed from an enclosed private environment. This target is only found in injector bindings.

public abstract V visit (InstanceBinding<? extends T> binding)

Visit a instance binding. The same instance is returned for every injection. This target is found in both module and injector bindings.

public abstract V visit (LinkedKeyBinding<? extends T> binding)

Visit a linked key binding. The other key's binding is used to resolve injections. This target is found in both module and injector bindings.

public abstract V visit (ProviderBinding<? extends T> binding)

Visit a binding to a Provider that delegates to the binding for the provided type. This target is found only on injector bindings.

public abstract V visit (ProviderInstanceBinding<? extends T> binding)

Visit a provider instance binding. The provider's get method is invoked to resolve injections. This target is found in both module and injector bindings.

public abstract V visit (ProviderKeyBinding<? extends T> binding)

Visit a provider key binding. To resolve injections, the provider key is first resolved, then that provider's get method is invoked. This target is found in both module and injector bindings.

public abstract V visit (UntargettedBinding<? extends T> binding)

Visit an untargetted binding. This target is found only on module bindings. It indicates that the injector should use its implicit binding strategies to resolve injections.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/spi/BindingScopingVisitor.html0000755000175000017500000005623211704661106030572 0ustar tonytony BindingScopingVisitor | Guice
public interface

BindingScopingVisitor

com.google.inject.spi.BindingScopingVisitor<V>
Known Indirect Subclasses

Class Overview

Visits each of the strategies used to scope an injection.

Summary

Public Methods
abstract V visitEagerSingleton()
Visit an eager singleton or single instance.
abstract V visitNoScoping()
Visit an unspecified or unscoped strategy.
abstract V visitScope(Scope scope)
Visit a scope instance.
abstract V visitScopeAnnotation(Class<? extends Annotation> scopeAnnotation)
Visit a scope annotation.

Public Methods

public abstract V visitEagerSingleton ()

Visit an eager singleton or single instance. This scope strategy is found on both module and injector bindings.

public abstract V visitNoScoping ()

Visit an unspecified or unscoped strategy. On a module, this strategy indicates that the injector should use scoping annotations to find a scope. On an injector, it indicates that no scope is applied to the binding. An unscoped binding will behave like a scoped one when it is linked to a scoped binding.

public abstract V visitScope (Scope scope)

Visit a scope instance. This scope strategy is found on both module and injector bindings.

public abstract V visitScopeAnnotation (Class<? extends Annotation> scopeAnnotation)

Visit a scope annotation. This scope strategy is found only on module bindings. The instance that implements this scope is registered by Binder.bindScope().

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/0000755000175000017500000000000011704661106024305 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/package-summary.html0000755000175000017500000004165311704661106030275 0ustar tonytony com.google.inject.servlet | Guice
package

com.google.inject.servlet

Classes | Description

Servlet API scopes, bindings and registration; this extension requires guice-servlet-3.0.jar.

more...

Interfaces

InstanceFilterBinding A binding to a single instance of a filter. 
InstanceServletBinding A binding to a single instance of a servlet. 
LinkedFilterBinding A linked binding to a filter. 
LinkedServletBinding A linked binding to a servlet. 
ServletModule.FilterKeyBindingBuilder See the EDSL examples at configureServlets() 
ServletModule.ServletKeyBindingBuilder See the EDSL examples at configureServlets() 
ServletModuleBinding A binding created by ServletModule
ServletModuleTargetVisitor<T, V> A visitor for the servlet extension. 

Classes

GuiceFilter

Apply this filter in web.xml above all other filters (typically), to all requests where you plan to use servlet scopes. 

GuiceServletContextListener As of Guice 2.0 you can still use (your subclasses of) GuiceServletContextListener class as a logical place to create and configure your injector. 
ServletModule Configures the servlet scopes and creates bindings for the servlet API objects so you can inject the request, response, session, etc. 
ServletScopes Servlet scopes. 

Enums

UriPatternType An enumeration of the available URI-pattern matching styles 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/package-descr.html0000755000175000017500000003041611704661106027673 0ustar tonytony com.google.inject.servlet Details | Guice
package

com.google.inject.servlet

Classes | Description

Servlet API scopes, bindings and registration; this extension requires guice-servlet-3.0.jar.

Apply GuiceFilter to any servlets which will use the servlet scopes. Install ServletModule into your Injector to install everything at once.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/UriPatternType.html0000755000175000017500000006720411704661106030146 0ustar tonytony UriPatternType | Guice
public final enum

UriPatternType

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.servlet.UriPatternType

Class Overview

An enumeration of the available URI-pattern matching styles

Summary

Enum Values
UriPatternType  REGEX   
UriPatternType  SERVLET   
Public Methods
static UriPatternType valueOf(String name)
final static UriPatternType[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final UriPatternType REGEX

Since: API Level

public static final UriPatternType SERVLET

Since: API Level

Public Methods

public static UriPatternType valueOf (String name)

public static final UriPatternType[] values ()

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/SessionScoped.html0000755000175000017500000003677011704661106027774 0ustar tonytony SessionScoped | Guice
public abstract @interface

SessionScoped

implements Annotation
com.google.inject.servlet.SessionScoped

Class Overview

Apply this to implementation classes when you want one instance per session.

See Also

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/ServletScopes.html0000755000175000017500000006341011704661106030003 0ustar tonytony ServletScopes | Guice
public class

ServletScopes

extends Object
java.lang.Object
   ↳ com.google.inject.servlet.ServletScopes

Class Overview

Servlet scopes.

Summary

Constants
Scope REQUEST HTTP servlet request scope.
Scope SESSION HTTP session scope.
Public Methods
static <T> Callable<T> continueRequest(Callable<T> callable, Map<Key<?>, Object> seedMap)
Wraps the given callable in a contextual callable that "continues" the HTTP request in another thread.
static <T> Callable<T> scopeRequest(Callable<T> callable, Map<Key<?>, Object> seedMap)
Scopes the given callable inside a request scope.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final Scope REQUEST

HTTP servlet request scope.

public static final Scope SESSION

HTTP session scope.

Public Methods

public static Callable<T> continueRequest (Callable<T> callable, Map<Key<?>, Object> seedMap)

Wraps the given callable in a contextual callable that "continues" the HTTP request in another thread. This acts as a way of transporting request context data from the request processing thread to to worker threads.

There are some limitations:

  • Derived objects (i.e. anything marked @RequestScoped will not be transported.
  • State changes to the HttpServletRequest after this method is called will not be seen in the continued thread.
  • Only the HttpServletRequest, ServletContext and request parameter map are available in the continued thread. The response and session are not available.

Parameters
callable code to be executed in another thread, which depends on the request scope.
seedMap the initial set of scoped instances for Guice to seed the request scope with. To seed a key with null, use null as the value.
Returns
  • a callable that will invoke the given callable, making the request context available to it.
Throws
OutOfScopeException if this method is called from a non-request thread, or if the request has completed.

public static Callable<T> scopeRequest (Callable<T> callable, Map<Key<?>, Object> seedMap)

Scopes the given callable inside a request scope. This is not the same as the HTTP request scope, but is used if no HTTP request scope is in progress. In this way, keys can be scoped as @RequestScoped and exist in non-HTTP requests (for example: RPC requests) as well as in HTTP request threads.

Parameters
callable code to be executed which depends on the request scope. Typically in another thread, but not necessarily so.
seedMap the initial set of scoped instances for Guice to seed the request scope with. To seed a key with null, use null as the value.
Returns
  • a callable that when called will run inside the a request scope that exposes the instances in the seedMap as scoped keys.
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/ServletModuleTargetVisitor.html0000755000175000017500000007313411704661106032527 0ustar tonytony ServletModuleTargetVisitor | Guice
public interface

ServletModuleTargetVisitor

implements BindingTargetVisitor<T, V>
com.google.inject.servlet.ServletModuleTargetVisitor<T, V>

Class Overview

A visitor for the servlet extension. If your BindingTargetVisitor implements this interface, bindings created by using ServletModule will be visited through this interface.

Summary

Public Methods
abstract V visit(InstanceFilterBinding binding)
Visits a filter binding created by filter(String, String...) where through(Class) is called with a Filter.
abstract V visit(InstanceServletBinding binding)
Visits a servlet binding created by serve(String, String...) where with(Class), is called with an HttpServlet.
abstract V visit(LinkedFilterBinding binding)
Visits a filter binding created by filter(String, String...), where through(Class) is called with a Class or Key.
abstract V visit(LinkedServletBinding binding)
Visits a servlet binding created by serve(String, String...) where with(Class), is called with a Class or Key.
[Expand]
Inherited Methods
From interface com.google.inject.spi.BindingTargetVisitor

Public Methods

public abstract V visit (InstanceFilterBinding binding)

Visits a filter binding created by filter(String, String...) where through(Class) is called with a Filter. If multiple patterns were specified, this will be called multiple times.

public abstract V visit (InstanceServletBinding binding)

Visits a servlet binding created by serve(String, String...) where with(Class), is called with an HttpServlet. If multiple patterns were specified, this will be called multiple times.

public abstract V visit (LinkedFilterBinding binding)

Visits a filter binding created by filter(String, String...), where through(Class) is called with a Class or Key. If multiple patterns were specified, this will be called multiple times.

public abstract V visit (LinkedServletBinding binding)

Visits a servlet binding created by serve(String, String...) where with(Class), is called with a Class or Key. If multiple patterns were specified, this will be called multiple times.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/ServletModuleBinding.html0000755000175000017500000005111111704661106031262 0ustar tonytony ServletModuleBinding | Guice
public interface

ServletModuleBinding

com.google.inject.servlet.ServletModuleBinding
Known Indirect Subclasses

Class Overview

A binding created by ServletModule.

Summary

Public Methods
abstract Map<String, String> getInitParams()
Returns any context params supplied when creating the binding.
abstract String getPattern()
Returns the pattern used to match against the binding.
abstract UriPatternType getUriPatternType()
Returns the pattern type that this binding was created with.
abstract boolean matchesUri(String uri)
Returns true if the given URI will match this binding.

Public Methods

public abstract Map<String, String> getInitParams ()

Returns any context params supplied when creating the binding.

public abstract String getPattern ()

Returns the pattern used to match against the binding.

public abstract UriPatternType getUriPatternType ()

Returns the pattern type that this binding was created with.

public abstract boolean matchesUri (String uri)

Returns true if the given URI will match this binding.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/ServletModule.html0000755000175000017500000015115611704661106030001 0ustar tonytony ServletModule | Guice
public class

ServletModule

extends AbstractModule
java.lang.Object
   ↳ com.google.inject.AbstractModule
     ↳ com.google.inject.servlet.ServletModule

Class Overview

Configures the servlet scopes and creates bindings for the servlet API objects so you can inject the request, response, session, etc.

You should subclass this module to register servlets and filters in the configureServlets() method.

Summary

Nested Classes
interface ServletModule.FilterKeyBindingBuilder See the EDSL examples at configureServlets() 
interface ServletModule.ServletKeyBindingBuilder See the EDSL examples at configureServlets() 
Public Constructors
ServletModule()
Protected Methods
final void configure()
Configures a Binder via the exposed methods.
void configureServlets()

Servlet Mapping EDSL

Part of the EDSL builder language for configuring servlets and filters with guice-servlet.

final ServletModule.FilterKeyBindingBuilder filter(String urlPattern, String... morePatterns)
final ServletModule.FilterKeyBindingBuilder filterRegex(String regex, String... regexes)
final ServletContext getServletContext()
This method only works if you are using the GuiceServletContextListener to create your injector.
final ServletModule.ServletKeyBindingBuilder serve(String urlPattern, String... morePatterns)
final ServletModule.ServletKeyBindingBuilder serveRegex(String regex, String... regexes)
[Expand]
Inherited Methods
From class com.google.inject.AbstractModule
From class java.lang.Object
From interface com.google.inject.Module

Public Constructors

public ServletModule ()

Protected Methods

protected final void configure ()

Configures a Binder via the exposed methods.

protected void configureServlets ()

Servlet Mapping EDSL

Part of the EDSL builder language for configuring servlets and filters with guice-servlet. Think of this as an in-code replacement for web.xml. Filters and servlets are configured here using simple java method calls. Here is a typical example of registering a filter when creating your Guice injector:

   Guice.createInjector(..., new ServletModule() {

     @Override
     protected void configureServlets() {
       serve("*.html").with(MyServlet.class)
     }
   }
 
This registers a servlet (subclass of HttpServlet) called MyServlet to service any web pages ending in .html. You can also use a path-style syntax to register servlets:
       serve("/my/*").with(MyServlet.class)
 
Every servlet (or filter) is required to be a singleton. If you cannot annotate the class directly, you should add a separate bind(..).in(Singleton.class) rule elsewhere in your module. Mapping a servlet that is bound under any other scope is an error.

Dispatch Order

You are free to register as many servlets and filters as you like this way. They will be compared and dispatched in the order in which the filter methods are called:

   Guice.createInjector(..., new ServletModule() {

     @Override
     protected void configureServlets() {
       filter("/*").through(MyFilter.class);
       filter("*.css").through(MyCssFilter.class);
       filter("*.jpg").through(new MyJpgFilter());
       // etc..

       serve("*.html").with(MyServlet.class);
       serve("/my/*").with(MyServlet.class);
       serve("*.jpg").with(new MyServlet());
       // etc..
      }
    }
 
This will traverse down the list of rules in lexical order. For example, a url "/my/file.js" (after it runs through the matching filters) will first be compared against the servlet mapping:
       serve("*.html").with(MyServlet.class);
 
And failing that, it will descend to the next servlet mapping:
       serve("/my/*").with(MyServlet.class);
 
Since this rule matches, Guice Servlet will dispatch to MyServlet. These two mapping rules can also be written in more compact form using varargs syntax:
       serve("*.html", "/my/*").with(MyServlet.class);
 
This way you can map several URI patterns to the same servlet. A similar syntax is also available for filter mappings.

Regular Expressions

You can also map servlets (or filters) to URIs using regular expressions:
    serveRegex("(.)*ajax(.)*").with(MyAjaxServlet.class)
 
This will map any URI containing the text "ajax" in it to MyAjaxServlet. Such as:
  • http://www.google.com/ajax.html
  • http://www.google.com/content/ajax/index
  • http://www.google.com/it/is_totally_ajaxian

Initialization Parameters

Servlets (and filters) allow you to pass in init params using the <init-param> tag in web.xml. You can similarly pass in parameters to Servlets and filters registered in Guice-servlet using a java.util.Map of parameter name/value pairs. For example, to initialize MyServlet with two parameters (name="Dhanji", site="google.com") you could write:
  Map<String, String> params = new HashMap<String, String>();
  params.put("name", "Dhanji");
  params.put("site", "google.com");

  ...
      serve("/*").with(MyServlet.class, params)
 

Binding Keys

You can also bind keys rather than classes. This lets you hide implementations with package-local visbility and expose them using only a Guice module and an annotation:
  ...
      filter("/*").through(Key.get(Filter.class, Fave.class));
 
Where Filter.class refers to the Servlet API interface and Fave.class is a custom binding annotation. Elsewhere (in one of your own modules) you can bind this filter's implementation:
   bind(Filter.class).annotatedWith(Fave.class).to(MyFilterImpl.class);
 
See Binder for more information on binding syntax.

Multiple Modules

It is sometimes useful to capture servlet and filter mappings from multiple different modules. This is essential if you want to package and offer drop-in Guice plugins that provide servlet functionality.

Guice Servlet allows you to register several instances of ServletModule to your injector. The order in which these modules are installed determines the dispatch order of filters and the precedence order of servlets. For example, if you had two servlet modules, RpcModule and WebServiceModule and they each contained a filter that mapped to the same URI pattern, "/*":

In RpcModule:

     filter("/*").through(RpcFilter.class);
 
In WebServiceModule:
     filter("/*").through(WebServiceFilter.class);
 
Then the order in which these filters are dispatched is determined by the order in which the modules are installed:
   install(new WebServiceModule());
   install(new RpcModule());
 
In the case shown above WebServiceFilter will run first.

protected final ServletModule.FilterKeyBindingBuilder filter (String urlPattern, String... morePatterns)

Parameters
urlPattern Any Servlet-style pattern. examples: /*, /html/*, *.html, etc.

protected final ServletModule.FilterKeyBindingBuilder filterRegex (String regex, String... regexes)

Parameters
regex Any Java-style regular expression.

protected final ServletContext getServletContext ()

This method only works if you are using the GuiceServletContextListener to create your injector. Otherwise, it returns null.

Returns
  • The current servlet context.

protected final ServletModule.ServletKeyBindingBuilder serve (String urlPattern, String... morePatterns)

Parameters
urlPattern Any Servlet-style pattern. examples: /*, /html/*, *.html, etc.

protected final ServletModule.ServletKeyBindingBuilder serveRegex (String regex, String... regexes)

Parameters
regex Any Java-style regular expression.
././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/ServletModule.ServletKeyBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/ServletModule.ServletKeyBinding0000755000175000017500000005126711704661106032427 0ustar tonytony ServletModule.ServletKeyBindingBuilder | Guice
public static interface

ServletModule.ServletKeyBindingBuilder

com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder

Class Overview

See the EDSL examples at configureServlets()

Summary

Public Methods
abstract void with(HttpServlet servlet)
abstract void with(HttpServlet servlet, Map<String, String> initParams)
abstract void with(Key<? extends HttpServlet> servletKey)
abstract void with(Key<? extends HttpServlet> servletKey, Map<String, String> initParams)
abstract void with(Class<? extends HttpServlet> servletKey)
abstract void with(Class<? extends HttpServlet> servletKey, Map<String, String> initParams)

Public Methods

public abstract void with (HttpServlet servlet)

public abstract void with (HttpServlet servlet, Map<String, String> initParams)

public abstract void with (Key<? extends HttpServlet> servletKey)

public abstract void with (Key<? extends HttpServlet> servletKey, Map<String, String> initParams)

public abstract void with (Class<? extends HttpServlet> servletKey)

public abstract void with (Class<? extends HttpServlet> servletKey, Map<String, String> initParams)

././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/ServletModule.FilterKeyBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/ServletModule.FilterKeyBindingB0000755000175000017500000005116211704661106032324 0ustar tonytony ServletModule.FilterKeyBindingBuilder | Guice
public static interface

ServletModule.FilterKeyBindingBuilder

com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder

Class Overview

See the EDSL examples at configureServlets()

Summary

Public Methods
abstract void through(Filter filter)
abstract void through(Filter filter, Map<String, String> initParams)
abstract void through(Key<? extends Filter> filterKey)
abstract void through(Key<? extends Filter> filterKey, Map<String, String> initParams)
abstract void through(Class<? extends Filter> filterKey)
abstract void through(Class<? extends Filter> filterKey, Map<String, String> initParams)

Public Methods

public abstract void through (Filter filter)

public abstract void through (Filter filter, Map<String, String> initParams)

public abstract void through (Key<? extends Filter> filterKey)

public abstract void through (Key<? extends Filter> filterKey, Map<String, String> initParams)

public abstract void through (Class<? extends Filter> filterKey)

public abstract void through (Class<? extends Filter> filterKey, Map<String, String> initParams)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/RequestScoped.html0000755000175000017500000003644111704661106027774 0ustar tonytony RequestScoped | Guice
public abstract @interface

RequestScoped

implements Annotation
com.google.inject.servlet.RequestScoped

Class Overview

Apply this to implementation classes when you want one instance per request.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/RequestParameters.html0000755000175000017500000003656111704661106030665 0ustar tonytony RequestParameters | Guice
public abstract @interface

RequestParameters

implements Annotation
com.google.inject.servlet.RequestParameters

Class Overview

Apply this to field or parameters of type Map<String, String[]> when you want the HTTP request parameter map to be injected.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/LinkedServletBinding.html0000755000175000017500000004372611704661106031260 0ustar tonytony LinkedServletBinding | Guice
public interface

LinkedServletBinding

implements ServletModuleBinding
com.google.inject.servlet.LinkedServletBinding

Class Overview

A linked binding to a servlet.

Summary

Public Methods
abstract Key<? extends HttpServlet> getLinkedKey()
Returns the key used to lookup the servlet instance.
[Expand]
Inherited Methods
From interface com.google.inject.servlet.ServletModuleBinding

Public Methods

public abstract Key<? extends HttpServlet> getLinkedKey ()

Returns the key used to lookup the servlet instance.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/LinkedFilterBinding.html0000755000175000017500000004370511704661106031056 0ustar tonytony LinkedFilterBinding | Guice
public interface

LinkedFilterBinding

implements ServletModuleBinding
com.google.inject.servlet.LinkedFilterBinding

Class Overview

A linked binding to a filter.

Summary

Public Methods
abstract Key<? extends Filter> getLinkedKey()
Returns the key used to lookup the filter instance.
[Expand]
Inherited Methods
From interface com.google.inject.servlet.ServletModuleBinding

Public Methods

public abstract Key<? extends Filter> getLinkedKey ()

Returns the key used to lookup the filter instance.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/InstanceServletBinding.html0000755000175000017500000004352211704661106031610 0ustar tonytony InstanceServletBinding | Guice
public interface

InstanceServletBinding

implements ServletModuleBinding
com.google.inject.servlet.InstanceServletBinding

Class Overview

A binding to a single instance of a servlet.

Summary

Public Methods
abstract HttpServlet getServletInstance()
Returns the servlet instance that will be used.
[Expand]
Inherited Methods
From interface com.google.inject.servlet.ServletModuleBinding

Public Methods

public abstract HttpServlet getServletInstance ()

Returns the servlet instance that will be used.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/InstanceFilterBinding.html0000755000175000017500000004347511704661106031420 0ustar tonytony InstanceFilterBinding | Guice
public interface

InstanceFilterBinding

implements ServletModuleBinding
com.google.inject.servlet.InstanceFilterBinding

Class Overview

A binding to a single instance of a filter.

Summary

Public Methods
abstract Filter getFilterInstance()
Returns the filter instance that will be used.
[Expand]
Inherited Methods
From interface com.google.inject.servlet.ServletModuleBinding

Public Methods

public abstract Filter getFilterInstance ()

Returns the filter instance that will be used.

././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/GuiceServletContextListener.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/GuiceServletContextListener.htm0000755000175000017500000005617111704661106032510 0ustar tonytony GuiceServletContextListener | Guice
public abstract class

GuiceServletContextListener

extends Object
java.lang.Object
   ↳ com.google.inject.servlet.GuiceServletContextListener

Class Overview

As of Guice 2.0 you can still use (your subclasses of) GuiceServletContextListener class as a logical place to create and configure your injector. This will ensure the injector is created when the web application is deployed.

Summary

Public Constructors
GuiceServletContextListener()
Public Methods
void contextDestroyed(ServletContextEvent servletContextEvent)
void contextInitialized(ServletContextEvent servletContextEvent)
Protected Methods
abstract Injector getInjector()
Override this method to create (or otherwise obtain a reference to) your injector.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public GuiceServletContextListener ()

Public Methods

public void contextDestroyed (ServletContextEvent servletContextEvent)

public void contextInitialized (ServletContextEvent servletContextEvent)

Protected Methods

protected abstract Injector getInjector ()

Override this method to create (or otherwise obtain a reference to) your injector.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/servlet/GuiceFilter.html0000755000175000017500000005677311704661106027422 0ustar tonytony GuiceFilter | Guice
public class

GuiceFilter

extends Object
java.lang.Object
   ↳ com.google.inject.servlet.GuiceFilter

Class Overview

Apply this filter in web.xml above all other filters (typically), to all requests where you plan to use servlet scopes. This is also needed in order to dispatch requests to injectable filters and servlets:

  <filter>
    <filter-name>guiceFilter</filter-name>
    <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>guiceFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  
This filter must appear before every filter that makes use of Guice injection or servlet scopes functionality. Typically, you will only register this filter in web.xml and register any other filters (and servlets) using a ServletModule.

Summary

Public Constructors
GuiceFilter()
Public Methods
void destroy()
void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
void init(FilterConfig filterConfig)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public GuiceFilter ()

Public Methods

public void destroy ()

public void doFilter (ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)

Throws
IOException
ServletException

public void init (FilterConfig filterConfig)

Throws
ServletException
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/0000755000175000017500000000000011704661106024312 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/package-summary.html0000755000175000017500000002752111704661106030300 0ustar tonytony com.google.inject.persist | Guice
package

com.google.inject.persist

Classes | Description

Guice Persist: a lightweight persistence library for Guice; this extension requires guice-persist-3.0.jar.

more...

Interfaces

PersistService Persistence provider service. 
UnitOfWork This interface is used to gain manual control over the unit of work. 

Classes

PersistFilter Apply this filter to enable the HTTP Request unit of work and to have guice-persist manage the lifecycle of active units of work. 
PersistModule Install this module to add guice-persist library support for JPA persistence providers. 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/package-descr.html0000755000175000017500000002425711704661106027706 0ustar tonytony com.google.inject.persist Details | Guice
package

com.google.inject.persist

Classes | Description

Guice Persist: a lightweight persistence library for Guice; this extension requires guice-persist-3.0.jar.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/jpa/0000755000175000017500000000000011704661106025064 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/jpa/package-summary.html0000755000175000017500000002420711704661106031050 0ustar tonytony com.google.inject.persist.jpa | Guice
package

com.google.inject.persist.jpa

Classes | Description

guice-persist's Java Persistence API (JPA) support.

more...

Classes

JpaPersistModule JPA provider for guice persist. 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/jpa/package-descr.html0000755000175000017500000002314711704661106030455 0ustar tonytony com.google.inject.persist.jpa Details | Guice
package

com.google.inject.persist.jpa

Classes | Description

guice-persist's Java Persistence API (JPA) support.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/jpa/JpaPersistModule.html0000755000175000017500000012315511704661106031216 0ustar tonytony JpaPersistModule | Guice
public final class

JpaPersistModule

extends PersistModule
java.lang.Object
   ↳ com.google.inject.AbstractModule
     ↳ com.google.inject.persist.PersistModule
       ↳ com.google.inject.persist.jpa.JpaPersistModule

Class Overview

JPA provider for guice persist.

Summary

Public Constructors
JpaPersistModule(String jpaUnit)
Public Methods
<T> JpaPersistModule addFinder(Class<T> iface)
Adds an interface to this module to use as a dynamic finder.
JpaPersistModule properties(Properties properties)
Configures the JPA persistence provider with a set of properties.
Protected Methods
void configurePersistence()
MethodInterceptor getTransactionInterceptor()
[Expand]
Inherited Methods
From class com.google.inject.persist.PersistModule
From class com.google.inject.AbstractModule
From class java.lang.Object
From interface com.google.inject.Module

Public Constructors

public JpaPersistModule (String jpaUnit)

Public Methods

public JpaPersistModule addFinder (Class<T> iface)

Adds an interface to this module to use as a dynamic finder.

Parameters
iface Any interface type whose methods are all dynamic finders.

public JpaPersistModule properties (Properties properties)

Configures the JPA persistence provider with a set of properties.

Parameters
properties A set of name value pairs that configure a JPA persistence provider as per the specification.

Protected Methods

protected void configurePersistence ()

protected MethodInterceptor getTransactionInterceptor ()

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/finder/0000755000175000017500000000000011704661106025561 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/finder/package-summary.html0000755000175000017500000002514611704661106031550 0ustar tonytony com.google.inject.persist.finder | Guice
package

com.google.inject.persist.finder

Classes | Description

Dynamic Finder API for Guice Persist.

more...

Classes

DynamicFinder Utility that helps you introspect dynamic finder methods. 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/finder/package-descr.html0000755000175000017500000002405711704661106031153 0ustar tonytony com.google.inject.persist.finder Details | Guice
package

com.google.inject.persist.finder

Classes | Description

Dynamic Finder API for Guice Persist.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/finder/MaxResults.html0000755000175000017500000003324511704661106030570 0ustar tonytony MaxResults | Guice
public abstract @interface

MaxResults

implements Annotation
com.google.inject.persist.finder.MaxResults

Class Overview

Annotate any dynamic finder method's integer argument with this to pass in the maximum size of returned result window. Usefule for paging result sets. Complement of FirstResult.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/finder/FirstResult.html0000755000175000017500000003330211704661106030741 0ustar tonytony FirstResult | Guice
public abstract @interface

FirstResult

implements Annotation
com.google.inject.persist.finder.FirstResult

Class Overview

Annotate any dynamic finder method's integer argument with this to pass in the index of the first result in the result set you are interested in. Useful for paging result sets. Complemented by MaxResults.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/finder/Finder.html0000755000175000017500000003306711704661106027672 0ustar tonytony Finder | Guice
public abstract @interface

Finder

implements Annotation
com.google.inject.persist.finder.Finder

Class Overview

Marks a method stub as a dynamic finder. The method is intercepted and replaced with the specified JPAQL query. Provides result auto-boxing and automatic parameter binding.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/finder/DynamicFinder.html0000755000175000017500000005006011704661106031167 0ustar tonytony DynamicFinder | Guice
public final class

DynamicFinder

extends Object
java.lang.Object
   ↳ com.google.inject.persist.finder.DynamicFinder

Class Overview

Utility that helps you introspect dynamic finder methods.

Summary

Public Constructors
DynamicFinder(Method method)
Public Methods
static DynamicFinder from(Method method)
Returns some metadata if the method is annotated @Finder or null.
Finder metadata()
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public DynamicFinder (Method method)

Public Methods

public static DynamicFinder from (Method method)

Returns some metadata if the method is annotated @Finder or null.

Parameters
method a method you want to test as a dynamic finder

public Finder metadata ()

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/UnitOfWork.html0000755000175000017500000003522211704661106027256 0ustar tonytony UnitOfWork | Guice
public interface

UnitOfWork

com.google.inject.persist.UnitOfWork

Class Overview

This interface is used to gain manual control over the unit of work. This is mostly to do work in non-request, non-transactional threads. Or where more fine-grained control over the unit of work is required. Starting and ending a unit of work directly corresponds to opening and closing a Session, EntityManager or ObjectContainer respectively.

The Unit of Work referred to by UnitOfWork will always be local to the calling thread. Be careful to end() in a finally block. Neither JPA, nor Hibernate supports threadsafe sessions (reasoning behind thread-locality of Unit of Work semantics).

  • Using UnitOfWork with the PersistFilter inside a request is not recommended.
  • Using UnitOfWork with session-per-txn strategy is not terribly clever either.
  • Using UnitOfWork with session-per-request strategy but *outside* a request (i.e. in a background or bootstrap thread) is probably a good use case.

Summary

Public Methods
abstract void begin()
Starts a Unit Of Work.
abstract void end()
Declares an end to the current Unit of Work.

Public Methods

public abstract void begin ()

Starts a Unit Of Work. Underneath, causes a session to the data layer to be opened. If there is already one open, the invocation will do nothing. In this way, you can define arbitrary units-of-work that nest within one another safely. Transaction semantics are not affected.

public abstract void end ()

Declares an end to the current Unit of Work. Underneath, causes any open session to the data layer to close. If there is no Unit of work open, then the call returns silently. You can safely invoke end() repeatedly.

Transaction semantics are not affected.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/Transactional.html0000755000175000017500000003414411704661106030013 0ustar tonytony Transactional | Guice
public abstract @interface

Transactional

implements Annotation
com.google.inject.persist.Transactional

Class Overview

Any method or class marked with this annotation will be considered for transactionality. Consult the documentation on http://code.google.com/p/google-guice for detailed semantics. Marking a method @Transactional will start a new transaction before the method executes and commit it after the method returns.

If the method throws an exception, the transaction will be rolled back unless you have specifically requested not to in the #ignore() clause.

Similarly, the set of exceptions that will trigger a rollback can be defined in the #rollbackOn() clause. By default, only unchecked exceptions trigger a rollback.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/PersistService.html0000755000175000017500000003370211704661106030162 0ustar tonytony PersistService | Guice
public interface

PersistService

com.google.inject.persist.PersistService

Class Overview

Persistence provider service. Use this to manage the overall startup and stop of the persistence module(s). TODO(dhanji): Integrate with Service API when appropriate.

Summary

Public Methods
abstract void start()
Starts the underlying persistence engine and makes guice-persist ready for use.
abstract void stop()
Stops the underlying persistence engine.

Public Methods

public abstract void start ()

Starts the underlying persistence engine and makes guice-persist ready for use. For instance, with JPA, it creates an EntityManagerFactory and may open connection pools. This method must be called by your code prior to using any guice-persist or JPA artifacts. If already started, calling this method does nothing, if already stopped, it also does nothing.

public abstract void stop ()

Stops the underlying persistence engine. For instance, with JPA, it closes the EntityManagerFactory. If already stopped, calling this method does nothing. If not yet started, it also does nothing.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/PersistModule.html0000755000175000017500000011372311704661106030011 0ustar tonytony PersistModule | Guice
public abstract class

PersistModule

extends AbstractModule
java.lang.Object
   ↳ com.google.inject.AbstractModule
     ↳ com.google.inject.persist.PersistModule
Known Direct Subclasses

Class Overview

Install this module to add guice-persist library support for JPA persistence providers.

Summary

Public Constructors
PersistModule()
Protected Methods
final void configure()
Configures a Binder via the exposed methods.
abstract void configurePersistence()
abstract MethodInterceptor getTransactionInterceptor()
[Expand]
Inherited Methods
From class com.google.inject.AbstractModule
From class java.lang.Object
From interface com.google.inject.Module

Public Constructors

public PersistModule ()

Protected Methods

protected final void configure ()

Configures a Binder via the exposed methods.

protected abstract void configurePersistence ()

protected abstract MethodInterceptor getTransactionInterceptor ()

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/persist/PersistFilter.html0000755000175000017500000005547511704661106030022 0ustar tonytony PersistFilter | Guice
public final class

PersistFilter

extends Object
java.lang.Object
   ↳ com.google.inject.persist.PersistFilter

Class Overview

Apply this filter to enable the HTTP Request unit of work and to have guice-persist manage the lifecycle of active units of work. The filter automatically starts and stops the relevant PersistService upon javax.servlet.Filter#init(javax.servlet.FilterConfig) and javax.servlet.Filter#destroy() respectively.

To be able to use the open session-in-view pattern (i.e. work per request), register this filter once in your Guice ServletModule. It is important that you register this filter before any other filter. For multiple providers, you should register this filter once per provider, inside a private module for each persist module installed (this must be the same private module where the specific persist module is itself installed).

Example configuration:

public class MyModule extends ServletModule {
    public void configureServlets() {
      filter("/*").through(PersistFilter.class);

      serve("/index.html").with(MyHtmlServlet.class);
      // Etc.
    
  }
 }

This filter is thread safe and allows you to create injectors concurrently and deploy multiple guice-persist modules within the same injector, or even multiple injectors with persist modules withing the same JVM or web app.

This filter requires the Guice Servlet extension.

Summary

Public Constructors
PersistFilter(UnitOfWork unitOfWork, PersistService persistService)
Public Methods
void destroy()
void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
void init(FilterConfig filterConfig)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public PersistFilter (UnitOfWork unitOfWork, PersistService persistService)

Public Methods

public void destroy ()

public void doFilter (ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)

Throws
IOException
ServletException

public void init (FilterConfig filterConfig)

Throws
ServletException
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/package-summary.html0000755000175000017500000004674611704661106026621 0ustar tonytony com.google.inject | Guice
package

com.google.inject

Classes | Description

Google Guice (pronounced "juice") is an ultra-lightweight dependency injection framework.

more...

Interfaces

Binder Collects configuration information (primarily bindings) which will be used to create an Injector
Binding<T> A mapping from a key (type and optional annotation) to the strategy for getting instances of the type. 
Injector Builds the graphs of objects that make up your application. 
MembersInjector<T> Injects dependencies into the fields and methods on instances of type T
Module A module contributes configuration information, typically interface bindings, which will be used to create an Injector
PrivateBinder Returns a binder whose configuration information is hidden from its environment by default. 
Provider<T> An object capable of providing instances of type T
Scope A scope is a level of visibility that instances provided by Guice may have. 

Classes

AbstractModule A support class for Modules which reduces repetition and results in a more readable configuration. 
Guice The entry point to the Guice framework. 
Key<T> Binding key consisting of an injection type and an optional annotation. 
PrivateModule A module whose configuration information is hidden from its environment by default. 
Scopes Built-in scope implementations. 
TypeLiteral<T> Represents a generic type T

Enums

Stage The stage we're running in. 

Exceptions

ConfigurationException Thrown when a programming error such as a misplaced annotation, illegal binding, or unsupported scope is found. 
CreationException Thrown when errors occur while creating a Injector
OutOfScopeException Thrown from get() when an attempt is made to access a scoped object while the scope in question is not currently active. 
ProvisionException Indicates that there was a runtime failure while providing an instance. 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/package-descr.html0000755000175000017500000003337611704661106026217 0ustar tonytony com.google.inject Details | Guice
package

com.google.inject

Classes | Description

Google Guice (pronounced "juice") is an ultra-lightweight dependency injection framework. Please refer to the Guice User's Guide for a gentle introduction.

The principal public APIs in this package are:

Inject
The annotation you will use in your implementation classes to tell Guice where and how it should send in ("inject") the objects you depend on (your "dependencies").
Module
The interface you will implement in order to specify "bindings" -- instructions for how Guice should handle injection -- for a particular set of interfaces.
Binder
The object that Guice passes into your Module to collect these bindings.
Provider
The interface you will implement when you need to customize exactly how Guice creates instances for a particular binding.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/name/0000755000175000017500000000000011704661106023541 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/name/package-summary.html0000755000175000017500000002431111704661106027521 0ustar tonytony com.google.inject.name | Guice
package

com.google.inject.name

Classes | Description

Support for binding to string-based names.

more...

Classes

Names Utility methods for use with @Named
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/name/package-descr.html0000755000175000017500000002315611704661106027132 0ustar tonytony com.google.inject.name Details | Guice
package

com.google.inject.name

Classes | Description

Support for binding to string-based names.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/name/Names.html0000755000175000017500000005015411704661106025502 0ustar tonytony Names | Guice
public class

Names

extends Object
java.lang.Object
   ↳ com.google.inject.name.Names

Class Overview

Utility methods for use with @Named.

Summary

Public Methods
static void bindProperties(Binder binder, Map<String, String> properties)
Creates a constant binding to @Named(key) for each entry in properties.
static void bindProperties(Binder binder, Properties properties)
Creates a constant binding to @Named(key) for each property.
static Named named(String name)
Creates a Named annotation with name as the value.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static void bindProperties (Binder binder, Map<String, String> properties)

Creates a constant binding to @Named(key) for each entry in properties.

public static void bindProperties (Binder binder, Properties properties)

Creates a constant binding to @Named(key) for each property. This method binds all properties including those inherited from defaults.

public static Named named (String name)

Creates a Named annotation with name as the value.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/name/Named.html0000755000175000017500000003173311704661106025465 0ustar tonytony Named | Guice
public abstract @interface

Named

implements Annotation
com.google.inject.name.Named

Class Overview

Annotates named things.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/multibindings/0000755000175000017500000000000011704661106025471 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/multibindings/package-summary.html0000755000175000017500000003040111704661106031446 0ustar tonytony com.google.inject.multibindings | Guice
package

com.google.inject.multibindings

Classes | Description

Extension for binding multiple instances in a collection; this extension requires guice-multibindings-3.0.jar.

more...

Interfaces

MapBinderBinding<T> A binding for a MapBinder. 
MultibinderBinding<T> A binding for a Multibinder. 
MultibindingsTargetVisitor<T, V> A visitor for the multibinder extension. 

Classes

MapBinder<K, V> An API to bind multiple map entries separately, only to later inject them as a complete map. 
Multibinder<T> An API to bind multiple values separately, only to later inject them as a complete collection. 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/multibindings/package-descr.html0000755000175000017500000002437611704661106031067 0ustar tonytony com.google.inject.multibindings Details | Guice
package

com.google.inject.multibindings

Classes | Description

Extension for binding multiple instances in a collection; this extension requires guice-multibindings-3.0.jar.

././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/multibindings/MultibindingsTargetVisitor.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/multibindings/MultibindingsTargetVisito0000755000175000017500000005502111704661106032577 0ustar tonytony MultibindingsTargetVisitor | Guice
public interface

MultibindingsTargetVisitor

implements BindingTargetVisitor<T, V>
com.google.inject.multibindings.MultibindingsTargetVisitor<T, V>

Class Overview

A visitor for the multibinder extension.

If your BindingTargetVisitor implements this interface, bindings created by using Multibinder or MapBinder will be visited through this interface.

Summary

Public Methods
abstract V visit(MapBinderBinding<? extends T> mapbinding)
Visits a binding created through MapBinder.
abstract V visit(MultibinderBinding<? extends T> multibinding)
Visits a binding created through Multibinder.
[Expand]
Inherited Methods
From interface com.google.inject.spi.BindingTargetVisitor

Public Methods

public abstract V visit (MapBinderBinding<? extends T> mapbinding)

Visits a binding created through MapBinder.

public abstract V visit (MultibinderBinding<? extends T> multibinding)

Visits a binding created through Multibinder.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/multibindings/MultibinderBinding.html0000755000175000017500000004752711704661106032152 0ustar tonytony MultibinderBinding | Guice
public interface

MultibinderBinding

com.google.inject.multibindings.MultibinderBinding<T>

Class Overview

A binding for a Multibinder.

Summary

Public Methods
abstract boolean containsElement(Element element)
Returns true if this Multibinder uses the given Element.
abstract TypeLiteral<?> getElementTypeLiteral()
Returns the TypeLiteral that describes the type of elements in the set.
abstract List<Binding<?>> getElements()
Returns all bindings that make up the set.
abstract Key<T> getSetKey()
Returns the key for the set.
abstract boolean permitsDuplicates()
Returns true if the multibinder permits duplicates.

Public Methods

public abstract boolean containsElement (Element element)

Returns true if this Multibinder uses the given Element. This will be true for bindings that derive the elements of the set and other bindings that Multibinder uses internally. This will work for MultibinderBindings retrieved from an injector and getElements(Module...). Usually this is only necessary if you are working with elements retrieved from modules (without an Injector), otherwise getElements() and permitsDuplicates() are better options.

If you need to introspect the details of the set, such as the values or if it permits duplicates, it is necessary to pass the elements through an Injector and use getElements() and permitsDuplicates().

public abstract TypeLiteral<?> getElementTypeLiteral ()

Returns the TypeLiteral that describes the type of elements in the set.

The elements will always match the type Set's generic type. For example, if getSetKey returns a key of Set<String>, then this will always return a TypeLiteral<String>.

public abstract List<Binding<?>> getElements ()

Returns all bindings that make up the set. This is only supported on bindings returned from an injector. This will throw UnsupportedOperationException if it is called on an element retrieved from getElements(Module...).

The elements will always match the type Set's generic type. For example, if getSetKey returns a key of Set<String>, then this will always return a list of type List<Binding<String>>.

public abstract Key<T> getSetKey ()

Returns the key for the set.

public abstract boolean permitsDuplicates ()

Returns true if the multibinder permits duplicates. This is only supported on bindings returned from an injector. This will throw UnsupportedOperationException if it is called on a MultibinderBinding retrieved from getElements(Module...).

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/multibindings/Multibinder.html0000755000175000017500000010233111704661106030640 0ustar tonytony Multibinder | Guice
public abstract class

Multibinder

extends Object
java.lang.Object
   ↳ com.google.inject.multibindings.Multibinder<T>

Class Overview

An API to bind multiple values separately, only to later inject them as a complete collection. Multibinder is intended for use in your application's module:


 public class SnacksModule extends AbstractModule {
   protected void configure() {
     Multibinder<Snack> multibinder
         = Multibinder.newSetBinder(binder(), Snack.class);
     multibinder.addBinding().toInstance(new Twix());
     multibinder.addBinding().toProvider(SnickersProvider.class);
     multibinder.addBinding().to(Skittles.class);
   }
 }

With this binding, a Set<Snack> can now be injected:


 class SnackMachine {
   @Inject
   public SnackMachine(Set<Snack> snacks) { ... }
 }

Contributing multibindings from different modules is supported. For example, it is okay to have both CandyModule and ChipsModule to both create their own Multibinder<Snack>, and to each contribute bindings to the set of snacks. When that set is injected, it will contain elements from both modules.

The set's iteration order is consistent with the binding order. This is convenient when multiple elements are contributed by the same module because that module can order its bindings appropriately. Avoid relying on the iteration order of elements contributed by different modules, since there is no equivalent mechanism to order modules.

The set is unmodifiable. Elements can only be added to the set by configuring the multibinder. Elements can never be removed from the set.

Elements are resolved at set injection time. If an element is bound to a provider, that provider's get method will be called each time the set is injected (unless the binding is also scoped).

Annotations are be used to create different sets of the same element type. Each distinct annotation gets its own independent collection of elements.

Elements must be distinct. If multiple bound elements have the same value, set injection will fail.

Elements must be non-null. If any set element is null, set injection will fail.

Summary

Public Methods
abstract LinkedBindingBuilder<T> addBinding()
Returns a binding builder used to add a new element in the set.
static <T> Multibinder<T> newSetBinder(Binder binder, TypeLiteral<T> type)
Returns a new multibinder that collects instances of type in a Set that is itself bound with no binding annotation.
static <T> Multibinder<T> newSetBinder(Binder binder, TypeLiteral<T> type, Class<? extends Annotation> annotationType)
Returns a new multibinder that collects instances of type in a Set that is itself bound with annotationType.
static <T> Multibinder<T> newSetBinder(Binder binder, TypeLiteral<T> type, Annotation annotation)
Returns a new multibinder that collects instances of type in a Set that is itself bound with annotation.
static <T> Multibinder<T> newSetBinder(Binder binder, Class<T> type)
Returns a new multibinder that collects instances of type in a Set that is itself bound with no binding annotation.
static <T> Multibinder<T> newSetBinder(Binder binder, Class<T> type, Class<? extends Annotation> annotationType)
Returns a new multibinder that collects instances of type in a Set that is itself bound with annotationType.
static <T> Multibinder<T> newSetBinder(Binder binder, Class<T> type, Annotation annotation)
Returns a new multibinder that collects instances of type in a Set that is itself bound with annotation.
abstract Multibinder<T> permitDuplicates()
Configures the bound set to silently discard duplicate elements.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public abstract LinkedBindingBuilder<T> addBinding ()

Returns a binding builder used to add a new element in the set. Each bound element must have a distinct value. Bound providers will be evaluated each time the set is injected.

It is an error to call this method without also calling one of the to methods on the returned binding builder.

Scoping elements independently is supported. Use the in method to specify a binding scope.

public static Multibinder<T> newSetBinder (Binder binder, TypeLiteral<T> type)

Returns a new multibinder that collects instances of type in a Set that is itself bound with no binding annotation.

public static Multibinder<T> newSetBinder (Binder binder, TypeLiteral<T> type, Class<? extends Annotation> annotationType)

Returns a new multibinder that collects instances of type in a Set that is itself bound with annotationType.

public static Multibinder<T> newSetBinder (Binder binder, TypeLiteral<T> type, Annotation annotation)

Returns a new multibinder that collects instances of type in a Set that is itself bound with annotation.

public static Multibinder<T> newSetBinder (Binder binder, Class<T> type)

Returns a new multibinder that collects instances of type in a Set that is itself bound with no binding annotation.

public static Multibinder<T> newSetBinder (Binder binder, Class<T> type, Class<? extends Annotation> annotationType)

Returns a new multibinder that collects instances of type in a Set that is itself bound with annotationType.

public static Multibinder<T> newSetBinder (Binder binder, Class<T> type, Annotation annotation)

Returns a new multibinder that collects instances of type in a Set that is itself bound with annotation.

public abstract Multibinder<T> permitDuplicates ()

Configures the bound set to silently discard duplicate elements. When multiple equal values are bound, the one that gets included is arbitrary. When multiple modules contribute elements to the set, this configuration option impacts all of them.

Returns
  • this multibinder
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/multibindings/MapBinderBinding.html0000755000175000017500000005445511704661106031533 0ustar tonytony MapBinderBinding | Guice
public interface

MapBinderBinding

com.google.inject.multibindings.MapBinderBinding<T>

Class Overview

A binding for a MapBinder.

Although MapBinders may be injected through a variety of generic types (Map<K, V>, Map <K, Provider<V>>, Map<K, Set<V>>, Map>, and even Set<Map.Entry<K, Provider<V>>), a MapBinderBinding exists only on the Binding associated with the Map<K, V> key. Other bindings can be validated to be derived from this MapBinderBinding using containsElement(Element).

Summary

Public Methods
abstract boolean containsElement(Element element)
Returns true if this MapBinder contains the given Element in order to build the map or uses the given Element in order to support building and injecting the map.
abstract List<Entry<?, Binding<?>>> getEntries()
Returns all entries in the Map.
abstract TypeLiteral<?> getKeyTypeLiteral()
Returns the TypeLiteral describing the keys of the map.
abstract Key<T> getMapKey()
Returns the Key for the map.
abstract TypeLiteral<?> getValueTypeLiteral()
Returns the TypeLiteral describing the values of the map.
abstract boolean permitsDuplicates()
Returns true if the MapBinder permits duplicates.

Public Methods

public abstract boolean containsElement (Element element)

Returns true if this MapBinder contains the given Element in order to build the map or uses the given Element in order to support building and injecting the map. This will work for MapBinderBindings retrieved from an injector and getElements(Module...). Usually this is only necessary if you are working with elements retrieved from modules (without an Injector), otherwise getEntries() and permitsDuplicates() are better options.

If you need to introspect the details of the map, such as the keys, values or if it permits duplicates, it is necessary to pass the elements through an Injector and use getEntries() and permitsDuplicates().

public abstract List<Entry<?, Binding<?>>> getEntries ()

Returns all entries in the Map. The returned list of Map.Entries contains the key and a binding to the value. Duplicate keys or values will exist as separate Map.Entries in the returned list. This is only supported on bindings returned from an injector. This will throw UnsupportedOperationException if it is called on an element retrieved from getElements(Module...).

The elements will always match the type Map's generic type. For example, if getMapKey returns a key of Map<String, Snack>, then this will always return a list of type List<Map.Entry<String, Binding<Snack>>>.

public abstract TypeLiteral<?> getKeyTypeLiteral ()

Returns the TypeLiteral describing the keys of the map.

The TypeLiteral will always match the type Map's generic type. For example, if getMapKey returns a key of Map<String, Snack>, then this will always return a TypeLiteral<String>.

public abstract Key<T> getMapKey ()

Returns the Key for the map.

public abstract TypeLiteral<?> getValueTypeLiteral ()

Returns the TypeLiteral describing the values of the map.

The TypeLiteral will always match the type Map's generic type. For example, if getMapKey returns a key of Map<String, Snack>, then this will always return a TypeLiteral<Snack>.

public abstract boolean permitsDuplicates ()

Returns true if the MapBinder permits duplicates. This is only supported on bindings returned from an injector. This will throw UnsupportedOperationException if it is called on a MapBinderBinding retrieved from getElements(Module...).

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/multibindings/MapBinder.html0000755000175000017500000010736011704661106030232 0ustar tonytony MapBinder | Guice
public abstract class

MapBinder

extends Object
java.lang.Object
   ↳ com.google.inject.multibindings.MapBinder<K, V>

Class Overview

An API to bind multiple map entries separately, only to later inject them as a complete map. MapBinder is intended for use in your application's module:


 public class SnacksModule extends AbstractModule {
   protected void configure() {
     MapBinder<String, Snack> mapbinder
         = MapBinder.newMapBinder(binder(), String.class, Snack.class);
     mapbinder.addBinding("twix").toInstance(new Twix());
     mapbinder.addBinding("snickers").toProvider(SnickersProvider.class);
     mapbinder.addBinding("skittles").to(Skittles.class);
   }
 }

With this binding, a Map<String, Snack> can now be injected:


 class SnackMachine {
   @Inject
   public SnackMachine(Map<String, Snack> snacks) { ... }
 }

In addition to binding Map<K, V>, a mapbinder will also bind Map<K, Provider<V>> for lazy value provision:


 class SnackMachine {
   @Inject
   public SnackMachine(Map<String, Provider<Snack>> snackProviders) { ... }
 }

Contributing mapbindings from different modules is supported. For example, it is okay to have both CandyModule and ChipsModule both create their own MapBinder<String, Snack>, and to each contribute bindings to the snacks map. When that map is injected, it will contain entries from both modules.

The map's iteration order is consistent with the binding order. This is convenient when multiple elements are contributed by the same module because that module can order its bindings appropriately. Avoid relying on the iteration order of elements contributed by different modules, since there is no equivalent mechanism to order modules.

The map is unmodifiable. Elements can only be added to the map by configuring the MapBinder. Elements can never be removed from the map.

Values are resolved at map injection time. If a value is bound to a provider, that provider's get method will be called each time the map is injected (unless the binding is also scoped, or a map of providers is injected).

Annotations are used to create different maps of the same key/value type. Each distinct annotation gets its own independent map.

Keys must be distinct. If the same key is bound more than once, map injection will fail. However, use permitDuplicates() in order to allow duplicate keys; extra bindings to Map<K, Set<V>> and Map<K, Set<Provider<V>> will be added.

Keys must be non-null. addBinding(null) will throw an unchecked exception.

Values must be non-null to use map injection. If any value is null, map injection will fail (although injecting a map of providers will not).

Summary

Public Methods
abstract LinkedBindingBuilder<V> addBinding(K key)
Returns a binding builder used to add a new entry in the map.
static <K, V> MapBinder<K, V> newMapBinder(Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType)
Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with no binding annotation.
static <K, V> MapBinder<K, V> newMapBinder(Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType, Class<? extends Annotation> annotationType)
Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotationType.
static <K, V> MapBinder<K, V> newMapBinder(Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType, Annotation annotation)
Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotation.
static <K, V> MapBinder<K, V> newMapBinder(Binder binder, Class<K> keyType, Class<V> valueType)
Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with no binding annotation.
static <K, V> MapBinder<K, V> newMapBinder(Binder binder, Class<K> keyType, Class<V> valueType, Class<? extends Annotation> annotationType)
Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotationType.
static <K, V> MapBinder<K, V> newMapBinder(Binder binder, Class<K> keyType, Class<V> valueType, Annotation annotation)
Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotation.
abstract MapBinder<K, V> permitDuplicates()
Configures the MapBinder to handle duplicate entries.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public abstract LinkedBindingBuilder<V> addBinding (K key)

Returns a binding builder used to add a new entry in the map. Each key must be distinct (and non-null). Bound providers will be evaluated each time the map is injected.

It is an error to call this method without also calling one of the to methods on the returned binding builder.

Scoping elements independently is supported. Use the in method to specify a binding scope.

public static MapBinder<K, V> newMapBinder (Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType)

Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with no binding annotation.

public static MapBinder<K, V> newMapBinder (Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType, Class<? extends Annotation> annotationType)

Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotationType.

public static MapBinder<K, V> newMapBinder (Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType, Annotation annotation)

Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotation.

public static MapBinder<K, V> newMapBinder (Binder binder, Class<K> keyType, Class<V> valueType)

Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with no binding annotation.

public static MapBinder<K, V> newMapBinder (Binder binder, Class<K> keyType, Class<V> valueType, Class<? extends Annotation> annotationType)

Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotationType.

public static MapBinder<K, V> newMapBinder (Binder binder, Class<K> keyType, Class<V> valueType, Annotation annotation)

Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotation.

public abstract MapBinder<K, V> permitDuplicates ()

Configures the MapBinder to handle duplicate entries.

When multiple equal keys are bound, the value that gets included in the map is arbitrary.

In addition to the Map<K, V> and Map<K, Provider<V>> maps that are normally bound, a Map<K, Set<V>> and Map<K, Set<Provider<V>>> are also bound, which contain all values bound to each key.

When multiple modules contribute elements to the map, this configuration option impacts all of them.

Returns
  • this map binder
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/matcher/0000755000175000017500000000000011704661106024244 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/matcher/package-summary.html0000755000175000017500000002601211704661106030224 0ustar tonytony com.google.inject.matcher | Guice
package

com.google.inject.matcher

Classes | Description

Used for matching things.

more...

Interfaces

Matcher<T> Returns true or false for a given input. 

Classes

AbstractMatcher<T> Implements and() and or()
Matchers Matcher implementations. 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/matcher/package-descr.html0000755000175000017500000002352111704661106027631 0ustar tonytony com.google.inject.matcher Details | Guice
package

com.google.inject.matcher

Classes | Description

Used for matching things. Primarily used to pick out methods to which to apply interceptors.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/matcher/Matchers.html0000755000175000017500000007477111704661106026723 0ustar tonytony Matchers | Guice
public class

Matchers

extends Object
java.lang.Object
   ↳ com.google.inject.matcher.Matchers

Class Overview

Matcher implementations. Supports matching classes and methods.

Summary

Public Methods
static Matcher<AnnotatedElement> annotatedWith(Class<? extends Annotation> annotationType)
Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.
static Matcher<AnnotatedElement> annotatedWith(Annotation annotation)
Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.
static Matcher<Object> any()
Returns a matcher which matches any input.
static Matcher<Object> identicalTo(Object value)
Returns a matcher which matches only the given object.
static Matcher<Class> inPackage(Package targetPackage)
Returns a matcher which matches classes in the given package.
static Matcher<Class> inSubpackage(String targetPackageName)
Returns a matcher which matches classes in the given package and its subpackages.
static <T> Matcher<T> not(Matcher<? super T> p)
Inverts the given matcher.
static Matcher<Object> only(Object value)
Returns a matcher which matches objects equal to the given object.
static Matcher<Method> returns(Matcher<? super Class<?>> returnType)
Returns a matcher which matches methods with matching return types.
static Matcher<Class> subclassesOf(Class<?> superclass)
Returns a matcher which matches subclasses of the given type (as well as the given type).
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Matcher<AnnotatedElement> annotatedWith (Class<? extends Annotation> annotationType)

Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.

public static Matcher<AnnotatedElement> annotatedWith (Annotation annotation)

Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.

public static Matcher<Object> any ()

Returns a matcher which matches any input.

public static Matcher<Object> identicalTo (Object value)

Returns a matcher which matches only the given object.

public static Matcher<Class> inPackage (Package targetPackage)

Returns a matcher which matches classes in the given package. Packages are specific to their classloader, so classes with the same package name may not have the same package at runtime.

public static Matcher<Class> inSubpackage (String targetPackageName)

Returns a matcher which matches classes in the given package and its subpackages. Unlike inPackage(), this matches classes from any classloader.

public static Matcher<T> not (Matcher<? super T> p)

Inverts the given matcher.

public static Matcher<Object> only (Object value)

Returns a matcher which matches objects equal to the given object.

public static Matcher<Method> returns (Matcher<? super Class<?>> returnType)

Returns a matcher which matches methods with matching return types.

public static Matcher<Class> subclassesOf (Class<?> superclass)

Returns a matcher which matches subclasses of the given type (as well as the given type).

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/matcher/Matcher.html0000755000175000017500000004140311704661106026522 0ustar tonytony Matcher | Guice
public interface

Matcher

com.google.inject.matcher.Matcher<T>
Known Indirect Subclasses

Class Overview

Returns true or false for a given input.

Summary

Public Methods
abstract Matcher<T> and(Matcher<? super T> other)
Returns a new matcher which returns true if both this and the given matcher return true.
abstract boolean matches(T t)
Returns true if this matches t, false otherwise.
abstract Matcher<T> or(Matcher<? super T> other)
Returns a new matcher which returns true if either this or the given matcher return true.

Public Methods

public abstract Matcher<T> and (Matcher<? super T> other)

Returns a new matcher which returns true if both this and the given matcher return true.

public abstract boolean matches (T t)

Returns true if this matches t, false otherwise.

public abstract Matcher<T> or (Matcher<? super T> other)

Returns a new matcher which returns true if either this or the given matcher return true.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/matcher/AbstractMatcher.html0000755000175000017500000005644211704661106030217 0ustar tonytony AbstractMatcher | Guice
public abstract class

AbstractMatcher

extends Object
implements Matcher<T>
java.lang.Object
   ↳ com.google.inject.matcher.AbstractMatcher<T>

Class Overview

Implements and() and or().

Summary

Public Constructors
AbstractMatcher()
Public Methods
Matcher<T> and(Matcher<? super T> other)
Returns a new matcher which returns true if both this and the given matcher return true.
Matcher<T> or(Matcher<? super T> other)
Returns a new matcher which returns true if either this or the given matcher return true.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.matcher.Matcher

Public Constructors

public AbstractMatcher ()

Public Methods

public Matcher<T> and (Matcher<? super T> other)

Returns a new matcher which returns true if both this and the given matcher return true.

public Matcher<T> or (Matcher<? super T> other)

Returns a new matcher which returns true if either this or the given matcher return true.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/jndi/0000755000175000017500000000000011704661106023545 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/jndi/package-summary.html0000755000175000017500000002400211704661106027522 0ustar tonytony com.google.inject.jndi | Guice
package

com.google.inject.jndi

Classes | Description

JNDI integration; this extension requires guice-jndi-3.0.jar.

more...

Classes

JndiIntegration Integrates Guice with JNDI. 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/jndi/package-descr.html0000755000175000017500000002276211704661106027140 0ustar tonytony com.google.inject.jndi Details | Guice
package

com.google.inject.jndi

Classes | Description

JNDI integration; this extension requires guice-jndi-3.0.jar.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/jndi/JndiIntegration.html0000755000175000017500000004155311704661106027536 0ustar tonytony JndiIntegration | Guice
public class

JndiIntegration

extends Object
java.lang.Object
   ↳ com.google.inject.jndi.JndiIntegration

Class Overview

Integrates Guice with JNDI. Requires a binding to javax.naming.Context.

Summary

Public Methods
static <T> Provider<T> fromJndi(Class<T> type, String name)
Creates a provider which looks up objects in JNDI using the given name.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Provider<T> fromJndi (Class<T> type, String name)

Creates a provider which looks up objects in JNDI using the given name. Example usage:

 bind(DataSource.class).toProvider(fromJndi(DataSource.class, "java:..."));
 

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/0000755000175000017500000000000011704661106024251 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/package-summary.html0000755000175000017500000005275311704661106030244 0ustar tonytony com.google.inject.grapher | Guice
package

com.google.inject.grapher

Interfaces

BindingEdge<K> Interface for an edge that connects an interface to the type or instance that is bound to implement it. 
BindingEdge.Factory<K, T extends BindingEdge<K>> Factory interface for BindingEdges. 
DependencyEdge<K> Interface for an edge from a class or InjectionPoint to the interface node that will satisfy the dependency. 
DependencyEdge.Factory<K, T extends DependencyEdge<K>> Factory interface for DependencyEdges. 
ImplementationNode<K> Node for classes and instances that have Dependencys and are bound to InterfaceNodes. 
ImplementationNode.Factory<K, T extends ImplementationNode<K>> Factory interface for ImplementationNodes. 
InterfaceNode<K> Node for an interface class that has been bound to an implementation class or instance. 
InterfaceNode.Factory<K, T extends InterfaceNode<K>> Factory interface for InterfaceNodes. 
NameFactory Interface for a service that provides nice Strings that we can display in the graph for the types that come up in Bindings. 
NodeAliasFactory<K> Factory for aliasing one node ID to another. 
NodeIdFactory<K> Factory for abstract identifiers for elements on the graph. 
Renderer Interface for the service that renders the graph. 

Classes

GrapherModule Module for the common bindings for InjectorGrapher
GraphingVisitor<K, N extends InterfaceNode<K>, M extends ImplementationNode<K>, B extends BindingEdge<K>, D extends DependencyEdge<K>> BindingTargetVisitor that adds nodes and edges to the graph based on the visited Binding
InjectorGrapher Root class for graphing an Injector
ShortNameFactory Reasonable implementation for NameFactory
StringNodeIdFactory IdFactory implementation that for String node IDs. 
TransitiveDependencyVisitor BindingTargetVisitor that returns a Collection of the Keys of each Binding's dependencies. 

Enums

BindingEdge.Type Classification for what kind of binding this edge represents. 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/package-descr.html0000755000175000017500000003206211704661106027636 0ustar tonytony com.google.inject.grapher Details | Guice
package

com.google.inject.grapher

Classes | Description

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/0000755000175000017500000000000011704661106026103 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/package-summary.html0000755000175000017500000005155011704661106032070 0ustar tonytony com.google.inject.grapher.graphviz | Guice
package

com.google.inject.grapher.graphviz

Interfaces

PortIdFactory Interface for a service that returns Graphviz port IDs, used for naming the rows in ImplementationNode-displaying GraphvizNodes. 

Classes

BindingEdgeFactory Graphviz-specific implementation of BindingEdge.Factory
BindingEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts BindingEdge methods to display operations on a GraphvizEdge
DependencyEdgeFactory Graphviz-specific implementation of DependencyEdge.Factory
DependencyEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts DependencyEdge methods to display operations on a GraphvizEdge
GraphvizEdge Data object to encapsulate the attributes of Graphviz edges that we're interested in drawing. 
GraphvizModule Module that provides GraphvizRenderer as the Renderer and binds the other Graphviz factories. 
GraphvizNode Data object to encapsulate the attributes of Graphviz nodes that we're interested in drawing. 
GraphvizRenderer Renderer implementation that writes out a Graphviz DOT file of the graph. 
ImplementationNodeFactory Graphviz-specific implementation of ImplementationNode.Factory
ImplementationNodeFactory.GraphvizNodeAdaptor Adaptor class that converts ImplementationNode methods to display operations on a GraphvizNode
InterfaceNodeFactory Graphviz-specific implementation of InterfaceNode.Factory
InterfaceNodeFactory.GraphvizNodeAdaptor Adaptor class that converts InterfaceNode methods to display operations on a GraphvizNode
PortIdFactoryImpl Implementation of PortIdFactory

Enums

ArrowType Arrow symbols that are available from Graphviz. 
CompassPoint Enum for the "compass point" values used to control where edge end points appear on the graph. 
EdgeStyle Styles for edges. 
NodeShape Enum for the shapes that are most interesting for Guice graphing. 
NodeStyle Styles for nodes. 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/package-descr.html0000755000175000017500000003075511704661106031477 0ustar tonytony com.google.inject.grapher.graphviz Details | Guice
package

com.google.inject.grapher.graphviz

Classes | Description

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/PortIdFactoryImpl.html0000755000175000017500000005503611704661106032360 0ustar tonytony PortIdFactoryImpl | Guice
public class

PortIdFactoryImpl

extends Object
implements PortIdFactory
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.PortIdFactoryImpl

Class Overview

Implementation of PortIdFactory. Bound in GraphvizModule.

Summary

Public Constructors
PortIdFactoryImpl()
Public Methods
String getPortId(Member member)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.graphviz.PortIdFactory

Public Constructors

public PortIdFactoryImpl ()

Public Methods

public String getPortId (Member member)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/PortIdFactory.html0000755000175000017500000004065011704661106031532 0ustar tonytony PortIdFactory | Guice
public interface

PortIdFactory

com.google.inject.grapher.graphviz.PortIdFactory
Known Indirect Subclasses

Class Overview

Interface for a service that returns Graphviz port IDs, used for naming the rows in ImplementationNode-displaying GraphvizNodes. Implemented by StringNodeIdFactory.

Summary

Public Methods
abstract String getPortId(Member member)

Public Methods

public abstract String getPortId (Member member)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/NodeStyle.html0000755000175000017500000010522411704661106030706 0ustar tonytony NodeStyle | Guice
public final enum

NodeStyle

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.grapher.graphviz.NodeStyle

Class Overview

Styles for nodes. Similar to EdgeStyle but with a few more options.

See: http://www.graphviz.org/doc/info/attrs.html#k:style

Summary

Enum Values
NodeStyle  BOLD   
NodeStyle  DASHED   
NodeStyle  DIAGONALS   
NodeStyle  DOTTED   
NodeStyle  FILLED   
NodeStyle  INVISIBLE   
NodeStyle  ROUNDED   
NodeStyle  SOLID   
Public Methods
String toString()
static NodeStyle valueOf(String name)
final static NodeStyle[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final NodeStyle BOLD

Since: API Level

public static final NodeStyle DASHED

Since: API Level

public static final NodeStyle DIAGONALS

Since: API Level

public static final NodeStyle DOTTED

Since: API Level

public static final NodeStyle FILLED

Since: API Level

public static final NodeStyle INVISIBLE

Since: API Level

public static final NodeStyle ROUNDED

Since: API Level

public static final NodeStyle SOLID

Since: API Level

Public Methods

public String toString ()

Since: API Level

public static NodeStyle valueOf (String name)

public static final NodeStyle[] values ()

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/NodeShape.html0000755000175000017500000007436311704661106030657 0ustar tonytony NodeShape | Guice
public final enum

NodeShape

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.grapher.graphviz.NodeShape

Class Overview

Enum for the shapes that are most interesting for Guice graphing.

See: http://www.graphviz.org/doc/info/shapes.html

Summary

Enum Values
NodeShape  BOX   
NodeShape  ELLIPSE   
NodeShape  NONE   
Public Methods
String toString()
static NodeShape valueOf(String name)
final static NodeShape[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final NodeShape BOX

Since: API Level

public static final NodeShape ELLIPSE

Since: API Level

public static final NodeShape NONE

Since: API Level

Public Methods

public String toString ()

Since: API Level

public static NodeShape valueOf (String name)

public static final NodeShape[] values ()

././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/InterfaceNodeFactory.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/InterfaceNodeFactory.h0000755000175000017500000006106011704661106032320 0ustar tonytony InterfaceNodeFactory | Guice
public class

InterfaceNodeFactory

extends Object
implements InterfaceNode.Factory<K, T extends InterfaceNode<K>>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.InterfaceNodeFactory

Class Overview

Graphviz-specific implementation of InterfaceNode.Factory. Uses a GraphvizEdgeAdaptor to delegate to a GraphvizNode.

Summary

Nested Classes
class InterfaceNodeFactory.GraphvizNodeAdaptor Adaptor class that converts InterfaceNode methods to display operations on a GraphvizNode
Public Constructors
InterfaceNodeFactory(GraphvizRenderer renderer, NameFactory nameFactory)
Public Methods
InterfaceNode<String> newInterfaceNode(String nodeId)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.InterfaceNode.Factory

Public Constructors

public InterfaceNodeFactory (GraphvizRenderer renderer, NameFactory nameFactory)

Public Methods

public InterfaceNode<String> newInterfaceNode (String nodeId)

././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/InterfaceNodeFactory.GraphvizNodeAdaptor.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/InterfaceNodeFactory.G0000755000175000017500000006371511704661106032270 0ustar tonytony InterfaceNodeFactory.GraphvizNodeAdaptor | Guice
protected class

InterfaceNodeFactory.GraphvizNodeAdaptor

extends Object
implements InterfaceNode<K>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.InterfaceNodeFactory.GraphvizNodeAdaptor

Class Overview

Adaptor class that converts InterfaceNode methods to display operations on a GraphvizNode.

Summary

Fields
protected final GraphvizNode node
Public Constructors
InterfaceNodeFactory.GraphvizNodeAdaptor(GraphvizNode node)
Public Methods
void setKey(Key<?> key)
void setSource(Object source)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.InterfaceNode

Fields

protected final GraphvizNode node

Public Constructors

public InterfaceNodeFactory.GraphvizNodeAdaptor (GraphvizNode node)

Public Methods

public void setKey (Key<?> key)

public void setSource (Object source)

././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/ImplementationNodeFactory.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/ImplementationNodeFact0000755000175000017500000006605311704661106032434 0ustar tonytony ImplementationNodeFactory | Guice
public class

ImplementationNodeFactory

extends Object
implements ImplementationNode.Factory<K, T extends ImplementationNode<K>>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.ImplementationNodeFactory

Class Overview

Graphviz-specific implementation of ImplementationNode.Factory. Uses a BindingEdgeFactory.GraphvizEdgeAdaptor to delegate to a GraphvizNode.

Summary

Nested Classes
class ImplementationNodeFactory.GraphvizNodeAdaptor Adaptor class that converts ImplementationNode methods to display operations on a GraphvizNode
Public Constructors
ImplementationNodeFactory(GraphvizRenderer renderer, NameFactory nameFactory, PortIdFactory portIdFactory)
Public Methods
ImplementationNode<String> newImplementationNode(String nodeId)
Protected Methods
ImplementationNodeFactory.GraphvizNodeAdaptor newAdaptor(GraphvizNode node)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.ImplementationNode.Factory

Public Constructors

public ImplementationNodeFactory (GraphvizRenderer renderer, NameFactory nameFactory, PortIdFactory portIdFactory)

Public Methods

public ImplementationNode<String> newImplementationNode (String nodeId)

Protected Methods

././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/ImplementationNodeFactory.GraphvizNodeAdaptor.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/ImplementationNodeFact0000755000175000017500000007372711704661106032442 0ustar tonytony ImplementationNodeFactory.GraphvizNodeAdaptor | Guice
protected class

ImplementationNodeFactory.GraphvizNodeAdaptor

extends Object
implements ImplementationNode<K>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.ImplementationNodeFactory.GraphvizNodeAdaptor

Class Overview

Adaptor class that converts ImplementationNode methods to display operations on a GraphvizNode.

Summary

Fields
protected final GraphvizNode node
Public Constructors
ImplementationNodeFactory.GraphvizNodeAdaptor(GraphvizNode node)
Public Methods
void addMember(Member member)
void setClassKey(Key<?> key)
Sets the Key that this node is for.
void setInstance(Object instance)
Sets the Object that's the already-created instance.
void setSource(Object source)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.ImplementationNode

Fields

protected final GraphvizNode node

Public Constructors

public ImplementationNodeFactory.GraphvizNodeAdaptor (GraphvizNode node)

Public Methods

public void addMember (Member member)

public void setClassKey (Key<?> key)

Sets the Key that this node is for. Used when the node is representing a class that Guice will instantiate.

public void setInstance (Object instance)

Sets the Object that's the already-created instance. Used when this node is represeting the instance instead of a class.

public void setSource (Object source)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/GraphvizRenderer.html0000755000175000017500000013375311704661106032271 0ustar tonytony GraphvizRenderer | Guice
public class

GraphvizRenderer

extends Object
implements NodeAliasFactory<K> Renderer
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.GraphvizRenderer

Class Overview

Renderer implementation that writes out a Graphviz DOT file of the graph. Bound in GraphvizModule.

Specify the PrintWriter to output to with setOut(PrintWriter).

Summary

Public Constructors
GraphvizRenderer()
Public Methods
void addEdge(GraphvizEdge edge)
void addNode(GraphvizNode node)
void newAlias(String fromId, String toId)
void render()
GraphvizRenderer setOut(PrintWriter out)
GraphvizRenderer setRankdir(String rankdir)
Protected Methods
void finish()
String getArrowString(List<ArrowType> arrows)
Turns a List of ArrowTypes into a String that represents combining them.
Map<String, String> getEdgeAttributes(GraphvizEdge edge)
String getEdgeEndPoint(String nodeId, String portId, CompassPoint compassPoint)
Map<String, String> getGraphAttributes()
Map<String, String> getNodeAttributes(GraphvizNode node)
String getNodeLabel(GraphvizNode node)
Creates the "label" for a node.
String htmlEscape(String str)
void renderEdge(GraphvizEdge edge)
void renderNode(GraphvizNode node)
String resolveAlias(String id)
void start()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.NodeAliasFactory
From interface com.google.inject.grapher.Renderer

Public Constructors

public GraphvizRenderer ()

Public Methods

public void addEdge (GraphvizEdge edge)

public void addNode (GraphvizNode node)

public void newAlias (String fromId, String toId)

public void render ()

public GraphvizRenderer setOut (PrintWriter out)

public GraphvizRenderer setRankdir (String rankdir)

Protected Methods

protected void finish ()

protected String getArrowString (List<ArrowType> arrows)

Turns a List of ArrowTypes into a String that represents combining them. With Graphviz, that just means concatenating them.

protected Map<String, String> getEdgeAttributes (GraphvizEdge edge)

protected String getEdgeEndPoint (String nodeId, String portId, CompassPoint compassPoint)

protected Map<String, String> getGraphAttributes ()

protected Map<String, String> getNodeAttributes (GraphvizNode node)

protected String getNodeLabel (GraphvizNode node)

Creates the "label" for a node. This is a string of HTML that defines a table with a heading at the top and (in the case of ImplementationNodes) rows for each of the member fields.

protected String htmlEscape (String str)

protected void renderEdge (GraphvizEdge edge)

protected void renderNode (GraphvizNode node)

protected String resolveAlias (String id)

protected void start ()

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/GraphvizNode.html0000755000175000017500000011052311704661106031376 0ustar tonytony GraphvizNode | Guice
public class

GraphvizNode

extends Object
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.GraphvizNode

Class Overview

Data object to encapsulate the attributes of Graphviz nodes that we're interested in drawing.

Summary

Public Constructors
GraphvizNode(String nodeId)
Public Methods
void addField(String portId, String title)
void addSubtitle(int position, String subtitle)
Map<String, String> getFields()
String getHeaderBackgroundColor()
String getHeaderTextColor()
String getNodeId()
NodeShape getShape()
NodeStyle getStyle()
List<String> getSubtitles()
String getTitle()
void setHeaderBackgroundColor(String headerBackgroundColor)
void setHeaderTextColor(String headerTextColor)
void setShape(NodeShape shape)
void setStyle(NodeStyle style)
void setTitle(String title)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public GraphvizNode (String nodeId)

Public Methods

public void addField (String portId, String title)

public void addSubtitle (int position, String subtitle)

public Map<String, String> getFields ()

public String getHeaderBackgroundColor ()

public String getHeaderTextColor ()

public String getNodeId ()

public NodeShape getShape ()

public NodeStyle getStyle ()

public List<String> getSubtitles ()

public String getTitle ()

public void setHeaderBackgroundColor (String headerBackgroundColor)

public void setHeaderTextColor (String headerTextColor)

public void setShape (NodeShape shape)

public void setStyle (NodeStyle style)

public void setTitle (String title)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/GraphvizModule.html0000755000175000017500000011272211704661106031741 0ustar tonytony GraphvizModule | Guice
public class

GraphvizModule

extends AbstractModule
java.lang.Object
   ↳ com.google.inject.AbstractModule
     ↳ com.google.inject.grapher.graphviz.GraphvizModule

Class Overview

Module that provides GraphvizRenderer as the Renderer and binds the other Graphviz factories.

Summary

Public Constructors
GraphvizModule()
Protected Methods
void configure()
Configures a Binder via the exposed methods.
[Expand]
Inherited Methods
From class com.google.inject.AbstractModule
From class java.lang.Object
From interface com.google.inject.Module

Public Constructors

public GraphvizModule ()

Protected Methods

protected void configure ()

Configures a Binder via the exposed methods.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/GraphvizEdge.html0000755000175000017500000011533011704661106031356 0ustar tonytony GraphvizEdge | Guice
public class

GraphvizEdge

extends Object
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.GraphvizEdge

Class Overview

Data object to encapsulate the attributes of Graphviz edges that we're interested in drawing.

Summary

Public Constructors
GraphvizEdge(String tailNodeId, String headNodeId)
Public Methods
List<ArrowType> getArrowHead()
List<ArrowType> getArrowTail()
CompassPoint getHeadCompassPoint()
String getHeadNodeId()
String getHeadPortId()
EdgeStyle getStyle()
CompassPoint getTailCompassPoint()
String getTailNodeId()
String getTailPortId()
void setArrowHead(List<ArrowType> arrowHead)
void setArrowTail(List<ArrowType> arrowTail)
void setHeadCompassPoint(CompassPoint headCompassPoint)
void setHeadPortId(String headPortId)
void setStyle(EdgeStyle style)
void setTailCompassPoint(CompassPoint tailCompassPoint)
void setTailPortId(String tailPortId)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public GraphvizEdge (String tailNodeId, String headNodeId)

Public Methods

public List<ArrowType> getArrowHead ()

public List<ArrowType> getArrowTail ()

public CompassPoint getHeadCompassPoint ()

public String getHeadNodeId ()

public String getHeadPortId ()

public EdgeStyle getStyle ()

public CompassPoint getTailCompassPoint ()

public String getTailNodeId ()

public String getTailPortId ()

public void setArrowHead (List<ArrowType> arrowHead)

public void setArrowTail (List<ArrowType> arrowTail)

public void setHeadCompassPoint (CompassPoint headCompassPoint)

public void setHeadPortId (String headPortId)

public void setStyle (EdgeStyle style)

public void setTailCompassPoint (CompassPoint tailCompassPoint)

public void setTailPortId (String tailPortId)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/EdgeStyle.html0000755000175000017500000007766311704661106030704 0ustar tonytony EdgeStyle | Guice
public final enum

EdgeStyle

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.grapher.graphviz.EdgeStyle

Class Overview

Styles for edges.

See: http://www.graphviz.org/doc/info/attrs.html#k:style

Summary

Enum Values
EdgeStyle  BOLD   
EdgeStyle  DASHED   
EdgeStyle  DOTTED   
EdgeStyle  INVISIBLE   
EdgeStyle  SOLID   
Public Methods
String toString()
static EdgeStyle valueOf(String name)
final static EdgeStyle[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final EdgeStyle BOLD

Since: API Level

public static final EdgeStyle DASHED

Since: API Level

public static final EdgeStyle DOTTED

Since: API Level

public static final EdgeStyle INVISIBLE

Since: API Level

public static final EdgeStyle SOLID

Since: API Level

Public Methods

public String toString ()

Since: API Level

public static EdgeStyle valueOf (String name)

public static final EdgeStyle[] values ()

././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/DependencyEdgeFactory.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/DependencyEdgeFactory.0000755000175000017500000006611711704661106032315 0ustar tonytony DependencyEdgeFactory | Guice
public class

DependencyEdgeFactory

extends Object
implements DependencyEdge.Factory<K, T extends DependencyEdge<K>>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.DependencyEdgeFactory

Class Overview

Graphviz-specific implementation of DependencyEdge.Factory. Uses a DependencyEdgeFactory.GraphvizEdgeAdaptor to delegate to a GraphvizEdge.

Summary

Nested Classes
class DependencyEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts DependencyEdge methods to display operations on a GraphvizEdge
Public Constructors
DependencyEdgeFactory(GraphvizRenderer renderer, PortIdFactory portIdFactory)
Public Methods
DependencyEdge<String> newDependencyEdge(String fromId, InjectionPoint fromPoint, String toId)
Protected Methods
DependencyEdgeFactory.GraphvizEdgeAdaptor newAdaptor(GraphvizEdge edge)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.DependencyEdge.Factory

Public Constructors

public DependencyEdgeFactory (GraphvizRenderer renderer, PortIdFactory portIdFactory)

Public Methods

public DependencyEdge<String> newDependencyEdge (String fromId, InjectionPoint fromPoint, String toId)

Protected Methods

././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/DependencyEdgeFactory.GraphvizEdgeAdaptor.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/DependencyEdgeFactory.0000755000175000017500000005317411704661106032314 0ustar tonytony DependencyEdgeFactory.GraphvizEdgeAdaptor | Guice
protected class

DependencyEdgeFactory.GraphvizEdgeAdaptor

extends Object
implements DependencyEdge<K>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.DependencyEdgeFactory.GraphvizEdgeAdaptor

Class Overview

Adaptor class that converts DependencyEdge methods to display operations on a GraphvizEdge.

Summary

Fields
protected final GraphvizEdge edge
Public Constructors
DependencyEdgeFactory.GraphvizEdgeAdaptor(GraphvizEdge edge)
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected final GraphvizEdge edge

Public Constructors

public DependencyEdgeFactory.GraphvizEdgeAdaptor (GraphvizEdge edge)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/CompassPoint.html0000755000175000017500000011077411704661106031425 0ustar tonytony CompassPoint | Guice
public final enum

CompassPoint

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.grapher.graphviz.CompassPoint

Class Overview

Enum for the "compass point" values used to control where edge end points appear on the graph.

See: http://www.graphviz.org/doc/info/attrs.html#k:portPos

Summary

Enum Values
CompassPoint  CENTER   
CompassPoint  EAST   
CompassPoint  EXTERIOR_SIDE   
CompassPoint  NORTH   
CompassPoint  NORTH_EAST   
CompassPoint  NORTH_WEST   
CompassPoint  SOUTH   
CompassPoint  SOUTH_EAST   
CompassPoint  SOUTH_WEST   
CompassPoint  WEST   
Public Methods
String toString()
static CompassPoint valueOf(String name)
final static CompassPoint[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final CompassPoint CENTER

Since: API Level

public static final CompassPoint EAST

Since: API Level

public static final CompassPoint EXTERIOR_SIDE

Since: API Level

public static final CompassPoint NORTH

Since: API Level

public static final CompassPoint NORTH_EAST

Since: API Level

public static final CompassPoint NORTH_WEST

Since: API Level

public static final CompassPoint SOUTH

Since: API Level

public static final CompassPoint SOUTH_EAST

Since: API Level

public static final CompassPoint SOUTH_WEST

Since: API Level

public static final CompassPoint WEST

Since: API Level

Public Methods

public String toString ()

Since: API Level

public static CompassPoint valueOf (String name)

public static final CompassPoint[] values ()

././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/BindingEdgeFactory.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/BindingEdgeFactory.htm0000755000175000017500000006436511704661106032325 0ustar tonytony BindingEdgeFactory | Guice
public class

BindingEdgeFactory

extends Object
implements BindingEdge.Factory<K, T extends BindingEdge<K>>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.BindingEdgeFactory

Class Overview

Graphviz-specific implementation of BindingEdge.Factory. Uses a BindingEdgeFactory.GraphvizEdgeAdaptor to delegate to a GraphvizEdge.

Summary

Nested Classes
class BindingEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts BindingEdge methods to display operations on a GraphvizEdge
Public Constructors
BindingEdgeFactory(GraphvizRenderer renderer)
Public Methods
BindingEdge<String> newBindingEdge(String fromId, String toId)
Protected Methods
BindingEdgeFactory.GraphvizEdgeAdaptor newAdaptor(GraphvizEdge edge)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.BindingEdge.Factory

Public Constructors

public BindingEdgeFactory (GraphvizRenderer renderer)

Public Methods

public BindingEdge<String> newBindingEdge (String fromId, String toId)

Protected Methods

././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/BindingEdgeFactory.GraphvizEdgeAdaptor.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/BindingEdgeFactory.Gra0000755000175000017500000006104111704661106032232 0ustar tonytony BindingEdgeFactory.GraphvizEdgeAdaptor | Guice
protected class

BindingEdgeFactory.GraphvizEdgeAdaptor

extends Object
implements BindingEdge<K>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.BindingEdgeFactory.GraphvizEdgeAdaptor

Class Overview

Adaptor class that converts BindingEdge methods to display operations on a GraphvizEdge.

Summary

Fields
protected final GraphvizEdge edge
Public Constructors
BindingEdgeFactory.GraphvizEdgeAdaptor(GraphvizEdge edge)
Public Methods
void setType(BindingEdge.Type type)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.BindingEdge

Fields

protected final GraphvizEdge edge

Public Constructors

public BindingEdgeFactory.GraphvizEdgeAdaptor (GraphvizEdge edge)

Public Methods

public void setType (BindingEdge.Type type)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/graphviz/ArrowType.html0000755000175000017500000011741311704661106030737 0ustar tonytony ArrowType | Guice
public final enum

ArrowType

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.grapher.graphviz.ArrowType

Class Overview

Arrow symbols that are available from Graphviz. These can be composed by concatenation to make double arrows and such.

See: http://www.graphviz.org/doc/info/arrows.html

Summary

Enum Values
ArrowType  BOX   
ArrowType  BOX_OPEN   
ArrowType  CROW   
ArrowType  DIAMOND   
ArrowType  DIAMOND_OPEN   
ArrowType  DOT   
ArrowType  DOT_OPEN   
ArrowType  INVERTED   
ArrowType  INVERTED_OPEN   
ArrowType  NONE   
ArrowType  NORMAL   
ArrowType  NORMAL_OPEN   
ArrowType  TEE   
ArrowType  VEE   
Public Methods
String toString()
static ArrowType valueOf(String name)
final static ArrowType[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final ArrowType BOX

Since: API Level

public static final ArrowType BOX_OPEN

Since: API Level

public static final ArrowType CROW

Since: API Level

public static final ArrowType DIAMOND

Since: API Level

public static final ArrowType DIAMOND_OPEN

Since: API Level

public static final ArrowType DOT

Since: API Level

public static final ArrowType DOT_OPEN

Since: API Level

public static final ArrowType INVERTED

Since: API Level

public static final ArrowType INVERTED_OPEN

Since: API Level

public static final ArrowType NONE

Since: API Level

public static final ArrowType NORMAL

Since: API Level

public static final ArrowType NORMAL_OPEN

Since: API Level

public static final ArrowType TEE

Since: API Level

public static final ArrowType VEE

Since: API Level

Public Methods

public String toString ()

Since: API Level

public static ArrowType valueOf (String name)

public static final ArrowType[] values ()

././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/TransitiveDependencyVisitor.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/TransitiveDependencyVisitor.htm0000755000175000017500000012104011704661106032473 0ustar tonytony TransitiveDependencyVisitor | Guice
public class

TransitiveDependencyVisitor

extends Object
implements BindingTargetVisitor<T, V>
java.lang.Object
   ↳ com.google.inject.grapher.TransitiveDependencyVisitor

Class Overview

BindingTargetVisitor that returns a Collection of the Keys of each Binding's dependencies. Used by InjectorGropher to walk the dependency graph from a starting set of Bindings.

Summary

Public Constructors
TransitiveDependencyVisitor()
Public Methods
Collection<Key<?>> visit(ConstructorBinding<?> binding)
Collection<Key<?>> visit(ConvertedConstantBinding<?> binding)
Collection<Key<?>> visit(ExposedBinding<?> binding)
Collection<Key<?>> visit(InstanceBinding<?> binding)
Collection<Key<?>> visit(LinkedKeyBinding<?> binding)
Collection<Key<?>> visit(ProviderBinding<?> binding)
Collection<Key<?>> visit(ProviderInstanceBinding<?> binding)
Collection<Key<?>> visit(ProviderKeyBinding<?> binding)
Collection<Key<?>> visit(UntargettedBinding<?> binding)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.BindingTargetVisitor

Public Constructors

public TransitiveDependencyVisitor ()

Public Methods

public Collection<Key<?>> visit (ConstructorBinding<?> binding)

public Collection<Key<?>> visit (ConvertedConstantBinding<?> binding)

public Collection<Key<?>> visit (ExposedBinding<?> binding)

public Collection<Key<?>> visit (InstanceBinding<?> binding)

public Collection<Key<?>> visit (LinkedKeyBinding<?> binding)

public Collection<Key<?>> visit (ProviderBinding<?> binding)

public Collection<Key<?>> visit (ProviderInstanceBinding<?> binding)

public Collection<Key<?>> visit (ProviderKeyBinding<?> binding)

public Collection<Key<?>> visit (UntargettedBinding<?> binding)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/StringNodeIdFactory.html0000755000175000017500000006142211704661106031030 0ustar tonytony StringNodeIdFactory | Guice
public class

StringNodeIdFactory

extends Object
implements NodeIdFactory<K>
java.lang.Object
   ↳ com.google.inject.grapher.StringNodeIdFactory

Class Overview

IdFactory implementation that for String node IDs. The IDs are comprised of letters, numbers and underscores.

Summary

Public Constructors
StringNodeIdFactory()
Public Methods
String getClassNodeId(Key<?> key)
String getInstanceNodeId(Key<?> key)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.NodeIdFactory

Public Constructors

public StringNodeIdFactory ()

Public Methods

public String getClassNodeId (Key<?> key)

public String getInstanceNodeId (Key<?> key)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/ShortNameFactory.html0000755000175000017500000010024311704661106030372 0ustar tonytony ShortNameFactory | Guice
public class

ShortNameFactory

extends Object
implements NameFactory
java.lang.Object
   ↳ com.google.inject.grapher.ShortNameFactory

Class Overview

Reasonable implementation for NameFactory. Mostly takes various toString()s and strips package names out of them so that they'll fit on the graph.

Summary

Public Constructors
ShortNameFactory()
Public Methods
String getAnnotationName(Key<?> key)
String getClassName(Key<?> key)
String getInstanceName(Object instance)
String getMemberName(Member member)
String getSourceName(Object source)
Returns a name for a Guice "source" object.
Protected Methods
String getFileString(StackTraceElement stackTraceElement)
String getMethodString(Method method)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.NameFactory

Public Constructors

public ShortNameFactory ()

Public Methods

public String getAnnotationName (Key<?> key)

public String getClassName (Key<?> key)

public String getInstanceName (Object instance)

public String getMemberName (Member member)

public String getSourceName (Object source)

Returns a name for a Guice "source" object. This will typically be either a StackTraceElement for when the binding is made to the instance, or a Method when a provider method is used.

Protected Methods

protected String getFileString (StackTraceElement stackTraceElement)

protected String getMethodString (Method method)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/Renderer.html0000755000175000017500000004276411704661106026725 0ustar tonytony Renderer | Guice
public interface

Renderer

com.google.inject.grapher.Renderer
Known Indirect Subclasses

Class Overview

Interface for the service that renders the graph. It is assumed that the implementations for BindingEdge.Factory, ImplementationNode.Factory, etc. will have direct access to the internals of the Renderer implementation, so the only external interface needed is the render() call that InjectorGrapher calls when it's done.

Summary

Public Methods
abstract void render()

Public Methods

public abstract void render ()

Throws
IOException
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/NodeIdFactory.html0000755000175000017500000004465511704661106027652 0ustar tonytony NodeIdFactory | Guice
public interface

NodeIdFactory

com.google.inject.grapher.NodeIdFactory<K>
Known Indirect Subclasses

Class Overview

Factory for abstract identifiers for elements on the graph. Most graph nodes will correspond directly to Keys, but we do this for additional flexibility and because instances do not have separate Keys from the interfaces they are bound to.

Node IDs are treated as opaque values by GraphingVisitor and the other classes in this package.

Summary

Public Methods
abstract K getClassNodeId(Key<?> key)
abstract K getInstanceNodeId(Key<?> key)

Public Methods

public abstract K getClassNodeId (Key<?> key)

public abstract K getInstanceNodeId (Key<?> key)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/NodeAliasFactory.html0000755000175000017500000004172411704661106030341 0ustar tonytony NodeAliasFactory | Guice
public interface

NodeAliasFactory

com.google.inject.grapher.NodeAliasFactory<K>
Known Indirect Subclasses

Class Overview

Factory for aliasing one node ID to another. Used when we don't want to render Keys from Bindings that are not interesting.

Summary

Public Methods
abstract void newAlias(K fromId, K toId)
Makes edges that would point to fromId point to toId instead.

Public Methods

public abstract void newAlias (K fromId, K toId)

Makes edges that would point to fromId point to toId instead.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/NameFactory.html0000755000175000017500000005247411704661106027366 0ustar tonytony NameFactory | Guice
public interface

NameFactory

com.google.inject.grapher.NameFactory
Known Indirect Subclasses

Class Overview

Interface for a service that provides nice Strings that we can display in the graph for the types that come up in Bindings.

Summary

Public Methods
abstract String getAnnotationName(Key<?> key)
abstract String getClassName(Key<?> key)
abstract String getInstanceName(Object instance)
abstract String getMemberName(Member member)
abstract String getSourceName(Object source)

Public Methods

public abstract String getAnnotationName (Key<?> key)

public abstract String getClassName (Key<?> key)

public abstract String getInstanceName (Object instance)

public abstract String getMemberName (Member member)

public abstract String getSourceName (Object source)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/InterfaceNode.html0000755000175000017500000004633311704661106027661 0ustar tonytony InterfaceNode | Guice
public interface

InterfaceNode

com.google.inject.grapher.InterfaceNode<K>
Known Indirect Subclasses

Class Overview

Node for an interface class that has been bound to an implementation class or instance. These nodes are basically defined by a Key.

See Also

Summary

Nested Classes
interface InterfaceNode.Factory<K, T extends InterfaceNode<K>> Factory interface for InterfaceNodes. 
Public Methods
abstract void setKey(Key<?> key)
abstract void setSource(Object source)

Public Methods

public abstract void setKey (Key<?> key)

public abstract void setSource (Object source)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/InterfaceNode.Factory.html0000755000175000017500000004340111704661106031260 0ustar tonytony InterfaceNode.Factory | Guice
public static interface

InterfaceNode.Factory

com.google.inject.grapher.InterfaceNode.Factory<K, T extends com.google.inject.grapher.InterfaceNode<K>>
Known Indirect Subclasses

Class Overview

Factory interface for InterfaceNodes. Renderer implementations will need to provide an implementation for this.

Summary

Public Methods
abstract T newInterfaceNode(K nodeId)
Creates a new InterfaceNode and adds it to the graph.

Public Methods

public abstract T newInterfaceNode (K nodeId)

Creates a new InterfaceNode and adds it to the graph.

Parameters
nodeId ID for the node.
Returns
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/InjectorGrapher.html0000755000175000017500000007231511704661106030240 0ustar tonytony InjectorGrapher | Guice
public class

InjectorGrapher

extends Object
java.lang.Object
   ↳ com.google.inject.grapher.InjectorGrapher

Class Overview

Root class for graphing an Injector. Bound in GrapherModule.

Use of(Injector) to specify the Injector to use, and graph() to graph the Injector using the currently-bound Renderer.

By default, this will graph the entire Injector. Use rootedAt(Class) or rootedAt(Key) to specify an initial set of Classes or Keys to use, and this will graph their transitive bindings and dependencies.

Summary

Public Constructors
InjectorGrapher(BindingTargetVisitor<Object, Collection<Key<?>>> keyVisitor, BindingTargetVisitor<Object, Void> graphingVisitor, Renderer renderer)
Public Methods
void graph()
Renders a graph with the bound Renderer.
InjectorGrapher of(Injector injector)
Sets the Injector to graph.
InjectorGrapher rootedAt(Key...<?> keys)
Sets an initial group of Keys to use as the starting point for the graph.
InjectorGrapher rootedAt(Class...<?> classes)
Sets an initial group of Classes to use as the starting point for the graph.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public InjectorGrapher (BindingTargetVisitor<Object, Collection<Key<?>>> keyVisitor, BindingTargetVisitor<Object, Void> graphingVisitor, Renderer renderer)

Public Methods

public void graph ()

Renders a graph with the bound Renderer. The Injector must have already been specified with of(Injector).

Throws
IOException

public InjectorGrapher of (Injector injector)

Sets the Injector to graph.

public InjectorGrapher rootedAt (Key...<?> keys)

Sets an initial group of Keys to use as the starting point for the graph. The graph will be of these keys and their transitive dependencies and bindings.

public InjectorGrapher rootedAt (Class...<?> classes)

Sets an initial group of Classes to use as the starting point for the graph. The graph will be of these classes and their transitive dependencies and bindings.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/ImplementationNode.html0000755000175000017500000005406111704661106030743 0ustar tonytony ImplementationNode | Guice
public interface

ImplementationNode

com.google.inject.grapher.ImplementationNode<K>
Known Indirect Subclasses

Class Overview

Node for classes and instances that have Dependencys and are bound to InterfaceNodes. These nodes will often have fields for Members that are InjectionPoints.

See Also

Summary

Nested Classes
interface ImplementationNode.Factory<K, T extends ImplementationNode<K>> Factory interface for ImplementationNodes. 
Public Methods
abstract void addMember(Member member)
abstract void setClassKey(Key<?> key)
Sets the Key that this node is for.
abstract void setInstance(Object instance)
Sets the Object that's the already-created instance.
abstract void setSource(Object source)

Public Methods

public abstract void addMember (Member member)

public abstract void setClassKey (Key<?> key)

Sets the Key that this node is for. Used when the node is representing a class that Guice will instantiate.

public abstract void setInstance (Object instance)

Sets the Object that's the already-created instance. Used when this node is represeting the instance instead of a class.

public abstract void setSource (Object source)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/ImplementationNode.Factory.html0000755000175000017500000004357111704661106032355 0ustar tonytony ImplementationNode.Factory | Guice
public static interface

ImplementationNode.Factory

com.google.inject.grapher.ImplementationNode.Factory<K, T extends com.google.inject.grapher.ImplementationNode<K>>
Known Indirect Subclasses

Class Overview

Factory interface for ImplementationNodes. Renderer implementations will need to provide an implementation for this.

Summary

Public Methods
abstract T newImplementationNode(K nodeId)
Creates a new ImplementationNode and adds it to the graph.

Public Methods

public abstract T newImplementationNode (K nodeId)

Creates a new ImplementationNode and adds it to the graph.

Parameters
nodeId ID for the node.
Returns
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/GraphingVisitor.html0000755000175000017500000022300411704661106030262 0ustar tonytony GraphingVisitor | Guice
public class

GraphingVisitor

extends Object
implements BindingTargetVisitor<T, V>
java.lang.Object
   ↳ com.google.inject.grapher.GraphingVisitor<K, N extends com.google.inject.grapher.InterfaceNode<K>, M extends com.google.inject.grapher.ImplementationNode<K>, B extends com.google.inject.grapher.BindingEdge<K>, D extends com.google.inject.grapher.DependencyEdge<K>>

Class Overview

BindingTargetVisitor that adds nodes and edges to the graph based on the visited Binding.

This class is parameterized over the four graph element types (InterfaceNode, ImplementationNode, BindingEdge, and DependencyEdge) so that you can extend those interfaces and also extend this class, and the helper methods will all return your new types.

Summary

Public Constructors
GraphingVisitor(NodeIdFactory<K> idFactory, Factory<K, N> interfaceNodeFactory, Factory<K, M> implementationNodeFactory, Factory<K, B> bindingEdgeFactory, Factory<K, D> dependencyEdgeFactory, NodeAliasFactory<K> nodeAliasFactory)
Public Methods
Void visit(ConstructorBinding<?> binding)
Visitor for ConstructorBindings.
Void visit(ConvertedConstantBinding<?> binding)
Void visit(ExposedBinding<?> binding)
Currently not displayed on the graph.
Void visit(InstanceBinding<?> binding)
Visitor for InstanceBinding.
Void visit(LinkedKeyBinding<?> binding)
Visitor for LinkedKeyBinding.
Void visit(ProviderBinding<?> binding)
Visitor for ProviderBinding.
Void visit(ProviderInstanceBinding<?> binding)
Void visit(ProviderKeyBinding<?> binding)
Void visit(UntargettedBinding<?> binding)
Currently not displayed on the graph.
Protected Methods
final K getClassNodeId(Binding<?> binding)
Helper method to return the standard node ID for the Binding's Key.
final K getInstanceNodeId(Binding<?> binding)
Helper method to return the instance node ID for the Binding's Key.
B newBindingEdge(K nodeId, K toId, BindingEdge.Type type)
Creates a new BindingEdge from the given node to the specified node.
M newClassImplementationNode(Binding<?> binding, InjectionPoint constructorInjectionPoint, Collection<InjectionPoint> memberInjectionPoints)
Creates and returns a new ImplementationNode for the given Binding, where the Binding is for a class that Guice will instantiate, rather than a specific instance.
D newDependencyEdge(K nodeId, InjectionPoint injectionPoint, Dependency<?> dependency)
Creates a new DependencyEdge from the given node to a Dependency.
Collection<D> newDependencyEdges(K nodeId, M node, Collection<Dependency<?>> dependencies)
Adds DependencyEdges to the graph for each of the provided Dependencys.
M newInstanceImplementationNode(Binding<?> binding, Object instance)
Creates and returns a new ImplementationNode for the given Binding, where the Binding is for an instance, rather than a class.
N newInterfaceNode(Binding<?> binding)
Creates and returns a new InterfaceNode object for the given Binding.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.BindingTargetVisitor

Public Constructors

public GraphingVisitor (NodeIdFactory<K> idFactory, Factory<K, N> interfaceNodeFactory, Factory<K, M> implementationNodeFactory, Factory<K, B> bindingEdgeFactory, Factory<K, D> dependencyEdgeFactory, NodeAliasFactory<K> nodeAliasFactory)

Public Methods

public Void visit (ConstructorBinding<?> binding)

Visitor for ConstructorBindings. These are for classes that Guice will instantiate to satisfy injection requests. We create a new ImplementationNode for the class, then add edges to everything that it depends on to be instantiated.

public Void visit (ConvertedConstantBinding<?> binding)

Visitor for ConvertedConstantBinding. The Binding's Key will be of an annotated primitive type, and the value of getSourceKey() will be of a String with the same annotation.

We render this as an InterfaceNode that has a BindingEdge to the source Key. That will then be rendered by visit(InstanceBinding) as an InterfaceNode with a BindingEdge to the String instance.

public Void visit (ExposedBinding<?> binding)

Currently not displayed on the graph.

public Void visit (InstanceBinding<?> binding)

Visitor for InstanceBinding. We render two nodes in this case: a InterfaceNode for the binding's Key, and then an ImplementationNode for the instance Object itself. We run a binding node between them.

We then render any DependencyEdges that the instance may have, which come either from InjectionPoints (method and field) on the instance, or on Dependencys the instance declares through the HasDependencies interface.

public Void visit (LinkedKeyBinding<?> binding)

Visitor for LinkedKeyBinding. This is the standard Binding you get from binding an interface class to an implementation class. We create an InterfaceNode, then draw a BindingEdge to the node of the implementing class.

public Void visit (ProviderBinding<?> binding)

Visitor for ProviderBinding. These Bindings arise from an InjectionPoint for the Provider interface. Since this isn't tremendously interesting information, we don't render this binding on the graph, and instead let the DependencyEdge go straight from the InjectionPoint to the node specified by getProvidedKey().

public Void visit (UntargettedBinding<?> binding)

Currently not displayed on the graph.

Protected Methods

protected final K getClassNodeId (Binding<?> binding)

Helper method to return the standard node ID for the Binding's Key.

protected final K getInstanceNodeId (Binding<?> binding)

Helper method to return the instance node ID for the Binding's Key.

protected B newBindingEdge (K nodeId, K toId, BindingEdge.Type type)

Creates a new BindingEdge from the given node to the specified node.

Parameters
nodeId ID of the InterfaceNode that binds to the other.
toId The node ID of a class or instance that is bound.
type The BindingEdge.Type of this binding.
Returns

protected M newClassImplementationNode (Binding<?> binding, InjectionPoint constructorInjectionPoint, Collection<InjectionPoint> memberInjectionPoints)

Creates and returns a new ImplementationNode for the given Binding, where the Binding is for a class that Guice will instantiate, rather than a specific instance.

protected D newDependencyEdge (K nodeId, InjectionPoint injectionPoint, Dependency<?> dependency)

Creates a new DependencyEdge from the given node to a Dependency.

This method takes more comprehensive parameters than strictly necessary in case they would be useful to overriding implementations.

Parameters
nodeId ID of the ImplementationNode where the edges will start.
injectionPoint The InjectionPoint that gave rise to this Dependency, if one exists. Used to figure out which Member the edge should point from.
dependency The Dependency to represent with this edge.
Returns

protected Collection<D> newDependencyEdges (K nodeId, M node, Collection<Dependency<?>> dependencies)

Adds DependencyEdges to the graph for each of the provided Dependencys. These will be from the given node ID to the Dependency's Key.

If a Dependency has an associated InjectionPoint, its member will be added to the given ImplementationNode and the edge will start at the Member.

Parameters
nodeId ID of the node that should be the tail of the DependencyEdges.
node An ImplementationNode to add Members to.
dependencies Collection of Dependencys from the Binding.
Returns

protected M newInstanceImplementationNode (Binding<?> binding, Object instance)

Creates and returns a new ImplementationNode for the given Binding, where the Binding is for an instance, rather than a class.

protected N newInterfaceNode (Binding<?> binding)

Creates and returns a new InterfaceNode object for the given Binding.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/GrapherModule.html0000755000175000017500000011413711704661106027707 0ustar tonytony GrapherModule | Guice
public class

GrapherModule

extends AbstractModule
java.lang.Object
   ↳ com.google.inject.AbstractModule
     ↳ com.google.inject.grapher.GrapherModule

Class Overview

Module for the common bindings for InjectorGrapher. You will also need to bind a Module that satisfies the Renderer dependency.

If you want to use subtypes of the node and edge classes, or a different node ID type, you will need to override the GraphingVisitor binding to specify the new type parameters.

Summary

Public Constructors
GrapherModule()
Protected Methods
void configure()
Configures a Binder via the exposed methods.
[Expand]
Inherited Methods
From class com.google.inject.AbstractModule
From class java.lang.Object
From interface com.google.inject.Module

Public Constructors

public GrapherModule ()

Protected Methods

protected void configure ()

Configures a Binder via the exposed methods.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/DependencyEdge.html0000755000175000017500000004106511704661106030013 0ustar tonytony DependencyEdge | Guice
public interface

DependencyEdge

com.google.inject.grapher.DependencyEdge<K>
Known Indirect Subclasses

Class Overview

Interface for an edge from a class or InjectionPoint to the interface node that will satisfy the dependency.

Summary

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/DependencyEdge.Factory.html0000755000175000017500000004420411704661106031417 0ustar tonytony DependencyEdge.Factory | Guice
Nested Classes
interface DependencyEdge.Factory<K, T extends DependencyEdge<K>> Factory interface for DependencyEdges. 
public static interface

DependencyEdge.Factory

com.google.inject.grapher.DependencyEdge.Factory<K, T extends com.google.inject.grapher.DependencyEdge<K>>
Known Indirect Subclasses

Class Overview

Factory interface for DependencyEdges. Renderer implementations will need to provide an implementation for this.

Summary

Public Methods
abstract T newDependencyEdge(K fromId, InjectionPoint fromPoint, K toId)
Creates a new DependencyEdge and adds it to the graph.

Public Methods

public abstract T newDependencyEdge (K fromId, InjectionPoint fromPoint, K toId)

Creates a new DependencyEdge and adds it to the graph.

Parameters
fromId The ID for the class or instance node that has the dependency.
fromPoint The point where the dependency will be @Injected.
toId The ID for the interface node that satisfies the dependency.
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/BindingEdge.html0000755000175000017500000004446611704661106027317 0ustar tonytony BindingEdge | Guice
public interface

BindingEdge

com.google.inject.grapher.BindingEdge<K>
Known Indirect Subclasses

Class Overview

Interface for an edge that connects an interface to the type or instance that is bound to implement it.

Summary

Nested Classes
interface BindingEdge.Factory<K, T extends BindingEdge<K>> Factory interface for BindingEdges. 
enum BindingEdge.Type Classification for what kind of binding this edge represents. 
Public Methods
abstract void setType(BindingEdge.Type type)

Public Methods

public abstract void setType (BindingEdge.Type type)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/BindingEdge.Type.html0000755000175000017500000007432711704661106030236 0ustar tonytony BindingEdge.Type | Guice
public static final enum

BindingEdge.Type

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.grapher.BindingEdge.Type

Class Overview

Classification for what kind of binding this edge represents.

Summary

Enum Values
BindingEdge.Type  CONVERTED_CONSTANT  Binding is to the interface for a constant of a different type. 
BindingEdge.Type  NORMAL  Binding is to an instance or class of the binding's same type. 
BindingEdge.Type  PROVIDER  Binding is to an instance or class that provides the binding's type. 
Public Methods
static BindingEdge.Type valueOf(String name)
final static Type[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final BindingEdge.Type CONVERTED_CONSTANT

Since: API Level

Binding is to the interface for a constant of a different type.

public static final BindingEdge.Type NORMAL

Since: API Level

Binding is to an instance or class of the binding's same type.

public static final BindingEdge.Type PROVIDER

Since: API Level

Binding is to an instance or class that provides the binding's type.

Public Methods

public static BindingEdge.Type valueOf (String name)

public static final Type[] values ()

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/grapher/BindingEdge.Factory.html0000755000175000017500000004362211704661106030716 0ustar tonytony BindingEdge.Factory | Guice
public static interface

BindingEdge.Factory

com.google.inject.grapher.BindingEdge.Factory<K, T extends com.google.inject.grapher.BindingEdge<K>>
Known Indirect Subclasses

Class Overview

Factory interface for BindingEdges. Renderer implementations will need to provide an implementation for this.

Summary

Public Methods
abstract T newBindingEdge(K fromId, K toId)
Creates a new BindingEdge instance and adds it to the graph.

Public Methods

public abstract T newBindingEdge (K fromId, K toId)

Creates a new BindingEdge instance and adds it to the graph.

Parameters
fromId Node ID for the interface node.
toId Node ID for the implementation (class or instance) node.
Returns
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/binder/0000755000175000017500000000000011704661106024064 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/binder/package-summary.html0000755000175000017500000003132711704661106030051 0ustar tonytony com.google.inject.binder | Guice
package

com.google.inject.binder

Classes | Description

Interfaces which make up Binder's expression language.

more...

Interfaces

AnnotatedBindingBuilder<T> See the EDSL examples at Binder
AnnotatedConstantBindingBuilder See the EDSL examples at Binder
AnnotatedElementBuilder See the EDSL examples at Binder
ConstantBindingBuilder Binds to a constant value. 
LinkedBindingBuilder<T> See the EDSL examples at Binder
ScopedBindingBuilder See the EDSL examples at Binder
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/binder/package-descr.html0000755000175000017500000002451111704661106027451 0ustar tonytony com.google.inject.binder Details | Guice
package

com.google.inject.binder

Classes | Description

Interfaces which make up Binder's expression language.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/binder/ScopedBindingBuilder.html0000755000175000017500000004325311704661106031003 0ustar tonytony ScopedBindingBuilder | Guice
public interface

ScopedBindingBuilder

com.google.inject.binder.ScopedBindingBuilder
Known Indirect Subclasses

Class Overview

See the EDSL examples at Binder.

Summary

Public Methods
abstract void asEagerSingleton()
Instructs the Injector to eagerly initialize this singleton-scoped binding upon creation.
abstract void in(Scope scope)
See the EDSL examples at Binder.
abstract void in(Class<? extends Annotation> scopeAnnotation)
See the EDSL examples at Binder.

Public Methods

public abstract void asEagerSingleton ()

Instructs the Injector to eagerly initialize this singleton-scoped binding upon creation. Useful for application initialization logic. See the EDSL examples at Binder.

public abstract void in (Scope scope)

See the EDSL examples at Binder.

public abstract void in (Class<? extends Annotation> scopeAnnotation)

See the EDSL examples at Binder.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/binder/LinkedBindingBuilder.html0000755000175000017500000010263111704661106030770 0ustar tonytony LinkedBindingBuilder | Guice
public interface

LinkedBindingBuilder

implements ScopedBindingBuilder
com.google.inject.binder.LinkedBindingBuilder<T>
Known Indirect Subclasses

Class Overview

See the EDSL examples at Binder.

Summary

Public Methods
abstract ScopedBindingBuilder to(Key<? extends T> targetKey)
See the EDSL examples at Binder.
abstract ScopedBindingBuilder to(TypeLiteral<? extends T> implementation)
See the EDSL examples at Binder.
abstract ScopedBindingBuilder to(Class<? extends T> implementation)
See the EDSL examples at Binder.
abstract <S extends T> ScopedBindingBuilder toConstructor(Constructor<S> constructor)
See the EDSL examples at Binder.
abstract <S extends T> ScopedBindingBuilder toConstructor(Constructor<S> constructor, TypeLiteral<? extends S> type)
See the EDSL examples at Binder.
abstract void toInstance(T instance)
See the EDSL examples at Binder.
abstract ScopedBindingBuilder toProvider(Key<? extends Provider<? extends T>> providerKey)
See the EDSL examples at Binder.
abstract ScopedBindingBuilder toProvider(Provider<? extends T> provider)
See the EDSL examples at Binder.
abstract ScopedBindingBuilder toProvider(TypeLiteral<? extends Provider<? extends T>> providerType)
See the EDSL examples at Binder.
abstract ScopedBindingBuilder toProvider(Class<? extends Provider<? extends T>> providerType)
See the EDSL examples at Binder.
[Expand]
Inherited Methods
From interface com.google.inject.binder.ScopedBindingBuilder

Public Methods

public abstract ScopedBindingBuilder to (Key<? extends T> targetKey)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder to (TypeLiteral<? extends T> implementation)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder to (Class<? extends T> implementation)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder toConstructor (Constructor<S> constructor)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder toConstructor (Constructor<S> constructor, TypeLiteral<? extends S> type)

See the EDSL examples at Binder.

public abstract void toInstance (T instance)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder toProvider (Key<? extends Provider<? extends T>> providerKey)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder toProvider (Provider<? extends T> provider)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder toProvider (TypeLiteral<? extends Provider<? extends T>> providerType)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder toProvider (Class<? extends Provider<? extends T>> providerType)

See the EDSL examples at Binder.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/binder/ConstantBindingBuilder.html0000755000175000017500000005730611704661106031363 0ustar tonytony ConstantBindingBuilder | Guice
public interface

ConstantBindingBuilder

com.google.inject.binder.ConstantBindingBuilder

Class Overview

Binds to a constant value.

Summary

Public Methods
abstract <E extends Enum<E>> void to(E value)
Binds constant to the given value.
abstract void to(boolean value)
Binds constant to the given value.
abstract void to(byte value)
Binds constant to the given value.
abstract void to(char value)
Binds constant to the given value.
abstract void to(double value)
Binds constant to the given value.
abstract void to(float value)
Binds constant to the given value.
abstract void to(int value)
Binds constant to the given value.
abstract void to(Class<?> value)
Binds constant to the given value.
abstract void to(String value)
Binds constant to the given value.
abstract void to(long value)
Binds constant to the given value.
abstract void to(short value)
Binds constant to the given value.

Public Methods

public abstract void to (E value)

Binds constant to the given value.

public abstract void to (boolean value)

Binds constant to the given value.

public abstract void to (byte value)

Binds constant to the given value.

public abstract void to (char value)

Binds constant to the given value.

public abstract void to (double value)

Binds constant to the given value.

public abstract void to (float value)

Binds constant to the given value.

public abstract void to (int value)

Binds constant to the given value.

public abstract void to (Class<?> value)

Binds constant to the given value.

public abstract void to (String value)

Binds constant to the given value.

public abstract void to (long value)

Binds constant to the given value.

public abstract void to (short value)

Binds constant to the given value.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/binder/AnnotatedElementBuilder.html0000755000175000017500000003426511704661106031525 0ustar tonytony AnnotatedElementBuilder | Guice
public interface

AnnotatedElementBuilder

com.google.inject.binder.AnnotatedElementBuilder

Class Overview

See the EDSL examples at Binder.

Summary

Public Methods
abstract void annotatedWith(Class<? extends Annotation> annotationType)
See the EDSL examples at Binder.
abstract void annotatedWith(Annotation annotation)
See the EDSL examples at Binder.

Public Methods

public abstract void annotatedWith (Class<? extends Annotation> annotationType)

See the EDSL examples at Binder.

public abstract void annotatedWith (Annotation annotation)

See the EDSL examples at Binder.

././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/binder/AnnotatedConstantBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/binder/AnnotatedConstantBindingBuilder.0000755000175000017500000003514111704661106032325 0ustar tonytony AnnotatedConstantBindingBuilder | Guice
public interface

AnnotatedConstantBindingBuilder

com.google.inject.binder.AnnotatedConstantBindingBuilder

Class Overview

See the EDSL examples at Binder.

Summary

Public Methods
abstract ConstantBindingBuilder annotatedWith(Class<? extends Annotation> annotationType)
See the EDSL examples at Binder.
abstract ConstantBindingBuilder annotatedWith(Annotation annotation)
See the EDSL examples at Binder.

Public Methods

public abstract ConstantBindingBuilder annotatedWith (Class<? extends Annotation> annotationType)

See the EDSL examples at Binder.

public abstract ConstantBindingBuilder annotatedWith (Annotation annotation)

See the EDSL examples at Binder.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/binder/AnnotatedBindingBuilder.html0000755000175000017500000006530611704661106031506 0ustar tonytony AnnotatedBindingBuilder | Guice
public interface

AnnotatedBindingBuilder

implements LinkedBindingBuilder<T>
com.google.inject.binder.AnnotatedBindingBuilder<T>

Class Overview

See the EDSL examples at Binder.

Summary

Public Methods
abstract LinkedBindingBuilder<T> annotatedWith(Class<? extends Annotation> annotationType)
See the EDSL examples at Binder.
abstract LinkedBindingBuilder<T> annotatedWith(Annotation annotation)
See the EDSL examples at Binder.
[Expand]
Inherited Methods
From interface com.google.inject.binder.LinkedBindingBuilder
From interface com.google.inject.binder.ScopedBindingBuilder

Public Methods

public abstract LinkedBindingBuilder<T> annotatedWith (Class<? extends Annotation> annotationType)

See the EDSL examples at Binder.

public abstract LinkedBindingBuilder<T> annotatedWith (Annotation annotation)

See the EDSL examples at Binder.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/assistedinject/0000755000175000017500000000000011704661106025635 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/assistedinject/package-summary.html0000755000175000017500000003144311704661106031621 0ustar tonytony com.google.inject.assistedinject | Guice
package

com.google.inject.assistedinject

Classes | Description

Extension for combining factory interfaces with injection; this extension requires guice-assistedinject-3.0.jar.

more...

Interfaces

AssistedInjectBinding<T> A binding for a factory created by FactoryModuleBuilder. 
AssistedInjectTargetVisitor<T, V> A visitor for the AssistedInject extension. 
AssistedMethod Details about how a method in an assisted inject factory will be assisted. 

Classes

FactoryModuleBuilder Provides a factory that combines the caller's arguments with injector-supplied values to construct objects. 
FactoryProvider<F> This class is deprecated. use FactoryModuleBuilder instead.  
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/assistedinject/package-descr.html0000755000175000017500000002513511704661106031225 0ustar tonytony com.google.inject.assistedinject Details | Guice
package

com.google.inject.assistedinject

Classes | Description

Extension for combining factory interfaces with injection; this extension requires guice-assistedinject-3.0.jar.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/assistedinject/FactoryProvider.html0000755000175000017500000007543611704661106031667 0ustar tonytony FactoryProvider | Guice
public class

FactoryProvider

extends Object
implements Provider<T> HasDependencies
java.lang.Object
   ↳ com.google.inject.assistedinject.FactoryProvider<F>

This class is deprecated.
use FactoryModuleBuilder instead.

Class Overview

Obsolete. Prefer FactoryModuleBuilder for its more concise API and additional capability.

Provides a factory that combines the caller's arguments with injector-supplied values to construct objects.

Defining a factory

Create an interface whose methods return the constructed type, or any of its supertypes. The method's parameters are the arguments required to build the constructed type.
public interface PaymentFactory {
   Payment create(Date startDate, Money amount);
 }
You can name your factory methods whatever you like, such as create, createPayment or newPayment.

Creating a type that accepts factory parameters

constructedType is a concrete class with an @Inject-annotated constructor. In addition to injector-supplied parameters, the constructor should have parameters that match each of the factory method's parameters. Each factory-supplied parameter requires an @Assisted annotation. This serves to document that the parameter is not bound by your application's modules.
public class RealPayment implements Payment {
   @Inject
   public RealPayment(
      CreditService creditService,
      AuthService authService,
      @Assisted Date startDate,
      @Assisted Money amount) {
     ...
   }
 }
Any parameter that permits a null value should also be annotated @Nullable.

Configuring factories

In your module, bind the factory interface to the returned factory:
bind(PaymentFactory.class).toProvider(
     FactoryProvider.newFactory(PaymentFactory.class, RealPayment.class));
As a side-effect of this binding, Guice will inject the factory to initialize it for use. The factory cannot be used until the injector has been initialized.

Using the factory

Inject your factory into your application classes. When you use the factory, your arguments will be combined with values from the injector to construct an instance.
public class PaymentAction {
   @Inject private PaymentFactory paymentFactory;

   public void doPayment(Money amount) {
     Payment payment = paymentFactory.create(new Date(), amount);
     payment.apply();
   }
 }

Making parameter types distinct

The types of the factory method's parameters must be distinct. To use multiple parameters of the same type, use a named @Assisted annotation to disambiguate the parameters. The names must be applied to the factory method's parameters:
public interface PaymentFactory {
   Payment create(
       @Assisted("startDate") Date startDate,
       @Assisted("dueDate") Date dueDate,
       Money amount);
 } 
...and to the concrete type's constructor parameters:
public class RealPayment implements Payment {
   @Inject
   public RealPayment(
      CreditService creditService,
      AuthService authService,
      @Assisted("startDate") Date startDate,
      @Assisted("dueDate") Date dueDate,
      @Assisted Money amount) {
     ...
   }
 }

Values are created by Guice

Returned factories use child injectors to create values. The values are eligible for method interception. In addition, @Inject members will be injected before they are returned.

Backwards compatibility using @AssistedInject

Instead of the @Inject annotation, you may annotate the constructed classes with @AssistedInject. This triggers a limited backwards-compatability mode.

Instead of matching factory method arguments to constructor parameters using their names, the parameters are matched by their order. The first factory method argument is used for the first @Assisted constructor parameter, etc.. Annotation names have no effect.

Returned values are not created by Guice. These types are not eligible for method interception. They do receive post-construction member injection.

Summary

Public Methods
F get()
Provides an instance of T.
Set<Dependency<?>> getDependencies()
Returns the known dependencies for this type.
static <F> Provider<F> newFactory(TypeLiteral<F> factoryType, TypeLiteral<?> implementationType)
static <F> Provider<F> newFactory(Class<F> factoryType, Class<?> implementationType)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.Provider
From interface com.google.inject.spi.HasDependencies
From interface javax.inject.Provider

Public Methods

public F get ()

Provides an instance of T. Must never return null.

public Set<Dependency<?>> getDependencies ()

Returns the known dependencies for this type. If this has dependencies whose values are not known statically, a dependency for the Injector will be included in the returned set.

Returns
  • a possibly empty set

public static Provider<F> newFactory (TypeLiteral<F> factoryType, TypeLiteral<?> implementationType)

public static Provider<F> newFactory (Class<F> factoryType, Class<?> implementationType)

././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/assistedinject/FactoryModuleBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/assistedinject/FactoryModuleBuilder.htm0000755000175000017500000016233011704661106032443 0ustar tonytony FactoryModuleBuilder | Guice
public final class

FactoryModuleBuilder

extends Object
java.lang.Object
   ↳ com.google.inject.assistedinject.FactoryModuleBuilder

Class Overview

Provides a factory that combines the caller's arguments with injector-supplied values to construct objects.

Defining a factory

Create an interface whose methods return the constructed type, or any of its supertypes. The method's parameters are the arguments required to build the constructed type.
public interface PaymentFactory {
   Payment create(Date startDate, Money amount);
 }
You can name your factory methods whatever you like, such as create, createPayment or newPayment.

Creating a type that accepts factory parameters

constructedType is a concrete class with an @Inject-annotated constructor. In addition to injector-supplied parameters, the constructor should have parameters that match each of the factory method's parameters. Each factory-supplied parameter requires an @Assisted annotation. This serves to document that the parameter is not bound by your application's modules.
public class RealPayment implements Payment {
   @Inject
   public RealPayment(
      CreditService creditService,
      AuthService authService,
      @Assisted Date startDate,
      @Assisted Money amount) {
     ...
   }
 }

Multiple factory methods for the same type

If the factory contains many methods that return the same type, you can create multiple constructors in your concrete class, each constructor marked with with @AssistedInject, in order to match the different parameters types of the factory methods.
public interface PaymentFactory {
    Payment create(Date startDate, Money amount);
    Payment createWithoutDate(Money amount);
 }
 
 public class RealPayment implements Payment {
  @AssistedInject
   public RealPayment(
      CreditService creditService,
      AuthService authService,
     @Assisted Date startDate,
     @Assisted Money amount) {
     ...
   }
   
  @AssistedInject
   public RealPayment(
      CreditService creditService,
      AuthService authService,
     @Assisted Money amount) {
     ...
   }   
 }

Configuring simple factories

In your module, install a FactoryModuleBuilder that creates the factory:
install(new FactoryModuleBuilder()
     .implement(Payment.class, RealPayment.class)
     .build(PaymentFactory.class);
As a side-effect of this binding, Guice will inject the factory to initialize it for use. The factory cannot be used until the injector has been initialized.

Configuring complex factories

Factories can create an arbitrary number of objects, one per each method. Each factory method can be configured using .implement.
public interface OrderFactory {
    Payment create(Date startDate, Money amount);
    Shipment create(Customer customer, Item item);
    Receipt create(Payment payment, Shipment shipment);
 }
 
 [...]
 
 install(new FactoryModuleBuilder()
     .implement(Payment.class, RealPayment.class)
     // excluding .implement for Shipment means the implementation class
     // will be 'Shipment' itself, which is legal if it's not an interface.
     .implement(Receipt.class, RealReceipt.class)
     .build(OrderFactory.class);

Using the factory

Inject your factory into your application classes. When you use the factory, your arguments will be combined with values from the injector to construct an instance.
public class PaymentAction {
   @Inject private PaymentFactory paymentFactory;

   public void doPayment(Money amount) {
     Payment payment = paymentFactory.create(new Date(), amount);
     payment.apply();
   }
 }

Making parameter types distinct

The types of the factory method's parameters must be distinct. To use multiple parameters of the same type, use a named @Assisted annotation to disambiguate the parameters. The names must be applied to the factory method's parameters:
public interface PaymentFactory {
   Payment create(
       @Assisted("startDate") Date startDate,
       @Assisted("dueDate") Date dueDate,
       Money amount);
 } 
...and to the concrete type's constructor parameters:
public class RealPayment implements Payment {
   @Inject
   public RealPayment(
      CreditService creditService,
      AuthService authService,
      @Assisted("startDate") Date startDate,
      @Assisted("dueDate") Date dueDate,
      @Assisted Money amount) {
     ...
   }
 }

Values are created by Guice

Returned factories use child injectors to create values. The values are eligible for method interception. In addition, @Inject members will be injected before they are returned.

More configuration options

In addition to simply specifying an implementation class for any returned type, factories' return values can be automatic or can be configured to use annotations:

If you just want to return the types specified in the factory, do not configure any implementations:

public interface FruitFactory {
   Apple getApple(Color color);
 }
 ...
 protected void configure() {
   install(new FactoryModuleBuilder().build(FruitFactory.class));
 }
Note that any type returned by the factory in this manner needs to be an implementation class.

To return two different implementations for the same interface from your factory, use binding annotations on your return types:

interface CarFactory {
   @Named("fast") Car getFastCar(Color color);
   @Named("clean") Car getCleanCar(Color color);
 }
 ...
 protected void configure() {
   install(new FactoryModuleBuilder()
       .implement(Car.class, Names.named("fast"), Porsche.class)
       .implement(Car.class, Names.named("clean"), Prius.class)
       .build(CarFactory.class));
 }

Implementation limitations

As a limitation of the implementation, it is prohibited to declare a factory method that accepts a Provider as one of its arguments.

Summary

Public Constructors
FactoryModuleBuilder()
Public Methods
<F> Module build(Key<F> factoryInterface)
<F> Module build(TypeLiteral<F> factoryInterface)
See the factory configuration examples at FactoryModuleBuilder.
<F> Module build(Class<F> factoryInterface)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Key<T> source, TypeLiteral<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Key<T> source, Class<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(TypeLiteral<T> source, TypeLiteral<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(TypeLiteral<T> source, Class<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(TypeLiteral<T> source, Class<? extends Annotation> annotationType, TypeLiteral<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(TypeLiteral<T> source, Class<? extends Annotation> annotationType, Class<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(TypeLiteral<T> source, Annotation annotation, TypeLiteral<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(TypeLiteral<T> source, Annotation annotation, Class<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Class<T> source, TypeLiteral<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Class<T> source, Class<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Class<T> source, Class<? extends Annotation> annotationType, TypeLiteral<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Class<T> source, Class<? extends Annotation> annotationType, Class<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Class<T> source, Annotation annotation, TypeLiteral<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Class<T> source, Annotation annotation, Class<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public FactoryModuleBuilder ()

Public Methods

public Module build (Key<F> factoryInterface)

public Module build (TypeLiteral<F> factoryInterface)

See the factory configuration examples at FactoryModuleBuilder.

public Module build (Class<F> factoryInterface)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Key<T> source, TypeLiteral<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Key<T> source, Class<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (TypeLiteral<T> source, TypeLiteral<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (TypeLiteral<T> source, Class<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (TypeLiteral<T> source, Class<? extends Annotation> annotationType, TypeLiteral<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (TypeLiteral<T> source, Class<? extends Annotation> annotationType, Class<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (TypeLiteral<T> source, Annotation annotation, TypeLiteral<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (TypeLiteral<T> source, Annotation annotation, Class<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Class<T> source, TypeLiteral<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Class<T> source, Class<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Class<T> source, Class<? extends Annotation> annotationType, TypeLiteral<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Class<T> source, Class<? extends Annotation> annotationType, Class<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Class<T> source, Annotation annotation, TypeLiteral<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Class<T> source, Annotation annotation, Class<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/assistedinject/AssistedMethod.html0000755000175000017500000004157711704661106031464 0ustar tonytony AssistedMethod | Guice
public interface

AssistedMethod

com.google.inject.assistedinject.AssistedMethod

Class Overview

Details about how a method in an assisted inject factory will be assisted.

Summary

Public Methods
abstract Set<Dependency<?>> getDependencies()
Returns all non-assisted dependencies required to construct and inject the implementation.
abstract Method getFactoryMethod()
Returns the factory method that is being assisted.
abstract Constructor<?> getImplementationConstructor()
Returns the constructor that will be used to construct instances of the implementation.
abstract TypeLiteral<?> getImplementationType()
Returns the implementation type that will be created when the method is used.

Public Methods

public abstract Set<Dependency<?>> getDependencies ()

Returns all non-assisted dependencies required to construct and inject the implementation.

public abstract Method getFactoryMethod ()

Returns the factory method that is being assisted.

public abstract Constructor<?> getImplementationConstructor ()

Returns the constructor that will be used to construct instances of the implementation.

public abstract TypeLiteral<?> getImplementationType ()

Returns the implementation type that will be created when the method is used.

././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/assistedinject/AssistedInjectTargetVisitor.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/assistedinject/AssistedInjectTargetVisi0000755000175000017500000005264711704661106032517 0ustar tonytony AssistedInjectTargetVisitor | Guice
public interface

AssistedInjectTargetVisitor

implements BindingTargetVisitor<T, V>
com.google.inject.assistedinject.AssistedInjectTargetVisitor<T, V>

Class Overview

A visitor for the AssistedInject extension.

If your BindingTargetVisitor implements this interface, bindings created by using FactoryModuleBuilder will be visited through this interface.

Summary

Public Methods
abstract V visit(AssistedInjectBinding<? extends T> assistedInjectBinding)
Visits an AssistedInjectBinding created through FactoryModuleBuilder.
[Expand]
Inherited Methods
From interface com.google.inject.spi.BindingTargetVisitor

Public Methods

public abstract V visit (AssistedInjectBinding<? extends T> assistedInjectBinding)

Visits an AssistedInjectBinding created through FactoryModuleBuilder.

././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/assistedinject/AssistedInjectBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/assistedinject/AssistedInjectBinding.ht0000755000175000017500000003500611704661106032410 0ustar tonytony AssistedInjectBinding | Guice
public interface

AssistedInjectBinding

com.google.inject.assistedinject.AssistedInjectBinding<T>

Class Overview

A binding for a factory created by FactoryModuleBuilder.

Summary

Public Methods
abstract Collection<AssistedMethod> getAssistedMethods()
Returns an AssistedMethod for each method in the factory.
abstract Key<T> getKey()
Returns the Key for the factory binding.

Public Methods

public abstract Collection<AssistedMethod> getAssistedMethods ()

Returns an AssistedMethod for each method in the factory.

public abstract Key<T> getKey ()

Returns the Key for the factory binding.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/assistedinject/AssistedInject.html0000755000175000017500000003645711704661106031461 0ustar tonytony AssistedInject | Guice
public abstract @interface

AssistedInject

implements Annotation
com.google.inject.assistedinject.AssistedInject

Class Overview

When used in tandem with FactoryModuleBuilder, constructors annotated with @AssistedInject indicate that multiple constructors can be injected, each with different parameters. AssistedInject annotations should not be mixed with @Inject annotations. The assisted parameters must exactly match one corresponding factory method within the factory interface, but the parameters do not need to be in the same order. Constructors annotated with AssistedInject are created by Guice and receive all the benefits (such as AOP).

Obsolete Usage: When used in tandem with FactoryProvider, constructors annotated with @AssistedInject trigger a "backwards compatibility mode". The assisted parameters must exactly match one corresponding factory method within the factory interface and all must be in the same order as listed in the factory. In this backwards compatable mode, constructors annotated with AssistedInject are not created by Guice and thus receive none of the benefits.

Constructor parameters must be either supplied by the factory interface and marked with @Assisted, or they must be injectable.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/assistedinject/Assisted.html0000755000175000017500000003371111704661106030312 0ustar tonytony Assisted | Guice
public abstract @interface

Assisted

implements Annotation
com.google.inject.assistedinject.Assisted

Class Overview

Annotates an injected parameter or field whose value comes from an argument to a factory method.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/TypeLiteral.html0000755000175000017500000011236711704661106025762 0ustar tonytony TypeLiteral | Guice
public class

TypeLiteral

extends Object
java.lang.Object
   ↳ com.google.inject.TypeLiteral<T>

Class Overview

Represents a generic type T. Java doesn't yet provide a way to represent generic types, so this class does. Forces clients to create a subclass of this class which enables retrieval the type information even at runtime.

For example, to create a type literal for List<String>, you can create an empty anonymous inner class:

TypeLiteral<List<String>> list = new TypeLiteral<List<String>>() {;}

Along with modeling generic types, this class can resolve type parameters. For example, to figure out what type keySet() returns on a Map<Integer, String>, use this code:

   TypeLiteral<Map<Integer, String>> mapType
       = new TypeLiteral<Map<Integer, String>>() {;
   TypeLiteral keySetType
       = mapType.getReturnType(Map.class.getMethod("keySet"));
   System.out.println(keySetType); // prints "Set"}

Summary

Protected Constructors
TypeLiteral()
Constructs a new type literal.
Public Methods
final boolean equals(Object o)
static <T> TypeLiteral<T> get(Class<T> type)
Gets type literal for the given Class instance.
static TypeLiteral<?> get(Type type)
Gets type literal for the given Type instance.
List<TypeLiteral<?>> getExceptionTypes(Member methodOrConstructor)
Returns the resolved generic exception types thrown by constructor.
TypeLiteral<?> getFieldType(Field field)
Returns the resolved generic type of field.
List<TypeLiteral<?>> getParameterTypes(Member methodOrConstructor)
Returns the resolved generic parameter types of methodOrConstructor.
final Class<? super T> getRawType()
Returns the raw (non-generic) type for this type.
TypeLiteral<?> getReturnType(Method method)
Returns the resolved generic return type of method.
TypeLiteral<?> getSupertype(Class<?> supertype)
Returns the generic form of supertype.
final Type getType()
Gets underlying Type instance.
final int hashCode()
final String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Protected Constructors

protected TypeLiteral ()

Constructs a new type literal. Derives represented class from type parameter.

Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

Public Methods

public final boolean equals (Object o)

public static TypeLiteral<T> get (Class<T> type)

Gets type literal for the given Class instance.

public static TypeLiteral<?> get (Type type)

Gets type literal for the given Type instance.

public List<TypeLiteral<?>> getExceptionTypes (Member methodOrConstructor)

Returns the resolved generic exception types thrown by constructor.

Parameters
methodOrConstructor a method or constructor defined by this or any supertype.

public TypeLiteral<?> getFieldType (Field field)

Returns the resolved generic type of field.

Parameters
field a field defined by this or any superclass.

public List<TypeLiteral<?>> getParameterTypes (Member methodOrConstructor)

Returns the resolved generic parameter types of methodOrConstructor.

Parameters
methodOrConstructor a method or constructor defined by this or any supertype.

public final Class<? super T> getRawType ()

Returns the raw (non-generic) type for this type.

public TypeLiteral<?> getReturnType (Method method)

Returns the resolved generic return type of method.

Parameters
method a method defined by this or any supertype.

public TypeLiteral<?> getSupertype (Class<?> supertype)

Returns the generic form of supertype. For example, if this is ArrayList<String>, this returns Iterable<String> given the input Iterable.class.

Parameters
supertype a superclass of, or interface implemented by, this.

public final Type getType ()

Gets underlying Type instance.

public final int hashCode ()

public final String toString ()

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/Stage.html0000755000175000017500000007312211704661106024562 0ustar tonytony Stage | Guice
public final enum

Stage

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.Stage

Class Overview

The stage we're running in.

Summary

Enum Values
Stage  DEVELOPMENT  We want fast startup times at the expense of runtime performance and some up front error checking. 
Stage  PRODUCTION  We want to catch errors as early as possible and take performance hits up front. 
Stage  TOOL  We're running in a tool (an IDE plugin for example). 
Public Methods
static Stage valueOf(String name)
final static Stage[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final Stage DEVELOPMENT

Since: API Level

We want fast startup times at the expense of runtime performance and some up front error checking.

public static final Stage PRODUCTION

Since: API Level

We want to catch errors as early as possible and take performance hits up front.

public static final Stage TOOL

Since: API Level

We're running in a tool (an IDE plugin for example). We need binding meta data but not a functioning Injector. Do not inject members of instances. Do not load eager singletons. Do as little as possible so our tools run nice and snappy. Injectors created in this stage cannot be used to satisfy injections.

Public Methods

public static Stage valueOf (String name)

public static final Stage[] values ()

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/Singleton.html0000755000175000017500000004025111704661106025456 0ustar tonytony Singleton | Guice
public abstract @interface

Singleton

implements Annotation
com.google.inject.Singleton

Class Overview

Apply this to implementation classes when you want only one instance (per Injector) to be reused for all injections for that binding.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/Scopes.html0000755000175000017500000005575511704661106024767 0ustar tonytony Scopes | Guice
public class

Scopes

extends Object
java.lang.Object
   ↳ com.google.inject.Scopes

Class Overview

Built-in scope implementations.

Summary

Constants
Scope NO_SCOPE No scope; the same as not applying any scope at all.
Scope SINGLETON One instance per Injector.
Public Methods
static boolean isSingleton(Binding<?> binding)
Returns true if binding is singleton-scoped.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final Scope NO_SCOPE

No scope; the same as not applying any scope at all. Each time the Injector obtains an instance of an object with "no scope", it injects this instance then immediately forgets it. When the next request for the same binding arrives it will need to obtain the instance over again.

This exists only in case a class has been annotated with a scope annotation such as @Singleton, and you need to override this to "no scope" in your binding.

public static final Scope SINGLETON

One instance per Injector. Also see @Singleton.

Public Methods

public static boolean isSingleton (Binding<?> binding)

Returns true if binding is singleton-scoped. If the binding is a linked key binding and belongs to an injector (ie. it was retrieved via Injector.getBinding()), then this method will also true if the target binding is singleton-scoped.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/ScopeAnnotation.html0000755000175000017500000004056411704661106026627 0ustar tonytony ScopeAnnotation | Guice
public abstract @interface

ScopeAnnotation

implements Annotation
com.google.inject.ScopeAnnotation

Class Overview

Annotates annotations which are used for scoping. Only one such annotation may apply to a single implementation class. You must also annotate scope annotations with @Retention(RUNTIME). For example:

   @Retention(RUNTIME)
   @Target(TYPE, METHOD)
   @ScopeAnnotation
   public @interface SessionScoped {}
 

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/Scope.html0000755000175000017500000004404711704661106024574 0ustar tonytony Scope | Guice
public interface

Scope

com.google.inject.Scope

Class Overview

A scope is a level of visibility that instances provided by Guice may have. By default, an instance created by the Injector has no scope, meaning it has no state from the framework's perspective -- the Injector creates it, injects it once into the class that required it, and then immediately forgets it. Associating a scope with a particular binding allows the created instance to be "remembered" and possibly used again for other injections.

An example of a scope is SINGLETON.

Summary

Public Methods
abstract <T> Provider<T> scope(Key<T> key, Provider<T> unscoped)
Scopes a provider.
abstract String toString()
A short but useful description of this scope.

Public Methods

public abstract Provider<T> scope (Key<T> key, Provider<T> unscoped)

Scopes a provider. The returned provider returns objects from this scope. If an object does not exist in this scope, the provider can use the given unscoped provider to retrieve one.

Scope implementations are strongly encouraged to override toString() in the returned provider and include the backing provider's toString() output.

Parameters
key binding key
unscoped locates an instance when one doesn't already exist in this scope.
Returns
  • a new provider which only delegates to the given unscoped provider when an instance of the requested object doesn't already exist in this scope

public abstract String toString ()

A short but useful description of this scope. For comparison, the standard scopes that ship with guice use the descriptions "Scopes.SINGLETON", "ServletScopes.SESSION" and "ServletScopes.REQUEST".

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/ProvisionException.html0000755000175000017500000007375111704661106027376 0ustar tonytony ProvisionException | Guice
public final class

ProvisionException

extends RuntimeException
java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ java.lang.RuntimeException
         ↳ com.google.inject.ProvisionException

Class Overview

Indicates that there was a runtime failure while providing an instance.

Summary

Public Constructors
ProvisionException(Iterable<Message> messages)
Creates a ProvisionException containing messages.
ProvisionException(String message)
ProvisionException(String message, Throwable cause)
Public Methods
Collection<Message> getErrorMessages()
Returns messages for the errors that caused this exception.
String getMessage()
[Expand]
Inherited Methods
From class java.lang.Throwable
From class java.lang.Object

Public Constructors

public ProvisionException (Iterable<Message> messages)

Creates a ProvisionException containing messages.

public ProvisionException (String message)

public ProvisionException (String message, Throwable cause)

Public Methods

public Collection<Message> getErrorMessages ()

Returns messages for the errors that caused this exception.

public String getMessage ()

Since: API Level

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/Provides.html0000755000175000017500000004032511704661106025311 0ustar tonytony Provides | Guice
public abstract @interface

Provides

implements Annotation
com.google.inject.Provides

Class Overview

Annotates methods of a Module to create a provider method binding. The method's return type is bound to it's returned value. Guice will pass dependencies to the method as parameters.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/Provider.html0000755000175000017500000005121011704661106025303 0ustar tonytony Provider | Guice
public interface

Provider

implements Provider<T>
com.google.inject.Provider<T>
Known Indirect Subclasses

Class Overview

An object capable of providing instances of type T. Providers are used in numerous ways by Guice:

  • When the default means for obtaining instances (an injectable or parameterless constructor) is insufficient for a particular binding, the module can specify a custom Provider instead, to control exactly how Guice creates or obtains instances for the binding.
  • An implementation class may always choose to have a Provider<T> instance injected, rather than having a T injected directly. This may give you access to multiple instances, instances you wish to safely mutate and discard, instances which are out of scope (e.g. using a @RequestScoped object from within a @SessionScoped object), or instances that will be initialized lazily.
  • A custom Scope is implemented as a decorator of Provider<T>, which decides when to delegate to the backing provider and when to provide the instance some other way.
  • The Injector offers access to the Provider<T> it uses to fulfill requests for a given key, via the getProvider(Key) methods.

Summary

Public Methods
abstract T get()
Provides an instance of T.
[Expand]
Inherited Methods
From interface javax.inject.Provider

Public Methods

public abstract T get ()

Provides an instance of T. Must never return null.

Throws
OutOfScopeException when an attempt is made to access a scoped object while the scope in question is not currently active
ProvisionException if an instance cannot be provided. Such exceptions include messages and throwables to describe why provision failed.
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/ProvidedBy.html0000755000175000017500000004002411704661106025561 0ustar tonytony ProvidedBy | Guice
public abstract @interface

ProvidedBy

implements Annotation
com.google.inject.ProvidedBy

Class Overview

A pointer to the default provider type for a type.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/PrivateModule.html0000755000175000017500000020341611704661106026300 0ustar tonytony PrivateModule | Guice
public abstract class

PrivateModule

extends Object
implements Module
java.lang.Object
   ↳ com.google.inject.PrivateModule

Class Overview

A module whose configuration information is hidden from its environment by default. Only bindings that are explicitly exposed will be available to other modules and to the users of the injector. This module may expose the bindings it creates and the bindings of the modules it installs.

A private module can be nested within a regular module or within another private module using install(). Its bindings live in a new environment that inherits bindings, type converters, scopes, and interceptors from the surrounding ("parent") environment. When you nest multiple private modules, the result is a tree of environments where the injector's environment is the root.

Guice EDSL bindings can be exposed with expose(). @Provides bindings can be exposed with the @Exposed annotation:

 public class FooBarBazModule extends PrivateModule {
   protected void configure() {
     bind(Foo.class).to(RealFoo.class);
     expose(Foo.class);

     install(new TransactionalBarModule());
     expose(Bar.class).annotatedWith(Transactional.class);

     bind(SomeImplementationDetail.class);
     install(new MoreImplementationDetailsModule());
   }

   @Provides @Exposed
   public Baz provideBaz() {
     return new SuperBaz();
   }
 }
 

Private modules are implemented using parent injectors. When it can satisfy their dependencies, just-in-time bindings will be created in the root environment. Such bindings are shared among all environments in the tree.

The scope of a binding is constrained to its environment. A singleton bound in a private module will be unique to its environment. But a binding for the same type in a different private module will yield a different instance.

A shared binding that injects the Injector gets the root injector, which only has access to bindings in the root environment. An explicit binding that injects the Injector gets access to all bindings in the child environment.

To promote a just-in-time binding to an explicit binding, bind it:

   bind(FooImpl.class);
 

Summary

Public Constructors
PrivateModule()
Public Methods
synchronized final void configure(Binder binder)
Contributes bindings and other configurations for this module to binder.
Protected Methods
final void addError(Message message)
final void addError(String message, Object... arguments)
final void addError(Throwable t)
final <T> LinkedBindingBuilder<T> bind(Key<T> key)
final <T> AnnotatedBindingBuilder<T> bind(TypeLiteral<T> typeLiteral)
final <T> AnnotatedBindingBuilder<T> bind(Class<T> clazz)
final AnnotatedConstantBindingBuilder bindConstant()
final void bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)
void bindListener(Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)
final void bindScope(Class<? extends Annotation> scopeAnnotation, Scope scope)
final PrivateBinder binder()
Returns the current binder.
abstract void configure()
Creates bindings and other configurations private to this module.
final void convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)
final Stage currentStage()
final <T> void expose(Key<T> key)
Makes the binding for key available to other modules and the injector.
final AnnotatedElementBuilder expose(TypeLiteral<?> type)
Makes a binding for type available to other modules and the injector.
final AnnotatedElementBuilder expose(Class<?> type)
Makes a binding for type available to other modules and the injector.
<T> MembersInjector<T> getMembersInjector(TypeLiteral<T> type)
<T> MembersInjector<T> getMembersInjector(Class<T> type)
final <T> Provider<T> getProvider(Key<T> key)
final <T> Provider<T> getProvider(Class<T> type)
final void install(Module module)
final void requestInjection(Object instance)
final void requestStaticInjection(Class...<?> types)
final void requireBinding(Key<?> key)
Instructs Guice to require a binding to the given key.
final void requireBinding(Class<?> type)
Instructs Guice to require a binding to the given type.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.Module

Public Constructors

public PrivateModule ()

Public Methods

public final synchronized void configure (Binder binder)

Contributes bindings and other configurations for this module to binder.

Do not invoke this method directly to install submodules. Instead use install(Module), which ensures that provider methods are discovered.

Protected Methods

protected final void addError (Message message)

protected final void addError (String message, Object... arguments)

protected final void addError (Throwable t)

protected final LinkedBindingBuilder<T> bind (Key<T> key)

See Also

protected final AnnotatedBindingBuilder<T> bind (TypeLiteral<T> typeLiteral)

protected final AnnotatedBindingBuilder<T> bind (Class<T> clazz)

See Also

protected final AnnotatedConstantBindingBuilder bindConstant ()

See Also

protected final void bindInterceptor (Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)

protected void bindListener (Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)

protected final void bindScope (Class<? extends Annotation> scopeAnnotation, Scope scope)

protected final PrivateBinder binder ()

Returns the current binder.

protected abstract void configure ()

Creates bindings and other configurations private to this module. Use expose() to make the bindings in this module available externally.

protected final void convertToTypes (Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)

protected final Stage currentStage ()

See Also

protected final void expose (Key<T> key)

Makes the binding for key available to other modules and the injector.

protected final AnnotatedElementBuilder expose (TypeLiteral<?> type)

Makes a binding for type available to other modules and the injector. Use annotatedWith() to expose type with a binding annotation.

protected final AnnotatedElementBuilder expose (Class<?> type)

Makes a binding for type available to other modules and the injector. Use annotatedWith() to expose type with a binding annotation.

protected MembersInjector<T> getMembersInjector (TypeLiteral<T> type)

protected MembersInjector<T> getMembersInjector (Class<T> type)

protected final Provider<T> getProvider (Key<T> key)

See Also

protected final Provider<T> getProvider (Class<T> type)

protected final void install (Module module)

See Also

protected final void requestInjection (Object instance)

protected final void requestStaticInjection (Class...<?> types)

protected final void requireBinding (Key<?> key)

Instructs Guice to require a binding to the given key.

protected final void requireBinding (Class<?> type)

Instructs Guice to require a binding to the given type.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/PrivateBinder.html0000755000175000017500000012077611704661106026265 0ustar tonytony PrivateBinder | Guice
public interface

PrivateBinder

implements Binder
com.google.inject.PrivateBinder

Class Overview

Returns a binder whose configuration information is hidden from its environment by default. See PrivateModule for details.

Summary

Public Methods
abstract void expose(Key<?> key)
Makes the binding for key available to the enclosing environment
abstract AnnotatedElementBuilder expose(TypeLiteral<?> type)
Makes a binding for type available to the enclosing environment.
abstract AnnotatedElementBuilder expose(Class<?> type)
Makes a binding for type available to the enclosing environment.
abstract PrivateBinder skipSources(Class... classesToSkip)
Returns a binder that skips classesToSkip when identify the calling code.
abstract PrivateBinder withSource(Object source)
Returns a binder that uses source as the reference location for configuration errors.
[Expand]
Inherited Methods
From interface com.google.inject.Binder

Public Methods

public abstract void expose (Key<?> key)

Makes the binding for key available to the enclosing environment

public abstract AnnotatedElementBuilder expose (TypeLiteral<?> type)

Makes a binding for type available to the enclosing environment. Use annotatedWith() to expose type with a binding annotation.

public abstract AnnotatedElementBuilder expose (Class<?> type)

Makes a binding for type available to the enclosing environment. Use annotatedWith() to expose type with a binding annotation.

public abstract PrivateBinder skipSources (Class... classesToSkip)

Returns a binder that skips classesToSkip when identify the calling code. The caller's StackTraceElement is used to locate the source of configuration errors.

Parameters
classesToSkip library classes that create bindings on behalf of their clients.
Returns
  • a binder that shares its configuration with this binder.

public abstract PrivateBinder withSource (Object source)

Returns a binder that uses source as the reference location for configuration errors. This is typically a StackTraceElement for .java source but it could any binding source, such as the path to a .properties file.

Parameters
source any object representing the source location and has a concise toString() value
Returns
  • a binder that shares its configuration with this binder
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/OutOfScopeException.html0000755000175000017500000006640611704661106027433 0ustar tonytony OutOfScopeException | Guice
public final class

OutOfScopeException

extends RuntimeException
java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ java.lang.RuntimeException
         ↳ com.google.inject.OutOfScopeException

Class Overview

Thrown from get() when an attempt is made to access a scoped object while the scope in question is not currently active.

Summary

Public Constructors
OutOfScopeException(String message)
OutOfScopeException(String message, Throwable cause)
OutOfScopeException(Throwable cause)
[Expand]
Inherited Methods
From class java.lang.Throwable
From class java.lang.Object

Public Constructors

public OutOfScopeException (String message)

public OutOfScopeException (String message, Throwable cause)

public OutOfScopeException (Throwable cause)

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/Module.html0000755000175000017500000005073311704661106024747 0ustar tonytony Module | Guice
public interface

Module

com.google.inject.Module
Known Indirect Subclasses

Class Overview

A module contributes configuration information, typically interface bindings, which will be used to create an Injector. A Guice-based application is ultimately composed of little more than a set of Modules and some bootstrapping code.

Your Module classes can use a more streamlined syntax by extending AbstractModule rather than implementing this interface directly.

In addition to the bindings configured via configure(Binder), bindings will be created for all methods annotated with @Provides. Use scope and binding annotations on these methods to configure the bindings.

Summary

Public Methods
abstract void configure(Binder binder)
Contributes bindings and other configurations for this module to binder.

Public Methods

public abstract void configure (Binder binder)

Contributes bindings and other configurations for this module to binder.

Do not invoke this method directly to install submodules. Instead use install(Module), which ensures that provider methods are discovered.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/MembersInjector.html0000755000175000017500000003675311704661106026620 0ustar tonytony MembersInjector | Guice
public interface

MembersInjector

com.google.inject.MembersInjector<T>

Class Overview

Injects dependencies into the fields and methods on instances of type T. Ignores the presence or absence of an injectable constructor.

Summary

Public Methods
abstract void injectMembers(T instance)
Injects dependencies into the fields and methods of instance.

Public Methods

public abstract void injectMembers (T instance)

Injects dependencies into the fields and methods of instance. Ignores the presence or absence of an injectable constructor.

Whenever Guice creates an instance, it performs this injection automatically (after first performing constructor injection), so if you're able to let Guice create all your objects for you, you'll never need to use this method.

Parameters
instance to inject members on. May be null.
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/Key.html0000755000175000017500000014334711704661106024256 0ustar tonytony Key | Guice
public class

Key

extends Object
java.lang.Object
   ↳ com.google.inject.Key<T>

Class Overview

Binding key consisting of an injection type and an optional annotation. Matches the type and annotation at a point of injection.

For example, Key.get(Service.class, Transactional.class) will match:

   @Inject
   public void setService(@Transactional Service service) {
     ...
   }
 

Key supports generic types via subclassing just like TypeLiteral.

Keys do not differentiate between primitive types (int, char, etc.) and their correpsonding wrapper types (Integer, Character, etc.). Primitive types will be replaced with their wrapper types when keys are created.

Summary

Protected Constructors
Key()
Constructs a new key.
Key(Class<? extends Annotation> annotationType)
Constructs a new key.
Key(Annotation annotation)
Constructs a new key.
Public Methods
final boolean equals(Object o)
static <T> Key<T> get(TypeLiteral<T> typeLiteral)
Gets a key for an injection type.
static <T> Key<T> get(TypeLiteral<T> typeLiteral, Class<? extends Annotation> annotationType)
Gets a key for an injection type and an annotation type.
static <T> Key<T> get(TypeLiteral<T> typeLiteral, Annotation annotation)
Gets a key for an injection type and an annotation.
static <T> Key<T> get(Class<T> type)
Gets a key for an injection type.
static <T> Key<T> get(Class<T> type, Class<? extends Annotation> annotationType)
Gets a key for an injection type and an annotation type.
static <T> Key<T> get(Class<T> type, Annotation annotation)
Gets a key for an injection type and an annotation.
static Key<?> get(Type type)
Gets a key for an injection type.
static Key<?> get(Type type, Class<? extends Annotation> annotationType)
Gets a key for an injection type and an annotation type.
static Key<?> get(Type type, Annotation annotation)
Gets a key for an injection type and an annotation.
final Annotation getAnnotation()
Gets the annotation.
final Class<? extends Annotation> getAnnotationType()
Gets the annotation type.
final TypeLiteral<T> getTypeLiteral()
Gets the key type.
boolean hasAttributes()
Returns true if this key has annotation attributes.
final int hashCode()
<T> Key<T> ofType(TypeLiteral<T> type)
Returns a new key of the specified type with the same annotation as this key.
<T> Key<T> ofType(Class<T> type)
Returns a new key of the specified type with the same annotation as this key.
Key<?> ofType(Type type)
Returns a new key of the specified type with the same annotation as this key.
final String toString()
Key<T> withoutAttributes()
Returns this key without annotation attributes, i.e.
[Expand]
Inherited Methods
From class java.lang.Object

Protected Constructors

protected Key ()

Constructs a new key. Derives the type from this class's type parameter.

Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

Example usage for a binding of type Foo:

new Key<Foo>() {}.

protected Key (Class<? extends Annotation> annotationType)

Constructs a new key. Derives the type from this class's type parameter.

Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

Example usage for a binding of type Foo annotated with @Bar:

new Key<Foo>(Bar.class) {}.

protected Key (Annotation annotation)

Constructs a new key. Derives the type from this class's type parameter.

Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

Example usage for a binding of type Foo annotated with @Bar:

new Key<Foo>(new Bar()) {}.

Public Methods

public final boolean equals (Object o)

public static Key<T> get (TypeLiteral<T> typeLiteral)

Gets a key for an injection type.

public static Key<T> get (TypeLiteral<T> typeLiteral, Class<? extends Annotation> annotationType)

Gets a key for an injection type and an annotation type.

public static Key<T> get (TypeLiteral<T> typeLiteral, Annotation annotation)

Gets a key for an injection type and an annotation.

public static Key<T> get (Class<T> type)

Gets a key for an injection type.

public static Key<T> get (Class<T> type, Class<? extends Annotation> annotationType)

Gets a key for an injection type and an annotation type.

public static Key<T> get (Class<T> type, Annotation annotation)

Gets a key for an injection type and an annotation.

public static Key<?> get (Type type)

Gets a key for an injection type.

public static Key<?> get (Type type, Class<? extends Annotation> annotationType)

Gets a key for an injection type and an annotation type.

public static Key<?> get (Type type, Annotation annotation)

Gets a key for an injection type and an annotation.

public final Annotation getAnnotation ()

Gets the annotation.

public final Class<? extends Annotation> getAnnotationType ()

Gets the annotation type.

public final TypeLiteral<T> getTypeLiteral ()

Gets the key type.

public boolean hasAttributes ()

Returns true if this key has annotation attributes.

public final int hashCode ()

public Key<T> ofType (TypeLiteral<T> type)

Returns a new key of the specified type with the same annotation as this key.

public Key<T> ofType (Class<T> type)

Returns a new key of the specified type with the same annotation as this key.

public Key<?> ofType (Type type)

Returns a new key of the specified type with the same annotation as this key.

public final String toString ()

public Key<T> withoutAttributes ()

Returns this key without annotation attributes, i.e. with only the annotation type.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/Injector.html0000755000175000017500000014471511704661106025303 0ustar tonytony Injector | Guice
public interface

Injector

com.google.inject.Injector

Class Overview

Builds the graphs of objects that make up your application. The injector tracks the dependencies for each type and uses bindings to inject them. This is the core of Guice, although you rarely interact with it directly. This "behind-the-scenes" operation is what distinguishes dependency injection from its cousin, the service locator pattern.

Contains several default bindings:

  • This Injector instance itself
  • A Provider<T> for each binding of type T
  • The java.util.logging.Logger for the class being injected
  • The Stage in which the Injector was created
Injectors are created using the facade class Guice.

An injector can also inject the dependencies of already-constructed instances. This can be used to interoperate with objects created by other frameworks or services.

Injectors can be hierarchical. Child injectors inherit the configuration of their parent injectors, but the converse does not hold.

The injector's internal bindings are available for introspection. This enables tools and extensions to operate on an injector reflectively.

Summary

Public Methods
abstract Injector createChildInjector(Module... modules)
Returns a new injector that inherits all state from this injector.
abstract Injector createChildInjector(Iterable<? extends Module> modules)
Returns a new injector that inherits all state from this injector.
abstract <T> List<Binding<T>> findBindingsByType(TypeLiteral<T> type)
Returns all explicit bindings for type.
abstract Map<Key<?>, Binding<?>> getAllBindings()
Returns a snapshot of this injector's bindings, both explicit and just-in-time.
abstract <T> Binding<T> getBinding(Key<T> key)
Returns the binding for the given injection key.
abstract <T> Binding<T> getBinding(Class<T> type)
Returns the binding for the given type.
abstract Map<Key<?>, Binding<?>> getBindings()
Returns this injector's explicit bindings.
abstract <T> Binding<T> getExistingBinding(Key<T> key)
Returns the binding if it already exists, or null if does not exist.
abstract <T> T getInstance(Key<T> key)
Returns the appropriate instance for the given injection key; equivalent to getProvider(key).get().
abstract <T> T getInstance(Class<T> type)
Returns the appropriate instance for the given injection type; equivalent to getProvider(type).get().
abstract <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral)
Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
abstract <T> MembersInjector<T> getMembersInjector(Class<T> type)
Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
abstract Injector getParent()
Returns this injector's parent, or null if this is a top-level injector.
abstract <T> Provider<T> getProvider(Key<T> key)
Returns the provider used to obtain instances for the given injection key.
abstract <T> Provider<T> getProvider(Class<T> type)
Returns the provider used to obtain instances for the given type.
abstract Map<Class<? extends Annotation>, Scope> getScopeBindings()
Returns a map containing all scopes in the injector.
abstract Set<TypeConverterBinding> getTypeConverterBindings()
Returns a set containing all type converter bindings in the injector.
abstract void injectMembers(Object instance)
Injects dependencies into the fields and methods of instance.

Public Methods

public abstract Injector createChildInjector (Module... modules)

Returns a new injector that inherits all state from this injector. All bindings, scopes, interceptors and type converters are inherited -- they are visible to the child injector. Elements of the child injector are not visible to its parent.

Just-in-time bindings created for child injectors will be created in an ancestor injector whenever possible. This allows for scoped instances to be shared between injectors. Use explicit bindings to prevent bindings from being shared with the parent injector.

No key may be bound by both an injector and one of its ancestors. This includes just-in-time bindings. The lone exception is the key for Injector.class, which is bound by each injector to itself.

public abstract Injector createChildInjector (Iterable<? extends Module> modules)

Returns a new injector that inherits all state from this injector. All bindings, scopes, interceptors and type converters are inherited -- they are visible to the child injector. Elements of the child injector are not visible to its parent.

Just-in-time bindings created for child injectors will be created in an ancestor injector whenever possible. This allows for scoped instances to be shared between injectors. Use explicit bindings to prevent bindings from being shared with the parent injector. Optional injections in just-in-time bindings (created in the parent injector) may be silently ignored if the optional dependencies are from the child injector.

No key may be bound by both an injector and one of its ancestors. This includes just-in-time bindings. The lone exception is the key for Injector.class, which is bound by each injector to itself.

public abstract List<Binding<T>> findBindingsByType (TypeLiteral<T> type)

Returns all explicit bindings for type.

This method is part of the Guice SPI and is intended for use by tools and extensions.

public abstract Map<Key<?>, Binding<?>> getAllBindings ()

Returns a snapshot of this injector's bindings, both explicit and just-in-time. The returned map is immutable; it contains only the bindings that were present when getAllBindings() was invoked. Subsequent calls may return a map with additional just-in-time bindings.

The returned map does not include bindings inherited from a parent injector, should one exist.

This method is part of the Guice SPI and is intended for use by tools and extensions.

public abstract Binding<T> getBinding (Key<T> key)

Returns the binding for the given injection key. This will be an explicit bindings if the key was bound explicitly by a module, or an implicit binding otherwise. The implicit binding will be created if necessary.

This method is part of the Guice SPI and is intended for use by tools and extensions.

Throws
ConfigurationException if this injector cannot find or create the binding.

public abstract Binding<T> getBinding (Class<T> type)

Returns the binding for the given type. This will be an explicit bindings if the injection key was bound explicitly by a module, or an implicit binding otherwise. The implicit binding will be created if necessary.

This method is part of the Guice SPI and is intended for use by tools and extensions.

Throws
ConfigurationException if this injector cannot find or create the binding.

public abstract Map<Key<?>, Binding<?>> getBindings ()

Returns this injector's explicit bindings.

The returned map does not include bindings inherited from a parent injector, should one exist. The returned map is guaranteed to iterate (for example, with its entrySet() iterator) in the order of insertion. In other words, the order in which bindings appear in user Modules.

This method is part of the Guice SPI and is intended for use by tools and extensions.

public abstract Binding<T> getExistingBinding (Key<T> key)

Returns the binding if it already exists, or null if does not exist. Unlike getBinding(Key), this does not attempt to create just-in-time bindings for keys that aren't bound.

This method is part of the Guice SPI and is intended for use by tools and extensions.

public abstract T getInstance (Key<T> key)

Returns the appropriate instance for the given injection key; equivalent to getProvider(key).get(). When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time.

Throws
ConfigurationException if this injector cannot find or create the provider.
ProvisionException if there was a runtime failure while providing an instance.

public abstract T getInstance (Class<T> type)

Returns the appropriate instance for the given injection type; equivalent to getProvider(type).get(). When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time.

Throws
ConfigurationException if this injector cannot find or create the provider.
ProvisionException if there was a runtime failure while providing an instance.

public abstract MembersInjector<T> getMembersInjector (TypeLiteral<T> typeLiteral)

Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.

Parameters
typeLiteral type to get members injector for

public abstract MembersInjector<T> getMembersInjector (Class<T> type)

Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. When feasible, use getMembersInjector(TypeLiteral) instead to get increased up front error detection.

Parameters
type type to get members injector for

public abstract Injector getParent ()

Returns this injector's parent, or null if this is a top-level injector.

public abstract Provider<T> getProvider (Key<T> key)

Returns the provider used to obtain instances for the given injection key. When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time.

Throws
ConfigurationException if this injector cannot find or create the provider.

public abstract Provider<T> getProvider (Class<T> type)

Returns the provider used to obtain instances for the given type. When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time.

Throws
ConfigurationException if this injector cannot find or create the provider.

public abstract Map<Class<? extends Annotation>, Scope> getScopeBindings ()

Returns a map containing all scopes in the injector. The maps keys are scoping annotations like Singleton.class, and the values are scope instances, such as Scopes.SINGLETON. The returned map is immutable.

This method is part of the Guice SPI and is intended for use by tools and extensions.

public abstract Set<TypeConverterBinding> getTypeConverterBindings ()

Returns a set containing all type converter bindings in the injector. The returned set is immutable.

This method is part of the Guice SPI and is intended for use by tools and extensions.

public abstract void injectMembers (Object instance)

Injects dependencies into the fields and methods of instance. Ignores the presence or absence of an injectable constructor.

Whenever Guice creates an instance, it performs this injection automatically (after first performing constructor injection), so if you're able to let Guice create all your objects for you, you'll never need to use this method.

Parameters
instance to inject members on
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/Inject.html0000755000175000017500000004263211704661106024735 0ustar tonytony Inject | Guice
public abstract @interface

Inject

implements Annotation
com.google.inject.Inject

Class Overview

Annotates members of your implementation class (constructors, methods and fields) into which the Injector should inject values. The Injector fulfills injection requests for:

  • Every instance it constructs. The class being constructed must have exactly one of its constructors marked with @Inject or must have a constructor taking no parameters. The Injector then proceeds to perform method and field injections.
  • Pre-constructed instances passed to injectMembers(Object), toInstance(Object) and toProvider(Provider). In this case all constructors are, of course, ignored.
  • Static fields and methods of classes which any Module has specifically requested static injection for, using requestStaticInjection(Class...).
In all cases, a member can be injected regardless of its Java access specifier (private, default, protected, public).

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/ImplementedBy.html0000755000175000017500000004003511704661106026252 0ustar tonytony ImplementedBy | Guice
public abstract @interface

ImplementedBy

implements Annotation
com.google.inject.ImplementedBy

Class Overview

A pointer to the default implementation of a type.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/Guice.html0000755000175000017500000006634011704661106024557 0ustar tonytony Guice | Guice
public final class

Guice

extends Object
java.lang.Object
   ↳ com.google.inject.Guice

Class Overview

The entry point to the Guice framework. Creates Injectors from Modules.

Guice supports a model of development that draws clear boundaries between APIs, Implementations of these APIs, Modules which configure these implementations, and finally Applications which consist of a collection of Modules. It is the Application, which typically defines your main() method, that bootstraps the Guice Injector using the Guice class, as in this example:

     public class FooApplication {
       public static void main(String[] args) {
         Injector injector = Guice.createInjector(
             new ModuleA(),
             new ModuleB(),
             . . .
             new FooApplicationFlagsModule(args)
         );

         // Now just bootstrap the application and you're done
         FooStarter starter = injector.getInstance(FooStarter.class);
         starter.runApplication();
       }
     }
 

Summary

Public Methods
static Injector createInjector(Module... modules)
Creates an injector for the given set of modules.
static Injector createInjector(Stage stage, Module... modules)
Creates an injector for the given set of modules, in a given development stage.
static Injector createInjector(Stage stage, Iterable<? extends Module> modules)
Creates an injector for the given set of modules, in a given development stage.
static Injector createInjector(Iterable<? extends Module> modules)
Creates an injector for the given set of modules.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Injector createInjector (Module... modules)

Creates an injector for the given set of modules.

Throws
CreationException if one or more errors occur during injector construction

public static Injector createInjector (Stage stage, Module... modules)

Creates an injector for the given set of modules, in a given development stage.

Throws
CreationException if one or more errors occur during injector creation.

public static Injector createInjector (Stage stage, Iterable<? extends Module> modules)

Creates an injector for the given set of modules, in a given development stage.

Throws
CreationException if one or more errors occur during injector construction

public static Injector createInjector (Iterable<? extends Module> modules)

Creates an injector for the given set of modules.

Throws
CreationException if one or more errors occur during injector creation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/Exposed.html0000755000175000017500000004021611704661106025124 0ustar tonytony Exposed | Guice
public abstract @interface

Exposed

implements Annotation
com.google.inject.Exposed

Class Overview

Acccompanies a @Provides method annotation in a private module to indicate that the provided binding is exposed.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/CreationException.html0000755000175000017500000006765011704661106027153 0ustar tonytony CreationException | Guice
public class

CreationException

extends RuntimeException
java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ java.lang.RuntimeException
         ↳ com.google.inject.CreationException

Class Overview

Thrown when errors occur while creating a Injector. Includes a list of encountered errors. Clients should catch this exception, log it, and stop execution.

Summary

Public Constructors
CreationException(Collection<Message> messages)
Creates a CreationException containing messages.
Public Methods
Collection<Message> getErrorMessages()
Returns messages for the errors that caused this exception.
String getMessage()
[Expand]
Inherited Methods
From class java.lang.Throwable
From class java.lang.Object

Public Constructors

public CreationException (Collection<Message> messages)

Creates a CreationException containing messages.

Public Methods

public Collection<Message> getErrorMessages ()

Returns messages for the errors that caused this exception.

public String getMessage ()

Since: API Level

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/ConfigurationException.html0000755000175000017500000007560511704661106030215 0ustar tonytony ConfigurationException | Guice
public final class

ConfigurationException

extends RuntimeException
java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ java.lang.RuntimeException
         ↳ com.google.inject.ConfigurationException

Class Overview

Thrown when a programming error such as a misplaced annotation, illegal binding, or unsupported scope is found. Clients should catch this exception, log it, and stop execution.

Summary

Public Constructors
ConfigurationException(Iterable<Message> messages)
Creates a ConfigurationException containing messages.
Public Methods
Collection<Message> getErrorMessages()
Returns messages for the errors that caused this exception.
String getMessage()
<E> E getPartialValue()
Returns a value that was only partially computed due to this exception.
ConfigurationException withPartialValue(Object partialValue)
Returns a copy of this configuration exception with the specified partial value.
[Expand]
Inherited Methods
From class java.lang.Throwable
From class java.lang.Object

Public Constructors

public ConfigurationException (Iterable<Message> messages)

Creates a ConfigurationException containing messages.

Public Methods

public Collection<Message> getErrorMessages ()

Returns messages for the errors that caused this exception.

public String getMessage ()

Since: API Level

public E getPartialValue ()

Returns a value that was only partially computed due to this exception. The caller can use this while collecting additional configuration problems.

Returns
  • the partial value, or null if none was set. The type of the partial value is specified by the throwing method.

public ConfigurationException withPartialValue (Object partialValue)

Returns a copy of this configuration exception with the specified partial value.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/BindingAnnotation.html0000755000175000017500000004061011704661106027120 0ustar tonytony BindingAnnotation | Guice
public abstract @interface

BindingAnnotation

implements Annotation
com.google.inject.BindingAnnotation

Class Overview

Annotates annotations which are used for binding. Only one such annotation may apply to a single injection point. You must also annotate binder annotations with @Retention(RUNTIME). For example:

   @Retention(RUNTIME)
   @Target({ FIELD, PARAMETER, METHOD })
   @BindingAnnotation
   public @interface Transactional {}
 

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/Binding.html0000755000175000017500000007403311704661106025073 0ustar tonytony Binding | Guice
public interface

Binding

implements Element
com.google.inject.Binding<T>
Known Indirect Subclasses

Class Overview

A mapping from a key (type and optional annotation) to the strategy for getting instances of the type. This interface is part of the introspection API and is intended primarily for use by tools.

Bindings are created in several ways:

  • Explicitly in a module, via bind() and bindConstant() statements:
         bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);
         bindConstant().annotatedWith(ServerHost.class).to(args[0]);
  • Implicitly by the Injector by following a type's pointer annotations or by using its annotated or default constructor.
  • By converting a bound instance to a different type.
  • For providers, by delegating to the binding for the provided type.

They exist on both modules and on injectors, and their behaviour is different for each:

  • Module bindings are incomplete and cannot be used to provide instances. This is because the applicable scopes and interceptors may not be known until an injector is created. From a tool's perspective, module bindings are like the injector's source code. They can be inspected or rewritten, but this analysis must be done statically.
  • Injector bindings are complete and valid and can be used to provide instances. From a tools' perspective, injector bindings are like reflection for an injector. They have full runtime information, including the complete graph of injections necessary to satisfy a binding.

Summary

Public Methods
abstract <V> V acceptScopingVisitor(BindingScopingVisitor<V> visitor)
Accepts a scoping visitor.
abstract <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> visitor)
Accepts a target visitor.
abstract Key<T> getKey()
Returns the key for this binding.
abstract Provider<T> getProvider()
Returns the scoped provider guice uses to fulfill requests for this binding.
[Expand]
Inherited Methods
From interface com.google.inject.spi.Element

Public Methods

public abstract V acceptScopingVisitor (BindingScopingVisitor<V> visitor)

Accepts a scoping visitor. Invokes the visitor method specific to this binding's scoping.

Parameters
visitor to call back on

public abstract V acceptTargetVisitor (BindingTargetVisitor<? super T, V> visitor)

Accepts a target visitor. Invokes the visitor method specific to this binding's target.

Parameters
visitor to call back on

public abstract Key<T> getKey ()

Returns the key for this binding.

public abstract Provider<T> getProvider ()

Returns the scoped provider guice uses to fulfill requests for this binding.

Throws
UnsupportedOperationException when invoked on a Binding created via getElements(Module...). This method is only supported on Bindings returned from an injector.
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/Binder.html0000755000175000017500000021376211704661106024730 0ustar tonytony Binder | Guice
public interface

Binder

com.google.inject.Binder
Known Indirect Subclasses

Class Overview

Collects configuration information (primarily bindings) which will be used to create an Injector. Guice provides this object to your application's Module implementors so they may each contribute their own bindings and other registrations.

The Guice Binding EDSL

Guice uses an embedded domain-specific language, or EDSL, to help you create bindings simply and readably. This approach is great for overall usability, but it does come with a small cost: it is difficult to learn how to use the Binding EDSL by reading method-level javadocs. Instead, you should consult the series of examples below. To save space, these examples omit the opening binder, just as you will if your module extends AbstractModule.
     bind(ServiceImpl.class);
This statement does essentially nothing; it "binds the ServiceImpl class to itself" and does not change Guice's default behavior. You may still want to use this if you prefer your Module class to serve as an explicit manifest for the services it provides. Also, in rare cases, Guice may be unable to validate a binding at injector creation time unless it is given explicitly.
     bind(Service.class).to(ServiceImpl.class);
Specifies that a request for a Service instance with no binding annotations should be treated as if it were a request for a ServiceImpl instance. This overrides the function of any @ImplementedBy or @ProvidedBy annotations found on Service, since Guice will have already "moved on" to ServiceImpl before it reaches the point when it starts looking for these annotations.
     bind(Service.class).toProvider(ServiceProvider.class);
In this example, ServiceProvider must extend or implement Provider<Service>. This binding specifies that Guice should resolve an unannotated injection request for Service by first resolving an instance of ServiceProvider in the regular way, then calling get() on the resulting Provider instance to obtain the Service instance.

The Provider you use here does not have to be a "factory"; that is, a provider which always creates each instance it provides. However, this is generally a good practice to follow. You can then use Guice's concept of scopes to guide when creation should happen -- "letting Guice work for you".

     bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);
Like the previous example, but only applies to injection requests that use the binding annotation @Red. If your module also includes bindings for particular values of the @Red annotation (see below), then this binding will serve as a "catch-all" for any values of @Red that have no exact match in the bindings.
     bind(ServiceImpl.class).in(Singleton.class);
     // or, alternatively
     bind(ServiceImpl.class).in(Scopes.SINGLETON);
Either of these statements places the ServiceImpl class into singleton scope. Guice will create only one instance of ServiceImpl and will reuse it for all injection requests of this type. Note that it is still possible to bind another instance of ServiceImpl if the second binding is qualified by an annotation as in the previous example. Guice is not overly concerned with preventing you from creating multiple instances of your "singletons", only with enabling your application to share only one instance if that's all you tell Guice you need.

Note: a scope specified in this way overrides any scope that was specified with an annotation on the ServiceImpl class.

Besides Singleton/SINGLETON, there are servlet-specific scopes available in com.google.inject.servlet.ServletScopes, and your Modules can contribute their own custom scopes for use here as well.

     bind(new TypeLiteral<PaymentService<CreditCard>>() {})
         .to(CreditCardPaymentService.class);
This admittedly odd construct is the way to bind a parameterized type. It tells Guice how to honor an injection request for an element of type PaymentService<CreditCard>. The class CreditCardPaymentService must implement the PaymentService<CreditCard> interface. Guice cannot currently bind or inject a generic type, such as Set<E>; all type parameters must be fully specified.
     bind(Service.class).toInstance(new ServiceImpl());
     // or, alternatively
     bind(Service.class).toInstance(SomeLegacyRegistry.getService());
In this example, your module itself, not Guice, takes responsibility for obtaining a ServiceImpl instance, then asks Guice to always use this single instance to fulfill all Service injection requests. When the Injector is created, it will automatically perform field and method injection for this instance, but any injectable constructor on ServiceImpl is simply ignored. Note that using this approach results in "eager loading" behavior that you can't control.
     bindConstant().annotatedWith(ServerHost.class).to(args[0]);
Sets up a constant binding. Constant injections must always be annotated. When a constant binding's value is a string, it is eligile for conversion to all primitive types, to all enums, and to class literals. Conversions for other types can be configured using convertToTypes().
   @Color("red") Color red; // A member variable (field)
    . . .
     red = MyModule.class.getDeclaredField("red").getAnnotation(Color.class);
     bind(Service.class).annotatedWith(red).to(RedService.class);
If your binding annotation has parameters you can apply different bindings to different specific values of your annotation. Getting your hands on the right instance of the annotation is a bit of a pain -- one approach, shown above, is to apply a prototype annotation to a field in your module class, so that you can read this annotation instance and give it to Guice.
     bind(Service.class)
         .annotatedWith(Names.named("blue"))
         .to(BlueService.class);
Differentiating by names is a common enough use case that we provided a standard annotation, @Named. Because of Guice's library support, binding by name is quite easier than in the arbitrary binding annotation case we just saw. However, remember that these names will live in a single flat namespace with all the other names used in your application.
     Constructor loneCtor = getLoneCtorFromServiceImplViaReflection();
     bind(ServiceImpl.class)
         .toConstructor(loneCtor);
In this example, we directly tell Guice which constructor to use in a concrete class implementation. It means that we do not need to place @Inject on any of the constructors and that Guice treats the provided constructor as though it were annotated so. It is useful for cases where you cannot modify existing classes and is a bit simpler than using a Provider.

The above list of examples is far from exhaustive. If you can think of how the concepts of one example might coexist with the concepts from another, you can most likely weave the two together. If the two concepts make no sense with each other, you most likely won't be able to do it. In a few cases Guice will let something bogus slip by, and will then inform you of the problems at runtime, as soon as you try to create your Injector.

The other methods of Binder such as bindScope(Class, Scope), bindInterceptor(Matcher>, Matcher, MethodInterceptor...), install(Module), requestStaticInjection(Class...), addError(String, Object...) and currentStage() are not part of the Binding EDSL; you can learn how to use these in the usual way, from the method documentation.

Summary

Public Methods
abstract void addError(Message message)
Records an error message to be presented to the user at a later time.
abstract void addError(String message, Object... arguments)
Records an error message which will be presented to the user at a later time.
abstract void addError(Throwable t)
Records an exception, the full details of which will be logged, and the message of which will be presented to the user at a later time.
abstract <T> LinkedBindingBuilder<T> bind(Key<T> key)
See the EDSL examples at Binder.
abstract <T> AnnotatedBindingBuilder<T> bind(TypeLiteral<T> typeLiteral)
See the EDSL examples at Binder.
abstract <T> AnnotatedBindingBuilder<T> bind(Class<T> type)
See the EDSL examples at Binder.
abstract AnnotatedConstantBindingBuilder bindConstant()
See the EDSL examples at Binder.
abstract void bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)
Binds method interceptor[s] to methods matched by class and method matchers.
abstract void bindListener(Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)
Registers a listener for injectable types.
abstract void bindScope(Class<? extends Annotation> annotationType, Scope scope)
Binds a scope to an annotation.
abstract void convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)
Binds a type converter.
abstract Stage currentStage()
Gets the current stage.
abstract void disableCircularProxies()
Prevents Guice from constructing a Proxy when a circular dependency is found.
abstract <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral)
Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
abstract <T> MembersInjector<T> getMembersInjector(Class<T> type)
Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
abstract <T> Provider<T> getProvider(Key<T> key)
Returns the provider used to obtain instances for the given injection key.
abstract <T> Provider<T> getProvider(Class<T> type)
Returns the provider used to obtain instances for the given injection type.
abstract void install(Module module)
Uses the given module to configure more bindings.
abstract PrivateBinder newPrivateBinder()
Creates a new private child environment for bindings and other configuration.
abstract <T> void requestInjection(TypeLiteral<T> type, T instance)
Upon successful creation, the Injector will inject instance fields and methods of the given object.
abstract void requestInjection(Object instance)
Upon successful creation, the Injector will inject instance fields and methods of the given object.
abstract void requestStaticInjection(Class...<?> types)
Upon successful creation, the Injector will inject static fields and methods in the given classes.
abstract void requireExplicitBindings()
Instructs the Injector that bindings must be listed in a Module in order to be injected.
abstract Binder skipSources(Class... classesToSkip)
Returns a binder that skips classesToSkip when identify the calling code.
abstract Binder withSource(Object source)
Returns a binder that uses source as the reference location for configuration errors.

Public Methods

public abstract void addError (Message message)

Records an error message to be presented to the user at a later time.

public abstract void addError (String message, Object... arguments)

Records an error message which will be presented to the user at a later time. Unlike throwing an exception, this enable us to continue configuring the Injector and discover more errors. Uses format(String, Object[]) to insert the arguments into the message.

public abstract void addError (Throwable t)

Records an exception, the full details of which will be logged, and the message of which will be presented to the user at a later time. If your Module calls something that you worry may fail, you should catch the exception and pass it into this.

public abstract LinkedBindingBuilder<T> bind (Key<T> key)

See the EDSL examples at Binder.

public abstract AnnotatedBindingBuilder<T> bind (TypeLiteral<T> typeLiteral)

See the EDSL examples at Binder.

public abstract AnnotatedBindingBuilder<T> bind (Class<T> type)

See the EDSL examples at Binder.

public abstract AnnotatedConstantBindingBuilder bindConstant ()

See the EDSL examples at Binder.

public abstract void bindInterceptor (Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)

Binds method interceptor[s] to methods matched by class and method matchers. A method is eligible for interception if:

  • Guice created the instance the method is on
  • Neither the enclosing type nor the method is final
  • And the method is package-private, protected, or public

Parameters
classMatcher matches classes the interceptor should apply to. For example: only(Runnable.class).
methodMatcher matches methods the interceptor should apply to. For example: annotatedWith(Transactional.class).
interceptors to bind

public abstract void bindListener (Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)

Registers a listener for injectable types. Guice will notify the listener when it encounters injectable types matched by the given type matcher.

Parameters
typeMatcher that matches injectable types the listener should be notified of
listener for injectable types matched by typeMatcher

public abstract void bindScope (Class<? extends Annotation> annotationType, Scope scope)

Binds a scope to an annotation.

public abstract void convertToTypes (Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)

Binds a type converter. The injector will use the given converter to convert string constants to matching types as needed.

Parameters
typeMatcher matches types the converter can handle
converter converts values

public abstract Stage currentStage ()

Gets the current stage.

public abstract void disableCircularProxies ()

Prevents Guice from constructing a Proxy when a circular dependency is found. By default, circular proxies are not disabled.

If a parent injector disables circular proxies, then all child injectors (and private modules within that injector) also disable circular proxies. If a parent does not disable circular proxies, a child injector or private module may optionally declare itself as disabling circular proxies. If it does, the behavior is limited only to that child or any grandchildren. No siblings of the child will disable circular proxies.

public abstract MembersInjector<T> getMembersInjector (TypeLiteral<T> typeLiteral)

Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. The returned members injector will not be valid until the main Injector has been created. The members injector will throw an IllegalStateException if you try to use it beforehand.

Parameters
typeLiteral type to get members injector for

public abstract MembersInjector<T> getMembersInjector (Class<T> type)

Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. The returned members injector will not be valid until the main Injector has been created. The members injector will throw an IllegalStateException if you try to use it beforehand.

Parameters
type type to get members injector for

public abstract Provider<T> getProvider (Key<T> key)

Returns the provider used to obtain instances for the given injection key. The returned provider will not be valid until the Injector has been created. The provider will throw an IllegalStateException if you try to use it beforehand.

public abstract Provider<T> getProvider (Class<T> type)

Returns the provider used to obtain instances for the given injection type. The returned provider will not be valid until the Injector has been created. The provider will throw an IllegalStateException if you try to use it beforehand.

public abstract void install (Module module)

Uses the given module to configure more bindings.

public abstract PrivateBinder newPrivateBinder ()

Creates a new private child environment for bindings and other configuration. The returned binder can be used to add and configuration information in this environment. See PrivateModule for details.

Returns
  • a binder that inherits configuration from this binder. Only exposed configuration on the returned binder will be visible to this binder.

public abstract void requestInjection (TypeLiteral<T> type, T instance)

Upon successful creation, the Injector will inject instance fields and methods of the given object.

Parameters
type of instance
instance for which members will be injected

public abstract void requestInjection (Object instance)

Upon successful creation, the Injector will inject instance fields and methods of the given object.

Parameters
instance for which members will be injected

public abstract void requestStaticInjection (Class...<?> types)

Upon successful creation, the Injector will inject static fields and methods in the given classes.

Parameters
types for which static members will be injected

public abstract void requireExplicitBindings ()

Instructs the Injector that bindings must be listed in a Module in order to be injected. Classes that are not explicitly bound in a module cannot be injected. Bindings created through a linked binding ( bind(Foo.class).to(FooImpl.class)) are allowed, but the implicit binding (FooImpl) cannot be directly injected unless it is also explicitly bound (bind(FooImpl.class)).

Tools can still retrieve bindings for implicit bindings (bindings created through a linked binding) if explicit bindings are required, however getProvider() will fail.

By default, explicit bindings are not required.

If a parent injector requires explicit bindings, then all child injectors (and private modules within that injector) also require explicit bindings. If a parent does not require explicit bindings, a child injector or private module may optionally declare itself as requiring explicit bindings. If it does, the behavior is limited only to that child or any grandchildren. No siblings of the child will require explicit bindings.

If the parent did not require explicit bindings but the child does, it is possible that a linked binding in the child may add a JIT binding to the parent. The child will not be allowed to reference the target binding directly, but the parent and other children of the parent may be able to.

public abstract Binder skipSources (Class... classesToSkip)

Returns a binder that skips classesToSkip when identify the calling code. The caller's StackTraceElement is used to locate the source of configuration errors.

Parameters
classesToSkip library classes that create bindings on behalf of their clients.
Returns
  • a binder that shares its configuration with this binder.

public abstract Binder withSource (Object source)

Returns a binder that uses source as the reference location for configuration errors. This is typically a StackTraceElement for .java source but it could any binding source, such as the path to a .properties file.

Parameters
source any object representing the source location and has a concise toString() value
Returns
  • a binder that shares its configuration with this binder
sisu-guice-sisu-guice-3.1.1/latest-javadoc/com/google/inject/AbstractModule.html0000755000175000017500000017663411704661106026444 0ustar tonytony AbstractModule | Guice
public abstract class

AbstractModule

extends Object
implements Module
java.lang.Object
   ↳ com.google.inject.AbstractModule
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

A support class for Modules which reduces repetition and results in a more readable configuration. Simply extend this class, implement configure(), and call the inherited methods which mirror those found in Binder. For example:

 public class MyModule extends AbstractModule {
   protected void configure() {
     bind(Service.class).to(ServiceImpl.class).in(Singleton.class);
     bind(CreditCardPaymentService.class);
     bind(PaymentService.class).to(CreditCardPaymentService.class);
     bindConstant().annotatedWith(Names.named("port")).to(8080);
   }
 }
 

Summary

Public Constructors
AbstractModule()
Public Methods
synchronized final void configure(Binder builder)
Contributes bindings and other configurations for this module to binder.
Protected Methods
void addError(Message message)
void addError(String message, Object... arguments)
void addError(Throwable t)
<T> LinkedBindingBuilder<T> bind(Key<T> key)
<T> AnnotatedBindingBuilder<T> bind(TypeLiteral<T> typeLiteral)
<T> AnnotatedBindingBuilder<T> bind(Class<T> clazz)
AnnotatedConstantBindingBuilder bindConstant()
void bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)
void bindListener(Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)
void bindScope(Class<? extends Annotation> scopeAnnotation, Scope scope)
Binder binder()
Gets direct access to the underlying Binder.
abstract void configure()
Configures a Binder via the exposed methods.
void convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)
Stage currentStage()
<T> MembersInjector<T> getMembersInjector(TypeLiteral<T> type)
<T> MembersInjector<T> getMembersInjector(Class<T> type)
<T> Provider<T> getProvider(Key<T> key)
<T> Provider<T> getProvider(Class<T> type)
void install(Module module)
void requestInjection(Object instance)
void requestStaticInjection(Class...<?> types)
void requireBinding(Key<?> key)
Adds a dependency from this module to key.
void requireBinding(Class<?> type)
Adds a dependency from this module to type.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.Module

Public Constructors

public AbstractModule ()

Public Methods

public final synchronized void configure (Binder builder)

Contributes bindings and other configurations for this module to binder.

Do not invoke this method directly to install submodules. Instead use install(Module), which ensures that provider methods are discovered.

Protected Methods

protected void addError (Message message)

protected void addError (String message, Object... arguments)

protected void addError (Throwable t)

protected LinkedBindingBuilder<T> bind (Key<T> key)

See Also

protected AnnotatedBindingBuilder<T> bind (TypeLiteral<T> typeLiteral)

protected AnnotatedBindingBuilder<T> bind (Class<T> clazz)

See Also

protected AnnotatedConstantBindingBuilder bindConstant ()

See Also

protected void bindInterceptor (Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)

protected void bindListener (Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)

protected void bindScope (Class<? extends Annotation> scopeAnnotation, Scope scope)

protected Binder binder ()

Gets direct access to the underlying Binder.

protected abstract void configure ()

Configures a Binder via the exposed methods.

protected void convertToTypes (Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)

protected Stage currentStage ()

See Also

protected MembersInjector<T> getMembersInjector (TypeLiteral<T> type)

protected MembersInjector<T> getMembersInjector (Class<T> type)

protected Provider<T> getProvider (Key<T> key)

See Also

protected Provider<T> getProvider (Class<T> type)

protected void install (Module module)

See Also

protected void requestInjection (Object instance)

protected void requestStaticInjection (Class...<?> types)

protected void requireBinding (Key<?> key)

Adds a dependency from this module to key. When the injector is created, Guice will report an error if key cannot be injected. Note that this requirement may be satisfied by implicit binding, such as a public no-arguments constructor.

protected void requireBinding (Class<?> type)

Adds a dependency from this module to type. When the injector is created, Guice will report an error if type cannot be injected. Note that this requirement may be satisfied by implicit binding, such as a public no-arguments constructor.

sisu-guice-sisu-guice-3.1.1/latest-javadoc/classes.html0000755000175000017500000021117411704661106021647 0ustar tonytony Class Index | Guice

Class Index

A B C D E F G H I J K L M N O P R S T U

A

AbstractMatcher<T> Implements and() and or()
AbstractModule A support class for Modules which reduces repetition and results in a more readable configuration. 
AnnotatedBindingBuilder<T> See the EDSL examples at Binder
AnnotatedConstantBindingBuilder See the EDSL examples at Binder
AnnotatedElementBuilder See the EDSL examples at Binder
ArrowType Arrow symbols that are available from Graphviz. 
Assisted Annotates an injected parameter or field whose value comes from an argument to a factory method. 
AssistedInject

When used in tandem with FactoryModuleBuilder, constructors annotated with @AssistedInject indicate that multiple constructors can be injected, each with different parameters. 

AssistedInjectBinding<T> A binding for a factory created by FactoryModuleBuilder. 
AssistedInjectTargetVisitor<T, V> A visitor for the AssistedInject extension. 
AssistedMethod Details about how a method in an assisted inject factory will be assisted. 

B

Binder Collects configuration information (primarily bindings) which will be used to create an Injector
Binding<T> A mapping from a key (type and optional annotation) to the strategy for getting instances of the type. 
BindingAnnotation Annotates annotations which are used for binding. 
BindingEdge<K> Interface for an edge that connects an interface to the type or instance that is bound to implement it. 
BindingEdge.Factory<K, T extends BindingEdge<K>> Factory interface for BindingEdges. 
BindingEdge.Type Classification for what kind of binding this edge represents. 
BindingEdgeFactory Graphviz-specific implementation of BindingEdge.Factory
BindingEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts BindingEdge methods to display operations on a GraphvizEdge
BindingScopingVisitor<V> Visits each of the strategies used to scope an injection. 
BindingTargetVisitor<T, V> Visits each of the strategies used to find an instance to satisfy an injection. 

C

CheckedProvider<T> Alternative to the Guice Provider that throws a checked Exception. 
CheckedProvides Annotates methods of a Module to create a CheckedProvider method binding that can throw exceptions. 
CompassPoint Enum for the "compass point" values used to control where edge end points appear on the graph. 
ConfigurationException Thrown when a programming error such as a misplaced annotation, illegal binding, or unsupported scope is found. 
ConstantBindingBuilder Binds to a constant value. 
ConstructorBinding<T> A binding to the constructor of a concrete clss. 
ConvertedConstantBinding<T> A binding created from converting a bound instance to a new type. 
CreationException Thrown when errors occur while creating a Injector

D

DefaultBindingScopingVisitor<V> No-op visitor for subclassing. 
DefaultBindingTargetVisitor<T, V> No-op visitor for subclassing. 
DefaultElementVisitor<V> No-op visitor for subclassing. 
Dependency<T> A variable that can be resolved by an injector. 
DependencyEdge<K> Interface for an edge from a class or InjectionPoint to the interface node that will satisfy the dependency. 
DependencyEdge.Factory<K, T extends DependencyEdge<K>> Factory interface for DependencyEdges. 
DependencyEdgeFactory Graphviz-specific implementation of DependencyEdge.Factory
DependencyEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts DependencyEdge methods to display operations on a GraphvizEdge
DisableCircularProxiesOption A request to disable circular proxies. 
DynamicFinder Utility that helps you introspect dynamic finder methods. 

E

EdgeStyle Styles for edges. 
Element A core component of a module or injector. 
Elements Exposes elements of a module so they can be inspected, validated or rewritten
ElementVisitor<V> Visit elements. 
Exposed Acccompanies a @Provides method annotation in a private module to indicate that the provided binding is exposed. 
ExposedBinding<T> A binding to a key exposed from an enclosed private environment. 

F

FactoryModuleBuilder Provides a factory that combines the caller's arguments with injector-supplied values to construct objects. 
FactoryProvider<F> This class is deprecated. use FactoryModuleBuilder instead.  
Finder Marks a method stub as a dynamic finder. 
FirstResult Annotate any dynamic finder method's integer argument with this to pass in the index of the first result in the result set you are interested in. 

G

GrapherModule Module for the common bindings for InjectorGrapher
GraphingVisitor<K, N extends InterfaceNode<K>, M extends ImplementationNode<K>, B extends BindingEdge<K>, D extends DependencyEdge<K>> BindingTargetVisitor that adds nodes and edges to the graph based on the visited Binding
GraphvizEdge Data object to encapsulate the attributes of Graphviz edges that we're interested in drawing. 
GraphvizModule Module that provides GraphvizRenderer as the Renderer and binds the other Graphviz factories. 
GraphvizNode Data object to encapsulate the attributes of Graphviz nodes that we're interested in drawing. 
GraphvizRenderer Renderer implementation that writes out a Graphviz DOT file of the graph. 
Guice The entry point to the Guice framework. 
GuiceFilter

Apply this filter in web.xml above all other filters (typically), to all requests where you plan to use servlet scopes. 

GuiceServletContextListener As of Guice 2.0 you can still use (your subclasses of) GuiceServletContextListener class as a logical place to create and configure your injector. 

H

HasDependencies Implemented by bindings, providers and instances that expose their dependencies explicitly. 

I

ImplementationNode<K> Node for classes and instances that have Dependencys and are bound to InterfaceNodes. 
ImplementationNode.Factory<K, T extends ImplementationNode<K>> Factory interface for ImplementationNodes. 
ImplementationNodeFactory Graphviz-specific implementation of ImplementationNode.Factory
ImplementationNodeFactory.GraphvizNodeAdaptor Adaptor class that converts ImplementationNode methods to display operations on a GraphvizNode
ImplementedBy A pointer to the default implementation of a type. 
Inject Annotates members of your implementation class (constructors, methods and fields) into which the Injector should inject values. 
InjectionListener<I> Listens for injections into instances of type I
InjectionPoint A constructor, field or method that can receive injections. 
InjectionRequest<T> A request to inject the instance fields and methods of an instance. 
Injector Builds the graphs of objects that make up your application. 
InjectorGrapher Root class for graphing an Injector
InstanceBinding<T> A binding to a single instance. 
InstanceFilterBinding A binding to a single instance of a filter. 
InstanceServletBinding A binding to a single instance of a servlet. 
InterceptorBinding Registration of interceptors for matching methods of matching classes. 
InterfaceNode<K> Node for an interface class that has been bound to an implementation class or instance. 
InterfaceNode.Factory<K, T extends InterfaceNode<K>> Factory interface for InterfaceNodes. 
InterfaceNodeFactory Graphviz-specific implementation of InterfaceNode.Factory
InterfaceNodeFactory.GraphvizNodeAdaptor Adaptor class that converts InterfaceNode methods to display operations on a GraphvizNode

J

JndiIntegration Integrates Guice with JNDI. 
JpaPersistModule JPA provider for guice persist. 

K

Key<T> Binding key consisting of an injection type and an optional annotation. 

L

LinkedBindingBuilder<T> See the EDSL examples at Binder
LinkedFilterBinding A linked binding to a filter. 
LinkedKeyBinding<T> A binding to a linked key. 
LinkedServletBinding A linked binding to a servlet. 

M

ManagedBindingMBean JMX interface to bindings. 
Manager Provides a JMX interface to Guice. 
MapBinder<K, V> An API to bind multiple map entries separately, only to later inject them as a complete map. 
MapBinderBinding<T> A binding for a MapBinder. 
Matcher<T> Returns true or false for a given input. 
Matchers Matcher implementations. 
MaxResults Annotate any dynamic finder method's integer argument with this to pass in the maximum size of returned result window. 
MembersInjector<T> Injects dependencies into the fields and methods on instances of type T
MembersInjectorLookup<T> A lookup of the members injector for a type. 
Message An error message and the context in which it occured. 
Module A module contributes configuration information, typically interface bindings, which will be used to create an Injector
Modules Static utility methods for creating and working with instances of Module
Modules.OverriddenModuleBuilder See the EDSL example at override()
Multibinder<T> An API to bind multiple values separately, only to later inject them as a complete collection. 
MultibinderBinding<T> A binding for a Multibinder. 
MultibindingsTargetVisitor<T, V> A visitor for the multibinder extension. 

N

Named Annotates named things. 
NameFactory Interface for a service that provides nice Strings that we can display in the graph for the types that come up in Bindings. 
Names Utility methods for use with @Named
NodeAliasFactory<K> Factory for aliasing one node ID to another. 
NodeIdFactory<K> Factory for abstract identifiers for elements on the graph. 
NodeShape Enum for the shapes that are most interesting for Guice graphing. 
NodeStyle Styles for nodes. 

O

OutOfScopeException Thrown from get() when an attempt is made to access a scoped object while the scope in question is not currently active. 

P

PersistFilter Apply this filter to enable the HTTP Request unit of work and to have guice-persist manage the lifecycle of active units of work. 
PersistModule Install this module to add guice-persist library support for JPA persistence providers. 
PersistService Persistence provider service. 
PortIdFactory Interface for a service that returns Graphviz port IDs, used for naming the rows in ImplementationNode-displaying GraphvizNodes. 
PortIdFactoryImpl Implementation of PortIdFactory
PrivateBinder Returns a binder whose configuration information is hidden from its environment by default. 
PrivateElements A private collection of elements that are hidden from the enclosing injector or module by default. 
PrivateModule A module whose configuration information is hidden from its environment by default. 
ProvidedBy A pointer to the default provider type for a type. 
Provider<T> An object capable of providing instances of type T
ProviderBinding<T extends Provider<?>> A binding to a Provider that delegates to the binding for the provided type. 
ProviderInstanceBinding<T> A binding to a provider instance. 
ProviderKeyBinding<T> A binding to a provider key. 
ProviderLookup<T> A lookup of the provider for a type. 
Providers Static utility methods for creating and working with instances of Provider
ProviderWithDependencies<T> A provider with dependencies on other injected types. 
ProviderWithExtensionVisitor<T> A Provider that is part of an extension which supports a custom BindingTargetVisitor. 
Provides Annotates methods of a Module to create a provider method binding. 
ProvisionException Indicates that there was a runtime failure while providing an instance. 

R

Renderer Interface for the service that renders the graph. 
RequestParameters Apply this to field or parameters of type Map<String, String[]> when you want the HTTP request parameter map to be injected. 
RequestScoped Apply this to implementation classes when you want one instance per request. 
RequireExplicitBindingsOption A request to require explicit bindings. 

S

Scope A scope is a level of visibility that instances provided by Guice may have. 
ScopeAnnotation Annotates annotations which are used for scoping. 
ScopeBinding Registration of a scope annotation with the scope that implements it. 
ScopedBindingBuilder See the EDSL examples at Binder
Scopes Built-in scope implementations. 
ServletModule Configures the servlet scopes and creates bindings for the servlet API objects so you can inject the request, response, session, etc. 
ServletModule.FilterKeyBindingBuilder See the EDSL examples at configureServlets() 
ServletModule.ServletKeyBindingBuilder See the EDSL examples at configureServlets() 
ServletModuleBinding A binding created by ServletModule
ServletModuleTargetVisitor<T, V> A visitor for the servlet extension. 
ServletScopes Servlet scopes. 
SessionScoped Apply this to implementation classes when you want one instance per session. 
ShortNameFactory Reasonable implementation for NameFactory
Singleton Apply this to implementation classes when you want only one instance (per Injector) to be reused for all injections for that binding. 
SpringIntegration Integrates Guice with Spring. 
Stage The stage we're running in. 
StaticInjectionRequest A request to inject the static fields and methods of a type. 
StringNodeIdFactory IdFactory implementation that for String node IDs. 

T

ThrowingProvider<T, E extends Exception> This interface is deprecated. use CheckedProvider instead.  
ThrowingProviderBinder

Builds a binding for a CheckedProvider

ThrowingProviderBinder.SecondaryBinder<P extends CheckedProvider>  
Toolable Instructs an Injector running in TOOL that a method should be injected. 
Transactional

Any method or class marked with this annotation will be considered for transactionality. 

TransitiveDependencyVisitor BindingTargetVisitor that returns a Collection of the Keys of each Binding's dependencies. 
TypeConverter Converts constant string values to a different type. 
TypeConverterBinding Registration of type converters for matching target types. 
TypeEncounter<I> Context of an injectable type encounter. 
TypeListener Listens for Guice to encounter injectable types. 
TypeListenerBinding Binds types (picked using a Matcher) to an type listener. 
TypeLiteral<T> Represents a generic type T
Types Static methods for working with types. 

U

UnitOfWork This interface is used to gain manual control over the unit of work. 
UntargettedBinding<T> An untargetted binding. 
UriPatternType An enumeration of the available URI-pattern matching styles 
sisu-guice-sisu-guice-3.1.1/latest-javadoc/assets/0000755000175000017500000000000011704661106020615 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-javadoc/assets/triangle-none.gif0000755000175000017500000000036011704661106024050 0ustar tonytony‰PNG  IHDR  HЦДtEXtSoftwareAdobe ImageReadyqЩe<PLTEхцъЋГжeuГэюёЬWhЎџџџџџџИ6хуtRNSџџџџџџџоƒНYZIDATxкb`gg`g VV€b`ea VV66 @ ЌlllЌ €˜XY™€Т@ 0R0&F#X!D 3˜С d12ƒ#+LЁ†1hЌgIENDЎB`‚sisu-guice-sisu-guice-3.1.1/latest-javadoc/assets/style.css0000755000175000017500000001320411704661106022472 0ustar tonytony.jd-toptitle { padding-left: 6px; margin-bottom: 30px; font-size: 160%; font-weight: bold; } div#jd-content table { border: none; } div#jd-content td, div#jd-content th { font-size: small; } div#jd-content table.jd-linktable { margin-top: 3px; border-spacing: 0; } div#jd-content p.jd-deprecated-warning { margin-top: 0; margin-bottom: 10px; } div#jd-content table.jd-linktable th { vertical-align: top; text-align: left; padding-top: 2px; padding-bottom: 2px; padding-left: 7px; padding-right: 7px; border: none; border-top: 1px solid #d2d7d0; background-color: #F7FCF4; } div#jd-content table.jd-linktable td { border: none; } div#jd-content table.jd-linktable td p { padding: 0; margin: 0; line-height: 110%; } div#jd-content table.jd-linktable .jd-linkcol { vertical-align: top; padding-top: 3px; padding-bottom: 0; padding-left: 7px; padding-right: 7px; border-top: 1px solid #d2d7d0; background-color: #E5F1E0; line-height: 110%; } div#jd-content table.jd-linktable .jd-descrcol { vertical-align: top; padding-top: 3px; padding-bottom: 0; padding-left: 7px; padding-right: 7px; border-top: 1px solid #d2d7d0; background-color: #F7FCF4; line-height: 110%; } div#jd-content table.jd-linktable .jd-descrcol p { padding: 0; margin: 0; line-height: 110%; } div#jd-content table.jd-linktable .jd-valcol { vertical-align: top; padding-top: 3px; padding-bottom: 0; padding-left: 7px; padding-right: 7px; border-top: 1px solid #d2d7d0; background-color: #E5F1E0; line-height: 110%; } div#jd-content table.jd-linktable .jd-commentrow { vertical-align: top; padding-top: 3px; padding-bottom: 4px; padding-left: 7px; padding-right: 7px; background-color: #F7FCF4; line-height: 110%; } div#jd-content div.jd-inheritedlinks { vertical-align: top; margin-top: 9px; padding-left: 7px; padding-right: 7px; background-color: #F7FCF4; line-height: 110%; } div#jd-content .jd-page_title-prefix { padding-top: 2em; margin-bottom: -14pt; } div#jd-content { margin-left: 0; margin-right: 10px; margin-bottom: 0; } div#jd-content h1 { padding-left: 10px; } div#jd-content h2 { padding-left: 10px; } div#jd-content h4 { margin-top: 9px; margin-bottom: 1px; } div#jd-content .jd-descr h5 { margin-bottom: 8px; } div#jd-content .sidebox h3 { margin: 1em 0 0 0; } div#jd-content .jd-letterlist { margin-top: 20px; margin-bottom: 0; } div#jd-content .jd-lettertable { margin-top: 15px; margin-right: 10px; } div#jd-content .jd-letterentries { list-style: none; margin-left: 0; } div#jd-content .jd-letterentrycomments { color: gray; } div#jd-content table.jd-inheritance-table { margin-top: 0; margin-left: 10px; margin-right: 10px; border-spacing: 0; } div#jd-content table.jd-inheritance-table td { border: none; margin: 0; padding: 0; background-color: white; } div#jd-content table.jd-inheritance-table .jd-inheritance-space { width: 10px; } div#jd-content table.jd-inheritance-table .jd-inheritance-interface-cell { padding-left: 17px; } div#jd-content h4.jd-details-title { margin: 0; background-color: #E5F1E0; padding: 2px; padding-left: 10px; padding-right: 10px; margin-top: 15px; } div#jd-content .jd-details { margin-top: 0; margin-left: -10px; } div#jd-content .jd-details-descr { line-height: 120%; padding-left: 10px; padding-top: 10px; padding-right: 20px; } div#jd-content .jd-descr h5, div#jd-content .jd-details h5 { font-style: normal; text-decoration: none; font-size: 120%; } div#jd-content .jd-more { } div#jd-content .jd-descr { padding-top: 0; } div#jd-content .jd-tagdata { margin-top: 6px; margin-bottom: 6px; } div#jd-content .jd-tagtitle { margin-top: 0px; } div#jd-content .jd-tagtable { margin-top: 10px; border-spacing: 0; } div#jd-content .jd-tagtable th { background: white; padding-left: 10px; padding-right: 10px; line-height: 120%; } div#jd-content .jd-tagtable th, div#jd-content .jd-tagtable td { line-height: 120%; border: none; margin: 0; text-align: left; padding-top: 0px; padding-bottom: 5px; } div#jd-content .Code,code,pre,samp,var { color: #004000; } div#jd-content pre.Code { padding-left: 20px; } /* XXX I would really like to apply font-size: 9pt only if var/samp is NOT inside of a .jd-descr div. */ div#jd-content .jd-descr code,var,samp { padding-left: 0px; } #search_autocomplete { font-size: 80%; } div#jd-searchbox table.jd-autocomplete-table-hidden { display: none; } div#jd-searchbox table.jd-autocomplete-table-showing { z-index: 10; border: 1px solid #3366cc; position: relative; top: -14px; left: 5px; background-color: white; } div#jd-searchbox td.jd-autocomplete { font-family: Arial, sans-serif; padding-left: 6px; padding-right: 6px; padding-top: 1px; padding-bottom: 1px; font-size: 80%; border: none; margin: 0; line-height: 105%; } div#jd-searchbox td.jd-selected { background-color: #E5F1E0; } div#jd-searchbox td.jd-linktype { color: #999999; } div#jd-content .jd-expando-trigger { margin-left: -8px; margin-right: 0px; border: none; } div#jd-build-id { color: #666; width: 100%; text-align: right; padding-right: 5px; padding-bottom: 3px; } @media print { #jd-searchbox, .jd-nav { display: none; } div#jd-content { margin-top: 0px; } } sisu-guice-sisu-guice-3.1.1/latest-javadoc/assets/search_autocomplete.js0000755000175000017500000002075011704661106025210 0ustar tonytonyvar gSelectedIndex = -1; var gSelectedID = -1; var gMatches = new Array(); var gLastText = ""; var ROW_COUNT = 20; var gInitialized = false; var DEFAULT_TEXT = "search developer docs"; var HAS_SEARCH_PAGE = false; function set_row_selected(row, selected) { var c1 = row.cells[0]; // var c2 = row.cells[1]; if (selected) { c1.className = "jd-autocomplete jd-selected"; // c2.className = "jd-autocomplete jd-selected jd-linktype"; } else { c1.className = "jd-autocomplete"; // c2.className = "jd-autocomplete jd-linktype"; } } function set_row_values(toroot, row, match) { var link = row.cells[0].childNodes[0]; link.innerHTML = match.__hilabel || match.label; link.href = toroot + match.link // row.cells[1].innerHTML = match.type; } function sync_selection_table(toroot) { var filtered = document.getElementById("search_filtered"); var r; //TR DOM object var i; //TR iterator gSelectedID = -1; filtered.onmouseover = function() { if(gSelectedIndex >= 0) { set_row_selected(this.rows[gSelectedIndex], false); gSelectedIndex = -1; } } //initialize the table; draw it for the first time (but not visible). if (!gInitialized) { for (i=0; i 0) { document.getElementById("search_filtered_div").className = "showing"; var N = gMatches.length < ROW_COUNT ? gMatches.length : ROW_COUNT; for (i=0; i ROW_COUNT) { r = filtered.rows[ROW_COUNT]; r.className = "show-row"; c1 = r.cells[0]; c1.innerHTML = "plus " + (gMatches.length-ROW_COUNT) + " more"; } else { filtered.rows[ROW_COUNT].className = "hide-row"; }*/ //if we have no results, hide the table } else { document.getElementById("search_filtered_div").className = "no-display"; } } function search_changed(e, kd, toroot) { var search = document.getElementById("search_autocomplete"); var text = search.value.replace(/(^ +)|( +$)/g, ''); // 13 = enter if (e.keyCode == 13) { document.getElementById("search_filtered_div").className = "no-display"; if (kd && gSelectedIndex >= 0) { window.location = toroot + gMatches[gSelectedIndex].link; return false; } else if (gSelectedIndex < 0) { if (HAS_SEARCH_PAGE) { return true; } else { sync_selection_table(toroot); return false; } } } // 38 -- arrow up else if (kd && (e.keyCode == 38)) { if (gSelectedIndex >= 0) { gSelectedIndex--; } sync_selection_table(toroot); return false; } // 40 -- arrow down else if (kd && (e.keyCode == 40)) { if (gSelectedIndex < gMatches.length-1 && gSelectedIndex < ROW_COUNT-1) { gSelectedIndex++; } sync_selection_table(toroot); return false; } else if (!kd) { gMatches = new Array(); matchedCount = 0; gSelectedIndex = -1; for (var i=0; i= 0) { if (l < 0) l = 0; l += tmp; s = s.substr(tmp + 1); } return l; }; // helper function that counts the occurrences of a given character in // a given string var _countChar = function(s, c) { var n = 0; for (var i=0; i= 0) { // exact part match var partsAfter = _countChar(labelLower.substr(t + 1), '.'); score *= 200 / (partsAfter + 1); } else { t = _lastSearch(labelLower, partPrefixAlnumRE); if (t >= 0) { // part prefix match var partsAfter = _countChar(labelLower.substr(t + 1), '.'); score *= 20 / (partsAfter + 1); } } return score; }; for (var i=0; i$1'); } } function search_focus_changed(obj, focused) { if (focused) { if(obj.value == DEFAULT_TEXT){ obj.value = ""; obj.style.color="#000000"; } } else { if(obj.value == ""){ obj.value = DEFAULT_TEXT; obj.style.color="#aaaaaa"; } document.getElementById("search_filtered_div").className = "no-display"; } } function submit_search() { if (HAS_SEARCH_PAGE) { var query = document.getElementById('search_autocomplete').value; document.location = toRoot + 'search.html#q=' + query + '&t=0'; } return false; } sisu-guice-sisu-guice-3.1.1/latest-javadoc/assets/prettify.js0000755000175000017500000004456711704661106023044 0ustar tonytony(function(){ var o=true,r=null,z=false;window.PR_SHOULD_USE_CONTINUATION=o;window.PR_TAB_WIDTH=8;window.PR_normalizedHtml=window.PR=window.prettyPrintOne=window.prettyPrint=void 0;window._pr_isIE6=function(){var N=navigator&&navigator.userAgent&&/\bMSIE 6\./.test(navigator.userAgent);window._pr_isIE6=function(){return N};return N}; var aa="!",ba="!=",ca="!==",F="#",da="%",ea="%=",G="&",fa="&&",ja="&&=",ka="&=",H="(",la="*",ma="*=",na="+=",oa=",",pa="-=",qa="->",ra="/",sa="/=",ta=":",ua="::",va=";",I="<",wa="<<",xa="<<=",ya="<=",za="=",Aa="==",Ba="===",J=">",Ca=">=",Da=">>",Ea=">>=",Fa=">>>",Ga=">>>=",Ha="?",Ia="@",L="[",M="^",Ta="^=",Ua="^^",Va="^^=",Wa="{",O="|",Xa="|=",Ya="||",Za="||=",$a="~",ab="break",bb="case",cb="continue",db="delete",eb="do",fb="else",gb="finally",hb="instanceof",ib="return",jb="throw",kb="try",lb="typeof", mb="(?:^^|[+-]",nb="\\$1",ob=")\\s*",pb="&",qb="<",rb=">",sb=""",tb="&#",ub="x",vb="'",wb='"',xb=" ",yb="XMP",zb="\n',ic="\t",jc="\n",kc="[^<]+| InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/stylesheet-jdiff.css0000755000175000017500000000400111704661106024027 0ustar tonytony /* The JDiff style sheet, derived from the Javadoc style sheet. */ /* Generated by the JDiff Javadoc doclet */ /* (http://www.jdiff.org) */ /* Define colors, fonts and other style attributes here to override the defaults */ /* Page background color */ body { background: #CCFFFF url(background.gif); font-family: arial; } /* Table colors */ .TableHeadingColor { background: #CCCCFF } /* Dark mauve */ .TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ .TableRowColor { background: #FFFFFF } /* White */ /* Font used in left-hand frame lists */ .FrameTitleFont { font-size: normal; font-family: normal } .FrameHeadingFont { font-size: normal; font-family: normal } .FrameItemFont { font-size: normal; font-family: normal } /* Example of smaller, sans-serif font in frames */ /* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */ /* Navigation bar fonts and colors */ .NavBarCell1 { background-color:#FFFFCC;} /* Changed to yellowish to make difference from Javadoc clear */ .NavBarCell1Rev { background-color:#00008B;}/* Dark Blue */ .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} /* Links which become blue when hovered upon and show that they have been visited. */ a.hiddenlink:link {color: black; text-decoration: none} a.hiddenlink:visited {color: purple; text-decoration: none} a.hiddenlink:hover {color: blue; text-decoration: underline;} /* Links which become blue when hovered upon but do not show that they have been visited. */ a.staysblack:link {color: black; text-decoration: none} a.staysblack:visited {color: black; text-decoration: none} a.staysblack:hover {color: blue; text-decoration: underline;} sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/new.gif0000755000175000017500000000016411704661106021332 0ustar tonytonyGIF89a ‘РРРџџ!љ, EŒo‚Š!мтyЯбDЋ“6ћџq@‘РifЄЦ ч“–*лІцыКБ8ТБ"ёzАмЬ‰ШŠС"2ЙIA-ЬХЊШ ДMTR;sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/missingSinces.txt0000755000175000017500000001273711704661106023442 0ustar tonytonyOK: com.google.inject.assistedinject.AssistedInjectBinding Interface OK: com.google.inject.assistedinject.AssistedInjectTargetVisitor Interface OK: com.google.inject.assistedinject.AssistedMethod Interface OK: com.google.inject.throwingproviders.CheckedProvider Interface OK: com.google.inject.throwingproviders.CheckedProvides Class OK: com.google.inject.spi.DisableCircularProxiesOption Class OK: com.google.inject.assistedinject.FactoryModuleBuilder Class OK: com.google.inject.servlet.InstanceFilterBinding Interface OK: com.google.inject.servlet.InstanceServletBinding Interface OK: com.google.inject.servlet.LinkedFilterBinding Interface OK: com.google.inject.servlet.LinkedServletBinding Interface OK: com.google.inject.multibindings.MapBinderBinding Interface OK: com.google.inject.multibindings.MultibinderBinding Interface OK: com.google.inject.multibindings.MultibindingsTargetVisitor Interface OK: com.google.inject.spi.ProviderWithExtensionVisitor Interface OK: com.google.inject.spi.RequireExplicitBindingsOption Class OK: com.google.inject.servlet.ServletModuleBinding Interface OK: com.google.inject.servlet.ServletModuleTargetVisitor Interface MISSING @SINCE TAG: com.google.inject.struts2.Struts2Factory Class MISSING @SINCE TAG: com.google.inject.struts2.Struts2GuicePluginModule Class OK: com.google.inject.spi.Toolable Class OK: com.google.inject.servlet.UriPatternType Class OK: com.google.inject.spi.TypeConverterBinding Constructor (java.lang.Object, com.google.inject.matcher.Matcher>, com.google.inject.spi.TypeConverter) OK: com.google.inject.servlet.ServletScopes Method continueRequest(java.util.concurrent.Callable, java.util.Map, java.lang.Object>) OK: com.google.inject.Binder Method disableCircularProxies() OK: com.google.inject.spi.InjectionPoint Method forConstructor(java.lang.reflect.Constructor) OK: com.google.inject.spi.InjectionPoint Method forConstructor(java.lang.reflect.Constructor, com.google.inject.TypeLiteral) OK: com.google.inject.throwingproviders.ThrowingProviderBinder Method forModule(com.google.inject.Module) OK: com.google.inject.Injector Method getAllBindings() OK: com.google.inject.spi.InjectionPoint Method getDeclaringType() OK: com.google.inject.Injector Method getExistingBinding(com.google.inject.Key) OK: com.google.inject.Injector Method getScopeBindings() OK: com.google.inject.servlet.ServletModule Method getServletContext() OK: com.google.inject.spi.ConvertedConstantBinding Method getTypeConverterBinding() OK: com.google.inject.Injector Method getTypeConverterBindings() OK: com.google.inject.util.Providers Method guicify(javax.inject.Provider) OK: com.google.inject.Key Method hasAttributes() OK: com.google.inject.Scopes Method isSingleton(com.google.inject.Binding) OK: com.google.inject.spi.InjectionPoint Method isToolable() OK: com.google.inject.Key Method ofType(java.lang.reflect.Type) OK: com.google.inject.Key Method ofType(com.google.inject.TypeLiteral) OK: com.google.inject.Key Method ofType(java.lang.Class) OK: com.google.inject.multibindings.MapBinder Method permitDuplicates() OK: com.google.inject.multibindings.Multibinder Method permitDuplicates() OK: com.google.inject.Binder Method requireExplicitBindings() OK: com.google.inject.servlet.ServletScopes Method scopeRequest(java.util.concurrent.Callable, java.util.Map, java.lang.Object>) OK: com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder Method through(Filter) OK: com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder Method through(Filter, java.util.Map) OK: com.google.inject.binder.ConstantBindingBuilder Method to(byte) OK: com.google.inject.binder.LinkedBindingBuilder Method toConstructor(java.lang.reflect.Constructor) OK: com.google.inject.binder.LinkedBindingBuilder Method toConstructor(java.lang.reflect.Constructor, com.google.inject.TypeLiteral) MISSING @SINCE TAG: com.google.inject.binder.LinkedBindingBuilder Method toProvider(com.google.inject.Key>) MISSING @SINCE TAG: com.google.inject.binder.LinkedBindingBuilder Method toProvider(com.google.inject.TypeLiteral>) MISSING @SINCE TAG: com.google.inject.binder.LinkedBindingBuilder Method toProvider(java.lang.Class>) NO DOC BLOCK: com.google.inject.spi.TypeConverterBinding Method toString() NO DOC BLOCK: com.google.inject.spi.DefaultElementVisitor Method visit(com.google.inject.spi.DisableCircularProxiesOption) NO DOC BLOCK: com.google.inject.spi.DefaultElementVisitor Method visit(com.google.inject.spi.InjectionRequest) NO DOC BLOCK: com.google.inject.spi.DefaultElementVisitor Method visit(com.google.inject.spi.RequireExplicitBindingsOption) OK: com.google.inject.spi.ElementVisitor Method visit(com.google.inject.spi.DisableCircularProxiesOption) MISSING @SINCE TAG: com.google.inject.spi.ElementVisitor Method visit(com.google.inject.spi.InjectionRequest) OK: com.google.inject.spi.ElementVisitor Method visit(com.google.inject.spi.RequireExplicitBindingsOption) OK: com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder Method with(HttpServlet) OK: com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder Method with(HttpServlet, java.util.Map) OK: com.google.inject.Key Method withoutAttributes() sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/0000755000175000017500000000000011704661106021455 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/packages.html0000755000175000017500000003422411704661106024131 0ustar tonytony Package Index | Guice

Package Index

com.google.inject Google Guice (pronounced "juice") is an ultra-lightweight dependency injection framework. 
com.google.inject.assistedinject Extension for combining factory interfaces with injection; this extension requires guice-assistedinject-3.0.jar
com.google.inject.binder Interfaces which make up Binder's expression language. 
com.google.inject.grapher  
com.google.inject.grapher.graphviz  
com.google.inject.jndi JNDI integration; this extension requires guice-jndi-3.0.jar
com.google.inject.matcher Used for matching things. 
com.google.inject.multibindings Extension for binding multiple instances in a collection; this extension requires guice-multibindings-3.0.jar
com.google.inject.name Support for binding to string-based names. 
com.google.inject.persist Guice Persist: a lightweight persistence library for Guice; this extension requires guice-persist-3.0.jar
com.google.inject.persist.finder Dynamic Finder API for Guice Persist. 
com.google.inject.persist.jpa guice-persist's Java Persistence API (JPA) support. 
com.google.inject.servlet Servlet API scopes, bindings and registration; this extension requires guice-servlet-3.0.jar
com.google.inject.spi Guice service provider interface  
com.google.inject.spring Spring integration; this extension requires guice-spring-3.0.jar
com.google.inject.throwingproviders Extension for injecting objects that may throw at provision time; this extension requires guice-throwingproviders-3.0.jar
com.google.inject.tools.jmx JMX integration; this extension requires guice-jmx-3.0.jar
com.google.inject.util Helper methods for working with Guice. 
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/package-list0000755000175000017500000000075311704661106023754 0ustar tonytonycom.google.inject com.google.inject.assistedinject com.google.inject.binder com.google.inject.grapher com.google.inject.grapher.graphviz com.google.inject.jndi com.google.inject.matcher com.google.inject.multibindings com.google.inject.name com.google.inject.persist com.google.inject.persist.finder com.google.inject.persist.jpa com.google.inject.servlet com.google.inject.spi com.google.inject.spring com.google.inject.throwingproviders com.google.inject.tools.jmx com.google.inject.util sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/lists.js0000755000175000017500000006144611704661106023167 0ustar tonytonyvar DATA = [ { id:0, label:"com.google.inject", link:"com/google/inject/package-summary.html", type:"package" }, { id:1, label:"com.google.inject.AbstractModule", link:"com/google/inject/AbstractModule.html", type:"class" }, { id:2, label:"com.google.inject.Binder", link:"com/google/inject/Binder.html", type:"class" }, { id:3, label:"com.google.inject.Binding", link:"com/google/inject/Binding.html", type:"class" }, { id:4, label:"com.google.inject.BindingAnnotation", link:"com/google/inject/BindingAnnotation.html", type:"class" }, { id:5, label:"com.google.inject.ConfigurationException", link:"com/google/inject/ConfigurationException.html", type:"class" }, { id:6, label:"com.google.inject.CreationException", link:"com/google/inject/CreationException.html", type:"class" }, { id:7, label:"com.google.inject.Exposed", link:"com/google/inject/Exposed.html", type:"class" }, { id:8, label:"com.google.inject.Guice", link:"com/google/inject/Guice.html", type:"class" }, { id:9, label:"com.google.inject.ImplementedBy", link:"com/google/inject/ImplementedBy.html", type:"class" }, { id:10, label:"com.google.inject.Inject", link:"com/google/inject/Inject.html", type:"class" }, { id:11, label:"com.google.inject.Injector", link:"com/google/inject/Injector.html", type:"class" }, { id:12, label:"com.google.inject.Key", link:"com/google/inject/Key.html", type:"class" }, { id:13, label:"com.google.inject.MembersInjector", link:"com/google/inject/MembersInjector.html", type:"class" }, { id:14, label:"com.google.inject.Module", link:"com/google/inject/Module.html", type:"class" }, { id:15, label:"com.google.inject.OutOfScopeException", link:"com/google/inject/OutOfScopeException.html", type:"class" }, { id:16, label:"com.google.inject.PrivateBinder", link:"com/google/inject/PrivateBinder.html", type:"class" }, { id:17, label:"com.google.inject.PrivateModule", link:"com/google/inject/PrivateModule.html", type:"class" }, { id:18, label:"com.google.inject.ProvidedBy", link:"com/google/inject/ProvidedBy.html", type:"class" }, { id:19, label:"com.google.inject.Provider", link:"com/google/inject/Provider.html", type:"class" }, { id:20, label:"com.google.inject.Provides", link:"com/google/inject/Provides.html", type:"class" }, { id:21, label:"com.google.inject.ProvisionException", link:"com/google/inject/ProvisionException.html", type:"class" }, { id:22, label:"com.google.inject.Scope", link:"com/google/inject/Scope.html", type:"class" }, { id:23, label:"com.google.inject.ScopeAnnotation", link:"com/google/inject/ScopeAnnotation.html", type:"class" }, { id:24, label:"com.google.inject.Scopes", link:"com/google/inject/Scopes.html", type:"class" }, { id:25, label:"com.google.inject.Singleton", link:"com/google/inject/Singleton.html", type:"class" }, { id:26, label:"com.google.inject.Stage", link:"com/google/inject/Stage.html", type:"class" }, { id:27, label:"com.google.inject.TypeLiteral", link:"com/google/inject/TypeLiteral.html", type:"class" }, { id:28, label:"com.google.inject.assistedinject", link:"com/google/inject/assistedinject/package-summary.html", type:"package" }, { id:29, label:"com.google.inject.assistedinject.Assisted", link:"com/google/inject/assistedinject/Assisted.html", type:"class" }, { id:30, label:"com.google.inject.assistedinject.AssistedInject", link:"com/google/inject/assistedinject/AssistedInject.html", type:"class" }, { id:31, label:"com.google.inject.assistedinject.AssistedInjectBinding", link:"com/google/inject/assistedinject/AssistedInjectBinding.html", type:"class" }, { id:32, label:"com.google.inject.assistedinject.AssistedInjectTargetVisitor", link:"com/google/inject/assistedinject/AssistedInjectTargetVisitor.html", type:"class" }, { id:33, label:"com.google.inject.assistedinject.AssistedMethod", link:"com/google/inject/assistedinject/AssistedMethod.html", type:"class" }, { id:34, label:"com.google.inject.assistedinject.FactoryModuleBuilder", link:"com/google/inject/assistedinject/FactoryModuleBuilder.html", type:"class" }, { id:35, label:"com.google.inject.assistedinject.FactoryProvider", link:"com/google/inject/assistedinject/FactoryProvider.html", type:"class" }, { id:36, label:"com.google.inject.binder", link:"com/google/inject/binder/package-summary.html", type:"package" }, { id:37, label:"com.google.inject.binder.AnnotatedBindingBuilder", link:"com/google/inject/binder/AnnotatedBindingBuilder.html", type:"class" }, { id:38, label:"com.google.inject.binder.AnnotatedConstantBindingBuilder", link:"com/google/inject/binder/AnnotatedConstantBindingBuilder.html", type:"class" }, { id:39, label:"com.google.inject.binder.AnnotatedElementBuilder", link:"com/google/inject/binder/AnnotatedElementBuilder.html", type:"class" }, { id:40, label:"com.google.inject.binder.ConstantBindingBuilder", link:"com/google/inject/binder/ConstantBindingBuilder.html", type:"class" }, { id:41, label:"com.google.inject.binder.LinkedBindingBuilder", link:"com/google/inject/binder/LinkedBindingBuilder.html", type:"class" }, { id:42, label:"com.google.inject.binder.ScopedBindingBuilder", link:"com/google/inject/binder/ScopedBindingBuilder.html", type:"class" }, { id:43, label:"com.google.inject.grapher", link:"com/google/inject/grapher/package-summary.html", type:"package" }, { id:44, label:"com.google.inject.grapher.BindingEdge", link:"com/google/inject/grapher/BindingEdge.html", type:"class" }, { id:45, label:"com.google.inject.grapher.BindingEdge.Factory", link:"com/google/inject/grapher/BindingEdge.Factory.html", type:"class" }, { id:46, label:"com.google.inject.grapher.BindingEdge.Type", link:"com/google/inject/grapher/BindingEdge.Type.html", type:"class" }, { id:47, label:"com.google.inject.grapher.DependencyEdge", link:"com/google/inject/grapher/DependencyEdge.html", type:"class" }, { id:48, label:"com.google.inject.grapher.DependencyEdge.Factory", link:"com/google/inject/grapher/DependencyEdge.Factory.html", type:"class" }, { id:49, label:"com.google.inject.grapher.GrapherModule", link:"com/google/inject/grapher/GrapherModule.html", type:"class" }, { id:50, label:"com.google.inject.grapher.GraphingVisitor", link:"com/google/inject/grapher/GraphingVisitor.html", type:"class" }, { id:51, label:"com.google.inject.grapher.ImplementationNode", link:"com/google/inject/grapher/ImplementationNode.html", type:"class" }, { id:52, label:"com.google.inject.grapher.ImplementationNode.Factory", link:"com/google/inject/grapher/ImplementationNode.Factory.html", type:"class" }, { id:53, label:"com.google.inject.grapher.InjectorGrapher", link:"com/google/inject/grapher/InjectorGrapher.html", type:"class" }, { id:54, label:"com.google.inject.grapher.InterfaceNode", link:"com/google/inject/grapher/InterfaceNode.html", type:"class" }, { id:55, label:"com.google.inject.grapher.InterfaceNode.Factory", link:"com/google/inject/grapher/InterfaceNode.Factory.html", type:"class" }, { id:56, label:"com.google.inject.grapher.NameFactory", link:"com/google/inject/grapher/NameFactory.html", type:"class" }, { id:57, label:"com.google.inject.grapher.NodeAliasFactory", link:"com/google/inject/grapher/NodeAliasFactory.html", type:"class" }, { id:58, label:"com.google.inject.grapher.NodeIdFactory", link:"com/google/inject/grapher/NodeIdFactory.html", type:"class" }, { id:59, label:"com.google.inject.grapher.Renderer", link:"com/google/inject/grapher/Renderer.html", type:"class" }, { id:60, label:"com.google.inject.grapher.ShortNameFactory", link:"com/google/inject/grapher/ShortNameFactory.html", type:"class" }, { id:61, label:"com.google.inject.grapher.StringNodeIdFactory", link:"com/google/inject/grapher/StringNodeIdFactory.html", type:"class" }, { id:62, label:"com.google.inject.grapher.TransitiveDependencyVisitor", link:"com/google/inject/grapher/TransitiveDependencyVisitor.html", type:"class" }, { id:63, label:"com.google.inject.grapher.graphviz", link:"com/google/inject/grapher/graphviz/package-summary.html", type:"package" }, { id:64, label:"com.google.inject.grapher.graphviz.ArrowType", link:"com/google/inject/grapher/graphviz/ArrowType.html", type:"class" }, { id:65, label:"com.google.inject.grapher.graphviz.BindingEdgeFactory", link:"com/google/inject/grapher/graphviz/BindingEdgeFactory.html", type:"class" }, { id:66, label:"com.google.inject.grapher.graphviz.BindingEdgeFactory.GraphvizEdgeAdaptor", link:"com/google/inject/grapher/graphviz/BindingEdgeFactory.GraphvizEdgeAdaptor.html", type:"class" }, { id:67, label:"com.google.inject.grapher.graphviz.CompassPoint", link:"com/google/inject/grapher/graphviz/CompassPoint.html", type:"class" }, { id:68, label:"com.google.inject.grapher.graphviz.DependencyEdgeFactory", link:"com/google/inject/grapher/graphviz/DependencyEdgeFactory.html", type:"class" }, { id:69, label:"com.google.inject.grapher.graphviz.DependencyEdgeFactory.GraphvizEdgeAdaptor", link:"com/google/inject/grapher/graphviz/DependencyEdgeFactory.GraphvizEdgeAdaptor.html", type:"class" }, { id:70, label:"com.google.inject.grapher.graphviz.EdgeStyle", link:"com/google/inject/grapher/graphviz/EdgeStyle.html", type:"class" }, { id:71, label:"com.google.inject.grapher.graphviz.GraphvizEdge", link:"com/google/inject/grapher/graphviz/GraphvizEdge.html", type:"class" }, { id:72, label:"com.google.inject.grapher.graphviz.GraphvizModule", link:"com/google/inject/grapher/graphviz/GraphvizModule.html", type:"class" }, { id:73, label:"com.google.inject.grapher.graphviz.GraphvizNode", link:"com/google/inject/grapher/graphviz/GraphvizNode.html", type:"class" }, { id:74, label:"com.google.inject.grapher.graphviz.GraphvizRenderer", link:"com/google/inject/grapher/graphviz/GraphvizRenderer.html", type:"class" }, { id:75, label:"com.google.inject.grapher.graphviz.ImplementationNodeFactory", link:"com/google/inject/grapher/graphviz/ImplementationNodeFactory.html", type:"class" }, { id:76, label:"com.google.inject.grapher.graphviz.ImplementationNodeFactory.GraphvizNodeAdaptor", link:"com/google/inject/grapher/graphviz/ImplementationNodeFactory.GraphvizNodeAdaptor.html", type:"class" }, { id:77, label:"com.google.inject.grapher.graphviz.InterfaceNodeFactory", link:"com/google/inject/grapher/graphviz/InterfaceNodeFactory.html", type:"class" }, { id:78, label:"com.google.inject.grapher.graphviz.InterfaceNodeFactory.GraphvizNodeAdaptor", link:"com/google/inject/grapher/graphviz/InterfaceNodeFactory.GraphvizNodeAdaptor.html", type:"class" }, { id:79, label:"com.google.inject.grapher.graphviz.NodeShape", link:"com/google/inject/grapher/graphviz/NodeShape.html", type:"class" }, { id:80, label:"com.google.inject.grapher.graphviz.NodeStyle", link:"com/google/inject/grapher/graphviz/NodeStyle.html", type:"class" }, { id:81, label:"com.google.inject.grapher.graphviz.PortIdFactory", link:"com/google/inject/grapher/graphviz/PortIdFactory.html", type:"class" }, { id:82, label:"com.google.inject.grapher.graphviz.PortIdFactoryImpl", link:"com/google/inject/grapher/graphviz/PortIdFactoryImpl.html", type:"class" }, { id:83, label:"com.google.inject.jndi", link:"com/google/inject/jndi/package-summary.html", type:"package" }, { id:84, label:"com.google.inject.jndi.JndiIntegration", link:"com/google/inject/jndi/JndiIntegration.html", type:"class" }, { id:85, label:"com.google.inject.matcher", link:"com/google/inject/matcher/package-summary.html", type:"package" }, { id:86, label:"com.google.inject.matcher.AbstractMatcher", link:"com/google/inject/matcher/AbstractMatcher.html", type:"class" }, { id:87, label:"com.google.inject.matcher.Matcher", link:"com/google/inject/matcher/Matcher.html", type:"class" }, { id:88, label:"com.google.inject.matcher.Matchers", link:"com/google/inject/matcher/Matchers.html", type:"class" }, { id:89, label:"com.google.inject.multibindings", link:"com/google/inject/multibindings/package-summary.html", type:"package" }, { id:90, label:"com.google.inject.multibindings.MapBinder", link:"com/google/inject/multibindings/MapBinder.html", type:"class" }, { id:91, label:"com.google.inject.multibindings.MapBinderBinding", link:"com/google/inject/multibindings/MapBinderBinding.html", type:"class" }, { id:92, label:"com.google.inject.multibindings.Multibinder", link:"com/google/inject/multibindings/Multibinder.html", type:"class" }, { id:93, label:"com.google.inject.multibindings.MultibinderBinding", link:"com/google/inject/multibindings/MultibinderBinding.html", type:"class" }, { id:94, label:"com.google.inject.multibindings.MultibindingsTargetVisitor", link:"com/google/inject/multibindings/MultibindingsTargetVisitor.html", type:"class" }, { id:95, label:"com.google.inject.name", link:"com/google/inject/name/package-summary.html", type:"package" }, { id:96, label:"com.google.inject.name.Named", link:"com/google/inject/name/Named.html", type:"class" }, { id:97, label:"com.google.inject.name.Names", link:"com/google/inject/name/Names.html", type:"class" }, { id:98, label:"com.google.inject.persist", link:"com/google/inject/persist/package-summary.html", type:"package" }, { id:99, label:"com.google.inject.persist.PersistFilter", link:"com/google/inject/persist/PersistFilter.html", type:"class" }, { id:100, label:"com.google.inject.persist.PersistModule", link:"com/google/inject/persist/PersistModule.html", type:"class" }, { id:101, label:"com.google.inject.persist.PersistService", link:"com/google/inject/persist/PersistService.html", type:"class" }, { id:102, label:"com.google.inject.persist.Transactional", link:"com/google/inject/persist/Transactional.html", type:"class" }, { id:103, label:"com.google.inject.persist.UnitOfWork", link:"com/google/inject/persist/UnitOfWork.html", type:"class" }, { id:104, label:"com.google.inject.persist.finder", link:"com/google/inject/persist/finder/package-summary.html", type:"package" }, { id:105, label:"com.google.inject.persist.finder.DynamicFinder", link:"com/google/inject/persist/finder/DynamicFinder.html", type:"class" }, { id:106, label:"com.google.inject.persist.finder.Finder", link:"com/google/inject/persist/finder/Finder.html", type:"class" }, { id:107, label:"com.google.inject.persist.finder.FirstResult", link:"com/google/inject/persist/finder/FirstResult.html", type:"class" }, { id:108, label:"com.google.inject.persist.finder.MaxResults", link:"com/google/inject/persist/finder/MaxResults.html", type:"class" }, { id:109, label:"com.google.inject.persist.jpa", link:"com/google/inject/persist/jpa/package-summary.html", type:"package" }, { id:110, label:"com.google.inject.persist.jpa.JpaPersistModule", link:"com/google/inject/persist/jpa/JpaPersistModule.html", type:"class" }, { id:111, label:"com.google.inject.servlet", link:"com/google/inject/servlet/package-summary.html", type:"package" }, { id:112, label:"com.google.inject.servlet.GuiceFilter", link:"com/google/inject/servlet/GuiceFilter.html", type:"class" }, { id:113, label:"com.google.inject.servlet.GuiceServletContextListener", link:"com/google/inject/servlet/GuiceServletContextListener.html", type:"class" }, { id:114, label:"com.google.inject.servlet.InstanceFilterBinding", link:"com/google/inject/servlet/InstanceFilterBinding.html", type:"class" }, { id:115, label:"com.google.inject.servlet.InstanceServletBinding", link:"com/google/inject/servlet/InstanceServletBinding.html", type:"class" }, { id:116, label:"com.google.inject.servlet.LinkedFilterBinding", link:"com/google/inject/servlet/LinkedFilterBinding.html", type:"class" }, { id:117, label:"com.google.inject.servlet.LinkedServletBinding", link:"com/google/inject/servlet/LinkedServletBinding.html", type:"class" }, { id:118, label:"com.google.inject.servlet.RequestParameters", link:"com/google/inject/servlet/RequestParameters.html", type:"class" }, { id:119, label:"com.google.inject.servlet.RequestScoped", link:"com/google/inject/servlet/RequestScoped.html", type:"class" }, { id:120, label:"com.google.inject.servlet.ServletModule", link:"com/google/inject/servlet/ServletModule.html", type:"class" }, { id:121, label:"com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder", link:"com/google/inject/servlet/ServletModule.FilterKeyBindingBuilder.html", type:"class" }, { id:122, label:"com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder", link:"com/google/inject/servlet/ServletModule.ServletKeyBindingBuilder.html", type:"class" }, { id:123, label:"com.google.inject.servlet.ServletModuleBinding", link:"com/google/inject/servlet/ServletModuleBinding.html", type:"class" }, { id:124, label:"com.google.inject.servlet.ServletModuleTargetVisitor", link:"com/google/inject/servlet/ServletModuleTargetVisitor.html", type:"class" }, { id:125, label:"com.google.inject.servlet.ServletScopes", link:"com/google/inject/servlet/ServletScopes.html", type:"class" }, { id:126, label:"com.google.inject.servlet.SessionScoped", link:"com/google/inject/servlet/SessionScoped.html", type:"class" }, { id:127, label:"com.google.inject.servlet.UriPatternType", link:"com/google/inject/servlet/UriPatternType.html", type:"class" }, { id:128, label:"com.google.inject.spi", link:"com/google/inject/spi/package-summary.html", type:"package" }, { id:129, label:"com.google.inject.spi.BindingScopingVisitor", link:"com/google/inject/spi/BindingScopingVisitor.html", type:"class" }, { id:130, label:"com.google.inject.spi.BindingTargetVisitor", link:"com/google/inject/spi/BindingTargetVisitor.html", type:"class" }, { id:131, label:"com.google.inject.spi.ConstructorBinding", link:"com/google/inject/spi/ConstructorBinding.html", type:"class" }, { id:132, label:"com.google.inject.spi.ConvertedConstantBinding", link:"com/google/inject/spi/ConvertedConstantBinding.html", type:"class" }, { id:133, label:"com.google.inject.spi.DefaultBindingScopingVisitor", link:"com/google/inject/spi/DefaultBindingScopingVisitor.html", type:"class" }, { id:134, label:"com.google.inject.spi.DefaultBindingTargetVisitor", link:"com/google/inject/spi/DefaultBindingTargetVisitor.html", type:"class" }, { id:135, label:"com.google.inject.spi.DefaultElementVisitor", link:"com/google/inject/spi/DefaultElementVisitor.html", type:"class" }, { id:136, label:"com.google.inject.spi.Dependency", link:"com/google/inject/spi/Dependency.html", type:"class" }, { id:137, label:"com.google.inject.spi.DisableCircularProxiesOption", link:"com/google/inject/spi/DisableCircularProxiesOption.html", type:"class" }, { id:138, label:"com.google.inject.spi.Element", link:"com/google/inject/spi/Element.html", type:"class" }, { id:139, label:"com.google.inject.spi.ElementVisitor", link:"com/google/inject/spi/ElementVisitor.html", type:"class" }, { id:140, label:"com.google.inject.spi.Elements", link:"com/google/inject/spi/Elements.html", type:"class" }, { id:141, label:"com.google.inject.spi.ExposedBinding", link:"com/google/inject/spi/ExposedBinding.html", type:"class" }, { id:142, label:"com.google.inject.spi.HasDependencies", link:"com/google/inject/spi/HasDependencies.html", type:"class" }, { id:143, label:"com.google.inject.spi.InjectionListener", link:"com/google/inject/spi/InjectionListener.html", type:"class" }, { id:144, label:"com.google.inject.spi.InjectionPoint", link:"com/google/inject/spi/InjectionPoint.html", type:"class" }, { id:145, label:"com.google.inject.spi.InjectionRequest", link:"com/google/inject/spi/InjectionRequest.html", type:"class" }, { id:146, label:"com.google.inject.spi.InstanceBinding", link:"com/google/inject/spi/InstanceBinding.html", type:"class" }, { id:147, label:"com.google.inject.spi.InterceptorBinding", link:"com/google/inject/spi/InterceptorBinding.html", type:"class" }, { id:148, label:"com.google.inject.spi.LinkedKeyBinding", link:"com/google/inject/spi/LinkedKeyBinding.html", type:"class" }, { id:149, label:"com.google.inject.spi.MembersInjectorLookup", link:"com/google/inject/spi/MembersInjectorLookup.html", type:"class" }, { id:150, label:"com.google.inject.spi.Message", link:"com/google/inject/spi/Message.html", type:"class" }, { id:151, label:"com.google.inject.spi.PrivateElements", link:"com/google/inject/spi/PrivateElements.html", type:"class" }, { id:152, label:"com.google.inject.spi.ProviderBinding", link:"com/google/inject/spi/ProviderBinding.html", type:"class" }, { id:153, label:"com.google.inject.spi.ProviderInstanceBinding", link:"com/google/inject/spi/ProviderInstanceBinding.html", type:"class" }, { id:154, label:"com.google.inject.spi.ProviderKeyBinding", link:"com/google/inject/spi/ProviderKeyBinding.html", type:"class" }, { id:155, label:"com.google.inject.spi.ProviderLookup", link:"com/google/inject/spi/ProviderLookup.html", type:"class" }, { id:156, label:"com.google.inject.spi.ProviderWithDependencies", link:"com/google/inject/spi/ProviderWithDependencies.html", type:"class" }, { id:157, label:"com.google.inject.spi.ProviderWithExtensionVisitor", link:"com/google/inject/spi/ProviderWithExtensionVisitor.html", type:"class" }, { id:158, label:"com.google.inject.spi.RequireExplicitBindingsOption", link:"com/google/inject/spi/RequireExplicitBindingsOption.html", type:"class" }, { id:159, label:"com.google.inject.spi.ScopeBinding", link:"com/google/inject/spi/ScopeBinding.html", type:"class" }, { id:160, label:"com.google.inject.spi.StaticInjectionRequest", link:"com/google/inject/spi/StaticInjectionRequest.html", type:"class" }, { id:161, label:"com.google.inject.spi.Toolable", link:"com/google/inject/spi/Toolable.html", type:"class" }, { id:162, label:"com.google.inject.spi.TypeConverter", link:"com/google/inject/spi/TypeConverter.html", type:"class" }, { id:163, label:"com.google.inject.spi.TypeConverterBinding", link:"com/google/inject/spi/TypeConverterBinding.html", type:"class" }, { id:164, label:"com.google.inject.spi.TypeEncounter", link:"com/google/inject/spi/TypeEncounter.html", type:"class" }, { id:165, label:"com.google.inject.spi.TypeListener", link:"com/google/inject/spi/TypeListener.html", type:"class" }, { id:166, label:"com.google.inject.spi.TypeListenerBinding", link:"com/google/inject/spi/TypeListenerBinding.html", type:"class" }, { id:167, label:"com.google.inject.spi.UntargettedBinding", link:"com/google/inject/spi/UntargettedBinding.html", type:"class" }, { id:168, label:"com.google.inject.spring", link:"com/google/inject/spring/package-summary.html", type:"package" }, { id:169, label:"com.google.inject.spring.SpringIntegration", link:"com/google/inject/spring/SpringIntegration.html", type:"class" }, { id:170, label:"com.google.inject.throwingproviders", link:"com/google/inject/throwingproviders/package-summary.html", type:"package" }, { id:171, label:"com.google.inject.throwingproviders.CheckedProvider", link:"com/google/inject/throwingproviders/CheckedProvider.html", type:"class" }, { id:172, label:"com.google.inject.throwingproviders.CheckedProvides", link:"com/google/inject/throwingproviders/CheckedProvides.html", type:"class" }, { id:173, label:"com.google.inject.throwingproviders.ThrowingProvider", link:"com/google/inject/throwingproviders/ThrowingProvider.html", type:"class" }, { id:174, label:"com.google.inject.throwingproviders.ThrowingProviderBinder", link:"com/google/inject/throwingproviders/ThrowingProviderBinder.html", type:"class" }, { id:175, label:"com.google.inject.throwingproviders.ThrowingProviderBinder.SecondaryBinder", link:"com/google/inject/throwingproviders/ThrowingProviderBinder.SecondaryBinder.html", type:"class" }, { id:176, label:"com.google.inject.tools.jmx", link:"com/google/inject/tools/jmx/package-summary.html", type:"package" }, { id:177, label:"com.google.inject.tools.jmx.ManagedBindingMBean", link:"com/google/inject/tools/jmx/ManagedBindingMBean.html", type:"class" }, { id:178, label:"com.google.inject.tools.jmx.Manager", link:"com/google/inject/tools/jmx/Manager.html", type:"class" }, { id:179, label:"com.google.inject.util", link:"com/google/inject/util/package-summary.html", type:"package" }, { id:180, label:"com.google.inject.util.Modules", link:"com/google/inject/util/Modules.html", type:"class" }, { id:181, label:"com.google.inject.util.Modules.OverriddenModuleBuilder", link:"com/google/inject/util/Modules.OverriddenModuleBuilder.html", type:"class" }, { id:182, label:"com.google.inject.util.Providers", link:"com/google/inject/util/Providers.html", type:"class" }, { id:183, label:"com.google.inject.util.Types", link:"com/google/inject/util/Types.html", type:"class" } ]; sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/index.html0000755000175000017500000000014711704661106023457 0ustar tonytony sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/hierarchy.html0000755000175000017500000007542511704661106024341 0ustar tonytony Class Hierarchy | Guice

Class Hierarchy

Class Interfaces
 
AbstractModule Module     
GrapherModule  
GraphvizModule  
PersistModule  
JpaPersistModule  
ServletModule  
Guice  
Key  
PrivateModule Module     
Scopes  
TypeLiteral  
FactoryModuleBuilder  
FactoryProvider Provider    HasDependencies     
GraphingVisitor BindingTargetVisitor     
InjectorGrapher  
ShortNameFactory NameFactory     
StringNodeIdFactory NodeIdFactory     
TransitiveDependencyVisitor BindingTargetVisitor     
BindingEdgeFactory BindingEdge.Factory     
BindingEdgeFactory.GraphvizEdgeAdaptor BindingEdge     
DependencyEdgeFactory DependencyEdge.Factory     
DependencyEdgeFactory.GraphvizEdgeAdaptor DependencyEdge     
GraphvizEdge  
GraphvizNode  
GraphvizRenderer NodeAliasFactory    Renderer     
ImplementationNodeFactory ImplementationNode.Factory     
ImplementationNodeFactory.GraphvizNodeAdaptor ImplementationNode     
InterfaceNodeFactory InterfaceNode.Factory     
InterfaceNodeFactory.GraphvizNodeAdaptor InterfaceNode     
PortIdFactoryImpl PortIdFactory     
JndiIntegration  
AbstractMatcher Matcher     
Matchers  
MapBinder  
Multibinder  
Names  
PersistFilter  
DynamicFinder  
GuiceFilter  
GuiceServletContextListener  
ServletScopes  
DefaultBindingScopingVisitor BindingScopingVisitor     
DefaultBindingTargetVisitor BindingTargetVisitor     
DefaultElementVisitor ElementVisitor     
Dependency  
DisableCircularProxiesOption Element     
Elements  
InjectionPoint  
InjectionRequest Element     
InterceptorBinding Element     
MembersInjectorLookup Element     
Message Element    Serializable     
ProviderLookup Element     
RequireExplicitBindingsOption Element     
ScopeBinding Element     
StaticInjectionRequest Element     
TypeConverterBinding Element     
TypeListenerBinding Element     
SpringIntegration  
ThrowingProviderBinder  
ThrowingProviderBinder.SecondaryBinder  
Manager  
Modules  
Providers  
Types  
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/current.xml0000755000175000017500000074006011704661106023673 0ustar tonytony sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/0000755000175000017500000000000011704661106022233 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/0000755000175000017500000000000011704661106023507 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/0000755000175000017500000000000011704661106024763 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/util/0000755000175000017500000000000011704661106025740 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/util/package-summary.html0000755000175000017500000002732011704661106031723 0ustar tonytony com.google.inject.util | Guice
package

com.google.inject.util

Classes | Description

Helper methods for working with Guice.

more...

Interfaces

Modules.OverriddenModuleBuilder See the EDSL example at override()

Classes

Modules Static utility methods for creating and working with instances of Module
Providers Static utility methods for creating and working with instances of Provider
Types Static methods for working with types. 
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/util/package-descr.html0000755000175000017500000002361511704661106031331 0ustar tonytony com.google.inject.util Details | Guice
package

com.google.inject.util

Classes | Description

Helper methods for working with Guice.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/util/Types.html0000755000175000017500000007321611704661106027746 0ustar tonytony Types | Guice
public final class

Types

extends Object
java.lang.Object
   ↳ com.google.inject.util.Types

Class Overview

Static methods for working with types.

Summary

Public Methods
static GenericArrayType arrayOf(Type componentType)
Returns an array type whose elements are all instances of componentType.
static ParameterizedType listOf(Type elementType)
Returns a type modelling a List whose elements are of type elementType.
static ParameterizedType mapOf(Type keyType, Type valueType)
Returns a type modelling a Map whose keys are of type keyType and whose values are of type valueType.
static ParameterizedType newParameterizedType(Type rawType, Type... typeArguments)
Returns a new parameterized type, applying typeArguments to rawType.
static ParameterizedType newParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments)
Returns a new parameterized type, applying typeArguments to rawType and enclosed by ownerType.
static ParameterizedType providerOf(Type providedType)
Returns a type modelling a Provider that provides elements of type elementType.
static ParameterizedType setOf(Type elementType)
Returns a type modelling a Set whose elements are of type elementType.
static WildcardType subtypeOf(Type bound)
Returns a type that represents an unknown type that extends bound.
static WildcardType supertypeOf(Type bound)
Returns a type that represents an unknown supertype of bound.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static GenericArrayType arrayOf (Type componentType)

Returns an array type whose elements are all instances of componentType.

Returns
  • a java.io.Serializable serializable generic array type.

public static ParameterizedType listOf (Type elementType)

Returns a type modelling a List whose elements are of type elementType.

Returns
  • a java.io.Serializable serializable parameterized type.

public static ParameterizedType mapOf (Type keyType, Type valueType)

Returns a type modelling a Map whose keys are of type keyType and whose values are of type valueType.

Returns
  • a java.io.Serializable serializable parameterized type.

public static ParameterizedType newParameterizedType (Type rawType, Type... typeArguments)

Returns a new parameterized type, applying typeArguments to rawType. The returned type does not have an owner type.

Returns
  • a java.io.Serializable serializable parameterized type.

public static ParameterizedType newParameterizedTypeWithOwner (Type ownerType, Type rawType, Type... typeArguments)

Returns a new parameterized type, applying typeArguments to rawType and enclosed by ownerType.

Returns
  • a java.io.Serializable serializable parameterized type.

public static ParameterizedType providerOf (Type providedType)

Returns a type modelling a Provider that provides elements of type elementType.

Returns
  • a java.io.Serializable serializable parameterized type.

public static ParameterizedType setOf (Type elementType)

Returns a type modelling a Set whose elements are of type elementType.

Returns
  • a java.io.Serializable serializable parameterized type.

public static WildcardType subtypeOf (Type bound)

Returns a type that represents an unknown type that extends bound. For example, if bound is CharSequence.class, this returns ? extends CharSequence. If bound is Object.class, this returns ?, which is shorthand for ? extends Object.

public static WildcardType supertypeOf (Type bound)

Returns a type that represents an unknown supertype of bound. For example, if bound is String.class, this returns ? super String.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/util/Providers.html0000755000175000017500000004631011704661106030612 0ustar tonytony Providers | Guice
public final class

Providers

extends Object
java.lang.Object
   ↳ com.google.inject.util.Providers

Class Overview

Static utility methods for creating and working with instances of Provider.

Summary

Public Methods
static <T> Provider<T> guicify(Provider<T> provider)
Returns a Guice-friendly com.google.inject.Provider for the given JSR-330 javax.inject.Provider.
static <T> Provider<T> of(T instance)
Returns a provider which always provides instance.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Provider<T> guicify (Provider<T> provider)

Returns a Guice-friendly com.google.inject.Provider for the given JSR-330 javax.inject.Provider. The converse method is unnecessary, since Guice providers directly implement the JSR-330 interface.

public static Provider<T> of (T instance)

Returns a provider which always provides instance. This should not be necessary to use in your application, but is helpful for several types of unit tests.

Parameters
instance the instance that should always be provided. This is also permitted to be null, to enable aggressive testing, although in real life a Guice-supplied Provider will never return null.
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/util/Modules.html0000755000175000017500000006410011704661106030242 0ustar tonytony Modules | Guice
public final class

Modules

extends Object
java.lang.Object
   ↳ com.google.inject.util.Modules

Class Overview

Static utility methods for creating and working with instances of Module.

Summary

Nested Classes
interface Modules.OverriddenModuleBuilder See the EDSL example at override()
Constants
Module EMPTY_MODULE
Public Methods
static Module combine(Module... modules)
Returns a new module that installs all of modules.
static Module combine(Iterable<? extends Module> modules)
Returns a new module that installs all of modules.
static Modules.OverriddenModuleBuilder override(Module... modules)
Returns a builder that creates a module that overlays override modules over the given modules.
static Modules.OverriddenModuleBuilder override(Iterable<? extends Module> modules)
Returns a builder that creates a module that overlays override modules over the given modules.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final Module EMPTY_MODULE

Public Methods

public static Module combine (Module... modules)

Returns a new module that installs all of modules.

public static Module combine (Iterable<? extends Module> modules)

Returns a new module that installs all of modules.

public static Modules.OverriddenModuleBuilder override (Module... modules)

Returns a builder that creates a module that overlays override modules over the given modules. If a key is bound in both sets of modules, only the binding from the override modules is kept. If a single PrivateModule is supplied or all elements are from a single PrivateBinder, then this will overwrite the private bindings. Otherwise, private bindings will not be overwritten unless they are exposed. This can be used to replace the bindings of a production module with test bindings:

 Module functionalTestModule
     = Modules.override(new ProductionModule()).with(new TestModule());
 

Prefer to write smaller modules that can be reused and tested without overrides.

Parameters
modules the modules whose bindings are open to be overridden

public static Modules.OverriddenModuleBuilder override (Iterable<? extends Module> modules)

Returns a builder that creates a module that overlays override modules over the given modules. If a key is bound in both sets of modules, only the binding from the override modules is kept. If a single PrivateModule is supplied or all elements are from a single PrivateBinder, then this will overwrite the private bindings. Otherwise, private bindings will not be overwritten unless they are exposed. This can be used to replace the bindings of a production module with test bindings:

 Module functionalTestModule
     = Modules.override(getProductionModules()).with(getTestModules());
 

Prefer to write smaller modules that can be reused and tested without overrides.

Parameters
modules the modules whose bindings are open to be overridden
././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/util/Modules.OverriddenModuleBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/util/Modules.OverriddenMo0000755000175000017500000003470311704661106031701 0ustar tonytony Modules.OverriddenModuleBuilder | Guice
public static interface

Modules.OverriddenModuleBuilder

com.google.inject.util.Modules.OverriddenModuleBuilder

Class Overview

See the EDSL example at override().

Summary

Public Methods
abstract Module with(Module... overrides)
See the EDSL example at override().
abstract Module with(Iterable<? extends Module> overrides)
See the EDSL example at override().

Public Methods

public abstract Module with (Module... overrides)

See the EDSL example at override().

public abstract Module with (Iterable<? extends Module> overrides)

See the EDSL example at override().

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/tools/0000755000175000017500000000000011704661106026123 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/tools/jmx/0000755000175000017500000000000011704661106026721 5ustar tonytony././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/tools/jmx/package-summary.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/tools/jmx/package-summary0000755000175000017500000002536011704661106031743 0ustar tonytony com.google.inject.tools.jmx | Guice
package

com.google.inject.tools.jmx

Classes | Description

JMX integration; this extension requires guice-jmx-3.0.jar.

more...

Interfaces

ManagedBindingMBean JMX interface to bindings. 

Classes

Manager Provides a JMX interface to Guice. 
././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/tools/jmx/package-descr.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/tools/jmx/package-descr.h0000755000175000017500000002346711704661106031602 0ustar tonytony com.google.inject.tools.jmx Details | Guice
package

com.google.inject.tools.jmx

Classes | Description

JMX integration; this extension requires guice-jmx-3.0.jar.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/tools/jmx/Manager.html0000755000175000017500000005266311704661106031200 0ustar tonytony Manager | Guice
public class

Manager

extends Object
java.lang.Object
   ↳ com.google.inject.tools.jmx.Manager

Class Overview

Provides a JMX interface to Guice.

Summary

Public Constructors
Manager()
Public Methods
static void main(String[] args)
Run with no arguments for usage instructions.
static void manage(String domain, Injector injector)
Registers all the bindings of an Injector with the platform MBean server.
static void manage(MBeanServer server, String domain, Injector injector)
Registers all the bindings of an Injector with the given MBean server.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Manager ()

Public Methods

public static void main (String[] args)

Run with no arguments for usage instructions.

Throws
Exception

public static void manage (String domain, Injector injector)

Registers all the bindings of an Injector with the platform MBean server. Consider using the name of your root Module class as the domain.

public static void manage (MBeanServer server, String domain, Injector injector)

Registers all the bindings of an Injector with the given MBean server. Consider using the name of your root Module class as the domain.

././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/tools/jmx/ManagedBindingMBean.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/tools/jmx/ManagedBindingM0000755000175000017500000003422111704661106031615 0ustar tonytony ManagedBindingMBean | Guice
public interface

ManagedBindingMBean

com.google.inject.tools.jmx.ManagedBindingMBean

Class Overview

JMX interface to bindings.

Summary

Public Methods
abstract String getKey()
Gets the binding key.
abstract String getProvider()
Gets the provider to which this binding is bound.
abstract String getSource()
Gets the source of this binding.

Public Methods

public abstract String getKey ()

Gets the binding key.

public abstract String getProvider ()

Gets the provider to which this binding is bound.

public abstract String getSource ()

Gets the source of this binding.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/throwingproviders/0000755000175000017500000000000011704661106030562 5ustar tonytony././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/throwingproviders/package-summary.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/throwingproviders/package0000755000175000017500000003115411704661106032107 0ustar tonytony com.google.inject.throwingproviders | Guice
package

com.google.inject.throwingproviders

Classes | Description

Extension for injecting objects that may throw at provision time; this extension requires guice-throwingproviders-3.0.jar.

more...

Interfaces

CheckedProvider<T> Alternative to the Guice Provider that throws a checked Exception. 
ThrowingProvider<T, E extends Exception> This interface is deprecated. use CheckedProvider instead.  

Classes

././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/throwingproviders/package-descr.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/throwingproviders/package0000755000175000017500000002501711704661106032110 0ustar tonytony com.google.inject.throwingproviders Details | Guice
package

com.google.inject.throwingproviders

Classes | Description

Extension for injecting objects that may throw at provision time; this extension requires guice-throwingproviders-3.0.jar.

././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/throwingproviders/ThrowingProviderBinder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/throwingproviders/Throwin0000755000175000017500000005436211704661106032154 0ustar tonytony ThrowingProviderBinder | Guice
public class

ThrowingProviderBinder

extends Object
java.lang.Object
   ↳ com.google.inject.throwingproviders.ThrowingProviderBinder

Class Overview

Builds a binding for a CheckedProvider.

You can use a fluent API and custom providers:

ThrowingProviderBinder.create(binder())
    .bind(RemoteProvider.class, Customer.class)
    .to(RemoteCustomerProvider.class)
    .in(RequestScope.class);
 
or, you can use throwing provider methods:
class MyModule extends AbstractModule {
   configure() {
     ThrowingProviderBinder.install(this, binder());
   }
   
   @CheckedProvides(RemoteProvider.class)
   @RequestScope
   Customer provideCustomer(FlakyCustomerCreator creator) throws RemoteException {
     return creator.getCustomerOrThrow();
   }
 }
 

Summary

Nested Classes
class ThrowingProviderBinder.SecondaryBinder<P extends CheckedProvider>  
Public Methods
<P extends CheckedProvider> SecondaryBinder<P> bind(Class<P> interfaceType, Type valueType)
static ThrowingProviderBinder create(Binder binder)
static Module forModule(Module module)
Returns a module that installs @CheckedProvides methods.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public SecondaryBinder<P> bind (Class<P> interfaceType, Type valueType)

public static ThrowingProviderBinder create (Binder binder)

public static Module forModule (Module module)

Returns a module that installs @CheckedProvides methods.

././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/throwingproviders/ThrowingProviderBinder.SecondaryBinder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/throwingproviders/Throwin0000755000175000017500000006144511704661106032154 0ustar tonytony ThrowingProviderBinder.SecondaryBinder | Guice
public class

ThrowingProviderBinder.SecondaryBinder

extends Object
java.lang.Object
   ↳ com.google.inject.throwingproviders.ThrowingProviderBinder.SecondaryBinder<P extends com.google.inject.throwingproviders.CheckedProvider>

Summary

Public Constructors
ThrowingProviderBinder.SecondaryBinder(Class<P> interfaceType, Type valueType)
Public Methods
SecondaryBinder<P> annotatedWith(Class<? extends Annotation> annotationType)
SecondaryBinder<P> annotatedWith(Annotation annotation)
ScopedBindingBuilder to(P target)
ScopedBindingBuilder to(Key<? extends P> targetKey)
ScopedBindingBuilder to(Class<? extends P> targetType)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ThrowingProviderBinder.SecondaryBinder (Class<P> interfaceType, Type valueType)

Public Methods

public SecondaryBinder<P> annotatedWith (Class<? extends Annotation> annotationType)

public SecondaryBinder<P> annotatedWith (Annotation annotation)

public ScopedBindingBuilder to (P target)

public ScopedBindingBuilder to (Key<? extends P> targetKey)

public ScopedBindingBuilder to (Class<? extends P> targetType)

././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/throwingproviders/ThrowingProvider.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/throwingproviders/Throwin0000755000175000017500000003741311704661106032152 0ustar tonytony ThrowingProvider | Guice
public interface

ThrowingProvider

implements CheckedProvider<T>
com.google.inject.throwingproviders.ThrowingProvider<T, E extends java.lang.Exception>

This interface is deprecated.
use CheckedProvider instead.

Class Overview

Alternative to the Guice Provider that throws a checked Exception. Users may not inject T directly.

This interface must be extended to use application-specific exception types. Such subinterfaces may not define new methods:

 public interface RemoteProvider<T> extends ThrowingProvider<T, RemoteException> { }
 

When this type is bound using ThrowingProviderBinder, the value returned or exception thrown by get() will be scoped. As a consequence, get() will invoked at most once within each scope.

Summary

Public Methods
abstract T get()
[Expand]
Inherited Methods
From interface com.google.inject.throwingproviders.CheckedProvider

Public Methods

public abstract T get ()

Throws
Exception
././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/throwingproviders/CheckedProvides.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/throwingproviders/Checked0000755000175000017500000003472611704661106032052 0ustar tonytony CheckedProvides | Guice
public abstract @interface

CheckedProvides

implements Annotation
com.google.inject.throwingproviders.CheckedProvides

Class Overview

Annotates methods of a Module to create a CheckedProvider method binding that can throw exceptions. The method's return type is bound to a CheckedProvider that can be injected. Guice will pass dependencies to the method as parameters. Install @CheckedProvides methods by using forModule(com.google.inject.Module) on the module where the methods are declared.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/throwingproviders/CheckedProvider.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/throwingproviders/Checked0000755000175000017500000003624311704661106032046 0ustar tonytony CheckedProvider | Guice
public interface

CheckedProvider

com.google.inject.throwingproviders.CheckedProvider<T>
Known Indirect Subclasses

Class Overview

Alternative to the Guice Provider that throws a checked Exception. Users may not inject T directly.

This interface must be extended to use application-specific exception types. Such subinterfaces may not define new methods, but may narrow the exception type.

 public interface RemoteProvider<T> extends CheckedProvider<T> { 
   T get() throws CustomExceptionOne, CustomExceptionTwo;
 }
 

When this type is bound using ThrowingProviderBinder, the value returned or exception thrown by get() will be scoped. As a consequence, get() will invoked at most once within each scope.

Summary

Public Methods
abstract T get()

Public Methods

public abstract T get ()

Throws
Exception
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spring/0000755000175000017500000000000011704661106026265 5ustar tonytony././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spring/package-summary.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spring/package-summary.ht0000755000175000017500000002403011704661106031712 0ustar tonytony com.google.inject.spring | Guice
package

com.google.inject.spring

Classes | Description

Spring integration; this extension requires guice-spring-3.0.jar.

more...

Classes

SpringIntegration Integrates Guice with Spring. 
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spring/package-descr.html0000755000175000017500000002300011704661106031642 0ustar tonytony com.google.inject.spring Details | Guice
package

com.google.inject.spring

Classes | Description

Spring integration; this extension requires guice-spring-3.0.jar.

././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spring/SpringIntegration.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spring/SpringIntegration.0000755000175000017500000004542611704661106031752 0ustar tonytony SpringIntegration | Guice
public class

SpringIntegration

extends Object
java.lang.Object
   ↳ com.google.inject.spring.SpringIntegration

Class Overview

Integrates Guice with Spring.

Summary

Public Methods
static void bindAll(Binder binder, ListableBeanFactory beanFactory)
Binds all Spring beans from the given factory by name.
static <T> Provider<T> fromSpring(Class<T> type, String name)
Creates a provider which looks up objects from Spring using the given name.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static void bindAll (Binder binder, ListableBeanFactory beanFactory)

Binds all Spring beans from the given factory by name. For a Spring bean named "foo", this method creates a binding to the bean's type and @Named("foo").

public static Provider<T> fromSpring (Class<T> type, String name)

Creates a provider which looks up objects from Spring using the given name. Expects a binding to org.springframework.beans.factory.BeanFactory. Example usage:

 bind(DataSource.class)
   .toProvider(fromSpring(DataSource.class, "dataSource"));
 

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/0000755000175000017500000000000011704661106025556 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/package-summary.html0000755000175000017500000006707111704661106031550 0ustar tonytony com.google.inject.spi | Guice
package

com.google.inject.spi

Classes | Description

Guice service provider interface

Interfaces

BindingScopingVisitor<V> Visits each of the strategies used to scope an injection. 
BindingTargetVisitor<T, V> Visits each of the strategies used to find an instance to satisfy an injection. 
ConstructorBinding<T> A binding to the constructor of a concrete clss. 
ConvertedConstantBinding<T> A binding created from converting a bound instance to a new type. 
Element A core component of a module or injector. 
ElementVisitor<V> Visit elements. 
ExposedBinding<T> A binding to a key exposed from an enclosed private environment. 
HasDependencies Implemented by bindings, providers and instances that expose their dependencies explicitly. 
InjectionListener<I> Listens for injections into instances of type I
InstanceBinding<T> A binding to a single instance. 
LinkedKeyBinding<T> A binding to a linked key. 
PrivateElements A private collection of elements that are hidden from the enclosing injector or module by default. 
ProviderBinding<T extends Provider<?>> A binding to a Provider that delegates to the binding for the provided type. 
ProviderInstanceBinding<T> A binding to a provider instance. 
ProviderKeyBinding<T> A binding to a provider key. 
ProviderWithDependencies<T> A provider with dependencies on other injected types. 
ProviderWithExtensionVisitor<T> A Provider that is part of an extension which supports a custom BindingTargetVisitor. 
TypeConverter Converts constant string values to a different type. 
TypeEncounter<I> Context of an injectable type encounter. 
TypeListener Listens for Guice to encounter injectable types. 
UntargettedBinding<T> An untargetted binding. 

Classes

DefaultBindingScopingVisitor<V> No-op visitor for subclassing. 
DefaultBindingTargetVisitor<T, V> No-op visitor for subclassing. 
DefaultElementVisitor<V> No-op visitor for subclassing. 
Dependency<T> A variable that can be resolved by an injector. 
DisableCircularProxiesOption A request to disable circular proxies. 
Elements Exposes elements of a module so they can be inspected, validated or rewritten
InjectionPoint A constructor, field or method that can receive injections. 
InjectionRequest<T> A request to inject the instance fields and methods of an instance. 
InterceptorBinding Registration of interceptors for matching methods of matching classes. 
MembersInjectorLookup<T> A lookup of the members injector for a type. 
Message An error message and the context in which it occured. 
ProviderLookup<T> A lookup of the provider for a type. 
RequireExplicitBindingsOption A request to require explicit bindings. 
ScopeBinding Registration of a scope annotation with the scope that implements it. 
StaticInjectionRequest A request to inject the static fields and methods of a type. 
TypeConverterBinding Registration of type converters for matching target types. 
TypeListenerBinding Binds types (picked using a Matcher) to an type listener. 
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/package-descr.html0000755000175000017500000003577511704661106031161 0ustar tonytony com.google.inject.spi Details | Guice
package

com.google.inject.spi

Classes | Description

Guice service provider interface

././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/UntargettedBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/UntargettedBinding.ht0000755000175000017500000005454311704661106031712 0ustar tonytony UntargettedBinding | Guice
public interface

UntargettedBinding

implements Binding<T>
com.google.inject.spi.UntargettedBinding<T>

Class Overview

An untargetted binding. This binding indicates that the injector should use its implicit binding strategies to resolve injections.

Summary

[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element
././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/TypeListenerBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/TypeListenerBinding.h0000755000175000017500000007704311704661106031667 0ustar tonytony TypeListenerBinding | Guice
public final class

TypeListenerBinding

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.TypeListenerBinding

Class Overview

Binds types (picked using a Matcher) to an type listener. Registrations are created explicitly in a module using bindListener(Matcher, TypeListener) statements:

     register(only(new TypeLiteral<PaymentService<CreditCard>>() {}), listener);

Summary

Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
TypeListener getListener()
Returns the registered listener.
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
Matcher<? super TypeLiteral<?>> getTypeMatcher()
Returns the type matcher which chooses which types the listener should be notified of.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public TypeListener getListener ()

Returns the registered listener.

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

public Matcher<? super TypeLiteral<?>> getTypeMatcher ()

Returns the type matcher which chooses which types the listener should be notified of.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/TypeListener.html0000755000175000017500000004565011704661106031110 0ustar tonytony TypeListener | Guice
public interface

TypeListener

com.google.inject.spi.TypeListener

Class Overview

Listens for Guice to encounter injectable types. If a given type has its constructor injected in one situation but only its methods and fields injected in another, Guice will notify this listener once.

Useful for extra type checking, registering injection listeners, and binding method interceptors.

Summary

Public Methods
abstract <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter)
Invoked when Guice encounters a new type eligible for constructor or members injection.

Public Methods

public abstract void hear (TypeLiteral<I> type, TypeEncounter<I> encounter)

Invoked when Guice encounters a new type eligible for constructor or members injection. Called during injector creation (or afterwords if Guice encounters a type at run time and creates a JIT binding).

Parameters
type encountered by Guice
encounter context of this encounter, enables reporting errors, registering injection listeners and binding method interceptors for type.
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/TypeEncounter.html0000755000175000017500000010374011704661106031260 0ustar tonytony TypeEncounter | Guice
public interface

TypeEncounter

com.google.inject.spi.TypeEncounter<I>

Class Overview

Context of an injectable type encounter. Enables reporting errors, registering injection listeners and binding method interceptors for injectable type I. It is an error to use an encounter after the hear() method has returned.

Summary

Public Methods
abstract void addError(Message message)
Records an error message to be presented to the user at a later time.
abstract void addError(String message, Object... arguments)
Records an error message for type I which will be presented to the user at a later time.
abstract void addError(Throwable t)
Records an exception for type I, the full details of which will be logged, and the message of which will be presented to the user at a later time.
abstract void bindInterceptor(Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)
Binds method interceptor[s] to methods matched in type I and its supertypes.
abstract <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral)
Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
abstract <T> MembersInjector<T> getMembersInjector(Class<T> type)
Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
abstract <T> Provider<T> getProvider(Key<T> key)
Returns the provider used to obtain instances for the given injection key.
abstract <T> Provider<T> getProvider(Class<T> type)
Returns the provider used to obtain instances for the given injection type.
abstract void register(MembersInjector<? super I> membersInjector)
Registers a members injector for type I.
abstract void register(InjectionListener<? super I> listener)
Registers an injection listener for type I.

Public Methods

public abstract void addError (Message message)

Records an error message to be presented to the user at a later time.

public abstract void addError (String message, Object... arguments)

Records an error message for type I which will be presented to the user at a later time. Unlike throwing an exception, this enable us to continue configuring the Injector and discover more errors. Uses format(String, Object[]) to insert the arguments into the message.

public abstract void addError (Throwable t)

Records an exception for type I, the full details of which will be logged, and the message of which will be presented to the user at a later time. If your type listener calls something that you worry may fail, you should catch the exception and pass it to this method.

public abstract void bindInterceptor (Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)

Binds method interceptor[s] to methods matched in type I and its supertypes. A method is eligible for interception if:

  • Guice created the instance the method is on
  • Neither the enclosing type nor the method is final
  • And the method is package-private or more accessible

Parameters
methodMatcher matches methods the interceptor should apply to. For example: annotatedWith(Transactional.class).
interceptors to bind

public abstract MembersInjector<T> getMembersInjector (TypeLiteral<T> typeLiteral)

Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. The returned members injector will not be valid until the main injector has been created. The members injector will throw an IllegalStateException if you try to use it beforehand.

Parameters
typeLiteral type to get members injector for

public abstract MembersInjector<T> getMembersInjector (Class<T> type)

Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. The returned members injector will not be valid until the main injector has been created. The members injector will throw an IllegalStateException if you try to use it beforehand.

Parameters
type type to get members injector for

public abstract Provider<T> getProvider (Key<T> key)

Returns the provider used to obtain instances for the given injection key. The returned provider will not be valid until the injector has been created. The provider will throw an IllegalStateException if you try to use it beforehand.

public abstract Provider<T> getProvider (Class<T> type)

Returns the provider used to obtain instances for the given injection type. The returned provider will not be valid until the injetor has been created. The provider will throw an IllegalStateException if you try to use it beforehand.

public abstract void register (MembersInjector<? super I> membersInjector)

Registers a members injector for type I. Guice will use the members injector after its performed its own injections on an instance of I.

public abstract void register (InjectionListener<? super I> listener)

Registers an injection listener for type I. Guice will notify the listener after all injections have been performed on an instance of I.

././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/TypeConverterBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/TypeConverterBinding.0000755000175000017500000010452511704661106031675 0ustar tonytony TypeConverterBinding | Guice
public final class

TypeConverterBinding

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.TypeConverterBinding

Class Overview

Registration of type converters for matching target types. Instances are created explicitly in a module using convertToTypes() statements:

     convertToTypes(Matchers.only(TypeLiteral.get(DateTime.class)), new DateTimeConverter());

Summary

Public Constructors
TypeConverterBinding(Object source, Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter typeConverter)
Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
TypeConverter getTypeConverter()
Matcher<? super TypeLiteral<?>> getTypeMatcher()
String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Constructors

public TypeConverterBinding (Object source, Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter typeConverter)

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

public TypeConverter getTypeConverter ()

public Matcher<? super TypeLiteral<?>> getTypeMatcher ()

public String toString ()

Since: API Level

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/TypeConverter.html0000755000175000017500000004300411704661106031261 0ustar tonytony TypeConverter | Guice
public interface

TypeConverter

com.google.inject.spi.TypeConverter

Class Overview

Converts constant string values to a different type.

Summary

Public Methods
abstract Object convert(String value, TypeLiteral<?> toType)
Converts a string value.

Public Methods

public abstract Object convert (String value, TypeLiteral<?> toType)

Converts a string value. Throws an exception if a conversion error occurs.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/Toolable.html0000755000175000017500000004642211704661106030220 0ustar tonytony Toolable | Guice
public abstract @interface

Toolable

implements Annotation
com.google.inject.spi.Toolable

Class Overview

Instructs an Injector running in TOOL that a method should be injected. This is typically useful for for extensions to Guice that perform additional validation in an injected method or field. This only applies to objects that are already constructed when bindings are created (ie., something bound using toProvider, toInstance, or requestInjection.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/StaticInjectionRequest.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/StaticInjectionReques0000755000175000017500000010011111704661106031755 0ustar tonytony StaticInjectionRequest | Guice
public final class

StaticInjectionRequest

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.StaticInjectionRequest

Class Overview

A request to inject the static fields and methods of a type. Requests are created explicitly in a module using requestStaticInjection() statements:

     requestStaticInjection(MyLegacyService.class);

Summary

Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Set<InjectionPoint> getInjectionPoints()
Returns the static methods and fields of type that will be injected to fulfill this request.
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
Class<?> getType()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Set<InjectionPoint> getInjectionPoints ()

Returns the static methods and fields of type that will be injected to fulfill this request.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

public Class<?> getType ()

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ScopeBinding.html0000755000175000017500000007552011704661106031024 0ustar tonytony ScopeBinding | Guice
public final class

ScopeBinding

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.ScopeBinding

Class Overview

Registration of a scope annotation with the scope that implements it. Instances are created explicitly in a module using bindScope() statements:

     Scope recordScope = new RecordScope();
     bindScope(RecordScoped.class, new RecordScope());

Summary

Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Class<? extends Annotation> getAnnotationType()
Scope getScope()
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Class<? extends Annotation> getAnnotationType ()

public Scope getScope ()

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/RequireExplicitBindingsOption.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/RequireExplicitBindin0000755000175000017500000007060011704661106031751 0ustar tonytony RequireExplicitBindingsOption | Guice
public final class

RequireExplicitBindingsOption

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.RequireExplicitBindingsOption

Class Overview

A request to require explicit bindings.

Summary

Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ProviderWithExtensionVisitor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ProviderWithExtension0000755000175000017500000005476111704661106032044 0ustar tonytony ProviderWithExtensionVisitor | Guice
public interface

ProviderWithExtensionVisitor

implements Provider<T>
com.google.inject.spi.ProviderWithExtensionVisitor<T>

Class Overview

A Provider that is part of an extension which supports a custom BindingTargetVisitor.

When an extension binds a provider instance, the provider can implement this interface to allow users using the acceptTargetVisitor(BindingTargetVisitor) method to visit a custom visitor designed for that extension. A typical implementation within the extension would look like

 
 <V, B> V acceptExtensionVisitor(BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding) {
   if(visitor instanceof MyCustomExtensionVisitor) {
     return ((MyCustomExtensionVisitor<B, V>)visitor).visitCustomExtension(customProperties, binding);
   } else {
     return visitor.visit(binding);
   }
 }
'MyCustomExtensionVisitor' in the example above would be an interface the extension provides that users can implement in order to be notified of custom extension information. These visitor interfaces must extend from BindingTargetVisitor.

Summary

Public Methods
abstract <B, V> V acceptExtensionVisitor(BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding)
Instructs the extension determine if the visitor is an instance of a custom extension visitor, and if so, visit it using that method.
[Expand]
Inherited Methods
From interface com.google.inject.Provider
From interface javax.inject.Provider

Public Methods

public abstract V acceptExtensionVisitor (BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding)

Instructs the extension determine if the visitor is an instance of a custom extension visitor, and if so, visit it using that method. If the visitor is not an instance of the custom extension visitor, this method MUST call visitor.visit(binding).

Due to issues with generics, the type parameters of this method do not relate to the type of the provider. In practice, the 'B' type will always be a supertype of 'T'.

././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ProviderWithDependencies.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ProviderWithDependenc0000755000175000017500000005114611704661106031747 0ustar tonytony ProviderWithDependencies | Guice
public interface

ProviderWithDependencies

implements Provider<T> HasDependencies
com.google.inject.spi.ProviderWithDependencies<T>

Class Overview

A provider with dependencies on other injected types. If a Provider has dependencies that aren't specified in injections, this interface should be used to expose all dependencies.

Summary

[Expand]
Inherited Methods
From interface com.google.inject.Provider
From interface com.google.inject.spi.HasDependencies
From interface javax.inject.Provider
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ProviderLookup.html0000755000175000017500000010724411704661106031443 0ustar tonytony ProviderLookup | Guice
public final class

ProviderLookup

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.ProviderLookup<T>

Class Overview

A lookup of the provider for a type. Lookups are created explicitly in a module using getProvider() statements:

     Provider<PaymentService> paymentServiceProvider
         = getProvider(PaymentService.class);

Summary

Public Constructors
ProviderLookup(Object source, Key<T> key)
Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Provider<T> getDelegate()
Returns the delegate provider, or null if it has not yet been initialized.
Key<T> getKey()
Provider<T> getProvider()
Returns the looked up provider.
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
void initializeDelegate(Provider<T> delegate)
Sets the actual provider.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Constructors

public ProviderLookup (Object source, Key<T> key)

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Provider<T> getDelegate ()

Returns the delegate provider, or null if it has not yet been initialized. The delegate will be initialized when this element is processed, or otherwise used to create an injector.

public Key<T> getKey ()

public Provider<T> getProvider ()

Returns the looked up provider. The result is not valid until this lookup has been initialized, which usually happens when the injector is created. The provider will throw an IllegalStateException if you try to use it beforehand.

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

public void initializeDelegate (Provider<T> delegate)

Sets the actual provider.

Throws
IllegalStateException if the delegate is already set
././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ProviderKeyBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ProviderKeyBinding.ht0000755000175000017500000006026711704661106031667 0ustar tonytony ProviderKeyBinding | Guice
public interface

ProviderKeyBinding

implements Binding<T>
com.google.inject.spi.ProviderKeyBinding<T>

Class Overview

A binding to a provider key. To resolve injections, the provider key is first resolved, then that provider's get method is invoked.

Summary

Public Methods
abstract Key<? extends Provider<? extends T>> getProviderKey()
Returns the key used to resolve the provider's binding.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element

Public Methods

public abstract Key<? extends Provider<? extends T>> getProviderKey ()

Returns the key used to resolve the provider's binding. That binding can be retrieved from an injector using Injector.getBinding(providerKey)

././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ProviderInstanceBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ProviderInstanceBindi0000755000175000017500000006615311704661106031744 0ustar tonytony ProviderInstanceBinding | Guice
public interface

ProviderInstanceBinding

implements Binding<T> HasDependencies
com.google.inject.spi.ProviderInstanceBinding<T>

Class Overview

A binding to a provider instance. The provider's get method is invoked to resolve injections.

Summary

Public Methods
abstract Set<InjectionPoint> getInjectionPoints()
Returns the field and method injection points of the provider, injected at injector-creation time only.
abstract Provider<? extends T> getProviderInstance()
Returns the user-supplied, unscoped provider.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element
From interface com.google.inject.spi.HasDependencies

Public Methods

public abstract Set<InjectionPoint> getInjectionPoints ()

Returns the field and method injection points of the provider, injected at injector-creation time only.

Returns
  • a possibly empty set

public abstract Provider<? extends T> getProviderInstance ()

Returns the user-supplied, unscoped provider.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ProviderBinding.html0000755000175000017500000006071611704661106031546 0ustar tonytony ProviderBinding | Guice
public interface

ProviderBinding

implements Binding<T>
com.google.inject.spi.ProviderBinding<T extends com.google.inject.Provider<?>>

Class Overview

A binding to a Provider that delegates to the binding for the provided type. This binding is used whenever a Provider<T> is injected (as opposed to injecting T directly).

Summary

Public Methods
abstract Key<?> getProvidedKey()
Returns the key whose binding is used to provide instances.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element

Public Methods

public abstract Key<?> getProvidedKey ()

Returns the key whose binding is used to provide instances. That binding can be retrieved from an injector using Injector.getBinding(providedKey)

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/PrivateElements.html0000755000175000017500000006264711704661106031575 0ustar tonytony PrivateElements | Guice
public interface

PrivateElements

implements Element
com.google.inject.spi.PrivateElements

Class Overview

A private collection of elements that are hidden from the enclosing injector or module by default. See PrivateModule for details.

Summary

Public Methods
abstract List<Element> getElements()
Returns the configuration information in this private environment.
abstract Set<Key<?>> getExposedKeys()
Returns the unique exposed keys for these private elements.
abstract Object getExposedSource(Key<?> key)
Returns an arbitrary object containing information about the "place" where this key was exposed.
abstract Injector getInjector()
Returns the child injector that hosts these private elements, or null if the elements haven't been used to create an injector.
[Expand]
Inherited Methods
From interface com.google.inject.spi.Element

Public Methods

public abstract List<Element> getElements ()

Returns the configuration information in this private environment.

public abstract Set<Key<?>> getExposedKeys ()

Returns the unique exposed keys for these private elements.

public abstract Object getExposedSource (Key<?> key)

Returns an arbitrary object containing information about the "place" where this key was exposed. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

Parameters
key one of the keys exposed by this module.

public abstract Injector getInjector ()

Returns the child injector that hosts these private elements, or null if the elements haven't been used to create an injector.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/Message.html0000755000175000017500000011473111704661106030042 0ustar tonytony Message | Guice
public final class

Message

extends Object
implements Element Serializable
java.lang.Object
   ↳ com.google.inject.spi.Message

Class Overview

An error message and the context in which it occured. Messages are usually created internally by Guice and its extensions. Messages can be created explicitly in a module using addError() statements:

     try {
       bindPropertiesFromFile();
     } catch (IOException e) {
       addError(e);
     }

Summary

Public Constructors
Message(Object source, String message)
Message(String message)
Message(List<Object> sources, String message, Throwable cause)
Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
boolean equals(Object o)
Throwable getCause()
Returns the throwable that caused this message, or null if this message was not caused by a throwable.
String getMessage()
Gets the error message text.
String getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
List<Object> getSources()
int hashCode()
String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Constructors

public Message (Object source, String message)

public Message (String message)

public Message (List<Object> sources, String message, Throwable cause)

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public boolean equals (Object o)

Since: API Level

public Throwable getCause ()

Returns the throwable that caused this message, or null if this message was not caused by a throwable.

public String getMessage ()

Gets the error message text.

public String getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

public List<Object> getSources ()

public int hashCode ()

Since: API Level

public String toString ()

Since: API Level

././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/MembersInjectorLookup.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/MembersInjectorLookup0000755000175000017500000011031411704661106031766 0ustar tonytony MembersInjectorLookup | Guice
public final class

MembersInjectorLookup

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.MembersInjectorLookup<T>

Class Overview

A lookup of the members injector for a type. Lookups are created explicitly in a module using getMembersInjector() statements:

     MembersInjector<PaymentService> membersInjector
         = getMembersInjector(PaymentService.class);

Summary

Public Constructors
MembersInjectorLookup(Object source, TypeLiteral<T> type)
Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
MembersInjector<T> getDelegate()
Returns the delegate members injector, or null if it has not yet been initialized.
MembersInjector<T> getMembersInjector()
Returns the looked up members injector.
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
TypeLiteral<T> getType()
Gets the type containing the members to be injected.
void initializeDelegate(MembersInjector<T> delegate)
Sets the actual members injector.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Constructors

public MembersInjectorLookup (Object source, TypeLiteral<T> type)

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public MembersInjector<T> getDelegate ()

Returns the delegate members injector, or null if it has not yet been initialized. The delegate will be initialized when this element is processed, or otherwise used to create an injector.

public MembersInjector<T> getMembersInjector ()

Returns the looked up members injector. The result is not valid until this lookup has been initialized, which usually happens when the injector is created. The members injector will throw an IllegalStateException if you try to use it beforehand.

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

public TypeLiteral<T> getType ()

Gets the type containing the members to be injected.

public void initializeDelegate (MembersInjector<T> delegate)

Sets the actual members injector.

Throws
IllegalStateException if the delegate is already set
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/LinkedKeyBinding.html0000755000175000017500000006001611704661106031624 0ustar tonytony LinkedKeyBinding | Guice
public interface

LinkedKeyBinding

implements Binding<T>
com.google.inject.spi.LinkedKeyBinding<T>

Class Overview

A binding to a linked key. The other key's binding is used to resolve injections.

Summary

Public Methods
abstract Key<? extends T> getLinkedKey()
Returns the linked key used to resolve injections.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element

Public Methods

public abstract Key<? extends T> getLinkedKey ()

Returns the linked key used to resolve injections. That binding can be retrieved from an injector using Injector.getBinding(key).

././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/InterceptorBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/InterceptorBinding.ht0000755000175000017500000010117211704661106031711 0ustar tonytony InterceptorBinding | Guice
public final class

InterceptorBinding

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.InterceptorBinding

Class Overview

Registration of interceptors for matching methods of matching classes. Instances are created explicitly in a module using bindInterceptor() statements:

     bindInterceptor(Matchers.subclassesOf(MyAction.class),
         Matchers.annotatedWith(Transactional.class),
         new MyTransactionInterceptor());
or from an injectable type listener using TypeEncounter.bindInterceptor().

Summary

Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Matcher<? super Class<?>> getClassMatcher()
List<MethodInterceptor> getInterceptors()
Matcher<? super Method> getMethodMatcher()
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Matcher<? super Class<?>> getClassMatcher ()

public List<MethodInterceptor> getInterceptors ()

public Matcher<? super Method> getMethodMatcher ()

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/InstanceBinding.html0000755000175000017500000006547211704661106031524 0ustar tonytony InstanceBinding | Guice
public interface

InstanceBinding

implements Binding<T> HasDependencies
com.google.inject.spi.InstanceBinding<T>

Class Overview

A binding to a single instance. The same instance is returned for every injection.

Summary

Public Methods
abstract Set<InjectionPoint> getInjectionPoints()
Returns the field and method injection points of the instance, injected at injector-creation time only.
abstract T getInstance()
Returns the user-supplied instance.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element
From interface com.google.inject.spi.HasDependencies

Public Methods

public abstract Set<InjectionPoint> getInjectionPoints ()

Returns the field and method injection points of the instance, injected at injector-creation time only.

Returns
  • a possibly empty set

public abstract T getInstance ()

Returns the user-supplied instance.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/InjectionRequest.html0000755000175000017500000010461411704661106031750 0ustar tonytony InjectionRequest | Guice
public final class

InjectionRequest

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.InjectionRequest<T>

Class Overview

A request to inject the instance fields and methods of an instance. Requests are created explicitly in a module using requestInjection() statements:

     requestInjection(serviceInstance);

Summary

Public Constructors
InjectionRequest(Object source, TypeLiteral<T> type, T instance)
Public Methods
<R> R acceptVisitor(ElementVisitor<R> visitor)
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Set<InjectionPoint> getInjectionPoints()
Returns the instance methods and fields of instance that will be injected to fulfill this request.
T getInstance()
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
TypeLiteral<T> getType()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Constructors

public InjectionRequest (Object source, TypeLiteral<T> type, T instance)

Public Methods

public R acceptVisitor (ElementVisitor<R> visitor)

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Set<InjectionPoint> getInjectionPoints ()

Returns the instance methods and fields of instance that will be injected to fulfill this request.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on the class of instance, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public T getInstance ()

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

public TypeLiteral<T> getType ()

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/InjectionPoint.html0000755000175000017500000014436111704661106031414 0ustar tonytony InjectionPoint | Guice
public final class

InjectionPoint

extends Object
java.lang.Object
   ↳ com.google.inject.spi.InjectionPoint

Class Overview

A constructor, field or method that can receive injections. Typically this is a member with the @Inject annotation. For non-private, no argument constructors, the member may omit the annotation.

Summary

Public Methods
boolean equals(Object o)
static <T> InjectionPoint forConstructor(Constructor<T> constructor)
Returns a new injection point for the specified constructor.
static <T> InjectionPoint forConstructor(Constructor<T> constructor, TypeLiteral<? extends T> type)
Returns a new injection point for the specified constructor of type.
static InjectionPoint forConstructorOf(TypeLiteral<?> type)
Returns a new injection point for the injectable constructor of type.
static InjectionPoint forConstructorOf(Class<?> type)
Returns a new injection point for the injectable constructor of type.
static Set<InjectionPoint> forInstanceMethodsAndFields(TypeLiteral<?> type)
Returns all instance method and field injection points on type.
static Set<InjectionPoint> forInstanceMethodsAndFields(Class<?> type)
Returns all instance method and field injection points on type.
static Set<InjectionPoint> forStaticMethodsAndFields(TypeLiteral<?> type)
Returns all static method and field injection points on type.
static Set<InjectionPoint> forStaticMethodsAndFields(Class<?> type)
Returns all static method and field injection points on type.
TypeLiteral<?> getDeclaringType()
Returns the generic type that defines this injection point.
List<Dependency<?>> getDependencies()
Returns the dependencies for this injection point.
Member getMember()
Returns the injected constructor, field, or method.
int hashCode()
boolean isOptional()
Returns true if this injection point shall be skipped if the injector cannot resolve bindings for all required dependencies.
boolean isToolable()
Returns true if the element is annotated with @Toolable.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public boolean equals (Object o)

Since: API Level

public static InjectionPoint forConstructor (Constructor<T> constructor)

Returns a new injection point for the specified constructor. If the declaring type of constructor is parameterized (such as List<T>), prefer the overload that includes a type literal.

Parameters
constructor any single constructor present on type.

public static InjectionPoint forConstructor (Constructor<T> constructor, TypeLiteral<? extends T> type)

Returns a new injection point for the specified constructor of type.

Parameters
constructor any single constructor present on type.
type the concrete type that defines constructor.

public static InjectionPoint forConstructorOf (TypeLiteral<?> type)

Returns a new injection point for the injectable constructor of type.

Parameters
type a concrete type with exactly one constructor annotated @Inject, or a no-arguments constructor that is not private.
Throws
ConfigurationException if there is no injectable constructor, more than one injectable constructor, or if parameters of the injectable constructor are malformed, such as a parameter with multiple binding annotations.

public static InjectionPoint forConstructorOf (Class<?> type)

Returns a new injection point for the injectable constructor of type.

Parameters
type a concrete type with exactly one constructor annotated @Inject, or a no-arguments constructor that is not private.
Throws
ConfigurationException if there is no injectable constructor, more than one injectable constructor, or if parameters of the injectable constructor are malformed, such as a parameter with multiple binding annotations.

public static Set<InjectionPoint> forInstanceMethodsAndFields (TypeLiteral<?> type)

Returns all instance method and field injection points on type.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public static Set<InjectionPoint> forInstanceMethodsAndFields (Class<?> type)

Returns all instance method and field injection points on type.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public static Set<InjectionPoint> forStaticMethodsAndFields (TypeLiteral<?> type)

Returns all static method and field injection points on type.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public static Set<InjectionPoint> forStaticMethodsAndFields (Class<?> type)

Returns all static method and field injection points on type.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
Throws
ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

public TypeLiteral<?> getDeclaringType ()

Returns the generic type that defines this injection point. If the member exists on a parameterized type, the result will include more type information than the member's raw declaring class.

public List<Dependency<?>> getDependencies ()

Returns the dependencies for this injection point. If the injection point is for a method or constructor, the dependencies will correspond to that member's parameters. Field injection points always have a single dependency for the field itself.

Returns
  • a possibly-empty list

public Member getMember ()

Returns the injected constructor, field, or method.

public int hashCode ()

Since: API Level

public boolean isOptional ()

Returns true if this injection point shall be skipped if the injector cannot resolve bindings for all required dependencies. Both explicit bindings (as specified in a module), and implicit bindings (@ImplementedBy, default constructors etc.) may be used to satisfy optional injection points.

public boolean isToolable ()

Returns true if the element is annotated with @Toolable.

public String toString ()

Since: API Level

././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/InjectionListener.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/InjectionListener.htm0000755000175000017500000004323411704661106031731 0ustar tonytony InjectionListener | Guice
public interface

InjectionListener

com.google.inject.spi.InjectionListener<I>

Class Overview

Listens for injections into instances of type I. Useful for performing further injections, post-injection initialization, and more.

Summary

Public Methods
abstract void afterInjection(I injectee)
Invoked by Guice after it injects the fields and methods of instance.

Public Methods

public abstract void afterInjection (I injectee)

Invoked by Guice after it injects the fields and methods of instance.

Parameters
injectee instance that Guice injected dependencies into
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/HasDependencies.html0000755000175000017500000005420211704661106031474 0ustar tonytony HasDependencies | Guice
public interface

HasDependencies

com.google.inject.spi.HasDependencies
Known Indirect Subclasses

Class Overview

Implemented by bindings, providers and instances that expose their dependencies explicitly.

Summary

Public Methods
abstract Set<Dependency<?>> getDependencies()
Returns the known dependencies for this type.

Public Methods

public abstract Set<Dependency<?>> getDependencies ()

Returns the known dependencies for this type. If this has dependencies whose values are not known statically, a dependency for the Injector will be included in the returned set.

Returns
  • a possibly empty set
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ExposedBinding.html0000755000175000017500000006572411704661106031367 0ustar tonytony ExposedBinding | Guice
public interface

ExposedBinding

implements Binding<T> HasDependencies
com.google.inject.spi.ExposedBinding<T>

Class Overview

A binding to a key exposed from an enclosed private environment.

Summary

Public Methods
abstract void applyTo(Binder binder)
Unsupported.
abstract PrivateElements getPrivateElements()
Returns the enclosed environment that holds the original binding.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element
From interface com.google.inject.spi.HasDependencies

Public Methods

public abstract void applyTo (Binder binder)

Unsupported. Always throws UnsupportedOperationException.

Parameters
binder to apply configuration element to

public abstract PrivateElements getPrivateElements ()

Returns the enclosed environment that holds the original binding.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/Elements.html0000755000175000017500000007463611704661106030243 0ustar tonytony Elements | Guice
public final class

Elements

extends Object
java.lang.Object
   ↳ com.google.inject.spi.Elements

Class Overview

Exposes elements of a module so they can be inspected, validated or rewritten.

Summary

Public Constructors
Elements()
Public Methods
static List<Element> getElements(Module... modules)
Records the elements executed by modules.
static List<Element> getElements(Stage stage, Module... modules)
Records the elements executed by modules.
static List<Element> getElements(Stage stage, Iterable<? extends Module> modules)
Records the elements executed by modules.
static List<Element> getElements(Iterable<? extends Module> modules)
Records the elements executed by modules.
static Module getModule(Iterable<? extends Element> elements)
Returns the module composed of elements.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Elements ()

Public Methods

public static List<Element> getElements (Module... modules)

Records the elements executed by modules.

public static List<Element> getElements (Stage stage, Module... modules)

Records the elements executed by modules.

public static List<Element> getElements (Stage stage, Iterable<? extends Module> modules)

Records the elements executed by modules.

public static List<Element> getElements (Iterable<? extends Module> modules)

Records the elements executed by modules.

public static Module getModule (Iterable<? extends Element> elements)

Returns the module composed of elements.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ElementVisitor.html0000755000175000017500000010777511704661106031441 0ustar tonytony ElementVisitor | Guice
public interface

ElementVisitor

com.google.inject.spi.ElementVisitor<V>
Known Indirect Subclasses

Class Overview

Visit elements.

Summary

Public Methods
abstract <T> V visit(Binding<T> binding)
Visit a mapping from a key (type and optional annotation) to the strategy for getting instances of the type.
abstract V visit(DisableCircularProxiesOption option)
Visit a disable circular proxies command.
abstract V visit(InjectionRequest<?> request)
Visit a request to inject the instance fields and methods of an instance.
abstract V visit(InterceptorBinding binding)
Visit a registration of interceptors for matching methods of matching classes.
abstract <T> V visit(MembersInjectorLookup<T> lookup)
Visit a lookup of the members injector.
abstract V visit(Message message)
Visit an error message and the context in which it occured.
abstract V visit(PrivateElements elements)
Visit a collection of configuration elements for a private binder.
abstract <T> V visit(ProviderLookup<T> lookup)
Visit a lookup of the provider for a type.
abstract V visit(RequireExplicitBindingsOption option)
Visit a require explicit bindings command.
abstract V visit(ScopeBinding binding)
Visit a registration of a scope annotation with the scope that implements it.
abstract V visit(StaticInjectionRequest request)
Visit a request to inject the static fields and methods of type.
abstract V visit(TypeConverterBinding binding)
Visit a registration of type converters for matching target types.
abstract V visit(TypeListenerBinding binding)
Visit an injectable type listener binding.

Public Methods

public abstract V visit (Binding<T> binding)

Visit a mapping from a key (type and optional annotation) to the strategy for getting instances of the type.

public abstract V visit (DisableCircularProxiesOption option)

Visit a disable circular proxies command.

public abstract V visit (InjectionRequest<?> request)

Visit a request to inject the instance fields and methods of an instance.

public abstract V visit (InterceptorBinding binding)

Visit a registration of interceptors for matching methods of matching classes.

public abstract V visit (MembersInjectorLookup<T> lookup)

Visit a lookup of the members injector.

public abstract V visit (Message message)

Visit an error message and the context in which it occured.

public abstract V visit (PrivateElements elements)

Visit a collection of configuration elements for a private binder.

public abstract V visit (ProviderLookup<T> lookup)

Visit a lookup of the provider for a type.

public abstract V visit (RequireExplicitBindingsOption option)

Visit a require explicit bindings command.

public abstract V visit (ScopeBinding binding)

Visit a registration of a scope annotation with the scope that implements it.

public abstract V visit (StaticInjectionRequest request)

Visit a request to inject the static fields and methods of type.

public abstract V visit (TypeConverterBinding binding)

Visit a registration of type converters for matching target types.

public abstract V visit (TypeListenerBinding binding)

Visit an injectable type listener binding.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/Element.html0000755000175000017500000010103711704661106030042 0ustar tonytony Element | Guice
public interface

Element

com.google.inject.spi.Element
Known Indirect Subclasses

Class Overview

A core component of a module or injector.

The elements of a module can be inspected, validated and rewritten. Use Elements.getElements() to read the elements from a module, and Elements.getModule() to rewrite them. This can be used for static analysis and generation of Guice modules.

The elements of an injector can be inspected and exercised. Use Injector.getBindings() to reflect on Guice injectors.

Summary

Public Methods
abstract <T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
abstract void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
abstract Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.

Public Methods

public abstract T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public abstract void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to
Throws
UnsupportedOperationException if the applyTo method is not supported by this element.

public abstract Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/DisableCircularProxiesOption.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/DisableCircularProxie0000755000175000017500000007057111704661106031735 0ustar tonytony DisableCircularProxiesOption | Guice
public final class

DisableCircularProxiesOption

extends Object
implements Element
java.lang.Object
   ↳ com.google.inject.spi.DisableCircularProxiesOption

Class Overview

A request to disable circular proxies.

Summary

Public Methods
<T> T acceptVisitor(ElementVisitor<T> visitor)
Accepts an element visitor.
void applyTo(Binder binder)
Writes this module element to the given binder (optional operation).
Object getSource()
Returns an arbitrary object containing information about the "place" where this element was configured.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.Element

Public Methods

public T acceptVisitor (ElementVisitor<T> visitor)

Accepts an element visitor. Invokes the visitor method specific to this element's type.

Parameters
visitor to call back on

public void applyTo (Binder binder)

Writes this module element to the given binder (optional operation).

Parameters
binder to apply configuration element to

public Object getSource ()

Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/Dependency.html0000755000175000017500000010112511704661106030525 0ustar tonytony Dependency | Guice
public final class

Dependency

extends Object
java.lang.Object
   ↳ com.google.inject.spi.Dependency<T>

Class Overview

A variable that can be resolved by an injector.

Use get(Key) to build a freestanding dependency, or InjectionPoint to build one that's attached to a constructor, method or field.

Summary

Public Methods
boolean equals(Object o)
static Set<Dependency<?>> forInjectionPoints(Set<InjectionPoint> injectionPoints)
Returns the dependencies from the given injection points.
static <T> Dependency<T> get(Key<T> key)
Returns a new dependency that is not attached to an injection point.
InjectionPoint getInjectionPoint()
Returns the injection point to which this dependency belongs, or null if this dependency isn't attached to a particular injection point.
Key<T> getKey()
Returns the key to the binding that satisfies this dependency.
int getParameterIndex()
Returns the index of this dependency in the injection point's parameter list, or -1 if this dependency does not belong to a parameter list.
int hashCode()
boolean isNullable()
Returns true if null is a legal value for this dependency.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public boolean equals (Object o)

Since: API Level

public static Set<Dependency<?>> forInjectionPoints (Set<InjectionPoint> injectionPoints)

Returns the dependencies from the given injection points.

public static Dependency<T> get (Key<T> key)

Returns a new dependency that is not attached to an injection point. The returned dependency is nullable.

public InjectionPoint getInjectionPoint ()

Returns the injection point to which this dependency belongs, or null if this dependency isn't attached to a particular injection point.

public Key<T> getKey ()

Returns the key to the binding that satisfies this dependency.

public int getParameterIndex ()

Returns the index of this dependency in the injection point's parameter list, or -1 if this dependency does not belong to a parameter list. Only method and constuctor dependencies are elements in a parameter list.

public int hashCode ()

Since: API Level

public boolean isNullable ()

Returns true if null is a legal value for this dependency.

public String toString ()

Since: API Level

././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/DefaultElementVisitor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/DefaultElementVisitor0000755000175000017500000014753711704661106032003 0ustar tonytony DefaultElementVisitor | Guice
public abstract class

DefaultElementVisitor

extends Object
implements ElementVisitor<V>
java.lang.Object
   ↳ com.google.inject.spi.DefaultElementVisitor<V>

Class Overview

No-op visitor for subclassing. All interface methods simply delegate to visitOther(Element), returning its result.

Summary

Public Constructors
DefaultElementVisitor()
Public Methods
<T> V visit(Binding<T> binding)
Visit a mapping from a key (type and optional annotation) to the strategy for getting instances of the type.
V visit(DisableCircularProxiesOption option)
Visit a disable circular proxies command.
V visit(InjectionRequest<?> injectionRequest)
Visit a request to inject the instance fields and methods of an instance.
V visit(InterceptorBinding interceptorBinding)
Visit a registration of interceptors for matching methods of matching classes.
<T> V visit(MembersInjectorLookup<T> lookup)
Visit a lookup of the members injector.
V visit(Message message)
Visit an error message and the context in which it occured.
V visit(PrivateElements privateElements)
Visit a collection of configuration elements for a private binder.
<T> V visit(ProviderLookup<T> providerLookup)
Visit a lookup of the provider for a type.
V visit(RequireExplicitBindingsOption option)
Visit a require explicit bindings command.
V visit(ScopeBinding scopeBinding)
Visit a registration of a scope annotation with the scope that implements it.
V visit(StaticInjectionRequest staticInjectionRequest)
Visit a request to inject the static fields and methods of type.
V visit(TypeConverterBinding typeConverterBinding)
Visit a registration of type converters for matching target types.
V visit(TypeListenerBinding binding)
Visit an injectable type listener binding.
Protected Methods
V visitOther(Element element)
Default visit implementation.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.ElementVisitor

Public Constructors

public DefaultElementVisitor ()

Public Methods

public V visit (Binding<T> binding)

Visit a mapping from a key (type and optional annotation) to the strategy for getting instances of the type.

public V visit (DisableCircularProxiesOption option)

Visit a disable circular proxies command.

public V visit (InjectionRequest<?> injectionRequest)

Visit a request to inject the instance fields and methods of an instance.

public V visit (InterceptorBinding interceptorBinding)

Visit a registration of interceptors for matching methods of matching classes.

public V visit (MembersInjectorLookup<T> lookup)

Visit a lookup of the members injector.

public V visit (Message message)

Visit an error message and the context in which it occured.

public V visit (PrivateElements privateElements)

Visit a collection of configuration elements for a private binder.

public V visit (ProviderLookup<T> providerLookup)

Visit a lookup of the provider for a type.

public V visit (RequireExplicitBindingsOption option)

Visit a require explicit bindings command.

public V visit (ScopeBinding scopeBinding)

Visit a registration of a scope annotation with the scope that implements it.

public V visit (StaticInjectionRequest staticInjectionRequest)

Visit a request to inject the static fields and methods of type.

public V visit (TypeConverterBinding typeConverterBinding)

Visit a registration of type converters for matching target types.

public V visit (TypeListenerBinding binding)

Visit an injectable type listener binding.

Protected Methods

protected V visitOther (Element element)

Default visit implementation. Returns null.

././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/DefaultBindingTargetVisitor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/DefaultBindingTargetV0000755000175000017500000013320611704661106031665 0ustar tonytony DefaultBindingTargetVisitor | Guice
public abstract class

DefaultBindingTargetVisitor

extends Object
implements BindingTargetVisitor<T, V>
java.lang.Object
   ↳ com.google.inject.spi.DefaultBindingTargetVisitor<T, V>

Class Overview

No-op visitor for subclassing. All interface methods simply delegate to visitOther(Binding), returning its result.

Summary

Public Constructors
DefaultBindingTargetVisitor()
Public Methods
V visit(ConstructorBinding<? extends T> constructorBinding)
Visit a constructor binding.
V visit(ConvertedConstantBinding<? extends T> convertedConstantBinding)
Visit a binding created from converting a bound instance to a new type.
V visit(ExposedBinding<? extends T> exposedBinding)
Visit a binding to a key exposed from an enclosed private environment.
V visit(InstanceBinding<? extends T> instanceBinding)
Visit a instance binding.
V visit(LinkedKeyBinding<? extends T> linkedKeyBinding)
Visit a linked key binding.
V visit(ProviderBinding<? extends T> providerBinding)
Visit a binding to a Provider that delegates to the binding for the provided type.
V visit(ProviderInstanceBinding<? extends T> providerInstanceBinding)
Visit a provider instance binding.
V visit(ProviderKeyBinding<? extends T> providerKeyBinding)
Visit a provider key binding.
V visit(UntargettedBinding<? extends T> untargettedBinding)
Visit an untargetted binding.
Protected Methods
V visitOther(Binding<? extends T> binding)
Default visit implementation.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.BindingTargetVisitor

Public Constructors

public DefaultBindingTargetVisitor ()

Public Methods

public V visit (ConstructorBinding<? extends T> constructorBinding)

Visit a constructor binding. To resolve injections, an instance is instantiated by invoking constructor. This target is found only on injector bindings.

public V visit (ConvertedConstantBinding<? extends T> convertedConstantBinding)

Visit a binding created from converting a bound instance to a new type. The source binding has the same binding annotation but a different type. This target is found only on injector bindings.

public V visit (ExposedBinding<? extends T> exposedBinding)

Visit a binding to a key exposed from an enclosed private environment. This target is only found in injector bindings.

public V visit (InstanceBinding<? extends T> instanceBinding)

Visit a instance binding. The same instance is returned for every injection. This target is found in both module and injector bindings.

public V visit (LinkedKeyBinding<? extends T> linkedKeyBinding)

Visit a linked key binding. The other key's binding is used to resolve injections. This target is found in both module and injector bindings.

public V visit (ProviderBinding<? extends T> providerBinding)

Visit a binding to a Provider that delegates to the binding for the provided type. This target is found only on injector bindings.

public V visit (ProviderInstanceBinding<? extends T> providerInstanceBinding)

Visit a provider instance binding. The provider's get method is invoked to resolve injections. This target is found in both module and injector bindings.

public V visit (ProviderKeyBinding<? extends T> providerKeyBinding)

Visit a provider key binding. To resolve injections, the provider key is first resolved, then that provider's get method is invoked. This target is found in both module and injector bindings.

public V visit (UntargettedBinding<? extends T> untargettedBinding)

Visit an untargetted binding. This target is found only on module bindings. It indicates that the injector should use its implicit binding strategies to resolve injections.

Protected Methods

protected V visitOther (Binding<? extends T> binding)

Default visit implementation. Returns null.

././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/DefaultBindingScopingVisitor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/DefaultBindingScoping0000755000175000017500000010123411704661106031707 0ustar tonytony DefaultBindingScopingVisitor | Guice
public class

DefaultBindingScopingVisitor

extends Object
implements BindingScopingVisitor<V>
java.lang.Object
   ↳ com.google.inject.spi.DefaultBindingScopingVisitor<V>

Class Overview

No-op visitor for subclassing. All interface methods simply delegate to visitOther(), returning its result.

Summary

Public Constructors
DefaultBindingScopingVisitor()
Public Methods
V visitEagerSingleton()
Visit an eager singleton or single instance.
V visitNoScoping()
Visit an unspecified or unscoped strategy.
V visitScope(Scope scope)
Visit a scope instance.
V visitScopeAnnotation(Class<? extends Annotation> scopeAnnotation)
Visit a scope annotation.
Protected Methods
V visitOther()
Default visit implementation.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.BindingScopingVisitor

Public Constructors

public DefaultBindingScopingVisitor ()

Public Methods

public V visitEagerSingleton ()

Visit an eager singleton or single instance. This scope strategy is found on both module and injector bindings.

public V visitNoScoping ()

Visit an unspecified or unscoped strategy. On a module, this strategy indicates that the injector should use scoping annotations to find a scope. On an injector, it indicates that no scope is applied to the binding. An unscoped binding will behave like a scoped one when it is linked to a scoped binding.

public V visitScope (Scope scope)

Visit a scope instance. This scope strategy is found on both module and injector bindings.

public V visitScopeAnnotation (Class<? extends Annotation> scopeAnnotation)

Visit a scope annotation. This scope strategy is found only on module bindings. The instance that implements this scope is registered by Binder.bindScope().

Protected Methods

protected V visitOther ()

Default visit implementation. Returns null.

././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ConvertedConstantBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ConvertedConstantBind0000755000175000017500000007322211704661106031752 0ustar tonytony ConvertedConstantBinding | Guice
public interface

ConvertedConstantBinding

implements Binding<T> HasDependencies
com.google.inject.spi.ConvertedConstantBinding<T>

Class Overview

A binding created from converting a bound instance to a new type. The source binding has the same binding annotation but a different type.

Summary

Public Methods
abstract Set<Dependency<?>> getDependencies()
Returns a singleton set containing only the converted key.
abstract Key<String> getSourceKey()
Returns the key for the source binding.
abstract TypeConverterBinding getTypeConverterBinding()
Returns the type converter binding used to convert the constant.
abstract T getValue()
Returns the converted value.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element
From interface com.google.inject.spi.HasDependencies

Public Methods

public abstract Set<Dependency<?>> getDependencies ()

Returns a singleton set containing only the converted key.

Returns
  • a possibly empty set

public abstract Key<String> getSourceKey ()

Returns the key for the source binding. That binding can e retrieved from an injector using Injector.getBinding(key).

public abstract TypeConverterBinding getTypeConverterBinding ()

Returns the type converter binding used to convert the constant.

public abstract T getValue ()

Returns the converted value.

././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ConstructorBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/ConstructorBinding.ht0000755000175000017500000007141011704661106031741 0ustar tonytony ConstructorBinding | Guice
public interface

ConstructorBinding

implements Binding<T> HasDependencies
com.google.inject.spi.ConstructorBinding<T>

Class Overview

A binding to the constructor of a concrete clss. To resolve injections, an instance is instantiated by invoking the constructor.

Summary

Public Methods
abstract InjectionPoint getConstructor()
Gets the constructor this binding injects.
abstract Set<InjectionPoint> getInjectableMembers()
Returns all instance method and field injection points on type.
abstract Map<Method, List<MethodInterceptor>> getMethodInterceptors()
Returns the interceptors applied to each method, in the order that they will be applied.
[Expand]
Inherited Methods
From interface com.google.inject.Binding
From interface com.google.inject.spi.Element
From interface com.google.inject.spi.HasDependencies

Public Methods

public abstract InjectionPoint getConstructor ()

Gets the constructor this binding injects.

public abstract Set<InjectionPoint> getInjectableMembers ()

Returns all instance method and field injection points on type.

Returns
  • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.

public abstract Map<Method, List<MethodInterceptor>> getMethodInterceptors ()

Returns the interceptors applied to each method, in the order that they will be applied.

Returns
  • a possibly empty map
././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/BindingTargetVisitor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/BindingTargetVisitor.0000755000175000017500000010716111704661106031671 0ustar tonytony BindingTargetVisitor | Guice
public interface

BindingTargetVisitor

com.google.inject.spi.BindingTargetVisitor<T, V>
Known Indirect Subclasses

Class Overview

Visits each of the strategies used to find an instance to satisfy an injection.

Summary

Public Methods
abstract V visit(ConstructorBinding<? extends T> binding)
Visit a constructor binding.
abstract V visit(ConvertedConstantBinding<? extends T> binding)
Visit a binding created from converting a bound instance to a new type.
abstract V visit(ExposedBinding<? extends T> binding)
Visit a binding to a key exposed from an enclosed private environment.
abstract V visit(InstanceBinding<? extends T> binding)
Visit a instance binding.
abstract V visit(LinkedKeyBinding<? extends T> binding)
Visit a linked key binding.
abstract V visit(ProviderBinding<? extends T> binding)
Visit a binding to a Provider that delegates to the binding for the provided type.
abstract V visit(ProviderInstanceBinding<? extends T> binding)
Visit a provider instance binding.
abstract V visit(ProviderKeyBinding<? extends T> binding)
Visit a provider key binding.
abstract V visit(UntargettedBinding<? extends T> binding)
Visit an untargetted binding.

Public Methods

public abstract V visit (ConstructorBinding<? extends T> binding)

Visit a constructor binding. To resolve injections, an instance is instantiated by invoking constructor. This target is found only on injector bindings.

public abstract V visit (ConvertedConstantBinding<? extends T> binding)

Visit a binding created from converting a bound instance to a new type. The source binding has the same binding annotation but a different type. This target is found only on injector bindings.

public abstract V visit (ExposedBinding<? extends T> binding)

Visit a binding to a key exposed from an enclosed private environment. This target is only found in injector bindings.

public abstract V visit (InstanceBinding<? extends T> binding)

Visit a instance binding. The same instance is returned for every injection. This target is found in both module and injector bindings.

public abstract V visit (LinkedKeyBinding<? extends T> binding)

Visit a linked key binding. The other key's binding is used to resolve injections. This target is found in both module and injector bindings.

public abstract V visit (ProviderBinding<? extends T> binding)

Visit a binding to a Provider that delegates to the binding for the provided type. This target is found only on injector bindings.

public abstract V visit (ProviderInstanceBinding<? extends T> binding)

Visit a provider instance binding. The provider's get method is invoked to resolve injections. This target is found in both module and injector bindings.

public abstract V visit (ProviderKeyBinding<? extends T> binding)

Visit a provider key binding. To resolve injections, the provider key is first resolved, then that provider's get method is invoked. This target is found in both module and injector bindings.

public abstract V visit (UntargettedBinding<? extends T> binding)

Visit an untargetted binding. This target is found only on module bindings. It indicates that the injector should use its implicit binding strategies to resolve injections.

././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/BindingScopingVisitor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/spi/BindingScopingVisitor0000755000175000017500000005623211704661106031771 0ustar tonytony BindingScopingVisitor | Guice
public interface

BindingScopingVisitor

com.google.inject.spi.BindingScopingVisitor<V>
Known Indirect Subclasses

Class Overview

Visits each of the strategies used to scope an injection.

Summary

Public Methods
abstract V visitEagerSingleton()
Visit an eager singleton or single instance.
abstract V visitNoScoping()
Visit an unspecified or unscoped strategy.
abstract V visitScope(Scope scope)
Visit a scope instance.
abstract V visitScopeAnnotation(Class<? extends Annotation> scopeAnnotation)
Visit a scope annotation.

Public Methods

public abstract V visitEagerSingleton ()

Visit an eager singleton or single instance. This scope strategy is found on both module and injector bindings.

public abstract V visitNoScoping ()

Visit an unspecified or unscoped strategy. On a module, this strategy indicates that the injector should use scoping annotations to find a scope. On an injector, it indicates that no scope is applied to the binding. An unscoped binding will behave like a scoped one when it is linked to a scoped binding.

public abstract V visitScope (Scope scope)

Visit a scope instance. This scope strategy is found on both module and injector bindings.

public abstract V visitScopeAnnotation (Class<? extends Annotation> scopeAnnotation)

Visit a scope annotation. This scope strategy is found only on module bindings. The instance that implements this scope is registered by Binder.bindScope().

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/0000755000175000017500000000000011704661106026447 5ustar tonytony././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/package-summary.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/package-summary.h0000755000175000017500000004165311704661106031722 0ustar tonytony com.google.inject.servlet | Guice
package

com.google.inject.servlet

Classes | Description

Servlet API scopes, bindings and registration; this extension requires guice-servlet-3.0.jar.

more...

Interfaces

InstanceFilterBinding A binding to a single instance of a filter. 
InstanceServletBinding A binding to a single instance of a servlet. 
LinkedFilterBinding A linked binding to a filter. 
LinkedServletBinding A linked binding to a servlet. 
ServletModule.FilterKeyBindingBuilder See the EDSL examples at configureServlets() 
ServletModule.ServletKeyBindingBuilder See the EDSL examples at configureServlets() 
ServletModuleBinding A binding created by ServletModule
ServletModuleTargetVisitor<T, V> A visitor for the servlet extension. 

Classes

GuiceFilter

Apply this filter in web.xml above all other filters (typically), to all requests where you plan to use servlet scopes. 

GuiceServletContextListener As of Guice 2.0 you can still use (your subclasses of) GuiceServletContextListener class as a logical place to create and configure your injector. 
ServletModule Configures the servlet scopes and creates bindings for the servlet API objects so you can inject the request, response, session, etc. 
ServletScopes Servlet scopes. 

Enums

UriPatternType An enumeration of the available URI-pattern matching styles 
././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/package-descr.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/package-descr.htm0000755000175000017500000003041611704661106031661 0ustar tonytony com.google.inject.servlet Details | Guice
package

com.google.inject.servlet

Classes | Description

Servlet API scopes, bindings and registration; this extension requires guice-servlet-3.0.jar.

Apply GuiceFilter to any servlets which will use the servlet scopes. Install ServletModule into your Injector to install everything at once.

././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/UriPatternType.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/UriPatternType.ht0000755000175000017500000006720411704661106031757 0ustar tonytony UriPatternType | Guice
public final enum

UriPatternType

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.servlet.UriPatternType

Class Overview

An enumeration of the available URI-pattern matching styles

Summary

Enum Values
UriPatternType  REGEX   
UriPatternType  SERVLET   
Public Methods
static UriPatternType valueOf(String name)
final static UriPatternType[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final UriPatternType REGEX

Since: API Level

public static final UriPatternType SERVLET

Since: API Level

Public Methods

public static UriPatternType valueOf (String name)

public static final UriPatternType[] values ()

././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/SessionScoped.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/SessionScoped.htm0000755000175000017500000003677011704661106031762 0ustar tonytony SessionScoped | Guice
public abstract @interface

SessionScoped

implements Annotation
com.google.inject.servlet.SessionScoped

Class Overview

Apply this to implementation classes when you want one instance per session.

See Also

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/ServletScopes.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/ServletScopes.htm0000755000175000017500000006341011704661106031771 0ustar tonytony ServletScopes | Guice
public class

ServletScopes

extends Object
java.lang.Object
   ↳ com.google.inject.servlet.ServletScopes

Class Overview

Servlet scopes.

Summary

Constants
Scope REQUEST HTTP servlet request scope.
Scope SESSION HTTP session scope.
Public Methods
static <T> Callable<T> continueRequest(Callable<T> callable, Map<Key<?>, Object> seedMap)
Wraps the given callable in a contextual callable that "continues" the HTTP request in another thread.
static <T> Callable<T> scopeRequest(Callable<T> callable, Map<Key<?>, Object> seedMap)
Scopes the given callable inside a request scope.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final Scope REQUEST

HTTP servlet request scope.

public static final Scope SESSION

HTTP session scope.

Public Methods

public static Callable<T> continueRequest (Callable<T> callable, Map<Key<?>, Object> seedMap)

Wraps the given callable in a contextual callable that "continues" the HTTP request in another thread. This acts as a way of transporting request context data from the request processing thread to to worker threads.

There are some limitations:

  • Derived objects (i.e. anything marked @RequestScoped will not be transported.
  • State changes to the HttpServletRequest after this method is called will not be seen in the continued thread.
  • Only the HttpServletRequest, ServletContext and request parameter map are available in the continued thread. The response and session are not available.

Parameters
callable code to be executed in another thread, which depends on the request scope.
seedMap the initial set of scoped instances for Guice to seed the request scope with. To seed a key with null, use null as the value.
Returns
  • a callable that will invoke the given callable, making the request context available to it.
Throws
OutOfScopeException if this method is called from a non-request thread, or if the request has completed.

public static Callable<T> scopeRequest (Callable<T> callable, Map<Key<?>, Object> seedMap)

Scopes the given callable inside a request scope. This is not the same as the HTTP request scope, but is used if no HTTP request scope is in progress. In this way, keys can be scoped as @RequestScoped and exist in non-HTTP requests (for example: RPC requests) as well as in HTTP request threads.

Parameters
callable code to be executed which depends on the request scope. Typically in another thread, but not necessarily so.
seedMap the initial set of scoped instances for Guice to seed the request scope with. To seed a key with null, use null as the value.
Returns
  • a callable that when called will run inside the a request scope that exposes the instances in the seedMap as scoped keys.
././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/ServletModuleTargetVisitor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/ServletModuleTarg0000755000175000017500000007313411704661106032015 0ustar tonytony ServletModuleTargetVisitor | Guice
public interface

ServletModuleTargetVisitor

implements BindingTargetVisitor<T, V>
com.google.inject.servlet.ServletModuleTargetVisitor<T, V>

Class Overview

A visitor for the servlet extension. If your BindingTargetVisitor implements this interface, bindings created by using ServletModule will be visited through this interface.

Summary

Public Methods
abstract V visit(InstanceFilterBinding binding)
Visits a filter binding created by filter(String, String...) where through(Class) is called with a Filter.
abstract V visit(InstanceServletBinding binding)
Visits a servlet binding created by serve(String, String...) where with(Class), is called with an HttpServlet.
abstract V visit(LinkedFilterBinding binding)
Visits a filter binding created by filter(String, String...), where through(Class) is called with a Class or Key.
abstract V visit(LinkedServletBinding binding)
Visits a servlet binding created by serve(String, String...) where with(Class), is called with a Class or Key.
[Expand]
Inherited Methods
From interface com.google.inject.spi.BindingTargetVisitor

Public Methods

public abstract V visit (InstanceFilterBinding binding)

Visits a filter binding created by filter(String, String...) where through(Class) is called with a Filter. If multiple patterns were specified, this will be called multiple times.

public abstract V visit (InstanceServletBinding binding)

Visits a servlet binding created by serve(String, String...) where with(Class), is called with an HttpServlet. If multiple patterns were specified, this will be called multiple times.

public abstract V visit (LinkedFilterBinding binding)

Visits a filter binding created by filter(String, String...), where through(Class) is called with a Class or Key. If multiple patterns were specified, this will be called multiple times.

public abstract V visit (LinkedServletBinding binding)

Visits a servlet binding created by serve(String, String...) where with(Class), is called with a Class or Key. If multiple patterns were specified, this will be called multiple times.

././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/ServletModuleBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/ServletModuleBind0000755000175000017500000005111111704661106031763 0ustar tonytony ServletModuleBinding | Guice
public interface

ServletModuleBinding

com.google.inject.servlet.ServletModuleBinding
Known Indirect Subclasses

Class Overview

A binding created by ServletModule.

Summary

Public Methods
abstract Map<String, String> getInitParams()
Returns any context params supplied when creating the binding.
abstract String getPattern()
Returns the pattern used to match against the binding.
abstract UriPatternType getUriPatternType()
Returns the pattern type that this binding was created with.
abstract boolean matchesUri(String uri)
Returns true if the given URI will match this binding.

Public Methods

public abstract Map<String, String> getInitParams ()

Returns any context params supplied when creating the binding.

public abstract String getPattern ()

Returns the pattern used to match against the binding.

public abstract UriPatternType getUriPatternType ()

Returns the pattern type that this binding was created with.

public abstract boolean matchesUri (String uri)

Returns true if the given URI will match this binding.

././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/ServletModule.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/ServletModule.htm0000755000175000017500000015115611704661106031767 0ustar tonytony ServletModule | Guice
public class

ServletModule

extends AbstractModule
java.lang.Object
   ↳ com.google.inject.AbstractModule
     ↳ com.google.inject.servlet.ServletModule

Class Overview

Configures the servlet scopes and creates bindings for the servlet API objects so you can inject the request, response, session, etc.

You should subclass this module to register servlets and filters in the configureServlets() method.

Summary

Nested Classes
interface ServletModule.FilterKeyBindingBuilder See the EDSL examples at configureServlets() 
interface ServletModule.ServletKeyBindingBuilder See the EDSL examples at configureServlets() 
Public Constructors
ServletModule()
Protected Methods
final void configure()
Configures a Binder via the exposed methods.
void configureServlets()

Servlet Mapping EDSL

Part of the EDSL builder language for configuring servlets and filters with guice-servlet.

final ServletModule.FilterKeyBindingBuilder filter(String urlPattern, String... morePatterns)
final ServletModule.FilterKeyBindingBuilder filterRegex(String regex, String... regexes)
final ServletContext getServletContext()
This method only works if you are using the GuiceServletContextListener to create your injector.
final ServletModule.ServletKeyBindingBuilder serve(String urlPattern, String... morePatterns)
final ServletModule.ServletKeyBindingBuilder serveRegex(String regex, String... regexes)
[Expand]
Inherited Methods
From class com.google.inject.AbstractModule
From class java.lang.Object
From interface com.google.inject.Module

Public Constructors

public ServletModule ()

Protected Methods

protected final void configure ()

Configures a Binder via the exposed methods.

protected void configureServlets ()

Servlet Mapping EDSL

Part of the EDSL builder language for configuring servlets and filters with guice-servlet. Think of this as an in-code replacement for web.xml. Filters and servlets are configured here using simple java method calls. Here is a typical example of registering a filter when creating your Guice injector:

   Guice.createInjector(..., new ServletModule() {

     @Override
     protected void configureServlets() {
       serve("*.html").with(MyServlet.class)
     }
   }
 
This registers a servlet (subclass of HttpServlet) called MyServlet to service any web pages ending in .html. You can also use a path-style syntax to register servlets:
       serve("/my/*").with(MyServlet.class)
 
Every servlet (or filter) is required to be a singleton. If you cannot annotate the class directly, you should add a separate bind(..).in(Singleton.class) rule elsewhere in your module. Mapping a servlet that is bound under any other scope is an error.

Dispatch Order

You are free to register as many servlets and filters as you like this way. They will be compared and dispatched in the order in which the filter methods are called:

   Guice.createInjector(..., new ServletModule() {

     @Override
     protected void configureServlets() {
       filter("/*").through(MyFilter.class);
       filter("*.css").through(MyCssFilter.class);
       filter("*.jpg").through(new MyJpgFilter());
       // etc..

       serve("*.html").with(MyServlet.class);
       serve("/my/*").with(MyServlet.class);
       serve("*.jpg").with(new MyServlet());
       // etc..
      }
    }
 
This will traverse down the list of rules in lexical order. For example, a url "/my/file.js" (after it runs through the matching filters) will first be compared against the servlet mapping:
       serve("*.html").with(MyServlet.class);
 
And failing that, it will descend to the next servlet mapping:
       serve("/my/*").with(MyServlet.class);
 
Since this rule matches, Guice Servlet will dispatch to MyServlet. These two mapping rules can also be written in more compact form using varargs syntax:
       serve("*.html", "/my/*").with(MyServlet.class);
 
This way you can map several URI patterns to the same servlet. A similar syntax is also available for filter mappings.

Regular Expressions

You can also map servlets (or filters) to URIs using regular expressions:
    serveRegex("(.)*ajax(.)*").with(MyAjaxServlet.class)
 
This will map any URI containing the text "ajax" in it to MyAjaxServlet. Such as:
  • http://www.google.com/ajax.html
  • http://www.google.com/content/ajax/index
  • http://www.google.com/it/is_totally_ajaxian

Initialization Parameters

Servlets (and filters) allow you to pass in init params using the <init-param> tag in web.xml. You can similarly pass in parameters to Servlets and filters registered in Guice-servlet using a java.util.Map of parameter name/value pairs. For example, to initialize MyServlet with two parameters (name="Dhanji", site="google.com") you could write:
  Map<String, String> params = new HashMap<String, String>();
  params.put("name", "Dhanji");
  params.put("site", "google.com");

  ...
      serve("/*").with(MyServlet.class, params)
 

Binding Keys

You can also bind keys rather than classes. This lets you hide implementations with package-local visbility and expose them using only a Guice module and an annotation:
  ...
      filter("/*").through(Key.get(Filter.class, Fave.class));
 
Where Filter.class refers to the Servlet API interface and Fave.class is a custom binding annotation. Elsewhere (in one of your own modules) you can bind this filter's implementation:
   bind(Filter.class).annotatedWith(Fave.class).to(MyFilterImpl.class);
 
See Binder for more information on binding syntax.

Multiple Modules

It is sometimes useful to capture servlet and filter mappings from multiple different modules. This is essential if you want to package and offer drop-in Guice plugins that provide servlet functionality.

Guice Servlet allows you to register several instances of ServletModule to your injector. The order in which these modules are installed determines the dispatch order of filters and the precedence order of servlets. For example, if you had two servlet modules, RpcModule and WebServiceModule and they each contained a filter that mapped to the same URI pattern, "/*":

In RpcModule:

     filter("/*").through(RpcFilter.class);
 
In WebServiceModule:
     filter("/*").through(WebServiceFilter.class);
 
Then the order in which these filters are dispatched is determined by the order in which the modules are installed:
   install(new WebServiceModule());
   install(new RpcModule());
 
In the case shown above WebServiceFilter will run first.

protected final ServletModule.FilterKeyBindingBuilder filter (String urlPattern, String... morePatterns)

Parameters
urlPattern Any Servlet-style pattern. examples: /*, /html/*, *.html, etc.

protected final ServletModule.FilterKeyBindingBuilder filterRegex (String regex, String... regexes)

Parameters
regex Any Java-style regular expression.

protected final ServletContext getServletContext ()

This method only works if you are using the GuiceServletContextListener to create your injector. Otherwise, it returns null.

Returns
  • The current servlet context.

protected final ServletModule.ServletKeyBindingBuilder serve (String urlPattern, String... morePatterns)

Parameters
urlPattern Any Servlet-style pattern. examples: /*, /html/*, *.html, etc.

protected final ServletModule.ServletKeyBindingBuilder serveRegex (String regex, String... regexes)

Parameters
regex Any Java-style regular expression.
././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/ServletModule.ServletKeyBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/ServletModule.Ser0000755000175000017500000005126711704661106031732 0ustar tonytony ServletModule.ServletKeyBindingBuilder | Guice
public static interface

ServletModule.ServletKeyBindingBuilder

com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder

Class Overview

See the EDSL examples at configureServlets()

Summary

Public Methods
abstract void with(HttpServlet servlet)
abstract void with(HttpServlet servlet, Map<String, String> initParams)
abstract void with(Key<? extends HttpServlet> servletKey)
abstract void with(Key<? extends HttpServlet> servletKey, Map<String, String> initParams)
abstract void with(Class<? extends HttpServlet> servletKey)
abstract void with(Class<? extends HttpServlet> servletKey, Map<String, String> initParams)

Public Methods

public abstract void with (HttpServlet servlet)

public abstract void with (HttpServlet servlet, Map<String, String> initParams)

public abstract void with (Key<? extends HttpServlet> servletKey)

public abstract void with (Key<? extends HttpServlet> servletKey, Map<String, String> initParams)

public abstract void with (Class<? extends HttpServlet> servletKey)

public abstract void with (Class<? extends HttpServlet> servletKey, Map<String, String> initParams)

././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/ServletModule.FilterKeyBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/ServletModule.Fil0000755000175000017500000005116211704661106031705 0ustar tonytony ServletModule.FilterKeyBindingBuilder | Guice
public static interface

ServletModule.FilterKeyBindingBuilder

com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder

Class Overview

See the EDSL examples at configureServlets()

Summary

Public Methods
abstract void through(Filter filter)
abstract void through(Filter filter, Map<String, String> initParams)
abstract void through(Key<? extends Filter> filterKey)
abstract void through(Key<? extends Filter> filterKey, Map<String, String> initParams)
abstract void through(Class<? extends Filter> filterKey)
abstract void through(Class<? extends Filter> filterKey, Map<String, String> initParams)

Public Methods

public abstract void through (Filter filter)

public abstract void through (Filter filter, Map<String, String> initParams)

public abstract void through (Key<? extends Filter> filterKey)

public abstract void through (Key<? extends Filter> filterKey, Map<String, String> initParams)

public abstract void through (Class<? extends Filter> filterKey)

public abstract void through (Class<? extends Filter> filterKey, Map<String, String> initParams)

././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/RequestScoped.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/RequestScoped.htm0000755000175000017500000003644111704661106031762 0ustar tonytony RequestScoped | Guice
public abstract @interface

RequestScoped

implements Annotation
com.google.inject.servlet.RequestScoped

Class Overview

Apply this to implementation classes when you want one instance per request.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/RequestParameters.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/RequestParameters0000755000175000017500000003656111704661106032064 0ustar tonytony RequestParameters | Guice
public abstract @interface

RequestParameters

implements Annotation
com.google.inject.servlet.RequestParameters

Class Overview

Apply this to field or parameters of type Map<String, String[]> when you want the HTTP request parameter map to be injected.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/LinkedServletBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/LinkedServletBind0000755000175000017500000004372611704661106031761 0ustar tonytony LinkedServletBinding | Guice
public interface

LinkedServletBinding

implements ServletModuleBinding
com.google.inject.servlet.LinkedServletBinding

Class Overview

A linked binding to a servlet.

Summary

Public Methods
abstract Key<? extends HttpServlet> getLinkedKey()
Returns the key used to lookup the servlet instance.
[Expand]
Inherited Methods
From interface com.google.inject.servlet.ServletModuleBinding

Public Methods

public abstract Key<? extends HttpServlet> getLinkedKey ()

Returns the key used to lookup the servlet instance.

././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/LinkedFilterBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/LinkedFilterBindi0000755000175000017500000004370511704661106031730 0ustar tonytony LinkedFilterBinding | Guice
public interface

LinkedFilterBinding

implements ServletModuleBinding
com.google.inject.servlet.LinkedFilterBinding

Class Overview

A linked binding to a filter.

Summary

Public Methods
abstract Key<? extends Filter> getLinkedKey()
Returns the key used to lookup the filter instance.
[Expand]
Inherited Methods
From interface com.google.inject.servlet.ServletModuleBinding

Public Methods

public abstract Key<? extends Filter> getLinkedKey ()

Returns the key used to lookup the filter instance.

././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/InstanceServletBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/InstanceServletBi0000755000175000017500000004352211704661106031767 0ustar tonytony InstanceServletBinding | Guice
public interface

InstanceServletBinding

implements ServletModuleBinding
com.google.inject.servlet.InstanceServletBinding

Class Overview

A binding to a single instance of a servlet.

Summary

Public Methods
abstract HttpServlet getServletInstance()
Returns the servlet instance that will be used.
[Expand]
Inherited Methods
From interface com.google.inject.servlet.ServletModuleBinding

Public Methods

public abstract HttpServlet getServletInstance ()

Returns the servlet instance that will be used.

././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/InstanceFilterBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/InstanceFilterBin0000755000175000017500000004347511704661106031755 0ustar tonytony InstanceFilterBinding | Guice
public interface

InstanceFilterBinding

implements ServletModuleBinding
com.google.inject.servlet.InstanceFilterBinding

Class Overview

A binding to a single instance of a filter.

Summary

Public Methods
abstract Filter getFilterInstance()
Returns the filter instance that will be used.
[Expand]
Inherited Methods
From interface com.google.inject.servlet.ServletModuleBinding

Public Methods

public abstract Filter getFilterInstance ()

Returns the filter instance that will be used.

././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/GuiceServletContextListener.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/GuiceServletConte0000755000175000017500000005617111704661106032001 0ustar tonytony GuiceServletContextListener | Guice
public abstract class

GuiceServletContextListener

extends Object
java.lang.Object
   ↳ com.google.inject.servlet.GuiceServletContextListener

Class Overview

As of Guice 2.0 you can still use (your subclasses of) GuiceServletContextListener class as a logical place to create and configure your injector. This will ensure the injector is created when the web application is deployed.

Summary

Public Constructors
GuiceServletContextListener()
Public Methods
void contextDestroyed(ServletContextEvent servletContextEvent)
void contextInitialized(ServletContextEvent servletContextEvent)
Protected Methods
abstract Injector getInjector()
Override this method to create (or otherwise obtain a reference to) your injector.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public GuiceServletContextListener ()

Public Methods

public void contextDestroyed (ServletContextEvent servletContextEvent)

public void contextInitialized (ServletContextEvent servletContextEvent)

Protected Methods

protected abstract Injector getInjector ()

Override this method to create (or otherwise obtain a reference to) your injector.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/servlet/GuiceFilter.html0000755000175000017500000005677311704661106031564 0ustar tonytony GuiceFilter | Guice
public class

GuiceFilter

extends Object
java.lang.Object
   ↳ com.google.inject.servlet.GuiceFilter

Class Overview

Apply this filter in web.xml above all other filters (typically), to all requests where you plan to use servlet scopes. This is also needed in order to dispatch requests to injectable filters and servlets:

  <filter>
    <filter-name>guiceFilter</filter-name>
    <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>guiceFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  
This filter must appear before every filter that makes use of Guice injection or servlet scopes functionality. Typically, you will only register this filter in web.xml and register any other filters (and servlets) using a ServletModule.

Summary

Public Constructors
GuiceFilter()
Public Methods
void destroy()
void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
void init(FilterConfig filterConfig)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public GuiceFilter ()

Public Methods

public void destroy ()

public void doFilter (ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)

Throws
IOException
ServletException

public void init (FilterConfig filterConfig)

Throws
ServletException
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/0000755000175000017500000000000011704661106026454 5ustar tonytony././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/package-summary.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/package-summary.h0000755000175000017500000002752111704661106031725 0ustar tonytony com.google.inject.persist | Guice
package

com.google.inject.persist

Classes | Description

Guice Persist: a lightweight persistence library for Guice; this extension requires guice-persist-3.0.jar.

more...

Interfaces

PersistService Persistence provider service. 
UnitOfWork This interface is used to gain manual control over the unit of work. 

Classes

PersistFilter Apply this filter to enable the HTTP Request unit of work and to have guice-persist manage the lifecycle of active units of work. 
PersistModule Install this module to add guice-persist library support for JPA persistence providers. 
././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/package-descr.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/package-descr.htm0000755000175000017500000002425711704661106031674 0ustar tonytony com.google.inject.persist Details | Guice
package

com.google.inject.persist

Classes | Description

Guice Persist: a lightweight persistence library for Guice; this extension requires guice-persist-3.0.jar.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/jpa/0000755000175000017500000000000011704661106027226 5ustar tonytony././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/jpa/package-summary.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/jpa/package-summa0000755000175000017500000002420711704661106031674 0ustar tonytony com.google.inject.persist.jpa | Guice
package

com.google.inject.persist.jpa

Classes | Description

guice-persist's Java Persistence API (JPA) support.

more...

Classes

JpaPersistModule JPA provider for guice persist. 
././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/jpa/package-descr.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/jpa/package-descr0000755000175000017500000002314711704661106031654 0ustar tonytony com.google.inject.persist.jpa Details | Guice
package

com.google.inject.persist.jpa

Classes | Description

guice-persist's Java Persistence API (JPA) support.

././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/jpa/JpaPersistModule.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/jpa/JpaPersistMod0000755000175000017500000012315511704661106031707 0ustar tonytony JpaPersistModule | Guice
public final class

JpaPersistModule

extends PersistModule
java.lang.Object
   ↳ com.google.inject.AbstractModule
     ↳ com.google.inject.persist.PersistModule
       ↳ com.google.inject.persist.jpa.JpaPersistModule

Class Overview

JPA provider for guice persist.

Summary

Public Constructors
JpaPersistModule(String jpaUnit)
Public Methods
<T> JpaPersistModule addFinder(Class<T> iface)
Adds an interface to this module to use as a dynamic finder.
JpaPersistModule properties(Properties properties)
Configures the JPA persistence provider with a set of properties.
Protected Methods
void configurePersistence()
MethodInterceptor getTransactionInterceptor()
[Expand]
Inherited Methods
From class com.google.inject.persist.PersistModule
From class com.google.inject.AbstractModule
From class java.lang.Object
From interface com.google.inject.Module

Public Constructors

public JpaPersistModule (String jpaUnit)

Public Methods

public JpaPersistModule addFinder (Class<T> iface)

Adds an interface to this module to use as a dynamic finder.

Parameters
iface Any interface type whose methods are all dynamic finders.

public JpaPersistModule properties (Properties properties)

Configures the JPA persistence provider with a set of properties.

Parameters
properties A set of name value pairs that configure a JPA persistence provider as per the specification.

Protected Methods

protected void configurePersistence ()

protected MethodInterceptor getTransactionInterceptor ()

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/finder/0000755000175000017500000000000011704661106027723 5ustar tonytony././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/finder/package-summary.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/finder/package-su0000755000175000017500000002514611704661106031701 0ustar tonytony com.google.inject.persist.finder | Guice
package

com.google.inject.persist.finder

Classes | Description

Dynamic Finder API for Guice Persist.

more...

Classes

DynamicFinder Utility that helps you introspect dynamic finder methods. 
././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/finder/package-descr.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/finder/package-de0000755000175000017500000002405711704661106031642 0ustar tonytony com.google.inject.persist.finder Details | Guice
package

com.google.inject.persist.finder

Classes | Description

Dynamic Finder API for Guice Persist.

././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/finder/MaxResults.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/finder/MaxResults0000755000175000017500000003324511704661106031767 0ustar tonytony MaxResults | Guice
public abstract @interface

MaxResults

implements Annotation
com.google.inject.persist.finder.MaxResults

Class Overview

Annotate any dynamic finder method's integer argument with this to pass in the maximum size of returned result window. Usefule for paging result sets. Complement of FirstResult.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/finder/FirstResult.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/finder/FirstResul0000755000175000017500000003330211704661106031754 0ustar tonytony FirstResult | Guice
public abstract @interface

FirstResult

implements Annotation
com.google.inject.persist.finder.FirstResult

Class Overview

Annotate any dynamic finder method's integer argument with this to pass in the index of the first result in the result set you are interested in. Useful for paging result sets. Complemented by MaxResults.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/finder/Finder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/finder/Finder.htm0000755000175000017500000003306711704661106031660 0ustar tonytony Finder | Guice
public abstract @interface

Finder

implements Annotation
com.google.inject.persist.finder.Finder

Class Overview

Marks a method stub as a dynamic finder. The method is intercepted and replaced with the specified JPAQL query. Provides result auto-boxing and automatic parameter binding.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/finder/DynamicFinder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/finder/DynamicFin0000755000175000017500000005006011704661106031673 0ustar tonytony DynamicFinder | Guice
public final class

DynamicFinder

extends Object
java.lang.Object
   ↳ com.google.inject.persist.finder.DynamicFinder

Class Overview

Utility that helps you introspect dynamic finder methods.

Summary

Public Constructors
DynamicFinder(Method method)
Public Methods
static DynamicFinder from(Method method)
Returns some metadata if the method is annotated @Finder or null.
Finder metadata()
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public DynamicFinder (Method method)

Public Methods

public static DynamicFinder from (Method method)

Returns some metadata if the method is annotated @Finder or null.

Parameters
method a method you want to test as a dynamic finder

public Finder metadata ()

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/UnitOfWork.html0000755000175000017500000003522211704661106031420 0ustar tonytony UnitOfWork | Guice
public interface

UnitOfWork

com.google.inject.persist.UnitOfWork

Class Overview

This interface is used to gain manual control over the unit of work. This is mostly to do work in non-request, non-transactional threads. Or where more fine-grained control over the unit of work is required. Starting and ending a unit of work directly corresponds to opening and closing a Session, EntityManager or ObjectContainer respectively.

The Unit of Work referred to by UnitOfWork will always be local to the calling thread. Be careful to end() in a finally block. Neither JPA, nor Hibernate supports threadsafe sessions (reasoning behind thread-locality of Unit of Work semantics).

  • Using UnitOfWork with the PersistFilter inside a request is not recommended.
  • Using UnitOfWork with session-per-txn strategy is not terribly clever either.
  • Using UnitOfWork with session-per-request strategy but *outside* a request (i.e. in a background or bootstrap thread) is probably a good use case.

Summary

Public Methods
abstract void begin()
Starts a Unit Of Work.
abstract void end()
Declares an end to the current Unit of Work.

Public Methods

public abstract void begin ()

Starts a Unit Of Work. Underneath, causes a session to the data layer to be opened. If there is already one open, the invocation will do nothing. In this way, you can define arbitrary units-of-work that nest within one another safely. Transaction semantics are not affected.

public abstract void end ()

Declares an end to the current Unit of Work. Underneath, causes any open session to the data layer to close. If there is no Unit of work open, then the call returns silently. You can safely invoke end() repeatedly.

Transaction semantics are not affected.

././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/Transactional.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/Transactional.htm0000755000175000017500000003414411704661106032001 0ustar tonytony Transactional | Guice
public abstract @interface

Transactional

implements Annotation
com.google.inject.persist.Transactional

Class Overview

Any method or class marked with this annotation will be considered for transactionality. Consult the documentation on http://code.google.com/p/google-guice for detailed semantics. Marking a method @Transactional will start a new transaction before the method executes and commit it after the method returns.

If the method throws an exception, the transaction will be rolled back unless you have specifically requested not to in the #ignore() clause.

Similarly, the set of exceptions that will trigger a rollback can be defined in the #rollbackOn() clause. By default, only unchecked exceptions trigger a rollback.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/PersistService.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/PersistService.ht0000755000175000017500000003370211704661106031773 0ustar tonytony PersistService | Guice
public interface

PersistService

com.google.inject.persist.PersistService

Class Overview

Persistence provider service. Use this to manage the overall startup and stop of the persistence module(s). TODO(dhanji): Integrate with Service API when appropriate.

Summary

Public Methods
abstract void start()
Starts the underlying persistence engine and makes guice-persist ready for use.
abstract void stop()
Stops the underlying persistence engine.

Public Methods

public abstract void start ()

Starts the underlying persistence engine and makes guice-persist ready for use. For instance, with JPA, it creates an EntityManagerFactory and may open connection pools. This method must be called by your code prior to using any guice-persist or JPA artifacts. If already started, calling this method does nothing, if already stopped, it also does nothing.

public abstract void stop ()

Stops the underlying persistence engine. For instance, with JPA, it closes the EntityManagerFactory. If already stopped, calling this method does nothing. If not yet started, it also does nothing.

././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/PersistModule.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/PersistModule.htm0000755000175000017500000011372311704661106031777 0ustar tonytony PersistModule | Guice
public abstract class

PersistModule

extends AbstractModule
java.lang.Object
   ↳ com.google.inject.AbstractModule
     ↳ com.google.inject.persist.PersistModule
Known Direct Subclasses

Class Overview

Install this module to add guice-persist library support for JPA persistence providers.

Summary

Public Constructors
PersistModule()
Protected Methods
final void configure()
Configures a Binder via the exposed methods.
abstract void configurePersistence()
abstract MethodInterceptor getTransactionInterceptor()
[Expand]
Inherited Methods
From class com.google.inject.AbstractModule
From class java.lang.Object
From interface com.google.inject.Module

Public Constructors

public PersistModule ()

Protected Methods

protected final void configure ()

Configures a Binder via the exposed methods.

protected abstract void configurePersistence ()

protected abstract MethodInterceptor getTransactionInterceptor ()

././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/PersistFilter.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/persist/PersistFilter.htm0000755000175000017500000005547511704661106032010 0ustar tonytony PersistFilter | Guice
public final class

PersistFilter

extends Object
java.lang.Object
   ↳ com.google.inject.persist.PersistFilter

Class Overview

Apply this filter to enable the HTTP Request unit of work and to have guice-persist manage the lifecycle of active units of work. The filter automatically starts and stops the relevant PersistService upon javax.servlet.Filter#init(javax.servlet.FilterConfig) and javax.servlet.Filter#destroy() respectively.

To be able to use the open session-in-view pattern (i.e. work per request), register this filter once in your Guice ServletModule. It is important that you register this filter before any other filter. For multiple providers, you should register this filter once per provider, inside a private module for each persist module installed (this must be the same private module where the specific persist module is itself installed).

Example configuration:

public class MyModule extends ServletModule {
    public void configureServlets() {
      filter("/*").through(PersistFilter.class);

      serve("/index.html").with(MyHtmlServlet.class);
      // Etc.
    
  }
 }

This filter is thread safe and allows you to create injectors concurrently and deploy multiple guice-persist modules within the same injector, or even multiple injectors with persist modules withing the same JVM or web app.

This filter requires the Guice Servlet extension.

Summary

Public Constructors
PersistFilter(UnitOfWork unitOfWork, PersistService persistService)
Public Methods
void destroy()
void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
void init(FilterConfig filterConfig)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public PersistFilter (UnitOfWork unitOfWork, PersistService persistService)

Public Methods

public void destroy ()

public void doFilter (ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)

Throws
IOException
ServletException

public void init (FilterConfig filterConfig)

Throws
ServletException
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/package-summary.html0000755000175000017500000004674611704661106030763 0ustar tonytony com.google.inject | Guice
package

com.google.inject

Classes | Description

Google Guice (pronounced "juice") is an ultra-lightweight dependency injection framework.

more...

Interfaces

Binder Collects configuration information (primarily bindings) which will be used to create an Injector
Binding<T> A mapping from a key (type and optional annotation) to the strategy for getting instances of the type. 
Injector Builds the graphs of objects that make up your application. 
MembersInjector<T> Injects dependencies into the fields and methods on instances of type T
Module A module contributes configuration information, typically interface bindings, which will be used to create an Injector
PrivateBinder Returns a binder whose configuration information is hidden from its environment by default. 
Provider<T> An object capable of providing instances of type T
Scope A scope is a level of visibility that instances provided by Guice may have. 

Classes

AbstractModule A support class for Modules which reduces repetition and results in a more readable configuration. 
Guice The entry point to the Guice framework. 
Key<T> Binding key consisting of an injection type and an optional annotation. 
PrivateModule A module whose configuration information is hidden from its environment by default. 
Scopes Built-in scope implementations. 
TypeLiteral<T> Represents a generic type T

Enums

Stage The stage we're running in. 

Exceptions

ConfigurationException Thrown when a programming error such as a misplaced annotation, illegal binding, or unsupported scope is found. 
CreationException Thrown when errors occur while creating a Injector
OutOfScopeException Thrown from get() when an attempt is made to access a scoped object while the scope in question is not currently active. 
ProvisionException Indicates that there was a runtime failure while providing an instance. 
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/package-descr.html0000755000175000017500000003337611704661106030361 0ustar tonytony com.google.inject Details | Guice
package

com.google.inject

Classes | Description

Google Guice (pronounced "juice") is an ultra-lightweight dependency injection framework. Please refer to the Guice User's Guide for a gentle introduction.

The principal public APIs in this package are:

Inject
The annotation you will use in your implementation classes to tell Guice where and how it should send in ("inject") the objects you depend on (your "dependencies").
Module
The interface you will implement in order to specify "bindings" -- instructions for how Guice should handle injection -- for a particular set of interfaces.
Binder
The object that Guice passes into your Module to collect these bindings.
Provider
The interface you will implement when you need to customize exactly how Guice creates instances for a particular binding.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/name/0000755000175000017500000000000011704661106025703 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/name/package-summary.html0000755000175000017500000002431111704661106031663 0ustar tonytony com.google.inject.name | Guice
package

com.google.inject.name

Classes | Description

Support for binding to string-based names.

more...

Classes

Names Utility methods for use with @Named
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/name/package-descr.html0000755000175000017500000002315611704661106031274 0ustar tonytony com.google.inject.name Details | Guice
package

com.google.inject.name

Classes | Description

Support for binding to string-based names.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/name/Names.html0000755000175000017500000005015411704661106027644 0ustar tonytony Names | Guice
public class

Names

extends Object
java.lang.Object
   ↳ com.google.inject.name.Names

Class Overview

Utility methods for use with @Named.

Summary

Public Methods
static void bindProperties(Binder binder, Map<String, String> properties)
Creates a constant binding to @Named(key) for each entry in properties.
static void bindProperties(Binder binder, Properties properties)
Creates a constant binding to @Named(key) for each property.
static Named named(String name)
Creates a Named annotation with name as the value.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static void bindProperties (Binder binder, Map<String, String> properties)

Creates a constant binding to @Named(key) for each entry in properties.

public static void bindProperties (Binder binder, Properties properties)

Creates a constant binding to @Named(key) for each property. This method binds all properties including those inherited from defaults.

public static Named named (String name)

Creates a Named annotation with name as the value.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/name/Named.html0000755000175000017500000003173311704661106027627 0ustar tonytony Named | Guice
public abstract @interface

Named

implements Annotation
com.google.inject.name.Named

Class Overview

Annotates named things.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/multibindings/0000755000175000017500000000000011704661106027633 5ustar tonytony././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/multibindings/package-summary.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/multibindings/package-sum0000755000175000017500000003040111704661106031754 0ustar tonytony com.google.inject.multibindings | Guice
package

com.google.inject.multibindings

Classes | Description

Extension for binding multiple instances in a collection; this extension requires guice-multibindings-3.0.jar.

more...

Interfaces

MapBinderBinding<T> A binding for a MapBinder. 
MultibinderBinding<T> A binding for a Multibinder. 
MultibindingsTargetVisitor<T, V> A visitor for the multibinder extension. 

Classes

MapBinder<K, V> An API to bind multiple map entries separately, only to later inject them as a complete map. 
Multibinder<T> An API to bind multiple values separately, only to later inject them as a complete collection. 
././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/multibindings/package-descr.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/multibindings/package-des0000755000175000017500000002437611704661106031741 0ustar tonytony com.google.inject.multibindings Details | Guice
package

com.google.inject.multibindings

Classes | Description

Extension for binding multiple instances in a collection; this extension requires guice-multibindings-3.0.jar.

././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/multibindings/MultibindingsTargetVisitor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/multibindings/Multibindin0000755000175000017500000005502111704661106032042 0ustar tonytony MultibindingsTargetVisitor | Guice
public interface

MultibindingsTargetVisitor

implements BindingTargetVisitor<T, V>
com.google.inject.multibindings.MultibindingsTargetVisitor<T, V>

Class Overview

A visitor for the multibinder extension.

If your BindingTargetVisitor implements this interface, bindings created by using Multibinder or MapBinder will be visited through this interface.

Summary

Public Methods
abstract V visit(MapBinderBinding<? extends T> mapbinding)
Visits a binding created through MapBinder.
abstract V visit(MultibinderBinding<? extends T> multibinding)
Visits a binding created through Multibinder.
[Expand]
Inherited Methods
From interface com.google.inject.spi.BindingTargetVisitor

Public Methods

public abstract V visit (MapBinderBinding<? extends T> mapbinding)

Visits a binding created through MapBinder.

public abstract V visit (MultibinderBinding<? extends T> multibinding)

Visits a binding created through Multibinder.

././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/multibindings/MultibinderBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/multibindings/Multibinder0000755000175000017500000004752711704661106032056 0ustar tonytony MultibinderBinding | Guice
public interface

MultibinderBinding

com.google.inject.multibindings.MultibinderBinding<T>

Class Overview

A binding for a Multibinder.

Summary

Public Methods
abstract boolean containsElement(Element element)
Returns true if this Multibinder uses the given Element.
abstract TypeLiteral<?> getElementTypeLiteral()
Returns the TypeLiteral that describes the type of elements in the set.
abstract List<Binding<?>> getElements()
Returns all bindings that make up the set.
abstract Key<T> getSetKey()
Returns the key for the set.
abstract boolean permitsDuplicates()
Returns true if the multibinder permits duplicates.

Public Methods

public abstract boolean containsElement (Element element)

Returns true if this Multibinder uses the given Element. This will be true for bindings that derive the elements of the set and other bindings that Multibinder uses internally. This will work for MultibinderBindings retrieved from an injector and getElements(Module...). Usually this is only necessary if you are working with elements retrieved from modules (without an Injector), otherwise getElements() and permitsDuplicates() are better options.

If you need to introspect the details of the set, such as the values or if it permits duplicates, it is necessary to pass the elements through an Injector and use getElements() and permitsDuplicates().

public abstract TypeLiteral<?> getElementTypeLiteral ()

Returns the TypeLiteral that describes the type of elements in the set.

The elements will always match the type Set's generic type. For example, if getSetKey returns a key of Set<String>, then this will always return a TypeLiteral<String>.

public abstract List<Binding<?>> getElements ()

Returns all bindings that make up the set. This is only supported on bindings returned from an injector. This will throw UnsupportedOperationException if it is called on an element retrieved from getElements(Module...).

The elements will always match the type Set's generic type. For example, if getSetKey returns a key of Set<String>, then this will always return a list of type List<Binding<String>>.

public abstract Key<T> getSetKey ()

Returns the key for the set.

public abstract boolean permitsDuplicates ()

Returns true if the multibinder permits duplicates. This is only supported on bindings returned from an injector. This will throw UnsupportedOperationException if it is called on a MultibinderBinding retrieved from getElements(Module...).

././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/multibindings/Multibinder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/multibindings/Multibinder0000755000175000017500000010233111704661106032037 0ustar tonytony Multibinder | Guice
public abstract class

Multibinder

extends Object
java.lang.Object
   ↳ com.google.inject.multibindings.Multibinder<T>

Class Overview

An API to bind multiple values separately, only to later inject them as a complete collection. Multibinder is intended for use in your application's module:


 public class SnacksModule extends AbstractModule {
   protected void configure() {
     Multibinder<Snack> multibinder
         = Multibinder.newSetBinder(binder(), Snack.class);
     multibinder.addBinding().toInstance(new Twix());
     multibinder.addBinding().toProvider(SnickersProvider.class);
     multibinder.addBinding().to(Skittles.class);
   }
 }

With this binding, a Set<Snack> can now be injected:


 class SnackMachine {
   @Inject
   public SnackMachine(Set<Snack> snacks) { ... }
 }

Contributing multibindings from different modules is supported. For example, it is okay to have both CandyModule and ChipsModule to both create their own Multibinder<Snack>, and to each contribute bindings to the set of snacks. When that set is injected, it will contain elements from both modules.

The set's iteration order is consistent with the binding order. This is convenient when multiple elements are contributed by the same module because that module can order its bindings appropriately. Avoid relying on the iteration order of elements contributed by different modules, since there is no equivalent mechanism to order modules.

The set is unmodifiable. Elements can only be added to the set by configuring the multibinder. Elements can never be removed from the set.

Elements are resolved at set injection time. If an element is bound to a provider, that provider's get method will be called each time the set is injected (unless the binding is also scoped).

Annotations are be used to create different sets of the same element type. Each distinct annotation gets its own independent collection of elements.

Elements must be distinct. If multiple bound elements have the same value, set injection will fail.

Elements must be non-null. If any set element is null, set injection will fail.

Summary

Public Methods
abstract LinkedBindingBuilder<T> addBinding()
Returns a binding builder used to add a new element in the set.
static <T> Multibinder<T> newSetBinder(Binder binder, TypeLiteral<T> type)
Returns a new multibinder that collects instances of type in a Set that is itself bound with no binding annotation.
static <T> Multibinder<T> newSetBinder(Binder binder, TypeLiteral<T> type, Class<? extends Annotation> annotationType)
Returns a new multibinder that collects instances of type in a Set that is itself bound with annotationType.
static <T> Multibinder<T> newSetBinder(Binder binder, TypeLiteral<T> type, Annotation annotation)
Returns a new multibinder that collects instances of type in a Set that is itself bound with annotation.
static <T> Multibinder<T> newSetBinder(Binder binder, Class<T> type)
Returns a new multibinder that collects instances of type in a Set that is itself bound with no binding annotation.
static <T> Multibinder<T> newSetBinder(Binder binder, Class<T> type, Class<? extends Annotation> annotationType)
Returns a new multibinder that collects instances of type in a Set that is itself bound with annotationType.
static <T> Multibinder<T> newSetBinder(Binder binder, Class<T> type, Annotation annotation)
Returns a new multibinder that collects instances of type in a Set that is itself bound with annotation.
abstract Multibinder<T> permitDuplicates()
Configures the bound set to silently discard duplicate elements.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public abstract LinkedBindingBuilder<T> addBinding ()

Returns a binding builder used to add a new element in the set. Each bound element must have a distinct value. Bound providers will be evaluated each time the set is injected.

It is an error to call this method without also calling one of the to methods on the returned binding builder.

Scoping elements independently is supported. Use the in method to specify a binding scope.

public static Multibinder<T> newSetBinder (Binder binder, TypeLiteral<T> type)

Returns a new multibinder that collects instances of type in a Set that is itself bound with no binding annotation.

public static Multibinder<T> newSetBinder (Binder binder, TypeLiteral<T> type, Class<? extends Annotation> annotationType)

Returns a new multibinder that collects instances of type in a Set that is itself bound with annotationType.

public static Multibinder<T> newSetBinder (Binder binder, TypeLiteral<T> type, Annotation annotation)

Returns a new multibinder that collects instances of type in a Set that is itself bound with annotation.

public static Multibinder<T> newSetBinder (Binder binder, Class<T> type)

Returns a new multibinder that collects instances of type in a Set that is itself bound with no binding annotation.

public static Multibinder<T> newSetBinder (Binder binder, Class<T> type, Class<? extends Annotation> annotationType)

Returns a new multibinder that collects instances of type in a Set that is itself bound with annotationType.

public static Multibinder<T> newSetBinder (Binder binder, Class<T> type, Annotation annotation)

Returns a new multibinder that collects instances of type in a Set that is itself bound with annotation.

public abstract Multibinder<T> permitDuplicates ()

Configures the bound set to silently discard duplicate elements. When multiple equal values are bound, the one that gets included is arbitrary. When multiple modules contribute elements to the set, this configuration option impacts all of them.

Returns
  • this multibinder
././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/multibindings/MapBinderBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/multibindings/MapBinderBi0000755000175000017500000005445511704661106031712 0ustar tonytony MapBinderBinding | Guice
public interface

MapBinderBinding

com.google.inject.multibindings.MapBinderBinding<T>

Class Overview

A binding for a MapBinder.

Although MapBinders may be injected through a variety of generic types (Map<K, V>, Map <K, Provider<V>>, Map<K, Set<V>>, Map>, and even Set<Map.Entry<K, Provider<V>>), a MapBinderBinding exists only on the Binding associated with the Map<K, V> key. Other bindings can be validated to be derived from this MapBinderBinding using containsElement(Element).

Summary

Public Methods
abstract boolean containsElement(Element element)
Returns true if this MapBinder contains the given Element in order to build the map or uses the given Element in order to support building and injecting the map.
abstract List<Entry<?, Binding<?>>> getEntries()
Returns all entries in the Map.
abstract TypeLiteral<?> getKeyTypeLiteral()
Returns the TypeLiteral describing the keys of the map.
abstract Key<T> getMapKey()
Returns the Key for the map.
abstract TypeLiteral<?> getValueTypeLiteral()
Returns the TypeLiteral describing the values of the map.
abstract boolean permitsDuplicates()
Returns true if the MapBinder permits duplicates.

Public Methods

public abstract boolean containsElement (Element element)

Returns true if this MapBinder contains the given Element in order to build the map or uses the given Element in order to support building and injecting the map. This will work for MapBinderBindings retrieved from an injector and getElements(Module...). Usually this is only necessary if you are working with elements retrieved from modules (without an Injector), otherwise getEntries() and permitsDuplicates() are better options.

If you need to introspect the details of the map, such as the keys, values or if it permits duplicates, it is necessary to pass the elements through an Injector and use getEntries() and permitsDuplicates().

public abstract List<Entry<?, Binding<?>>> getEntries ()

Returns all entries in the Map. The returned list of Map.Entries contains the key and a binding to the value. Duplicate keys or values will exist as separate Map.Entries in the returned list. This is only supported on bindings returned from an injector. This will throw UnsupportedOperationException if it is called on an element retrieved from getElements(Module...).

The elements will always match the type Map's generic type. For example, if getMapKey returns a key of Map<String, Snack>, then this will always return a list of type List<Map.Entry<String, Binding<Snack>>>.

public abstract TypeLiteral<?> getKeyTypeLiteral ()

Returns the TypeLiteral describing the keys of the map.

The TypeLiteral will always match the type Map's generic type. For example, if getMapKey returns a key of Map<String, Snack>, then this will always return a TypeLiteral<String>.

public abstract Key<T> getMapKey ()

Returns the Key for the map.

public abstract TypeLiteral<?> getValueTypeLiteral ()

Returns the TypeLiteral describing the values of the map.

The TypeLiteral will always match the type Map's generic type. For example, if getMapKey returns a key of Map<String, Snack>, then this will always return a TypeLiteral<Snack>.

public abstract boolean permitsDuplicates ()

Returns true if the MapBinder permits duplicates. This is only supported on bindings returned from an injector. This will throw UnsupportedOperationException if it is called on a MapBinderBinding retrieved from getElements(Module...).

././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/multibindings/MapBinder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/multibindings/MapBinder.h0000755000175000017500000010736011704661106031657 0ustar tonytony MapBinder | Guice
public abstract class

MapBinder

extends Object
java.lang.Object
   ↳ com.google.inject.multibindings.MapBinder<K, V>

Class Overview

An API to bind multiple map entries separately, only to later inject them as a complete map. MapBinder is intended for use in your application's module:


 public class SnacksModule extends AbstractModule {
   protected void configure() {
     MapBinder<String, Snack> mapbinder
         = MapBinder.newMapBinder(binder(), String.class, Snack.class);
     mapbinder.addBinding("twix").toInstance(new Twix());
     mapbinder.addBinding("snickers").toProvider(SnickersProvider.class);
     mapbinder.addBinding("skittles").to(Skittles.class);
   }
 }

With this binding, a Map<String, Snack> can now be injected:


 class SnackMachine {
   @Inject
   public SnackMachine(Map<String, Snack> snacks) { ... }
 }

In addition to binding Map<K, V>, a mapbinder will also bind Map<K, Provider<V>> for lazy value provision:


 class SnackMachine {
   @Inject
   public SnackMachine(Map<String, Provider<Snack>> snackProviders) { ... }
 }

Contributing mapbindings from different modules is supported. For example, it is okay to have both CandyModule and ChipsModule both create their own MapBinder<String, Snack>, and to each contribute bindings to the snacks map. When that map is injected, it will contain entries from both modules.

The map's iteration order is consistent with the binding order. This is convenient when multiple elements are contributed by the same module because that module can order its bindings appropriately. Avoid relying on the iteration order of elements contributed by different modules, since there is no equivalent mechanism to order modules.

The map is unmodifiable. Elements can only be added to the map by configuring the MapBinder. Elements can never be removed from the map.

Values are resolved at map injection time. If a value is bound to a provider, that provider's get method will be called each time the map is injected (unless the binding is also scoped, or a map of providers is injected).

Annotations are used to create different maps of the same key/value type. Each distinct annotation gets its own independent map.

Keys must be distinct. If the same key is bound more than once, map injection will fail. However, use permitDuplicates() in order to allow duplicate keys; extra bindings to Map<K, Set<V>> and Map<K, Set<Provider<V>> will be added.

Keys must be non-null. addBinding(null) will throw an unchecked exception.

Values must be non-null to use map injection. If any value is null, map injection will fail (although injecting a map of providers will not).

Summary

Public Methods
abstract LinkedBindingBuilder<V> addBinding(K key)
Returns a binding builder used to add a new entry in the map.
static <K, V> MapBinder<K, V> newMapBinder(Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType)
Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with no binding annotation.
static <K, V> MapBinder<K, V> newMapBinder(Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType, Class<? extends Annotation> annotationType)
Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotationType.
static <K, V> MapBinder<K, V> newMapBinder(Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType, Annotation annotation)
Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotation.
static <K, V> MapBinder<K, V> newMapBinder(Binder binder, Class<K> keyType, Class<V> valueType)
Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with no binding annotation.
static <K, V> MapBinder<K, V> newMapBinder(Binder binder, Class<K> keyType, Class<V> valueType, Class<? extends Annotation> annotationType)
Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotationType.
static <K, V> MapBinder<K, V> newMapBinder(Binder binder, Class<K> keyType, Class<V> valueType, Annotation annotation)
Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotation.
abstract MapBinder<K, V> permitDuplicates()
Configures the MapBinder to handle duplicate entries.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public abstract LinkedBindingBuilder<V> addBinding (K key)

Returns a binding builder used to add a new entry in the map. Each key must be distinct (and non-null). Bound providers will be evaluated each time the map is injected.

It is an error to call this method without also calling one of the to methods on the returned binding builder.

Scoping elements independently is supported. Use the in method to specify a binding scope.

public static MapBinder<K, V> newMapBinder (Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType)

Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with no binding annotation.

public static MapBinder<K, V> newMapBinder (Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType, Class<? extends Annotation> annotationType)

Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotationType.

public static MapBinder<K, V> newMapBinder (Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType, Annotation annotation)

Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotation.

public static MapBinder<K, V> newMapBinder (Binder binder, Class<K> keyType, Class<V> valueType)

Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with no binding annotation.

public static MapBinder<K, V> newMapBinder (Binder binder, Class<K> keyType, Class<V> valueType, Class<? extends Annotation> annotationType)

Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotationType.

public static MapBinder<K, V> newMapBinder (Binder binder, Class<K> keyType, Class<V> valueType, Annotation annotation)

Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotation.

public abstract MapBinder<K, V> permitDuplicates ()

Configures the MapBinder to handle duplicate entries.

When multiple equal keys are bound, the value that gets included in the map is arbitrary.

In addition to the Map<K, V> and Map<K, Provider<V>> maps that are normally bound, a Map<K, Set<V>> and Map<K, Set<Provider<V>>> are also bound, which contain all values bound to each key.

When multiple modules contribute elements to the map, this configuration option impacts all of them.

Returns
  • this map binder
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/matcher/0000755000175000017500000000000011704661106026406 5ustar tonytony././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/matcher/package-summary.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/matcher/package-summary.h0000755000175000017500000002601211704661106031651 0ustar tonytony com.google.inject.matcher | Guice
package

com.google.inject.matcher

Classes | Description

Used for matching things.

more...

Interfaces

Matcher<T> Returns true or false for a given input. 

Classes

AbstractMatcher<T> Implements and() and or()
Matchers Matcher implementations. 
././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/matcher/package-descr.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/matcher/package-descr.htm0000755000175000017500000002352111704661106031617 0ustar tonytony com.google.inject.matcher Details | Guice
package

com.google.inject.matcher

Classes | Description

Used for matching things. Primarily used to pick out methods to which to apply interceptors.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/matcher/Matchers.html0000755000175000017500000007477111704661106031065 0ustar tonytony Matchers | Guice
public class

Matchers

extends Object
java.lang.Object
   ↳ com.google.inject.matcher.Matchers

Class Overview

Matcher implementations. Supports matching classes and methods.

Summary

Public Methods
static Matcher<AnnotatedElement> annotatedWith(Class<? extends Annotation> annotationType)
Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.
static Matcher<AnnotatedElement> annotatedWith(Annotation annotation)
Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.
static Matcher<Object> any()
Returns a matcher which matches any input.
static Matcher<Object> identicalTo(Object value)
Returns a matcher which matches only the given object.
static Matcher<Class> inPackage(Package targetPackage)
Returns a matcher which matches classes in the given package.
static Matcher<Class> inSubpackage(String targetPackageName)
Returns a matcher which matches classes in the given package and its subpackages.
static <T> Matcher<T> not(Matcher<? super T> p)
Inverts the given matcher.
static Matcher<Object> only(Object value)
Returns a matcher which matches objects equal to the given object.
static Matcher<Method> returns(Matcher<? super Class<?>> returnType)
Returns a matcher which matches methods with matching return types.
static Matcher<Class> subclassesOf(Class<?> superclass)
Returns a matcher which matches subclasses of the given type (as well as the given type).
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Matcher<AnnotatedElement> annotatedWith (Class<? extends Annotation> annotationType)

Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.

public static Matcher<AnnotatedElement> annotatedWith (Annotation annotation)

Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.

public static Matcher<Object> any ()

Returns a matcher which matches any input.

public static Matcher<Object> identicalTo (Object value)

Returns a matcher which matches only the given object.

public static Matcher<Class> inPackage (Package targetPackage)

Returns a matcher which matches classes in the given package. Packages are specific to their classloader, so classes with the same package name may not have the same package at runtime.

public static Matcher<Class> inSubpackage (String targetPackageName)

Returns a matcher which matches classes in the given package and its subpackages. Unlike inPackage(), this matches classes from any classloader.

public static Matcher<T> not (Matcher<? super T> p)

Inverts the given matcher.

public static Matcher<Object> only (Object value)

Returns a matcher which matches objects equal to the given object.

public static Matcher<Method> returns (Matcher<? super Class<?>> returnType)

Returns a matcher which matches methods with matching return types.

public static Matcher<Class> subclassesOf (Class<?> superclass)

Returns a matcher which matches subclasses of the given type (as well as the given type).

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/matcher/Matcher.html0000755000175000017500000004140311704661106030664 0ustar tonytony Matcher | Guice
public interface

Matcher

com.google.inject.matcher.Matcher<T>
Known Indirect Subclasses

Class Overview

Returns true or false for a given input.

Summary

Public Methods
abstract Matcher<T> and(Matcher<? super T> other)
Returns a new matcher which returns true if both this and the given matcher return true.
abstract boolean matches(T t)
Returns true if this matches t, false otherwise.
abstract Matcher<T> or(Matcher<? super T> other)
Returns a new matcher which returns true if either this or the given matcher return true.

Public Methods

public abstract Matcher<T> and (Matcher<? super T> other)

Returns a new matcher which returns true if both this and the given matcher return true.

public abstract boolean matches (T t)

Returns true if this matches t, false otherwise.

public abstract Matcher<T> or (Matcher<? super T> other)

Returns a new matcher which returns true if either this or the given matcher return true.

././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/matcher/AbstractMatcher.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/matcher/AbstractMatcher.h0000755000175000017500000005644211704661106031644 0ustar tonytony AbstractMatcher | Guice
public abstract class

AbstractMatcher

extends Object
implements Matcher<T>
java.lang.Object
   ↳ com.google.inject.matcher.AbstractMatcher<T>

Class Overview

Implements and() and or().

Summary

Public Constructors
AbstractMatcher()
Public Methods
Matcher<T> and(Matcher<? super T> other)
Returns a new matcher which returns true if both this and the given matcher return true.
Matcher<T> or(Matcher<? super T> other)
Returns a new matcher which returns true if either this or the given matcher return true.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.matcher.Matcher

Public Constructors

public AbstractMatcher ()

Public Methods

public Matcher<T> and (Matcher<? super T> other)

Returns a new matcher which returns true if both this and the given matcher return true.

public Matcher<T> or (Matcher<? super T> other)

Returns a new matcher which returns true if either this or the given matcher return true.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/jndi/0000755000175000017500000000000011704661106025707 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/jndi/package-summary.html0000755000175000017500000002400211704661106031664 0ustar tonytony com.google.inject.jndi | Guice
package

com.google.inject.jndi

Classes | Description

JNDI integration; this extension requires guice-jndi-3.0.jar.

more...

Classes

JndiIntegration Integrates Guice with JNDI. 
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/jndi/package-descr.html0000755000175000017500000002276211704661106031302 0ustar tonytony com.google.inject.jndi Details | Guice
package

com.google.inject.jndi

Classes | Description

JNDI integration; this extension requires guice-jndi-3.0.jar.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/jndi/JndiIntegration.html0000755000175000017500000004155311704661106031700 0ustar tonytony JndiIntegration | Guice
public class

JndiIntegration

extends Object
java.lang.Object
   ↳ com.google.inject.jndi.JndiIntegration

Class Overview

Integrates Guice with JNDI. Requires a binding to javax.naming.Context.

Summary

Public Methods
static <T> Provider<T> fromJndi(Class<T> type, String name)
Creates a provider which looks up objects in JNDI using the given name.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Provider<T> fromJndi (Class<T> type, String name)

Creates a provider which looks up objects in JNDI using the given name. Example usage:

 bind(DataSource.class).toProvider(fromJndi(DataSource.class, "java:..."));
 

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/0000755000175000017500000000000011704661106026413 5ustar tonytony././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/package-summary.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/package-summary.h0000755000175000017500000005275311704661106031671 0ustar tonytony com.google.inject.grapher | Guice
package

com.google.inject.grapher

Interfaces

BindingEdge<K> Interface for an edge that connects an interface to the type or instance that is bound to implement it. 
BindingEdge.Factory<K, T extends BindingEdge<K>> Factory interface for BindingEdges. 
DependencyEdge<K> Interface for an edge from a class or InjectionPoint to the interface node that will satisfy the dependency. 
DependencyEdge.Factory<K, T extends DependencyEdge<K>> Factory interface for DependencyEdges. 
ImplementationNode<K> Node for classes and instances that have Dependencys and are bound to InterfaceNodes. 
ImplementationNode.Factory<K, T extends ImplementationNode<K>> Factory interface for ImplementationNodes. 
InterfaceNode<K> Node for an interface class that has been bound to an implementation class or instance. 
InterfaceNode.Factory<K, T extends InterfaceNode<K>> Factory interface for InterfaceNodes. 
NameFactory Interface for a service that provides nice Strings that we can display in the graph for the types that come up in Bindings. 
NodeAliasFactory<K> Factory for aliasing one node ID to another. 
NodeIdFactory<K> Factory for abstract identifiers for elements on the graph. 
Renderer Interface for the service that renders the graph. 

Classes

GrapherModule Module for the common bindings for InjectorGrapher
GraphingVisitor<K, N extends InterfaceNode<K>, M extends ImplementationNode<K>, B extends BindingEdge<K>, D extends DependencyEdge<K>> BindingTargetVisitor that adds nodes and edges to the graph based on the visited Binding
InjectorGrapher Root class for graphing an Injector
ShortNameFactory Reasonable implementation for NameFactory
StringNodeIdFactory IdFactory implementation that for String node IDs. 
TransitiveDependencyVisitor BindingTargetVisitor that returns a Collection of the Keys of each Binding's dependencies. 

Enums

BindingEdge.Type Classification for what kind of binding this edge represents. 
././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/package-descr.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/package-descr.htm0000755000175000017500000003206211704661106031624 0ustar tonytony com.google.inject.grapher Details | Guice
package

com.google.inject.grapher

Classes | Description

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/0000755000175000017500000000000011704661106030245 5ustar tonytony././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/package-summary.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/package-0000755000175000017500000005155011704661106031651 0ustar tonytony com.google.inject.grapher.graphviz | Guice
package

com.google.inject.grapher.graphviz

Interfaces

PortIdFactory Interface for a service that returns Graphviz port IDs, used for naming the rows in ImplementationNode-displaying GraphvizNodes. 

Classes

BindingEdgeFactory Graphviz-specific implementation of BindingEdge.Factory
BindingEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts BindingEdge methods to display operations on a GraphvizEdge
DependencyEdgeFactory Graphviz-specific implementation of DependencyEdge.Factory
DependencyEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts DependencyEdge methods to display operations on a GraphvizEdge
GraphvizEdge Data object to encapsulate the attributes of Graphviz edges that we're interested in drawing. 
GraphvizModule Module that provides GraphvizRenderer as the Renderer and binds the other Graphviz factories. 
GraphvizNode Data object to encapsulate the attributes of Graphviz nodes that we're interested in drawing. 
GraphvizRenderer Renderer implementation that writes out a Graphviz DOT file of the graph. 
ImplementationNodeFactory Graphviz-specific implementation of ImplementationNode.Factory
ImplementationNodeFactory.GraphvizNodeAdaptor Adaptor class that converts ImplementationNode methods to display operations on a GraphvizNode
InterfaceNodeFactory Graphviz-specific implementation of InterfaceNode.Factory
InterfaceNodeFactory.GraphvizNodeAdaptor Adaptor class that converts InterfaceNode methods to display operations on a GraphvizNode
PortIdFactoryImpl Implementation of PortIdFactory

Enums

ArrowType Arrow symbols that are available from Graphviz. 
CompassPoint Enum for the "compass point" values used to control where edge end points appear on the graph. 
EdgeStyle Styles for edges. 
NodeShape Enum for the shapes that are most interesting for Guice graphing. 
NodeStyle Styles for nodes. 
././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/package-descr.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/package-0000755000175000017500000003075511704661106031655 0ustar tonytony com.google.inject.grapher.graphviz Details | Guice
package

com.google.inject.grapher.graphviz

Classes | Description

././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/PortIdFactoryImpl.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/PortIdFa0000755000175000017500000005503611704661106031654 0ustar tonytony PortIdFactoryImpl | Guice
public class

PortIdFactoryImpl

extends Object
implements PortIdFactory
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.PortIdFactoryImpl

Class Overview

Implementation of PortIdFactory. Bound in GraphvizModule.

Summary

Public Constructors
PortIdFactoryImpl()
Public Methods
String getPortId(Member member)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.graphviz.PortIdFactory

Public Constructors

public PortIdFactoryImpl ()

Public Methods

public String getPortId (Member member)

././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/PortIdFactory.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/PortIdFa0000755000175000017500000004065011704661106031650 0ustar tonytony PortIdFactory | Guice
public interface

PortIdFactory

com.google.inject.grapher.graphviz.PortIdFactory
Known Indirect Subclasses

Class Overview

Interface for a service that returns Graphviz port IDs, used for naming the rows in ImplementationNode-displaying GraphvizNodes. Implemented by StringNodeIdFactory.

Summary

Public Methods
abstract String getPortId(Member member)

Public Methods

public abstract String getPortId (Member member)

././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/NodeStyle.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/NodeStyl0000755000175000017500000010522411704661106031740 0ustar tonytony NodeStyle | Guice
public final enum

NodeStyle

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.grapher.graphviz.NodeStyle

Class Overview

Styles for nodes. Similar to EdgeStyle but with a few more options.

See: http://www.graphviz.org/doc/info/attrs.html#k:style

Summary

Enum Values
NodeStyle  BOLD   
NodeStyle  DASHED   
NodeStyle  DIAGONALS   
NodeStyle  DOTTED   
NodeStyle  FILLED   
NodeStyle  INVISIBLE   
NodeStyle  ROUNDED   
NodeStyle  SOLID   
Public Methods
String toString()
static NodeStyle valueOf(String name)
final static NodeStyle[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final NodeStyle BOLD

Since: API Level

public static final NodeStyle DASHED

Since: API Level

public static final NodeStyle DIAGONALS

Since: API Level

public static final NodeStyle DOTTED

Since: API Level

public static final NodeStyle FILLED

Since: API Level

public static final NodeStyle INVISIBLE

Since: API Level

public static final NodeStyle ROUNDED

Since: API Level

public static final NodeStyle SOLID

Since: API Level

Public Methods

public String toString ()

Since: API Level

public static NodeStyle valueOf (String name)

public static final NodeStyle[] values ()

././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/NodeShape.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/NodeShap0000755000175000017500000007436311704661106031711 0ustar tonytony NodeShape | Guice
public final enum

NodeShape

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.grapher.graphviz.NodeShape

Class Overview

Enum for the shapes that are most interesting for Guice graphing.

See: http://www.graphviz.org/doc/info/shapes.html

Summary

Enum Values
NodeShape  BOX   
NodeShape  ELLIPSE   
NodeShape  NONE   
Public Methods
String toString()
static NodeShape valueOf(String name)
final static NodeShape[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final NodeShape BOX

Since: API Level

public static final NodeShape ELLIPSE

Since: API Level

public static final NodeShape NONE

Since: API Level

Public Methods

public String toString ()

Since: API Level

public static NodeShape valueOf (String name)

public static final NodeShape[] values ()

././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/InterfaceNodeFactory.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/Interfac0000755000175000017500000006106011704661106031731 0ustar tonytony InterfaceNodeFactory | Guice
public class

InterfaceNodeFactory

extends Object
implements InterfaceNode.Factory<K, T extends InterfaceNode<K>>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.InterfaceNodeFactory

Class Overview

Graphviz-specific implementation of InterfaceNode.Factory. Uses a GraphvizEdgeAdaptor to delegate to a GraphvizNode.

Summary

Nested Classes
class InterfaceNodeFactory.GraphvizNodeAdaptor Adaptor class that converts InterfaceNode methods to display operations on a GraphvizNode
Public Constructors
InterfaceNodeFactory(GraphvizRenderer renderer, NameFactory nameFactory)
Public Methods
InterfaceNode<String> newInterfaceNode(String nodeId)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.InterfaceNode.Factory

Public Constructors

public InterfaceNodeFactory (GraphvizRenderer renderer, NameFactory nameFactory)

Public Methods

public InterfaceNode<String> newInterfaceNode (String nodeId)

././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/InterfaceNodeFactory.GraphvizNodeAdaptor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/Interfac0000755000175000017500000006371511704661106031742 0ustar tonytony InterfaceNodeFactory.GraphvizNodeAdaptor | Guice
protected class

InterfaceNodeFactory.GraphvizNodeAdaptor

extends Object
implements InterfaceNode<K>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.InterfaceNodeFactory.GraphvizNodeAdaptor

Class Overview

Adaptor class that converts InterfaceNode methods to display operations on a GraphvizNode.

Summary

Fields
protected final GraphvizNode node
Public Constructors
InterfaceNodeFactory.GraphvizNodeAdaptor(GraphvizNode node)
Public Methods
void setKey(Key<?> key)
void setSource(Object source)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.InterfaceNode

Fields

protected final GraphvizNode node

Public Constructors

public InterfaceNodeFactory.GraphvizNodeAdaptor (GraphvizNode node)

Public Methods

public void setKey (Key<?> key)

public void setSource (Object source)

././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/ImplementationNodeFactory.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/Implemen0000755000175000017500000006605311704661106031753 0ustar tonytony ImplementationNodeFactory | Guice
public class

ImplementationNodeFactory

extends Object
implements ImplementationNode.Factory<K, T extends ImplementationNode<K>>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.ImplementationNodeFactory

Class Overview

Graphviz-specific implementation of ImplementationNode.Factory. Uses a BindingEdgeFactory.GraphvizEdgeAdaptor to delegate to a GraphvizNode.

Summary

Nested Classes
class ImplementationNodeFactory.GraphvizNodeAdaptor Adaptor class that converts ImplementationNode methods to display operations on a GraphvizNode
Public Constructors
ImplementationNodeFactory(GraphvizRenderer renderer, NameFactory nameFactory, PortIdFactory portIdFactory)
Public Methods
ImplementationNode<String> newImplementationNode(String nodeId)
Protected Methods
ImplementationNodeFactory.GraphvizNodeAdaptor newAdaptor(GraphvizNode node)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.ImplementationNode.Factory

Public Constructors

public ImplementationNodeFactory (GraphvizRenderer renderer, NameFactory nameFactory, PortIdFactory portIdFactory)

Public Methods

public ImplementationNode<String> newImplementationNode (String nodeId)

Protected Methods

././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/ImplementationNodeFactory.GraphvizNodeAdaptor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/Implemen0000755000175000017500000007372711704661106031761 0ustar tonytony ImplementationNodeFactory.GraphvizNodeAdaptor | Guice
protected class

ImplementationNodeFactory.GraphvizNodeAdaptor

extends Object
implements ImplementationNode<K>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.ImplementationNodeFactory.GraphvizNodeAdaptor

Class Overview

Adaptor class that converts ImplementationNode methods to display operations on a GraphvizNode.

Summary

Fields
protected final GraphvizNode node
Public Constructors
ImplementationNodeFactory.GraphvizNodeAdaptor(GraphvizNode node)
Public Methods
void addMember(Member member)
void setClassKey(Key<?> key)
Sets the Key that this node is for.
void setInstance(Object instance)
Sets the Object that's the already-created instance.
void setSource(Object source)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.ImplementationNode

Fields

protected final GraphvizNode node

Public Constructors

public ImplementationNodeFactory.GraphvizNodeAdaptor (GraphvizNode node)

Public Methods

public void addMember (Member member)

public void setClassKey (Key<?> key)

Sets the Key that this node is for. Used when the node is representing a class that Guice will instantiate.

public void setInstance (Object instance)

Sets the Object that's the already-created instance. Used when this node is represeting the instance instead of a class.

public void setSource (Object source)

././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/GraphvizRenderer.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/Graphviz0000755000175000017500000013375311704661106032001 0ustar tonytony GraphvizRenderer | Guice
public class

GraphvizRenderer

extends Object
implements NodeAliasFactory<K> Renderer
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.GraphvizRenderer

Class Overview

Renderer implementation that writes out a Graphviz DOT file of the graph. Bound in GraphvizModule.

Specify the PrintWriter to output to with setOut(PrintWriter).

Summary

Public Constructors
GraphvizRenderer()
Public Methods
void addEdge(GraphvizEdge edge)
void addNode(GraphvizNode node)
void newAlias(String fromId, String toId)
void render()
GraphvizRenderer setOut(PrintWriter out)
GraphvizRenderer setRankdir(String rankdir)
Protected Methods
void finish()
String getArrowString(List<ArrowType> arrows)
Turns a List of ArrowTypes into a String that represents combining them.
Map<String, String> getEdgeAttributes(GraphvizEdge edge)
String getEdgeEndPoint(String nodeId, String portId, CompassPoint compassPoint)
Map<String, String> getGraphAttributes()
Map<String, String> getNodeAttributes(GraphvizNode node)
String getNodeLabel(GraphvizNode node)
Creates the "label" for a node.
String htmlEscape(String str)
void renderEdge(GraphvizEdge edge)
void renderNode(GraphvizNode node)
String resolveAlias(String id)
void start()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.NodeAliasFactory
From interface com.google.inject.grapher.Renderer

Public Constructors

public GraphvizRenderer ()

Public Methods

public void addEdge (GraphvizEdge edge)

public void addNode (GraphvizNode node)

public void newAlias (String fromId, String toId)

public void render ()

public GraphvizRenderer setOut (PrintWriter out)

public GraphvizRenderer setRankdir (String rankdir)

Protected Methods

protected void finish ()

protected String getArrowString (List<ArrowType> arrows)

Turns a List of ArrowTypes into a String that represents combining them. With Graphviz, that just means concatenating them.

protected Map<String, String> getEdgeAttributes (GraphvizEdge edge)

protected String getEdgeEndPoint (String nodeId, String portId, CompassPoint compassPoint)

protected Map<String, String> getGraphAttributes ()

protected Map<String, String> getNodeAttributes (GraphvizNode node)

protected String getNodeLabel (GraphvizNode node)

Creates the "label" for a node. This is a string of HTML that defines a table with a heading at the top and (in the case of ImplementationNodes) rows for each of the member fields.

protected String htmlEscape (String str)

protected void renderEdge (GraphvizEdge edge)

protected void renderNode (GraphvizNode node)

protected String resolveAlias (String id)

protected void start ()

././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/GraphvizNode.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/Graphviz0000755000175000017500000011052311704661106031767 0ustar tonytony GraphvizNode | Guice
public class

GraphvizNode

extends Object
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.GraphvizNode

Class Overview

Data object to encapsulate the attributes of Graphviz nodes that we're interested in drawing.

Summary

Public Constructors
GraphvizNode(String nodeId)
Public Methods
void addField(String portId, String title)
void addSubtitle(int position, String subtitle)
Map<String, String> getFields()
String getHeaderBackgroundColor()
String getHeaderTextColor()
String getNodeId()
NodeShape getShape()
NodeStyle getStyle()
List<String> getSubtitles()
String getTitle()
void setHeaderBackgroundColor(String headerBackgroundColor)
void setHeaderTextColor(String headerTextColor)
void setShape(NodeShape shape)
void setStyle(NodeStyle style)
void setTitle(String title)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public GraphvizNode (String nodeId)

Public Methods

public void addField (String portId, String title)

public void addSubtitle (int position, String subtitle)

public Map<String, String> getFields ()

public String getHeaderBackgroundColor ()

public String getHeaderTextColor ()

public String getNodeId ()

public NodeShape getShape ()

public NodeStyle getStyle ()

public List<String> getSubtitles ()

public String getTitle ()

public void setHeaderBackgroundColor (String headerBackgroundColor)

public void setHeaderTextColor (String headerTextColor)

public void setShape (NodeShape shape)

public void setStyle (NodeStyle style)

public void setTitle (String title)

././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/GraphvizModule.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/Graphviz0000755000175000017500000011272211704661106031772 0ustar tonytony GraphvizModule | Guice
public class

GraphvizModule

extends AbstractModule
java.lang.Object
   ↳ com.google.inject.AbstractModule
     ↳ com.google.inject.grapher.graphviz.GraphvizModule

Class Overview

Module that provides GraphvizRenderer as the Renderer and binds the other Graphviz factories.

Summary

Public Constructors
GraphvizModule()
Protected Methods
void configure()
Configures a Binder via the exposed methods.
[Expand]
Inherited Methods
From class com.google.inject.AbstractModule
From class java.lang.Object
From interface com.google.inject.Module

Public Constructors

public GraphvizModule ()

Protected Methods

protected void configure ()

Configures a Binder via the exposed methods.

././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/GraphvizEdge.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/Graphviz0000755000175000017500000011533011704661106031770 0ustar tonytony GraphvizEdge | Guice
public class

GraphvizEdge

extends Object
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.GraphvizEdge

Class Overview

Data object to encapsulate the attributes of Graphviz edges that we're interested in drawing.

Summary

Public Constructors
GraphvizEdge(String tailNodeId, String headNodeId)
Public Methods
List<ArrowType> getArrowHead()
List<ArrowType> getArrowTail()
CompassPoint getHeadCompassPoint()
String getHeadNodeId()
String getHeadPortId()
EdgeStyle getStyle()
CompassPoint getTailCompassPoint()
String getTailNodeId()
String getTailPortId()
void setArrowHead(List<ArrowType> arrowHead)
void setArrowTail(List<ArrowType> arrowTail)
void setHeadCompassPoint(CompassPoint headCompassPoint)
void setHeadPortId(String headPortId)
void setStyle(EdgeStyle style)
void setTailCompassPoint(CompassPoint tailCompassPoint)
void setTailPortId(String tailPortId)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public GraphvizEdge (String tailNodeId, String headNodeId)

Public Methods

public List<ArrowType> getArrowHead ()

public List<ArrowType> getArrowTail ()

public CompassPoint getHeadCompassPoint ()

public String getHeadNodeId ()

public String getHeadPortId ()

public EdgeStyle getStyle ()

public CompassPoint getTailCompassPoint ()

public String getTailNodeId ()

public String getTailPortId ()

public void setArrowHead (List<ArrowType> arrowHead)

public void setArrowTail (List<ArrowType> arrowTail)

public void setHeadCompassPoint (CompassPoint headCompassPoint)

public void setHeadPortId (String headPortId)

public void setStyle (EdgeStyle style)

public void setTailCompassPoint (CompassPoint tailCompassPoint)

public void setTailPortId (String tailPortId)

././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/EdgeStyle.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/EdgeStyl0000755000175000017500000007766311704661106031736 0ustar tonytony EdgeStyle | Guice
public final enum

EdgeStyle

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.grapher.graphviz.EdgeStyle

Class Overview

Styles for edges.

See: http://www.graphviz.org/doc/info/attrs.html#k:style

Summary

Enum Values
EdgeStyle  BOLD   
EdgeStyle  DASHED   
EdgeStyle  DOTTED   
EdgeStyle  INVISIBLE   
EdgeStyle  SOLID   
Public Methods
String toString()
static EdgeStyle valueOf(String name)
final static EdgeStyle[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final EdgeStyle BOLD

Since: API Level

public static final EdgeStyle DASHED

Since: API Level

public static final EdgeStyle DOTTED

Since: API Level

public static final EdgeStyle INVISIBLE

Since: API Level

public static final EdgeStyle SOLID

Since: API Level

Public Methods

public String toString ()

Since: API Level

public static EdgeStyle valueOf (String name)

public static final EdgeStyle[] values ()

././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/DependencyEdgeFactory.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/Dependen0000755000175000017500000006611711704661106031730 0ustar tonytony DependencyEdgeFactory | Guice
public class

DependencyEdgeFactory

extends Object
implements DependencyEdge.Factory<K, T extends DependencyEdge<K>>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.DependencyEdgeFactory

Class Overview

Graphviz-specific implementation of DependencyEdge.Factory. Uses a DependencyEdgeFactory.GraphvizEdgeAdaptor to delegate to a GraphvizEdge.

Summary

Nested Classes
class DependencyEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts DependencyEdge methods to display operations on a GraphvizEdge
Public Constructors
DependencyEdgeFactory(GraphvizRenderer renderer, PortIdFactory portIdFactory)
Public Methods
DependencyEdge<String> newDependencyEdge(String fromId, InjectionPoint fromPoint, String toId)
Protected Methods
DependencyEdgeFactory.GraphvizEdgeAdaptor newAdaptor(GraphvizEdge edge)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.DependencyEdge.Factory

Public Constructors

public DependencyEdgeFactory (GraphvizRenderer renderer, PortIdFactory portIdFactory)

Public Methods

public DependencyEdge<String> newDependencyEdge (String fromId, InjectionPoint fromPoint, String toId)

Protected Methods

././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/DependencyEdgeFactory.GraphvizEdgeAdaptor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/Dependen0000755000175000017500000005317411704661106031727 0ustar tonytony DependencyEdgeFactory.GraphvizEdgeAdaptor | Guice
protected class

DependencyEdgeFactory.GraphvizEdgeAdaptor

extends Object
implements DependencyEdge<K>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.DependencyEdgeFactory.GraphvizEdgeAdaptor

Class Overview

Adaptor class that converts DependencyEdge methods to display operations on a GraphvizEdge.

Summary

Fields
protected final GraphvizEdge edge
Public Constructors
DependencyEdgeFactory.GraphvizEdgeAdaptor(GraphvizEdge edge)
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected final GraphvizEdge edge

Public Constructors

public DependencyEdgeFactory.GraphvizEdgeAdaptor (GraphvizEdge edge)

././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/CompassPoint.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/CompassP0000755000175000017500000011077411704661106031732 0ustar tonytony CompassPoint | Guice
public final enum

CompassPoint

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.grapher.graphviz.CompassPoint

Class Overview

Enum for the "compass point" values used to control where edge end points appear on the graph.

See: http://www.graphviz.org/doc/info/attrs.html#k:portPos

Summary

Enum Values
CompassPoint  CENTER   
CompassPoint  EAST   
CompassPoint  EXTERIOR_SIDE   
CompassPoint  NORTH   
CompassPoint  NORTH_EAST   
CompassPoint  NORTH_WEST   
CompassPoint  SOUTH   
CompassPoint  SOUTH_EAST   
CompassPoint  SOUTH_WEST   
CompassPoint  WEST   
Public Methods
String toString()
static CompassPoint valueOf(String name)
final static CompassPoint[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final CompassPoint CENTER

Since: API Level

public static final CompassPoint EAST

Since: API Level

public static final CompassPoint EXTERIOR_SIDE

Since: API Level

public static final CompassPoint NORTH

Since: API Level

public static final CompassPoint NORTH_EAST

Since: API Level

public static final CompassPoint NORTH_WEST

Since: API Level

public static final CompassPoint SOUTH

Since: API Level

public static final CompassPoint SOUTH_EAST

Since: API Level

public static final CompassPoint SOUTH_WEST

Since: API Level

public static final CompassPoint WEST

Since: API Level

Public Methods

public String toString ()

Since: API Level

public static CompassPoint valueOf (String name)

public static final CompassPoint[] values ()

././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/BindingEdgeFactory.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/BindingE0000755000175000017500000006436511704661106031670 0ustar tonytony BindingEdgeFactory | Guice
public class

BindingEdgeFactory

extends Object
implements BindingEdge.Factory<K, T extends BindingEdge<K>>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.BindingEdgeFactory

Class Overview

Graphviz-specific implementation of BindingEdge.Factory. Uses a BindingEdgeFactory.GraphvizEdgeAdaptor to delegate to a GraphvizEdge.

Summary

Nested Classes
class BindingEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts BindingEdge methods to display operations on a GraphvizEdge
Public Constructors
BindingEdgeFactory(GraphvizRenderer renderer)
Public Methods
BindingEdge<String> newBindingEdge(String fromId, String toId)
Protected Methods
BindingEdgeFactory.GraphvizEdgeAdaptor newAdaptor(GraphvizEdge edge)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.BindingEdge.Factory

Public Constructors

public BindingEdgeFactory (GraphvizRenderer renderer)

Public Methods

public BindingEdge<String> newBindingEdge (String fromId, String toId)

Protected Methods

././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/BindingEdgeFactory.GraphvizEdgeAdaptor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/BindingE0000755000175000017500000006104111704661106031654 0ustar tonytony BindingEdgeFactory.GraphvizEdgeAdaptor | Guice
protected class

BindingEdgeFactory.GraphvizEdgeAdaptor

extends Object
implements BindingEdge<K>
java.lang.Object
   ↳ com.google.inject.grapher.graphviz.BindingEdgeFactory.GraphvizEdgeAdaptor

Class Overview

Adaptor class that converts BindingEdge methods to display operations on a GraphvizEdge.

Summary

Fields
protected final GraphvizEdge edge
Public Constructors
BindingEdgeFactory.GraphvizEdgeAdaptor(GraphvizEdge edge)
Public Methods
void setType(BindingEdge.Type type)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.BindingEdge

Fields

protected final GraphvizEdge edge

Public Constructors

public BindingEdgeFactory.GraphvizEdgeAdaptor (GraphvizEdge edge)

Public Methods

public void setType (BindingEdge.Type type)

././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/ArrowType.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/graphviz/ArrowTyp0000755000175000017500000011741311704661106031771 0ustar tonytony ArrowType | Guice
public final enum

ArrowType

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.grapher.graphviz.ArrowType

Class Overview

Arrow symbols that are available from Graphviz. These can be composed by concatenation to make double arrows and such.

See: http://www.graphviz.org/doc/info/arrows.html

Summary

Enum Values
ArrowType  BOX   
ArrowType  BOX_OPEN   
ArrowType  CROW   
ArrowType  DIAMOND   
ArrowType  DIAMOND_OPEN   
ArrowType  DOT   
ArrowType  DOT_OPEN   
ArrowType  INVERTED   
ArrowType  INVERTED_OPEN   
ArrowType  NONE   
ArrowType  NORMAL   
ArrowType  NORMAL_OPEN   
ArrowType  TEE   
ArrowType  VEE   
Public Methods
String toString()
static ArrowType valueOf(String name)
final static ArrowType[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final ArrowType BOX

Since: API Level

public static final ArrowType BOX_OPEN

Since: API Level

public static final ArrowType CROW

Since: API Level

public static final ArrowType DIAMOND

Since: API Level

public static final ArrowType DIAMOND_OPEN

Since: API Level

public static final ArrowType DOT

Since: API Level

public static final ArrowType DOT_OPEN

Since: API Level

public static final ArrowType INVERTED

Since: API Level

public static final ArrowType INVERTED_OPEN

Since: API Level

public static final ArrowType NONE

Since: API Level

public static final ArrowType NORMAL

Since: API Level

public static final ArrowType NORMAL_OPEN

Since: API Level

public static final ArrowType TEE

Since: API Level

public static final ArrowType VEE

Since: API Level

Public Methods

public String toString ()

Since: API Level

public static ArrowType valueOf (String name)

public static final ArrowType[] values ()

././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/TransitiveDependencyVisitor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/TransitiveDepende0000755000175000017500000012104011704661106031754 0ustar tonytony TransitiveDependencyVisitor | Guice
public class

TransitiveDependencyVisitor

extends Object
implements BindingTargetVisitor<T, V>
java.lang.Object
   ↳ com.google.inject.grapher.TransitiveDependencyVisitor

Class Overview

BindingTargetVisitor that returns a Collection of the Keys of each Binding's dependencies. Used by InjectorGropher to walk the dependency graph from a starting set of Bindings.

Summary

Public Constructors
TransitiveDependencyVisitor()
Public Methods
Collection<Key<?>> visit(ConstructorBinding<?> binding)
Collection<Key<?>> visit(ConvertedConstantBinding<?> binding)
Collection<Key<?>> visit(ExposedBinding<?> binding)
Collection<Key<?>> visit(InstanceBinding<?> binding)
Collection<Key<?>> visit(LinkedKeyBinding<?> binding)
Collection<Key<?>> visit(ProviderBinding<?> binding)
Collection<Key<?>> visit(ProviderInstanceBinding<?> binding)
Collection<Key<?>> visit(ProviderKeyBinding<?> binding)
Collection<Key<?>> visit(UntargettedBinding<?> binding)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.BindingTargetVisitor

Public Constructors

public TransitiveDependencyVisitor ()

Public Methods

public Collection<Key<?>> visit (ConstructorBinding<?> binding)

public Collection<Key<?>> visit (ConvertedConstantBinding<?> binding)

public Collection<Key<?>> visit (ExposedBinding<?> binding)

public Collection<Key<?>> visit (InstanceBinding<?> binding)

public Collection<Key<?>> visit (LinkedKeyBinding<?> binding)

public Collection<Key<?>> visit (ProviderBinding<?> binding)

public Collection<Key<?>> visit (ProviderInstanceBinding<?> binding)

public Collection<Key<?>> visit (ProviderKeyBinding<?> binding)

public Collection<Key<?>> visit (UntargettedBinding<?> binding)

././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/StringNodeIdFactory.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/StringNodeIdFacto0000755000175000017500000006142211704661106031654 0ustar tonytony StringNodeIdFactory | Guice
public class

StringNodeIdFactory

extends Object
implements NodeIdFactory<K>
java.lang.Object
   ↳ com.google.inject.grapher.StringNodeIdFactory

Class Overview

IdFactory implementation that for String node IDs. The IDs are comprised of letters, numbers and underscores.

Summary

Public Constructors
StringNodeIdFactory()
Public Methods
String getClassNodeId(Key<?> key)
String getInstanceNodeId(Key<?> key)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.NodeIdFactory

Public Constructors

public StringNodeIdFactory ()

Public Methods

public String getClassNodeId (Key<?> key)

public String getInstanceNodeId (Key<?> key)

././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/ShortNameFactory.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/ShortNameFactory.0000755000175000017500000010024311704661106031647 0ustar tonytony ShortNameFactory | Guice
public class

ShortNameFactory

extends Object
implements NameFactory
java.lang.Object
   ↳ com.google.inject.grapher.ShortNameFactory

Class Overview

Reasonable implementation for NameFactory. Mostly takes various toString()s and strips package names out of them so that they'll fit on the graph.

Summary

Public Constructors
ShortNameFactory()
Public Methods
String getAnnotationName(Key<?> key)
String getClassName(Key<?> key)
String getInstanceName(Object instance)
String getMemberName(Member member)
String getSourceName(Object source)
Returns a name for a Guice "source" object.
Protected Methods
String getFileString(StackTraceElement stackTraceElement)
String getMethodString(Method method)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.grapher.NameFactory

Public Constructors

public ShortNameFactory ()

Public Methods

public String getAnnotationName (Key<?> key)

public String getClassName (Key<?> key)

public String getInstanceName (Object instance)

public String getMemberName (Member member)

public String getSourceName (Object source)

Returns a name for a Guice "source" object. This will typically be either a StackTraceElement for when the binding is made to the instance, or a Method when a provider method is used.

Protected Methods

protected String getFileString (StackTraceElement stackTraceElement)

protected String getMethodString (Method method)

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/Renderer.html0000755000175000017500000004276411704661106031067 0ustar tonytony Renderer | Guice
public interface

Renderer

com.google.inject.grapher.Renderer
Known Indirect Subclasses

Class Overview

Interface for the service that renders the graph. It is assumed that the implementations for BindingEdge.Factory, ImplementationNode.Factory, etc. will have direct access to the internals of the Renderer implementation, so the only external interface needed is the render() call that InjectorGrapher calls when it's done.

Summary

Public Methods
abstract void render()

Public Methods

public abstract void render ()

Throws
IOException
././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/NodeIdFactory.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/NodeIdFactory.htm0000755000175000017500000004465511704661106031640 0ustar tonytony NodeIdFactory | Guice
public interface

NodeIdFactory

com.google.inject.grapher.NodeIdFactory<K>
Known Indirect Subclasses

Class Overview

Factory for abstract identifiers for elements on the graph. Most graph nodes will correspond directly to Keys, but we do this for additional flexibility and because instances do not have separate Keys from the interfaces they are bound to.

Node IDs are treated as opaque values by GraphingVisitor and the other classes in this package.

Summary

Public Methods
abstract K getClassNodeId(Key<?> key)
abstract K getInstanceNodeId(Key<?> key)

Public Methods

public abstract K getClassNodeId (Key<?> key)

public abstract K getInstanceNodeId (Key<?> key)

././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/NodeAliasFactory.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/NodeAliasFactory.0000755000175000017500000004172411704661106031616 0ustar tonytony NodeAliasFactory | Guice
public interface

NodeAliasFactory

com.google.inject.grapher.NodeAliasFactory<K>
Known Indirect Subclasses

Class Overview

Factory for aliasing one node ID to another. Used when we don't want to render Keys from Bindings that are not interesting.

Summary

Public Methods
abstract void newAlias(K fromId, K toId)
Makes edges that would point to fromId point to toId instead.

Public Methods

public abstract void newAlias (K fromId, K toId)

Makes edges that would point to fromId point to toId instead.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/NameFactory.html0000755000175000017500000005247411704661106031530 0ustar tonytony NameFactory | Guice
public interface

NameFactory

com.google.inject.grapher.NameFactory
Known Indirect Subclasses

Class Overview

Interface for a service that provides nice Strings that we can display in the graph for the types that come up in Bindings.

Summary

Public Methods
abstract String getAnnotationName(Key<?> key)
abstract String getClassName(Key<?> key)
abstract String getInstanceName(Object instance)
abstract String getMemberName(Member member)
abstract String getSourceName(Object source)

Public Methods

public abstract String getAnnotationName (Key<?> key)

public abstract String getClassName (Key<?> key)

public abstract String getInstanceName (Object instance)

public abstract String getMemberName (Member member)

public abstract String getSourceName (Object source)

././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/InterfaceNode.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/InterfaceNode.htm0000755000175000017500000004633311704661106031647 0ustar tonytony InterfaceNode | Guice
public interface

InterfaceNode

com.google.inject.grapher.InterfaceNode<K>
Known Indirect Subclasses

Class Overview

Node for an interface class that has been bound to an implementation class or instance. These nodes are basically defined by a Key.

See Also

Summary

Nested Classes
interface InterfaceNode.Factory<K, T extends InterfaceNode<K>> Factory interface for InterfaceNodes. 
Public Methods
abstract void setKey(Key<?> key)
abstract void setSource(Object source)

Public Methods

public abstract void setKey (Key<?> key)

public abstract void setSource (Object source)

././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/InterfaceNode.Factory.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/InterfaceNode.Fac0000755000175000017500000004340111704661106031541 0ustar tonytony InterfaceNode.Factory | Guice
public static interface

InterfaceNode.Factory

com.google.inject.grapher.InterfaceNode.Factory<K, T extends com.google.inject.grapher.InterfaceNode<K>>
Known Indirect Subclasses

Class Overview

Factory interface for InterfaceNodes. Renderer implementations will need to provide an implementation for this.

Summary

Public Methods
abstract T newInterfaceNode(K nodeId)
Creates a new InterfaceNode and adds it to the graph.

Public Methods

public abstract T newInterfaceNode (K nodeId)

Creates a new InterfaceNode and adds it to the graph.

Parameters
nodeId ID for the node.
Returns
././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/InjectorGrapher.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/InjectorGrapher.h0000755000175000017500000007231511704661106031665 0ustar tonytony InjectorGrapher | Guice
public class

InjectorGrapher

extends Object
java.lang.Object
   ↳ com.google.inject.grapher.InjectorGrapher

Class Overview

Root class for graphing an Injector. Bound in GrapherModule.

Use of(Injector) to specify the Injector to use, and graph() to graph the Injector using the currently-bound Renderer.

By default, this will graph the entire Injector. Use rootedAt(Class) or rootedAt(Key) to specify an initial set of Classes or Keys to use, and this will graph their transitive bindings and dependencies.

Summary

Public Constructors
InjectorGrapher(BindingTargetVisitor<Object, Collection<Key<?>>> keyVisitor, BindingTargetVisitor<Object, Void> graphingVisitor, Renderer renderer)
Public Methods
void graph()
Renders a graph with the bound Renderer.
InjectorGrapher of(Injector injector)
Sets the Injector to graph.
InjectorGrapher rootedAt(Key...<?> keys)
Sets an initial group of Keys to use as the starting point for the graph.
InjectorGrapher rootedAt(Class...<?> classes)
Sets an initial group of Classes to use as the starting point for the graph.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public InjectorGrapher (BindingTargetVisitor<Object, Collection<Key<?>>> keyVisitor, BindingTargetVisitor<Object, Void> graphingVisitor, Renderer renderer)

Public Methods

public void graph ()

Renders a graph with the bound Renderer. The Injector must have already been specified with of(Injector).

Throws
IOException

public InjectorGrapher of (Injector injector)

Sets the Injector to graph.

public InjectorGrapher rootedAt (Key...<?> keys)

Sets an initial group of Keys to use as the starting point for the graph. The graph will be of these keys and their transitive dependencies and bindings.

public InjectorGrapher rootedAt (Class...<?> classes)

Sets an initial group of Classes to use as the starting point for the graph. The graph will be of these classes and their transitive dependencies and bindings.

././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/ImplementationNode.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/ImplementationNod0000755000175000017500000005406111704661106031775 0ustar tonytony ImplementationNode | Guice
public interface

ImplementationNode

com.google.inject.grapher.ImplementationNode<K>
Known Indirect Subclasses

Class Overview

Node for classes and instances that have Dependencys and are bound to InterfaceNodes. These nodes will often have fields for Members that are InjectionPoints.

See Also

Summary

Nested Classes
interface ImplementationNode.Factory<K, T extends ImplementationNode<K>> Factory interface for ImplementationNodes. 
Public Methods
abstract void addMember(Member member)
abstract void setClassKey(Key<?> key)
Sets the Key that this node is for.
abstract void setInstance(Object instance)
Sets the Object that's the already-created instance.
abstract void setSource(Object source)

Public Methods

public abstract void addMember (Member member)

public abstract void setClassKey (Key<?> key)

Sets the Key that this node is for. Used when the node is representing a class that Guice will instantiate.

public abstract void setInstance (Object instance)

Sets the Object that's the already-created instance. Used when this node is represeting the instance instead of a class.

public abstract void setSource (Object source)

././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/ImplementationNode.Factory.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/ImplementationNod0000755000175000017500000004357111704661106032001 0ustar tonytony ImplementationNode.Factory | Guice
public static interface

ImplementationNode.Factory

com.google.inject.grapher.ImplementationNode.Factory<K, T extends com.google.inject.grapher.ImplementationNode<K>>
Known Indirect Subclasses

Class Overview

Factory interface for ImplementationNodes. Renderer implementations will need to provide an implementation for this.

Summary

Public Methods
abstract T newImplementationNode(K nodeId)
Creates a new ImplementationNode and adds it to the graph.

Public Methods

public abstract T newImplementationNode (K nodeId)

Creates a new ImplementationNode and adds it to the graph.

Parameters
nodeId ID for the node.
Returns
././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/GraphingVisitor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/GraphingVisitor.h0000755000175000017500000022300411704661106031707 0ustar tonytony GraphingVisitor | Guice
public class

GraphingVisitor

extends Object
implements BindingTargetVisitor<T, V>
java.lang.Object
   ↳ com.google.inject.grapher.GraphingVisitor<K, N extends com.google.inject.grapher.InterfaceNode<K>, M extends com.google.inject.grapher.ImplementationNode<K>, B extends com.google.inject.grapher.BindingEdge<K>, D extends com.google.inject.grapher.DependencyEdge<K>>

Class Overview

BindingTargetVisitor that adds nodes and edges to the graph based on the visited Binding.

This class is parameterized over the four graph element types (InterfaceNode, ImplementationNode, BindingEdge, and DependencyEdge) so that you can extend those interfaces and also extend this class, and the helper methods will all return your new types.

Summary

Public Constructors
GraphingVisitor(NodeIdFactory<K> idFactory, Factory<K, N> interfaceNodeFactory, Factory<K, M> implementationNodeFactory, Factory<K, B> bindingEdgeFactory, Factory<K, D> dependencyEdgeFactory, NodeAliasFactory<K> nodeAliasFactory)
Public Methods
Void visit(ConstructorBinding<?> binding)
Visitor for ConstructorBindings.
Void visit(ConvertedConstantBinding<?> binding)
Void visit(ExposedBinding<?> binding)
Currently not displayed on the graph.
Void visit(InstanceBinding<?> binding)
Visitor for InstanceBinding.
Void visit(LinkedKeyBinding<?> binding)
Visitor for LinkedKeyBinding.
Void visit(ProviderBinding<?> binding)
Visitor for ProviderBinding.
Void visit(ProviderInstanceBinding<?> binding)
Void visit(ProviderKeyBinding<?> binding)
Void visit(UntargettedBinding<?> binding)
Currently not displayed on the graph.
Protected Methods
final K getClassNodeId(Binding<?> binding)
Helper method to return the standard node ID for the Binding's Key.
final K getInstanceNodeId(Binding<?> binding)
Helper method to return the instance node ID for the Binding's Key.
B newBindingEdge(K nodeId, K toId, BindingEdge.Type type)
Creates a new BindingEdge from the given node to the specified node.
M newClassImplementationNode(Binding<?> binding, InjectionPoint constructorInjectionPoint, Collection<InjectionPoint> memberInjectionPoints)
Creates and returns a new ImplementationNode for the given Binding, where the Binding is for a class that Guice will instantiate, rather than a specific instance.
D newDependencyEdge(K nodeId, InjectionPoint injectionPoint, Dependency<?> dependency)
Creates a new DependencyEdge from the given node to a Dependency.
Collection<D> newDependencyEdges(K nodeId, M node, Collection<Dependency<?>> dependencies)
Adds DependencyEdges to the graph for each of the provided Dependencys.
M newInstanceImplementationNode(Binding<?> binding, Object instance)
Creates and returns a new ImplementationNode for the given Binding, where the Binding is for an instance, rather than a class.
N newInterfaceNode(Binding<?> binding)
Creates and returns a new InterfaceNode object for the given Binding.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.spi.BindingTargetVisitor

Public Constructors

public GraphingVisitor (NodeIdFactory<K> idFactory, Factory<K, N> interfaceNodeFactory, Factory<K, M> implementationNodeFactory, Factory<K, B> bindingEdgeFactory, Factory<K, D> dependencyEdgeFactory, NodeAliasFactory<K> nodeAliasFactory)

Public Methods

public Void visit (ConstructorBinding<?> binding)

Visitor for ConstructorBindings. These are for classes that Guice will instantiate to satisfy injection requests. We create a new ImplementationNode for the class, then add edges to everything that it depends on to be instantiated.

public Void visit (ConvertedConstantBinding<?> binding)

Visitor for ConvertedConstantBinding. The Binding's Key will be of an annotated primitive type, and the value of getSourceKey() will be of a String with the same annotation.

We render this as an InterfaceNode that has a BindingEdge to the source Key. That will then be rendered by visit(InstanceBinding) as an InterfaceNode with a BindingEdge to the String instance.

public Void visit (ExposedBinding<?> binding)

Currently not displayed on the graph.

public Void visit (InstanceBinding<?> binding)

Visitor for InstanceBinding. We render two nodes in this case: a InterfaceNode for the binding's Key, and then an ImplementationNode for the instance Object itself. We run a binding node between them.

We then render any DependencyEdges that the instance may have, which come either from InjectionPoints (method and field) on the instance, or on Dependencys the instance declares through the HasDependencies interface.

public Void visit (LinkedKeyBinding<?> binding)

Visitor for LinkedKeyBinding. This is the standard Binding you get from binding an interface class to an implementation class. We create an InterfaceNode, then draw a BindingEdge to the node of the implementing class.

public Void visit (ProviderBinding<?> binding)

Visitor for ProviderBinding. These Bindings arise from an InjectionPoint for the Provider interface. Since this isn't tremendously interesting information, we don't render this binding on the graph, and instead let the DependencyEdge go straight from the InjectionPoint to the node specified by getProvidedKey().

public Void visit (UntargettedBinding<?> binding)

Currently not displayed on the graph.

Protected Methods

protected final K getClassNodeId (Binding<?> binding)

Helper method to return the standard node ID for the Binding's Key.

protected final K getInstanceNodeId (Binding<?> binding)

Helper method to return the instance node ID for the Binding's Key.

protected B newBindingEdge (K nodeId, K toId, BindingEdge.Type type)

Creates a new BindingEdge from the given node to the specified node.

Parameters
nodeId ID of the InterfaceNode that binds to the other.
toId The node ID of a class or instance that is bound.
type The BindingEdge.Type of this binding.
Returns

protected M newClassImplementationNode (Binding<?> binding, InjectionPoint constructorInjectionPoint, Collection<InjectionPoint> memberInjectionPoints)

Creates and returns a new ImplementationNode for the given Binding, where the Binding is for a class that Guice will instantiate, rather than a specific instance.

protected D newDependencyEdge (K nodeId, InjectionPoint injectionPoint, Dependency<?> dependency)

Creates a new DependencyEdge from the given node to a Dependency.

This method takes more comprehensive parameters than strictly necessary in case they would be useful to overriding implementations.

Parameters
nodeId ID of the ImplementationNode where the edges will start.
injectionPoint The InjectionPoint that gave rise to this Dependency, if one exists. Used to figure out which Member the edge should point from.
dependency The Dependency to represent with this edge.
Returns

protected Collection<D> newDependencyEdges (K nodeId, M node, Collection<Dependency<?>> dependencies)

Adds DependencyEdges to the graph for each of the provided Dependencys. These will be from the given node ID to the Dependency's Key.

If a Dependency has an associated InjectionPoint, its member will be added to the given ImplementationNode and the edge will start at the Member.

Parameters
nodeId ID of the node that should be the tail of the DependencyEdges.
node An ImplementationNode to add Members to.
dependencies Collection of Dependencys from the Binding.
Returns

protected M newInstanceImplementationNode (Binding<?> binding, Object instance)

Creates and returns a new ImplementationNode for the given Binding, where the Binding is for an instance, rather than a class.

protected N newInterfaceNode (Binding<?> binding)

Creates and returns a new InterfaceNode object for the given Binding.

././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/GrapherModule.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/GrapherModule.htm0000755000175000017500000011413711704661106031675 0ustar tonytony GrapherModule | Guice
public class

GrapherModule

extends AbstractModule
java.lang.Object
   ↳ com.google.inject.AbstractModule
     ↳ com.google.inject.grapher.GrapherModule

Class Overview

Module for the common bindings for InjectorGrapher. You will also need to bind a Module that satisfies the Renderer dependency.

If you want to use subtypes of the node and edge classes, or a different node ID type, you will need to override the GraphingVisitor binding to specify the new type parameters.

Summary

Public Constructors
GrapherModule()
Protected Methods
void configure()
Configures a Binder via the exposed methods.
[Expand]
Inherited Methods
From class com.google.inject.AbstractModule
From class java.lang.Object
From interface com.google.inject.Module

Public Constructors

public GrapherModule ()

Protected Methods

protected void configure ()

Configures a Binder via the exposed methods.

././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/DependencyEdge.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/DependencyEdge.ht0000755000175000017500000004106511704661106031624 0ustar tonytony DependencyEdge | Guice
public interface

DependencyEdge

com.google.inject.grapher.DependencyEdge<K>
Known Indirect Subclasses

Class Overview

Interface for an edge from a class or InjectionPoint to the interface node that will satisfy the dependency.

Summary

././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/DependencyEdge.Factory.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/DependencyEdge.Fa0000755000175000017500000004420411704661106031535 0ustar tonytony DependencyEdge.Factory | Guice
Nested Classes
interface DependencyEdge.Factory<K, T extends DependencyEdge<K>> Factory interface for DependencyEdges. 
public static interface

DependencyEdge.Factory

com.google.inject.grapher.DependencyEdge.Factory<K, T extends com.google.inject.grapher.DependencyEdge<K>>
Known Indirect Subclasses

Class Overview

Factory interface for DependencyEdges. Renderer implementations will need to provide an implementation for this.

Summary

Public Methods
abstract T newDependencyEdge(K fromId, InjectionPoint fromPoint, K toId)
Creates a new DependencyEdge and adds it to the graph.

Public Methods

public abstract T newDependencyEdge (K fromId, InjectionPoint fromPoint, K toId)

Creates a new DependencyEdge and adds it to the graph.

Parameters
fromId The ID for the class or instance node that has the dependency.
fromPoint The point where the dependency will be @Injected.
toId The ID for the interface node that satisfies the dependency.
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/BindingEdge.html0000755000175000017500000004446611704661106031461 0ustar tonytony BindingEdge | Guice
public interface

BindingEdge

com.google.inject.grapher.BindingEdge<K>
Known Indirect Subclasses

Class Overview

Interface for an edge that connects an interface to the type or instance that is bound to implement it.

Summary

Nested Classes
interface BindingEdge.Factory<K, T extends BindingEdge<K>> Factory interface for BindingEdges. 
enum BindingEdge.Type Classification for what kind of binding this edge represents. 
Public Methods
abstract void setType(BindingEdge.Type type)

Public Methods

public abstract void setType (BindingEdge.Type type)

././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/BindingEdge.Type.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/BindingEdge.Type.0000755000175000017500000007432711704661106031513 0ustar tonytony BindingEdge.Type | Guice
public static final enum

BindingEdge.Type

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.grapher.BindingEdge.Type

Class Overview

Classification for what kind of binding this edge represents.

Summary

Enum Values
BindingEdge.Type  CONVERTED_CONSTANT  Binding is to the interface for a constant of a different type. 
BindingEdge.Type  NORMAL  Binding is to an instance or class of the binding's same type. 
BindingEdge.Type  PROVIDER  Binding is to an instance or class that provides the binding's type. 
Public Methods
static BindingEdge.Type valueOf(String name)
final static Type[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final BindingEdge.Type CONVERTED_CONSTANT

Since: API Level

Binding is to the interface for a constant of a different type.

public static final BindingEdge.Type NORMAL

Since: API Level

Binding is to an instance or class of the binding's same type.

public static final BindingEdge.Type PROVIDER

Since: API Level

Binding is to an instance or class that provides the binding's type.

Public Methods

public static BindingEdge.Type valueOf (String name)

public static final Type[] values ()

././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/BindingEdge.Factory.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/grapher/BindingEdge.Facto0000755000175000017500000004362211704661106031542 0ustar tonytony BindingEdge.Factory | Guice
public static interface

BindingEdge.Factory

com.google.inject.grapher.BindingEdge.Factory<K, T extends com.google.inject.grapher.BindingEdge<K>>
Known Indirect Subclasses

Class Overview

Factory interface for BindingEdges. Renderer implementations will need to provide an implementation for this.

Summary

Public Methods
abstract T newBindingEdge(K fromId, K toId)
Creates a new BindingEdge instance and adds it to the graph.

Public Methods

public abstract T newBindingEdge (K fromId, K toId)

Creates a new BindingEdge instance and adds it to the graph.

Parameters
fromId Node ID for the interface node.
toId Node ID for the implementation (class or instance) node.
Returns
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/0000755000175000017500000000000011704661106026226 5ustar tonytony././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/package-summary.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/package-summary.ht0000755000175000017500000003132711704661106031662 0ustar tonytony com.google.inject.binder | Guice
package

com.google.inject.binder

Classes | Description

Interfaces which make up Binder's expression language.

more...

Interfaces

AnnotatedBindingBuilder<T> See the EDSL examples at Binder
AnnotatedConstantBindingBuilder See the EDSL examples at Binder
AnnotatedElementBuilder See the EDSL examples at Binder
ConstantBindingBuilder Binds to a constant value. 
LinkedBindingBuilder<T> See the EDSL examples at Binder
ScopedBindingBuilder See the EDSL examples at Binder
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/package-descr.html0000755000175000017500000002451111704661106031613 0ustar tonytony com.google.inject.binder Details | Guice
package

com.google.inject.binder

Classes | Description

Interfaces which make up Binder's expression language.

././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/ScopedBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/ScopedBindingBuild0000755000175000017500000004325311704661106031653 0ustar tonytony ScopedBindingBuilder | Guice
public interface

ScopedBindingBuilder

com.google.inject.binder.ScopedBindingBuilder
Known Indirect Subclasses

Class Overview

See the EDSL examples at Binder.

Summary

Public Methods
abstract void asEagerSingleton()
Instructs the Injector to eagerly initialize this singleton-scoped binding upon creation.
abstract void in(Scope scope)
See the EDSL examples at Binder.
abstract void in(Class<? extends Annotation> scopeAnnotation)
See the EDSL examples at Binder.

Public Methods

public abstract void asEagerSingleton ()

Instructs the Injector to eagerly initialize this singleton-scoped binding upon creation. Useful for application initialization logic. See the EDSL examples at Binder.

public abstract void in (Scope scope)

See the EDSL examples at Binder.

public abstract void in (Class<? extends Annotation> scopeAnnotation)

See the EDSL examples at Binder.

././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/LinkedBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/LinkedBindingBuild0000755000175000017500000010263111704661106031640 0ustar tonytony LinkedBindingBuilder | Guice
public interface

LinkedBindingBuilder

implements ScopedBindingBuilder
com.google.inject.binder.LinkedBindingBuilder<T>
Known Indirect Subclasses

Class Overview

See the EDSL examples at Binder.

Summary

Public Methods
abstract ScopedBindingBuilder to(Key<? extends T> targetKey)
See the EDSL examples at Binder.
abstract ScopedBindingBuilder to(TypeLiteral<? extends T> implementation)
See the EDSL examples at Binder.
abstract ScopedBindingBuilder to(Class<? extends T> implementation)
See the EDSL examples at Binder.
abstract <S extends T> ScopedBindingBuilder toConstructor(Constructor<S> constructor)
See the EDSL examples at Binder.
abstract <S extends T> ScopedBindingBuilder toConstructor(Constructor<S> constructor, TypeLiteral<? extends S> type)
See the EDSL examples at Binder.
abstract void toInstance(T instance)
See the EDSL examples at Binder.
abstract ScopedBindingBuilder toProvider(Key<? extends Provider<? extends T>> providerKey)
See the EDSL examples at Binder.
abstract ScopedBindingBuilder toProvider(Provider<? extends T> provider)
See the EDSL examples at Binder.
abstract ScopedBindingBuilder toProvider(TypeLiteral<? extends Provider<? extends T>> providerType)
See the EDSL examples at Binder.
abstract ScopedBindingBuilder toProvider(Class<? extends Provider<? extends T>> providerType)
See the EDSL examples at Binder.
[Expand]
Inherited Methods
From interface com.google.inject.binder.ScopedBindingBuilder

Public Methods

public abstract ScopedBindingBuilder to (Key<? extends T> targetKey)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder to (TypeLiteral<? extends T> implementation)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder to (Class<? extends T> implementation)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder toConstructor (Constructor<S> constructor)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder toConstructor (Constructor<S> constructor, TypeLiteral<? extends S> type)

See the EDSL examples at Binder.

public abstract void toInstance (T instance)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder toProvider (Key<? extends Provider<? extends T>> providerKey)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder toProvider (Provider<? extends T> provider)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder toProvider (TypeLiteral<? extends Provider<? extends T>> providerType)

See the EDSL examples at Binder.

public abstract ScopedBindingBuilder toProvider (Class<? extends Provider<? extends T>> providerType)

See the EDSL examples at Binder.

././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/ConstantBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/ConstantBindingBui0000755000175000017500000005730611704661106031713 0ustar tonytony ConstantBindingBuilder | Guice
public interface

ConstantBindingBuilder

com.google.inject.binder.ConstantBindingBuilder

Class Overview

Binds to a constant value.

Summary

Public Methods
abstract <E extends Enum<E>> void to(E value)
Binds constant to the given value.
abstract void to(boolean value)
Binds constant to the given value.
abstract void to(byte value)
Binds constant to the given value.
abstract void to(char value)
Binds constant to the given value.
abstract void to(double value)
Binds constant to the given value.
abstract void to(float value)
Binds constant to the given value.
abstract void to(int value)
Binds constant to the given value.
abstract void to(Class<?> value)
Binds constant to the given value.
abstract void to(String value)
Binds constant to the given value.
abstract void to(long value)
Binds constant to the given value.
abstract void to(short value)
Binds constant to the given value.

Public Methods

public abstract void to (E value)

Binds constant to the given value.

public abstract void to (boolean value)

Binds constant to the given value.

public abstract void to (byte value)

Binds constant to the given value.

public abstract void to (char value)

Binds constant to the given value.

public abstract void to (double value)

Binds constant to the given value.

public abstract void to (float value)

Binds constant to the given value.

public abstract void to (int value)

Binds constant to the given value.

public abstract void to (Class<?> value)

Binds constant to the given value.

public abstract void to (String value)

Binds constant to the given value.

public abstract void to (long value)

Binds constant to the given value.

public abstract void to (short value)

Binds constant to the given value.

././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/AnnotatedElementBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/AnnotatedElementBu0000755000175000017500000003426511704661106031704 0ustar tonytony AnnotatedElementBuilder | Guice
public interface

AnnotatedElementBuilder

com.google.inject.binder.AnnotatedElementBuilder

Class Overview

See the EDSL examples at Binder.

Summary

Public Methods
abstract void annotatedWith(Class<? extends Annotation> annotationType)
See the EDSL examples at Binder.
abstract void annotatedWith(Annotation annotation)
See the EDSL examples at Binder.

Public Methods

public abstract void annotatedWith (Class<? extends Annotation> annotationType)

See the EDSL examples at Binder.

public abstract void annotatedWith (Annotation annotation)

See the EDSL examples at Binder.

././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/AnnotatedConstantBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/AnnotatedConstantB0000755000175000017500000003514111704661106031711 0ustar tonytony AnnotatedConstantBindingBuilder | Guice
public interface

AnnotatedConstantBindingBuilder

com.google.inject.binder.AnnotatedConstantBindingBuilder

Class Overview

See the EDSL examples at Binder.

Summary

Public Methods
abstract ConstantBindingBuilder annotatedWith(Class<? extends Annotation> annotationType)
See the EDSL examples at Binder.
abstract ConstantBindingBuilder annotatedWith(Annotation annotation)
See the EDSL examples at Binder.

Public Methods

public abstract ConstantBindingBuilder annotatedWith (Class<? extends Annotation> annotationType)

See the EDSL examples at Binder.

public abstract ConstantBindingBuilder annotatedWith (Annotation annotation)

See the EDSL examples at Binder.

././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/AnnotatedBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/binder/AnnotatedBindingBu0000755000175000017500000006530611704661106031665 0ustar tonytony AnnotatedBindingBuilder | Guice
public interface

AnnotatedBindingBuilder

implements LinkedBindingBuilder<T>
com.google.inject.binder.AnnotatedBindingBuilder<T>

Class Overview

See the EDSL examples at Binder.

Summary

Public Methods
abstract LinkedBindingBuilder<T> annotatedWith(Class<? extends Annotation> annotationType)
See the EDSL examples at Binder.
abstract LinkedBindingBuilder<T> annotatedWith(Annotation annotation)
See the EDSL examples at Binder.
[Expand]
Inherited Methods
From interface com.google.inject.binder.LinkedBindingBuilder
From interface com.google.inject.binder.ScopedBindingBuilder

Public Methods

public abstract LinkedBindingBuilder<T> annotatedWith (Class<? extends Annotation> annotationType)

See the EDSL examples at Binder.

public abstract LinkedBindingBuilder<T> annotatedWith (Annotation annotation)

See the EDSL examples at Binder.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/0000755000175000017500000000000011704661106027777 5ustar tonytony././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/package-summary.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/package-su0000755000175000017500000003144311704661106031752 0ustar tonytony com.google.inject.assistedinject | Guice
package

com.google.inject.assistedinject

Classes | Description

Extension for combining factory interfaces with injection; this extension requires guice-assistedinject-3.0.jar.

more...

Interfaces

AssistedInjectBinding<T> A binding for a factory created by FactoryModuleBuilder. 
AssistedInjectTargetVisitor<T, V> A visitor for the AssistedInject extension. 
AssistedMethod Details about how a method in an assisted inject factory will be assisted. 

Classes

FactoryModuleBuilder Provides a factory that combines the caller's arguments with injector-supplied values to construct objects. 
FactoryProvider<F> This class is deprecated. use FactoryModuleBuilder instead.  
././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/package-descr.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/package-de0000755000175000017500000002513511704661106031714 0ustar tonytony com.google.inject.assistedinject Details | Guice
package

com.google.inject.assistedinject

Classes | Description

Extension for combining factory interfaces with injection; this extension requires guice-assistedinject-3.0.jar.

././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/FactoryProvider.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/FactoryPro0000755000175000017500000007543611704661106032034 0ustar tonytony FactoryProvider | Guice
public class

FactoryProvider

extends Object
implements Provider<T> HasDependencies
java.lang.Object
   ↳ com.google.inject.assistedinject.FactoryProvider<F>

This class is deprecated.
use FactoryModuleBuilder instead.

Class Overview

Obsolete. Prefer FactoryModuleBuilder for its more concise API and additional capability.

Provides a factory that combines the caller's arguments with injector-supplied values to construct objects.

Defining a factory

Create an interface whose methods return the constructed type, or any of its supertypes. The method's parameters are the arguments required to build the constructed type.
public interface PaymentFactory {
   Payment create(Date startDate, Money amount);
 }
You can name your factory methods whatever you like, such as create, createPayment or newPayment.

Creating a type that accepts factory parameters

constructedType is a concrete class with an @Inject-annotated constructor. In addition to injector-supplied parameters, the constructor should have parameters that match each of the factory method's parameters. Each factory-supplied parameter requires an @Assisted annotation. This serves to document that the parameter is not bound by your application's modules.
public class RealPayment implements Payment {
   @Inject
   public RealPayment(
      CreditService creditService,
      AuthService authService,
      @Assisted Date startDate,
      @Assisted Money amount) {
     ...
   }
 }
Any parameter that permits a null value should also be annotated @Nullable.

Configuring factories

In your module, bind the factory interface to the returned factory:
bind(PaymentFactory.class).toProvider(
     FactoryProvider.newFactory(PaymentFactory.class, RealPayment.class));
As a side-effect of this binding, Guice will inject the factory to initialize it for use. The factory cannot be used until the injector has been initialized.

Using the factory

Inject your factory into your application classes. When you use the factory, your arguments will be combined with values from the injector to construct an instance.
public class PaymentAction {
   @Inject private PaymentFactory paymentFactory;

   public void doPayment(Money amount) {
     Payment payment = paymentFactory.create(new Date(), amount);
     payment.apply();
   }
 }

Making parameter types distinct

The types of the factory method's parameters must be distinct. To use multiple parameters of the same type, use a named @Assisted annotation to disambiguate the parameters. The names must be applied to the factory method's parameters:
public interface PaymentFactory {
   Payment create(
       @Assisted("startDate") Date startDate,
       @Assisted("dueDate") Date dueDate,
       Money amount);
 } 
...and to the concrete type's constructor parameters:
public class RealPayment implements Payment {
   @Inject
   public RealPayment(
      CreditService creditService,
      AuthService authService,
      @Assisted("startDate") Date startDate,
      @Assisted("dueDate") Date dueDate,
      @Assisted Money amount) {
     ...
   }
 }

Values are created by Guice

Returned factories use child injectors to create values. The values are eligible for method interception. In addition, @Inject members will be injected before they are returned.

Backwards compatibility using @AssistedInject

Instead of the @Inject annotation, you may annotate the constructed classes with @AssistedInject. This triggers a limited backwards-compatability mode.

Instead of matching factory method arguments to constructor parameters using their names, the parameters are matched by their order. The first factory method argument is used for the first @Assisted constructor parameter, etc.. Annotation names have no effect.

Returned values are not created by Guice. These types are not eligible for method interception. They do receive post-construction member injection.

Summary

Public Methods
F get()
Provides an instance of T.
Set<Dependency<?>> getDependencies()
Returns the known dependencies for this type.
static <F> Provider<F> newFactory(TypeLiteral<F> factoryType, TypeLiteral<?> implementationType)
static <F> Provider<F> newFactory(Class<F> factoryType, Class<?> implementationType)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.Provider
From interface com.google.inject.spi.HasDependencies
From interface javax.inject.Provider

Public Methods

public F get ()

Provides an instance of T. Must never return null.

public Set<Dependency<?>> getDependencies ()

Returns the known dependencies for this type. If this has dependencies whose values are not known statically, a dependency for the Injector will be included in the returned set.

Returns
  • a possibly empty set

public static Provider<F> newFactory (TypeLiteral<F> factoryType, TypeLiteral<?> implementationType)

public static Provider<F> newFactory (Class<F> factoryType, Class<?> implementationType)

././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/FactoryModuleBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/FactoryMod0000755000175000017500000016233011704661106032001 0ustar tonytony FactoryModuleBuilder | Guice
public final class

FactoryModuleBuilder

extends Object
java.lang.Object
   ↳ com.google.inject.assistedinject.FactoryModuleBuilder

Class Overview

Provides a factory that combines the caller's arguments with injector-supplied values to construct objects.

Defining a factory

Create an interface whose methods return the constructed type, or any of its supertypes. The method's parameters are the arguments required to build the constructed type.
public interface PaymentFactory {
   Payment create(Date startDate, Money amount);
 }
You can name your factory methods whatever you like, such as create, createPayment or newPayment.

Creating a type that accepts factory parameters

constructedType is a concrete class with an @Inject-annotated constructor. In addition to injector-supplied parameters, the constructor should have parameters that match each of the factory method's parameters. Each factory-supplied parameter requires an @Assisted annotation. This serves to document that the parameter is not bound by your application's modules.
public class RealPayment implements Payment {
   @Inject
   public RealPayment(
      CreditService creditService,
      AuthService authService,
      @Assisted Date startDate,
      @Assisted Money amount) {
     ...
   }
 }

Multiple factory methods for the same type

If the factory contains many methods that return the same type, you can create multiple constructors in your concrete class, each constructor marked with with @AssistedInject, in order to match the different parameters types of the factory methods.
public interface PaymentFactory {
    Payment create(Date startDate, Money amount);
    Payment createWithoutDate(Money amount);
 }
 
 public class RealPayment implements Payment {
  @AssistedInject
   public RealPayment(
      CreditService creditService,
      AuthService authService,
     @Assisted Date startDate,
     @Assisted Money amount) {
     ...
   }
   
  @AssistedInject
   public RealPayment(
      CreditService creditService,
      AuthService authService,
     @Assisted Money amount) {
     ...
   }   
 }

Configuring simple factories

In your module, install a FactoryModuleBuilder that creates the factory:
install(new FactoryModuleBuilder()
     .implement(Payment.class, RealPayment.class)
     .build(PaymentFactory.class);
As a side-effect of this binding, Guice will inject the factory to initialize it for use. The factory cannot be used until the injector has been initialized.

Configuring complex factories

Factories can create an arbitrary number of objects, one per each method. Each factory method can be configured using .implement.
public interface OrderFactory {
    Payment create(Date startDate, Money amount);
    Shipment create(Customer customer, Item item);
    Receipt create(Payment payment, Shipment shipment);
 }
 
 [...]
 
 install(new FactoryModuleBuilder()
     .implement(Payment.class, RealPayment.class)
     // excluding .implement for Shipment means the implementation class
     // will be 'Shipment' itself, which is legal if it's not an interface.
     .implement(Receipt.class, RealReceipt.class)
     .build(OrderFactory.class);

Using the factory

Inject your factory into your application classes. When you use the factory, your arguments will be combined with values from the injector to construct an instance.
public class PaymentAction {
   @Inject private PaymentFactory paymentFactory;

   public void doPayment(Money amount) {
     Payment payment = paymentFactory.create(new Date(), amount);
     payment.apply();
   }
 }

Making parameter types distinct

The types of the factory method's parameters must be distinct. To use multiple parameters of the same type, use a named @Assisted annotation to disambiguate the parameters. The names must be applied to the factory method's parameters:
public interface PaymentFactory {
   Payment create(
       @Assisted("startDate") Date startDate,
       @Assisted("dueDate") Date dueDate,
       Money amount);
 } 
...and to the concrete type's constructor parameters:
public class RealPayment implements Payment {
   @Inject
   public RealPayment(
      CreditService creditService,
      AuthService authService,
      @Assisted("startDate") Date startDate,
      @Assisted("dueDate") Date dueDate,
      @Assisted Money amount) {
     ...
   }
 }

Values are created by Guice

Returned factories use child injectors to create values. The values are eligible for method interception. In addition, @Inject members will be injected before they are returned.

More configuration options

In addition to simply specifying an implementation class for any returned type, factories' return values can be automatic or can be configured to use annotations:

If you just want to return the types specified in the factory, do not configure any implementations:

public interface FruitFactory {
   Apple getApple(Color color);
 }
 ...
 protected void configure() {
   install(new FactoryModuleBuilder().build(FruitFactory.class));
 }
Note that any type returned by the factory in this manner needs to be an implementation class.

To return two different implementations for the same interface from your factory, use binding annotations on your return types:

interface CarFactory {
   @Named("fast") Car getFastCar(Color color);
   @Named("clean") Car getCleanCar(Color color);
 }
 ...
 protected void configure() {
   install(new FactoryModuleBuilder()
       .implement(Car.class, Names.named("fast"), Porsche.class)
       .implement(Car.class, Names.named("clean"), Prius.class)
       .build(CarFactory.class));
 }

Implementation limitations

As a limitation of the implementation, it is prohibited to declare a factory method that accepts a Provider as one of its arguments.

Summary

Public Constructors
FactoryModuleBuilder()
Public Methods
<F> Module build(Key<F> factoryInterface)
<F> Module build(TypeLiteral<F> factoryInterface)
See the factory configuration examples at FactoryModuleBuilder.
<F> Module build(Class<F> factoryInterface)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Key<T> source, TypeLiteral<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Key<T> source, Class<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(TypeLiteral<T> source, TypeLiteral<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(TypeLiteral<T> source, Class<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(TypeLiteral<T> source, Class<? extends Annotation> annotationType, TypeLiteral<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(TypeLiteral<T> source, Class<? extends Annotation> annotationType, Class<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(TypeLiteral<T> source, Annotation annotation, TypeLiteral<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(TypeLiteral<T> source, Annotation annotation, Class<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Class<T> source, TypeLiteral<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Class<T> source, Class<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Class<T> source, Class<? extends Annotation> annotationType, TypeLiteral<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Class<T> source, Class<? extends Annotation> annotationType, Class<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Class<T> source, Annotation annotation, TypeLiteral<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
<T> FactoryModuleBuilder implement(Class<T> source, Annotation annotation, Class<? extends T> target)
See the factory configuration examples at FactoryModuleBuilder.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public FactoryModuleBuilder ()

Public Methods

public Module build (Key<F> factoryInterface)

public Module build (TypeLiteral<F> factoryInterface)

See the factory configuration examples at FactoryModuleBuilder.

public Module build (Class<F> factoryInterface)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Key<T> source, TypeLiteral<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Key<T> source, Class<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (TypeLiteral<T> source, TypeLiteral<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (TypeLiteral<T> source, Class<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (TypeLiteral<T> source, Class<? extends Annotation> annotationType, TypeLiteral<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (TypeLiteral<T> source, Class<? extends Annotation> annotationType, Class<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (TypeLiteral<T> source, Annotation annotation, TypeLiteral<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (TypeLiteral<T> source, Annotation annotation, Class<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Class<T> source, TypeLiteral<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Class<T> source, Class<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Class<T> source, Class<? extends Annotation> annotationType, TypeLiteral<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Class<T> source, Class<? extends Annotation> annotationType, Class<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Class<T> source, Annotation annotation, TypeLiteral<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

public FactoryModuleBuilder implement (Class<T> source, Annotation annotation, Class<? extends T> target)

See the factory configuration examples at FactoryModuleBuilder.

././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/AssistedMethod.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/AssistedMe0000755000175000017500000004157711704661106032004 0ustar tonytony AssistedMethod | Guice
public interface

AssistedMethod

com.google.inject.assistedinject.AssistedMethod

Class Overview

Details about how a method in an assisted inject factory will be assisted.

Summary

Public Methods
abstract Set<Dependency<?>> getDependencies()
Returns all non-assisted dependencies required to construct and inject the implementation.
abstract Method getFactoryMethod()
Returns the factory method that is being assisted.
abstract Constructor<?> getImplementationConstructor()
Returns the constructor that will be used to construct instances of the implementation.
abstract TypeLiteral<?> getImplementationType()
Returns the implementation type that will be created when the method is used.

Public Methods

public abstract Set<Dependency<?>> getDependencies ()

Returns all non-assisted dependencies required to construct and inject the implementation.

public abstract Method getFactoryMethod ()

Returns the factory method that is being assisted.

public abstract Constructor<?> getImplementationConstructor ()

Returns the constructor that will be used to construct instances of the implementation.

public abstract TypeLiteral<?> getImplementationType ()

Returns the implementation type that will be created when the method is used.

././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/AssistedInjectTargetVisitor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/AssistedIn0000755000175000017500000005264711704661106032011 0ustar tonytony AssistedInjectTargetVisitor | Guice
public interface

AssistedInjectTargetVisitor

implements BindingTargetVisitor<T, V>
com.google.inject.assistedinject.AssistedInjectTargetVisitor<T, V>

Class Overview

A visitor for the AssistedInject extension.

If your BindingTargetVisitor implements this interface, bindings created by using FactoryModuleBuilder will be visited through this interface.

Summary

Public Methods
abstract V visit(AssistedInjectBinding<? extends T> assistedInjectBinding)
Visits an AssistedInjectBinding created through FactoryModuleBuilder.
[Expand]
Inherited Methods
From interface com.google.inject.spi.BindingTargetVisitor

Public Methods

public abstract V visit (AssistedInjectBinding<? extends T> assistedInjectBinding)

Visits an AssistedInjectBinding created through FactoryModuleBuilder.

././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/AssistedInjectBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/AssistedIn0000755000175000017500000003500611704661106031777 0ustar tonytony AssistedInjectBinding | Guice
public interface

AssistedInjectBinding

com.google.inject.assistedinject.AssistedInjectBinding<T>

Class Overview

A binding for a factory created by FactoryModuleBuilder.

Summary

Public Methods
abstract Collection<AssistedMethod> getAssistedMethods()
Returns an AssistedMethod for each method in the factory.
abstract Key<T> getKey()
Returns the Key for the factory binding.

Public Methods

public abstract Collection<AssistedMethod> getAssistedMethods ()

Returns an AssistedMethod for each method in the factory.

public abstract Key<T> getKey ()

Returns the Key for the factory binding.

././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/AssistedInject.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/AssistedIn0000755000175000017500000003645711704661106032012 0ustar tonytony AssistedInject | Guice
public abstract @interface

AssistedInject

implements Annotation
com.google.inject.assistedinject.AssistedInject

Class Overview

When used in tandem with FactoryModuleBuilder, constructors annotated with @AssistedInject indicate that multiple constructors can be injected, each with different parameters. AssistedInject annotations should not be mixed with @Inject annotations. The assisted parameters must exactly match one corresponding factory method within the factory interface, but the parameters do not need to be in the same order. Constructors annotated with AssistedInject are created by Guice and receive all the benefits (such as AOP).

Obsolete Usage: When used in tandem with FactoryProvider, constructors annotated with @AssistedInject trigger a "backwards compatibility mode". The assisted parameters must exactly match one corresponding factory method within the factory interface and all must be in the same order as listed in the factory. In this backwards compatable mode, constructors annotated with AssistedInject are not created by Guice and thus receive none of the benefits.

Constructor parameters must be either supplied by the factory interface and marked with @Assisted, or they must be injectable.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/Assisted.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/assistedinject/Assisted.h0000755000175000017500000003371111704661106031737 0ustar tonytony Assisted | Guice
public abstract @interface

Assisted

implements Annotation
com.google.inject.assistedinject.Assisted

Class Overview

Annotates an injected parameter or field whose value comes from an argument to a factory method.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/TypeLiteral.html0000755000175000017500000011236711704661106030124 0ustar tonytony TypeLiteral | Guice
public class

TypeLiteral

extends Object
java.lang.Object
   ↳ com.google.inject.TypeLiteral<T>

Class Overview

Represents a generic type T. Java doesn't yet provide a way to represent generic types, so this class does. Forces clients to create a subclass of this class which enables retrieval the type information even at runtime.

For example, to create a type literal for List<String>, you can create an empty anonymous inner class:

TypeLiteral<List<String>> list = new TypeLiteral<List<String>>() {;}

Along with modeling generic types, this class can resolve type parameters. For example, to figure out what type keySet() returns on a Map<Integer, String>, use this code:

   TypeLiteral<Map<Integer, String>> mapType
       = new TypeLiteral<Map<Integer, String>>() {;
   TypeLiteral keySetType
       = mapType.getReturnType(Map.class.getMethod("keySet"));
   System.out.println(keySetType); // prints "Set"}

Summary

Protected Constructors
TypeLiteral()
Constructs a new type literal.
Public Methods
final boolean equals(Object o)
static <T> TypeLiteral<T> get(Class<T> type)
Gets type literal for the given Class instance.
static TypeLiteral<?> get(Type type)
Gets type literal for the given Type instance.
List<TypeLiteral<?>> getExceptionTypes(Member methodOrConstructor)
Returns the resolved generic exception types thrown by constructor.
TypeLiteral<?> getFieldType(Field field)
Returns the resolved generic type of field.
List<TypeLiteral<?>> getParameterTypes(Member methodOrConstructor)
Returns the resolved generic parameter types of methodOrConstructor.
final Class<? super T> getRawType()
Returns the raw (non-generic) type for this type.
TypeLiteral<?> getReturnType(Method method)
Returns the resolved generic return type of method.
TypeLiteral<?> getSupertype(Class<?> supertype)
Returns the generic form of supertype.
final Type getType()
Gets underlying Type instance.
final int hashCode()
final String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Protected Constructors

protected TypeLiteral ()

Constructs a new type literal. Derives represented class from type parameter.

Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

Public Methods

public final boolean equals (Object o)

public static TypeLiteral<T> get (Class<T> type)

Gets type literal for the given Class instance.

public static TypeLiteral<?> get (Type type)

Gets type literal for the given Type instance.

public List<TypeLiteral<?>> getExceptionTypes (Member methodOrConstructor)

Returns the resolved generic exception types thrown by constructor.

Parameters
methodOrConstructor a method or constructor defined by this or any supertype.

public TypeLiteral<?> getFieldType (Field field)

Returns the resolved generic type of field.

Parameters
field a field defined by this or any superclass.

public List<TypeLiteral<?>> getParameterTypes (Member methodOrConstructor)

Returns the resolved generic parameter types of methodOrConstructor.

Parameters
methodOrConstructor a method or constructor defined by this or any supertype.

public final Class<? super T> getRawType ()

Returns the raw (non-generic) type for this type.

public TypeLiteral<?> getReturnType (Method method)

Returns the resolved generic return type of method.

Parameters
method a method defined by this or any supertype.

public TypeLiteral<?> getSupertype (Class<?> supertype)

Returns the generic form of supertype. For example, if this is ArrayList<String>, this returns Iterable<String> given the input Iterable.class.

Parameters
supertype a superclass of, or interface implemented by, this.

public final Type getType ()

Gets underlying Type instance.

public final int hashCode ()

public final String toString ()

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/Stage.html0000755000175000017500000007312211704661106026724 0ustar tonytony Stage | Guice
public final enum

Stage

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.google.inject.Stage

Class Overview

The stage we're running in.

Summary

Enum Values
Stage  DEVELOPMENT  We want fast startup times at the expense of runtime performance and some up front error checking. 
Stage  PRODUCTION  We want to catch errors as early as possible and take performance hits up front. 
Stage  TOOL  We're running in a tool (an IDE plugin for example). 
Public Methods
static Stage valueOf(String name)
final static Stage[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final Stage DEVELOPMENT

Since: API Level

We want fast startup times at the expense of runtime performance and some up front error checking.

public static final Stage PRODUCTION

Since: API Level

We want to catch errors as early as possible and take performance hits up front.

public static final Stage TOOL

Since: API Level

We're running in a tool (an IDE plugin for example). We need binding meta data but not a functioning Injector. Do not inject members of instances. Do not load eager singletons. Do as little as possible so our tools run nice and snappy. Injectors created in this stage cannot be used to satisfy injections.

Public Methods

public static Stage valueOf (String name)

public static final Stage[] values ()

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/Singleton.html0000755000175000017500000004025111704661106027620 0ustar tonytony Singleton | Guice
public abstract @interface

Singleton

implements Annotation
com.google.inject.Singleton

Class Overview

Apply this to implementation classes when you want only one instance (per Injector) to be reused for all injections for that binding.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/Scopes.html0000755000175000017500000005575511704661106027131 0ustar tonytony Scopes | Guice
public class

Scopes

extends Object
java.lang.Object
   ↳ com.google.inject.Scopes

Class Overview

Built-in scope implementations.

Summary

Constants
Scope NO_SCOPE No scope; the same as not applying any scope at all.
Scope SINGLETON One instance per Injector.
Public Methods
static boolean isSingleton(Binding<?> binding)
Returns true if binding is singleton-scoped.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final Scope NO_SCOPE

No scope; the same as not applying any scope at all. Each time the Injector obtains an instance of an object with "no scope", it injects this instance then immediately forgets it. When the next request for the same binding arrives it will need to obtain the instance over again.

This exists only in case a class has been annotated with a scope annotation such as @Singleton, and you need to override this to "no scope" in your binding.

public static final Scope SINGLETON

One instance per Injector. Also see @Singleton.

Public Methods

public static boolean isSingleton (Binding<?> binding)

Returns true if binding is singleton-scoped. If the binding is a linked key binding and belongs to an injector (ie. it was retrieved via Injector.getBinding()), then this method will also true if the target binding is singleton-scoped.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/ScopeAnnotation.html0000755000175000017500000004056411704661106030771 0ustar tonytony ScopeAnnotation | Guice
public abstract @interface

ScopeAnnotation

implements Annotation
com.google.inject.ScopeAnnotation

Class Overview

Annotates annotations which are used for scoping. Only one such annotation may apply to a single implementation class. You must also annotate scope annotations with @Retention(RUNTIME). For example:

   @Retention(RUNTIME)
   @Target(TYPE, METHOD)
   @ScopeAnnotation
   public @interface SessionScoped {}
 

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/Scope.html0000755000175000017500000004404711704661106026736 0ustar tonytony Scope | Guice
public interface

Scope

com.google.inject.Scope

Class Overview

A scope is a level of visibility that instances provided by Guice may have. By default, an instance created by the Injector has no scope, meaning it has no state from the framework's perspective -- the Injector creates it, injects it once into the class that required it, and then immediately forgets it. Associating a scope with a particular binding allows the created instance to be "remembered" and possibly used again for other injections.

An example of a scope is SINGLETON.

Summary

Public Methods
abstract <T> Provider<T> scope(Key<T> key, Provider<T> unscoped)
Scopes a provider.
abstract String toString()
A short but useful description of this scope.

Public Methods

public abstract Provider<T> scope (Key<T> key, Provider<T> unscoped)

Scopes a provider. The returned provider returns objects from this scope. If an object does not exist in this scope, the provider can use the given unscoped provider to retrieve one.

Scope implementations are strongly encouraged to override toString() in the returned provider and include the backing provider's toString() output.

Parameters
key binding key
unscoped locates an instance when one doesn't already exist in this scope.
Returns
  • a new provider which only delegates to the given unscoped provider when an instance of the requested object doesn't already exist in this scope

public abstract String toString ()

A short but useful description of this scope. For comparison, the standard scopes that ship with guice use the descriptions "Scopes.SINGLETON", "ServletScopes.SESSION" and "ServletScopes.REQUEST".

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/ProvisionException.html0000755000175000017500000007375111704661106031540 0ustar tonytony ProvisionException | Guice
public final class

ProvisionException

extends RuntimeException
java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ java.lang.RuntimeException
         ↳ com.google.inject.ProvisionException

Class Overview

Indicates that there was a runtime failure while providing an instance.

Summary

Public Constructors
ProvisionException(Iterable<Message> messages)
Creates a ProvisionException containing messages.
ProvisionException(String message)
ProvisionException(String message, Throwable cause)
Public Methods
Collection<Message> getErrorMessages()
Returns messages for the errors that caused this exception.
String getMessage()
[Expand]
Inherited Methods
From class java.lang.Throwable
From class java.lang.Object

Public Constructors

public ProvisionException (Iterable<Message> messages)

Creates a ProvisionException containing messages.

public ProvisionException (String message)

public ProvisionException (String message, Throwable cause)

Public Methods

public Collection<Message> getErrorMessages ()

Returns messages for the errors that caused this exception.

public String getMessage ()

Since: API Level

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/Provides.html0000755000175000017500000004032511704661106027453 0ustar tonytony Provides | Guice
public abstract @interface

Provides

implements Annotation
com.google.inject.Provides

Class Overview

Annotates methods of a Module to create a provider method binding. The method's return type is bound to it's returned value. Guice will pass dependencies to the method as parameters.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/Provider.html0000755000175000017500000005121011704661106027445 0ustar tonytony Provider | Guice
public interface

Provider

implements Provider<T>
com.google.inject.Provider<T>
Known Indirect Subclasses

Class Overview

An object capable of providing instances of type T. Providers are used in numerous ways by Guice:

  • When the default means for obtaining instances (an injectable or parameterless constructor) is insufficient for a particular binding, the module can specify a custom Provider instead, to control exactly how Guice creates or obtains instances for the binding.
  • An implementation class may always choose to have a Provider<T> instance injected, rather than having a T injected directly. This may give you access to multiple instances, instances you wish to safely mutate and discard, instances which are out of scope (e.g. using a @RequestScoped object from within a @SessionScoped object), or instances that will be initialized lazily.
  • A custom Scope is implemented as a decorator of Provider<T>, which decides when to delegate to the backing provider and when to provide the instance some other way.
  • The Injector offers access to the Provider<T> it uses to fulfill requests for a given key, via the getProvider(Key) methods.

Summary

Public Methods
abstract T get()
Provides an instance of T.
[Expand]
Inherited Methods
From interface javax.inject.Provider

Public Methods

public abstract T get ()

Provides an instance of T. Must never return null.

Throws
OutOfScopeException when an attempt is made to access a scoped object while the scope in question is not currently active
ProvisionException if an instance cannot be provided. Such exceptions include messages and throwables to describe why provision failed.
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/ProvidedBy.html0000755000175000017500000004002411704661106027723 0ustar tonytony ProvidedBy | Guice
public abstract @interface

ProvidedBy

implements Annotation
com.google.inject.ProvidedBy

Class Overview

A pointer to the default provider type for a type.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/PrivateModule.html0000755000175000017500000020341611704661106030442 0ustar tonytony PrivateModule | Guice
public abstract class

PrivateModule

extends Object
implements Module
java.lang.Object
   ↳ com.google.inject.PrivateModule

Class Overview

A module whose configuration information is hidden from its environment by default. Only bindings that are explicitly exposed will be available to other modules and to the users of the injector. This module may expose the bindings it creates and the bindings of the modules it installs.

A private module can be nested within a regular module or within another private module using install(). Its bindings live in a new environment that inherits bindings, type converters, scopes, and interceptors from the surrounding ("parent") environment. When you nest multiple private modules, the result is a tree of environments where the injector's environment is the root.

Guice EDSL bindings can be exposed with expose(). @Provides bindings can be exposed with the @Exposed annotation:

 public class FooBarBazModule extends PrivateModule {
   protected void configure() {
     bind(Foo.class).to(RealFoo.class);
     expose(Foo.class);

     install(new TransactionalBarModule());
     expose(Bar.class).annotatedWith(Transactional.class);

     bind(SomeImplementationDetail.class);
     install(new MoreImplementationDetailsModule());
   }

   @Provides @Exposed
   public Baz provideBaz() {
     return new SuperBaz();
   }
 }
 

Private modules are implemented using parent injectors. When it can satisfy their dependencies, just-in-time bindings will be created in the root environment. Such bindings are shared among all environments in the tree.

The scope of a binding is constrained to its environment. A singleton bound in a private module will be unique to its environment. But a binding for the same type in a different private module will yield a different instance.

A shared binding that injects the Injector gets the root injector, which only has access to bindings in the root environment. An explicit binding that injects the Injector gets access to all bindings in the child environment.

To promote a just-in-time binding to an explicit binding, bind it:

   bind(FooImpl.class);
 

Summary

Public Constructors
PrivateModule()
Public Methods
synchronized final void configure(Binder binder)
Contributes bindings and other configurations for this module to binder.
Protected Methods
final void addError(Message message)
final void addError(String message, Object... arguments)
final void addError(Throwable t)
final <T> LinkedBindingBuilder<T> bind(Key<T> key)
final <T> AnnotatedBindingBuilder<T> bind(TypeLiteral<T> typeLiteral)
final <T> AnnotatedBindingBuilder<T> bind(Class<T> clazz)
final AnnotatedConstantBindingBuilder bindConstant()
final void bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)
void bindListener(Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)
final void bindScope(Class<? extends Annotation> scopeAnnotation, Scope scope)
final PrivateBinder binder()
Returns the current binder.
abstract void configure()
Creates bindings and other configurations private to this module.
final void convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)
final Stage currentStage()
final <T> void expose(Key<T> key)
Makes the binding for key available to other modules and the injector.
final AnnotatedElementBuilder expose(TypeLiteral<?> type)
Makes a binding for type available to other modules and the injector.
final AnnotatedElementBuilder expose(Class<?> type)
Makes a binding for type available to other modules and the injector.
<T> MembersInjector<T> getMembersInjector(TypeLiteral<T> type)
<T> MembersInjector<T> getMembersInjector(Class<T> type)
final <T> Provider<T> getProvider(Key<T> key)
final <T> Provider<T> getProvider(Class<T> type)
final void install(Module module)
final void requestInjection(Object instance)
final void requestStaticInjection(Class...<?> types)
final void requireBinding(Key<?> key)
Instructs Guice to require a binding to the given key.
final void requireBinding(Class<?> type)
Instructs Guice to require a binding to the given type.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.Module

Public Constructors

public PrivateModule ()

Public Methods

public final synchronized void configure (Binder binder)

Contributes bindings and other configurations for this module to binder.

Do not invoke this method directly to install submodules. Instead use install(Module), which ensures that provider methods are discovered.

Protected Methods

protected final void addError (Message message)

protected final void addError (String message, Object... arguments)

protected final void addError (Throwable t)

protected final LinkedBindingBuilder<T> bind (Key<T> key)

See Also

protected final AnnotatedBindingBuilder<T> bind (TypeLiteral<T> typeLiteral)

protected final AnnotatedBindingBuilder<T> bind (Class<T> clazz)

See Also

protected final AnnotatedConstantBindingBuilder bindConstant ()

See Also

protected final void bindInterceptor (Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)

protected void bindListener (Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)

protected final void bindScope (Class<? extends Annotation> scopeAnnotation, Scope scope)

protected final PrivateBinder binder ()

Returns the current binder.

protected abstract void configure ()

Creates bindings and other configurations private to this module. Use expose() to make the bindings in this module available externally.

protected final void convertToTypes (Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)

protected final Stage currentStage ()

See Also

protected final void expose (Key<T> key)

Makes the binding for key available to other modules and the injector.

protected final AnnotatedElementBuilder expose (TypeLiteral<?> type)

Makes a binding for type available to other modules and the injector. Use annotatedWith() to expose type with a binding annotation.

protected final AnnotatedElementBuilder expose (Class<?> type)

Makes a binding for type available to other modules and the injector. Use annotatedWith() to expose type with a binding annotation.

protected MembersInjector<T> getMembersInjector (TypeLiteral<T> type)

protected MembersInjector<T> getMembersInjector (Class<T> type)

protected final Provider<T> getProvider (Key<T> key)

See Also

protected final Provider<T> getProvider (Class<T> type)

protected final void install (Module module)

See Also

protected final void requestInjection (Object instance)

protected final void requestStaticInjection (Class...<?> types)

protected final void requireBinding (Key<?> key)

Instructs Guice to require a binding to the given key.

protected final void requireBinding (Class<?> type)

Instructs Guice to require a binding to the given type.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/PrivateBinder.html0000755000175000017500000012077611704661106030427 0ustar tonytony PrivateBinder | Guice
public interface

PrivateBinder

implements Binder
com.google.inject.PrivateBinder

Class Overview

Returns a binder whose configuration information is hidden from its environment by default. See PrivateModule for details.

Summary

Public Methods
abstract void expose(Key<?> key)
Makes the binding for key available to the enclosing environment
abstract AnnotatedElementBuilder expose(TypeLiteral<?> type)
Makes a binding for type available to the enclosing environment.
abstract AnnotatedElementBuilder expose(Class<?> type)
Makes a binding for type available to the enclosing environment.
abstract PrivateBinder skipSources(Class... classesToSkip)
Returns a binder that skips classesToSkip when identify the calling code.
abstract PrivateBinder withSource(Object source)
Returns a binder that uses source as the reference location for configuration errors.
[Expand]
Inherited Methods
From interface com.google.inject.Binder

Public Methods

public abstract void expose (Key<?> key)

Makes the binding for key available to the enclosing environment

public abstract AnnotatedElementBuilder expose (TypeLiteral<?> type)

Makes a binding for type available to the enclosing environment. Use annotatedWith() to expose type with a binding annotation.

public abstract AnnotatedElementBuilder expose (Class<?> type)

Makes a binding for type available to the enclosing environment. Use annotatedWith() to expose type with a binding annotation.

public abstract PrivateBinder skipSources (Class... classesToSkip)

Returns a binder that skips classesToSkip when identify the calling code. The caller's StackTraceElement is used to locate the source of configuration errors.

Parameters
classesToSkip library classes that create bindings on behalf of their clients.
Returns
  • a binder that shares its configuration with this binder.

public abstract PrivateBinder withSource (Object source)

Returns a binder that uses source as the reference location for configuration errors. This is typically a StackTraceElement for .java source but it could any binding source, such as the path to a .properties file.

Parameters
source any object representing the source location and has a concise toString() value
Returns
  • a binder that shares its configuration with this binder
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/OutOfScopeException.html0000755000175000017500000006640611704661106031575 0ustar tonytony OutOfScopeException | Guice
public final class

OutOfScopeException

extends RuntimeException
java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ java.lang.RuntimeException
         ↳ com.google.inject.OutOfScopeException

Class Overview

Thrown from get() when an attempt is made to access a scoped object while the scope in question is not currently active.

Summary

Public Constructors
OutOfScopeException(String message)
OutOfScopeException(String message, Throwable cause)
OutOfScopeException(Throwable cause)
[Expand]
Inherited Methods
From class java.lang.Throwable
From class java.lang.Object

Public Constructors

public OutOfScopeException (String message)

public OutOfScopeException (String message, Throwable cause)

public OutOfScopeException (Throwable cause)

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/Module.html0000755000175000017500000005073311704661106027111 0ustar tonytony Module | Guice
public interface

Module

com.google.inject.Module
Known Indirect Subclasses

Class Overview

A module contributes configuration information, typically interface bindings, which will be used to create an Injector. A Guice-based application is ultimately composed of little more than a set of Modules and some bootstrapping code.

Your Module classes can use a more streamlined syntax by extending AbstractModule rather than implementing this interface directly.

In addition to the bindings configured via configure(Binder), bindings will be created for all methods annotated with @Provides. Use scope and binding annotations on these methods to configure the bindings.

Summary

Public Methods
abstract void configure(Binder binder)
Contributes bindings and other configurations for this module to binder.

Public Methods

public abstract void configure (Binder binder)

Contributes bindings and other configurations for this module to binder.

Do not invoke this method directly to install submodules. Instead use install(Module), which ensures that provider methods are discovered.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/MembersInjector.html0000755000175000017500000003675311704661106030762 0ustar tonytony MembersInjector | Guice
public interface

MembersInjector

com.google.inject.MembersInjector<T>

Class Overview

Injects dependencies into the fields and methods on instances of type T. Ignores the presence or absence of an injectable constructor.

Summary

Public Methods
abstract void injectMembers(T instance)
Injects dependencies into the fields and methods of instance.

Public Methods

public abstract void injectMembers (T instance)

Injects dependencies into the fields and methods of instance. Ignores the presence or absence of an injectable constructor.

Whenever Guice creates an instance, it performs this injection automatically (after first performing constructor injection), so if you're able to let Guice create all your objects for you, you'll never need to use this method.

Parameters
instance to inject members on. May be null.
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/Key.html0000755000175000017500000014334711704661106026420 0ustar tonytony Key | Guice
public class

Key

extends Object
java.lang.Object
   ↳ com.google.inject.Key<T>

Class Overview

Binding key consisting of an injection type and an optional annotation. Matches the type and annotation at a point of injection.

For example, Key.get(Service.class, Transactional.class) will match:

   @Inject
   public void setService(@Transactional Service service) {
     ...
   }
 

Key supports generic types via subclassing just like TypeLiteral.

Keys do not differentiate between primitive types (int, char, etc.) and their correpsonding wrapper types (Integer, Character, etc.). Primitive types will be replaced with their wrapper types when keys are created.

Summary

Protected Constructors
Key()
Constructs a new key.
Key(Class<? extends Annotation> annotationType)
Constructs a new key.
Key(Annotation annotation)
Constructs a new key.
Public Methods
final boolean equals(Object o)
static <T> Key<T> get(TypeLiteral<T> typeLiteral)
Gets a key for an injection type.
static <T> Key<T> get(TypeLiteral<T> typeLiteral, Class<? extends Annotation> annotationType)
Gets a key for an injection type and an annotation type.
static <T> Key<T> get(TypeLiteral<T> typeLiteral, Annotation annotation)
Gets a key for an injection type and an annotation.
static <T> Key<T> get(Class<T> type)
Gets a key for an injection type.
static <T> Key<T> get(Class<T> type, Class<? extends Annotation> annotationType)
Gets a key for an injection type and an annotation type.
static <T> Key<T> get(Class<T> type, Annotation annotation)
Gets a key for an injection type and an annotation.
static Key<?> get(Type type)
Gets a key for an injection type.
static Key<?> get(Type type, Class<? extends Annotation> annotationType)
Gets a key for an injection type and an annotation type.
static Key<?> get(Type type, Annotation annotation)
Gets a key for an injection type and an annotation.
final Annotation getAnnotation()
Gets the annotation.
final Class<? extends Annotation> getAnnotationType()
Gets the annotation type.
final TypeLiteral<T> getTypeLiteral()
Gets the key type.
boolean hasAttributes()
Returns true if this key has annotation attributes.
final int hashCode()
<T> Key<T> ofType(TypeLiteral<T> type)
Returns a new key of the specified type with the same annotation as this key.
<T> Key<T> ofType(Class<T> type)
Returns a new key of the specified type with the same annotation as this key.
Key<?> ofType(Type type)
Returns a new key of the specified type with the same annotation as this key.
final String toString()
Key<T> withoutAttributes()
Returns this key without annotation attributes, i.e.
[Expand]
Inherited Methods
From class java.lang.Object

Protected Constructors

protected Key ()

Constructs a new key. Derives the type from this class's type parameter.

Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

Example usage for a binding of type Foo:

new Key<Foo>() {}.

protected Key (Class<? extends Annotation> annotationType)

Constructs a new key. Derives the type from this class's type parameter.

Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

Example usage for a binding of type Foo annotated with @Bar:

new Key<Foo>(Bar.class) {}.

protected Key (Annotation annotation)

Constructs a new key. Derives the type from this class's type parameter.

Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

Example usage for a binding of type Foo annotated with @Bar:

new Key<Foo>(new Bar()) {}.

Public Methods

public final boolean equals (Object o)

public static Key<T> get (TypeLiteral<T> typeLiteral)

Gets a key for an injection type.

public static Key<T> get (TypeLiteral<T> typeLiteral, Class<? extends Annotation> annotationType)

Gets a key for an injection type and an annotation type.

public static Key<T> get (TypeLiteral<T> typeLiteral, Annotation annotation)

Gets a key for an injection type and an annotation.

public static Key<T> get (Class<T> type)

Gets a key for an injection type.

public static Key<T> get (Class<T> type, Class<? extends Annotation> annotationType)

Gets a key for an injection type and an annotation type.

public static Key<T> get (Class<T> type, Annotation annotation)

Gets a key for an injection type and an annotation.

public static Key<?> get (Type type)

Gets a key for an injection type.

public static Key<?> get (Type type, Class<? extends Annotation> annotationType)

Gets a key for an injection type and an annotation type.

public static Key<?> get (Type type, Annotation annotation)

Gets a key for an injection type and an annotation.

public final Annotation getAnnotation ()

Gets the annotation.

public final Class<? extends Annotation> getAnnotationType ()

Gets the annotation type.

public final TypeLiteral<T> getTypeLiteral ()

Gets the key type.

public boolean hasAttributes ()

Returns true if this key has annotation attributes.

public final int hashCode ()

public Key<T> ofType (TypeLiteral<T> type)

Returns a new key of the specified type with the same annotation as this key.

public Key<T> ofType (Class<T> type)

Returns a new key of the specified type with the same annotation as this key.

public Key<?> ofType (Type type)

Returns a new key of the specified type with the same annotation as this key.

public final String toString ()

public Key<T> withoutAttributes ()

Returns this key without annotation attributes, i.e. with only the annotation type.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/Injector.html0000755000175000017500000014471511704661106027445 0ustar tonytony Injector | Guice
public interface

Injector

com.google.inject.Injector

Class Overview

Builds the graphs of objects that make up your application. The injector tracks the dependencies for each type and uses bindings to inject them. This is the core of Guice, although you rarely interact with it directly. This "behind-the-scenes" operation is what distinguishes dependency injection from its cousin, the service locator pattern.

Contains several default bindings:

  • This Injector instance itself
  • A Provider<T> for each binding of type T
  • The java.util.logging.Logger for the class being injected
  • The Stage in which the Injector was created
Injectors are created using the facade class Guice.

An injector can also inject the dependencies of already-constructed instances. This can be used to interoperate with objects created by other frameworks or services.

Injectors can be hierarchical. Child injectors inherit the configuration of their parent injectors, but the converse does not hold.

The injector's internal bindings are available for introspection. This enables tools and extensions to operate on an injector reflectively.

Summary

Public Methods
abstract Injector createChildInjector(Module... modules)
Returns a new injector that inherits all state from this injector.
abstract Injector createChildInjector(Iterable<? extends Module> modules)
Returns a new injector that inherits all state from this injector.
abstract <T> List<Binding<T>> findBindingsByType(TypeLiteral<T> type)
Returns all explicit bindings for type.
abstract Map<Key<?>, Binding<?>> getAllBindings()
Returns a snapshot of this injector's bindings, both explicit and just-in-time.
abstract <T> Binding<T> getBinding(Key<T> key)
Returns the binding for the given injection key.
abstract <T> Binding<T> getBinding(Class<T> type)
Returns the binding for the given type.
abstract Map<Key<?>, Binding<?>> getBindings()
Returns this injector's explicit bindings.
abstract <T> Binding<T> getExistingBinding(Key<T> key)
Returns the binding if it already exists, or null if does not exist.
abstract <T> T getInstance(Key<T> key)
Returns the appropriate instance for the given injection key; equivalent to getProvider(key).get().
abstract <T> T getInstance(Class<T> type)
Returns the appropriate instance for the given injection type; equivalent to getProvider(type).get().
abstract <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral)
Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
abstract <T> MembersInjector<T> getMembersInjector(Class<T> type)
Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
abstract Injector getParent()
Returns this injector's parent, or null if this is a top-level injector.
abstract <T> Provider<T> getProvider(Key<T> key)
Returns the provider used to obtain instances for the given injection key.
abstract <T> Provider<T> getProvider(Class<T> type)
Returns the provider used to obtain instances for the given type.
abstract Map<Class<? extends Annotation>, Scope> getScopeBindings()
Returns a map containing all scopes in the injector.
abstract Set<TypeConverterBinding> getTypeConverterBindings()
Returns a set containing all type converter bindings in the injector.
abstract void injectMembers(Object instance)
Injects dependencies into the fields and methods of instance.

Public Methods

public abstract Injector createChildInjector (Module... modules)

Returns a new injector that inherits all state from this injector. All bindings, scopes, interceptors and type converters are inherited -- they are visible to the child injector. Elements of the child injector are not visible to its parent.

Just-in-time bindings created for child injectors will be created in an ancestor injector whenever possible. This allows for scoped instances to be shared between injectors. Use explicit bindings to prevent bindings from being shared with the parent injector.

No key may be bound by both an injector and one of its ancestors. This includes just-in-time bindings. The lone exception is the key for Injector.class, which is bound by each injector to itself.

public abstract Injector createChildInjector (Iterable<? extends Module> modules)

Returns a new injector that inherits all state from this injector. All bindings, scopes, interceptors and type converters are inherited -- they are visible to the child injector. Elements of the child injector are not visible to its parent.

Just-in-time bindings created for child injectors will be created in an ancestor injector whenever possible. This allows for scoped instances to be shared between injectors. Use explicit bindings to prevent bindings from being shared with the parent injector. Optional injections in just-in-time bindings (created in the parent injector) may be silently ignored if the optional dependencies are from the child injector.

No key may be bound by both an injector and one of its ancestors. This includes just-in-time bindings. The lone exception is the key for Injector.class, which is bound by each injector to itself.

public abstract List<Binding<T>> findBindingsByType (TypeLiteral<T> type)

Returns all explicit bindings for type.

This method is part of the Guice SPI and is intended for use by tools and extensions.

public abstract Map<Key<?>, Binding<?>> getAllBindings ()

Returns a snapshot of this injector's bindings, both explicit and just-in-time. The returned map is immutable; it contains only the bindings that were present when getAllBindings() was invoked. Subsequent calls may return a map with additional just-in-time bindings.

The returned map does not include bindings inherited from a parent injector, should one exist.

This method is part of the Guice SPI and is intended for use by tools and extensions.

public abstract Binding<T> getBinding (Key<T> key)

Returns the binding for the given injection key. This will be an explicit bindings if the key was bound explicitly by a module, or an implicit binding otherwise. The implicit binding will be created if necessary.

This method is part of the Guice SPI and is intended for use by tools and extensions.

Throws
ConfigurationException if this injector cannot find or create the binding.

public abstract Binding<T> getBinding (Class<T> type)

Returns the binding for the given type. This will be an explicit bindings if the injection key was bound explicitly by a module, or an implicit binding otherwise. The implicit binding will be created if necessary.

This method is part of the Guice SPI and is intended for use by tools and extensions.

Throws
ConfigurationException if this injector cannot find or create the binding.

public abstract Map<Key<?>, Binding<?>> getBindings ()

Returns this injector's explicit bindings.

The returned map does not include bindings inherited from a parent injector, should one exist. The returned map is guaranteed to iterate (for example, with its entrySet() iterator) in the order of insertion. In other words, the order in which bindings appear in user Modules.

This method is part of the Guice SPI and is intended for use by tools and extensions.

public abstract Binding<T> getExistingBinding (Key<T> key)

Returns the binding if it already exists, or null if does not exist. Unlike getBinding(Key), this does not attempt to create just-in-time bindings for keys that aren't bound.

This method is part of the Guice SPI and is intended for use by tools and extensions.

public abstract T getInstance (Key<T> key)

Returns the appropriate instance for the given injection key; equivalent to getProvider(key).get(). When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time.

Throws
ConfigurationException if this injector cannot find or create the provider.
ProvisionException if there was a runtime failure while providing an instance.

public abstract T getInstance (Class<T> type)

Returns the appropriate instance for the given injection type; equivalent to getProvider(type).get(). When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time.

Throws
ConfigurationException if this injector cannot find or create the provider.
ProvisionException if there was a runtime failure while providing an instance.

public abstract MembersInjector<T> getMembersInjector (TypeLiteral<T> typeLiteral)

Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.

Parameters
typeLiteral type to get members injector for

public abstract MembersInjector<T> getMembersInjector (Class<T> type)

Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. When feasible, use getMembersInjector(TypeLiteral) instead to get increased up front error detection.

Parameters
type type to get members injector for

public abstract Injector getParent ()

Returns this injector's parent, or null if this is a top-level injector.

public abstract Provider<T> getProvider (Key<T> key)

Returns the provider used to obtain instances for the given injection key. When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time.

Throws
ConfigurationException if this injector cannot find or create the provider.

public abstract Provider<T> getProvider (Class<T> type)

Returns the provider used to obtain instances for the given type. When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time.

Throws
ConfigurationException if this injector cannot find or create the provider.

public abstract Map<Class<? extends Annotation>, Scope> getScopeBindings ()

Returns a map containing all scopes in the injector. The maps keys are scoping annotations like Singleton.class, and the values are scope instances, such as Scopes.SINGLETON. The returned map is immutable.

This method is part of the Guice SPI and is intended for use by tools and extensions.

public abstract Set<TypeConverterBinding> getTypeConverterBindings ()

Returns a set containing all type converter bindings in the injector. The returned set is immutable.

This method is part of the Guice SPI and is intended for use by tools and extensions.

public abstract void injectMembers (Object instance)

Injects dependencies into the fields and methods of instance. Ignores the presence or absence of an injectable constructor.

Whenever Guice creates an instance, it performs this injection automatically (after first performing constructor injection), so if you're able to let Guice create all your objects for you, you'll never need to use this method.

Parameters
instance to inject members on
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/Inject.html0000755000175000017500000004263211704661106027077 0ustar tonytony Inject | Guice
public abstract @interface

Inject

implements Annotation
com.google.inject.Inject

Class Overview

Annotates members of your implementation class (constructors, methods and fields) into which the Injector should inject values. The Injector fulfills injection requests for:

  • Every instance it constructs. The class being constructed must have exactly one of its constructors marked with @Inject or must have a constructor taking no parameters. The Injector then proceeds to perform method and field injections.
  • Pre-constructed instances passed to injectMembers(Object), toInstance(Object) and toProvider(Provider). In this case all constructors are, of course, ignored.
  • Static fields and methods of classes which any Module has specifically requested static injection for, using requestStaticInjection(Class...).
In all cases, a member can be injected regardless of its Java access specifier (private, default, protected, public).

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/ImplementedBy.html0000755000175000017500000004003511704661106030414 0ustar tonytony ImplementedBy | Guice
public abstract @interface

ImplementedBy

implements Annotation
com.google.inject.ImplementedBy

Class Overview

A pointer to the default implementation of a type.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/Guice.html0000755000175000017500000006634011704661106026721 0ustar tonytony Guice | Guice
public final class

Guice

extends Object
java.lang.Object
   ↳ com.google.inject.Guice

Class Overview

The entry point to the Guice framework. Creates Injectors from Modules.

Guice supports a model of development that draws clear boundaries between APIs, Implementations of these APIs, Modules which configure these implementations, and finally Applications which consist of a collection of Modules. It is the Application, which typically defines your main() method, that bootstraps the Guice Injector using the Guice class, as in this example:

     public class FooApplication {
       public static void main(String[] args) {
         Injector injector = Guice.createInjector(
             new ModuleA(),
             new ModuleB(),
             . . .
             new FooApplicationFlagsModule(args)
         );

         // Now just bootstrap the application and you're done
         FooStarter starter = injector.getInstance(FooStarter.class);
         starter.runApplication();
       }
     }
 

Summary

Public Methods
static Injector createInjector(Module... modules)
Creates an injector for the given set of modules.
static Injector createInjector(Stage stage, Module... modules)
Creates an injector for the given set of modules, in a given development stage.
static Injector createInjector(Stage stage, Iterable<? extends Module> modules)
Creates an injector for the given set of modules, in a given development stage.
static Injector createInjector(Iterable<? extends Module> modules)
Creates an injector for the given set of modules.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Injector createInjector (Module... modules)

Creates an injector for the given set of modules.

Throws
CreationException if one or more errors occur during injector construction

public static Injector createInjector (Stage stage, Module... modules)

Creates an injector for the given set of modules, in a given development stage.

Throws
CreationException if one or more errors occur during injector creation.

public static Injector createInjector (Stage stage, Iterable<? extends Module> modules)

Creates an injector for the given set of modules, in a given development stage.

Throws
CreationException if one or more errors occur during injector construction

public static Injector createInjector (Iterable<? extends Module> modules)

Creates an injector for the given set of modules.

Throws
CreationException if one or more errors occur during injector creation
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/Exposed.html0000755000175000017500000004021611704661106027266 0ustar tonytony Exposed | Guice
public abstract @interface

Exposed

implements Annotation
com.google.inject.Exposed

Class Overview

Acccompanies a @Provides method annotation in a private module to indicate that the provided binding is exposed.

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/CreationException.html0000755000175000017500000006765011704661106031315 0ustar tonytony CreationException | Guice
public class

CreationException

extends RuntimeException
java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ java.lang.RuntimeException
         ↳ com.google.inject.CreationException

Class Overview

Thrown when errors occur while creating a Injector. Includes a list of encountered errors. Clients should catch this exception, log it, and stop execution.

Summary

Public Constructors
CreationException(Collection<Message> messages)
Creates a CreationException containing messages.
Public Methods
Collection<Message> getErrorMessages()
Returns messages for the errors that caused this exception.
String getMessage()
[Expand]
Inherited Methods
From class java.lang.Throwable
From class java.lang.Object

Public Constructors

public CreationException (Collection<Message> messages)

Creates a CreationException containing messages.

Public Methods

public Collection<Message> getErrorMessages ()

Returns messages for the errors that caused this exception.

public String getMessage ()

Since: API Level

././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/ConfigurationException.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/ConfigurationException.ht0000755000175000017500000007560511704661106032026 0ustar tonytony ConfigurationException | Guice
public final class

ConfigurationException

extends RuntimeException
java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ java.lang.RuntimeException
         ↳ com.google.inject.ConfigurationException

Class Overview

Thrown when a programming error such as a misplaced annotation, illegal binding, or unsupported scope is found. Clients should catch this exception, log it, and stop execution.

Summary

Public Constructors
ConfigurationException(Iterable<Message> messages)
Creates a ConfigurationException containing messages.
Public Methods
Collection<Message> getErrorMessages()
Returns messages for the errors that caused this exception.
String getMessage()
<E> E getPartialValue()
Returns a value that was only partially computed due to this exception.
ConfigurationException withPartialValue(Object partialValue)
Returns a copy of this configuration exception with the specified partial value.
[Expand]
Inherited Methods
From class java.lang.Throwable
From class java.lang.Object

Public Constructors

public ConfigurationException (Iterable<Message> messages)

Creates a ConfigurationException containing messages.

Public Methods

public Collection<Message> getErrorMessages ()

Returns messages for the errors that caused this exception.

public String getMessage ()

Since: API Level

public E getPartialValue ()

Returns a value that was only partially computed due to this exception. The caller can use this while collecting additional configuration problems.

Returns
  • the partial value, or null if none was set. The type of the partial value is specified by the throwing method.

public ConfigurationException withPartialValue (Object partialValue)

Returns a copy of this configuration exception with the specified partial value.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/BindingAnnotation.html0000755000175000017500000004061011704661106031262 0ustar tonytony BindingAnnotation | Guice
public abstract @interface

BindingAnnotation

implements Annotation
com.google.inject.BindingAnnotation

Class Overview

Annotates annotations which are used for binding. Only one such annotation may apply to a single injection point. You must also annotate binder annotations with @Retention(RUNTIME). For example:

   @Retention(RUNTIME)
   @Target({ FIELD, PARAMETER, METHOD })
   @BindingAnnotation
   public @interface Transactional {}
 

Summary

[Expand]
Inherited Methods
From interface java.lang.annotation.Annotation
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/Binding.html0000755000175000017500000007403311704661106027235 0ustar tonytony Binding | Guice
public interface

Binding

implements Element
com.google.inject.Binding<T>
Known Indirect Subclasses

Class Overview

A mapping from a key (type and optional annotation) to the strategy for getting instances of the type. This interface is part of the introspection API and is intended primarily for use by tools.

Bindings are created in several ways:

  • Explicitly in a module, via bind() and bindConstant() statements:
         bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);
         bindConstant().annotatedWith(ServerHost.class).to(args[0]);
  • Implicitly by the Injector by following a type's pointer annotations or by using its annotated or default constructor.
  • By converting a bound instance to a different type.
  • For providers, by delegating to the binding for the provided type.

They exist on both modules and on injectors, and their behaviour is different for each:

  • Module bindings are incomplete and cannot be used to provide instances. This is because the applicable scopes and interceptors may not be known until an injector is created. From a tool's perspective, module bindings are like the injector's source code. They can be inspected or rewritten, but this analysis must be done statically.
  • Injector bindings are complete and valid and can be used to provide instances. From a tools' perspective, injector bindings are like reflection for an injector. They have full runtime information, including the complete graph of injections necessary to satisfy a binding.

Summary

Public Methods
abstract <V> V acceptScopingVisitor(BindingScopingVisitor<V> visitor)
Accepts a scoping visitor.
abstract <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> visitor)
Accepts a target visitor.
abstract Key<T> getKey()
Returns the key for this binding.
abstract Provider<T> getProvider()
Returns the scoped provider guice uses to fulfill requests for this binding.
[Expand]
Inherited Methods
From interface com.google.inject.spi.Element

Public Methods

public abstract V acceptScopingVisitor (BindingScopingVisitor<V> visitor)

Accepts a scoping visitor. Invokes the visitor method specific to this binding's scoping.

Parameters
visitor to call back on

public abstract V acceptTargetVisitor (BindingTargetVisitor<? super T, V> visitor)

Accepts a target visitor. Invokes the visitor method specific to this binding's target.

Parameters
visitor to call back on

public abstract Key<T> getKey ()

Returns the key for this binding.

public abstract Provider<T> getProvider ()

Returns the scoped provider guice uses to fulfill requests for this binding.

Throws
UnsupportedOperationException when invoked on a Binding created via getElements(Module...). This method is only supported on Bindings returned from an injector.
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/Binder.html0000755000175000017500000021376211704661106027072 0ustar tonytony Binder | Guice
public interface

Binder

com.google.inject.Binder
Known Indirect Subclasses

Class Overview

Collects configuration information (primarily bindings) which will be used to create an Injector. Guice provides this object to your application's Module implementors so they may each contribute their own bindings and other registrations.

The Guice Binding EDSL

Guice uses an embedded domain-specific language, or EDSL, to help you create bindings simply and readably. This approach is great for overall usability, but it does come with a small cost: it is difficult to learn how to use the Binding EDSL by reading method-level javadocs. Instead, you should consult the series of examples below. To save space, these examples omit the opening binder, just as you will if your module extends AbstractModule.
     bind(ServiceImpl.class);
This statement does essentially nothing; it "binds the ServiceImpl class to itself" and does not change Guice's default behavior. You may still want to use this if you prefer your Module class to serve as an explicit manifest for the services it provides. Also, in rare cases, Guice may be unable to validate a binding at injector creation time unless it is given explicitly.
     bind(Service.class).to(ServiceImpl.class);
Specifies that a request for a Service instance with no binding annotations should be treated as if it were a request for a ServiceImpl instance. This overrides the function of any @ImplementedBy or @ProvidedBy annotations found on Service, since Guice will have already "moved on" to ServiceImpl before it reaches the point when it starts looking for these annotations.
     bind(Service.class).toProvider(ServiceProvider.class);
In this example, ServiceProvider must extend or implement Provider<Service>. This binding specifies that Guice should resolve an unannotated injection request for Service by first resolving an instance of ServiceProvider in the regular way, then calling get() on the resulting Provider instance to obtain the Service instance.

The Provider you use here does not have to be a "factory"; that is, a provider which always creates each instance it provides. However, this is generally a good practice to follow. You can then use Guice's concept of scopes to guide when creation should happen -- "letting Guice work for you".

     bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);
Like the previous example, but only applies to injection requests that use the binding annotation @Red. If your module also includes bindings for particular values of the @Red annotation (see below), then this binding will serve as a "catch-all" for any values of @Red that have no exact match in the bindings.
     bind(ServiceImpl.class).in(Singleton.class);
     // or, alternatively
     bind(ServiceImpl.class).in(Scopes.SINGLETON);
Either of these statements places the ServiceImpl class into singleton scope. Guice will create only one instance of ServiceImpl and will reuse it for all injection requests of this type. Note that it is still possible to bind another instance of ServiceImpl if the second binding is qualified by an annotation as in the previous example. Guice is not overly concerned with preventing you from creating multiple instances of your "singletons", only with enabling your application to share only one instance if that's all you tell Guice you need.

Note: a scope specified in this way overrides any scope that was specified with an annotation on the ServiceImpl class.

Besides Singleton/SINGLETON, there are servlet-specific scopes available in com.google.inject.servlet.ServletScopes, and your Modules can contribute their own custom scopes for use here as well.

     bind(new TypeLiteral<PaymentService<CreditCard>>() {})
         .to(CreditCardPaymentService.class);
This admittedly odd construct is the way to bind a parameterized type. It tells Guice how to honor an injection request for an element of type PaymentService<CreditCard>. The class CreditCardPaymentService must implement the PaymentService<CreditCard> interface. Guice cannot currently bind or inject a generic type, such as Set<E>; all type parameters must be fully specified.
     bind(Service.class).toInstance(new ServiceImpl());
     // or, alternatively
     bind(Service.class).toInstance(SomeLegacyRegistry.getService());
In this example, your module itself, not Guice, takes responsibility for obtaining a ServiceImpl instance, then asks Guice to always use this single instance to fulfill all Service injection requests. When the Injector is created, it will automatically perform field and method injection for this instance, but any injectable constructor on ServiceImpl is simply ignored. Note that using this approach results in "eager loading" behavior that you can't control.
     bindConstant().annotatedWith(ServerHost.class).to(args[0]);
Sets up a constant binding. Constant injections must always be annotated. When a constant binding's value is a string, it is eligile for conversion to all primitive types, to all enums, and to class literals. Conversions for other types can be configured using convertToTypes().
   @Color("red") Color red; // A member variable (field)
    . . .
     red = MyModule.class.getDeclaredField("red").getAnnotation(Color.class);
     bind(Service.class).annotatedWith(red).to(RedService.class);
If your binding annotation has parameters you can apply different bindings to different specific values of your annotation. Getting your hands on the right instance of the annotation is a bit of a pain -- one approach, shown above, is to apply a prototype annotation to a field in your module class, so that you can read this annotation instance and give it to Guice.
     bind(Service.class)
         .annotatedWith(Names.named("blue"))
         .to(BlueService.class);
Differentiating by names is a common enough use case that we provided a standard annotation, @Named. Because of Guice's library support, binding by name is quite easier than in the arbitrary binding annotation case we just saw. However, remember that these names will live in a single flat namespace with all the other names used in your application.
     Constructor loneCtor = getLoneCtorFromServiceImplViaReflection();
     bind(ServiceImpl.class)
         .toConstructor(loneCtor);
In this example, we directly tell Guice which constructor to use in a concrete class implementation. It means that we do not need to place @Inject on any of the constructors and that Guice treats the provided constructor as though it were annotated so. It is useful for cases where you cannot modify existing classes and is a bit simpler than using a Provider.

The above list of examples is far from exhaustive. If you can think of how the concepts of one example might coexist with the concepts from another, you can most likely weave the two together. If the two concepts make no sense with each other, you most likely won't be able to do it. In a few cases Guice will let something bogus slip by, and will then inform you of the problems at runtime, as soon as you try to create your Injector.

The other methods of Binder such as bindScope(Class, Scope), bindInterceptor(Matcher>, Matcher, MethodInterceptor...), install(Module), requestStaticInjection(Class...), addError(String, Object...) and currentStage() are not part of the Binding EDSL; you can learn how to use these in the usual way, from the method documentation.

Summary

Public Methods
abstract void addError(Message message)
Records an error message to be presented to the user at a later time.
abstract void addError(String message, Object... arguments)
Records an error message which will be presented to the user at a later time.
abstract void addError(Throwable t)
Records an exception, the full details of which will be logged, and the message of which will be presented to the user at a later time.
abstract <T> LinkedBindingBuilder<T> bind(Key<T> key)
See the EDSL examples at Binder.
abstract <T> AnnotatedBindingBuilder<T> bind(TypeLiteral<T> typeLiteral)
See the EDSL examples at Binder.
abstract <T> AnnotatedBindingBuilder<T> bind(Class<T> type)
See the EDSL examples at Binder.
abstract AnnotatedConstantBindingBuilder bindConstant()
See the EDSL examples at Binder.
abstract void bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)
Binds method interceptor[s] to methods matched by class and method matchers.
abstract void bindListener(Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)
Registers a listener for injectable types.
abstract void bindScope(Class<? extends Annotation> annotationType, Scope scope)
Binds a scope to an annotation.
abstract void convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)
Binds a type converter.
abstract Stage currentStage()
Gets the current stage.
abstract void disableCircularProxies()
Prevents Guice from constructing a Proxy when a circular dependency is found.
abstract <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral)
Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
abstract <T> MembersInjector<T> getMembersInjector(Class<T> type)
Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
abstract <T> Provider<T> getProvider(Key<T> key)
Returns the provider used to obtain instances for the given injection key.
abstract <T> Provider<T> getProvider(Class<T> type)
Returns the provider used to obtain instances for the given injection type.
abstract void install(Module module)
Uses the given module to configure more bindings.
abstract PrivateBinder newPrivateBinder()
Creates a new private child environment for bindings and other configuration.
abstract <T> void requestInjection(TypeLiteral<T> type, T instance)
Upon successful creation, the Injector will inject instance fields and methods of the given object.
abstract void requestInjection(Object instance)
Upon successful creation, the Injector will inject instance fields and methods of the given object.
abstract void requestStaticInjection(Class...<?> types)
Upon successful creation, the Injector will inject static fields and methods in the given classes.
abstract void requireExplicitBindings()
Instructs the Injector that bindings must be listed in a Module in order to be injected.
abstract Binder skipSources(Class... classesToSkip)
Returns a binder that skips classesToSkip when identify the calling code.
abstract Binder withSource(Object source)
Returns a binder that uses source as the reference location for configuration errors.

Public Methods

public abstract void addError (Message message)

Records an error message to be presented to the user at a later time.

public abstract void addError (String message, Object... arguments)

Records an error message which will be presented to the user at a later time. Unlike throwing an exception, this enable us to continue configuring the Injector and discover more errors. Uses format(String, Object[]) to insert the arguments into the message.

public abstract void addError (Throwable t)

Records an exception, the full details of which will be logged, and the message of which will be presented to the user at a later time. If your Module calls something that you worry may fail, you should catch the exception and pass it into this.

public abstract LinkedBindingBuilder<T> bind (Key<T> key)

See the EDSL examples at Binder.

public abstract AnnotatedBindingBuilder<T> bind (TypeLiteral<T> typeLiteral)

See the EDSL examples at Binder.

public abstract AnnotatedBindingBuilder<T> bind (Class<T> type)

See the EDSL examples at Binder.

public abstract AnnotatedConstantBindingBuilder bindConstant ()

See the EDSL examples at Binder.

public abstract void bindInterceptor (Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)

Binds method interceptor[s] to methods matched by class and method matchers. A method is eligible for interception if:

  • Guice created the instance the method is on
  • Neither the enclosing type nor the method is final
  • And the method is package-private, protected, or public

Parameters
classMatcher matches classes the interceptor should apply to. For example: only(Runnable.class).
methodMatcher matches methods the interceptor should apply to. For example: annotatedWith(Transactional.class).
interceptors to bind

public abstract void bindListener (Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)

Registers a listener for injectable types. Guice will notify the listener when it encounters injectable types matched by the given type matcher.

Parameters
typeMatcher that matches injectable types the listener should be notified of
listener for injectable types matched by typeMatcher

public abstract void bindScope (Class<? extends Annotation> annotationType, Scope scope)

Binds a scope to an annotation.

public abstract void convertToTypes (Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)

Binds a type converter. The injector will use the given converter to convert string constants to matching types as needed.

Parameters
typeMatcher matches types the converter can handle
converter converts values

public abstract Stage currentStage ()

Gets the current stage.

public abstract void disableCircularProxies ()

Prevents Guice from constructing a Proxy when a circular dependency is found. By default, circular proxies are not disabled.

If a parent injector disables circular proxies, then all child injectors (and private modules within that injector) also disable circular proxies. If a parent does not disable circular proxies, a child injector or private module may optionally declare itself as disabling circular proxies. If it does, the behavior is limited only to that child or any grandchildren. No siblings of the child will disable circular proxies.

public abstract MembersInjector<T> getMembersInjector (TypeLiteral<T> typeLiteral)

Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. The returned members injector will not be valid until the main Injector has been created. The members injector will throw an IllegalStateException if you try to use it beforehand.

Parameters
typeLiteral type to get members injector for

public abstract MembersInjector<T> getMembersInjector (Class<T> type)

Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. The returned members injector will not be valid until the main Injector has been created. The members injector will throw an IllegalStateException if you try to use it beforehand.

Parameters
type type to get members injector for

public abstract Provider<T> getProvider (Key<T> key)

Returns the provider used to obtain instances for the given injection key. The returned provider will not be valid until the Injector has been created. The provider will throw an IllegalStateException if you try to use it beforehand.

public abstract Provider<T> getProvider (Class<T> type)

Returns the provider used to obtain instances for the given injection type. The returned provider will not be valid until the Injector has been created. The provider will throw an IllegalStateException if you try to use it beforehand.

public abstract void install (Module module)

Uses the given module to configure more bindings.

public abstract PrivateBinder newPrivateBinder ()

Creates a new private child environment for bindings and other configuration. The returned binder can be used to add and configuration information in this environment. See PrivateModule for details.

Returns
  • a binder that inherits configuration from this binder. Only exposed configuration on the returned binder will be visible to this binder.

public abstract void requestInjection (TypeLiteral<T> type, T instance)

Upon successful creation, the Injector will inject instance fields and methods of the given object.

Parameters
type of instance
instance for which members will be injected

public abstract void requestInjection (Object instance)

Upon successful creation, the Injector will inject instance fields and methods of the given object.

Parameters
instance for which members will be injected

public abstract void requestStaticInjection (Class...<?> types)

Upon successful creation, the Injector will inject static fields and methods in the given classes.

Parameters
types for which static members will be injected

public abstract void requireExplicitBindings ()

Instructs the Injector that bindings must be listed in a Module in order to be injected. Classes that are not explicitly bound in a module cannot be injected. Bindings created through a linked binding ( bind(Foo.class).to(FooImpl.class)) are allowed, but the implicit binding (FooImpl) cannot be directly injected unless it is also explicitly bound (bind(FooImpl.class)).

Tools can still retrieve bindings for implicit bindings (bindings created through a linked binding) if explicit bindings are required, however getProvider() will fail.

By default, explicit bindings are not required.

If a parent injector requires explicit bindings, then all child injectors (and private modules within that injector) also require explicit bindings. If a parent does not require explicit bindings, a child injector or private module may optionally declare itself as requiring explicit bindings. If it does, the behavior is limited only to that child or any grandchildren. No siblings of the child will require explicit bindings.

If the parent did not require explicit bindings but the child does, it is possible that a linked binding in the child may add a JIT binding to the parent. The child will not be allowed to reference the target binding directly, but the parent and other children of the parent may be able to.

public abstract Binder skipSources (Class... classesToSkip)

Returns a binder that skips classesToSkip when identify the calling code. The caller's StackTraceElement is used to locate the source of configuration errors.

Parameters
classesToSkip library classes that create bindings on behalf of their clients.
Returns
  • a binder that shares its configuration with this binder.

public abstract Binder withSource (Object source)

Returns a binder that uses source as the reference location for configuration errors. This is typically a StackTraceElement for .java source but it could any binding source, such as the path to a .properties file.

Parameters
source any object representing the source location and has a concise toString() value
Returns
  • a binder that shares its configuration with this binder
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/com/google/inject/AbstractModule.html0000755000175000017500000017663411704661106030606 0ustar tonytony AbstractModule | Guice
public abstract class

AbstractModule

extends Object
implements Module
java.lang.Object
   ↳ com.google.inject.AbstractModule
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

A support class for Modules which reduces repetition and results in a more readable configuration. Simply extend this class, implement configure(), and call the inherited methods which mirror those found in Binder. For example:

 public class MyModule extends AbstractModule {
   protected void configure() {
     bind(Service.class).to(ServiceImpl.class).in(Singleton.class);
     bind(CreditCardPaymentService.class);
     bind(PaymentService.class).to(CreditCardPaymentService.class);
     bindConstant().annotatedWith(Names.named("port")).to(8080);
   }
 }
 

Summary

Public Constructors
AbstractModule()
Public Methods
synchronized final void configure(Binder builder)
Contributes bindings and other configurations for this module to binder.
Protected Methods
void addError(Message message)
void addError(String message, Object... arguments)
void addError(Throwable t)
<T> LinkedBindingBuilder<T> bind(Key<T> key)
<T> AnnotatedBindingBuilder<T> bind(TypeLiteral<T> typeLiteral)
<T> AnnotatedBindingBuilder<T> bind(Class<T> clazz)
AnnotatedConstantBindingBuilder bindConstant()
void bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)
void bindListener(Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)
void bindScope(Class<? extends Annotation> scopeAnnotation, Scope scope)
Binder binder()
Gets direct access to the underlying Binder.
abstract void configure()
Configures a Binder via the exposed methods.
void convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)
Stage currentStage()
<T> MembersInjector<T> getMembersInjector(TypeLiteral<T> type)
<T> MembersInjector<T> getMembersInjector(Class<T> type)
<T> Provider<T> getProvider(Key<T> key)
<T> Provider<T> getProvider(Class<T> type)
void install(Module module)
void requestInjection(Object instance)
void requestStaticInjection(Class...<?> types)
void requireBinding(Key<?> key)
Adds a dependency from this module to key.
void requireBinding(Class<?> type)
Adds a dependency from this module to type.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.Module

Public Constructors

public AbstractModule ()

Public Methods

public final synchronized void configure (Binder builder)

Contributes bindings and other configurations for this module to binder.

Do not invoke this method directly to install submodules. Instead use install(Module), which ensures that provider methods are discovered.

Protected Methods

protected void addError (Message message)

protected void addError (String message, Object... arguments)

protected void addError (Throwable t)

protected LinkedBindingBuilder<T> bind (Key<T> key)

See Also

protected AnnotatedBindingBuilder<T> bind (TypeLiteral<T> typeLiteral)

protected AnnotatedBindingBuilder<T> bind (Class<T> clazz)

See Also

protected AnnotatedConstantBindingBuilder bindConstant ()

See Also

protected void bindInterceptor (Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)

protected void bindListener (Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)

protected void bindScope (Class<? extends Annotation> scopeAnnotation, Scope scope)

protected Binder binder ()

Gets direct access to the underlying Binder.

protected abstract void configure ()

Configures a Binder via the exposed methods.

protected void convertToTypes (Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)

protected Stage currentStage ()

See Also

protected MembersInjector<T> getMembersInjector (TypeLiteral<T> type)

protected MembersInjector<T> getMembersInjector (Class<T> type)

protected Provider<T> getProvider (Key<T> key)

See Also

protected Provider<T> getProvider (Class<T> type)

protected void install (Module module)

See Also

protected void requestInjection (Object instance)

protected void requestStaticInjection (Class...<?> types)

protected void requireBinding (Key<?> key)

Adds a dependency from this module to key. When the injector is created, Guice will report an error if key cannot be injected. Note that this requirement may be satisfied by implicit binding, such as a public no-arguments constructor.

protected void requireBinding (Class<?> type)

Adds a dependency from this module to type. When the injector is created, Guice will report an error if type cannot be injected. Note that this requirement may be satisfied by implicit binding, such as a public no-arguments constructor.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/classes.html0000755000175000017500000021117411704661106024011 0ustar tonytony Class Index | Guice

Class Index

A B C D E F G H I J K L M N O P R S T U

A

AbstractMatcher<T> Implements and() and or()
AbstractModule A support class for Modules which reduces repetition and results in a more readable configuration. 
AnnotatedBindingBuilder<T> See the EDSL examples at Binder
AnnotatedConstantBindingBuilder See the EDSL examples at Binder
AnnotatedElementBuilder See the EDSL examples at Binder
ArrowType Arrow symbols that are available from Graphviz. 
Assisted Annotates an injected parameter or field whose value comes from an argument to a factory method. 
AssistedInject

When used in tandem with FactoryModuleBuilder, constructors annotated with @AssistedInject indicate that multiple constructors can be injected, each with different parameters. 

AssistedInjectBinding<T> A binding for a factory created by FactoryModuleBuilder. 
AssistedInjectTargetVisitor<T, V> A visitor for the AssistedInject extension. 
AssistedMethod Details about how a method in an assisted inject factory will be assisted. 

B

Binder Collects configuration information (primarily bindings) which will be used to create an Injector
Binding<T> A mapping from a key (type and optional annotation) to the strategy for getting instances of the type. 
BindingAnnotation Annotates annotations which are used for binding. 
BindingEdge<K> Interface for an edge that connects an interface to the type or instance that is bound to implement it. 
BindingEdge.Factory<K, T extends BindingEdge<K>> Factory interface for BindingEdges. 
BindingEdge.Type Classification for what kind of binding this edge represents. 
BindingEdgeFactory Graphviz-specific implementation of BindingEdge.Factory
BindingEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts BindingEdge methods to display operations on a GraphvizEdge
BindingScopingVisitor<V> Visits each of the strategies used to scope an injection. 
BindingTargetVisitor<T, V> Visits each of the strategies used to find an instance to satisfy an injection. 

C

CheckedProvider<T> Alternative to the Guice Provider that throws a checked Exception. 
CheckedProvides Annotates methods of a Module to create a CheckedProvider method binding that can throw exceptions. 
CompassPoint Enum for the "compass point" values used to control where edge end points appear on the graph. 
ConfigurationException Thrown when a programming error such as a misplaced annotation, illegal binding, or unsupported scope is found. 
ConstantBindingBuilder Binds to a constant value. 
ConstructorBinding<T> A binding to the constructor of a concrete clss. 
ConvertedConstantBinding<T> A binding created from converting a bound instance to a new type. 
CreationException Thrown when errors occur while creating a Injector

D

DefaultBindingScopingVisitor<V> No-op visitor for subclassing. 
DefaultBindingTargetVisitor<T, V> No-op visitor for subclassing. 
DefaultElementVisitor<V> No-op visitor for subclassing. 
Dependency<T> A variable that can be resolved by an injector. 
DependencyEdge<K> Interface for an edge from a class or InjectionPoint to the interface node that will satisfy the dependency. 
DependencyEdge.Factory<K, T extends DependencyEdge<K>> Factory interface for DependencyEdges. 
DependencyEdgeFactory Graphviz-specific implementation of DependencyEdge.Factory
DependencyEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts DependencyEdge methods to display operations on a GraphvizEdge
DisableCircularProxiesOption A request to disable circular proxies. 
DynamicFinder Utility that helps you introspect dynamic finder methods. 

E

EdgeStyle Styles for edges. 
Element A core component of a module or injector. 
Elements Exposes elements of a module so they can be inspected, validated or rewritten
ElementVisitor<V> Visit elements. 
Exposed Acccompanies a @Provides method annotation in a private module to indicate that the provided binding is exposed. 
ExposedBinding<T> A binding to a key exposed from an enclosed private environment. 

F

FactoryModuleBuilder Provides a factory that combines the caller's arguments with injector-supplied values to construct objects. 
FactoryProvider<F> This class is deprecated. use FactoryModuleBuilder instead.  
Finder Marks a method stub as a dynamic finder. 
FirstResult Annotate any dynamic finder method's integer argument with this to pass in the index of the first result in the result set you are interested in. 

G

GrapherModule Module for the common bindings for InjectorGrapher
GraphingVisitor<K, N extends InterfaceNode<K>, M extends ImplementationNode<K>, B extends BindingEdge<K>, D extends DependencyEdge<K>> BindingTargetVisitor that adds nodes and edges to the graph based on the visited Binding
GraphvizEdge Data object to encapsulate the attributes of Graphviz edges that we're interested in drawing. 
GraphvizModule Module that provides GraphvizRenderer as the Renderer and binds the other Graphviz factories. 
GraphvizNode Data object to encapsulate the attributes of Graphviz nodes that we're interested in drawing. 
GraphvizRenderer Renderer implementation that writes out a Graphviz DOT file of the graph. 
Guice The entry point to the Guice framework. 
GuiceFilter

Apply this filter in web.xml above all other filters (typically), to all requests where you plan to use servlet scopes. 

GuiceServletContextListener As of Guice 2.0 you can still use (your subclasses of) GuiceServletContextListener class as a logical place to create and configure your injector. 

H

HasDependencies Implemented by bindings, providers and instances that expose their dependencies explicitly. 

I

ImplementationNode<K> Node for classes and instances that have Dependencys and are bound to InterfaceNodes. 
ImplementationNode.Factory<K, T extends ImplementationNode<K>> Factory interface for ImplementationNodes. 
ImplementationNodeFactory Graphviz-specific implementation of ImplementationNode.Factory
ImplementationNodeFactory.GraphvizNodeAdaptor Adaptor class that converts ImplementationNode methods to display operations on a GraphvizNode
ImplementedBy A pointer to the default implementation of a type. 
Inject Annotates members of your implementation class (constructors, methods and fields) into which the Injector should inject values. 
InjectionListener<I> Listens for injections into instances of type I
InjectionPoint A constructor, field or method that can receive injections. 
InjectionRequest<T> A request to inject the instance fields and methods of an instance. 
Injector Builds the graphs of objects that make up your application. 
InjectorGrapher Root class for graphing an Injector
InstanceBinding<T> A binding to a single instance. 
InstanceFilterBinding A binding to a single instance of a filter. 
InstanceServletBinding A binding to a single instance of a servlet. 
InterceptorBinding Registration of interceptors for matching methods of matching classes. 
InterfaceNode<K> Node for an interface class that has been bound to an implementation class or instance. 
InterfaceNode.Factory<K, T extends InterfaceNode<K>> Factory interface for InterfaceNodes. 
InterfaceNodeFactory Graphviz-specific implementation of InterfaceNode.Factory
InterfaceNodeFactory.GraphvizNodeAdaptor Adaptor class that converts InterfaceNode methods to display operations on a GraphvizNode

J

JndiIntegration Integrates Guice with JNDI. 
JpaPersistModule JPA provider for guice persist. 

K

Key<T> Binding key consisting of an injection type and an optional annotation. 

L

LinkedBindingBuilder<T> See the EDSL examples at Binder
LinkedFilterBinding A linked binding to a filter. 
LinkedKeyBinding<T> A binding to a linked key. 
LinkedServletBinding A linked binding to a servlet. 

M

ManagedBindingMBean JMX interface to bindings. 
Manager Provides a JMX interface to Guice. 
MapBinder<K, V> An API to bind multiple map entries separately, only to later inject them as a complete map. 
MapBinderBinding<T> A binding for a MapBinder. 
Matcher<T> Returns true or false for a given input. 
Matchers Matcher implementations. 
MaxResults Annotate any dynamic finder method's integer argument with this to pass in the maximum size of returned result window. 
MembersInjector<T> Injects dependencies into the fields and methods on instances of type T
MembersInjectorLookup<T> A lookup of the members injector for a type. 
Message An error message and the context in which it occured. 
Module A module contributes configuration information, typically interface bindings, which will be used to create an Injector
Modules Static utility methods for creating and working with instances of Module
Modules.OverriddenModuleBuilder See the EDSL example at override()
Multibinder<T> An API to bind multiple values separately, only to later inject them as a complete collection. 
MultibinderBinding<T> A binding for a Multibinder. 
MultibindingsTargetVisitor<T, V> A visitor for the multibinder extension. 

N

Named Annotates named things. 
NameFactory Interface for a service that provides nice Strings that we can display in the graph for the types that come up in Bindings. 
Names Utility methods for use with @Named
NodeAliasFactory<K> Factory for aliasing one node ID to another. 
NodeIdFactory<K> Factory for abstract identifiers for elements on the graph. 
NodeShape Enum for the shapes that are most interesting for Guice graphing. 
NodeStyle Styles for nodes. 

O

OutOfScopeException Thrown from get() when an attempt is made to access a scoped object while the scope in question is not currently active. 

P

PersistFilter Apply this filter to enable the HTTP Request unit of work and to have guice-persist manage the lifecycle of active units of work. 
PersistModule Install this module to add guice-persist library support for JPA persistence providers. 
PersistService Persistence provider service. 
PortIdFactory Interface for a service that returns Graphviz port IDs, used for naming the rows in ImplementationNode-displaying GraphvizNodes. 
PortIdFactoryImpl Implementation of PortIdFactory
PrivateBinder Returns a binder whose configuration information is hidden from its environment by default. 
PrivateElements A private collection of elements that are hidden from the enclosing injector or module by default. 
PrivateModule A module whose configuration information is hidden from its environment by default. 
ProvidedBy A pointer to the default provider type for a type. 
Provider<T> An object capable of providing instances of type T
ProviderBinding<T extends Provider<?>> A binding to a Provider that delegates to the binding for the provided type. 
ProviderInstanceBinding<T> A binding to a provider instance. 
ProviderKeyBinding<T> A binding to a provider key. 
ProviderLookup<T> A lookup of the provider for a type. 
Providers Static utility methods for creating and working with instances of Provider
ProviderWithDependencies<T> A provider with dependencies on other injected types. 
ProviderWithExtensionVisitor<T> A Provider that is part of an extension which supports a custom BindingTargetVisitor. 
Provides Annotates methods of a Module to create a provider method binding. 
ProvisionException Indicates that there was a runtime failure while providing an instance. 

R

Renderer Interface for the service that renders the graph. 
RequestParameters Apply this to field or parameters of type Map<String, String[]> when you want the HTTP request parameter map to be injected. 
RequestScoped Apply this to implementation classes when you want one instance per request. 
RequireExplicitBindingsOption A request to require explicit bindings. 

S

Scope A scope is a level of visibility that instances provided by Guice may have. 
ScopeAnnotation Annotates annotations which are used for scoping. 
ScopeBinding Registration of a scope annotation with the scope that implements it. 
ScopedBindingBuilder See the EDSL examples at Binder
Scopes Built-in scope implementations. 
ServletModule Configures the servlet scopes and creates bindings for the servlet API objects so you can inject the request, response, session, etc. 
ServletModule.FilterKeyBindingBuilder See the EDSL examples at configureServlets() 
ServletModule.ServletKeyBindingBuilder See the EDSL examples at configureServlets() 
ServletModuleBinding A binding created by ServletModule
ServletModuleTargetVisitor<T, V> A visitor for the servlet extension. 
ServletScopes Servlet scopes. 
SessionScoped Apply this to implementation classes when you want one instance per session. 
ShortNameFactory Reasonable implementation for NameFactory
Singleton Apply this to implementation classes when you want only one instance (per Injector) to be reused for all injections for that binding. 
SpringIntegration Integrates Guice with Spring. 
Stage The stage we're running in. 
StaticInjectionRequest A request to inject the static fields and methods of a type. 
StringNodeIdFactory IdFactory implementation that for String node IDs. 

T

ThrowingProvider<T, E extends Exception> This interface is deprecated. use CheckedProvider instead.  
ThrowingProviderBinder

Builds a binding for a CheckedProvider

ThrowingProviderBinder.SecondaryBinder<P extends CheckedProvider>  
Toolable Instructs an Injector running in TOOL that a method should be injected. 
Transactional

Any method or class marked with this annotation will be considered for transactionality. 

TransitiveDependencyVisitor BindingTargetVisitor that returns a Collection of the Keys of each Binding's dependencies. 
TypeConverter Converts constant string values to a different type. 
TypeConverterBinding Registration of type converters for matching target types. 
TypeEncounter<I> Context of an injectable type encounter. 
TypeListener Listens for Guice to encounter injectable types. 
TypeListenerBinding Binds types (picked using a Matcher) to an type listener. 
TypeLiteral<T> Represents a generic type T
Types Static methods for working with types. 

U

UnitOfWork This interface is used to gain manual control over the unit of work. 
UntargettedBinding<T> An untargetted binding. 
UriPatternType An enumeration of the available URI-pattern matching styles 
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/assets/0000755000175000017500000000000011704661106022757 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/assets/triangle-none.gif0000755000175000017500000000036011704661106026212 0ustar tonytony‰PNG  IHDR  HЦДtEXtSoftwareAdobe ImageReadyqЩe<PLTEхцъЋГжeuГэюёЬWhЎџџџџџџИ6хуtRNSџџџџџџџоƒНYZIDATxкb`gg`g VV€b`ea VV66 @ ЌlllЌ €˜XY™€Т@ 0R0&F#X!D 3˜С d12ƒ#+LЁ†1hЌgIENDЎB`‚sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/assets/style.css0000755000175000017500000001320411704661106024634 0ustar tonytony.jd-toptitle { padding-left: 6px; margin-bottom: 30px; font-size: 160%; font-weight: bold; } div#jd-content table { border: none; } div#jd-content td, div#jd-content th { font-size: small; } div#jd-content table.jd-linktable { margin-top: 3px; border-spacing: 0; } div#jd-content p.jd-deprecated-warning { margin-top: 0; margin-bottom: 10px; } div#jd-content table.jd-linktable th { vertical-align: top; text-align: left; padding-top: 2px; padding-bottom: 2px; padding-left: 7px; padding-right: 7px; border: none; border-top: 1px solid #d2d7d0; background-color: #F7FCF4; } div#jd-content table.jd-linktable td { border: none; } div#jd-content table.jd-linktable td p { padding: 0; margin: 0; line-height: 110%; } div#jd-content table.jd-linktable .jd-linkcol { vertical-align: top; padding-top: 3px; padding-bottom: 0; padding-left: 7px; padding-right: 7px; border-top: 1px solid #d2d7d0; background-color: #E5F1E0; line-height: 110%; } div#jd-content table.jd-linktable .jd-descrcol { vertical-align: top; padding-top: 3px; padding-bottom: 0; padding-left: 7px; padding-right: 7px; border-top: 1px solid #d2d7d0; background-color: #F7FCF4; line-height: 110%; } div#jd-content table.jd-linktable .jd-descrcol p { padding: 0; margin: 0; line-height: 110%; } div#jd-content table.jd-linktable .jd-valcol { vertical-align: top; padding-top: 3px; padding-bottom: 0; padding-left: 7px; padding-right: 7px; border-top: 1px solid #d2d7d0; background-color: #E5F1E0; line-height: 110%; } div#jd-content table.jd-linktable .jd-commentrow { vertical-align: top; padding-top: 3px; padding-bottom: 4px; padding-left: 7px; padding-right: 7px; background-color: #F7FCF4; line-height: 110%; } div#jd-content div.jd-inheritedlinks { vertical-align: top; margin-top: 9px; padding-left: 7px; padding-right: 7px; background-color: #F7FCF4; line-height: 110%; } div#jd-content .jd-page_title-prefix { padding-top: 2em; margin-bottom: -14pt; } div#jd-content { margin-left: 0; margin-right: 10px; margin-bottom: 0; } div#jd-content h1 { padding-left: 10px; } div#jd-content h2 { padding-left: 10px; } div#jd-content h4 { margin-top: 9px; margin-bottom: 1px; } div#jd-content .jd-descr h5 { margin-bottom: 8px; } div#jd-content .sidebox h3 { margin: 1em 0 0 0; } div#jd-content .jd-letterlist { margin-top: 20px; margin-bottom: 0; } div#jd-content .jd-lettertable { margin-top: 15px; margin-right: 10px; } div#jd-content .jd-letterentries { list-style: none; margin-left: 0; } div#jd-content .jd-letterentrycomments { color: gray; } div#jd-content table.jd-inheritance-table { margin-top: 0; margin-left: 10px; margin-right: 10px; border-spacing: 0; } div#jd-content table.jd-inheritance-table td { border: none; margin: 0; padding: 0; background-color: white; } div#jd-content table.jd-inheritance-table .jd-inheritance-space { width: 10px; } div#jd-content table.jd-inheritance-table .jd-inheritance-interface-cell { padding-left: 17px; } div#jd-content h4.jd-details-title { margin: 0; background-color: #E5F1E0; padding: 2px; padding-left: 10px; padding-right: 10px; margin-top: 15px; } div#jd-content .jd-details { margin-top: 0; margin-left: -10px; } div#jd-content .jd-details-descr { line-height: 120%; padding-left: 10px; padding-top: 10px; padding-right: 20px; } div#jd-content .jd-descr h5, div#jd-content .jd-details h5 { font-style: normal; text-decoration: none; font-size: 120%; } div#jd-content .jd-more { } div#jd-content .jd-descr { padding-top: 0; } div#jd-content .jd-tagdata { margin-top: 6px; margin-bottom: 6px; } div#jd-content .jd-tagtitle { margin-top: 0px; } div#jd-content .jd-tagtable { margin-top: 10px; border-spacing: 0; } div#jd-content .jd-tagtable th { background: white; padding-left: 10px; padding-right: 10px; line-height: 120%; } div#jd-content .jd-tagtable th, div#jd-content .jd-tagtable td { line-height: 120%; border: none; margin: 0; text-align: left; padding-top: 0px; padding-bottom: 5px; } div#jd-content .Code,code,pre,samp,var { color: #004000; } div#jd-content pre.Code { padding-left: 20px; } /* XXX I would really like to apply font-size: 9pt only if var/samp is NOT inside of a .jd-descr div. */ div#jd-content .jd-descr code,var,samp { padding-left: 0px; } #search_autocomplete { font-size: 80%; } div#jd-searchbox table.jd-autocomplete-table-hidden { display: none; } div#jd-searchbox table.jd-autocomplete-table-showing { z-index: 10; border: 1px solid #3366cc; position: relative; top: -14px; left: 5px; background-color: white; } div#jd-searchbox td.jd-autocomplete { font-family: Arial, sans-serif; padding-left: 6px; padding-right: 6px; padding-top: 1px; padding-bottom: 1px; font-size: 80%; border: none; margin: 0; line-height: 105%; } div#jd-searchbox td.jd-selected { background-color: #E5F1E0; } div#jd-searchbox td.jd-linktype { color: #999999; } div#jd-content .jd-expando-trigger { margin-left: -8px; margin-right: 0px; border: none; } div#jd-build-id { color: #666; width: 100%; text-align: right; padding-right: 5px; padding-bottom: 3px; } @media print { #jd-searchbox, .jd-nav { display: none; } div#jd-content { margin-top: 0px; } } sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/assets/search_autocomplete.js0000755000175000017500000002075011704661106027352 0ustar tonytonyvar gSelectedIndex = -1; var gSelectedID = -1; var gMatches = new Array(); var gLastText = ""; var ROW_COUNT = 20; var gInitialized = false; var DEFAULT_TEXT = "search developer docs"; var HAS_SEARCH_PAGE = false; function set_row_selected(row, selected) { var c1 = row.cells[0]; // var c2 = row.cells[1]; if (selected) { c1.className = "jd-autocomplete jd-selected"; // c2.className = "jd-autocomplete jd-selected jd-linktype"; } else { c1.className = "jd-autocomplete"; // c2.className = "jd-autocomplete jd-linktype"; } } function set_row_values(toroot, row, match) { var link = row.cells[0].childNodes[0]; link.innerHTML = match.__hilabel || match.label; link.href = toroot + match.link // row.cells[1].innerHTML = match.type; } function sync_selection_table(toroot) { var filtered = document.getElementById("search_filtered"); var r; //TR DOM object var i; //TR iterator gSelectedID = -1; filtered.onmouseover = function() { if(gSelectedIndex >= 0) { set_row_selected(this.rows[gSelectedIndex], false); gSelectedIndex = -1; } } //initialize the table; draw it for the first time (but not visible). if (!gInitialized) { for (i=0; i 0) { document.getElementById("search_filtered_div").className = "showing"; var N = gMatches.length < ROW_COUNT ? gMatches.length : ROW_COUNT; for (i=0; i ROW_COUNT) { r = filtered.rows[ROW_COUNT]; r.className = "show-row"; c1 = r.cells[0]; c1.innerHTML = "plus " + (gMatches.length-ROW_COUNT) + " more"; } else { filtered.rows[ROW_COUNT].className = "hide-row"; }*/ //if we have no results, hide the table } else { document.getElementById("search_filtered_div").className = "no-display"; } } function search_changed(e, kd, toroot) { var search = document.getElementById("search_autocomplete"); var text = search.value.replace(/(^ +)|( +$)/g, ''); // 13 = enter if (e.keyCode == 13) { document.getElementById("search_filtered_div").className = "no-display"; if (kd && gSelectedIndex >= 0) { window.location = toroot + gMatches[gSelectedIndex].link; return false; } else if (gSelectedIndex < 0) { if (HAS_SEARCH_PAGE) { return true; } else { sync_selection_table(toroot); return false; } } } // 38 -- arrow up else if (kd && (e.keyCode == 38)) { if (gSelectedIndex >= 0) { gSelectedIndex--; } sync_selection_table(toroot); return false; } // 40 -- arrow down else if (kd && (e.keyCode == 40)) { if (gSelectedIndex < gMatches.length-1 && gSelectedIndex < ROW_COUNT-1) { gSelectedIndex++; } sync_selection_table(toroot); return false; } else if (!kd) { gMatches = new Array(); matchedCount = 0; gSelectedIndex = -1; for (var i=0; i= 0) { if (l < 0) l = 0; l += tmp; s = s.substr(tmp + 1); } return l; }; // helper function that counts the occurrences of a given character in // a given string var _countChar = function(s, c) { var n = 0; for (var i=0; i= 0) { // exact part match var partsAfter = _countChar(labelLower.substr(t + 1), '.'); score *= 200 / (partsAfter + 1); } else { t = _lastSearch(labelLower, partPrefixAlnumRE); if (t >= 0) { // part prefix match var partsAfter = _countChar(labelLower.substr(t + 1), '.'); score *= 20 / (partsAfter + 1); } } return score; }; for (var i=0; i$1'); } } function search_focus_changed(obj, focused) { if (focused) { if(obj.value == DEFAULT_TEXT){ obj.value = ""; obj.style.color="#000000"; } } else { if(obj.value == ""){ obj.value = DEFAULT_TEXT; obj.style.color="#aaaaaa"; } document.getElementById("search_filtered_div").className = "no-display"; } } function submit_search() { if (HAS_SEARCH_PAGE) { var query = document.getElementById('search_autocomplete').value; document.location = toRoot + 'search.html#q=' + query + '&t=0'; } return false; } sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/javadoc/assets/prettify.js0000755000175000017500000004456711704661106025206 0ustar tonytony(function(){ var o=true,r=null,z=false;window.PR_SHOULD_USE_CONTINUATION=o;window.PR_TAB_WIDTH=8;window.PR_normalizedHtml=window.PR=window.prettyPrintOne=window.prettyPrint=void 0;window._pr_isIE6=function(){var N=navigator&&navigator.userAgent&&/\bMSIE 6\./.test(navigator.userAgent);window._pr_isIE6=function(){return N};return N}; var aa="!",ba="!=",ca="!==",F="#",da="%",ea="%=",G="&",fa="&&",ja="&&=",ka="&=",H="(",la="*",ma="*=",na="+=",oa=",",pa="-=",qa="->",ra="/",sa="/=",ta=":",ua="::",va=";",I="<",wa="<<",xa="<<=",ya="<=",za="=",Aa="==",Ba="===",J=">",Ca=">=",Da=">>",Ea=">>=",Fa=">>>",Ga=">>>=",Ha="?",Ia="@",L="[",M="^",Ta="^=",Ua="^^",Va="^^=",Wa="{",O="|",Xa="|=",Ya="||",Za="||=",$a="~",ab="break",bb="case",cb="continue",db="delete",eb="do",fb="else",gb="finally",hb="instanceof",ib="return",jb="throw",kb="try",lb="typeof", mb="(?:^^|[+-]",nb="\\$1",ob=")\\s*",pb="&",qb="<",rb=">",sb=""",tb="&#",ub="x",vb="'",wb='"',xb=" ",yb="XMP",zb="\n',ic="\t",jc="\n",kc="[^<]+| com.google.inject.util
Generated by
JDiff

Package com.google.inject.util

Changed Classes
Modules Static utility methods for creating and working with instances of Module.
Providers Static utility methods for creating and working with instances of Provider.
 



././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/pkg_com.google.inject.throwingproviders.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/pkg_com.google.inject.throwingproviders.htm0000755000175000017500000002117111704661106032140 0ustar tonytony com.google.inject.throwingproviders
Generated by
JDiff

Package com.google.inject.throwingproviders

Added Classes and Interfaces
CheckedProvider Alternative to the Guice com.google.inject.Provider that throws a checked Exception.
CheckedProvides Annotates methods of a Module to create a CheckedProvider method binding that can throw exceptions.
 

Changed Classes and Interfaces
ThrowingProvider Alternative to the Guice com.google.inject.Provider that throws a checked Exception.
ThrowingProviderBinder

Builds a binding for a CheckedProvider.

ThrowingProviderBinder.
SecondaryBinder
 
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/pkg_com.google.inject.struts2.html0000755000175000017500000001565311704661106030153 0ustar tonytony com.google.inject.struts2
Generated by
JDiff

Package com.google.inject.struts2

Added Classes
Struts2Factory Cleanup up version from Bob's GuiceObjectFactory.
Struts2GuicePluginModule Initializes the Struts 2 Guice Plugin.
 

Changed Classes
GuiceObjectFactory @deprecated Use com.google.inject.servlet.Struts2Factory instead.
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/pkg_com.google.inject.spi.html0000755000175000017500000002351011704661106027307 0ustar tonytony com.google.inject.spi
Generated by
JDiff

Package com.google.inject.spi

Added Classes and Interfaces
DisableCircularProxiesOption A request to disable circular proxies.
ProviderWithExtensionVisitor A Provider that is part of an extension which supports a custom BindingTargetVisitor.
RequireExplicitBindingsOption A request to require explicit bindings.
Toolable Instructs an Injector running in Stage.TOOL that a method should be injected.
 

Changed Classes and Interfaces
ConvertedConstantBinding A binding created from converting a bound instance to a new type.
DefaultElementVisitor No-op visitor for subclassing.
ElementVisitor Visit elements.
InjectionPoint A constructor, field or method that can receive injections.
InterceptorBinding Registration of interceptors for matching methods of matching classes.
ProviderKeyBinding A binding to a provider key.
TypeConverterBinding Registration of type converters for matching target types.
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/pkg_com.google.inject.servlet.html0000755000175000017500000002504211704661106030202 0ustar tonytony com.google.inject.servlet
Generated by
JDiff

Package com.google.inject.servlet

Added Classes and Interfaces
InstanceFilterBinding A binding to a single instance of a filter.
InstanceServletBinding A binding to a single instance of a servlet.
LinkedFilterBinding A linked binding to a filter.
LinkedServletBinding A linked binding to a servlet.
ServletModuleBinding A binding created by ServletModule.
ServletModuleTargetVisitor A visitor for the servlet extension.
UriPatternType An enumeration of the available URI-pattern matching styles
 

Changed Classes and Interfaces
ServletModule Configures the servlet scopes and creates bindings for the servlet API objects so you can inject the request, response, session, etc.
ServletModule.FilterKeyBindingBuilder See the EDSL examples at ServletModule.configureServlets()
ServletModule.ServletKeyBindingBuilder See the EDSL examples at ServletModule.configureServlets()
ServletScopes Servlet scopes.
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/pkg_com.google.inject.multibindings.html0000755000175000017500000001724711704661106031376 0ustar tonytony com.google.inject.multibindings
Generated by
JDiff

Package com.google.inject.multibindings

Added Interfaces
MapBinderBinding A binding for a MapBinder.
MultibinderBinding A binding for a Multibinder.
MultibindingsTargetVisitor A visitor for the multibinder extension.
 

Changed Classes
MapBinder An API to bind multiple map entries separately, only to later inject them as a complete map.
Multibinder An API to bind multiple values separately, only to later inject them as a complete collection.
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/pkg_com.google.inject.html0000755000175000017500000002611511704661106026521 0ustar tonytony com.google.inject
Generated by
JDiff

Package com.google.inject

Changed Classes and Interfaces
Binder Collects configuration information (primarily bindings) which will be used to create an Injector. Guice provides this object to your application's Module implementors so they may each contribute their own bindings and other registrations.

The Guice Binding EDSL

Guice uses an embedded domain-specific language, or EDSL, to help you create bindings simply and readably. This approach is great for overall usability, but it does come with a small cost: it is difficult to learn how to use the Binding EDSL by reading method-level javadocs. Instead, you should consult the series of examples below. To save space, these examples omit the opening {@code binder}, just as you will if your module extends AbstractModule.
     bind(ServiceImpl.class);
This statement does essentially nothing; it "binds the {@code ServiceImpl} class to itself" and does not change Guice's default behavior. You may still want to use this if you prefer your Module class to serve as an explicit manifest for the services it provides. Also, in rare cases, Guice may be unable to validate a binding at injector creation time unless it is given explicitly.
     bind(Service.class).to(ServiceImpl.class);
Specifies that a request for a {@code Service} instance with no binding annotations should be treated as if it were a request for a {@code ServiceImpl} instance. This overrides the function of any @ImplementedBy or @ProvidedBy annotations found on {@code Service}, since Guice will have already "moved on" to {@code ServiceImpl} before it reaches the point when it starts looking for these annotations.
     bind(Service.class).toProvider(ServiceProvider.class);
In this example, {@code ServiceProvider} must extend or implement {@code Provider}. This binding specifies that Guice should resolve an unannotated injection request for {@code Service} by first resolving an instance of {@code ServiceProvider} in the regular way, then calling get() on the resulting Provider instance to obtain the {@code Service} instance.
Guice The entry point to the Guice framework. Creates Injectors from Modules.
Injector Builds the graphs of objects that make up your application.
Key Binding key consisting of an injection type and an optional annotation.
Provider An object capable of providing instances of type {@code T}.
ProvisionException Indicates that there was a runtime failure while providing an instance.
ScopeAnnotation Annotates annotations which are used for scoping.
Scopes Built-in scope implementations.
TypeLiteral Represents a generic type {@code T}.
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/pkg_com.google.inject.binder.html0000755000175000017500000001421711704661106027763 0ustar tonytony com.google.inject.binder
Generated by
JDiff

Package com.google.inject.binder

Changed Interfaces
ConstantBindingBuilder Binds to a constant value.
LinkedBindingBuilder See the EDSL examples at com.google.inject.Binder.
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/pkg_com.google.inject.assistedinject.html0000755000175000017500000002131511704661106031531 0ustar tonytony com.google.inject.assistedinject
Generated by
JDiff

Package com.google.inject.assistedinject

Added Classes and Interfaces
AssistedInjectBinding A binding for a factory created by FactoryModuleBuilder.
AssistedInjectTargetVisitor A visitor for the AssistedInject extension.
AssistedMethod Details about how a method in an assisted inject factory will be assisted.
FactoryModuleBuilder Provides a factory that combines the caller's arguments with injector-supplied values to construct objects.
 

Changed Classes
AssistedInject

When used in tandem with FactoryModuleBuilder, constructors annotated with {@code @AssistedInject} indicate that multiple constructors can be injected, each with different parameters.

FactoryProvider Obsolete. Prefer FactoryModuleBuilder for its more concise API and additional capability.
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/packages_index_removals.html0000755000175000017500000000324011704661106027223 0ustar tonytony Package Removals Index
All Packages
Removals
Additions
Changes
Bold is New, strike is deleted


sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/packages_index_changes.html0000755000175000017500000000527111704661106027011 0ustar tonytony Package Changes Index
All Packages
Removals
Additions
Changes
Bold is New, strike is deleted


com.google.inject
com.google.inject.assistedinject
com.google.inject.binder
com.google.inject.multibindings
com.google.inject.servlet
com.google.inject.spi
com.google.inject.struts2
com.google.inject.throwingproviders
com.google.inject.util
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/packages_index_all.html0000755000175000017500000000671411704661106026154 0ustar tonytony Package Differences Index
All Packages
Removals
Additions
Changes
Bold is New, strike is deleted


com.google.inject
com.google.inject.assistedinject
com.google.inject.binder
com.google.inject.grapher
com.google.inject.grapher.graphviz
com.google.inject.multibindings
com.google.inject.persist
com.google.inject.persist.finder
com.google.inject.persist.jpa
com.google.inject.servlet
com.google.inject.spi
com.google.inject.struts2
com.google.inject.throwingproviders
com.google.inject.util
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/packages_index_additions.html0000755000175000017500000000452611704661106027361 0ustar tonytony Package Additions Index
All Packages
Removals
Additions
Changes
Bold is New, strike is deleted


com.google.inject.grapher
com.google.inject.grapher.graphviz
com.google.inject.persist
com.google.inject.persist.finder
com.google.inject.persist.jpa
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/methods_index_removals.html0000755000175000017500000000671011704661106027115 0ustar tonytony Method Removals Index
All Methods
Removals
Additions
Changes
Bold is New, strike is deleted


T  V TOP
toProvider
  type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
  type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder

V  T TOP
visit
  type  (InjectionRequest) in com.google.inject.spi.DefaultElementVisitor
  type  (InjectionRequest) in com.google.inject.spi.ElementVisitor
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/methods_index_changes.html0000755000175000017500000001526311704661106026700 0ustar tonytony Method Changes Index
All Methods
Removals
Additions
Changes
Bold is New, strike is deleted


C  F G O T TOP
configureServlets ()
createChildInjector (Iterable<Module>)
createInjector
  type  (Module[]) in com.google.inject.Guice
  type  (Stage, Module[]) in com.google.inject.Guice
  type  (Stage, Iterable<Module>) in com.google.inject.Guice
  type  (Iterable<Module>) in com.google.inject.Guice

F  C G O T TOP
forStaticMethodsAndFields (TypeLiteral<?>)

G  C F O T TOP
getBindings ()
getInterceptors ()
getProvider (Key<T>)
getProviderKey ()

O  C F G T TOP
override
  type  (Module[]) in com.google.inject.util.Modules
  type  (Iterable<Module>) in com.google.inject.util.Modules

T  C F G O TOP
to (CheckedProvider)
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/methods_index_all.html0000755000175000017500000006600011704661106026033 0ustar tonytony Method Differences Index
All Methods
Removals
Additions
Changes
Bold is New, strike is deleted


C  D F G H I O P R S T V W TOP
configureServlets ()
continueRequest (Callable<T>, Map<Key<?>, Object>)
createChildInjector (Iterable<Module>)
createInjector
  type  (Module[]) in com.google.inject.Guice
  type  (Stage, Module[]) in com.google.inject.Guice
  type  (Stage, Iterable<Module>) in com.google.inject.Guice
  type  (Iterable<Module>) in com.google.inject.Guice

D  C F G H I O P R S T V W TOP
disableCircularProxies ()

F  C D G H I O P R S T V W TOP
forConstructor
  type  (Constructor<T>) in com.google.inject.spi.InjectionPoint
  type  (Constructor<T>, TypeLiteral<? extends T>) in com.google.inject.spi.InjectionPoint
forModule (Module)
forStaticMethodsAndFields (TypeLiteral<?>)

G  C D F H I O P R S T V W TOP
getAllBindings ()
getBindings ()
getDeclaringType ()
getExistingBinding (Key<T>)
getInterceptors ()
getProvider (Key<T>)
getProviderKey ()
getScopeBindings ()
getServletContext ()
getTypeConverterBinding ()
getTypeConverterBindings ()
guicify (Provider<T>)

H  C D F G I O P R S T V W TOP
hasAttributes ()

I  C D F G H O P R S T V W TOP
isSingleton (Binding<?>)
isToolable ()

O  C D F G H I P R S T V W TOP
ofType
  type  (Type) in com.google.inject.Key
  type  (TypeLiteral<T>) in com.google.inject.Key
  type  (Class<T>) in com.google.inject.Key
override
  type  (Module[]) in com.google.inject.util.Modules
  type  (Iterable<Module>) in com.google.inject.util.Modules

P  C D F G H I O R S T V W TOP
permitDuplicates
  type  () in com.google.inject.multibindings.MapBinder
  type  () in com.google.inject.multibindings.Multibinder

R  C D F G H I O P S T V W TOP
requireExplicitBindings ()

S  C D F G H I O P R T V W TOP
scopeRequest (Callable<T>, Map<Key<?>, Object>)

T  C D F G H I O P R S V W TOP
through
  type  (Filter) in com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder
  type  (Filter, Map<String, String>) in com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder
to
  type  (byte) in com.google.inject.binder.ConstantBindingBuilder
  type  (CheckedProvider) in com.google.inject.throwingproviders.ThrowingProviderBinder.SecondaryBinder
toConstructor
  type  (Constructor<S>) in com.google.inject.binder.LinkedBindingBuilder
  type  (Constructor<S>, TypeLiteral<? extends S>) in com.google.inject.binder.LinkedBindingBuilder
toProvider
  type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
  type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
  type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
  type  (TypeLiteral<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
  type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
toString ()

V  C D F G H I O P R S T W TOP
visit
  type  (InjectionRequest) in com.google.inject.spi.DefaultElementVisitor
  type  (DisableCircularProxiesOption) in com.google.inject.spi.DefaultElementVisitor
  type  (InjectionRequest<?>) in com.google.inject.spi.DefaultElementVisitor
  type  (RequireExplicitBindingsOption) in com.google.inject.spi.DefaultElementVisitor
  type  (InjectionRequest) in com.google.inject.spi.ElementVisitor
  type  (DisableCircularProxiesOption) in com.google.inject.spi.ElementVisitor
  type  (InjectionRequest<?>) in com.google.inject.spi.ElementVisitor
  type  (RequireExplicitBindingsOption) in com.google.inject.spi.ElementVisitor

W  C D F G H I O P R S T V TOP
with
  type  (HttpServlet) in com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder
  type  (HttpServlet, Map<String, String>) in com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder
withoutAttributes ()
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/methods_index_additions.html0000755000175000017500000005321111704661106027241 0ustar tonytony Method Additions Index
All Methods
Removals
Additions
Changes
Bold is New, strike is deleted


C  D F G H I O P R S T V W TOP
continueRequest (Callable<T>, Map<Key<?>, Object>)

D  C F G H I O P R S T V W TOP
disableCircularProxies ()

F  C D G H I O P R S T V W TOP
forConstructor
  type  (Constructor<T>) in com.google.inject.spi.InjectionPoint
  type  (Constructor<T>, TypeLiteral<? extends T>) in com.google.inject.spi.InjectionPoint
forModule (Module)

G  C D F H I O P R S T V W TOP
getAllBindings ()
getDeclaringType ()
getExistingBinding (Key<T>)
getScopeBindings ()
getServletContext ()
getTypeConverterBinding ()
getTypeConverterBindings ()
guicify (Provider<T>)

H  C D F G I O P R S T V W TOP
hasAttributes ()

I  C D F G H O P R S T V W TOP
isSingleton (Binding<?>)
isToolable ()

O  C D F G H I P R S T V W TOP
ofType
  type  (Type) in com.google.inject.Key
  type  (TypeLiteral<T>) in com.google.inject.Key
  type  (Class<T>) in com.google.inject.Key

P  C D F G H I O R S T V W TOP
permitDuplicates
  type  () in com.google.inject.multibindings.MapBinder
  type  () in com.google.inject.multibindings.Multibinder

R  C D F G H I O P S T V W TOP
requireExplicitBindings ()

S  C D F G H I O P R T V W TOP
scopeRequest (Callable<T>, Map<Key<?>, Object>)

T  C D F G H I O P R S V W TOP
through
  type  (Filter) in com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder
  type  (Filter, Map<String, String>) in com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder
to (byte)
toConstructor
  type  (Constructor<S>) in com.google.inject.binder.LinkedBindingBuilder
  type  (Constructor<S>, TypeLiteral<? extends S>) in com.google.inject.binder.LinkedBindingBuilder
toProvider
  type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
  type  (TypeLiteral<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
  type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
toString ()

V  C D F G H I O P R S T W TOP
visit
  type  (DisableCircularProxiesOption) in com.google.inject.spi.DefaultElementVisitor
  type  (InjectionRequest<?>) in com.google.inject.spi.DefaultElementVisitor
  type  (RequireExplicitBindingsOption) in com.google.inject.spi.DefaultElementVisitor
  type  (DisableCircularProxiesOption) in com.google.inject.spi.ElementVisitor
  type  (InjectionRequest<?>) in com.google.inject.spi.ElementVisitor
  type  (RequireExplicitBindingsOption) in com.google.inject.spi.ElementVisitor

W  C D F G H I O P R S T V TOP
with
  type  (HttpServlet) in com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder
  type  (HttpServlet, Map<String, String>) in com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder
withoutAttributes ()
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/jdiff_topleftframe.html0000755000175000017500000000375011704661106026206 0ustar tonytony JDiff
JDiff Indexes
All Differences
By Package
By Class
By Constructor
By Method
By Field
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/jdiff_statistics.html0000755000175000017500000004255511704661106025716 0ustar tonytony JDiff Statistics
Generated by
JDiff

JDiff Statistics

The percent change statistic reported for all elements in each API is defined recursively as follows:
Percentage difference = 100 * (added + removed + 2*changed)
                        -----------------------------------
                        sum of public elements in BOTH APIs
Where added is the number of packages added, removed is the number of packages removed, and changed is the number of packages changed. This definition is applied recursively for the classes and their program elements, so the value for a changed package will be less than 1, unless every class in that package has changed. The definition ensures that if all packages are removed and all new packages are added, the change will be 100%. Values are rounded here, so a value of 0% indicates a percentage difference of less than 0.5%.

The overall difference between the two APIs is approximately 32%.

Sections

Packages sorted by percentage difference
Classes and Interfaces sorted by percentage difference
Differences by number and type

Packages Sorted By Percentage Difference

Percentage
Difference
Package
62 com.google.inject.assistedinject
55 com.google.inject.struts2
46 com.google.inject.multibindings
46 com.google.inject.throwingproviders
34 com.google.inject.servlet
18 com.google.inject.util
12 com.google.inject
9 com.google.inject.spi
7 com.google.inject.binder

Percentage
Difference
Frequency Percentage Frequency
7 0.1111111111111111 |
9 0.1111111111111111 |
12 0.1111111111111111 |
18 0.1111111111111111 |
34 0.1111111111111111 |
46 0.2222222222222222 |
55 0.1111111111111111 |
62 0.1111111111111111 |


Classes and Interfaces Sorted By Percentage Difference

Percentage
Difference
Class or Interface
100 com.google.inject.Guice
50 com.google.inject.Provider
50 com.google.inject.spi.ProviderKeyBinding
50 com.google.inject.throwingproviders.ThrowingProvider
41 com.google.inject.binder.LinkedBindingBuilder
40 com.google.inject.util.Modules
33 com.google.inject.servlet.ServletScopes
33 com.google.inject.util.Providers
21 com.google.inject.Injector
21 com.google.inject.spi.InjectionPoint
20 com.google.inject.ProvisionException
20 com.google.inject.Scopes
20 com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder
20 com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder
20 com.google.inject.throwingproviders.ThrowingProviderBinder
16 com.google.inject.spi.ElementVisitor
16 com.google.inject.spi.TypeConverterBinding
16 com.google.inject.throwingproviders.ThrowingProviderBinder.SecondaryBinder
14 com.google.inject.spi.ConvertedConstantBinding
14 com.google.inject.spi.DefaultElementVisitor
13 com.google.inject.servlet.ServletModule
12 com.google.inject.assistedinject.FactoryProvider
12 com.google.inject.Key
10 com.google.inject.struts2.GuiceObjectFactory
8 com.google.inject.Binder
8 com.google.inject.spi.InterceptorBinding
6 com.google.inject.multibindings.MapBinder
6 com.google.inject.multibindings.Multibinder
4 com.google.inject.binder.ConstantBindingBuilder
3 com.google.inject.TypeLiteral
<1 com.google.inject.ScopeAnnotation
<1 com.google.inject.assistedinject.AssistedInject

Percentage
Difference
Frequency Percentage Frequency
0 0.0625 |
3 0.03125 |
4 0.03125 |
6 0.0625 |
8 0.0625 |
10 0.03125 |
12 0.0625 |
13 0.03125 |
14 0.0625 |
16 0.09375 |
20 0.15625 |
21 0.0625 |
33 0.0625 |
40 0.03125 |
41 0.03125 |
50 0.09375 |
100 0.03125 |


Differences By Number and Type

The numbers of program elements (packages, classes. constructors, methods and fields) which are recorded as removed, added or changed includes only the highest-level program elements. That is, if a class with two methods was added, the number of methods added does not include those two methods, but the number of classes added does include that class.
Number of Differences
  Removals Additions Changes Total
Packages 0 5 9 14
Classes and Interfaces 0 22 32 54
Constructors 0 1 1 2
Methods 4 41 14 59
Fields 0 0 0 0
Total 4 69 56 129
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/jdiff_help.html0000755000175000017500000001427111704661106024446 0ustar tonytony JDiff Help
Generated by
JDiff

JDiff Documentation

JDiff is a Javadoc doclet which generates a report of the API differences between two versions of a product. It does not report changes in Javadoc comments, or changes in what a class or method does. This help page describes the different parts of the output from JDiff.
See the reference page in the source for JDiff for information about how to generate a report like this one.
The indexes shown in the top-left frame help show each type of change in more detail. The index "All Differences" contains all the differences between the APIs, in alphabetical order. These indexes all use the same format:
  • Removed packages, classes, constructors, methods and fields are struck through.
  • Added packages, classes, constructors, methods and fields appear in bold.
  • Changed packages, classes, constructors, methods and fields appear in normal text.
You can always tell when you are reading a JDiff page, rather than a Javadoc page, by the color of the index bar and the color of the background. Links which take you to a Javadoc page are always in a typewriter font. Just like Javadoc, all interface names are in italic, and class names are not italicized. Where there are multiple entries in an index with the same name, the heading for them is also in italics, but is not a link.

Javadoc

This is a link to the top-level Javadoc page for the new version of the product.

Overview

The overview is the top-level summary of what was removed, added and changed between versions.

Package

This is a link to the package containing the current changed class or interface.

Class

This is highlighted when you are looking at the changed class or interface.

Text Changes

This is a link to the top-level index of all documentation changes for the current package or class. If it is not present, then there are no documentation changes for the current package or class. This link can be removed entirely by not using the -docchanges option.

Statistics

This is a link to a page which shows statistics about the changes between the two APIs. This link can be removed entirely by not using the -stats option.

Help

A link to this Help page for JDiff.

Prev/Next

These links take you to the previous and next changed package or class.

Frames/No Frames

These links show and hide the HTML frames. All pages are available with or without frames.

Complex Changes

There are some complex changes which can occur between versions, for example, when two or more methods with the same name change simultaneously, or when a method or field is moved into or from a superclass. In these cases, the change will be seen as a removal and an addition, rather than as a change. Unexpected removals or additions are often part of one of these type of changes.
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/fields_index_removals.html0000755000175000017500000000312211704661106026712 0ustar tonytony Field Removals Index
All Fields
Removals
Additions
Changes
Bold is New, strike is deleted

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/fields_index_changes.html0000755000175000017500000000312111704661106026471 0ustar tonytony Field Changes Index
All Fields
Removals
Additions
Changes
Bold is New, strike is deleted

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/fields_index_all.html0000755000175000017500000000312511704661106025635 0ustar tonytony Field Differences Index
All Fields
Removals
Additions
Changes
Bold is New, strike is deleted

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/fields_index_additions.html0000755000175000017500000000312311704661106027041 0ustar tonytony Field Additions Index
All Fields
Removals
Additions
Changes
Bold is New, strike is deleted

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/docdiffs_index.html0000755000175000017500000001765511704661106025335 0ustar tonytony All Documentation Differences
Generated by
JDiff

All Documentation Differences

Package com.google.inject
  Class Binder
    Method getProvider(Key<T>)

  Class Guice
    Method createInjector(Iterable<Module>)
    Method createInjector(Module[])
    Method createInjector(Stage, Iterable<Module>)
    Method createInjector(Stage, Module[])

  Class Injector
    Method createChildInjector(Iterable<Module>)
    Method getBindings()

  Class ProvisionException
    ProvisionException(Iterable<Message>)

  Class ScopeAnnotation

  Class TypeLiteral

Package com.google.inject.assistedinject
  Class AssistedInject

  Class FactoryProvider

Package com.google.inject.multibindings
  Class MapBinder

  Class Multibinder

Package com.google.inject.servlet
  Class ServletModule
    Method configureServlets()

Package com.google.inject.spi
  Class InjectionPoint

  Class TypeConverterBinding

Package com.google.inject.throwingproviders
  Class ThrowingProvider

  Class ThrowingProviderBinder

Package com.google.inject.util
  Class Modules
    Method override(Iterable<Module>)
    Method override(Module[])
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/docdiffs_com.google.inject.util.html0000755000175000017500000001547611704661106030505 0ustar tonytony com.google.inject.util Documentation Differences
Generated by
JDiff

com.google.inject.util Documentation Differences

This file contains all the changes in documentation in the package com.google.inject.util as colored differences. Deletions are shown like this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

Class Modules, OverriddenModuleBuilder override(Iterable<Module>)

Returns a builder that creates a module that overlays override modules over the given modules. If a key is bound in both sets of modules, only the binding from the override modules is kept. If a single PrivateModule is supplied or all elements are from a single PrivateBinder, then this will overwrite the private bindings. Otherwise, private bindings will not be overwritten unless they are exposed. This can be used to replace the bindings of a production module with test bindings:
 Module functionalTestModule
     = Modules.override(getProductionModules()).with(getTestModules());
 

Prefer to write smaller modules that can be reused and tested without overrides. @param modules the modules whose bindings are open to be overridden

Class Modules, OverriddenModuleBuilder override(Module[])

Returns a builder that creates a module that overlays override modules over the given modules. If a key is bound in both sets of modules, only the binding from the override modules is kept. If a single PrivateModule is supplied or all elements are from a single PrivateBinder, then this will overwrite the private bindings. Otherwise, private bindings will not be overwritten unless they are exposed. This can be used to replace the bindings of a production module with test bindings:
 Module functionalTestModule
     = Modules.override(new ProductionModule()).with(new TestModule());
 

Prefer to write smaller modules that can be reused and tested without overrides. @param modules the modules whose bindings are open to be overridden

././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/docdiffs_com.google.inject.throwingproviders.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/docdiffs_com.google.inject.throwingprovider0000755000175000017500000001652111704661106032171 0ustar tonytony com.google.inject.throwingproviders Documentation Differences
Generated by
JDiff

com.google.inject.throwingproviders Documentation Differences

This file contains all the changes in documentation in the package com.google.inject.throwingproviders as colored differences. Deletions are shown like this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

Class ThrowingProvider

Alternative to the Guice com.google.inject.Provider that throws a checked Exception. Users may not inject {@code T} directly.

This interface must be extended to use application-specific exception types. Such subinterfaces may not define new methods:

 public interface RemoteProvider<T> extends ThrowingProvider<T, RemoteException> { }
 

When this type is bound using ThrowingProviderBinder, the value returned or exception thrown by .get will be scoped. As a consequence, .get will invoked at most once within each scope. @author jmourits@google.com (Jerome Mourits) @author jessewilson@google.com (Jesse Wilson) @deprecated use CheckedProvider instead.


Class ThrowingProviderBinder

Builds a binding for a ThrowingProviderCheckedProvider.

You can usinguse a fluent API and custom providers:

ThrowingProviderBinder.create(binder())
    .bind(RemoteProvider.class, Customer.class)
    .to(RemoteCustomerProvider.class)
    .in(RequestScope.class);
 
or, you can use throwing provider methods:
class MyModule extends AbstractModule {
   configure() {
     ThrowingProviderBinder.install(this, binder());
   }
   
   {@literal @}CheckedProvides(RemoteProvider.class)
   {@literal @}RequestScope
   Customer provideCustomer(FlakyCustomerCreator creator) throws RemoteException {
     return creator.getCustomerOrThrow();
   }
 }
 
@author jmourits@google.com (Jerome Mourits) @author jessewilson@google.com (Jesse Wilson)

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/docdiffs_com.google.inject.spi.html0000755000175000017500000001274411704661106030316 0ustar tonytony com.google.inject.spi Documentation Differences
Generated by
JDiff

com.google.inject.spi Documentation Differences

This file contains all the changes in documentation in the package com.google.inject.spi as colored differences. Deletions are shown like this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

Class InjectionPoint

A constructor, field or method that can receive injections. Typically this is a member with the {@literal @}Inject annotation. For non-private, no argument constructors, the member may omit the annotation. @author crazybob@google.com (Bob Lee) @since 2.0

Class TypeConverterBinding

Registration of type converters for matching target types. Instances are created explicitly in a module using convertToTypes() statements:
     convertToTypes(Matchers.only(TypeLiteral.get(DateTime.class)), new DateTimeConverter());
@author jessewilson@google.com (Jesse Wilson) @since 2.0

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/docdiffs_com.google.inject.servlet.html0000755000175000017500000002377711704661106031217 0ustar tonytony com.google.inject.servlet Documentation Differences
Generated by
JDiff

com.google.inject.servlet Documentation Differences

This file contains all the changes in documentation in the package com.google.inject.servlet as colored differences. Deletions are shown like this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

Class ServletModule, void configureServlets()

Servlet Mapping EDSL

Part of the EDSL builder language for configuring servlets and filters with guice-servlet. Think of this as an in-code replacement for web.xml. Filters and servlets are configured here using simple java method calls. Here is a typical example of registering a filter when creating your Guice injector:

   Guice.createInjector(..., new ServletModule() {

     {@literal @}Override
     protected void configureServlets() {
       serve("*.html").with(MyServlet.class)
     }
   }
 
This registers a servlet (subclass of {@code HttpServlet}) called {@code MyServlet} to service any web pages ending in {@code .html}. You can also use a path-style syntax to register servlets:
       serve("/my/*").with(MyServlet.class)
 
Every servlet (or filter) is required to be a singleton. If you cannot annotate the class directly, you should add a separate {@code bind(..).in(Singleton.class)} rule elsewhere in your module. Mapping a servlet that is bound under any other scope is an error.

Dispatch Order

You are free to register as many servlets and filters as you like this way. They will be compared and dispatched in the order in which the filter methods are called:

   Guice.createInjector(..., new ServletModule() {

     {@literal @}Override
     protected void configureServlets() {
       filter("/*").through(MyFilter.class);
       filter("*.css").through(MyCssFilter.class);
       filter("*.jpg").through(new MyJpgFilter());
       // etc..

       serve("*.html").with(MyServlet.class);
       serve("/my/*").with(MyServlet.class);
       serve("*.jpg").with(new MyServlet());
       // etc..
      }
    }
 
This will traverse down the list of rules in lexical order. For example, a url "{@code /my/file.js}" (after it runs through the matching filters) will first be compared against the servlet mapping:
       serve("*.html").with(MyServlet.class);
 
And failing that, it will descend to the next servlet mapping:
       serve("/my/*").with(MyServlet.class);
 
Since this rule matches, Guice Servlet will dispatch to {@code MyServlet}. These two mapping rules can also be written in more compact form using varargs syntax:
       serve("*.html", "/my/*").with(MyServlet.class);
 
This way you can map several URI patterns to the same servlet. A similar syntax is also available for filter mappings.

Regular Expressions

You can also map servlets (or filters) to URIs using regular expressions:
    serveRegex("(.)*ajax(.)*").with(MyAjaxServlet.class)
 
This will map any URI containing the text "ajax" in it to {@code MyAjaxServlet}. Such as:
  • http://www.google.com/ajax.html
  • http://www.google.com/content/ajax/index
  • http://www.google.com/it/is_totally_ajaxian

Initialization Parameters

Servlets (and filters) allow you to pass in init params using the {@code } tag in web.xml. You can similarly pass in parameters to Servlets and filters registered in Guice-servlet using a java.util.Map of parameter name/value pairs. For example, to initialize {@code MyServlet} with two parameters ({@code name="Dhanji", site="google.com"}) you could write:
  Map<String, String> params = new HashMap<String, String>();
  params.put("name", "Dhanji");
  params.put("site", "google.com");

  ...
      serve("/*").with(MyServlet.class, params)
 

Binding Keys

You can also bind keys rather than classes. This lets you hide implementations with package-local visbility and expose them using only a Guice module and an annotation:
  ...
      filter("/*").through(Key.get(Filter.class, Fave.class));
 
Where {@code Filter.class} refers to the Servlet API interface and {@code Fave.class} is a custom binding annotation. Elsewhere (in one of your own modules) you can bind this filter's implementation:
   bind(Filter.class).annotatedWith(Fave.class).to(MyFilterImpl.class);
 
See com.google.inject.Binder for more information on binding syntax.

Multiple Modules

It is sometimes useful to capture servlet and filter mappings from multiple different modules. This is essential if you want to package and offer drop-in Guice plugins that provide servlet functionality.

Guice Servlet allows you to register several instances of {@code ServletModule} to your injector. The order in which these modules are installed determines the dispatch order of filters and the precedence order of servlets. For example, if you had two servlet modules, {@code RpcModule} and {@code WebServiceModule} and they each contained a filter that mapped to the same URI pattern, {@code "/*"}:

In {@code RpcModule}:

     filter("/*").through(RpcFilter.class);
 
In {@code WebServiceModule}:
     filter("/*").through(WebServiceFilter.class);
 
Then the order in which these filters are dispatched is determined by the order in which the modules are installed:
   install(new WebServiceModule());
   install(new RpcModule());
 
In the case shown above {@code WebServiceFilter} will run first. @since 2.0

././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/docdiffs_com.google.inject.multibindings.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/docdiffs_com.google.inject.multibindings.ht0000755000175000017500000002610711704661106032040 0ustar tonytony com.google.inject.multibindings Documentation Differences
Generated by
JDiff

com.google.inject.multibindings Documentation Differences

This file contains all the changes in documentation in the package com.google.inject.multibindings as colored differences. Deletions are shown like this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

Class MapBinder

An API to bind multiple map entries separately, only to later inject them as a complete map. MapBinder is intended for use in your application's module:

 public class SnacksModule extends AbstractModule {
   protected void configure() {
     MapBinder<String, Snack> mapbinder
         = MapBinder.newMapBinder(binder(), String.class, Snack.class);
     mapbinder.addBinding("twix").toInstance(new Twix());
     mapbinder.addBinding("snickers").toProvider(SnickersProvider.class);
     mapbinder.addBinding("skittles").to(Skittles.class);
   }
 }

With this binding, a Map{@code } can now be be injected:


 class SnackMachine {
   {@literal @}Inject
   public SnackMachine(Map<String, Snack> snacks) { ... }
 }

In addition to binding {@code Map}, a mapbinder will also bind {@code Map>} for lazy value provision:


 class SnackMachine {
   {@literal @}Inject
   public SnackMachine(Map<String, Provider<Snack>> snackProviders) { ... }
 }

CreatingContributing mapbindings from different modules is supported. For example, it it is okay to have both {@code CandyModule} and {@code ChipsModule} both create their own {@code MapBinder}, and to each contributecontribute bindings to the snacks map. When that map is injected, it will contain contain entries from both modules.

The map's iteration order is consistent with the binding order. This is convenient when multiple elements are contributed by the same module because that module can order its bindings appropriately. Avoid relying on the iteration order of elements contributed by different modules, since there is no equivalent mechanism to order modules.

The map is unmodifiable. Elements can only be added to the map by configuring the MapBinder. Elements can never be removed from the map.

Values are resolved at map injection time. If a value is bound to a provider, that provider's get method will be called each time the map is injected (unless the binding is also scoped, or a map of providers is injected).

Annotations are used to create different maps of the same key/value type. Each distinct annotation gets its own independent map.

Keys must be distinct. If the same key is bound more than once, map injection will fail. However, use .permitDuplicates() in order to allow duplicate keys; extra bindings to {@code Map>} and {@code Map>} will be added.

Keys must be non-null. {@code addBinding(null)} will will throw an unchecked exception.

Values must be non-null to use map injection. If any value is null, map injection will fail (although injecting a map of providers will not). @author dpb@google.com (David P. Baker)


Class Multibinder

An API to bind multiple values separately, only to later inject them as a complete collection. Multibinder is intended for use in your application's module:

 public class SnacksModule extends AbstractModule {
   protected void configure() {
     Multibinder<Snack> multibinder
         = Multibinder.newSetBinder(binder(), Snack.class);
     multibinder.addBinding().toInstance(new Twix());
     multibinder.addBinding().toProvider(SnickersProvider.class);
     multibinder.addBinding().to(Skittles.class);
   }
 }

With this binding, a Set{@code } can now be injected:


 class SnackMachine {
   {@literal @}Inject
   public SnackMachine(Set<Snack> snacks) { ... }
 }

CreateContributing multibindings from different modules is supported. ForFor example, it it is okay to have both {@code CandyModule} and {@code ChipsModule} to both both create their own {@code Multibinder}, and to each contributecontribute bindings bindings to the set of snacks. When that set is injected, it will containcontain elements elements from both modules.

The set's iteration order is consistent with the binding order. This is convenient when multiple elements are contributed by the same module because that module can order its bindings appropriately. Avoid relying on the iteration order of elements contributed by different modules, since there is no equivalent mechanism to order modules.

The set is unmodifiable. Elements can only be added to the set by configuring the multibinder. Elements can never be removed from the set.

Elements are resolved at set injection time. If an element is bound to a provider, that provider's get method will be called each time the set is injected (unless the binding is also scoped).

Annotations are be used to create different sets of the same element type. Each distinct annotation gets its own independent collection of elements.

Elements must be distinct. If multiple bound elements have the same value, set injection will fail.

Elements must be non-null. If any set element is null, set injection will fail. @author jessewilson@google.com (Jesse Wilson)


sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/docdiffs_com.google.inject.html0000755000175000017500000005746311704661106027533 0ustar tonytony com.google.inject Documentation Differences
Generated by
JDiff

com.google.inject Documentation Differences

This file contains all the changes in documentation in the package com.google.inject as colored differences. Deletions are shown like this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

Class Binder

Collects configuration information (primarily bindings) which will be used to create an Injector. Guice provides this object to your application's Module implementors so they may each contribute their own bindings and other registrations.

The Guice Binding EDSL

Guice uses an embedded domain-specific language, or EDSL, to help you create bindings simply and readably. This approach is great for overall usability, but it does come with a small cost: it is difficult to learn how to use the Binding EDSL by reading method-level javadocs. Instead, you should consult the series of examples below. To save space, these examples omit the opening {@code binder}, just as you will if your module extends AbstractModule.
     bind(ServiceImpl.class);
This statement does essentially nothing; it "binds the {@code ServiceImpl} class to itself" and does not change Guice's default behavior. You may still want to use this if you prefer your Module class to serve as an explicit manifest for the services it provides. Also, in rare cases, Guice may be unable to validate a binding at injector creation time unless it is given explicitly.
     bind(Service.class).to(ServiceImpl.class);
Specifies that a request for a {@code Service} instance with no binding annotations should be treated as if it were a request for a {@code ServiceImpl} instance. This overrides the function of any @ImplementedBy or @ProvidedBy annotations found on {@code Service}, since Guice will have already "moved on" to {@code ServiceImpl} before it reaches the point when it starts looking for these annotations.
     bind(Service.class).toProvider(ServiceProvider.class);
In this example, {@code ServiceProvider} must extend or implement {@code Provider}. This binding specifies that Guice should resolve an unannotated injection request for {@code Service} by first resolving an instance of {@code ServiceProvider} in the regular way, then calling get() on the resulting Provider instance to obtain the {@code Service} instance.

The Provider you use here does not have to be a "factory"; that is, a provider which always creates each instance it provides. However, this is generally a good practice to follow. You can then use Guice's concept of scopes to guide when creation should happen -- "letting Guice work for you".

     bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);
Like the previous example, but only applies to injection requests that use the binding annotation {@code @Red}. If your module also includes bindings for particular values of the {@code @Red} annotation (see below), then this binding will serve as a "catch-all" for any values of {@code @Red} that have no exact match in the bindings.
     bind(ServiceImpl.class).in(Singleton.class);
     // or, alternatively
     bind(ServiceImpl.class).in(Scopes.SINGLETON);
Either of these statements places the {@code ServiceImpl} class into singleton scope. Guice will create only one instance of {@code ServiceImpl} and will reuse it for all injection requests of this type. Note that it is still possible to bind another instance of {@code ServiceImpl} if the second binding is qualified by an annotation as in the previous example. Guice is not overly concerned with preventing you from creating multiple instances of your "singletons", only with enabling your application to share only one instance if that's all you tell Guice you need.

Note: a scope specified in this way overrides any scope that was specified with an annotation on the {@code ServiceImpl} class.

Besides Singleton/Scopes.SINGLETON, there are servlet-specific scopes available in {@code com.google.inject.servlet.ServletScopes}, and your Modules can contribute their own custom scopes for use here as well.

     bind(new TypeLiteral<PaymentService<CreditCard>>() {})
         .to(CreditCardPaymentService.class);
This admittedly odd construct is the way to bind a parameterized type. It tells Guice how to honor an injection request for an element of type {@code PaymentService}. The class {@code CreditCardPaymentService} must implement the {@code PaymentService} interface. Guice cannot currently bind or inject a generic type, such as {@code Set}; all type parameters must be fully specified.
     bind(Service.class).toInstance(new ServiceImpl());
     // or, alternatively
     bind(Service.class).toInstance(SomeLegacyRegistry.getService());
In this example, your module itself, not Guice, takes responsibility for obtaining a {@code ServiceImpl} instance, then asks Guice to always use this single instance to fulfill all {@code Service} injection requests. When the Injector is created, it will automatically perform field and method injection for this instance, but any injectable constructor on {@code ServiceImpl} is simply ignored. Note that using this approach results in "eager loading" behavior that you can't control.
     bindConstant().annotatedWith(ServerHost.class).to(args[0]);
Sets up a constant binding. Constant injections must always be annotated. When a constant binding's value is a string, it is eligile for conversion to all primitive types, to all enums, and to class literals. Conversions for other types can be configured using convertToTypes().
   {@literal @}Color("red") Color red; // A member variable (field)
    . . .
     red = MyModule.class.getDeclaredField("red").getAnnotation(Color.class);
     bind(Service.class).annotatedWith(red).to(RedService.class);
If your binding annotation has parameters you can apply different bindings to different specific values of your annotation. Getting your hands on the right instance of the annotation is a bit of a pain -- one approach, shown above, is to apply a prototype annotation to a field in your module class, so that you can read this annotation instance and give it to Guice.
     bind(Service.class)
         .annotatedWith(Names.named("blue"))
         .to(BlueService.class);
Differentiating by names is a common enough use case that we provided a standard annotation, @Named. Because of Guice's library support, binding by name is quite easier than in the arbitrary binding annotation case we just saw. However, remember that these names will live in a single flat namespace with all the other names used in your application.

     Constructor loneCtor = getLoneCtorFromServiceImplViaReflection();
     bind(ServiceImpl.class)
         .toConstructor(loneCtor);
In this example, we directly tell Guice which constructor to use in a concrete class implementation. It means that we do not need to place {@literal @}Inject on any of the constructors and that Guice treats the provided constructor as though it were annotated so. It is useful for cases where you cannot modify existing classes and is a bit simpler than using a Provider.

The above list of examples is far from exhaustive. If you can think of how the concepts of one example might coexist with the concepts from another, you can most likely weave the two together. If the two concepts make no sense with each other, you most likely won't be able to do it. In a few cases Guice will let something bogus slip by, and will then inform you of the problems at runtime, as soon as you try to create your Injector.

The other methods of Binder such as .bindScope, .bindInterceptor, .install, .requestStaticInjection, .addError and .currentStage are not part of the Binding EDSL; you can learn how to use these in the usual way, from the method documentation. @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson) @author kevinb@google.com (Kevin Bourrillion)

Class Binder, Provider<T> getProvider(Key<T>)

Returns the provider used to obtain instances for the given injection key. The returned provider will not be valid until the Injector has been created. The provider will throw an {@code IllegalStateException} if you try to use it beforehand. @since 2.0

Class Guice, Injector createInjector(Iterable<Module>)

Creates an injector for the given set of modules. @throws CreationException if one or more errors occur during Injector injector creation
Class Guice, Injector createInjector(Module[])

Creates an injector for the given set of modules. @throws CreationException if one or more errors occur during Injector injector construction
Class Guice, Injector createInjector(Stage, Iterable<Module>)

Creates an injector for the given set of modules, in a given development stage. @throws CreationException if one or more errors occur during Injector injector construction
Class Guice, Injector createInjector(Stage, Module[])

Creates an injector for the given set of modules, in a given development stage. @throws CreationException if one or more errors occur during Injector injector creation.

Class Injector, Injector createChildInjector(Iterable<Module>)

Returns a new injector that inherits all state from this injector. All bindings, scopes, interceptors and type converters are inherited -- they are visible to the child injector. Elements of the child injector are not visible to its parent.

Just-in-time bindings created for child injectors will be created in an ancestor injector whenever possible. This allows for scoped instances to be shared between injectors. Use explicit bindings to prevent bindings from being shared with the parent injector. Optional injections in just-in-time bindings (created in the parent injector) may be silently ignored if the optional dependencies are from the child injector.

No key may be bound by both an injector and one of its ancestors. This includes just-in-time bindings. The lone exception is the key for {@code Injector.class}, which is bound by each injector to itself. @since 2.0

Class Injector, Map<Key<?>, Binding<?>> getBindings()

Returns allthis injector's explicit bindings.

The returned map does not include bindings inherited from a parent injector, should one exist. The returned map is guaranteed to iterate (for example, with its java.util.Map.entrySet() iterator) in the order of insertion. In other words, the order inin which bindings appear in user Modules.

This method is part of the Guice SPI and is intended for use by tools and extensions.


Class ProvisionException, constructor ProvisionException(Iterable<Message>)

Creates a ConfigurationExceptionProvisionException containing {@code messages}.

Class ScopeAnnotation

Annotates annotations which are used for scoping. Only one such annotation may apply to a single implementation class. You must also annotate scope annotations with {@code @Retention(RUNTIME)}. For example:
   {@code @}Retention(RUNTIME)
   {@code @}Target(TYPE, METHOD)
   {@code @}ScopeAnnotation
   public {@code @}interface SessionScoped {}
 
@author crazybob@google.com (Bob Lee)

Class TypeLiteral

Represents a generic type {@code T}. Java doesn't yet provide a way to represent generic types, so this class does. Forces clients to create a subclass of this class which enables retrieval the type information even at runtime.

For example, to create a type literal for {@code List}, you can create an empty anonymous inner class:

{@code TypeLiteral> list = new TypeLiteral>() {};}

This syntax cannot be used to create type literals that have wildcard parameters, such as {@code Class} or {@code List extends CharSequence}. Such type literals must be constructed programatically, either by extracting types from members or by using the Types factory class. Along with modeling generic types, this class can resolve type parameters. For example, to figure out what type {@code keySet()} returns on a {@code Map}, use this code:

   {@code

   TypeLiteral> mapType
       = new TypeLiteral>() {};
   TypeLiteral<> keySetType
       = mapType.getReturnType(Map.class.getMethod("keySet"));
   System.out.println(keySetType); // prints "Set"}
@author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson)

././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/docdiffs_com.google.inject.assistedinject.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/docdiffs_com.google.inject.assistedinject.h0000755000175000017500000003726611704661106032030 0ustar tonytony com.google.inject.assistedinject Documentation Differences
Generated by
JDiff

com.google.inject.assistedinject Documentation Differences

This file contains all the changes in documentation in the package com.google.inject.assistedinject as colored differences. Deletions are shown like this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

Class AssistedInject

Constructors When used in tandem with FactoryModuleBuilder, constructors annotated with {@code @AssistedInject} indicate that theymultiple constructors can be instantiatedinjected, by theeach with different parameters. AssistedInject annotations should not be mixed with {@literal @}FactoryProviderInject annotations. Each constructorThe assisted parameters must exactly match one corresponding factory method withinmethod within the factory interface. , but Constructorthe parameters must be either supplied bydo not need to be in the factorysame interfaceorder. and marked with Constructors annotated with @Assisted,AssistedInject orare they must becreated by Guice injectableand receive all the benefits (such as AOP). @deprecated

Obsolete Usage: When used in tandem with FactoryProvider now, works betterconstructors annotated with the standard {@literalcode @InjectAssistedInject} trigger a "backwards compatibility annotationmode". When using thatThe assisted parameters annotation,must parametersexactly arematch one matched by namecorresponding factory method andwithin the factory interface type rather than and all must be in the same byorder positionas listed in the factory. In additionthis backwards compatable mode, valuesconstructors thatannotated with AssistedInject are not created useby Guice and thus receive none of the standardbenefits. {@literal @Inject}

Constructor constructor parameters must be either supplied annotation are eligible forby the factory interface methodand marked with @Assisted, or they must interceptionbe injectable. @author jmourits@google.com (Jerome Mourits) @author jessewilson@google.com (Jesse Wilson)


Class FactoryProvider

Obsolete. Prefer FactoryModuleBuilder for its more concise API and additional capability.

Provides a factory that combines the caller's arguments with injector-supplied values to construct objects.

Defining a factory

Create an interface whose methods return the constructed type, or any of its supertypes. The method's parameters are the arguments required to build the constructed type.
public interface PaymentFactory {
   Payment create(Date startDate, Money amount);
 }
You can name your factory methods whatever you like, such as create, createPayment or newPayment.

Creating a type that accepts factory parameters

{@code constructedType} is a concrete class with an {@literal @}Inject-annotated constructor. In addition to injector-supplied parameters, the constructor should have parameters that match each of the factory method's parameters. Each factory-supplied parameter requires an {@literal @}Assisted annotation. This serves to document that the parameter is not bound by your application's modules.
public class RealPayment implements Payment {
   {@literal @}Inject
   public RealPayment(
      CreditService creditService,
      AuthService authService,
      {@literal @}Assisted Date startDate,
      {@literal @}Assisted Money amount) {
     ...
   }
 }
Any parameter that permits a null value should also be annotated {@code @Nullable}.

Configuring factories

In your module, bind the factory interface to the returned factory:
bind(PaymentFactory.class).toProvider(
     FactoryProvider.newFactory(PaymentFactory.class, RealPayment.class));
As a side-effect of this binding, Guice will inject the factory to initialize it for use. The factory cannot be used until the injector has been initialized.

Using the factory

Inject your factory into your application classes. When you use the factory, your arguments will be combined with values from the injector to construct an instance.
public class PaymentAction {
   {@literal @}Inject private PaymentFactory paymentFactory;

   public void doPayment(Money amount) {
     Payment payment = paymentFactory.create(new Date(), amount);
     payment.apply();
   }
 }

Making parameter types distinct

The types of the factory method's parameters must be distinct. To use multiple parameters of the same type, use a named {@literal @}Assisted annotation to disambiguate the parameters. The names must be applied to the factory method's parameters:
public interface PaymentFactory {
   Payment create(
       {@literal @}Assisted("startDate") Date startDate,
       {@literal @}Assisted("dueDate") Date dueDate,
       Money amount);
 } 
...and to the concrete type's constructor parameters:
public class RealPayment implements Payment {
   {@literal @}Inject
   public RealPayment(
      CreditService creditService,
      AuthService authService,
      {@literal @}Assisted("startDate") Date startDate,
      {@literal @}Assisted("dueDate") Date dueDate,
      {@literal @}Assisted Money amount) {
     ...
   }
 }

Values are created by Guice

Returned factories use child injectors to create values. The values are eligible for method interception. In addition, {@literal @}{@literal Inject} members will be injected before they are returned.

Backwards compatibility using {@literal @}AssistedInject

Instead of the {@literal @}Inject annotation, you may annotate the constructed classes with {@literal @}AssistedInject. This triggers a limited backwards-compatability mode.

Instead of matching factory method arguments to constructor parameters using their names, the parameters are matched by their order. The first factory method argument is used for the first {@literal @}Assisted constructor parameter, etc.. Annotation names have no effect.

Returned values are not created by Guice. These types are not eligible for method interception. They do receive post-construction member injection. @param The factory interface @author jmourits@google.com (Jerome Mourits) @author jessewilson@google.com (Jesse Wilson) @author dtm@google.com (Daniel Martin) @deprecated use FactoryModuleBuilder instead.


sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/constructors_index_removals.html0000755000175000017500000000326211704661106030221 0ustar tonytony Constructor Removals Index
All Constructors
Removals
Additions
Changes
Bold is New, strike is deleted

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/constructors_index_changes.html0000755000175000017500000000401411704661106027775 0ustar tonytony Constructor Changes Index
All Constructors
Removals
Additions
Changes
Bold is New, strike is deleted


P  TOP
ProvisionException (Iterable<Message>) constructor
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/constructors_index_all.html0000755000175000017500000000527411704661106027146 0ustar tonytony Constructor Differences Index
All Constructors
Removals
Additions
Changes
Bold is New, strike is deleted


P  T TOP
ProvisionException (Iterable<Message>) constructor

T  P TOP
TypeConverterBinding (Object, Matcher<TypeLiteral<?>>, TypeConverter) constructor
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/constructors_index_additions.html0000755000175000017500000000422311704661106030345 0ustar tonytony Constructor Additions Index
All Constructors
Removals
Additions
Changes
Bold is New, strike is deleted


T  TOP
TypeConverterBinding (Object, Matcher<TypeLiteral<?>>, TypeConverter) constructor
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.util.Providers.html0000755000175000017500000001377211704661106030615 0ustar tonytony com.google.inject.util.Providers
Generated by
JDiff

Class com.google.inject.util.Providers

Added Methods
Provider<T> guicify(Provider<T>) Returns a Guice-friendly {@code com.google.inject.Provider} for the given JSR-330 {@code javax.inject.Provider}.
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.util.Modules.html0000755000175000017500000001770011704661106030243 0ustar tonytony com.google.inject.util.Modules
Generated by
JDiff

Class com.google.inject.util.Modules

Changed Methods
OverriddenModuleBuilder override(Module[]) Documentation changed from old to new.
Returns a builder that creates a module that overlays override modules over the given modules.
OverriddenModuleBuilder override(Iterable<Module>) Documentation changed from old to new.
Returns a builder that creates a module that overlays override modules over the given modules.
 



././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.throwingproviders.ThrowingProviderBinder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.throwingproviders.Throwin0000755000175000017500000001636011704661106032145 0ustar tonytony com.google.inject.throwingproviders.ThrowingProviderBinder
Generated by
JDiff

Class com.google.inject.throwingproviders.ThrowingProviderBinder

Documentation changed from old to new.

Added Methods
Module forModule(Module) Returns a module that installs {@literal @}CheckedProvides methods.
 



././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.throwingproviders.ThrowingProviderBinder.SecondaryBinder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.throwingproviders.Throwin0000755000175000017500000001503311704661106032141 0ustar tonytony com.google.inject.throwingproviders.ThrowingProviderBinder.SecondaryBinder
Generated by
JDiff

Class com.google.inject.throwingproviders.ThrowingProviderBinder.SecondaryBinder

Changed Methods
ScopedBindingBuilder to(CheckedProvider) Change in signature from ThrowingProvider to CheckedProvider.
 
 



././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.throwingproviders.ThrowingProvider.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.throwingproviders.Throwin0000755000175000017500000001414511704661106032144 0ustar tonytony com.google.inject.throwingproviders.ThrowingProvider
Generated by
JDiff

Interface com.google.inject.throwingproviders.ThrowingProvider

Added interface com.google.inject.throwingproviders.CheckedProvider.
Documentation changed from old to new.

Now deprecated.



././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.struts2.GuiceObjectFactory.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.struts2.GuiceObjectFactor0000755000175000017500000001267611704661106031672 0ustar tonytony com.google.inject.struts2.GuiceObjectFactory
Generated by
JDiff

Class com.google.inject.struts2.GuiceObjectFactory

Documentation changed from old to new.

Now deprecated.



././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.spi.TypeConverterBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.spi.TypeConverterBinding.0000755000175000017500000001714111704661106031667 0ustar tonytony com.google.inject.spi.TypeConverterBinding
Generated by
JDiff

Class com.google.inject.spi.TypeConverterBinding

Documentation changed from old to new.

Added Constructors
TypeConverterBinding(Object, Matcher<TypeLiteral<?>>, TypeConverter) @since 3.0
 

Added Methods
String toString()  
 



././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.spi.ProviderKeyBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.spi.ProviderKeyBinding.ht0000755000175000017500000001455511704661106031663 0ustar tonytony com.google.inject.spi.ProviderKeyBinding
Generated by
JDiff

Interface com.google.inject.spi.ProviderKeyBinding

Changed Methods
Key<Provider<? extends T>> getProviderKey() Change in return type from (com.google.inject.Key>) to (com.google.inject.Key>).
Returns the key used to resolve the provider's binding.
 



././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.spi.InterceptorBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.spi.InterceptorBinding.ht0000755000175000017500000001434611704661106031714 0ustar tonytony com.google.inject.spi.InterceptorBinding
Generated by
JDiff

Class com.google.inject.spi.InterceptorBinding

Changed Methods
List<MethodInterceptor> getInterceptors() Change in return type from java.util.List to java.util.List.
 
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.spi.InjectionPoint.html0000755000175000017500000002313511704661106031404 0ustar tonytony com.google.inject.spi.InjectionPoint
Generated by
JDiff

Class com.google.inject.spi.InjectionPoint

Documentation changed from old to new.

Added Methods
InjectionPoint forConstructor(Constructor<T>) Returns a new injection point for the specified constructor.
InjectionPoint forConstructor(Constructor<T>, TypeLiteral<?, extends, T>) Returns a new injection point for the specified constructor of {@code type}.
TypeLiteral<?> getDeclaringType() Returns the generic type that defines this injection point.
boolean isToolable() Returns true if the element is annotated with {@literal @}Toolable.
 

Changed Methods
Set<InjectionPoint> forStaticMethodsAndFields(TypeLiteral<?>) Change in signature from TypeLiteral to TypeLiteral<?>.
Returns all static method and field injection points on {@code type}.
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.spi.ElementVisitor.html0000755000175000017500000002014311704661106031415 0ustar tonytony com.google.inject.spi.ElementVisitor
Generated by
JDiff

Interface com.google.inject.spi.ElementVisitor

Removed Methods
V visit(InjectionRequest) Visit a request to inject the instance fields and methods of an instance.
 

Added Methods
V visit(DisableCircularProxiesOption) Visit a disable circular proxies command.
V visit(InjectionRequest<?>) Visit a request to inject the instance fields and methods of an instance.
V visit(RequireExplicitBindingsOption) Visit a require explicit bindings command.
 



././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.spi.DefaultElementVisitor.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.spi.DefaultElementVisitor0000755000175000017500000001771511704661106031772 0ustar tonytony com.google.inject.spi.DefaultElementVisitor
Generated by
JDiff

Class com.google.inject.spi.DefaultElementVisitor

Removed Methods
V visit(InjectionRequest)  
 

Added Methods
V visit(DisableCircularProxiesOption)  
V visit(InjectionRequest<?>)  
V visit(RequireExplicitBindingsOption)  
 



././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.spi.ConvertedConstantBinding.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.spi.ConvertedConstantBind0000755000175000017500000001411011704661106031736 0ustar tonytony com.google.inject.spi.ConvertedConstantBinding
Generated by
JDiff

Interface com.google.inject.spi.ConvertedConstantBinding

Added Methods
TypeConverterBinding getTypeConverterBinding() Returns the type converter binding used to convert the constant.
 



././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.servlet.ServletScopes.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.servlet.ServletScopes.htm0000755000175000017500000001612411704661106031766 0ustar tonytony com.google.inject.servlet.ServletScopes
Generated by
JDiff

Class com.google.inject.servlet.ServletScopes

Added Methods
Callable<T> continueRequest(Callable<T>, Map<Key<?>, Object>) Wraps the given callable in a contextual callable that "continues" the HTTP request in another thread.
Callable<T> scopeRequest(Callable<T>, Map<Key<?>, Object>) Scopes the given callable inside a request scope.
 



././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.servlet.ServletModule.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.servlet.ServletModule.htm0000755000175000017500000001716711704661106031767 0ustar tonytony com.google.inject.servlet.ServletModule
Generated by
JDiff

Class com.google.inject.servlet.ServletModule

Added Methods
ServletContext getServletContext() This method only works if you are using the GuiceServletContextListener to create your injector.
 

Changed Methods
void configureServlets() Documentation changed from old to new.

Servlet Mapping EDSL

 



././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.servlet.ServletModule.Ser0000755000175000017500000001571711704661106031727 0ustar tonytony com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder
Generated by
JDiff

Interface com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder

Added Methods
void with(HttpServlet) @since 3.0
void with(HttpServlet, Map<String, String>) @since 3.0
 



././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.servlet.ServletModule.Fil0000755000175000017500000001567211704661106031710 0ustar tonytony com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder
Generated by
JDiff

Interface com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder

Added Methods
void through(Filter) @since 3.0
void through(Filter, Map<String, String>) @since 3.0
 



././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.multibindings.Multibinder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.multibindings.Multibinder0000755000175000017500000001526311704661106032043 0ustar tonytony com.google.inject.multibindings.Multibinder
Generated by
JDiff

Class com.google.inject.multibindings.Multibinder

Documentation changed from old to new.

Added Methods
Multibinder<T> permitDuplicates() Configures the bound set to silently discard duplicate elements.
 



././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.multibindings.MapBinder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.multibindings.MapBinder.h0000755000175000017500000001523311704661106031651 0ustar tonytony com.google.inject.multibindings.MapBinder
Generated by
JDiff

Class com.google.inject.multibindings.MapBinder

Documentation changed from old to new.

Added Methods
(MapBinder<K, V>permitDuplicates() Configures the {@code MapBinder} to handle duplicate entries.
 



././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.binder.LinkedBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.binder.LinkedBindingBuild0000755000175000017500000002657711704661106031653 0ustar tonytony com.google.inject.binder.LinkedBindingBuilder
Generated by
JDiff

Interface com.google.inject.binder.LinkedBindingBuilder

Removed Methods
ScopedBindingBuilder toProvider(Key<Provider<? extends T>>) See the EDSL examples at com.google.inject.Binder.
ScopedBindingBuilder toProvider(Class<Provider<? extends T>>) See the EDSL examples at com.google.inject.Binder.
 

Added Methods
ScopedBindingBuilder toConstructor(Constructor<S>) See the EDSL examples at com.google.inject.Binder.
ScopedBindingBuilder toConstructor(Constructor<S>, TypeLiteral<?, extends, S>) See the EDSL examples at com.google.inject.Binder.
ScopedBindingBuilder toProvider(Key<Provider<? extends T>>) See the EDSL examples at com.google.inject.Binder.
ScopedBindingBuilder toProvider(TypeLiteral<Provider<? extends T>>) See the EDSL examples at com.google.inject.Binder.
ScopedBindingBuilder toProvider(Class<Provider<? extends T>>) See the EDSL examples at com.google.inject.Binder.
 



././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.binder.ConstantBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.binder.ConstantBindingBui0000755000175000017500000001400711704661106031677 0ustar tonytony com.google.inject.binder.ConstantBindingBuilder
Generated by
JDiff

Interface com.google.inject.binder.ConstantBindingBuilder

Added Methods
void to(byte) Binds constant to the given value.
 



././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.assistedinject.FactoryProvider.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.assistedinject.FactoryPro0000755000175000017500000001363611704661106032023 0ustar tonytony com.google.inject.assistedinject.FactoryProvider
Generated by
JDiff

Class com.google.inject.assistedinject.FactoryProvider

Documentation changed from old to new.

Now deprecated.



././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.assistedinject.AssistedInject.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.assistedinject.AssistedIn0000755000175000017500000001364511704661106032001 0ustar tonytony com.google.inject.assistedinject.AssistedInject
Generated by
JDiff

Class com.google.inject.assistedinject.AssistedInject

Documentation changed from old to new.

Change from deprecated to undeprecated.



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.TypeLiteral.html0000755000175000017500000001305111704661106030110 0ustar tonytony com.google.inject.TypeLiteral
Generated by
JDiff

Class com.google.inject.TypeLiteral

Documentation changed from old to new.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.Scopes.html0000755000175000017500000001372011704661106027111 0ustar tonytony com.google.inject.Scopes
Generated by
JDiff

Class com.google.inject.Scopes

Added Methods
boolean isSingleton(Binding<?>) Returns true if {@code binding} is singleton-scoped.
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.ScopeAnnotation.html0000755000175000017500000001327511704661106030766 0ustar tonytony com.google.inject.ScopeAnnotation
Generated by
JDiff

Class com.google.inject.ScopeAnnotation

Documentation changed from old to new.

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.ProvisionException.html0000755000175000017500000001563711704661106031535 0ustar tonytony com.google.inject.ProvisionException
Generated by
JDiff

Class com.google.inject.ProvisionException

Changed Constructors
ProvisionException(Iterable<Message>) Documentation changed from old to new.
Creates a ProvisionException containing {@code messages}.
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.Provider.html0000755000175000017500000001222111704661106027442 0ustar tonytony com.google.inject.Provider
Generated by
JDiff

Interface com.google.inject.Provider

Added interface javax.inject.Provider.



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.Key.html0000755000175000017500000001753111704661106026411 0ustar tonytony com.google.inject.Key
Generated by
JDiff

Class com.google.inject.Key

Added Methods
boolean hasAttributes() Returns true if this key has annotation attributes.
Key<?> ofType(Type) Returns a new key of the specified type with the same annotation as this key.
Key<T> ofType(TypeLiteral<T>) Returns a new key of the specified type with the same annotation as this key.
Key<T> ofType(Class<T>) Returns a new key of the specified type with the same annotation as this key.
Key<T> withoutAttributes() Returns this key without annotation attributes, i.e.
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.Injector.html0000755000175000017500000002422711704661106027436 0ustar tonytony com.google.inject.Injector
Generated by
JDiff

Interface com.google.inject.Injector

Added Methods
(Map<Key<?>, Binding<?>>getAllBindings() Returns a snapshot of this injector's bindings, both explicit and just-in-time.
Binding<T> getExistingBinding(Key<T>) Returns the binding if it already exists, or null if does not exist.
(Map<Class<Annotation>, Scope>getScopeBindings() Returns a map containing all scopes in the injector.
Set<TypeConverterBinding> getTypeConverterBindings() Returns a set containing all type converter bindings in the injector.
 

Changed Methods
Map<Key<?>, Binding<?>> getBindings() Documentation changed from old to new.
Returns this injector's explicit bindings.
Injector createChildInjector(Iterable<Module>) Documentation changed from old to new.
Returns a new injector that inherits all state from this injector.
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.Guice.html0000755000175000017500000002460111704661106026711 0ustar tonytony com.google.inject.Guice
Generated by
JDiff

Class com.google.inject.Guice

Changed Methods
Injector createInjector(Module[]) Documentation changed from old to new.
Creates an injector for the given set of modules.
Injector createInjector(Stage, Module[]) Documentation changed from old to new.
Creates an injector for the given set of modules, in a given development stage.
Injector createInjector(Stage, Iterable<Module>) Documentation changed from old to new.
Creates an injector for the given set of modules, in a given development stage.
Injector createInjector(Iterable<Module>) Documentation changed from old to new.
Creates an injector for the given set of modules.
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/com.google.inject.Binder.html0000755000175000017500000002050511704661106027057 0ustar tonytony com.google.inject.Binder
Generated by
JDiff

Interface com.google.inject.Binder

Documentation changed from old to new.

Added Methods
void disableCircularProxies() Prevents Guice from constructing a Proxy when a circular dependency is found.
void requireExplicitBindings() Instructs the Injector that bindings must be listed in a Module in order to be injected.
 

Changed Methods
Provider<T> getProvider(Key<T>) Documentation changed from old to new.
Returns the provider used to obtain instances for the given injection key.
 



sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/classes_index_removals.html0000755000175000017500000000322311704661106027103 0ustar tonytony Class Removals Index
All Classes
Removals
Additions
Changes
Bold is New, strike is deleted

sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/classes_index_changes.html0000755000175000017500000003553111704661106026672 0ustar tonytony Class Changes Index
All Classes
Removals
Additions
Changes
Bold is New, strike is deleted


A  B C D E F G I K L M P S T TOP
AssistedInject

B  A C D E F G I K L M P S T TOP
Binder

C  A B D E F G I K L M P S T TOP
ConstantBindingBuilder
ConvertedConstantBinding

D  A B C E F G I K L M P S T TOP
DefaultElementVisitor

E  A B C D F G I K L M P S T TOP
ElementVisitor

F  A B C D E G I K L M P S T TOP
FactoryProvider

G  A B C D E F I K L M P S T TOP
Guice
GuiceObjectFactory

I  A B C D E F G K L M P S T TOP
InjectionPoint
Injector
InterceptorBinding

K  A B C D E F G I L M P S T TOP
Key

L  A B C D E F G I K M P S T TOP
LinkedBindingBuilder

M  A B C D E F G I K L P S T TOP
MapBinder
Modules
Multibinder

P  A B C D E F G I K L M S T TOP
Provider
ProviderKeyBinding
Providers
ProvisionException

S  A B C D E F G I K L M P T TOP
ScopeAnnotation
Scopes
ServletModule
ServletModule.FilterKeyBindingBuilder
ServletModule.ServletKeyBindingBuilder
ServletScopes

T  A B C D E F G I K L M P S TOP
ThrowingProvider
ThrowingProviderBinder
ThrowingProviderBinder.SecondaryBinder
TypeConverterBinding
TypeLiteral
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/classes_index_all.html0000755000175000017500000005147711704661106026041 0ustar tonytony Class Differences Index
All Classes
Removals
Additions
Changes
Bold is New, strike is deleted


A  B C D E F G I K L M P R S T U TOP
AssistedInject
AssistedInjectBinding
AssistedInjectTargetVisitor
AssistedMethod

B  A C D E F G I K L M P R S T U TOP
Binder

C  A B D E F G I K L M P R S T U TOP
CheckedProvider
CheckedProvides
ConstantBindingBuilder
ConvertedConstantBinding

D  A B C E F G I K L M P R S T U TOP
DefaultElementVisitor
DisableCircularProxiesOption

E  A B C D F G I K L M P R S T U TOP
ElementVisitor

F  A B C D E G I K L M P R S T U TOP
FactoryModuleBuilder
FactoryProvider

G  A B C D E F I K L M P R S T U TOP
Guice
GuiceObjectFactory

I  A B C D E F G K L M P R S T U TOP
InjectionPoint
Injector
InstanceFilterBinding
InstanceServletBinding
InterceptorBinding

K  A B C D E F G I L M P R S T U TOP
Key

L  A B C D E F G I K M P R S T U TOP
LinkedBindingBuilder
LinkedFilterBinding
LinkedServletBinding

M  A B C D E F G I K L P R S T U TOP
MapBinder
MapBinderBinding
Modules
Multibinder
MultibinderBinding
MultibindingsTargetVisitor

P  A B C D E F G I K L M R S T U TOP
Provider
ProviderKeyBinding
Providers
ProviderWithExtensionVisitor
ProvisionException

R  A B C D E F G I K L M P S T U TOP
RequireExplicitBindingsOption

S  A B C D E F G I K L M P R T U TOP
ScopeAnnotation
Scopes
ServletModule
ServletModule.FilterKeyBindingBuilder
ServletModule.ServletKeyBindingBuilder
ServletModuleBinding
ServletModuleTargetVisitor
ServletScopes
Struts2Factory
Struts2GuicePluginModule

T  A B C D E F G I K L M P R S U TOP
ThrowingProvider
ThrowingProviderBinder
ThrowingProviderBinder.SecondaryBinder
Toolable
TypeConverterBinding
TypeLiteral

U  A B C D E F G I K L M P R S T TOP
UriPatternType
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/classes_index_additions.html0000755000175000017500000002747011704661106027243 0ustar tonytony Class Additions Index
All Classes
Removals
Additions
Changes
Bold is New, strike is deleted


A  C D F I L M P R S T U TOP
AssistedInjectBinding
AssistedInjectTargetVisitor
AssistedMethod

C  A D F I L M P R S T U TOP
CheckedProvider
CheckedProvides

D  A C F I L M P R S T U TOP
DisableCircularProxiesOption

F  A C D I L M P R S T U TOP
FactoryModuleBuilder

I  A C D F L M P R S T U TOP
InstanceFilterBinding
InstanceServletBinding

L  A C D F I M P R S T U TOP
LinkedFilterBinding
LinkedServletBinding

M  A C D F I L P R S T U TOP
MapBinderBinding
MultibinderBinding
MultibindingsTargetVisitor

P  A C D F I L M R S T U TOP
ProviderWithExtensionVisitor

R  A C D F I L M P S T U TOP
RequireExplicitBindingsOption

S  A C D F I L M P R T U TOP
ServletModuleBinding
ServletModuleTargetVisitor
Struts2Factory
Struts2GuicePluginModule

T  A C D F I L M P R S U TOP
Toolable

U  A C D F I L M P R S T TOP
UriPatternType
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/changes-summary.html0000755000175000017500000001675111704661106025464 0ustar tonytony API Differences between 2.0 and 3.0
Generated by
JDiff

API Differences

Between 2.0 and 3.0

Added Packages
com.google.inject.grapher  
com.google.inject.grapher.
graphviz
 
com.google.inject.persist  
com.google.inject.persist.
finder
 
com.google.inject.persist.jpa  
 

Changed Packages
com.google.inject  
com.google.inject.assistedinject  
com.google.inject.binder  
com.google.inject.multibindings  
com.google.inject.servlet  
com.google.inject.spi  
com.google.inject.struts2  
com.google.inject.throwingproviders  
com.google.inject.util  
  sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/alldiffs_index_removals.html0000755000175000017500000000707211704661106027240 0ustar tonytony All Removals Index
All Differences
Removals
Additions
Changes
Bold is New, strike is deleted


T  V TOP
toProvider
  type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
  type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder

V  T TOP
visit
  type  (InjectionRequest) in com.google.inject.spi.DefaultElementVisitor
  type  (InjectionRequest) in com.google.inject.spi.ElementVisitor
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/alldiffs_index_changes.html0000755000175000017500000005466011704661106027025 0ustar tonytony All Changes Index
All Differences
Removals
Additions
Changes
Bold is New, strike is deleted


A  B C D E F G I K L M O P S T TOP
AssistedInject

B  A C D E F G I K L M O P S T TOP
Binder
com.google.inject
com.google.inject.assistedinject
com.google.inject.binder
com.google.inject.multibindings
com.google.inject.servlet
com.google.inject.spi
com.google.inject.struts2
com.google.inject.throwingproviders
com.google.inject.util
configureServlets ()
ConstantBindingBuilder
ConvertedConstantBinding
createChildInjector (Iterable<Module>)
createInjector
  type  (Module[]) in com.google.inject.Guice
  type  (Stage, Module[]) in com.google.inject.Guice
  type  (Stage, Iterable<Module>) in com.google.inject.Guice
  type  (Iterable<Module>) in com.google.inject.Guice

D  A B C E F G I K L M O P S T TOP
DefaultElementVisitor

E  A B C D F G I K L M O P S T TOP
ElementVisitor

F  A B C D E G I K L M O P S T TOP
FactoryProvider
forStaticMethodsAndFields (TypeLiteral<?>)

G  A B C D E F I K L M O P S T TOP
getBindings ()
getInterceptors ()
getProvider (Key<T>)
getProviderKey ()
Guice
GuiceObjectFactory

I  A B C D E F G K L M O P S T TOP
InjectionPoint
Injector
InterceptorBinding

K  A B C D E F G I L M O P S T TOP
Key

L  A B C D E F G I K M O P S T TOP
LinkedBindingBuilder

M  A B C D E F G I K L O P S T TOP
MapBinder
Modules
Multibinder

O  A B C D E F G I K L M P S T TOP
override
  type  (Module[]) in com.google.inject.util.Modules
  type  (Iterable<Module>) in com.google.inject.util.Modules

P  A B C D E F G I K L M O S T TOP
Provider
ProviderKeyBinding
Providers
ProvisionException
  com.google.inject
  ProvisionException (Iterable<Message>) constructor

S  A B C D E F G I K L M O P T TOP
ScopeAnnotation
Scopes
ServletModule
ServletModule.FilterKeyBindingBuilder
ServletModule.ServletKeyBindingBuilder
ServletScopes

T  A B C D E F G I K L M O P S TOP
ThrowingProvider
ThrowingProviderBinder
ThrowingProviderBinder.SecondaryBinder
to (CheckedProvider)
TypeConverterBinding
TypeLiteral
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/alldiffs_index_all.html0000755000175000017500000014647411704661106026172 0ustar tonytony All Differences Index
All Differences
Removals
Additions
Changes
Bold is New, strike is deleted


A  B C D E F G H I K L M O P R S T U V W TOP
AssistedInject
AssistedInjectBinding
AssistedInjectTargetVisitor
AssistedMethod

B  A C D E F G H I K L M O P R S T U V W TOP
Binder

C  A B D E F G H I K L M O P R S T U V W TOP
CheckedProvider
CheckedProvides
com.google.inject
com.google.inject.assistedinject
com.google.inject.binder
com.google.inject.grapher
com.google.inject.grapher.graphviz
com.google.inject.multibindings
com.google.inject.persist
com.google.inject.persist.finder
com.google.inject.persist.jpa
com.google.inject.servlet
com.google.inject.spi
com.google.inject.struts2
com.google.inject.throwingproviders
com.google.inject.util
configureServlets ()
ConstantBindingBuilder
continueRequest (Callable<T>, Map<Key<?>, Object>)
ConvertedConstantBinding
createChildInjector (Iterable<Module>)
createInjector
  type  (Module[]) in com.google.inject.Guice
  type  (Stage, Module[]) in com.google.inject.Guice
  type  (Stage, Iterable<Module>) in com.google.inject.Guice
  type  (Iterable<Module>) in com.google.inject.Guice

D  A B C E F G H I K L M O P R S T U V W TOP
DefaultElementVisitor
disableCircularProxies ()
DisableCircularProxiesOption

E  A B C D F G H I K L M O P R S T U V W TOP
ElementVisitor

F  A B C D E G H I K L M O P R S T U V W TOP
FactoryModuleBuilder
FactoryProvider
forConstructor
  type  (Constructor<T>) in com.google.inject.spi.InjectionPoint
  type  (Constructor<T>, TypeLiteral<? extends T>) in com.google.inject.spi.InjectionPoint
forModule (Module)
forStaticMethodsAndFields (TypeLiteral<?>)

G  A B C D E F H I K L M O P R S T U V W TOP
getAllBindings ()
getBindings ()
getDeclaringType ()
getExistingBinding (Key<T>)
getInterceptors ()
getProvider (Key<T>)
getProviderKey ()
getScopeBindings ()
getServletContext ()
getTypeConverterBinding ()
getTypeConverterBindings ()
Guice
GuiceObjectFactory
guicify (Provider<T>)

H  A B C D E F G I K L M O P R S T U V W TOP
hasAttributes ()

I  A B C D E F G H K L M O P R S T U V W TOP
InjectionPoint
Injector
InstanceFilterBinding
InstanceServletBinding
InterceptorBinding
isSingleton (Binding<?>)
isToolable ()

K  A B C D E F G H I L M O P R S T U V W TOP
Key

L  A B C D E F G H I K M O P R S T U V W TOP
LinkedBindingBuilder
LinkedFilterBinding
LinkedServletBinding

M  A B C D E F G H I K L O P R S T U V W TOP
MapBinder
MapBinderBinding
Modules
Multibinder
MultibinderBinding
MultibindingsTargetVisitor

O  A B C D E F G H I K L M P R S T U V W TOP
ofType
  type  (Type) in com.google.inject.Key
  type  (TypeLiteral<T>) in com.google.inject.Key
  type  (Class<T>) in com.google.inject.Key
override
  type  (Module[]) in com.google.inject.util.Modules
  type  (Iterable<Module>) in com.google.inject.util.Modules

P  A B C D E F G H I K L M O R S T U V W TOP
permitDuplicates
  type  () in com.google.inject.multibindings.MapBinder
  type  () in com.google.inject.multibindings.Multibinder
Provider
ProviderKeyBinding
Providers
ProviderWithExtensionVisitor
ProvisionException
  com.google.inject
  ProvisionException (Iterable<Message>) constructor

R  A B C D E F G H I K L M O P S T U V W TOP
requireExplicitBindings ()
RequireExplicitBindingsOption

S  A B C D E F G H I K L M O P R T U V W TOP
ScopeAnnotation
scopeRequest (Callable<T>, Map<Key<?>, Object>)
Scopes
ServletModule
ServletModule.FilterKeyBindingBuilder
ServletModule.ServletKeyBindingBuilder
ServletModuleBinding
ServletModuleTargetVisitor
ServletScopes
Struts2Factory
Struts2GuicePluginModule

T  A B C D E F G H I K L M O P R S U V W TOP
through
  type  (Filter) in com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder
  type  (Filter, Map<String, String>) in com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder
ThrowingProvider
ThrowingProviderBinder
ThrowingProviderBinder.SecondaryBinder
to
  type  (byte) in com.google.inject.binder.ConstantBindingBuilder
  type  (CheckedProvider) in com.google.inject.throwingproviders.ThrowingProviderBinder.SecondaryBinder
toConstructor
  type  (Constructor<S>) in com.google.inject.binder.LinkedBindingBuilder
  type  (Constructor<S>, TypeLiteral<? extends S>) in com.google.inject.binder.LinkedBindingBuilder
Toolable
toProvider
  type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
  type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
  type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
  type  (TypeLiteral<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
  type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
toString ()
TypeConverterBinding
  com.google.inject.spi
  TypeConverterBinding (Object, Matcher<TypeLiteral<?>>, TypeConverter) constructor
TypeLiteral

U  A B C D E F G H I K L M O P R S T V W TOP
UriPatternType

V  A B C D E F G H I K L M O P R S T U W TOP
visit
  type  (InjectionRequest) in com.google.inject.spi.DefaultElementVisitor
  type  (DisableCircularProxiesOption) in com.google.inject.spi.DefaultElementVisitor
  type  (InjectionRequest<?>) in com.google.inject.spi.DefaultElementVisitor
  type  (RequireExplicitBindingsOption) in com.google.inject.spi.DefaultElementVisitor
  type  (InjectionRequest) in com.google.inject.spi.ElementVisitor
  type  (DisableCircularProxiesOption) in com.google.inject.spi.ElementVisitor
  type  (InjectionRequest<?>) in com.google.inject.spi.ElementVisitor
  type  (RequireExplicitBindingsOption) in com.google.inject.spi.ElementVisitor

W  A B C D E F G H I K L M O P R S T U V TOP
with
  type  (HttpServlet) in com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder
  type  (HttpServlet, Map<String, String>) in com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder
withoutAttributes ()
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes/alldiffs_index_additions.html0000755000175000017500000010324111704661106027361 0ustar tonytony All Additions Index
All Differences
Removals
Additions
Changes
Bold is New, strike is deleted


A  C D F G H I L M O P R S T U V W TOP
AssistedInjectBinding
AssistedInjectTargetVisitor
AssistedMethod

C  A D F G H I L M O P R S T U V W TOP
CheckedProvider
CheckedProvides
com.google.inject.grapher
com.google.inject.grapher.graphviz
com.google.inject.persist
com.google.inject.persist.finder
com.google.inject.persist.jpa
continueRequest (Callable<T>, Map<Key<?>, Object>)

D  A C F G H I L M O P R S T U V W TOP
disableCircularProxies ()
DisableCircularProxiesOption

F  A C D G H I L M O P R S T U V W TOP
FactoryModuleBuilder
forConstructor
  type  (Constructor<T>) in com.google.inject.spi.InjectionPoint
  type  (Constructor<T>, TypeLiteral<? extends T>) in com.google.inject.spi.InjectionPoint
forModule (Module)

G  A C D F H I L M O P R S T U V W TOP
getAllBindings ()
getDeclaringType ()
getExistingBinding (Key<T>)
getScopeBindings ()
getServletContext ()
getTypeConverterBinding ()
getTypeConverterBindings ()
guicify (Provider<T>)

H  A C D F G I L M O P R S T U V W TOP
hasAttributes ()

I  A C D F G H L M O P R S T U V W TOP
InstanceFilterBinding
InstanceServletBinding
isSingleton (Binding<?>)
isToolable ()

L  A C D F G H I M O P R S T U V W TOP
LinkedFilterBinding
LinkedServletBinding

M  A C D F G H I L O P R S T U V W TOP
MapBinderBinding
MultibinderBinding
MultibindingsTargetVisitor

O  A C D F G H I L M P R S T U V W TOP
ofType
  type  (Type) in com.google.inject.Key
  type  (TypeLiteral<T>) in com.google.inject.Key
  type  (Class<T>) in com.google.inject.Key

P  A C D F G H I L M O R S T U V W TOP
permitDuplicates
  type  () in com.google.inject.multibindings.MapBinder
  type  () in com.google.inject.multibindings.Multibinder
ProviderWithExtensionVisitor

R  A C D F G H I L M O P S T U V W TOP
requireExplicitBindings ()
RequireExplicitBindingsOption

S  A C D F G H I L M O P R T U V W TOP
scopeRequest (Callable<T>, Map<Key<?>, Object>)
ServletModuleBinding
ServletModuleTargetVisitor
Struts2Factory
Struts2GuicePluginModule

T  A C D F G H I L M O P R S U V W TOP
through
  type  (Filter) in com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder
  type  (Filter, Map<String, String>) in com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder
to (byte)
toConstructor
  type  (Constructor<S>) in com.google.inject.binder.LinkedBindingBuilder
  type  (Constructor<S>, TypeLiteral<? extends S>) in com.google.inject.binder.LinkedBindingBuilder
Toolable
toProvider
  type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
  type  (TypeLiteral<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
  type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
toString ()
TypeConverterBinding (Object, Matcher<TypeLiteral<?>>, TypeConverter) constructor

U  A C D F G H I L M O P R S T V W TOP
UriPatternType

V  A C D F G H I L M O P R S T U W TOP
visit
  type  (DisableCircularProxiesOption) in com.google.inject.spi.DefaultElementVisitor
  type  (InjectionRequest<?>) in com.google.inject.spi.DefaultElementVisitor
  type  (RequireExplicitBindingsOption) in com.google.inject.spi.DefaultElementVisitor
  type  (DisableCircularProxiesOption) in com.google.inject.spi.ElementVisitor
  type  (InjectionRequest<?>) in com.google.inject.spi.ElementVisitor
  type  (RequireExplicitBindingsOption) in com.google.inject.spi.ElementVisitor

W  A C D F G H I L M O P R S T U V TOP
with
  type  (HttpServlet) in com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder
  type  (HttpServlet, Map<String, String>) in com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder
withoutAttributes ()
sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/changes.html0000755000175000017500000000274011704661106022352 0ustar tonytony API Differences between 2.0 and 3.0 <H2> Frame Alert </H2> <P> This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. <BR> Link to <A HREF="changes/changes-summary.html" target="_top">Non-frame version.</A> sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/black.gif0000755000175000017500000000143711704661106021621 0ustar tonytonyGIF89aїџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ,;sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0/background.gif0000755000175000017500000000105711704661106022662 0ustar tonytonyGIF89ahh€ѕѕѕ!љ,hhџ„ЉЫэЃœДк‹ГоМћ†тH–ц‰ІъЪЖю ЧђLзічњЮїў ‡ФЂёˆL*—ЬІѓ JЇдЊѕŠЭjЗмЎї ‹ЧфВљŒNЋзьЖћ ЫчєК§ŽЯыїќОџ(8HXhxˆ˜ЈИШишј)9IYiy‰™ЉЙЩйщљ *:JZjzŠšЊКЪкъњ +;K[k{‹›ЋЛЫлыћ ,N^n~ŽžЎОЮоюў/?O_oŸЏПЯпяџ0 Р <ˆ0ЁТ… :|1ЂФ‰+ZМˆ1ЃЦџ;zќ2ЄШ‘$Kš<‰2ЅЪ•,[К| 3ІЬ™4kкМ‰3ЇЮ<{њќ 4ЈаЁD‹=Š4ЉвЅL›:} 5ЊдЉTЋZНŠ5Ћж­\Лz§ 6ЌиБdЫš=‹6­кЕlлК} 7ЎмЙtыкН‹7ЏоН|ћњ§ 8АрС„ >Œ8БтХŒ;~ 9ВфЩ”+[ОŒ9ГцЭœ;{ў :ДшбЄK›>:ЕъеЌ[Л~ ;ЖьйДkлО;ЗюнМ{ћў <И№сФ‹?Ž<ЙђхЬ›;=КєщдЋ[ПŽ=ЛіэмЛ{џ>МјёфЫ›?>НњѕьлЛ?ОќљєылП?Пў§ќћћџ O;sisu-guice-sisu-guice-3.1.1/latest-api-diffs/3.0.xml0000755000175000017500000161303411704661106020603 0ustar tonytony public class MyModule extends AbstractModule { protected void configure() { bind(Service.class).to(ServiceImpl.class).in(Singleton.class); bind(CreditCardPaymentService.class); bind(PaymentService.class).to(CreditCardPaymentService.class); bindConstant().annotatedWith(Names.named("port")).to(8080); } } @author crazybob@google.com (Bob Lee)]]>

  • Guice created the instance the method is on
  • Neither the enclosing type nor the method is final
  • And the method is package-private, protected, or public
  • @param classMatcher matches classes the interceptor should apply to. For example: {@code only(Runnable.class)}. @param methodMatcher matches methods the interceptor should apply to. For example: {@code annotatedWith(Transactional.class)}. @param interceptors to bind]]> bind(Foo.class).to(FooImpl.class)) are allowed, but the implicit binding (FooImpl) cannot be directly injected unless it is also explicitly bound (bind(FooImpl.class)).

    Tools can still retrieve bindings for implicit bindings (bindings created through a linked binding) if explicit bindings are required, however {@link Binding#getProvider} will fail.

    By default, explicit bindings are not required.

    If a parent injector requires explicit bindings, then all child injectors (and private modules within that injector) also require explicit bindings. If a parent does not require explicit bindings, a child injector or private module may optionally declare itself as requiring explicit bindings. If it does, the behavior is limited only to that child or any grandchildren. No siblings of the child will require explicit bindings.

    If the parent did not require explicit bindings but the child does, it is possible that a linked binding in the child may add a JIT binding to the parent. The child will not be allowed to reference the target binding directly, but the parent and other children of the parent may be able to. @since 3.0]]> If a parent injector disables circular proxies, then all child injectors (and private modules within that injector) also disable circular proxies. If a parent does not disable circular proxies, a child injector or private module may optionally declare itself as disabling circular proxies. If it does, the behavior is limited only to that child or any grandchildren. No siblings of the child will disable circular proxies. @since 3.0]]> bindings) which will be used to create an {@link Injector}. Guice provides this object to your application's {@link Module} implementors so they may each contribute their own bindings and other registrations.

    The Guice Binding EDSL

    Guice uses an embedded domain-specific language, or EDSL, to help you create bindings simply and readably. This approach is great for overall usability, but it does come with a small cost: it is difficult to learn how to use the Binding EDSL by reading method-level javadocs. Instead, you should consult the series of examples below. To save space, these examples omit the opening {@code binder}, just as you will if your module extends {@link AbstractModule}.
         bind(ServiceImpl.class);
    This statement does essentially nothing; it "binds the {@code ServiceImpl} class to itself" and does not change Guice's default behavior. You may still want to use this if you prefer your {@link Module} class to serve as an explicit manifest for the services it provides. Also, in rare cases, Guice may be unable to validate a binding at injector creation time unless it is given explicitly.
         bind(Service.class).to(ServiceImpl.class);
    Specifies that a request for a {@code Service} instance with no binding annotations should be treated as if it were a request for a {@code ServiceImpl} instance. This overrides the function of any {@link ImplementedBy @ImplementedBy} or {@link ProvidedBy @ProvidedBy} annotations found on {@code Service}, since Guice will have already "moved on" to {@code ServiceImpl} before it reaches the point when it starts looking for these annotations.
         bind(Service.class).toProvider(ServiceProvider.class);
    In this example, {@code ServiceProvider} must extend or implement {@code Provider}. This binding specifies that Guice should resolve an unannotated injection request for {@code Service} by first resolving an instance of {@code ServiceProvider} in the regular way, then calling {@link Provider#get get()} on the resulting Provider instance to obtain the {@code Service} instance.

    The {@link Provider} you use here does not have to be a "factory"; that is, a provider which always creates each instance it provides. However, this is generally a good practice to follow. You can then use Guice's concept of {@link Scope scopes} to guide when creation should happen -- "letting Guice work for you".

         bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);
    Like the previous example, but only applies to injection requests that use the binding annotation {@code @Red}. If your module also includes bindings for particular values of the {@code @Red} annotation (see below), then this binding will serve as a "catch-all" for any values of {@code @Red} that have no exact match in the bindings.
         bind(ServiceImpl.class).in(Singleton.class);
         // or, alternatively
         bind(ServiceImpl.class).in(Scopes.SINGLETON);
    Either of these statements places the {@code ServiceImpl} class into singleton scope. Guice will create only one instance of {@code ServiceImpl} and will reuse it for all injection requests of this type. Note that it is still possible to bind another instance of {@code ServiceImpl} if the second binding is qualified by an annotation as in the previous example. Guice is not overly concerned with preventing you from creating multiple instances of your "singletons", only with enabling your application to share only one instance if that's all you tell Guice you need.

    Note: a scope specified in this way overrides any scope that was specified with an annotation on the {@code ServiceImpl} class.

    Besides {@link Singleton}/{@link Scopes#SINGLETON}, there are servlet-specific scopes available in {@code com.google.inject.servlet.ServletScopes}, and your Modules can contribute their own custom scopes for use here as well.

         bind(new TypeLiteral<PaymentService<CreditCard>>() {})
             .to(CreditCardPaymentService.class);
    This admittedly odd construct is the way to bind a parameterized type. It tells Guice how to honor an injection request for an element of type {@code PaymentService}. The class {@code CreditCardPaymentService} must implement the {@code PaymentService} interface. Guice cannot currently bind or inject a generic type, such as {@code Set}; all type parameters must be fully specified.
         bind(Service.class).toInstance(new ServiceImpl());
         // or, alternatively
         bind(Service.class).toInstance(SomeLegacyRegistry.getService());
    In this example, your module itself, not Guice, takes responsibility for obtaining a {@code ServiceImpl} instance, then asks Guice to always use this single instance to fulfill all {@code Service} injection requests. When the {@link Injector} is created, it will automatically perform field and method injection for this instance, but any injectable constructor on {@code ServiceImpl} is simply ignored. Note that using this approach results in "eager loading" behavior that you can't control.
         bindConstant().annotatedWith(ServerHost.class).to(args[0]);
    Sets up a constant binding. Constant injections must always be annotated. When a constant binding's value is a string, it is eligile for conversion to all primitive types, to {@link Enum#valueOf(Class, String) all enums}, and to {@link Class#forName class literals}. Conversions for other types can be configured using {@link #convertToTypes(Matcher, TypeConverter) convertToTypes()}.
       {@literal @}Color("red") Color red; // A member variable (field)
        . . .
         red = MyModule.class.getDeclaredField("red").getAnnotation(Color.class);
         bind(Service.class).annotatedWith(red).to(RedService.class);
    If your binding annotation has parameters you can apply different bindings to different specific values of your annotation. Getting your hands on the right instance of the annotation is a bit of a pain -- one approach, shown above, is to apply a prototype annotation to a field in your module class, so that you can read this annotation instance and give it to Guice.
         bind(Service.class)
             .annotatedWith(Names.named("blue"))
             .to(BlueService.class);
    Differentiating by names is a common enough use case that we provided a standard annotation, {@link com.google.inject.name.Named @Named}. Because of Guice's library support, binding by name is quite easier than in the arbitrary binding annotation case we just saw. However, remember that these names will live in a single flat namespace with all the other names used in your application.
         Constructor loneCtor = getLoneCtorFromServiceImplViaReflection();
         bind(ServiceImpl.class)
             .toConstructor(loneCtor);
    In this example, we directly tell Guice which constructor to use in a concrete class implementation. It means that we do not need to place {@literal @}Inject on any of the constructors and that Guice treats the provided constructor as though it were annotated so. It is useful for cases where you cannot modify existing classes and is a bit simpler than using a {@link Provider}.

    The above list of examples is far from exhaustive. If you can think of how the concepts of one example might coexist with the concepts from another, you can most likely weave the two together. If the two concepts make no sense with each other, you most likely won't be able to do it. In a few cases Guice will let something bogus slip by, and will then inform you of the problems at runtime, as soon as you try to create your Injector.

    The other methods of Binder such as {@link #bindScope}, {@link #bindInterceptor}, {@link #install}, {@link #requestStaticInjection}, {@link #addError} and {@link #currentStage} are not part of the Binding EDSL; you can learn how to use these in the usual way, from the method documentation. @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson) @author kevinb@google.com (Kevin Bourrillion)]]> Bindings are created in several ways:

    • Explicitly in a module, via {@code bind()} and {@code bindConstant()} statements:
           bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);
           bindConstant().annotatedWith(ServerHost.class).to(args[0]);
    • Implicitly by the Injector by following a type's {@link ImplementedBy pointer} {@link ProvidedBy annotations} or by using its {@link Inject annotated} or default constructor.
    • By converting a bound instance to a different type.
    • For {@link Provider providers}, by delegating to the binding for the provided type.

    They exist on both modules and on injectors, and their behaviour is different for each:

    • Module bindings are incomplete and cannot be used to provide instances. This is because the applicable scopes and interceptors may not be known until an injector is created. From a tool's perspective, module bindings are like the injector's source code. They can be inspected or rewritten, but this analysis must be done statically.
    • Injector bindings are complete and valid and can be used to provide instances. From a tools' perspective, injector bindings are like reflection for an injector. They have full runtime information, including the complete graph of injections necessary to satisfy a binding.
    @param the bound type. The injected is always assignable to this type. @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson)]]>
    {@code @}Retention(RUNTIME) {@code @}Target({ FIELD, PARAMETER, METHOD }) {@code @}BindingAnnotation public {@code @}interface Transactional {} @author crazybob@google.com (Bob Lee)]]> Guice supports a model of development that draws clear boundaries between APIs, Implementations of these APIs, Modules which configure these implementations, and finally Applications which consist of a collection of Modules. It is the Application, which typically defines your {@code main()} method, that bootstraps the Guice Injector using the {@code Guice} class, as in this example:
         public class FooApplication {
           public static void main(String[] args) {
             Injector injector = Guice.createInjector(
                 new ModuleA(),
                 new ModuleB(),
                 . . .
                 new FooApplicationFlagsModule(args)
             );
    
             // Now just bootstrap the application and you're done
             FooStarter starter = injector.getInstance(FooStarter.class);
             starter.runApplication();
           }
         }
     
    ]]>
  • Every instance it constructs. The class being constructed must have exactly one of its constructors marked with {@code @Inject} or must have a constructor taking no parameters. The Injector then proceeds to perform method and field injections.
  • Pre-constructed instances passed to {@link Injector#injectMembers}, {@link com.google.inject.binder.LinkedBindingBuilder#toInstance(Object)} and {@link com.google.inject.binder.LinkedBindingBuilder#toProvider(Provider)}. In this case all constructors are, of course, ignored.
  • Static fields and methods of classes which any {@link Module} has specifically requested static injection for, using {@link Binder#requestStaticInjection}. In all cases, a member can be injected regardless of its Java access specifier (private, default, protected, public). @author crazybob@google.com (Bob Lee)]]> Whenever Guice creates an instance, it performs this injection automatically (after first performing constructor injection), so if you're able to let Guice create all your objects for you, you'll never need to use this method. @param instance to inject members on @see Binder#getMembersInjector(Class) for a preferred alternative that supports checks before run time]]> explicit bindings.

    The returned map does not include bindings inherited from a {@link #getParent() parent injector}, should one exist. The returned map is guaranteed to iterate (for example, with its {@link Map#entrySet()} iterator) in the order of insertion. In other words, the order in which bindings appear in user Modules.

    This method is part of the Guice SPI and is intended for use by tools and extensions.]]> both explicit and just-in-time. The returned map is immutable; it contains only the bindings that were present when {@code getAllBindings()} was invoked. Subsequent calls may return a map with additional just-in-time bindings.

    The returned map does not include bindings inherited from a {@link #getParent() parent injector}, should one exist.

    This method is part of the Guice SPI and is intended for use by tools and extensions. @since 3.0]]> This method is part of the Guice SPI and is intended for use by tools and extensions. @throws ConfigurationException if this injector cannot find or create the binding.]]> This method is part of the Guice SPI and is intended for use by tools and extensions. @throws ConfigurationException if this injector cannot find or create the binding. @since 2.0]]> This method is part of the Guice SPI and is intended for use by tools and extensions. @since 3.0]]> This method is part of the Guice SPI and is intended for use by tools and extensions.]]> Just-in-time bindings created for child injectors will be created in an ancestor injector whenever possible. This allows for scoped instances to be shared between injectors. Use explicit bindings to prevent bindings from being shared with the parent injector. Optional injections in just-in-time bindings (created in the parent injector) may be silently ignored if the optional dependencies are from the child injector.

    No key may be bound by both an injector and one of its ancestors. This includes just-in-time bindings. The lone exception is the key for {@code Injector.class}, which is bound by each injector to itself. @since 2.0]]> Just-in-time bindings created for child injectors will be created in an ancestor injector whenever possible. This allows for scoped instances to be shared between injectors. Use explicit bindings to prevent bindings from being shared with the parent injector.

    No key may be bound by both an injector and one of its ancestors. This includes just-in-time bindings. The lone exception is the key for {@code Injector.class}, which is bound by each injector to itself. @since 2.0]]> This method is part of the Guice SPI and is intended for use by tools and extensions. @since 3.0]]> This method is part of the Guice SPI and is intended for use by tools and extensions. @since 3.0]]> Contains several default bindings:

    • This {@link Injector} instance itself
    • A {@code Provider} for each binding of type {@code T}
    • The {@link java.util.logging.Logger} for the class being injected
    • The {@link Stage} in which the Injector was created
    Injectors are created using the facade class {@link Guice}.

    An injector can also {@link #injectMembers(Object) inject the dependencies} of already-constructed instances. This can be used to interoperate with objects created by other frameworks or services.

    Injectors can be {@link #createChildInjector(Iterable) hierarchical}. Child injectors inherit the configuration of their parent injectors, but the converse does not hold.

    The injector's {@link #getBindings() internal bindings} are available for introspection. This enables tools and extensions to operate on an injector reflectively. @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson)]]> Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

    Example usage for a binding of type {@code Foo} annotated with {@code @Bar}:

    {@code new Key(Bar.class) {}}.]]> Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

    Example usage for a binding of type {@code Foo} annotated with {@code @Bar}:

    {@code new Key(new Bar()) {}}.]]> Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

    Example usage for a binding of type {@code Foo}:

    {@code new Key() {}}.]]> For example, {@code Key.get(Service.class, Transactional.class)} will match:

       {@literal @}Inject
       public void setService({@literal @}Transactional Service service) {
         ...
       }
     

    {@code Key} supports generic types via subclassing just like {@link TypeLiteral}.

    Keys do not differentiate between primitive types (int, char, etc.) and their correpsonding wrapper types (Integer, Character, etc.). Primitive types will be replaced with their wrapper types when keys are created. @author crazybob@google.com (Bob Lee)]]> Whenever Guice creates an instance, it performs this injection automatically (after first performing constructor injection), so if you're able to let Guice create all your objects for you, you'll never need to use this method. @param instance to inject members on. May be {@code null}.]]> type to inject members of @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> Do not invoke this method directly to install submodules. Instead use {@link Binder#install(Module)}, which ensures that {@link Provides provider methods} are discovered.]]> Your Module classes can use a more streamlined syntax by extending {@link AbstractModule} rather than implementing this interface directly.

    In addition to the bindings configured via {@link #configure}, bindings will be created for all methods annotated with {@literal @}{@link Provides}. Use scope and binding annotations on these methods to configure the bindings.]]> A private module can be nested within a regular module or within another private module using {@link Binder#install install()}. Its bindings live in a new environment that inherits bindings, type converters, scopes, and interceptors from the surrounding ("parent") environment. When you nest multiple private modules, the result is a tree of environments where the injector's environment is the root.

    Guice EDSL bindings can be exposed with {@link #expose(Class) expose()}. {@literal @}{@link com.google.inject.Provides Provides} bindings can be exposed with the {@literal @}{@link Exposed} annotation:

     public class FooBarBazModule extends PrivateModule {
       protected void configure() {
         bind(Foo.class).to(RealFoo.class);
         expose(Foo.class);
    
         install(new TransactionalBarModule());
         expose(Bar.class).annotatedWith(Transactional.class);
    
         bind(SomeImplementationDetail.class);
         install(new MoreImplementationDetailsModule());
       }
    
       {@literal @}Provides {@literal @}Exposed
       public Baz provideBaz() {
         return new SuperBaz();
       }
     }
     

    Private modules are implemented using {@link Injector#createChildInjector(Module[]) parent injectors}. When it can satisfy their dependencies, just-in-time bindings will be created in the root environment. Such bindings are shared among all environments in the tree.

    The scope of a binding is constrained to its environment. A singleton bound in a private module will be unique to its environment. But a binding for the same type in a different private module will yield a different instance.

    A shared binding that injects the {@code Injector} gets the root injector, which only has access to bindings in the root environment. An explicit binding that injects the {@code Injector} gets access to all bindings in the child environment.

    To promote a just-in-time binding to an explicit binding, bind it:

       bind(FooImpl.class);
     
    @author jessewilson@google.com (Jesse Wilson) @since 2.0]]>
  • When the default means for obtaining instances (an injectable or parameterless constructor) is insufficient for a particular binding, the module can specify a custom {@code Provider} instead, to control exactly how Guice creates or obtains instances for the binding.
  • An implementation class may always choose to have a {@code Provider} instance injected, rather than having a {@code T} injected directly. This may give you access to multiple instances, instances you wish to safely mutate and discard, instances which are out of scope (e.g. using a {@code @RequestScoped} object from within a {@code @SessionScoped} object), or instances that will be initialized lazily.
  • A custom {@link Scope} is implemented as a decorator of {@code Provider}, which decides when to delegate to the backing provider and when to provide the instance some other way.
  • The {@link Injector} offers access to the {@code Provider} it uses to fulfill requests for a given key, via the {@link Injector#getProvider} methods. @param the type of object this provides @author crazybob@google.com (Bob Lee)]]> Scope implementations are strongly encouraged to override {@link Object#toString} in the returned provider and include the backing provider's {@code toString()} output. @param key binding key @param unscoped locates an instance when one doesn't already exist in this scope. @return a new provider which only delegates to the given unscoped provider when an instance of the requested object doesn't already exist in this scope]]> no scope, meaning it has no state from the framework's perspective -- the {@code Injector} creates it, injects it once into the class that required it, and then immediately forgets it. Associating a scope with a particular binding allows the created instance to be "remembered" and possibly used again for other injections.

    An example of a scope is {@link Scopes#SINGLETON}. @author crazybob@google.com (Bob Lee)]]> {@code @}Retention(RUNTIME) {@code @}Target(TYPE, METHOD) {@code @}ScopeAnnotation public {@code @}interface SessionScoped {} @author crazybob@google.com (Bob Lee)]]> This exists only in case a class has been annotated with a scope annotation such as {@link Singleton @Singleton}, and you need to override this to "no scope" in your binding. @since 2.0]]> Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.]]> }, this returns {@code Iterable} given the input {@code Iterable.class}. @param supertype a superclass of, or interface implemented by, this. @since 2.0]]> For example, to create a type literal for {@code List}, you can create an empty anonymous inner class:

    {@code TypeLiteral> list = new TypeLiteral>() {};}

    Along with modeling generic types, this class can resolve type parameters. For example, to figure out what type {@code keySet()} returns on a {@code Map}, use this code:

       {@code
    
       TypeLiteral> mapType
           = new TypeLiteral>() {};
       TypeLiteral keySetType
           = mapType.getReturnType(Map.class.getMethod("keySet"));
       System.out.println(keySetType); // prints "Set"}
    @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson)]]>
    When used in tandem with {@link FactoryModuleBuilder}, constructors annotated with {@code @AssistedInject} indicate that multiple constructors can be injected, each with different parameters. AssistedInject annotations should not be mixed with {@literal @}{@link Inject} annotations. The assisted parameters must exactly match one corresponding factory method within the factory interface, but the parameters do not need to be in the same order. Constructors annotated with AssistedInject are created by Guice and receive all the benefits (such as AOP).

    Obsolete Usage: When used in tandem with {@link FactoryProvider}, constructors annotated with {@code @AssistedInject} trigger a "backwards compatibility mode". The assisted parameters must exactly match one corresponding factory method within the factory interface and all must be in the same order as listed in the factory. In this backwards compatable mode, constructors annotated with AssistedInject are not created by Guice and thus receive none of the benefits.

    Constructor parameters must be either supplied by the factory interface and marked with @Assisted, or they must be injectable. @author jmourits@google.com (Jerome Mourits) @author jessewilson@google.com (Jesse Wilson)]]> The fully qualified type of the factory. @since 3.0 @author ramakrishna@google.com (Ramakrishna Rajanna)]]> If your {@link BindingTargetVisitor} implements this interface, bindings created by using {@link FactoryModuleBuilder} will be visited through this interface. @since 3.0 @author ramakrishna@google.com (Ramakrishna Rajanna)]]> Defining a factory Create an interface whose methods return the constructed type, or any of its supertypes. The method's parameters are the arguments required to build the constructed type.

    public interface PaymentFactory {
       Payment create(Date startDate, Money amount);
     }
    You can name your factory methods whatever you like, such as create, createPayment or newPayment.

    Creating a type that accepts factory parameters

    {@code constructedType} is a concrete class with an {@literal @}{@link com.google.inject.Inject Inject}-annotated constructor. In addition to injector-supplied parameters, the constructor should have parameters that match each of the factory method's parameters. Each factory-supplied parameter requires an {@literal @}{@link Assisted} annotation. This serves to document that the parameter is not bound by your application's modules.
    public class RealPayment implements Payment {
       {@literal @}Inject
       public RealPayment(
          CreditService creditService,
          AuthService authService,
          {@literal @}Assisted Date startDate,
          {@literal @}Assisted Money amount) {
         ...
       }
     }

    Multiple factory methods for the same type

    If the factory contains many methods that return the same type, you can create multiple constructors in your concrete class, each constructor marked with with {@literal @}{@link AssistedInject}, in order to match the different parameters types of the factory methods.
    public interface PaymentFactory {
        Payment create(Date startDate, Money amount);
        Payment createWithoutDate(Money amount);
     }
     
     public class RealPayment implements Payment {
      {@literal @}AssistedInject
       public RealPayment(
          CreditService creditService,
          AuthService authService,
         {@literal @}Assisted Date startDate,
         {@literal @}Assisted Money amount) {
         ...
       }
       
      {@literal @}AssistedInject
       public RealPayment(
          CreditService creditService,
          AuthService authService,
         {@literal @}Assisted Money amount) {
         ...
       }   
     }

    Configuring simple factories

    In your {@link Module module}, install a {@code FactoryModuleBuilder} that creates the factory:
    install(new FactoryModuleBuilder()
         .implement(Payment.class, RealPayment.class)
         .build(PaymentFactory.class);
    As a side-effect of this binding, Guice will inject the factory to initialize it for use. The factory cannot be used until the injector has been initialized.

    Configuring complex factories

    Factories can create an arbitrary number of objects, one per each method. Each factory method can be configured using .implement.
    public interface OrderFactory {
        Payment create(Date startDate, Money amount);
        Shipment create(Customer customer, Item item);
        Receipt create(Payment payment, Shipment shipment);
     }
     
     [...]
     
     install(new FactoryModuleBuilder()
         .implement(Payment.class, RealPayment.class)
         // excluding .implement for Shipment means the implementation class
         // will be 'Shipment' itself, which is legal if it's not an interface.
         .implement(Receipt.class, RealReceipt.class)
         .build(OrderFactory.class);

    Using the factory

    Inject your factory into your application classes. When you use the factory, your arguments will be combined with values from the injector to construct an instance.
    public class PaymentAction {
       {@literal @}Inject private PaymentFactory paymentFactory;
    
       public void doPayment(Money amount) {
         Payment payment = paymentFactory.create(new Date(), amount);
         payment.apply();
       }
     }

    Making parameter types distinct

    The types of the factory method's parameters must be distinct. To use multiple parameters of the same type, use a named {@literal @}{@link Assisted} annotation to disambiguate the parameters. The names must be applied to the factory method's parameters:
    public interface PaymentFactory {
       Payment create(
           {@literal @}Assisted("startDate") Date startDate,
           {@literal @}Assisted("dueDate") Date dueDate,
           Money amount);
     } 
    ...and to the concrete type's constructor parameters:
    public class RealPayment implements Payment {
       {@literal @}Inject
       public RealPayment(
          CreditService creditService,
          AuthService authService,
          {@literal @}Assisted("startDate") Date startDate,
          {@literal @}Assisted("dueDate") Date dueDate,
          {@literal @}Assisted Money amount) {
         ...
       }
     }

    Values are created by Guice

    Returned factories use child injectors to create values. The values are eligible for method interception. In addition, {@literal @}{@literal Inject} members will be injected before they are returned.

    More configuration options

    In addition to simply specifying an implementation class for any returned type, factories' return values can be automatic or can be configured to use annotations:

    If you just want to return the types specified in the factory, do not configure any implementations:

    public interface FruitFactory {
       Apple getApple(Color color);
     }
     ...
     protected void configure() {
       install(new FactoryModuleBuilder().build(FruitFactory.class));
     }
    Note that any type returned by the factory in this manner needs to be an implementation class.

    To return two different implementations for the same interface from your factory, use binding annotations on your return types:

    interface CarFactory {
       {@literal @}Named("fast") Car getFastCar(Color color);
       {@literal @}Named("clean") Car getCleanCar(Color color);
     }
     ...
     protected void configure() {
       install(new FactoryModuleBuilder()
           .implement(Car.class, Names.named("fast"), Porsche.class)
           .implement(Car.class, Names.named("clean"), Prius.class)
           .build(CarFactory.class));
     }

    Implementation limitations

    As a limitation of the implementation, it is prohibited to declare a factory method that accepts a {@code Provider} as one of its arguments. @since 3.0 @author schmitt@google.com (Peter Schmitt)]]>
    Obsolete. Prefer {@link FactoryModuleBuilder} for its more concise API and additional capability.

    Provides a factory that combines the caller's arguments with injector-supplied values to construct objects.

    Defining a factory

    Create an interface whose methods return the constructed type, or any of its supertypes. The method's parameters are the arguments required to build the constructed type.
    public interface PaymentFactory {
       Payment create(Date startDate, Money amount);
     }
    You can name your factory methods whatever you like, such as create, createPayment or newPayment.

    Creating a type that accepts factory parameters

    {@code constructedType} is a concrete class with an {@literal @}{@link Inject}-annotated constructor. In addition to injector-supplied parameters, the constructor should have parameters that match each of the factory method's parameters. Each factory-supplied parameter requires an {@literal @}{@link Assisted} annotation. This serves to document that the parameter is not bound by your application's modules.
    public class RealPayment implements Payment {
       {@literal @}Inject
       public RealPayment(
          CreditService creditService,
          AuthService authService,
          {@literal @}Assisted Date startDate,
          {@literal @}Assisted Money amount) {
         ...
       }
     }
    Any parameter that permits a null value should also be annotated {@code @Nullable}.

    Configuring factories

    In your {@link com.google.inject.Module module}, bind the factory interface to the returned factory:
    bind(PaymentFactory.class).toProvider(
         FactoryProvider.newFactory(PaymentFactory.class, RealPayment.class));
    As a side-effect of this binding, Guice will inject the factory to initialize it for use. The factory cannot be used until the injector has been initialized.

    Using the factory

    Inject your factory into your application classes. When you use the factory, your arguments will be combined with values from the injector to construct an instance.
    public class PaymentAction {
       {@literal @}Inject private PaymentFactory paymentFactory;
    
       public void doPayment(Money amount) {
         Payment payment = paymentFactory.create(new Date(), amount);
         payment.apply();
       }
     }

    Making parameter types distinct

    The types of the factory method's parameters must be distinct. To use multiple parameters of the same type, use a named {@literal @}{@link Assisted} annotation to disambiguate the parameters. The names must be applied to the factory method's parameters:
    public interface PaymentFactory {
       Payment create(
           {@literal @}Assisted("startDate") Date startDate,
           {@literal @}Assisted("dueDate") Date dueDate,
           Money amount);
     } 
    ...and to the concrete type's constructor parameters:
    public class RealPayment implements Payment {
       {@literal @}Inject
       public RealPayment(
          CreditService creditService,
          AuthService authService,
          {@literal @}Assisted("startDate") Date startDate,
          {@literal @}Assisted("dueDate") Date dueDate,
          {@literal @}Assisted Money amount) {
         ...
       }
     }

    Values are created by Guice

    Returned factories use child injectors to create values. The values are eligible for method interception. In addition, {@literal @}{@literal Inject} members will be injected before they are returned.

    Backwards compatibility using {@literal @}AssistedInject

    Instead of the {@literal @}Inject annotation, you may annotate the constructed classes with {@literal @}{@link AssistedInject}. This triggers a limited backwards-compatability mode.

    Instead of matching factory method arguments to constructor parameters using their names, the parameters are matched by their order. The first factory method argument is used for the first {@literal @}Assisted constructor parameter, etc.. Annotation names have no effect.

    Returned values are not created by Guice. These types are not eligible for method interception. They do receive post-construction member injection. @param The factory interface @author jmourits@google.com (Jerome Mourits) @author jessewilson@google.com (Jesse Wilson) @author dtm@google.com (Daniel Martin) @deprecated use {@link FactoryModuleBuilder} instead.]]> The type for node IDs.]]> The type for node IDs. @param The {@link BindingEdge} sub-type that this factory provides.]]> The type for node IDs.]]> The type for node IDs. @param The {@link DependencyEdge} sub-type that this factory provides.]]> If you want to use subtypes of the node and edge classes, or a different node ID type, you will need to override the {@link GraphingVisitor} binding to specify the new type parameters. @author phopkins@gmail.com (Pete Hopkins)]]> If a {@link Dependency} has an associated {@link InjectionPoint}, its member will be added to the given {@link ImplementationNode} and the edge will start at the {@link Member}. @see #newDependencyEdge(Object, InjectionPoint, Dependency) @param nodeId ID of the node that should be the tail of the {@link DependencyEdge}s. @param node An {@link ImplementationNode} to add {@link Member}s to. @param dependencies {@link Collection} of {@link Dependency}s from the {@link Binding}. @return A {@link Collection} of the {@link DependencyEdge}s that were added to the graph.]]> This method takes more comprehensive parameters than strictly necessary in case they would be useful to overriding implementations. @param nodeId ID of the {@link ImplementationNode} where the edges will start. @param injectionPoint The {@link InjectionPoint} that gave rise to this {@link Dependency}, if one exists. Used to figure out which {@link Member} the edge should point from. @param dependency The {@link Dependency} to represent with this edge. @return The newly-created and added {@link DependencyEdge}.]]> We render this as an {@link InterfaceNode} that has a {@link BindingEdge} to the source {@link Key}. That will then be rendered by {@link #visit(InstanceBinding)} as an {@link InterfaceNode} with a {@link BindingEdge} to the {@link String} instance. @see #newInterfaceNode(Binding) @see #newBindingEdge(Object, Object, com.google.inject.grapher.BindingEdge.Type)]]> We then render any {@link DependencyEdge}s that the instance may have, which come either from {@link InjectionPoint}s (method and field) on the instance, or on {@link Dependency}s the instance declares through the {@link HasDependencies} interface. @see #newInterfaceNode(Binding) @see #newBindingEdge(Object, Object, com.google.inject.grapher.BindingEdge.Type) @see #newInstanceImplementationNode(Binding, Object) @see #newDependencyEdges(Object, ImplementationNode, java.util.Collection)]]> This class is parameterized over the four graph element types ({@link InterfaceNode}, {@link ImplementationNode}, {@link BindingEdge}, and {@link DependencyEdge}) so that you can extend those interfaces and also extend this class, and the helper methods will all return your new types. @author phopkins@gmail.com (Pete Hopkins) @param The type for node IDs. @param Type for {@link InterfaceNode}s. @param Type for {@link ImplementationNode}.s @param Type for {@link BindingEdge}s. @param Type for {@link DependencyEdge}s.]]> The type for node IDs.]]> The type for node IDs. @param The {@link ImplementationNode} sub-type that this factory provides.]]> Use {@link #of(Injector)} to specify the {@link Injector} to use, and {@link graph()} to graph the {@link Injector} using the currently-bound {@link Renderer}.

    By default, this will graph the entire {@link Injector}. Use {@link #rootedAt(Class...)} or {@link #rootedAt(Key...)} to specify an initial set of {@link Class}es or {@link Key}s to use, and this will graph their transitive bindings and dependencies. @author phopkins@gmail.com (Pete Hopkins)]]> The type for node IDs.]]> The type for node IDs. @param The {@link InterfaceNode} sub-type that this factory provides.]]> Node IDs are treated as opaque values by {@link GraphingVisitor} and the other classes in this package. @author phopkins@gmail.com (Pete Hopkins) @param The type for node IDs.]]> See: http://www.graphviz.org/doc/info/arrows.html @author phopkins@gmail.com (Pete Hopkins)]]> See: http://www.graphviz.org/doc/info/attrs.html#k:portPos @author phopkins@gmail.com (Pete Hopkins)]]> See: http://www.graphviz.org/doc/info/attrs.html#k:style @author phopkins@gmail.com (Pete Hopkins)]]> Specify the {@link PrintWriter} to output to with {@link #setOut(PrintWriter)}. @author phopkins@gmail.com (Pete Hopkins)]]> See: http://www.graphviz.org/doc/info/shapes.html @author phopkins@gmail.com (Pete Hopkins)]]> See: http://www.graphviz.org/doc/info/attrs.html#k:style @author phopkins@gmail.com (Pete Hopkins)]]> bind(DataSource.class).toProvider(fromJndi(DataSource.class, "java:...")); ]]> When multiple equal keys are bound, the value that gets included in the map is arbitrary.

    In addition to the {@code Map} and {@code Map>} maps that are normally bound, a {@code Map>} and {@code Map>>} are also bound, which contain all values bound to each key.

    When multiple modules contribute elements to the map, this configuration option impacts all of them. @return this map binder @since 3.0]]> It is an error to call this method without also calling one of the {@code to} methods on the returned binding builder.

    Scoping elements independently is supported. Use the {@code in} method to specify a binding scope.]]> public class SnacksModule extends AbstractModule { protected void configure() { MapBinder<String, Snack> mapbinder = MapBinder.newMapBinder(binder(), String.class, Snack.class); mapbinder.addBinding("twix").toInstance(new Twix()); mapbinder.addBinding("snickers").toProvider(SnickersProvider.class); mapbinder.addBinding("skittles").to(Skittles.class); } }

    With this binding, a {@link Map}{@code } can now be injected:

    
     class SnackMachine {
       {@literal @}Inject
       public SnackMachine(Map<String, Snack> snacks) { ... }
     }

    In addition to binding {@code Map}, a mapbinder will also bind {@code Map>} for lazy value provision:

    
     class SnackMachine {
       {@literal @}Inject
       public SnackMachine(Map<String, Provider<Snack>> snackProviders) { ... }
     }

    Contributing mapbindings from different modules is supported. For example, it is okay to have both {@code CandyModule} and {@code ChipsModule} both create their own {@code MapBinder}, and to each contribute bindings to the snacks map. When that map is injected, it will contain entries from both modules.

    The map's iteration order is consistent with the binding order. This is convenient when multiple elements are contributed by the same module because that module can order its bindings appropriately. Avoid relying on the iteration order of elements contributed by different modules, since there is no equivalent mechanism to order modules.

    The map is unmodifiable. Elements can only be added to the map by configuring the MapBinder. Elements can never be removed from the map.

    Values are resolved at map injection time. If a value is bound to a provider, that provider's get method will be called each time the map is injected (unless the binding is also scoped, or a map of providers is injected).

    Annotations are used to create different maps of the same key/value type. Each distinct annotation gets its own independent map.

    Keys must be distinct. If the same key is bound more than once, map injection will fail. However, use {@link #permitDuplicates()} in order to allow duplicate keys; extra bindings to {@code Map>} and {@code Map>} will be added.

    Keys must be non-null. {@code addBinding(null)} will throw an unchecked exception.

    Values must be non-null to use map injection. If any value is null, map injection will fail (although injecting a map of providers will not). @author dpb@google.com (David P. Baker)]]> The TypeLiteral will always match the type Map's generic type. For example, if getMapKey returns a key of Map<String, Snack>, then this will always return a TypeLiteral<String>.]]> The TypeLiteral will always match the type Map's generic type. For example, if getMapKey returns a key of Map<String, Snack>, then this will always return a TypeLiteral<Snack>.]]> The elements will always match the type Map's generic type. For example, if getMapKey returns a key of Map<String, Snack>, then this will always return a list of type List<Map.Entry<String, Binding<Snack>>>.]]> If you need to introspect the details of the map, such as the keys, values or if it permits duplicates, it is necessary to pass the elements through an Injector and use {@link #getEntries()} and {@link #permitsDuplicates()}.]]> Although MapBinders may be injected through a variety of generic types (Map<K, V>, Map <K, Provider<V>>, Map<K, Set<V>>, Map>, and even Set<Map.Entry<K, Provider<V>>), a MapBinderBinding exists only on the Binding associated with the Map<K, V> key. Other bindings can be validated to be derived from this MapBinderBinding using {@link #containsElement(Element)}. @param The fully qualified type of the map, including Map. For example: MapBinderBinding<Map<String, Snack>> @since 3.0 @author sameb@google.com (Sam Berlin)]]> It is an error to call this method without also calling one of the {@code to} methods on the returned binding builder.

    Scoping elements independently is supported. Use the {@code in} method to specify a binding scope.]]> public class SnacksModule extends AbstractModule { protected void configure() { Multibinder<Snack> multibinder = Multibinder.newSetBinder(binder(), Snack.class); multibinder.addBinding().toInstance(new Twix()); multibinder.addBinding().toProvider(SnickersProvider.class); multibinder.addBinding().to(Skittles.class); } }

    With this binding, a {@link Set}{@code } can now be injected:

    
     class SnackMachine {
       {@literal @}Inject
       public SnackMachine(Set<Snack> snacks) { ... }
     }

    Contributing multibindings from different modules is supported. For example, it is okay to have both {@code CandyModule} and {@code ChipsModule} to both create their own {@code Multibinder}, and to each contribute bindings to the set of snacks. When that set is injected, it will contain elements from both modules.

    The set's iteration order is consistent with the binding order. This is convenient when multiple elements are contributed by the same module because that module can order its bindings appropriately. Avoid relying on the iteration order of elements contributed by different modules, since there is no equivalent mechanism to order modules.

    The set is unmodifiable. Elements can only be added to the set by configuring the multibinder. Elements can never be removed from the set.

    Elements are resolved at set injection time. If an element is bound to a provider, that provider's get method will be called each time the set is injected (unless the binding is also scoped).

    Annotations are be used to create different sets of the same element type. Each distinct annotation gets its own independent collection of elements.

    Elements must be distinct. If multiple bound elements have the same value, set injection will fail.

    Elements must be non-null. If any set element is null, set injection will fail. @author jessewilson@google.com (Jesse Wilson)]]> The elements will always match the type Set's generic type. For example, if getSetKey returns a key of Set<String>, then this will always return a TypeLiteral<String>.]]> The elements will always match the type Set's generic type. For example, if getSetKey returns a key of Set<String>, then this will always return a list of type List<Binding<String>>.]]> If you need to introspect the details of the set, such as the values or if it permits duplicates, it is necessary to pass the elements through an Injector and use {@link #getElements()} and {@link #permitsDuplicates()}.]]> The fully qualified type of the set, including Set. For example: MultibinderBinding<Set<Boolean>> @since 3.0 @author sameb@google.com (Sam Berlin)]]> If your {@link BindingTargetVisitor} implements this interface, bindings created by using {@link Multibinder} or {@link MapBinder} will be visited through this interface. @since 3.0 @author sameb@google.com (Sam Berlin)]]> To be able to use the open session-in-view pattern (i.e. work per request), register this filter once in your Guice {@code ServletModule}. It is important that you register this filter before any other filter. For multiple providers, you should register this filter once per provider, inside a private module for each persist module installed (this must be the same private module where the specific persist module is itself installed).

    Example configuration:

    {@code
      public class MyModule extends ServletModule {
        public void configureServlets() {
          filter("/*").through(PersistFilter.class);
    
          serve("/index.html").with(MyHtmlServlet.class);
          // Etc.
        }
      }
     }

    This filter is thread safe and allows you to create injectors concurrently and deploy multiple guice-persist modules within the same injector, or even multiple injectors with persist modules withing the same JVM or web app.

    This filter requires the Guice Servlet extension. @author Dhanji R. Prasanna (dhanji@gmail.com)]]> Any method or class marked with this annotation will be considered for transactionality. Consult the documentation on http://code.google.com/p/google-guice for detailed semantics. Marking a method {@code @Transactional} will start a new transaction before the method executes and commit it after the method returns.

    If the method throws an exception, the transaction will be rolled back unless you have specifically requested not to in the {@link #ignore()} clause.

    Similarly, the set of exceptions that will trigger a rollback can be defined in the {@link #rollbackOn()} clause. By default, only unchecked exceptions trigger a rollback. @author Dhanji R. Prasanna (dhanji@gmail.com)]]> Transaction semantics are not affected.]]> The Unit of Work referred to by UnitOfWork will always be local to the calling thread. Be careful to end() in a finally block. Neither JPA, nor Hibernate supports threadsafe sessions (reasoning behind thread-locality of Unit of Work semantics).

    • Using UnitOfWork with the PersistFilter inside a request is not recommended.
    • Using UnitOfWork with session-per-txn strategy is not terribly clever either.
    • Using UnitOfWork with session-per-request strategy but *outside* a request (i.e. in a background or bootstrap thread) is probably a good use case.
    @author Dhanji R. Prasanna (dhanji@gmail com)]]>
    Apply this filter in web.xml above all other filters (typically), to all requests where you plan to use servlet scopes. This is also needed in order to dispatch requests to injectable filters and servlets:
      <filter>
        <filter-name>guiceFilter</filter-name>
        <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
      </filter>
    
      <filter-mapping>
        <filter-name>guiceFilter</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
      
    This filter must appear before every filter that makes use of Guice injection or servlet scopes functionality. Typically, you will only register this filter in web.xml and register any other filters (and servlets) using a {@link ServletModule}. @author crazybob@google.com (Bob Lee) @author dhanji@gmail.com (Dhanji R. Prasanna)]]>
    } when you want the HTTP request parameter map to be injected. @author crazybob@google.com (Bob Lee)]]> Servlet Mapping EDSL

    Part of the EDSL builder language for configuring servlets and filters with guice-servlet. Think of this as an in-code replacement for web.xml. Filters and servlets are configured here using simple java method calls. Here is a typical example of registering a filter when creating your Guice injector:

       Guice.createInjector(..., new ServletModule() {
    
         {@literal @}Override
         protected void configureServlets() {
           serve("*.html").with(MyServlet.class)
         }
       }
     
    This registers a servlet (subclass of {@code HttpServlet}) called {@code MyServlet} to service any web pages ending in {@code .html}. You can also use a path-style syntax to register servlets:
           serve("/my/*").with(MyServlet.class)
     
    Every servlet (or filter) is required to be a singleton. If you cannot annotate the class directly, you should add a separate {@code bind(..).in(Singleton.class)} rule elsewhere in your module. Mapping a servlet that is bound under any other scope is an error.

    Dispatch Order

    You are free to register as many servlets and filters as you like this way. They will be compared and dispatched in the order in which the filter methods are called:
    
       Guice.createInjector(..., new ServletModule() {
    
         {@literal @}Override
         protected void configureServlets() {
           filter("/*").through(MyFilter.class);
           filter("*.css").through(MyCssFilter.class);
           filter("*.jpg").through(new MyJpgFilter());
           // etc..
    
           serve("*.html").with(MyServlet.class);
           serve("/my/*").with(MyServlet.class);
           serve("*.jpg").with(new MyServlet());
           // etc..
          }
        }
     
    This will traverse down the list of rules in lexical order. For example, a url "{@code /my/file.js}" (after it runs through the matching filters) will first be compared against the servlet mapping:
           serve("*.html").with(MyServlet.class);
     
    And failing that, it will descend to the next servlet mapping:
           serve("/my/*").with(MyServlet.class);
     
    Since this rule matches, Guice Servlet will dispatch to {@code MyServlet}. These two mapping rules can also be written in more compact form using varargs syntax:
           serve("*.html", "/my/*").with(MyServlet.class);
     
    This way you can map several URI patterns to the same servlet. A similar syntax is also available for filter mappings.

    Regular Expressions

    You can also map servlets (or filters) to URIs using regular expressions:
        serveRegex("(.)*ajax(.)*").with(MyAjaxServlet.class)
     
    This will map any URI containing the text "ajax" in it to {@code MyAjaxServlet}. Such as:
    • http://www.google.com/ajax.html
    • http://www.google.com/content/ajax/index
    • http://www.google.com/it/is_totally_ajaxian

    Initialization Parameters

    Servlets (and filters) allow you to pass in init params using the {@code } tag in web.xml. You can similarly pass in parameters to Servlets and filters registered in Guice-servlet using a {@link java.util.Map} of parameter name/value pairs. For example, to initialize {@code MyServlet} with two parameters ({@code name="Dhanji", site="google.com"}) you could write:
      Map<String, String> params = new HashMap<String, String>();
      params.put("name", "Dhanji");
      params.put("site", "google.com");
    
      ...
          serve("/*").with(MyServlet.class, params)
     

    Binding Keys

    You can also bind keys rather than classes. This lets you hide implementations with package-local visbility and expose them using only a Guice module and an annotation:
      ...
          filter("/*").through(Key.get(Filter.class, Fave.class));
     
    Where {@code Filter.class} refers to the Servlet API interface and {@code Fave.class} is a custom binding annotation. Elsewhere (in one of your own modules) you can bind this filter's implementation:
       bind(Filter.class).annotatedWith(Fave.class).to(MyFilterImpl.class);
     
    See {@link com.google.inject.Binder} for more information on binding syntax.

    Multiple Modules

    It is sometimes useful to capture servlet and filter mappings from multiple different modules. This is essential if you want to package and offer drop-in Guice plugins that provide servlet functionality.

    Guice Servlet allows you to register several instances of {@code ServletModule} to your injector. The order in which these modules are installed determines the dispatch order of filters and the precedence order of servlets. For example, if you had two servlet modules, {@code RpcModule} and {@code WebServiceModule} and they each contained a filter that mapped to the same URI pattern, {@code "/*"}:

    In {@code RpcModule}:

         filter("/*").through(RpcFilter.class);
     
    In {@code WebServiceModule}:
         filter("/*").through(WebServiceFilter.class);
     
    Then the order in which these filters are dispatched is determined by the order in which the modules are installed:
       install(new WebServiceModule());
       install(new RpcModule());
     
    In the case shown above {@code WebServiceFilter} will run first. @since 2.0]]>
    You should subclass this module to register servlets and filters in the {@link #configureServlets()} method. @author crazybob@google.com (Bob Lee) @author dhanji@gmail.com (Dhanji R. Prasanna)]]>
    There are some limitations:
    • Derived objects (i.e. anything marked @RequestScoped will not be transported.
    • State changes to the HttpServletRequest after this method is called will not be seen in the continued thread.
    • Only the HttpServletRequest, ServletContext and request parameter map are available in the continued thread. The response and session are not available.
    @param callable code to be executed in another thread, which depends on the request scope. @param seedMap the initial set of scoped instances for Guice to seed the request scope with. To seed a key with null, use {@code null} as the value. @return a callable that will invoke the given callable, making the request context available to it. @throws OutOfScopeException if this method is called from a non-request thread, or if the request has completed. @since 3.0]]>
    any type to be returned by the visit method. Use {@link Void} with {@code return null} if no return type is needed. @since 2.0]]> any type to be returned by the visit method. Use {@link Void} with {@code return null} if no return type is needed. @since 2.0]]> any type to be returned by the visit method. Use {@link Void} with {@code return null} if no return type is needed. @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> any type to be returned by the visit method. Use {@link Void} with {@code return null} if no return type is needed. @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> any type to be returned by the visit method. Use {@link Void} with {@code return null} if no return type is needed. @author sberlin@gmail.com (Sam Berlin) @since 2.0]]> Use {@link #get} to build a freestanding dependency, or {@link InjectionPoint} to build one that's attached to a constructor, method or field. @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> Tools might specially handle types they know about; {@code StackTraceElement} is a good example. Tools should simply call {@code toString()} on the source object if the type is unfamiliar.]]> The elements of a module can be inspected, validated and rewritten. Use {@link Elements#getElements(com.google.inject.Module[]) Elements.getElements()} to read the elements from a module, and {@link Elements#getModule(Iterable) Elements.getModule()} to rewrite them. This can be used for static analysis and generation of Guice modules.

    The elements of an injector can be inspected and exercised. Use {@link com.google.inject.Injector#getBindings Injector.getBindings()} to reflect on Guice injectors. @author jessewilson@google.com (Jesse Wilson) @author crazybob@google.com (Bob Lee) @since 2.0]]> any type to be returned by the visit method. Use {@link Void} with {@code return null} if no return type is needed. @since 2.0]]> }), prefer the overload that includes a type literal. @param constructor any single constructor present on {@code type}. @since 3.0]]> } of the valid injection points.]]> } of the valid injection points.]]> } of the valid injection points.]]> } of the valid injection points.]]> } of the valid injection points.]]> requestInjection(serviceInstance); @author mikeward@google.com (Mike Ward) @since 2.0]]> bindInterceptor(Matchers.subclassesOf(MyAction.class), Matchers.annotatedWith(Transactional.class), new MyTransactionInterceptor()); or from an injectable type listener using {@link TypeEncounter#bindInterceptor(Matcher, org.aopalliance.intercept.MethodInterceptor[]) TypeEncounter.bindInterceptor()}. @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> MembersInjector<PaymentService> membersInjector = getMembersInjector(PaymentService.class); @author crazybob@google.com (Bob Lee) @since 2.0]]> try { bindPropertiesFromFile(); } catch (IOException e) { addError(e); } @author crazybob@google.com (Bob Lee)]]> Tools might specially handle types they know about; {@code StackTraceElement} is a good example. Tools should simply call {@code toString()} on the source object if the type is unfamiliar. @param key one of the keys exposed by this module.]]> } is injected (as opposed to injecting {@code T} directly). @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> Provider<PaymentService> paymentServiceProvider = getProvider(PaymentService.class); @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> MUST call visitor.visit(binding).

    Due to issues with generics, the type parameters of this method do not relate to the type of the provider. In practice, the 'B' type will always be a supertype of 'T'.]]> When an extension binds a provider instance, the provider can implement this interface to allow users using the {@link Binding#acceptTargetVisitor(BindingTargetVisitor)} method to visit a custom visitor designed for that extension. A typical implementation within the extension would look like

     
     <V, B> V acceptExtensionVisitor(BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding) {
       if(visitor instanceof MyCustomExtensionVisitor) {
         return ((MyCustomExtensionVisitor<B, V>)visitor).visitCustomExtension(customProperties, binding);
       } else {
         return visitor.visit(binding);
       }
     }
    'MyCustomExtensionVisitor' in the example above would be an interface the extension provides that users can implement in order to be notified of custom extension information. These visitor interfaces must extend from BindingTargetVisitor. @since 3.0 @author sameb@google.com (Sam Berlin)]]> Scope recordScope = new RecordScope(); bindScope(RecordScoped.class, new RecordScope()); @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> } of the valid injection points.]]> requestStaticInjection(MyLegacyService.class); @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> convertToTypes(Matchers.only(TypeLiteral.get(DateTime.class)), new DateTimeConverter()); @author jessewilson@google.com (Jesse Wilson) @since 2.0]]>
  • Guice created the instance the method is on
  • Neither the enclosing type nor the method is final
  • And the method is package-private or more accessible
  • @param methodMatcher matches methods the interceptor should apply to. For example: {@code annotatedWith(Transactional.class)}. @param interceptors to bind]]>
    the injectable type encountered @since 2.0]]> the injectable type]]> Useful for extra type checking, {@linkplain TypeEncounter#register(InjectionListener) registering injection listeners}, and {@linkplain TypeEncounter#bindInterceptor( com.google.inject.matcher.Matcher, org.aopalliance.intercept.MethodInterceptor[]) binding method interceptors}. @since 2.0]]> register(only(new TypeLiteral<PaymentService<CreditCard>>() {}), listener); @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> bind(DataSource.class) .toProvider(fromSpring(DataSource.class, "dataSource")); ]]> This interface must be extended to use application-specific exception types. Such subinterfaces may not define new methods, but may narrow the exception type.
     public interface RemoteProvider<T> extends CheckedProvider<T> { 
       T get() throws CustomExceptionOne, CustomExceptionTwo;
     }
     

    When this type is bound using {@link ThrowingProviderBinder}, the value returned or exception thrown by {@link #get} will be scoped. As a consequence, {@link #get} will invoked at most once within each scope. @since 3.0]]> This interface must be extended to use application-specific exception types. Such subinterfaces may not define new methods:

     public interface RemoteProvider<T> extends ThrowingProvider<T, RemoteException> { }
     

    When this type is bound using {@link ThrowingProviderBinder}, the value returned or exception thrown by {@link #get} will be scoped. As a consequence, {@link #get} will invoked at most once within each scope. @author jmourits@google.com (Jerome Mourits) @author jessewilson@google.com (Jesse Wilson) @deprecated use {@link CheckedProvider} instead.]]> Builds a binding for a {@link CheckedProvider}.

    You can use a fluent API and custom providers:

    ThrowingProviderBinder.create(binder())
        .bind(RemoteProvider.class, Customer.class)
        .to(RemoteCustomerProvider.class)
        .in(RequestScope.class);
     
    or, you can use throwing provider methods:
    class MyModule extends AbstractModule {
       configure() {
         ThrowingProviderBinder.install(this, binder());
       }
       
       {@literal @}CheckedProvides(RemoteProvider.class)
       {@literal @}RequestScope
       Customer provideCustomer(FlakyCustomerCreator creator) throws RemoteException {
         return creator.getCustomerOrThrow();
       }
     }
     
    @author jmourits@google.com (Jerome Mourits) @author jessewilson@google.com (Jesse Wilson)]]>
    Module functionalTestModule = Modules.override(new ProductionModule()).with(new TestModule());

    Prefer to write smaller modules that can be reused and tested without overrides. @param modules the modules whose bindings are open to be overridden]]> Module functionalTestModule = Modules.override(getProductionModules()).with(getTestModules());

    Prefer to write smaller modules that can be reused and tested without overrides. @param modules the modules whose bindings are open to be overridden]]> sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/0000755000175000017500000000000012273115427020047 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/user_comments_for_1.0_to_2.0.xml0000644000175000017500000007006411704661106025766 0ustar tonytony InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere InsertCommentsHere sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/stylesheet-jdiff.css0000644000175000017500000000372211704661106024034 0ustar tonytony /* The JDiff style sheet, derived from the Javadoc style sheet. */ /* Generated by the JDiff Javadoc doclet */ /* (http://www.jdiff.org) */ /* Define colors, fonts and other style attributes here to override the defaults */ /* Page background color */ body { background: #CCFFFF url(background.gif); font-family: arial; } /* Table colors */ .TableHeadingColor { background: #CCCCFF } /* Dark mauve */ .TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ .TableRowColor { background: #FFFFFF } /* White */ /* Font used in left-hand frame lists */ .FrameTitleFont { font-size: normal; font-family: normal } .FrameHeadingFont { font-size: normal; font-family: normal } .FrameItemFont { font-size: normal; font-family: normal } /* Example of smaller, sans-serif font in frames */ /* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */ /* Navigation bar fonts and colors */ .NavBarCell1 { background-color:#FFFFCC;} /* Changed to yellowish to make difference from Javadoc clear */ .NavBarCell1Rev { background-color:#00008B;}/* Dark Blue */ .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} /* Links which become blue when hovered upon and show that they have been visited. */ a.hiddenlink:link {color: black; text-decoration: none} a.hiddenlink:visited {color: purple; text-decoration: none} a.hiddenlink:hover {color: blue; text-decoration: underline;} /* Links which become blue when hovered upon but do not show that they have been visited. */ a.staysblack:link {color: black; text-decoration: none} a.staysblack:visited {color: black; text-decoration: none} a.staysblack:hover {color: blue; text-decoration: underline;} sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/missingSinces.txt0000644000175000017500000001546311704661106023435 0ustar tonytonyOK: com.google.inject.binder.AnnotatedElementBuilder Interface OK: com.google.inject.spi.BindingScopingVisitor Interface OK: com.google.inject.spi.BindingTargetVisitor Interface OK: com.google.inject.ConfigurationException Class OK: com.google.inject.spi.ConstructorBinding Interface OK: com.google.inject.spi.ConvertedConstantBinding Interface OK: com.google.inject.spi.DefaultBindingScopingVisitor Class OK: com.google.inject.spi.DefaultBindingTargetVisitor Class OK: com.google.inject.spi.DefaultElementVisitor Class OK: com.google.inject.spi.Dependency Class OK: com.google.inject.spi.Element Interface OK: com.google.inject.spi.Elements Class OK: com.google.inject.spi.ElementVisitor Interface OK: com.google.inject.Exposed Class OK: com.google.inject.spi.ExposedBinding Interface OK: com.google.inject.servlet.GuiceServletContextListener Class OK: com.google.inject.spi.HasDependencies Interface OK: com.google.inject.spi.InjectionListener Interface OK: com.google.inject.spi.InjectionPoint Class OK: com.google.inject.spi.InjectionRequest Class OK: com.google.inject.spi.InstanceBinding Interface OK: com.google.inject.spi.InterceptorBinding Class OK: com.google.inject.spi.LinkedKeyBinding Interface OK: com.google.inject.MembersInjector Interface OK: com.google.inject.spi.MembersInjectorLookup Class OK: com.google.inject.OutOfScopeException Class OK: com.google.inject.PrivateBinder Interface OK: com.google.inject.spi.PrivateElements Interface OK: com.google.inject.PrivateModule Class OK: com.google.inject.spi.ProviderBinding Interface OK: com.google.inject.spi.ProviderInstanceBinding Interface OK: com.google.inject.spi.ProviderKeyBinding Interface OK: com.google.inject.spi.ProviderLookup Class OK: com.google.inject.spi.ProviderWithDependencies Interface OK: com.google.inject.Provides Class OK: com.google.inject.ProvisionException Class OK: com.google.inject.spi.ScopeBinding Class OK: com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder Interface OK: com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder Interface OK: com.google.inject.spi.StaticInjectionRequest Class OK: com.google.inject.spi.TypeConverter Interface OK: com.google.inject.spi.TypeConverterBinding Class OK: com.google.inject.spi.TypeEncounter Interface OK: com.google.inject.spi.TypeListener Interface OK: com.google.inject.spi.TypeListenerBinding Class OK: com.google.inject.spi.UntargettedBinding Interface OK: com.google.inject.spi.Message Constructor (java.util.List, java.lang.String, java.lang.Throwable) OK: com.google.inject.Binding Method acceptScopingVisitor(com.google.inject.spi.BindingScopingVisitor) OK: com.google.inject.Binding Method acceptTargetVisitor(com.google.inject.spi.BindingTargetVisitor) OK: com.google.inject.spi.Message Method acceptVisitor(com.google.inject.spi.ElementVisitor) OK: com.google.inject.AbstractModule Method addError(com.google.inject.spi.Message) OK: com.google.inject.Binder Method addError(com.google.inject.spi.Message) OK: com.google.inject.spi.Message Method applyTo(com.google.inject.Binder) OK: com.google.inject.AbstractModule Method bindListener(com.google.inject.matcher.Matcher>, com.google.inject.spi.TypeListener) OK: com.google.inject.Binder Method bindListener(com.google.inject.matcher.Matcher>, com.google.inject.spi.TypeListener) OK: com.google.inject.servlet.ServletModule Method configureServlets() OK: com.google.inject.AbstractModule Method convertToTypes(com.google.inject.matcher.Matcher>, com.google.inject.spi.TypeConverter) OK: com.google.inject.Binder Method convertToTypes(com.google.inject.matcher.Matcher>, com.google.inject.spi.TypeConverter) OK: com.google.inject.Injector Method createChildInjector(com.google.inject.Module[]) OK: com.google.inject.Injector Method createChildInjector(java.lang.Iterable) MISSING @SINCE TAG: com.google.inject.Guice Method createInjector(com.google.inject.Stage, java.lang.Iterable) MISSING @SINCE TAG: com.google.inject.Guice Method createInjector(java.lang.Iterable) OK: com.google.inject.AbstractModule Method currentStage() OK: com.google.inject.servlet.ServletModule Method filter(java.lang.String, java.lang.String[]) OK: com.google.inject.servlet.ServletModule Method filterRegex(java.lang.String, java.lang.String[]) OK: com.google.inject.Injector Method getBinding(java.lang.Class) OK: com.google.inject.spi.Message Method getCause() OK: com.google.inject.TypeLiteral Method getExceptionTypes(java.lang.reflect.Member) OK: com.google.inject.TypeLiteral Method getFieldType(java.lang.reflect.Field) OK: com.google.inject.AbstractModule Method getMembersInjector(com.google.inject.TypeLiteral) OK: com.google.inject.AbstractModule Method getMembersInjector(java.lang.Class) OK: com.google.inject.Binder Method getMembersInjector(com.google.inject.TypeLiteral) OK: com.google.inject.Binder Method getMembersInjector(java.lang.Class) OK: com.google.inject.Injector Method getMembersInjector(com.google.inject.TypeLiteral) OK: com.google.inject.Injector Method getMembersInjector(java.lang.Class) OK: com.google.inject.TypeLiteral Method getParameterTypes(java.lang.reflect.Member) OK: com.google.inject.Injector Method getParent() OK: com.google.inject.AbstractModule Method getProvider(com.google.inject.Key) OK: com.google.inject.AbstractModule Method getProvider(java.lang.Class) OK: com.google.inject.Binder Method getProvider(com.google.inject.Key) OK: com.google.inject.Binder Method getProvider(java.lang.Class) OK: com.google.inject.TypeLiteral Method getRawType() OK: com.google.inject.TypeLiteral Method getReturnType(java.lang.reflect.Method) OK: com.google.inject.spi.Message Method getSources() OK: com.google.inject.TypeLiteral Method getSupertype(java.lang.Class) OK: com.google.inject.matcher.Matchers Method inSubpackage(java.lang.String) OK: com.google.inject.Binder Method newPrivateBinder() OK: com.google.inject.AbstractModule Method requestInjection(java.lang.Object) OK: com.google.inject.Binder Method requestInjection(com.google.inject.TypeLiteral, T) OK: com.google.inject.Binder Method requestInjection(java.lang.Object) OK: com.google.inject.AbstractModule Method requireBinding(com.google.inject.Key) OK: com.google.inject.AbstractModule Method requireBinding(java.lang.Class) OK: com.google.inject.servlet.ServletModule Method serve(java.lang.String, java.lang.String[]) OK: com.google.inject.servlet.ServletModule Method serveRegex(java.lang.String, java.lang.String[]) OK: com.google.inject.Binder Method skipSources(java.lang.Class[]) OK: com.google.inject.Binder Method withSource(java.lang.Object) OK: com.google.inject.Scopes Field NO_SCOPE sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/0000755000175000017500000000000011704661106021455 5ustar tonytonysisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/pkg_com.google.inject.struts2.html0000755000175000017500000001337511704661106030151 0ustar tonytony com.google.inject.struts2
    Generated by
    JDiff


    Package com.google.inject.struts2

    Changed Classes
    GuiceObjectFactory @deprecated Use com.google.inject.servlet.Struts2Factory instead.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/pkg_com.google.inject.spi.html0000755000175000017500000005521711704661106027317 0ustar tonytony com.google.inject.spi
    Generated by
    JDiff

    Package com.google.inject.spi

    Removed Classes and Interfaces
    SourceProvider Provides source objects to the com.google.inject.Binder.
    SourceProviders Provides access to the default SourceProvider implementation and common controls for certain implementations.
     

    Added Classes and Interfaces
    BindingScopingVisitor Visits each of the strategies used to scope an injection.
    BindingTargetVisitor Visits each of the strategies used to find an instance to satisfy an injection.
    ConstructorBinding A binding to the constructor of a concrete clss.
    ConvertedConstantBinding A binding created from converting a bound instance to a new type.
    DefaultBindingScopingVisitor No-op visitor for subclassing.
    DefaultBindingTargetVisitor No-op visitor for subclassing.
    DefaultElementVisitor No-op visitor for subclassing.
    Dependency A variable that can be resolved by an injector.
    Element A core component of a module or injector.
    ElementVisitor Visit elements.
    Elements Exposes elements of a module so they can be inspected, validated or rewritten.
    ExposedBinding A binding to a key exposed from an enclosed private environment.
    HasDependencies Implemented by bindings, providers and instances that expose their dependencies explicitly.
    InjectionListener Listens for injections into instances of type {@code I}.
    InjectionPoint A constructor, field or method that can receive injections.
    InjectionRequest A request to inject the instance fields and methods of an instance.
    InstanceBinding A binding to a single instance.
    InterceptorBinding Registration of interceptors for matching methods of matching classes.
    LinkedKeyBinding A binding to a linked key.
    MembersInjectorLookup A lookup of the members injector for a type.
    PrivateElements A private collection of elements that are hidden from the enclosing injector or module by default.
    ProviderBinding A binding to a Provider that delegates to the binding for the provided type.
    ProviderInstanceBinding A binding to a provider instance.
    ProviderKeyBinding A binding to a provider key.
    ProviderLookup A lookup of the provider for a type.
    ProviderWithDependencies A provider with dependencies on other injected types.
    ProviderWithExtensionVisitor A Provider that is part of an extension which supports a custom BindingTargetVisitor.
    ScopeBinding Registration of a scope annotation with the scope that implements it.
    StaticInjectionRequest A request to inject the static fields and methods of a type.
    Toolable Instructs an Injector running in Stage.TOOL that a method should be injected.
    TypeConverter Converts constant string values to a different type.
    TypeConverterBinding Registration of type converters for matching target types.
    TypeEncounter Context of an injectable type encounter.
    TypeListener Listens for Guice to encounter injectable types.
    TypeListenerBinding Binds types (picked using a Matcher) to an type listener.
    UntargettedBinding An untargetted binding.
     

    Changed Classes
    Message An error message and the context in which it occured.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/pkg_com.google.inject.servlet.html0000755000175000017500000002661011704661106030203 0ustar tonytony com.google.inject.servlet
    Generated by
    JDiff

    Package com.google.inject.servlet

    Added Classes and Interfaces
    GuiceServletContextListener As of Guice 2.0 you can still use (your subclasses of) {@code GuiceServletContextListener} class as a logical place to create and configure your injector.
    InstanceFilterBinding A binding to a single instance of a filter.
    InstanceServletBinding A binding to a single instance of a servlet.
    LinkedFilterBinding A linked binding to a filter.
    LinkedServletBinding A linked binding to a servlet.
    ServletModule.FilterKeyBindingBuilder See the EDSL examples at ServletModule.configureServlets()
    ServletModule.ServletKeyBindingBuilder See the EDSL examples at ServletModule.configureServlets()
    ServletModuleTargetVisitor A visitor for the servlet extension.
    Struts2Factory Cleanup up version from Bob's GuiceObjectFactory.
    UriPatternType An enumeration of the available URI-pattern matching styles
     

    Changed Classes
    GuiceFilter

    Apply this filter in web.xml above all other filters (typically), to all requests where you plan to use servlet scopes.

    ServletModule Configures the servlet scopes and creates bindings for the servlet API objects so you can inject the request, response, session, etc.
    ServletScopes Servlet scopes.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/pkg_com.google.inject.name.html0000755000175000017500000001354411704661106027441 0ustar tonytony com.google.inject.name
    Generated by
    JDiff

    Package com.google.inject.name

    Changed Classes
    Names Utility methods for use with {@code @}Named.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/pkg_com.google.inject.matcher.html0000755000175000017500000001334611704661106030144 0ustar tonytony com.google.inject.matcher
    Generated by
    JDiff

    Package com.google.inject.matcher

    Changed Classes
    Matchers Matcher implementations.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/pkg_com.google.inject.html0000755000175000017500000004406111704661106026520 0ustar tonytony com.google.inject
    Generated by
    JDiff

    Package com.google.inject

    Added Classes and Interfaces
    ConfigurationException Thrown when a programming error such as a misplaced annotation, illegal binding, or unsupported scope is found.
    Exposed Acccompanies a {@literal @}Provides method annotation in a private module to indicate that the provided binding is exposed.
    InjectorBuilder The advanced entry point to the Guice framework. Creates Injectors from Modules, allowing many options to be configured for the Injector.
    MembersInjector Injects dependencies into the fields and methods on instances of type {@code T}.
    OutOfScopeException Thrown from Provider.get when an attempt is made to access a scoped object while the scope in question is not currently active.
    PrivateBinder Returns a binder whose configuration information is hidden from its environment by default.
    PrivateModule A module whose configuration information is hidden from its environment by default.
    Provides Annotates methods of a Module to create a provider method binding.
    ProvisionException Indicates that there was a runtime failure while providing an instance.
     

    Changed Classes and Interfaces
    AbstractModule A support class for Modules which reduces repetition and results in a more readable configuration.
    Binder Collects configuration information (primarily bindings) which will be used to create an Injector. Guice provides this object to your application's Module implementors so they may each contribute their own bindings and other registrations.

    The Guice Binding EDSL

    Guice uses an embedded domain-specific language, or EDSL, to help you create bindings simply and readably. This approach is great for overall usability, but it does come with a small cost: it is difficult to learn how to use the Binding EDSL by reading method-level javadocs. Instead, you should consult the series of examples below. To save space, these examples omit the opening {@code binder}, just as you will if your module extends AbstractModule.
         bind(ServiceImpl.class);
    This statement does essentially nothing; it "binds the {@code ServiceImpl} class to itself" and does not change Guice's default behavior. You may still want to use this if you prefer your Module class to serve as an explicit manifest for the services it provides. Also, in rare cases, Guice may be unable to validate a binding at injector creation time unless it is given explicitly.
         bind(Service.class).to(ServiceImpl.class);
    Specifies that a request for a {@code Service} instance with no binding annotations should be treated as if it were a request for a {@code ServiceImpl} instance. This overrides the function of any @ImplementedBy or @ProvidedBy annotations found on {@code Service}, since Guice will have already "moved on" to {@code ServiceImpl} before it reaches the point when it starts looking for these annotations.
         bind(Service.class).toProvider(ServiceProvider.class);
    In this example, {@code ServiceProvider} must extend or implement {@code Provider}. This binding specifies that Guice should resolve an unannotated injection request for {@code Service} by first resolving an instance of {@code ServiceProvider} in the regular way, then calling get() on the resulting Provider instance to obtain the {@code Service} instance.
    Binding A mapping from a key (type and optional annotation) to the strategy for getting instances of the type.
    BindingAnnotation Annotates annotations which are used for binding.
    CreationException Thrown when errors occur while creating a Injector.
    Guice The entry point to the Guice framework. Creates Injectors from Modules. For advanced usage, see InjectorBuilder.
    Injector Builds the graphs of objects that make up your application.
    Key Binding key consisting of an injection type and an optional annotation.
    Module A module contributes configuration information, typically interface bindings, which will be used to create an Injector.
    Provider An object capable of providing instances of type {@code T}.
    Scope A scope is a level of visibility that instances provided by Guice may have.
    ScopeAnnotation Annotates annotations which are used for scoping.
    Scopes Built-in scope implementations.
    TypeLiteral Represents a generic type {@code T}.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/pkg_com.google.inject.binder.html0000755000175000017500000002116711704661106027764 0ustar tonytony com.google.inject.binder
    Generated by
    JDiff

    Package com.google.inject.binder

    Added Interfaces
    AnnotatedElementBuilder See the EDSL examples at com.google.inject.Binder.
     

    Changed Interfaces
    AnnotatedBindingBuilder See the EDSL examples at com.google.inject.Binder.
    AnnotatedConstantBindingBuilder See the EDSL examples at com.google.inject.Binder.
    ConstantBindingBuilder Binds to a constant value.
    LinkedBindingBuilder See the EDSL examples at com.google.inject.Binder.
    ScopedBindingBuilder See the EDSL examples at com.google.inject.Binder.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/packages_index_removals.html0000755000175000017500000000324011704661106027222 0ustar tonytony Package Removals Index
    All Packages
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/packages_index_changes.html0000755000175000017500000000463511704661106027013 0ustar tonytony Package Changes Index
    All Packages
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    com.google.inject
    com.google.inject.binder
    com.google.inject.matcher
    com.google.inject.name
    com.google.inject.servlet
    com.google.inject.spi
    com.google.inject.struts2
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/packages_index_all.html0000755000175000017500000000673211704661106026153 0ustar tonytony Package Differences Index
    All Packages
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    com.google.inject
    com.google.inject.assistedinject
    com.google.inject.binder
    com.google.inject.matcher
    com.google.inject.multibindings
    com.google.inject.name
    com.google.inject.persist
    com.google.inject.persist.finder
    com.google.inject.persist.jpa
    com.google.inject.servlet
    com.google.inject.spi
    com.google.inject.struts2
    com.google.inject.throwingproviders
    com.google.inject.util
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/packages_index_additions.html0000755000175000017500000000520011704661106027346 0ustar tonytony Package Additions Index
    All Packages
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    com.google.inject.assistedinject
    com.google.inject.multibindings
    com.google.inject.persist
    com.google.inject.persist.finder
    com.google.inject.persist.jpa
    com.google.inject.throwingproviders
    com.google.inject.util
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/methods_index_removals.html0000755000175000017500000001071111704661106027110 0ustar tonytony Method Removals Index
    All Methods
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    C  G T TOP
    createInjector
      type  (Stage, Iterable<Module>) in com.google.inject.Guice
      type  (Iterable<Module>) in com.google.inject.Guice

    G  C T TOP
    getSource ()
    getSourceString ()

    T  C G TOP
    toProvider
      type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Provider<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/methods_index_changes.html0000755000175000017500000004602511704661106026677 0ustar tonytony Method Changes Index
    All Methods
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    A  B C E F G H I S T TOP
    annotatedWith
      type  (Class<Annotation>) in com.google.inject.binder.AnnotatedBindingBuilder
      type  (Annotation) in com.google.inject.binder.AnnotatedBindingBuilder
      type  (Class<Annotation>) in com.google.inject.binder.AnnotatedConstantBindingBuilder
      type  (Annotation) in com.google.inject.binder.AnnotatedConstantBindingBuilder
    asEagerSingleton ()

    B  A C E F G H I S T TOP
    bind
      type  (TypeLiteral<T>) in com.google.inject.Binder
      type  (Class<T>) in com.google.inject.Binder
      type  (Key<T>) in com.google.inject.Binder
    bindConstant ()
    bindInterceptor
      type  (Matcher<Class<?>>, Matcher<Method>, MethodInterceptor[]) in com.google.inject.AbstractModule
      type  (Matcher<Class<?>>, Matcher<Method>, MethodInterceptor[]) in com.google.inject.Binder
    bindProperties
      type  (Binder, Map<String, String>) in com.google.inject.name.Names
      type  (Binder, Properties) in com.google.inject.name.Names

    C  A B E F G H I S T TOP
    configure
      type  (Binder) in com.google.inject.Module
      type  () in com.google.inject.servlet.ServletModule
    createInjector
      type  (Module[]) in com.google.inject.Guice
      type  (Stage, Module[]) in com.google.inject.Guice

    E  A B C F G H I S T TOP
    equals
      type  (Object) in com.google.inject.Key
      type  (Object) in com.google.inject.TypeLiteral

    F  A B C E G H I S T TOP
    findBindingsByType (TypeLiteral<T>)

    G  A B C E F H I S T TOP
    get ()
    getAnnotation ()
    getAnnotationType ()
    getBinding (Key<T>)
    getBindings ()
    getErrorMessages ()
    getInstance
      type  (Key<T>) in com.google.inject.Injector
      type  (Class<T>) in com.google.inject.Injector
    getProvider
      type  () in com.google.inject.Binding
      type  (Key<T>) in com.google.inject.Injector
      type  (Class<T>) in com.google.inject.Injector
    getSource ()
    getType ()
    getTypeLiteral ()

    H  A B C E F G I S T TOP
    hashCode
      type  () in com.google.inject.Key
      type  () in com.google.inject.TypeLiteral

    I  A B C E F G H S T TOP
    in
      type  (Scope) in com.google.inject.binder.ScopedBindingBuilder
      type  (Class<Annotation>) in com.google.inject.binder.ScopedBindingBuilder
    injectMembers (Object)
    inPackage (Package)

    S  A B C E F G H I T TOP
    scope (Key<T>, Provider<T>)

    T  A B C E F G H I S TOP
    to
      type  (Key<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (TypeLiteral<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Class<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
    toInstance (T)
    toString
      type  () in com.google.inject.Key
      type  () in com.google.inject.TypeLiteral
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/methods_index_all.html0000755000175000017500000013051411704661106026034 0ustar tonytony Method Differences Index
    All Methods
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    A  B C E F G H I N O R S T W TOP
    acceptScopingVisitor (BindingScopingVisitor<V>)
    acceptTargetVisitor (BindingTargetVisitor<? super T, V>)
    acceptVisitor (ElementVisitor<T>)
    addError
      type  (Message) in com.google.inject.AbstractModule
      type  (Message) in com.google.inject.Binder
    annotatedWith
      type  (Class<Annotation>) in com.google.inject.binder.AnnotatedBindingBuilder
      type  (Annotation) in com.google.inject.binder.AnnotatedBindingBuilder
      type  (Class<Annotation>) in com.google.inject.binder.AnnotatedConstantBindingBuilder
      type  (Annotation) in com.google.inject.binder.AnnotatedConstantBindingBuilder
    applyTo (Binder)
    asEagerSingleton ()

    B  A C E F G H I N O R S T W TOP
    bind
      type  (TypeLiteral<T>) in com.google.inject.Binder
      type  (Class<T>) in com.google.inject.Binder
      type  (Key<T>) in com.google.inject.Binder
    bindConstant ()
    bindInterceptor
      type  (Matcher<Class<?>>, Matcher<Method>, MethodInterceptor[]) in com.google.inject.AbstractModule
      type  (Matcher<Class<?>>, Matcher<Method>, MethodInterceptor[]) in com.google.inject.Binder
    bindListener
      type  (Matcher<TypeLiteral<?>>, TypeListener) in com.google.inject.AbstractModule
      type  (Matcher<TypeLiteral<?>>, TypeListener) in com.google.inject.Binder
    bindProperties
      type  (Binder, Map<String, String>) in com.google.inject.name.Names
      type  (Binder, Properties) in com.google.inject.name.Names

    C  A B E F G H I N O R S T W TOP
    configure
      type  (Binder) in com.google.inject.Module
      type  () in com.google.inject.servlet.ServletModule
    configureServlets ()
    continueRequest (Callable<T>, Map<Key<?>, Object>)
    convertToTypes
      type  (Matcher<TypeLiteral<?>>, TypeConverter) in com.google.inject.AbstractModule
      type  (Matcher<TypeLiteral<?>>, TypeConverter) in com.google.inject.Binder
    createChildInjector
      type  (Module[]) in com.google.inject.Injector
      type  (Iterable<Module>) in com.google.inject.Injector
    createInjector
      type  (Stage, Iterable<Module>) in com.google.inject.Guice
      type  (Iterable<Module>) in com.google.inject.Guice
      type  (Stage, Iterable<Module>) in com.google.inject.Guice
      type  (Iterable<Module>) in com.google.inject.Guice
      type  (Module[]) in com.google.inject.Guice
      type  (Stage, Module[]) in com.google.inject.Guice
    currentStage ()

    E  A B C F G H I N O R S T W TOP
    equals
      type  (Object) in com.google.inject.Key
      type  (Object) in com.google.inject.TypeLiteral

    F  A B C E G H I N O R S T W TOP
    filter (String, String[])
    filterRegex (String, String[])
    findBindingsByType (TypeLiteral<T>)

    G  A B C E F H I N O R S T W TOP
    get ()
    getAllBindings ()
    getAnnotation ()
    getAnnotationType ()
    getBinding
      type  (Class<T>) in com.google.inject.Injector
      type  (Key<T>) in com.google.inject.Injector
    getBindings ()
    getCause ()
    getErrorMessages ()
    getExceptionTypes (Member)
    getExistingBinding (Key<T>)
    getFieldType (Field)
    getInstance
      type  (Key<T>) in com.google.inject.Injector
      type  (Class<T>) in com.google.inject.Injector
    getMembersInjector
      type  (TypeLiteral<T>) in com.google.inject.AbstractModule
      type  (Class<T>) in com.google.inject.AbstractModule
      type  (TypeLiteral<T>) in com.google.inject.Binder
      type  (Class<T>) in com.google.inject.Binder
      type  (TypeLiteral<T>) in com.google.inject.Injector
      type  (Class<T>) in com.google.inject.Injector
    getParameterTypes (Member)
    getParent ()
    getProvider
      type  (Key<T>) in com.google.inject.AbstractModule
      type  (Class<T>) in com.google.inject.AbstractModule
      type  (Key<T>) in com.google.inject.Binder
      type  (Class<T>) in com.google.inject.Binder
      type  () in com.google.inject.Binding
      type  (Key<T>) in com.google.inject.Injector
      type  (Class<T>) in com.google.inject.Injector
    getRawType ()
    getReturnType (Method)
    getScopeBindings ()
    getServletContext ()
    getSource
      type  () in com.google.inject.Binding
      type  () in com.google.inject.spi.Message
    getSources ()
    getSourceString ()
    getSupertype (Class<?>)
    getType ()
    getTypeLiteral ()

    H  A B C E F G I N O R S T W TOP
    hasAttributes ()
    hashCode
      type  () in com.google.inject.Key
      type  () in com.google.inject.TypeLiteral

    I  A B C E F G H N O R S T W TOP
    in
      type  (Scope) in com.google.inject.binder.ScopedBindingBuilder
      type  (Class<Annotation>) in com.google.inject.binder.ScopedBindingBuilder
    injectMembers (Object)
    inPackage (Package)
    inSubpackage (String)
    isSingleton (Binding<?>)

    N  A B C E F G H I O R S T W TOP
    newPrivateBinder ()

    O  A B C E F G H I N R S T W TOP
    ofType
      type  (Type) in com.google.inject.Key
      type  (TypeLiteral<T>) in com.google.inject.Key
      type  (Class<T>) in com.google.inject.Key

    R  A B C E F G H I N O S T W TOP
    requestInjection
      type  (Object) in com.google.inject.AbstractModule
      type  (TypeLiteral<T>, T) in com.google.inject.Binder
      type  (Object) in com.google.inject.Binder
    requireBinding
      type  (Key<?>) in com.google.inject.AbstractModule
      type  (Class<?>) in com.google.inject.AbstractModule

    S  A B C E F G H I N O R T W TOP
    scope (Key<T>, Provider<T>)
    scopeRequest (Callable<T>, Map<Key<?>, Object>)
    serve (String, String[])
    serveRegex (String, String[])
    skipSources (Class[])

    T  A B C E F G H I N O R S W TOP
    to
      type  (byte) in com.google.inject.binder.ConstantBindingBuilder
      type  (Key<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (TypeLiteral<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Class<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
    toConstructor
      type  (Constructor<S>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Constructor<S>, TypeLiteral<? extends S>) in com.google.inject.binder.LinkedBindingBuilder
    toInstance (T)
    toProvider
      type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Provider<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Provider<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (TypeLiteral<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
    toString
      type  () in com.google.inject.Key
      type  () in com.google.inject.TypeLiteral

    W  A B C E F G H I N O R S T TOP
    withoutAttributes ()
    withSource (Object)
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/methods_index_additions.html0000755000175000017500000007023411704661106027244 0ustar tonytony Method Additions Index
    All Methods
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    A  B C F G H I N O R S T W TOP
    acceptScopingVisitor (BindingScopingVisitor<V>)
    acceptTargetVisitor (BindingTargetVisitor<? super T, V>)
    acceptVisitor (ElementVisitor<T>)
    addError
      type  (Message) in com.google.inject.AbstractModule
      type  (Message) in com.google.inject.Binder
    applyTo (Binder)

    B  A C F G H I N O R S T W TOP
    bindListener
      type  (Matcher<TypeLiteral<?>>, TypeListener) in com.google.inject.AbstractModule
      type  (Matcher<TypeLiteral<?>>, TypeListener) in com.google.inject.Binder

    C  A B F G H I N O R S T W TOP
    configureServlets ()
    continueRequest (Callable<T>, Map<Key<?>, Object>)
    convertToTypes
      type  (Matcher<TypeLiteral<?>>, TypeConverter) in com.google.inject.AbstractModule
      type  (Matcher<TypeLiteral<?>>, TypeConverter) in com.google.inject.Binder
    createChildInjector
      type  (Module[]) in com.google.inject.Injector
      type  (Iterable<Module>) in com.google.inject.Injector
    createInjector
      type  (Stage, Iterable<Module>) in com.google.inject.Guice
      type  (Iterable<Module>) in com.google.inject.Guice
    currentStage ()

    F  A B C G H I N O R S T W TOP
    filter (String, String[])
    filterRegex (String, String[])

    G  A B C F H I N O R S T W TOP
    getAllBindings ()
    getBinding (Class<T>)
    getCause ()
    getExceptionTypes (Member)
    getExistingBinding (Key<T>)
    getFieldType (Field)
    getMembersInjector
      type  (TypeLiteral<T>) in com.google.inject.AbstractModule
      type  (Class<T>) in com.google.inject.AbstractModule
      type  (TypeLiteral<T>) in com.google.inject.Binder
      type  (Class<T>) in com.google.inject.Binder
      type  (TypeLiteral<T>) in com.google.inject.Injector
      type  (Class<T>) in com.google.inject.Injector
    getParameterTypes (Member)
    getParent ()
    getProvider
      type  (Key<T>) in com.google.inject.AbstractModule
      type  (Class<T>) in com.google.inject.AbstractModule
      type  (Key<T>) in com.google.inject.Binder
      type  (Class<T>) in com.google.inject.Binder
    getRawType ()
    getReturnType (Method)
    getScopeBindings ()
    getServletContext ()
    getSources ()
    getSupertype (Class<?>)

    H  A B C F G I N O R S T W TOP
    hasAttributes ()

    I  A B C F G H N O R S T W TOP
    inSubpackage (String)
    isSingleton (Binding<?>)

    N  A B C F G H I O R S T W TOP
    newPrivateBinder ()

    O  A B C F G H I N R S T W TOP
    ofType
      type  (Type) in com.google.inject.Key
      type  (TypeLiteral<T>) in com.google.inject.Key
      type  (Class<T>) in com.google.inject.Key

    R  A B C F G H I N O S T W TOP
    requestInjection
      type  (Object) in com.google.inject.AbstractModule
      type  (TypeLiteral<T>, T) in com.google.inject.Binder
      type  (Object) in com.google.inject.Binder
    requireBinding
      type  (Key<?>) in com.google.inject.AbstractModule
      type  (Class<?>) in com.google.inject.AbstractModule

    S  A B C F G H I N O R T W TOP
    scopeRequest (Callable<T>, Map<Key<?>, Object>)
    serve (String, String[])
    serveRegex (String, String[])
    skipSources (Class[])

    T  A B C F G H I N O R S W TOP
    to (byte)
    toConstructor
      type  (Constructor<S>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Constructor<S>, TypeLiteral<? extends S>) in com.google.inject.binder.LinkedBindingBuilder
    toProvider
      type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Provider<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (TypeLiteral<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder

    W  A B C F G H I N O R S T TOP
    withoutAttributes ()
    withSource (Object)
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/jdiff_topleftframe.html0000755000175000017500000000375011704661106026205 0ustar tonytony JDiff
    JDiff Indexes
    All Differences
    By Package
    By Class
    By Constructor
    By Method
    By Field
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/jdiff_statistics.html0000755000175000017500000004073211704661106025710 0ustar tonytony JDiff Statistics
    Generated by
    JDiff

    JDiff Statistics

    The percent change statistic reported for all elements in each API is defined recursively as follows:
    Percentage difference = 100 * (added + removed + 2*changed)
                            -----------------------------------
                            sum of public elements in BOTH APIs
    
    Where added is the number of packages added, removed is the number of packages removed, and changed is the number of packages changed. This definition is applied recursively for the classes and their program elements, so the value for a changed package will be less than 1, unless every class in that package has changed. The definition ensures that if all packages are removed and all new packages are added, the change will be 100%. Values are rounded here, so a value of 0% indicates a percentage difference of less than 0.5%.

    The overall difference between the two APIs is approximately 50%.

    Sections

    Packages sorted by percentage difference
    Classes and Interfaces sorted by percentage difference
    Differences by number and type

    Packages Sorted By Percentage Difference

    Percentage
    Difference
    Package
    96 com.google.inject.spi
    78 com.google.inject.binder
    56 com.google.inject.servlet
    54 com.google.inject
    33 com.google.inject.name
    10 com.google.inject.struts2
    3 com.google.inject.matcher

    Percentage
    Difference
    Frequency Percentage Frequency
    3 0.14285714285714285 |
    10 0.14285714285714285 |
    33 0.14285714285714285 |
    54 0.14285714285714285 |
    56 0.14285714285714285 |
    78 0.14285714285714285 |
    96 0.14285714285714285 |


    Classes and Interfaces Sorted By Percentage Difference

    Percentage
    Difference
    Class or Interface
    100 com.google.inject.Guice
    100 com.google.inject.binder.AnnotatedBindingBuilder
    100 com.google.inject.binder.AnnotatedConstantBindingBuilder
    94 com.google.inject.binder.LinkedBindingBuilder
    88 com.google.inject.Injector
    83 com.google.inject.binder.ScopedBindingBuilder
    80 com.google.inject.servlet.ServletModule
    66 com.google.inject.name.Names
    58 com.google.inject.Binder
    57 com.google.inject.Binding
    50 com.google.inject.Module
    50 com.google.inject.Provider
    50 com.google.inject.Scopes
    50 com.google.inject.TypeLiteral
    35 com.google.inject.spi.Message
    33 com.google.inject.CreationException
    33 com.google.inject.servlet.ServletScopes
    30 com.google.inject.AbstractModule
    26 com.google.inject.Key
    25 com.google.inject.Scope
    12 com.google.inject.servlet.GuiceFilter
    10 com.google.inject.matcher.Matchers
    10 com.google.inject.struts2.GuiceObjectFactory
    4 com.google.inject.binder.ConstantBindingBuilder
    <1 com.google.inject.BindingAnnotation
    <1 com.google.inject.ScopeAnnotation

    Percentage
    Difference
    Frequency Percentage Frequency
    0 0.07692307692307693 |
    4 0.038461538461538464 |
    10 0.07692307692307693 |
    12 0.038461538461538464 |
    25 0.038461538461538464 |
    26 0.038461538461538464 |
    30 0.038461538461538464 |
    33 0.07692307692307693 |
    35 0.038461538461538464 |
    50 0.15384615384615385 |
    57 0.038461538461538464 |
    58 0.038461538461538464 |
    66 0.038461538461538464 |
    80 0.038461538461538464 |
    83 0.038461538461538464 |
    88 0.038461538461538464 |
    94 0.038461538461538464 |
    100 0.11538461538461539 |


    Differences By Number and Type

    The numbers of program elements (packages, classes. constructors, methods and fields) which are recorded as removed, added or changed includes only the highest-level program elements. That is, if a class with two methods was added, the number of methods added does not include those two methods, but the number of classes added does include that class.
    Number of Differences
      Removals Additions Changes Total
    Packages 0 7 7 14
    Classes and Interfaces 2 56 26 84
    Constructors 0 1 1 2
    Methods 7 68 47 122
    Fields 0 1 0 1
    Total 9 133 81 223
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/jdiff_help.html0000755000175000017500000001427111704661106024445 0ustar tonytony JDiff Help
    Generated by
    JDiff

    JDiff Documentation

    JDiff is a Javadoc doclet which generates a report of the API differences between two versions of a product. It does not report changes in Javadoc comments, or changes in what a class or method does. This help page describes the different parts of the output from JDiff.
    See the reference page in the source for JDiff for information about how to generate a report like this one.
    The indexes shown in the top-left frame help show each type of change in more detail. The index "All Differences" contains all the differences between the APIs, in alphabetical order. These indexes all use the same format:
    • Removed packages, classes, constructors, methods and fields are struck through.
    • Added packages, classes, constructors, methods and fields appear in bold.
    • Changed packages, classes, constructors, methods and fields appear in normal text.
    You can always tell when you are reading a JDiff page, rather than a Javadoc page, by the color of the index bar and the color of the background. Links which take you to a Javadoc page are always in a typewriter font. Just like Javadoc, all interface names are in italic, and class names are not italicized. Where there are multiple entries in an index with the same name, the heading for them is also in italics, but is not a link.

    Javadoc

    This is a link to the top-level Javadoc page for the new version of the product.

    Overview

    The overview is the top-level summary of what was removed, added and changed between versions.

    Package

    This is a link to the package containing the current changed class or interface.

    Class

    This is highlighted when you are looking at the changed class or interface.

    Text Changes

    This is a link to the top-level index of all documentation changes for the current package or class. If it is not present, then there are no documentation changes for the current package or class. This link can be removed entirely by not using the -docchanges option.

    Statistics

    This is a link to a page which shows statistics about the changes between the two APIs. This link can be removed entirely by not using the -stats option.

    Help

    A link to this Help page for JDiff.

    Prev/Next

    These links take you to the previous and next changed package or class.

    Frames/No Frames

    These links show and hide the HTML frames. All pages are available with or without frames.

    Complex Changes

    There are some complex changes which can occur between versions, for example, when two or more methods with the same name change simultaneously, or when a method or field is moved into or from a superclass. In these cases, the change will be seen as a removal and an addition, rather than as a change. Unexpected removals or additions are often part of one of these type of changes.
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/fields_index_removals.html0000755000175000017500000000316111704661106026714 0ustar tonytony Field Removals Index
    All Fields
    Removals
    Additions
    Changes
    Bold is New, strike is deleted

    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/fields_index_changes.html0000755000175000017500000000316011704661106026473 0ustar tonytony Field Changes Index
    All Fields
    Removals
    Additions
    Changes
    Bold is New, strike is deleted

    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/fields_index_all.html0000755000175000017500000000357011704661106025640 0ustar tonytony Field Differences Index
    All Fields
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    N  TOP
    NO_SCOPE
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/fields_index_additions.html0000755000175000017500000000350111704661106027040 0ustar tonytony Field Additions Index
    All Fields
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    N  TOP
    NO_SCOPE
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/docdiffs_index.html0000755000175000017500000003244611704661106025327 0ustar tonytony All Documentation Differences
    Generated by
    JDiff

    All Documentation Differences

    Package com.google.inject
      Class AbstractModule

      Class Binder
        Method bind(Class<T>)
        Method bind(Key<T>)
        Method bind(TypeLiteral<T>)
        Method bindConstant()
        Method bindInterceptor(Matcher<Class<?>>, Matcher<Method>, MethodInterceptor[])

      Class Binding
        Method getProvider()

      Class BindingAnnotation

      Class CreationException
        CreationException(Collection<Message>)
        Method getErrorMessages()

      Class Guice
        Method createInjector(Module[])
        Method createInjector(Stage, Module[])

      Class Injector
        Method findBindingsByType(TypeLiteral<T>)
        Method getBinding(Key<T>)
        Method getBindings()
        Method getInstance(Class<T>)
        Method getInstance(Key<T>)
        Method getProvider(Class<T>)
        Method getProvider(Key<T>)
        Method injectMembers(Object)

      Class Key

      Class Module
        Method configure(Binder)

      Class Provider
        Method get()

      Class Scope
        Method scope(Key<T>, Provider<T>)

      Class ScopeAnnotation

      Class Scopes

      Class TypeLiteral

    Package com.google.inject.binder
      Class AnnotatedBindingBuilder
        Method annotatedWith(Annotation)
        Method annotatedWith(Class<Annotation>)

      Class AnnotatedConstantBindingBuilder
        Method annotatedWith(Annotation)
        Method annotatedWith(Class<Annotation>)

      Class LinkedBindingBuilder
        Method to(Class<? extends T>)
        Method to(Key<? extends T>)
        Method to(TypeLiteral<? extends T>)
        Method toInstance(T)

      Class ScopedBindingBuilder
        Method asEagerSingleton()
        Method in(Class<Annotation>)
        Method in(Scope)

    Package com.google.inject.matcher
      Class Matchers
        Method inPackage(Package)

    Package com.google.inject.name
      Class Names
        Method bindProperties(Binder, Map<String, String>)
        Method bindProperties(Binder, Properties)

    Package com.google.inject.servlet
      Class GuiceFilter

      Class ServletModule

    Package com.google.inject.spi
      Class Message
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/docdiffs_com.google.inject.spi.html0000755000175000017500000001251511704661106030311 0ustar tonytony com.google.inject.spi Documentation Differences
    Generated by
    JDiff

    com.google.inject.spi Documentation Differences

    This file contains all the changes in documentation in the package com.google.inject.spi as colored differences. Deletions are shown like this, and additions are shown like this.
    If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
    Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

    Class Message

    AAn error message. Contains a sourceand the context pointingin which toit theoccured. code which resulted in thisMessages are usually created internally messageby Guice and its extensions. Messages can be created explicitly in a textmodule message.using addError() statements:
         try {
           bindPropertiesFromFile();
         } catch (IOException e) {
           addError(e);
         }
    @author crazybob@google.com (Bob Lee)
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/docdiffs_com.google.inject.servlet.html0000755000175000017500000001447411704661106031210 0ustar tonytony com.google.inject.servlet Documentation Differences
    Generated by
    JDiff

    com.google.inject.servlet Documentation Differences

    This file contains all the changes in documentation in the package com.google.inject.servlet as colored differences. Deletions are shown like this, and additions are shown like this.
    If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
    Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

    Class GuiceFilter

    Apply this filter in web.xml above all other filters (typically), to all requests where you planplan to use servlet scopes. This is also needed in order to dispatch requests to injectable filters and servlets:

      <filter>
        <filter-name>guiceFilter</filter-name>
        <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
      </filter>
    
      <filter-mapping>
        <filter-name>guiceFilter</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
      
    This filter must appear before every filter that makes use of Guice injection or servlet scopes functionality. Typically, you will only register this filter in web.xml and register any other filters (and servlets) using a ServletModule. @author crazybob@google.com (Bob Lee) @author dhanji@gmail.com (Dhanji R. Prasanna)

    Class ServletModule

    Configures the servlet scopes and creates bindings for the servlet API objects so you can inject the request, response, session, etc.

    You should subclass this module to register servlets and filters in the .configureServlets() method. @author crazybob@google.com (Bob Lee) @author dhanji@gmail.com (Dhanji R. Prasanna)


    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/docdiffs_com.google.inject.name.html0000755000175000017500000001257711704661106030446 0ustar tonytony com.google.inject.name Documentation Differences
    Generated by
    JDiff

    com.google.inject.name Documentation Differences

    This file contains all the changes in documentation in the package com.google.inject.name as colored differences. Deletions are shown like this, and additions are shown like this.
    If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
    Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

    Class Names, void bindProperties(Binder, Map<String, String>)

    Creates a constant binding to {@code @Named(key)} for each propertyentry in {@code properties}.
    Class Names, void bindProperties(Binder, Properties)

    Creates a constant binding to {@code @Named(key)} for each property. This method binds all properties including those inherited from defaults.

    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/docdiffs_com.google.inject.matcher.html0000755000175000017500000001125011704661106031134 0ustar tonytony com.google.inject.matcher Documentation Differences
    Generated by
    JDiff

    com.google.inject.matcher Documentation Differences

    This file contains all the changes in documentation in the package com.google.inject.matcher as colored differences. Deletions are shown like this, and additions are shown like this.
    If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
    Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

    Class Matchers, Matcher<Class> inPackage(Package)

    Returns a matcher which matches classes in the given package. Packages are specific to their classloader, so classes with the same package name may not have the same package at runtime.

    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/docdiffs_com.google.inject.html0000755000175000017500000020247111704661106027521 0ustar tonytony com.google.inject Documentation Differences
    Generated by
    JDiff

    com.google.inject Documentation Differences

    This file contains all the changes in documentation in the package com.google.inject as colored differences. Deletions are shown like this, and additions are shown like this.
    If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
    Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

    Class AbstractModule

    A support class for Modules which reduces repetition and results in a more readable configuration. Simply extend this class, implement .configure(), and call the inherited methods which mirror those found in Binder. For example:
     import static com.google.inject.Names.named;
    
     public class MyModule extends AbstractModule {
       protected void configure() {
         bind(FooService.class).to(FooImplServiceImpl.class).in(ScopesSingleton.SINGLETONclass);
         bind(BarImplCreditCardPaymentService.class);
         linkbind(BarPaymentService.class).to(BarImplCreditCardPaymentService.class);
         bindConstant().annotatedWith(Names.named("port")).to(8080);
       }
     }
     
    @author crazybob@google.com (Bob Lee)

    Class Binder

    Collects configuration information (primarily bindings) which will be used to create an Injector. Guice provides this object to your application's Modules implementors so they may each contribute their own bindings and other registrations.

    The Guice Binding EDSL

    Guice uses an embedded domain-specific language, or EDSL, to help you create bindings contributedsimply and readably. This approach is great for overall usability, but it does come with a small cost: it is difficult to learn how to use the Binding EDSL by reading method-level javadocs. Instead, you should consult the series of examples below. To save space, these examples omit the opening {@code Modulebinder}s, definejust howas you will if your module extends AbstractModule.
    
         bind(ServiceImpl.class);
    This statement does essentially nothing; it "binds the {@code Injectorcode ServiceImpl} class to itself" and does not change Guice's resolves dependenciesdefault behavior. A You may still want to use this if you prefer your KeyModule consistingclass ofto serve as an explicit manifest for the services it provides. Also, in rare cases, Guice may be unable to validate a type and optionalbinding at injector annotationcreation time unless it is given explicitly.
         bind(Service.class).to(ServiceImpl.class);
    Specifies that
    uniquelya request for a {@code Service} instance with no identifiesbinding annotations should be treated as if it were a request for a {@code ServiceImpl} instance. This overrides the function of any @ImplementedBy or @ProvidedBy annotations found on {@code Service}, since Guice will have already "moved on" to {@code ServiceImpl} before it reaches the point when it starts looking for these annotations.
         bind(Service.class).toProvider(ServiceProvider.class);
    In this example, {@code ServiceProvider} must extend or implement {@code Provider}. This
    binding withinspecifies that Guice should resolve an unannotated injection request for {@code code InjectorService} by first resolving an instance of {@code ServiceProvider} in the regular way, then calling get() on the resulting Provider instance to obtain the {@code Service} instance.

    YouThe mayProvider bind fromyou use ahere does not keyhave to: be Anothera binding"factory"; that is, a provider which always creates each instance it provides. However, this bindingis generally a good practice to follow. You can then use Guice's key isconcept of nowscopes to guide when creation should happen -- "aliasedletting toGuice work for you".

    
     Another    bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);
    Like the previous example, but only applies to injection requests that use the binding annotation {@code @Red}. If your module also includes bindings for particular values of the {@code @Red} annotation (see below), whichthen this binding referenceswill serve as a Provider"catch-all" for any values of {@code @Red} that have no exact match in the bindings.
         bind(ServiceImpl.class).in(Singleton.class);
         // or, alternatively
         bind(ServiceImpl.class).in(Scopes.SINGLETON);
    Either of these statements places the {@code ServiceImpl} class into singleton scope. Guice will create only one instance of {@code ServiceImpl} and will reuse
    it for all injection requests of this key type. ANote preconstructed instance that it Ais preconstructedstill possible to bind another instance whichof should{@code beServiceImpl} usedif the second binding is qualified by an annotation as in the previous example. Guice is not overly concerned with preventing you from creating multiple instances of your "singletons", only with enabling your application to share only one instance if that's all you tell Guice you need.

    Note: a scope specified in this way overrides any scope that was specified with an annotation on the {@code ServiceImpl} class.

    Besides ProviderSingleton /Scopes.SINGLETON, there are servlet-specific scopes available in {@code com.google.inject.servlet.ServletScopes}, and your Modules can contribute their own custom scopes for this binding use here as well. In

    
     addition,    bind(new TypeLiteral<PaymentService<CreditCard>>() {})
             .to(CreditCardPaymentService.class);
    This admittedly odd construct is the way to bind
    a bindingparameterized maytype. haveIt tells Guice how to honor an associatedinjection scoperequest for an element of type {@code PaymentService}. The class {@code CreditCardPaymentService} must implement the {@code PaymentService} interface. Guice cannot currently bind or inject a generic type, such as as Scopes{@code Set}; all type parameters must be fully specified.SINGLETON
         bind(Service.class).toInstance(new ServiceImpl());
         // or, alternatively
         bind(Service.class).toInstance(SomeLegacyRegistry.getService());
    In this example, your module itself, not Guice, takes responsibility for obtaining a {@code ServiceImpl} instance, then asks Guice to always use this single instance to fulfill all {@code Service} injection requests. When the Injector
    is created, it will automatically perform field and singleton bindingsmethod injection mayfor this instance, but any injectable constructor on {@code ServiceImpl} is simply ignored. specify Note that using this approach results in "eager orloading" behavior that you lazy can't initializationcontrol. See
    
     the    bindConstant().annotatedWith(ServerHost.class).to(args[0]);
    Sets up a constant binding. Constant injections must always be annotated. When a constant usersbinding's guidevalue is a string, it is eligile for conversion to all primitive types, to appendixall enums, and to class literals. Conversions for other types can be configured using convertToTypes().
       {@literal @}Color("red") Color red; // A member variable (field)
        . . .
         red = MyModule.class.getDeclaredField("red"How).getAnnotation(Color.class);
         bind(Service.class).annotatedWith(red).to(RedService.class);
    If your binding annotation has parameters you can apply different bindings to different specific values of your
    annotation. Getting your hands on the right instance of the Injector resolves injection annotation is a requestsbit of a pain -- one approach, shown above, is to apply a prototype annotation to a field in your module class, so that you can read this annotation instance and give it to Guice.
         bind(Service.class)
             .annotatedWith(Names.named("blue"))
             .to(BlueService.class);
    Differentiating by names is a
    better understandcommon enough use case that we provided a standard annotation, @Named. Because of Guice's library support, binding by name is quite easier than in the arbitrary binding resolutionannotation case we just saw. However, remember that these names will live in a single flat namespace with all the other names used in your application. After
    
     an    Constructor loneCtor = getLoneCtorFromServiceImplViaReflection();
         bind(ServiceImpl.class)
             .toConstructor(loneCtor);
    In this example, we directly tell Guice which constructor to use in a concrete class implementation. It means that we do not need to place {@code Injectorliteral @}Inject has beenon any created,of its bindings maythe constructors and be that Guice treats the provided constructor as though it were annotated so. It is useful for cases where you cannot modify existing classes and is a bit examinedsimpler than using a Provider.

    The above list of examples is far from exhaustive. If you can think of how the concepts of one example might coexist with the concepts from another, you can most likely weave the two together. If the two concepts make no sense with each other, you most likely won't be able to do it. In a few cases Guice will let something bogus slip by, and will then inform you of the problems at runtime, as soon as you try to create your Injector.

    The other methods likeof Binder such as Injector.getBinding(Key)bindScope, but.bindInterceptor, this .install, read-only.requestStaticInjection, Binding.addError typeand is.currentStage are not used whenpart of creatingthe the Binding bindingsEDSL; you can learn how to use these in the usual way, from the method documentation. @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson) @author kevinb@google.com (Kevin Bourrillion)

    Class Binder, AnnotatedBindingBuilder<T> bind(Class<T>)

    Creates a binding to aSee the EDSL examples at typeBinder.
    Class Binder, LinkedBindingBuilder<T> bind(Key<T>)

    Creates a binding to aSee the EDSL examples at keyBinder.
    Class Binder, AnnotatedBindingBuilder<T> bind(TypeLiteral<T>)

    Creates a binding to aSee the EDSL examples at typeBinder.
    Class Binder, AnnotatedConstantBindingBuilder bindConstant()

    Binds a constant value toSee the EDSL examples at an annotationBinder.
    Class Binder, void bindInterceptor(Matcher<Class<?>>, Matcher<Method>, MethodInterceptor[])

    Binds a method interceptor[s] to methods matched by class and method method matchers. A method is eligible for interception if:
    • Guice created the instance the method is on
    • Neither the enclosing type nor the method is final
    • And the method is package-private, protected, or public
    @param classMatcher matches classes the interceptor should apply to. For example: {@code only(Runnable.class)}. @param methodMatcher matches methods the interceptor should apply to. For example: {@code annotatedWith(Transactional.class)}. @param interceptors to bind

    Class Binding

    A mapping from a key (type and optional annotation) to athe providerstrategy for of getting instances of thatthe type. This interface is part of the Injector introspection API and is intended primaryprimarily for use by tools.

    Bindings are created in several ways:

    • Explicitly in a module, via {@code bind()} and {@code bindConstant()} statements:
           bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);
           bindConstant().annotatedWith(ServerHost.class).to(args[0]);
    • Implicitly by the Injector by following a type's pointer annotations or by using its annotated or default constructor.
    • By converting a bound instance to a different type.
    • For providers, by delegating to the binding for the provided type.

    They exist on both modules and on injectors, and their behaviour is different for each:

    • Module bindings are incomplete and cannot be used to provide instances. This is because the applicable scopes and interceptors may not be known until an injector is created. From a tool's perspective, module bindings are like the injector's source code. They can be inspected or rewritten, but this analysis must be done statically.
    • Injector bindings are complete and valid and can be used to provide instances. From a tools' perspective, injector bindings are like reflection for an injector. They have full runtime information, including the complete graph of injections necessary to satisfy a binding.
    @param the bound type. The injected is always assignable to this type
    . @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson)
    Class Binding, Provider<T> getProvider()

    Returns the scoped provider guice uses to fulfill requests for thisthis binding. @throws UnsupportedOperationException when invoked on a Binding created via com.google.inject.spi.Elements.getElements. This method is only supported on Bindings returned from an injector.

    Class BindingAnnotation

    Annotates annotations which are used for binding. Only one such annotation may apply to a single injection point. You must also annotate binder annotations with {@code @Retention(RUNTIME)}. For example:
       {@code @}Retention(RUNTIME)
       {@code @}Target({ FIELD, PARAMETER, METHOD })
       {@code @}BindingAnnotation
       public {@code @}interface Transactional {}
     
    @author crazybob@google.com (Bob Lee)

    Class CreationException

    Thrown when errors occur while creating a Injector. Includes a list list of encounteredencountered errors. Typically, a clientClients should catch this exception, log log it, and stop execution. @author crazybob@google.com (Bob Lee)
    Class CreationException, constructor CreationException(Collection<Message>)

    ConstructsCreates a newCreationException exceptioncontaining for{@code the given errorsmessages}.
    Class CreationException, Collection<Message> getErrorMessages()

    Gets the error messages which resulted inReturns messages for the errors that caused this exception.

    Class Guice

    The entry point to the Guice framework. Creates Injectors from Modules. For advanced usage, see InjectorBuilder.

    Guice supports a model of development that draws clear boundaries between APIs, Implementations of these APIs, Modules which configure these implementations, and finally Applications which consist of a collection of Modules. It is the Application, which typically defines your {@code main()} method, that bootstraps the Guice Injector using the {@code Guice} class, as in this example:

         public class FooApplication {
           public static void main(String[] args) {
             Injector injector = Guice.createInjector(
                 new ModuleA(),
                 new ModuleB(),
                 . . .
                 new FooApplicationFlagsModule(args)
             );
    
             // Now just bootstrap the application and you're done
             FooStarter starter = injector.getInstance(FooStarter.class);
             starter.runApplication();
           }
         }
     
    Class Guice, Injector createInjector(Module[])

    Creates an injector for the given set of modules. To create an injector with a Stage or other options, see InjectorBuilder. @throws CreationException from which you can retrieveif one or more errors theoccur during injector individual error messagesconstruction
    Class Guice, Injector createInjector(Stage, Module[])

    Creates an injector for the given set of modules, in a given development stage. Use InjectorBuilder for advanced injector creation. @throws CreationException from which you can retrieveif one or more errors theoccur during injector individual error messagescreation.

    Class Injector

    FulfillsBuilds requests for the objectgraphs instancesof objects that make up your application, . always ensuring that these instances are properly injected before they are The injector tracks the dependencies for each type and uses bindings returned.to Theinject {@codethem. Injector}This is the heartcore of the Guice framework, although you don't typicallyrarely interact with it directly very often. This This "behind-the-scenes" operation is what distinguishes the dependency injection pattern from its cousin, the service locator. The {@code Injector} API has a few additional features: it allows pre-constructed instances to have their fields and methods injected and offers programmatic introspection to support tool developmentpattern.

    Contains several default bindings:

    • This Injector instance itself
    • A {@code Provider} for each binding of type {@code T}
    • The java.util.logging.Logger for the class being injected
    • The Stage in which the Injector was created
    Injectors are created using the facade class Guice.

    An injector can also inject the dependencies of already-constructed instances. This can be used to interoperate with objects created by other frameworks or services.

    Injectors can be hierarchical. Child injectors inherit the configuration of their parent injectors, but the converse does not hold.

    The injector's internal bindings are available for introspection. This enables tools and extensions to operate on an injector reflectively. @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson)

    Class Injector, List<Binding<T>> findBindingsByType(TypeLiteral<T>)

    FindsReturns all explicit bindings tofor {@code type}.

    This method is part of the givenGuice typeSPI and is intended for use by tools and extensions.

    Class Injector, Binding<T> getBinding(Key<T>)

    Gets aReturns the binding for the given injection key. This will be an explicit bindings if the key was bound explicitly by a module, or an implicit binding otherwise. The implicit binding will be created if necessary.

    This method is part of the Guice SPI and is intended for use by tools and extensions. @throws ConfigurationException if this injector cannot find or create the binding.

    Class Injector, Map<Key<?>, Binding<?>> getBindings()

    Gets allReturns this injector's explicit bindings.

    The returned map does not include bindings inherited from a parent injector, should one exist. The returned map is guaranteed to iterate (for example, with its Map.entrySet() iterator) in the order of insertion. In other words, the order in which bindings appear in user Modules.

    This method is part of the Guice SPI and is intended for use by tools and extensions.

    Class Injector, T getInstance(Class<T>)

    Gets an instance bound toReturns the appropriate instance for the given injection type; equivalent to to {@codecode getProvider(type).get()}. When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time. @throws ConfigurationException if this injector cannot find or create the provider. @throws ProvisionException if there was a runtime failure while providing an instance.
    Class Injector, T getInstance(Key<T>)

    Gets an instance bound toReturns the appropriate instance for the given injection key; equivalent to to {@codecode getProvider(key).get()}. When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time. @throws ConfigurationException if this injector cannot find or create the provider. @throws ProvisionException if there was a runtime failure while providing an instance.
    Class Injector, Provider<T> getProvider(Class<T>)

    GetsReturns the provider boundused to obtain instances for the given type. When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time. @throws ConfigurationException if this injector cannot find or create the provider. @see Binder#getProvider(Class) for an alternative that offers up front error detection
    Class Injector, Provider<T> getProvider(Key<T>)

    GetsReturns the provider boundused to obtain instances for the given injection key. When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time. @throws ConfigurationException if this injector cannot find or create the provider. @see Binder#getProvider(Key) for an alternative that offers up front error detection
    Class Injector, void injectMembers(Object)

    Injects dependencies into the fields and methods of {@code instance}. Ignores the presence or absence of an existing objectinjectable constructor. Does

    Whenever not injectGuice creates thean instance, it performs this injection automatically (after first performing constructor injection), so if you're able to let Guice create all your objects for you, you'll never need to use this method. @param instance to inject members on @see Binder#getMembersInjector(Class) for a preferred alternative that supports checks before run time


    Class Key

    Binding key consisting of an injection type and an optional annotation. Matches the type and annotation at a point of injection.

    For example, {@code Key.get(Service.class, Transactional.class)} will match:

       {@literal @}Inject
       public void setService({@literal @}Transactional Service service) {
         ...
       }
     

    {@code Key} supports generic types via subclassing just like TypeLiteral.

    Keys do not differentiate between primitive types (int, char, etc.) and their correpsonding wrapper types (Integer, Character, etc.). Primitive types will be replaced with their wrapper types when keys are created. @author crazybob@google.com (Bob Lee)


    Class Module

    A module contributes configuration information, typically interface bindings, which will be used to create an Injector. A guiceGuice-based application is ultimately composed of little more than a set of {@code Module}s and some bootstrapping code.

    Your Module classes can use a more streamlined syntax by extending AbstractModule rather than implementing this interface directly.

    In addition to the bindings configured via .configure, bindings will be created for all methods annotated with {@literal @}Provides. Use scope and binding annotations on these methods to configure the bindings.

    Class Module, void configure(Binder)

    Contributes bindings and other configurations tofor this amodule to {@code Binderbinder}.

    Do not invoke this method directly to install submodules. Instead use Binder.install(Module), which ensures that provider methods are discovered.


    Class Provider

    Simply, anyAn object capable of providing instances of type {@code T}. Providers are used in numerous waysways by the Guice framework:
    • When the default means for obtaining instances (an injectable or or parameterless constructor) is insufficient for a particular binding, the the module can specify a custom {@code Provider} instead, to control exactly how how Guice creates or obtains instances for the binding.
    • An implementation class may always choose to have a {@code Provider} instance injected, rather than having a {@code T} injected directly. This This may give you access to multiplemultiple instances, instances you wish to safely safely mutate and discard, instances which are out of scopescope (e.g. using a a {@code @RequestScoped} object from within a {@code @SessionScoped} object), oror instances you don't want to initializethat until theywill be are absolutelyinitialized neededlazily.
    • A custom Scope is implemented as a decorator of of {@code Provider}, which decidesdecides when to delegate to the backing provider provider and when to provide the instance some other way.
    • The Injector offers access to the {@code Provider} it uses uses to fulfill requestsrequests for a given key, via the Injector.getProvider methods.
    @param the type of object this provider provides @author crazybob@google.com (Bob Lee)
    Class Provider, T get()

    Provides an instance of {@code T}. Must never return {@code null}. @throws OutOfScopeException when an attempt is made to access a scoped object while the scope in question is not currently active @throws ProvisionException if an instance cannot be provided. Such exceptions include messages and throwables to describe why provision failed.

    Class Scope

    A scope is a level of visibility that instances provided by Guice may have. By default, an instance created by the Injector has no no scope, meaning it has no state from the framework's perspective -- the {@code Injector} creates it, injects it once into the class that required it, and then immediately forgets it. Associating a scope with a particular binding particular binding allows the created instance to be "remembered" and possibly usedused again for for other injections. @see

    An example of a scope is Scopes#SINGLETON .SINGLETON. @author crazybob@google.com (Bob Lee)

    Class Scope, Provider<T> scope(Key<T>, Provider<T>)

    Scopes a provider. The returned locatorprovider returns objects from this scope. If If an object does not exist in this scope, the provider can use the given unscoped provider to retrieve one.

    Scope implementations are strongly encouraged to override Object.toString in the returned provider and include the backing provider's {@code toString()} output. @param key binding key @param unscoped locates an instance when one doesn't already exist in this scope. @return a new provider which only delegates to the given unscoped provider when an instance of the requested object doesn't already exist in this scope


    Class ScopeAnnotation

    Annotates annotations which are used for scoping. Only one such annotation may apply to a single implementation class. You must also annotate scope annotations with {@code @Retention(RUNTIME)}. For example:
       {@code @}Retention(RUNTIME)
       {@code @}Target(TYPE, METHOD)
       {@code @}ScopeAnnotation
       public {@code @}interface SessionScoped {}
     
    @author crazybob@google.com (Bob Lee)

    Class Scopes

    Built -in scope implementations. @author crazybob@google.com (Bob Lee)

    Class TypeLiteral

    Represents a generic type {@code T}. Java doesn't yet provide a way to represent generic types, so this class does. Forces clients to create a subclass of this class which enables retrieval the type information even at runtime.

    For example, to create a type literal for {@code List}, you can create an empty anonymous inner class:

    {@code TypeLiteral> list = new TypeLiteral>() {};}

    AssumesThis thatsyntax cannot be used to create type literals that have wildcard parameters, such as {@code TClass<>} implementsor Object{@code List< extends CharSequence>}.equals Such type literals must be constructed programatically, either by extracting types from members and or by using the ObjectTypes factory class.

    Along with modeling generic types, this class can resolve type parameters.hashCode For example, to figure out what type {@code keySet()} asreturns on a {@code Map}, use this code:

       {@code
    
     value  TypeLiteral> mapType
           = new TypeLiteral>(as) {};
     opposed to TypeLiteral<> keySetType
           identity= mapType.getReturnType(Map.class.getMethod("keySet"));
     comparison  System.out.println(keySetType); // prints "Set"}
    @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson)

    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/docdiffs_com.google.inject.binder.html0000755000175000017500000004205311704661106030761 0ustar tonytony com.google.inject.binder Documentation Differences
    Generated by
    JDiff

    com.google.inject.binder Documentation Differences

    This file contains all the changes in documentation in the package com.google.inject.binder as colored differences. Deletions are shown like this, and additions are shown like this.
    If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
    Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

    Class AnnotatedBindingBuilder

    SpecifiesSee the annotationEDSL for aexamples at bindingcom. google.inject.Binder. @author crazybob@google.com (Bob Lee)
    Class AnnotatedBindingBuilder, LinkedBindingBuilder<T> annotatedWith(Annotation)

    Specifies an annotation value forSee the EDSL examples at this bindingcom.google.inject.Binder.
    Class AnnotatedBindingBuilder, LinkedBindingBuilder<T> annotatedWith(Class<Annotation>)

    Specifies an annotation type forSee the EDSL examples at this bindingcom.google.inject.Binder.

    Class AnnotatedConstantBindingBuilder

    SpecifiesSee the annotationEDSL for aexamples at constant bindingcom.google.inject.Binder. @author crazybob@google.com (Bob Lee)
    Class AnnotatedConstantBindingBuilder, ConstantBindingBuilder annotatedWith(Annotation)

    Specifies an annotation value forSee the EDSL examples at this bindingcom.google.inject.Binder.
    Class AnnotatedConstantBindingBuilder, ConstantBindingBuilder annotatedWith(Class<Annotation>)

    Specifies an annotation type forSee the EDSL examples at this bindingcom.google.inject.Binder.

    Class LinkedBindingBuilder

    Links a binding to anotherSee the EDSL examples at binding or an instancecom.google.inject.Binder. @author crazybob@google.com (Bob Lee)
    Class LinkedBindingBuilder, ScopedBindingBuilder to(Class<? extends T>)

    BindsSee to another bindingthe with the specifiedEDSL examples at typecom.google.inject.Binder.
    Class LinkedBindingBuilder, ScopedBindingBuilder to(Key<? extends T>)

    BindsSee to another bindingthe with the specifiedEDSL examples at keycom.google.inject.Binder.
    Class LinkedBindingBuilder, ScopedBindingBuilder to(TypeLiteral<? extends T>)

    BindsSee to another bindingthe with the specifiedEDSL examples at typecom.google.inject.Binder.
    Class LinkedBindingBuilder, void toInstance(T)

    Binds toSee the given instance. The InjectorEDSL will automaticallyexamples at com.google.inject the members of this instance when it is first created.Binder. See@see com.google.inject.Injector.#injectMembers(Object).

    Class ScopedBindingBuilder

    SpecifiesSee the scopeEDSL for aexamples at bindingcom.google.inject.Binder. @author crazybob@google.com (Bob Lee)
    Class ScopedBindingBuilder, void asEagerSingleton()

    Instructs the com.google.inject.Injector to eagerly initialize this singleton-scoped binding upon creation. Useful for application initialization logic. See the EDSL examples at com.google.inject.Binder.
    Class ScopedBindingBuilder, void in(Class<Annotation>)

    SpecifiesSee the scope. References theEDSL annotation passedexamples at to com.google.inject.Binder.bindScope(Class, com.google.inject.Scope).
    Class ScopedBindingBuilder, void in(Scope)

    SpecifiesSee the scopeEDSL examples at com.google.inject.Binder.

    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/constructors_index_removals.html0000755000175000017500000000326211704661106030220 0ustar tonytony Constructor Removals Index
    All Constructors
    Removals
    Additions
    Changes
    Bold is New, strike is deleted

    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/constructors_index_changes.html0000755000175000017500000000401511704661106027775 0ustar tonytony Constructor Changes Index
    All Constructors
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    C  TOP
    CreationException (Collection<Message>) constructor
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/constructors_index_all.html0000755000175000017500000000510611704661106027137 0ustar tonytony Constructor Differences Index
    All Constructors
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    C  M TOP
    CreationException (Collection<Message>) constructor

    M  C TOP
    Message (List<Object>, String, Throwable) constructor
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/constructors_index_additions.html0000755000175000017500000000403411704661106030344 0ustar tonytony Constructor Additions Index
    All Constructors
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    M  TOP
    Message (List<Object>, String, Throwable) constructor
    ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.struts2.GuiceObjectFactory.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.struts2.GuiceObjectFactor0000755000175000017500000001267611704661106031671 0ustar tonytony com.google.inject.struts2.GuiceObjectFactory
    Generated by
    JDiff

    Class com.google.inject.struts2.GuiceObjectFactory

    Documentation changed from old to new.

    Now deprecated.



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.spi.Message.html0000755000175000017500000002523611704661106030037 0ustar tonytony com.google.inject.spi.Message
    Generated by
    JDiff

    Class com.google.inject.spi.Message

    Added interfaces com.google.inject.spi.Element, java.io.Serializable.
    Documentation changed from old to new.

    Change from non-final to final.

    Added Constructors
    Message(List<Object>, String, Throwable) @since 2.0
     

    Removed Methods
    String getSourceString() Returns a string representation of the source object.
     

    Added Methods
    T acceptVisitor(ElementVisitor<T>) @since 2.0
    void applyTo(Binder) @since 2.0
    Throwable getCause() Returns the throwable that caused this message, or {@code null} if this message was not caused by a throwable.
    List<Object> getSources() @since 2.0
     

    Changed Methods
    String getSource() Change in return type from Object to String.
    Documentation changed from old to new.
     
     



    ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.servlet.ServletScopes.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.servlet.ServletScopes.htm0000755000175000017500000001604211704661106031764 0ustar tonytony com.google.inject.servlet.ServletScopes
    Generated by
    JDiff

    Class com.google.inject.servlet.ServletScopes

    Added Methods
    Callable<T> continueRequest(Callable<T>, Map<Key<?>, Object>) Wraps the given callable in a contextual callable that "continues" the HTTP request in another thread.
    Callable<T> scopeRequest(Callable<T>, Map<Key<?>, Object>) Scopes the given callable inside a request scope.
     



    ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.servlet.ServletModule.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.servlet.ServletModule.htm0000755000175000017500000002460411704661106031760 0ustar tonytony com.google.inject.servlet.ServletModule
    Generated by
    JDiff

    Class com.google.inject.servlet.ServletModule

    Documentation changed from old to new.

    Added Methods
    void configureServlets()

    Servlet Mapping EDSL

    FilterKeyBindingBuilder filter(String, String[]) @param urlPattern Any Servlet-style pattern.
    FilterKeyBindingBuilder filterRegex(String, String[]) @param regex Any Java-style regular expression.
    ServletContext getServletContext() This method only works if you are using the GuiceServletContextListener to create your injector.
    ServletKeyBindingBuilder serve(String, String[]) @param urlPattern Any Servlet-style pattern.
    ServletKeyBindingBuilder serveRegex(String, String[]) @param regex Any Java-style regular expression.
     

    Changed Methods
    void configure() Change from non-final to final.
     
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.servlet.GuiceFilter.html0000755000175000017500000001327711704661106031550 0ustar tonytony com.google.inject.servlet.GuiceFilter
    Generated by
    JDiff

    Class com.google.inject.servlet.GuiceFilter

    Documentation changed from old to new.

    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.name.Names.html0000755000175000017500000002007711704661106027641 0ustar tonytony com.google.inject.name.Names
    Generated by
    JDiff

    Class com.google.inject.name.Names

    Changed Methods
    void bindProperties(Binder, Map<String, String>) Documentation changed from old to new.
    Creates a constant binding to {@code @Named(key)} for each entry in {@code properties}.
    void bindProperties(Binder, Properties) Documentation changed from old to new.
    Creates a constant binding to {@code @Named(key)} for each property.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.matcher.Matchers.html0000755000175000017500000001663011704661106031047 0ustar tonytony com.google.inject.matcher.Matchers
    Generated by
    JDiff

    Class com.google.inject.matcher.Matchers

    Added Methods
    Matcher<Class> inSubpackage(String) Returns a matcher which matches classes in the given package and its subpackages.
     

    Changed Methods
    Matcher<Class> inPackage(Package) Documentation changed from old to new.
    Returns a matcher which matches classes in the given package.
     



    ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.binder.ScopedBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.binder.ScopedBindingBuild0000755000175000017500000002400111704661106031635 0ustar tonytony com.google.inject.binder.ScopedBindingBuilder
    Generated by
    JDiff

    Interface com.google.inject.binder.ScopedBindingBuilder

    Documentation changed from old to new.

    Changed Methods
    void asEagerSingleton() Documentation changed from old to new.
    Instructs the com.google.inject.Injector to eagerly initialize this singleton-scoped binding upon creation.
    void in(Scope) Documentation changed from old to new.
    See the EDSL examples at com.google.inject.Binder.
    void in(Class<Annotation>) Documentation changed from old to new.
    See the EDSL examples at com.google.inject.Binder.
     



    ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.binder.LinkedBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.binder.LinkedBindingBuild0000755000175000017500000004513511704661106031641 0ustar tonytony com.google.inject.binder.LinkedBindingBuilder
    Generated by
    JDiff

    Interface com.google.inject.binder.LinkedBindingBuilder

    Documentation changed from old to new.

    Removed Methods
    ScopedBindingBuilder toProvider(Key<Provider<? extends T>>) Binds to instances from the provider bound to the given key.
    ScopedBindingBuilder toProvider(Provider<? extends T>) Binds to instances generated by the given Provider.
    ScopedBindingBuilder toProvider(Class<Provider<? extends T>>) Binds to instances from the provider bound to the given provider type.
     

    Added Methods
    ScopedBindingBuilder toConstructor(Constructor<S>) See the EDSL examples at com.google.inject.Binder.
    ScopedBindingBuilder toConstructor(Constructor<S>, TypeLiteral<?, extends, S>) See the EDSL examples at com.google.inject.Binder.
    ScopedBindingBuilder toProvider(Key<Provider<? extends T>>) See the EDSL examples at com.google.inject.Binder.
    ScopedBindingBuilder toProvider(Provider<? extends T>) See the EDSL examples at com.google.inject.Binder.
    ScopedBindingBuilder toProvider(TypeLiteral<Provider<? extends T>>) See the EDSL examples at com.google.inject.Binder.
    ScopedBindingBuilder toProvider(Class<Provider<? extends T>>) See the EDSL examples at com.google.inject.Binder.
     

    Changed Methods
    void toInstance(T) Documentation changed from old to new.
    See the EDSL examples at com.google.inject.Binder.
    ScopedBindingBuilder to(Key<? extends T>) Documentation changed from old to new.
    See the EDSL examples at com.google.inject.Binder.
    ScopedBindingBuilder to(TypeLiteral<? extends T>) Documentation changed from old to new.
    See the EDSL examples at com.google.inject.Binder.
    ScopedBindingBuilder to(Class<? extends T>) Documentation changed from old to new.
    See the EDSL examples at com.google.inject.Binder.
     



    ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.binder.ConstantBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.binder.ConstantBindingBui0000755000175000017500000001422311704661106031676 0ustar tonytony com.google.inject.binder.ConstantBindingBuilder
    Generated by
    JDiff

    Interface com.google.inject.binder.ConstantBindingBuilder

    Added Methods
    void to(byte) Binds constant to the given value.
     



    ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.binder.AnnotatedConstantBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.binder.AnnotatedConstantB0000755000175000017500000002252511704661106031707 0ustar tonytony com.google.inject.binder.AnnotatedConstantBindingBuilder
    Generated by
    JDiff

    Interface com.google.inject.binder.AnnotatedConstantBindingBuilder

    Documentation changed from old to new.

    Changed Methods
    ConstantBindingBuilder annotatedWith(Class<Annotation>) Documentation changed from old to new.
    See the EDSL examples at com.google.inject.Binder.
    ConstantBindingBuilder annotatedWith(Annotation) Documentation changed from old to new.
    See the EDSL examples at com.google.inject.Binder.
     



    ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.binder.AnnotatedBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.binder.AnnotatedBindingBu0000755000175000017500000002211111704661106031644 0ustar tonytony com.google.inject.binder.AnnotatedBindingBuilder
    Generated by
    JDiff

    Interface com.google.inject.binder.AnnotatedBindingBuilder

    Documentation changed from old to new.

    Changed Methods
    LinkedBindingBuilder<T> annotatedWith(Class<Annotation>) Documentation changed from old to new.
    See the EDSL examples at com.google.inject.Binder.
    LinkedBindingBuilder<T> annotatedWith(Annotation) Documentation changed from old to new.
    See the EDSL examples at com.google.inject.Binder.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.TypeLiteral.html0000755000175000017500000002657011704661106030121 0ustar tonytony com.google.inject.TypeLiteral
    Generated by
    JDiff

    Class com.google.inject.TypeLiteral

    Documentation changed from old to new.

    Changed from abstract to non-abstract.

    Added Methods
    List<TypeLiteral<?>> getExceptionTypes(Member) Returns the resolved generic exception types thrown by {@code constructor}.
    TypeLiteral<?> getFieldType(Field) Returns the resolved generic type of {@code field}.
    List<TypeLiteral<?>> getParameterTypes(Member) Returns the resolved generic parameter types of {@code methodOrConstructor}.
    (Class<? super T>getRawType() Returns the raw (non-generic) type for this type.
    TypeLiteral<?> getReturnType(Method) Returns the resolved generic return type of {@code method}.
    TypeLiteral<?> getSupertype(Class<?>) Returns the generic form of {@code supertype}.
     

    Changed Methods
    boolean equals(Object) Change from non-final to final.
     
    Type getType() Change from non-final to final.
    Gets underlying {@code Type} instance.
    int hashCode() Change from non-final to final.
     
    String toString() Change from non-final to final.
     
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.Scopes.html0000755000175000017500000001627411704661106027117 0ustar tonytony com.google.inject.Scopes
    Generated by
    JDiff

    Class com.google.inject.Scopes

    Documentation changed from old to new.

    Added Methods
    boolean isSingleton(Binding<?>) Returns true if {@code binding} is singleton-scoped.
     

    Added Fields
    Scope NO_SCOPE No scope; the same as not applying any scope at all.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.ScopeAnnotation.html0000755000175000017500000001324311704661106030760 0ustar tonytony com.google.inject.ScopeAnnotation
    Generated by
    JDiff

    Class com.google.inject.ScopeAnnotation

    Documentation changed from old to new.

    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.Scope.html0000755000175000017500000001617311704661106026732 0ustar tonytony com.google.inject.Scope
    Generated by
    JDiff

    Interface com.google.inject.Scope

    Documentation changed from old to new.

    Changed Methods
    Provider<T> scope(Key<T>, Provider<T>) Documentation changed from old to new.
    Scopes a provider.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.Provider.html0000755000175000017500000001564611704661106027457 0ustar tonytony com.google.inject.Provider
    Generated by
    JDiff

    Interface com.google.inject.Provider

    Added interface javax.inject.Provider.
    Documentation changed from old to new.

    Changed Methods
    T get() Documentation changed from old to new.
    Provides an instance of {@code T}.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.Module.html0000755000175000017500000001577411704661106027114 0ustar tonytony com.google.inject.Module
    Generated by
    JDiff

    Interface com.google.inject.Module

    Documentation changed from old to new.

    Changed Methods
    void configure(Binder) Documentation changed from old to new.
    Contributes bindings and other configurations for this module to {@code binder}.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.Key.html0000755000175000017500000002710611704661106026407 0ustar tonytony com.google.inject.Key
    Generated by
    JDiff

    Class com.google.inject.Key

    Documentation changed from old to new.

    Changed from abstract to non-abstract.

    Added Methods
    boolean hasAttributes() Returns true if this key has annotation attributes.
    Key<?> ofType(Type) Returns a new key of the specified type with the same annotation as this key.
    Key<T> ofType(TypeLiteral<T>) Returns a new key of the specified type with the same annotation as this key.
    Key<T> ofType(Class<T>) Returns a new key of the specified type with the same annotation as this key.
    Key<T> withoutAttributes() Returns this key without annotation attributes, i.e.
     

    Changed Methods
    boolean equals(Object) Change from non-final to final.
     
    Annotation getAnnotation() Change from non-final to final.
    Gets the annotation.
    Class<Annotation> getAnnotationType() Change from non-final to final.
    Gets the annotation type.
    TypeLiteral<T> getTypeLiteral() Change from non-final to final.
    Gets the key type.
    int hashCode() Change from non-final to final.
     
    String toString() Change from non-final to final.
     
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.Injector.html0000755000175000017500000004740011704661106027433 0ustar tonytony com.google.inject.Injector
    Generated by
    JDiff

    Interface com.google.inject.Injector

    Documentation changed from old to new.

    Added Methods
    Injector createChildInjector(Module[]) Returns a new injector that inherits all state from this injector.
    Injector createChildInjector(Iterable<Module>) Returns a new injector that inherits all state from this injector.
    (Map<Key<?>, Binding<?>>getAllBindings() Returns a snapshot of this injector's bindings, both explicit and just-in-time.
    Binding<T> getBinding(Class<T>) Returns the binding for the given type.
    Binding<T> getExistingBinding(Key<T>) Returns the binding if it already exists, or null if does not exist.
    MembersInjector<T> getMembersInjector(TypeLiteral<T>) Returns the members injector used to inject dependencies into methods and fields on instances of the given type {@code T}.
    MembersInjector<T> getMembersInjector(Class<T>) Returns the members injector used to inject dependencies into methods and fields on instances of the given type {@code T}.
    Injector getParent() Returns this injector's parent, or {@code null} if this is a top-level injector.
    (Map<Class<Annotation>, Scope>getScopeBindings() Returns a map containing all scopes in the injector.
     

    Changed Methods
    List<Binding<T>> findBindingsByType(TypeLiteral<T>) Documentation changed from old to new.
    Returns all explicit bindings for {@code type}.
    Map<Key<?>, Binding<?>> getBindings() Documentation changed from old to new.
    Returns this injector's explicit bindings.
    void injectMembers(Object) Documentation changed from old to new.
    Injects dependencies into the fields and methods of {@code instance}.
    Binding<T> getBinding(Key<T>) Documentation changed from old to new.
    Returns the binding for the given injection key.
    T getInstance(Key<T>) Documentation changed from old to new.
    Returns the appropriate instance for the given injection key; equivalent to {@code getProvider(key).get()}.
    T getInstance(Class<T>) Documentation changed from old to new.
    Returns the appropriate instance for the given injection type; equivalent to {@code getProvider(type).get()}.
    Provider<T> getProvider(Key<T>) Documentation changed from old to new.
    Returns the provider used to obtain instances for the given injection key.
    Provider<T> getProvider(Class<T>) Documentation changed from old to new.
    Returns the provider used to obtain instances for the given type.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.Guice.html0000755000175000017500000002642211704661106026713 0ustar tonytony com.google.inject.Guice
    Generated by
    JDiff

    Class com.google.inject.Guice

    Documentation changed from old to new.

    Removed Methods
    Injector createInjector(Stage, Iterable<Module>) Creates an injector for the given set of modules, in a given development stage.
    Injector createInjector(Iterable<Module>) Creates an injector for the given set of modules.
     

    Added Methods
    Injector createInjector(Stage, Iterable<Module>) Creates an injector for the given set of modules, in a given development stage.
    Injector createInjector(Iterable<Module>) Creates an injector for the given set of modules.
     

    Changed Methods
    Injector createInjector(Module[]) Documentation changed from old to new.
    Creates an injector for the given set of modules.
    Injector createInjector(Stage, Module[]) Documentation changed from old to new.
    Creates an injector for the given set of modules, in a given development stage.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.CreationException.html0000755000175000017500000002121611704661106031276 0ustar tonytony com.google.inject.CreationException
    Generated by
    JDiff

    Class com.google.inject.CreationException

    Documentation changed from old to new.

    Changed Constructors
    CreationException(Collection<Message>) Documentation changed from old to new.
    Creates a CreationException containing {@code messages}.
     

    Changed Methods
    Collection<Message> getErrorMessages() Documentation changed from old to new.
    Returns messages for the errors that caused this exception.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.BindingAnnotation.html0000755000175000017500000001332511704661106031262 0ustar tonytony com.google.inject.BindingAnnotation
    Generated by
    JDiff

    Class com.google.inject.BindingAnnotation

    Documentation changed from old to new.

    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.Binding.html0000755000175000017500000002237611704661106027235 0ustar tonytony com.google.inject.Binding
    Generated by
    JDiff

    Interface com.google.inject.Binding

    Added interface com.google.inject.spi.Element.
    Documentation changed from old to new.

    Removed Methods
    Object getSource() Returns an arbitrary object containing information about the "place" where this binding was configured.
     

    Added Methods
    V acceptScopingVisitor(BindingScopingVisitor<V>) Accepts a scoping visitor.
    V acceptTargetVisitor(BindingTargetVisitor<?, super, T, V>) Accepts a target visitor.
     

    Changed Methods
    Provider<T> getProvider() Documentation changed from old to new.
    Returns the scoped provider guice uses to fulfill requests for this binding.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.Binder.html0000755000175000017500000005001211704661106027052 0ustar tonytony com.google.inject.Binder
    Generated by
    JDiff

    Interface com.google.inject.Binder

    Documentation changed from old to new.

    Added Methods
    void addError(Message) Records an error message to be presented to the user at a later time.
    void bindListener(Matcher<TypeLiteral<?>>, TypeListener) Registers a listener for injectable types.
    void convertToTypes(Matcher<TypeLiteral<?>>, TypeConverter) Binds a type converter.
    MembersInjector<T> getMembersInjector(TypeLiteral<T>) Returns the members injector used to inject dependencies into methods and fields on instances of the given type {@code T}.
    MembersInjector<T> getMembersInjector(Class<T>) Returns the members injector used to inject dependencies into methods and fields on instances of the given type {@code T}.
    Provider<T> getProvider(Key<T>) Returns the provider used to obtain instances for the given injection key.
    Provider<T> getProvider(Class<T>) Returns the provider used to obtain instances for the given injection type.
    PrivateBinder newPrivateBinder() Creates a new private child environment for bindings and other configuration.
    void requestInjection(TypeLiteral<T>, T) Upon successful creation, the Injector will inject instance fields and methods of the given object.
    void requestInjection(Object) Upon successful creation, the Injector will inject instance fields and methods of the given object.
    Binder skipSources(Class[]) Returns a binder that skips {@code classesToSkip} when identify the calling code.
    Binder withSource(Object) Returns a binder that uses {@code source} as the reference location for configuration errors.
     

    Changed Methods
    AnnotatedConstantBindingBuilder bindConstant() Documentation changed from old to new.
    See the EDSL examples at Binder.
    void bindInterceptor(Matcher<Class<?>>, Matcher<Method>, MethodInterceptor[]) Change in signature from (com.google.inject.matcher.Matcher>, com.google.inject.matcher.Matcher, MethodInterceptor[]) to (com.google.inject.matcher.Matcher>, com.google.inject.matcher.Matcher, org.aopalliance.intercept.MethodInterceptor[]).
    Documentation changed from old to new.
    Binds method interceptor[s] to methods matched by class and method matchers.
    AnnotatedBindingBuilder<T> bind(TypeLiteral<T>) Documentation changed from old to new.
    See the EDSL examples at Binder.
    AnnotatedBindingBuilder<T> bind(Class<T>) Documentation changed from old to new.
    See the EDSL examples at Binder.
    LinkedBindingBuilder<T> bind(Key<T>) Documentation changed from old to new.
    See the EDSL examples at Binder.
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/com.google.inject.AbstractModule.html0000755000175000017500000003347011704661106030571 0ustar tonytony com.google.inject.AbstractModule
    Generated by
    JDiff

    Class com.google.inject.AbstractModule

    Documentation changed from old to new.

    Added Methods
    void addError(Message) @see Binder#addError(Message)
    void bindListener(Matcher<TypeLiteral<?>>, TypeListener) @see Binder#bindListener(com.google.inject.matcher.Matcher, com.google.inject.spi.TypeListener)
    void convertToTypes(Matcher<TypeLiteral<?>>, TypeConverter) @see Binder#convertToTypes
    Stage currentStage() @see Binder#currentStage()
    MembersInjector<T> getMembersInjector(TypeLiteral<T>) @see Binder#getMembersInjector(TypeLiteral)
    MembersInjector<T> getMembersInjector(Class<T>) @see Binder#getMembersInjector(Class)
    Provider<T> getProvider(Key<T>) @see Binder#getProvider(Key)
    Provider<T> getProvider(Class<T>) @see Binder#getProvider(Class)
    void requestInjection(Object) @see Binder#requestInjection(Object)
    void requireBinding(Key<?>) Adds a dependency from this module to {@code key}.
    void requireBinding(Class<?>) Adds a dependency from this module to {@code type}.
     

    Changed Methods
    void bindInterceptor(Matcher<Class<?>>, Matcher<Method>, MethodInterceptor[]) Change in signature from (com.google.inject.matcher.Matcher>, com.google.inject.matcher.Matcher, MethodInterceptor[]) to (com.google.inject.matcher.Matcher>, com.google.inject.matcher.Matcher, org.aopalliance.intercept.MethodInterceptor[]).
    @see Binder#bindInterceptor(com.google.inject.matcher.Matcher, com.google.inject.matcher.Matcher, org.aopalliance.intercept.MethodInterceptor[])
     



    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/classes_index_removals.html0000755000175000017500000000400111704661106027075 0ustar tonytony Class Removals Index
    All Classes
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    S  TOP
    SourceProvider
    SourceProviders
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/classes_index_changes.html0000755000175000017500000002702311704661106026666 0ustar tonytony Class Changes Index
    All Classes
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    A  B C G I K L M N P S T TOP
    AbstractModule
    AnnotatedBindingBuilder
    AnnotatedConstantBindingBuilder

    B  A C G I K L M N P S T TOP
    Binder
    Binding
    BindingAnnotation

    C  A B G I K L M N P S T TOP
    ConstantBindingBuilder
    CreationException

    G  A B C I K L M N P S T TOP
    Guice
    GuiceFilter
    GuiceObjectFactory

    I  A B C G K L M N P S T TOP
    Injector

    K  A B C G I L M N P S T TOP
    Key

    L  A B C G I K M N P S T TOP
    LinkedBindingBuilder

    M  A B C G I K L N P S T TOP
    Matchers
    Message
    Module

    N  A B C G I K L M P S T TOP
    Names

    P  A B C G I K L M N S T TOP
    Provider

    S  A B C G I K L M N P T TOP
    Scope
    ScopeAnnotation
    ScopedBindingBuilder
    Scopes
    ServletModule
    ServletScopes

    T  A B C G I K L M N P S TOP
    TypeLiteral
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/classes_index_all.html0000755000175000017500000006373111704661106026034 0ustar tonytony Class Differences Index
    All Classes
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    A  B C D E G H I K L M N O P S T U TOP
    AbstractModule
    AnnotatedBindingBuilder
    AnnotatedConstantBindingBuilder
    AnnotatedElementBuilder

    B  A C D E G H I K L M N O P S T U TOP
    Binder
    Binding
    BindingAnnotation
    BindingScopingVisitor
    BindingTargetVisitor

    C  A B D E G H I K L M N O P S T U TOP
    ConfigurationException
    ConstantBindingBuilder
    ConstructorBinding
    ConvertedConstantBinding
    CreationException

    D  A B C E G H I K L M N O P S T U TOP
    DefaultBindingScopingVisitor
    DefaultBindingTargetVisitor
    DefaultElementVisitor
    Dependency

    E  A B C D G H I K L M N O P S T U TOP
    Element
    Elements
    ElementVisitor
    Exposed
    ExposedBinding

    G  A B C D E H I K L M N O P S T U TOP
    Guice
    GuiceFilter
    GuiceObjectFactory
    GuiceServletContextListener

    H  A B C D E G I K L M N O P S T U TOP
    HasDependencies

    I  A B C D E G H K L M N O P S T U TOP
    InjectionListener
    InjectionPoint
    InjectionRequest
    Injector
    InjectorBuilder
    InstanceBinding
    InstanceFilterBinding
    InstanceServletBinding
    InterceptorBinding

    K  A B C D E G H I L M N O P S T U TOP
    Key

    L  A B C D E G H I K M N O P S T U TOP
    LinkedBindingBuilder
    LinkedFilterBinding
    LinkedKeyBinding
    LinkedServletBinding

    M  A B C D E G H I K L N O P S T U TOP
    Matchers
    MembersInjector
    MembersInjectorLookup
    Message
    Module

    N  A B C D E G H I K L M O P S T U TOP
    Names

    O  A B C D E G H I K L M N P S T U TOP
    OutOfScopeException

    P  A B C D E G H I K L M N O S T U TOP
    PrivateBinder
    PrivateElements
    PrivateModule
    Provider
    ProviderBinding
    ProviderInstanceBinding
    ProviderKeyBinding
    ProviderLookup
    ProviderWithDependencies
    ProviderWithExtensionVisitor
    Provides
    ProvisionException

    S  A B C D E G H I K L M N O P T U TOP
    Scope
    ScopeAnnotation
    ScopeBinding
    ScopedBindingBuilder
    Scopes
    ServletModule
    ServletModule.FilterKeyBindingBuilder
    ServletModule.ServletKeyBindingBuilder
    ServletModuleTargetVisitor
    ServletScopes
    SourceProvider
    SourceProviders
    StaticInjectionRequest
    Struts2Factory

    T  A B C D E G H I K L M N O P S U TOP
    Toolable
    TypeConverter
    TypeConverterBinding
    TypeEncounter
    TypeListener
    TypeListenerBinding
    TypeLiteral

    U  A B C D E G H I K L M N O P S T TOP
    UntargettedBinding
    UriPatternType
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/classes_index_additions.html0000755000175000017500000004756611704661106027252 0ustar tonytony Class Additions Index
    All Classes
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    A  B C D E G H I L M O P S T U TOP
    AnnotatedElementBuilder

    B  A C D E G H I L M O P S T U TOP
    BindingScopingVisitor
    BindingTargetVisitor

    C  A B D E G H I L M O P S T U TOP
    ConfigurationException
    ConstructorBinding
    ConvertedConstantBinding

    D  A B C E G H I L M O P S T U TOP
    DefaultBindingScopingVisitor
    DefaultBindingTargetVisitor
    DefaultElementVisitor
    Dependency

    E  A B C D G H I L M O P S T U TOP
    Element
    Elements
    ElementVisitor
    Exposed
    ExposedBinding

    G  A B C D E H I L M O P S T U TOP
    GuiceServletContextListener

    H  A B C D E G I L M O P S T U TOP
    HasDependencies

    I  A B C D E G H L M O P S T U TOP
    InjectionListener
    InjectionPoint
    InjectionRequest
    InjectorBuilder
    InstanceBinding
    InstanceFilterBinding
    InstanceServletBinding
    InterceptorBinding

    L  A B C D E G H I M O P S T U TOP
    LinkedFilterBinding
    LinkedKeyBinding
    LinkedServletBinding

    M  A B C D E G H I L O P S T U TOP
    MembersInjector
    MembersInjectorLookup

    O  A B C D E G H I L M P S T U TOP
    OutOfScopeException

    P  A B C D E G H I L M O S T U TOP
    PrivateBinder
    PrivateElements
    PrivateModule
    ProviderBinding
    ProviderInstanceBinding
    ProviderKeyBinding
    ProviderLookup
    ProviderWithDependencies
    ProviderWithExtensionVisitor
    Provides
    ProvisionException

    S  A B C D E G H I L M O P T U TOP
    ScopeBinding
    ServletModule.FilterKeyBindingBuilder
    ServletModule.ServletKeyBindingBuilder
    ServletModuleTargetVisitor
    StaticInjectionRequest
    Struts2Factory

    T  A B C D E G H I L M O P S U TOP
    Toolable
    TypeConverter
    TypeConverterBinding
    TypeEncounter
    TypeListener
    TypeListenerBinding

    U  A B C D E G H I L M O P S T TOP
    UntargettedBinding
    UriPatternType
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/changes-summary.html0000755000175000017500000001723311704661106025457 0ustar tonytony API Differences between 1.0 and 2.0
    Generated by
    JDiff

    API Differences

    Between 1.0 and 2.0

    Added Packages
    com.google.inject.assistedinject  
    com.google.inject.multibindings  
    com.google.inject.persist  
    com.google.inject.persist.
    finder
     
    com.google.inject.persist.jpa  
    com.google.inject.throwingproviders  
    com.google.inject.util  
     

    Changed Packages
    com.google.inject  
    com.google.inject.binder  
    com.google.inject.matcher  
    com.google.inject.name  
    com.google.inject.servlet  
    com.google.inject.spi  
    com.google.inject.struts2  
      sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/alldiffs_index_removals.html0000755000175000017500000001256011704661106027235 0ustar tonytony All Removals Index
    All Differences
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    C  G S T TOP
    createInjector
      type  (Stage, Iterable<Module>) in com.google.inject.Guice
      type  (Iterable<Module>) in com.google.inject.Guice

    G  C S T TOP
    getSource ()
    getSourceString ()

    S  C G T TOP
    SourceProvider
    SourceProviders

    T  C G S TOP
    toProvider
      type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Provider<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/alldiffs_index_changes.html0000755000175000017500000007463111704661106027024 0ustar tonytony All Changes Index
    All Differences
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    A  B C E F G H I K L M N P S T TOP
    AbstractModule
    AnnotatedBindingBuilder
    AnnotatedConstantBindingBuilder
    annotatedWith
      type  (Class<Annotation>) in com.google.inject.binder.AnnotatedBindingBuilder
      type  (Annotation) in com.google.inject.binder.AnnotatedBindingBuilder
      type  (Class<Annotation>) in com.google.inject.binder.AnnotatedConstantBindingBuilder
      type  (Annotation) in com.google.inject.binder.AnnotatedConstantBindingBuilder
    asEagerSingleton ()

    B  A C E F G H I K L M N P S T TOP
    bind
      type  (TypeLiteral<T>) in com.google.inject.Binder
      type  (Class<T>) in com.google.inject.Binder
      type  (Key<T>) in com.google.inject.Binder
    bindConstant ()
    Binder
    Binding
    BindingAnnotation
    bindInterceptor
      type  (Matcher<Class<?>>, Matcher<Method>, MethodInterceptor[]) in com.google.inject.AbstractModule
      type  (Matcher<Class<?>>, Matcher<Method>, MethodInterceptor[]) in com.google.inject.Binder
    bindProperties
      type  (Binder, Map<String, String>) in com.google.inject.name.Names
      type  (Binder, Properties) in com.google.inject.name.Names
    com.google.inject
    com.google.inject.binder
    com.google.inject.matcher
    com.google.inject.name
    com.google.inject.servlet
    com.google.inject.spi
    com.google.inject.struts2
    configure
      type  (Binder) in com.google.inject.Module
      type  () in com.google.inject.servlet.ServletModule
    ConstantBindingBuilder
    createInjector
      type  (Module[]) in com.google.inject.Guice
      type  (Stage, Module[]) in com.google.inject.Guice
    CreationException
      com.google.inject
      CreationException (Collection<Message>) constructor

    E  A B C F G H I K L M N P S T TOP
    equals
      type  (Object) in com.google.inject.Key
      type  (Object) in com.google.inject.TypeLiteral

    F  A B C E G H I K L M N P S T TOP
    findBindingsByType (TypeLiteral<T>)

    G  A B C E F H I K L M N P S T TOP
    get ()
    getAnnotation ()
    getAnnotationType ()
    getBinding (Key<T>)
    getBindings ()
    getErrorMessages ()
    getInstance
      type  (Key<T>) in com.google.inject.Injector
      type  (Class<T>) in com.google.inject.Injector
    getProvider
      type  () in com.google.inject.Binding
      type  (Key<T>) in com.google.inject.Injector
      type  (Class<T>) in com.google.inject.Injector
    getSource ()
    getType ()
    getTypeLiteral ()
    Guice
    GuiceFilter
    GuiceObjectFactory

    H  A B C E F G I K L M N P S T TOP
    hashCode
      type  () in com.google.inject.Key
      type  () in com.google.inject.TypeLiteral

    I  A B C E F G H K L M N P S T TOP
    in
      type  (Scope) in com.google.inject.binder.ScopedBindingBuilder
      type  (Class<Annotation>) in com.google.inject.binder.ScopedBindingBuilder
    injectMembers (Object)
    Injector
    inPackage (Package)

    K  A B C E F G H I L M N P S T TOP
    Key

    L  A B C E F G H I K M N P S T TOP
    LinkedBindingBuilder

    M  A B C E F G H I K L N P S T TOP
    Matchers
    Message
    Module

    N  A B C E F G H I K L M P S T TOP
    Names

    P  A B C E F G H I K L M N S T TOP
    Provider

    S  A B C E F G H I K L M N P T TOP
    Scope
    scope (Key<T>, Provider<T>)
    ScopeAnnotation
    ScopedBindingBuilder
    Scopes
    ServletModule
    ServletScopes

    T  A B C E F G H I K L M N P S TOP
    to
      type  (Key<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (TypeLiteral<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Class<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
    toInstance (T)
    toString
      type  () in com.google.inject.Key
      type  () in com.google.inject.TypeLiteral
    TypeLiteral
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/alldiffs_index_all.html0000755000175000017500000022160311704661106026155 0ustar tonytony All Differences Index
    All Differences
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    A  B C D E F G H I K L M N O P R S T U W TOP
    AbstractModule
    acceptScopingVisitor (BindingScopingVisitor<V>)
    acceptTargetVisitor (BindingTargetVisitor<? super T, V>)
    acceptVisitor (ElementVisitor<T>)
    addError
      type  (Message) in com.google.inject.AbstractModule
      type  (Message) in com.google.inject.Binder
    AnnotatedBindingBuilder
    AnnotatedConstantBindingBuilder
    AnnotatedElementBuilder
    annotatedWith
      type  (Class<Annotation>) in com.google.inject.binder.AnnotatedBindingBuilder
      type  (Annotation) in com.google.inject.binder.AnnotatedBindingBuilder
      type  (Class<Annotation>) in com.google.inject.binder.AnnotatedConstantBindingBuilder
      type  (Annotation) in com.google.inject.binder.AnnotatedConstantBindingBuilder
    applyTo (Binder)
    asEagerSingleton ()

    B  A C D E F G H I K L M N O P R S T U W TOP
    bind
      type  (TypeLiteral<T>) in com.google.inject.Binder
      type  (Class<T>) in com.google.inject.Binder
      type  (Key<T>) in com.google.inject.Binder
    bindConstant ()
    Binder
    Binding
    BindingAnnotation
    BindingScopingVisitor
    BindingTargetVisitor
    bindInterceptor
      type  (Matcher<Class<?>>, Matcher<Method>, MethodInterceptor[]) in com.google.inject.AbstractModule
      type  (Matcher<Class<?>>, Matcher<Method>, MethodInterceptor[]) in com.google.inject.Binder
    bindListener
      type  (Matcher<TypeLiteral<?>>, TypeListener) in com.google.inject.AbstractModule
      type  (Matcher<TypeLiteral<?>>, TypeListener) in com.google.inject.Binder
    bindProperties
      type  (Binder, Map<String, String>) in com.google.inject.name.Names
      type  (Binder, Properties) in com.google.inject.name.Names
    com.google.inject
    com.google.inject.assistedinject
    com.google.inject.binder
    com.google.inject.matcher
    com.google.inject.multibindings
    com.google.inject.name
    com.google.inject.persist
    com.google.inject.persist.finder
    com.google.inject.persist.jpa
    com.google.inject.servlet
    com.google.inject.spi
    com.google.inject.struts2
    com.google.inject.throwingproviders
    com.google.inject.util
    ConfigurationException
    configure
      type  (Binder) in com.google.inject.Module
      type  () in com.google.inject.servlet.ServletModule
    configureServlets ()
    ConstantBindingBuilder
    ConstructorBinding
    continueRequest (Callable<T>, Map<Key<?>, Object>)
    ConvertedConstantBinding
    convertToTypes
      type  (Matcher<TypeLiteral<?>>, TypeConverter) in com.google.inject.AbstractModule
      type  (Matcher<TypeLiteral<?>>, TypeConverter) in com.google.inject.Binder
    createChildInjector
      type  (Module[]) in com.google.inject.Injector
      type  (Iterable<Module>) in com.google.inject.Injector
    createInjector
      type  (Stage, Iterable<Module>) in com.google.inject.Guice
      type  (Iterable<Module>) in com.google.inject.Guice
      type  (Stage, Iterable<Module>) in com.google.inject.Guice
      type  (Iterable<Module>) in com.google.inject.Guice
      type  (Module[]) in com.google.inject.Guice
      type  (Stage, Module[]) in com.google.inject.Guice
    CreationException
      com.google.inject
      CreationException (Collection<Message>) constructor
    currentStage ()

    D  A B C E F G H I K L M N O P R S T U W TOP
    DefaultBindingScopingVisitor
    DefaultBindingTargetVisitor
    DefaultElementVisitor
    Dependency

    E  A B C D F G H I K L M N O P R S T U W TOP
    Element
    Elements
    ElementVisitor
    equals
      type  (Object) in com.google.inject.Key
      type  (Object) in com.google.inject.TypeLiteral
    Exposed
    ExposedBinding

    F  A B C D E G H I K L M N O P R S T U W TOP
    filter (String, String[])
    filterRegex (String, String[])
    findBindingsByType (TypeLiteral<T>)

    G  A B C D E F H I K L M N O P R S T U W TOP
    get ()
    getAllBindings ()
    getAnnotation ()
    getAnnotationType ()
    getBinding
      type  (Class<T>) in com.google.inject.Injector
      type  (Key<T>) in com.google.inject.Injector
    getBindings ()
    getCause ()
    getErrorMessages ()
    getExceptionTypes (Member)
    getExistingBinding (Key<T>)
    getFieldType (Field)
    getInstance
      type  (Key<T>) in com.google.inject.Injector
      type  (Class<T>) in com.google.inject.Injector
    getMembersInjector
      type  (TypeLiteral<T>) in com.google.inject.AbstractModule
      type  (Class<T>) in com.google.inject.AbstractModule
      type  (TypeLiteral<T>) in com.google.inject.Binder
      type  (Class<T>) in com.google.inject.Binder
      type  (TypeLiteral<T>) in com.google.inject.Injector
      type  (Class<T>) in com.google.inject.Injector
    getParameterTypes (Member)
    getParent ()
    getProvider
      type  (Key<T>) in com.google.inject.AbstractModule
      type  (Class<T>) in com.google.inject.AbstractModule
      type  (Key<T>) in com.google.inject.Binder
      type  (Class<T>) in com.google.inject.Binder
      type  () in com.google.inject.Binding
      type  (Key<T>) in com.google.inject.Injector
      type  (Class<T>) in com.google.inject.Injector
    getRawType ()
    getReturnType (Method)
    getScopeBindings ()
    getServletContext ()
    getSource
      type  () in com.google.inject.Binding
      type  () in com.google.inject.spi.Message
    getSources ()
    getSourceString ()
    getSupertype (Class<?>)
    getType ()
    getTypeLiteral ()
    Guice
    GuiceFilter
    GuiceObjectFactory
    GuiceServletContextListener

    H  A B C D E F G I K L M N O P R S T U W TOP
    hasAttributes ()
    HasDependencies
    hashCode
      type  () in com.google.inject.Key
      type  () in com.google.inject.TypeLiteral

    I  A B C D E F G H K L M N O P R S T U W TOP
    in
      type  (Scope) in com.google.inject.binder.ScopedBindingBuilder
      type  (Class<Annotation>) in com.google.inject.binder.ScopedBindingBuilder
    InjectionListener
    InjectionPoint
    InjectionRequest
    injectMembers (Object)
    Injector
    InjectorBuilder
    inPackage (Package)
    InstanceBinding
    InstanceFilterBinding
    InstanceServletBinding
    inSubpackage (String)
    InterceptorBinding
    isSingleton (Binding<?>)

    K  A B C D E F G H I L M N O P R S T U W TOP
    Key

    L  A B C D E F G H I K M N O P R S T U W TOP
    LinkedBindingBuilder
    LinkedFilterBinding
    LinkedKeyBinding
    LinkedServletBinding

    M  A B C D E F G H I K L N O P R S T U W TOP
    Matchers
    MembersInjector
    MembersInjectorLookup
    Message
      com.google.inject.spi
      Message (List<Object>, String, Throwable) constructor
    Module

    N  A B C D E F G H I K L M O P R S T U W TOP
    Names
    newPrivateBinder ()
    NO_SCOPE

    O  A B C D E F G H I K L M N P R S T U W TOP
    ofType
      type  (Type) in com.google.inject.Key
      type  (TypeLiteral<T>) in com.google.inject.Key
      type  (Class<T>) in com.google.inject.Key
    OutOfScopeException

    P  A B C D E F G H I K L M N O R S T U W TOP
    PrivateBinder
    PrivateElements
    PrivateModule
    Provider
    ProviderBinding
    ProviderInstanceBinding
    ProviderKeyBinding
    ProviderLookup
    ProviderWithDependencies
    ProviderWithExtensionVisitor
    Provides
    ProvisionException

    R  A B C D E F G H I K L M N O P S T U W TOP
    requestInjection
      type  (Object) in com.google.inject.AbstractModule
      type  (TypeLiteral<T>, T) in com.google.inject.Binder
      type  (Object) in com.google.inject.Binder
    requireBinding
      type  (Key<?>) in com.google.inject.AbstractModule
      type  (Class<?>) in com.google.inject.AbstractModule

    S  A B C D E F G H I K L M N O P R T U W TOP
    Scope
    scope (Key<T>, Provider<T>)
    ScopeAnnotation
    ScopeBinding
    ScopedBindingBuilder
    scopeRequest (Callable<T>, Map<Key<?>, Object>)
    Scopes
    serve (String, String[])
    serveRegex (String, String[])
    ServletModule
    ServletModule.FilterKeyBindingBuilder
    ServletModule.ServletKeyBindingBuilder
    ServletModuleTargetVisitor
    ServletScopes
    skipSources (Class[])
    SourceProvider
    SourceProviders
    StaticInjectionRequest
    Struts2Factory

    T  A B C D E F G H I K L M N O P R S U W TOP
    to
      type  (byte) in com.google.inject.binder.ConstantBindingBuilder
      type  (Key<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (TypeLiteral<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Class<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
    toConstructor
      type  (Constructor<S>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Constructor<S>, TypeLiteral<? extends S>) in com.google.inject.binder.LinkedBindingBuilder
    toInstance (T)
    Toolable
    toProvider
      type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Provider<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Provider<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (TypeLiteral<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
    toString
      type  () in com.google.inject.Key
      type  () in com.google.inject.TypeLiteral
    TypeConverter
    TypeConverterBinding
    TypeEncounter
    TypeListener
    TypeListenerBinding
    TypeLiteral

    U  A B C D E F G H I K L M N O P R S T W TOP
    UntargettedBinding
    UriPatternType

    W  A B C D E F G H I K L M N O P R S T U TOP
    withoutAttributes ()
    withSource (Object)
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes/alldiffs_index_additions.html0000755000175000017500000014245511704661106027372 0ustar tonytony All Additions Index
    All Differences
    Removals
    Additions
    Changes
    Bold is New, strike is deleted


    A  B C D E F G H I L M N O P R S T U W TOP
    acceptScopingVisitor (BindingScopingVisitor<V>)
    acceptTargetVisitor (BindingTargetVisitor<? super T, V>)
    acceptVisitor (ElementVisitor<T>)
    addError
      type  (Message) in com.google.inject.AbstractModule
      type  (Message) in com.google.inject.Binder
    AnnotatedElementBuilder
    applyTo (Binder)

    B  A C D E F G H I L M N O P R S T U W TOP
    BindingScopingVisitor
    BindingTargetVisitor
    bindListener
      type  (Matcher<TypeLiteral<?>>, TypeListener) in com.google.inject.AbstractModule
      type  (Matcher<TypeLiteral<?>>, TypeListener) in com.google.inject.Binder
    com.google.inject.assistedinject
    com.google.inject.multibindings
    com.google.inject.persist
    com.google.inject.persist.finder
    com.google.inject.persist.jpa
    com.google.inject.throwingproviders
    com.google.inject.util
    ConfigurationException
    configureServlets ()
    ConstructorBinding
    continueRequest (Callable<T>, Map<Key<?>, Object>)
    ConvertedConstantBinding
    convertToTypes
      type  (Matcher<TypeLiteral<?>>, TypeConverter) in com.google.inject.AbstractModule
      type  (Matcher<TypeLiteral<?>>, TypeConverter) in com.google.inject.Binder
    createChildInjector
      type  (Module[]) in com.google.inject.Injector
      type  (Iterable<Module>) in com.google.inject.Injector
    createInjector
      type  (Stage, Iterable<Module>) in com.google.inject.Guice
      type  (Iterable<Module>) in com.google.inject.Guice
    currentStage ()

    D  A B C E F G H I L M N O P R S T U W TOP
    DefaultBindingScopingVisitor
    DefaultBindingTargetVisitor
    DefaultElementVisitor
    Dependency

    E  A B C D F G H I L M N O P R S T U W TOP
    Element
    Elements
    ElementVisitor
    Exposed
    ExposedBinding

    F  A B C D E G H I L M N O P R S T U W TOP
    filter (String, String[])
    filterRegex (String, String[])

    G  A B C D E F H I L M N O P R S T U W TOP
    getAllBindings ()
    getBinding (Class<T>)
    getCause ()
    getExceptionTypes (Member)
    getExistingBinding (Key<T>)
    getFieldType (Field)
    getMembersInjector
      type  (TypeLiteral<T>) in com.google.inject.AbstractModule
      type  (Class<T>) in com.google.inject.AbstractModule
      type  (TypeLiteral<T>) in com.google.inject.Binder
      type  (Class<T>) in com.google.inject.Binder
      type  (TypeLiteral<T>) in com.google.inject.Injector
      type  (Class<T>) in com.google.inject.Injector
    getParameterTypes (Member)
    getParent ()
    getProvider
      type  (Key<T>) in com.google.inject.AbstractModule
      type  (Class<T>) in com.google.inject.AbstractModule
      type  (Key<T>) in com.google.inject.Binder
      type  (Class<T>) in com.google.inject.Binder
    getRawType ()
    getReturnType (Method)
    getScopeBindings ()
    getServletContext ()
    getSources ()
    getSupertype (Class<?>)
    GuiceServletContextListener

    H  A B C D E F G I L M N O P R S T U W TOP
    hasAttributes ()
    HasDependencies

    I  A B C D E F G H L M N O P R S T U W TOP
    InjectionListener
    InjectionPoint
    InjectionRequest
    InjectorBuilder
    InstanceBinding
    InstanceFilterBinding
    InstanceServletBinding
    inSubpackage (String)
    InterceptorBinding
    isSingleton (Binding<?>)

    L  A B C D E F G H I M N O P R S T U W TOP
    LinkedFilterBinding
    LinkedKeyBinding
    LinkedServletBinding

    M  A B C D E F G H I L N O P R S T U W TOP
    MembersInjector
    MembersInjectorLookup
    Message (List<Object>, String, Throwable) constructor

    N  A B C D E F G H I L M O P R S T U W TOP
    newPrivateBinder ()
    NO_SCOPE

    O  A B C D E F G H I L M N P R S T U W TOP
    ofType
      type  (Type) in com.google.inject.Key
      type  (TypeLiteral<T>) in com.google.inject.Key
      type  (Class<T>) in com.google.inject.Key
    OutOfScopeException

    P  A B C D E F G H I L M N O R S T U W TOP
    PrivateBinder
    PrivateElements
    PrivateModule
    ProviderBinding
    ProviderInstanceBinding
    ProviderKeyBinding
    ProviderLookup
    ProviderWithDependencies
    ProviderWithExtensionVisitor
    Provides
    ProvisionException

    R  A B C D E F G H I L M N O P S T U W TOP
    requestInjection
      type  (Object) in com.google.inject.AbstractModule
      type  (TypeLiteral<T>, T) in com.google.inject.Binder
      type  (Object) in com.google.inject.Binder
    requireBinding
      type  (Key<?>) in com.google.inject.AbstractModule
      type  (Class<?>) in com.google.inject.AbstractModule

    S  A B C D E F G H I L M N O P R T U W TOP
    ScopeBinding
    scopeRequest (Callable<T>, Map<Key<?>, Object>)
    serve (String, String[])
    serveRegex (String, String[])
    ServletModule.FilterKeyBindingBuilder
    ServletModule.ServletKeyBindingBuilder
    ServletModuleTargetVisitor
    skipSources (Class[])
    StaticInjectionRequest
    Struts2Factory

    T  A B C D E F G H I L M N O P R S U W TOP
    to (byte)
    toConstructor
      type  (Constructor<S>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Constructor<S>, TypeLiteral<? extends S>) in com.google.inject.binder.LinkedBindingBuilder
    Toolable
    toProvider
      type  (Key<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Provider<? extends T>) in com.google.inject.binder.LinkedBindingBuilder
      type  (TypeLiteral<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
      type  (Class<Provider<? extends T>>) in com.google.inject.binder.LinkedBindingBuilder
    TypeConverter
    TypeConverterBinding
    TypeEncounter
    TypeListener
    TypeListenerBinding

    U  A B C D E F G H I L M N O P R S T W TOP
    UntargettedBinding
    UriPatternType

    W  A B C D E F G H I L M N O P R S T U TOP
    withoutAttributes ()
    withSource (Object)
    sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/changes.html0000644000175000017500000000270111704661106022343 0ustar tonytony API Differences between 1.0 and 2.0 <H2> Frame Alert </H2> <P> This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. <BR> Link to <A HREF="changes/changes-summary.html" target="_top">Non-frame version.</A> sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/black.gif0000644000175000017500000000143711704661106021615 0ustar tonytonyGIF89aїџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ,;sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0/background.gif0000644000175000017500000000105711704661106022656 0ustar tonytonyGIF89ahh€ѕѕѕ!љ,hhџ„ЉЫэЃœДк‹ГоМћ†тH–ц‰ІъЪЖю ЧђLзічњЮїў ‡ФЂёˆL*—ЬІѓ JЇдЊѕŠЭjЗмЎї ‹ЧфВљŒNЋзьЖћ ЫчєК§ŽЯыїќОџ(8HXhxˆ˜ЈИШишј)9IYiy‰™ЉЙЩйщљ *:JZjzŠšЊКЪкъњ +;K[k{‹›ЋЛЫлыћ ,N^n~ŽžЎОЮоюў/?O_oŸЏПЯпяџ0 Р <ˆ0ЁТ… :|1ЂФ‰+ZМˆ1ЃЦџ;zќ2ЄШ‘$Kš<‰2ЅЪ•,[К| 3ІЬ™4kкМ‰3ЇЮ<{њќ 4ЈаЁD‹=Š4ЉвЅL›:} 5ЊдЉTЋZНŠ5Ћж­\Лz§ 6ЌиБdЫš=‹6­кЕlлК} 7ЎмЙtыкН‹7ЏоН|ћњ§ 8АрС„ >Œ8БтХŒ;~ 9ВфЩ”+[ОŒ9ГцЭœ;{ў :ДшбЄK›>:ЕъеЌ[Л~ ;ЖьйДkлО;ЗюнМ{ћў <И№сФ‹?Ž<ЙђхЬ›;=КєщдЋ[ПŽ=ЛіэмЛ{џ>МјёфЫ›?>НњѕьлЛ?ОќљєылП?Пў§ќћћџ O;sisu-guice-sisu-guice-3.1.1/latest-api-diffs/2.0.xml0000644000175000017500000106250011704661106020573 0ustar tonytony public class MyModule extends AbstractModule { protected void configure() { bind(Service.class).to(ServiceImpl.class).in(Singleton.class); bind(CreditCardPaymentService.class); bind(PaymentService.class).to(CreditCardPaymentService.class); bindConstant().annotatedWith(Names.named("port")).to(8080); } } @author crazybob@google.com (Bob Lee)]]>

  • Guice created the instance the method is on
  • Neither the enclosing type nor the method is final
  • And the method is package-private, protected, or public
  • @param classMatcher matches classes the interceptor should apply to. For example: {@code only(Runnable.class)}. @param methodMatcher matches methods the interceptor should apply to. For example: {@code annotatedWith(Transactional.class)}. @param interceptors to bind]]>
    bindings) which will be used to create an {@link Injector}. Guice provides this object to your application's {@link Module} implementors so they may each contribute their own bindings and other registrations.

    The Guice Binding EDSL

    Guice uses an embedded domain-specific language, or EDSL, to help you create bindings simply and readably. This approach is great for overall usability, but it does come with a small cost: it is difficult to learn how to use the Binding EDSL by reading method-level javadocs. Instead, you should consult the series of examples below. To save space, these examples omit the opening {@code binder}, just as you will if your module extends {@link AbstractModule}.
         bind(ServiceImpl.class);
    This statement does essentially nothing; it "binds the {@code ServiceImpl} class to itself" and does not change Guice's default behavior. You may still want to use this if you prefer your {@link Module} class to serve as an explicit manifest for the services it provides. Also, in rare cases, Guice may be unable to validate a binding at injector creation time unless it is given explicitly.
         bind(Service.class).to(ServiceImpl.class);
    Specifies that a request for a {@code Service} instance with no binding annotations should be treated as if it were a request for a {@code ServiceImpl} instance. This overrides the function of any {@link ImplementedBy @ImplementedBy} or {@link ProvidedBy @ProvidedBy} annotations found on {@code Service}, since Guice will have already "moved on" to {@code ServiceImpl} before it reaches the point when it starts looking for these annotations.
         bind(Service.class).toProvider(ServiceProvider.class);
    In this example, {@code ServiceProvider} must extend or implement {@code Provider}. This binding specifies that Guice should resolve an unannotated injection request for {@code Service} by first resolving an instance of {@code ServiceProvider} in the regular way, then calling {@link Provider#get get()} on the resulting Provider instance to obtain the {@code Service} instance.

    The {@link Provider} you use here does not have to be a "factory"; that is, a provider which always creates each instance it provides. However, this is generally a good practice to follow. You can then use Guice's concept of {@link Scope scopes} to guide when creation should happen -- "letting Guice work for you".

         bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);
    Like the previous example, but only applies to injection requests that use the binding annotation {@code @Red}. If your module also includes bindings for particular values of the {@code @Red} annotation (see below), then this binding will serve as a "catch-all" for any values of {@code @Red} that have no exact match in the bindings.
         bind(ServiceImpl.class).in(Singleton.class);
         // or, alternatively
         bind(ServiceImpl.class).in(Scopes.SINGLETON);
    Either of these statements places the {@code ServiceImpl} class into singleton scope. Guice will create only one instance of {@code ServiceImpl} and will reuse it for all injection requests of this type. Note that it is still possible to bind another instance of {@code ServiceImpl} if the second binding is qualified by an annotation as in the previous example. Guice is not overly concerned with preventing you from creating multiple instances of your "singletons", only with enabling your application to share only one instance if that's all you tell Guice you need.

    Note: a scope specified in this way overrides any scope that was specified with an annotation on the {@code ServiceImpl} class.

    Besides {@link Singleton}/{@link Scopes#SINGLETON}, there are servlet-specific scopes available in {@code com.google.inject.servlet.ServletScopes}, and your Modules can contribute their own custom scopes for use here as well.

         bind(new TypeLiteral<PaymentService<CreditCard>>() {})
             .to(CreditCardPaymentService.class);
    This admittedly odd construct is the way to bind a parameterized type. It tells Guice how to honor an injection request for an element of type {@code PaymentService}. The class {@code CreditCardPaymentService} must implement the {@code PaymentService} interface. Guice cannot currently bind or inject a generic type, such as {@code Set}; all type parameters must be fully specified.
         bind(Service.class).toInstance(new ServiceImpl());
         // or, alternatively
         bind(Service.class).toInstance(SomeLegacyRegistry.getService());
    In this example, your module itself, not Guice, takes responsibility for obtaining a {@code ServiceImpl} instance, then asks Guice to always use this single instance to fulfill all {@code Service} injection requests. When the {@link Injector} is created, it will automatically perform field and method injection for this instance, but any injectable constructor on {@code ServiceImpl} is simply ignored. Note that using this approach results in "eager loading" behavior that you can't control.
         bindConstant().annotatedWith(ServerHost.class).to(args[0]);
    Sets up a constant binding. Constant injections must always be annotated. When a constant binding's value is a string, it is eligile for conversion to all primitive types, to {@link Enum#valueOf(Class, String) all enums}, and to {@link Class#forName class literals}. Conversions for other types can be configured using {@link #convertToTypes(Matcher, TypeConverter) convertToTypes()}.
       {@literal @}Color("red") Color red; // A member variable (field)
        . . .
         red = MyModule.class.getDeclaredField("red").getAnnotation(Color.class);
         bind(Service.class).annotatedWith(red).to(RedService.class);
    If your binding annotation has parameters you can apply different bindings to different specific values of your annotation. Getting your hands on the right instance of the annotation is a bit of a pain -- one approach, shown above, is to apply a prototype annotation to a field in your module class, so that you can read this annotation instance and give it to Guice.
         bind(Service.class)
             .annotatedWith(Names.named("blue"))
             .to(BlueService.class);
    Differentiating by names is a common enough use case that we provided a standard annotation, {@link com.google.inject.name.Named @Named}. Because of Guice's library support, binding by name is quite easier than in the arbitrary binding annotation case we just saw. However, remember that these names will live in a single flat namespace with all the other names used in your application.

    The above list of examples is far from exhaustive. If you can think of how the concepts of one example might coexist with the concepts from another, you can most likely weave the two together. If the two concepts make no sense with each other, you most likely won't be able to do it. In a few cases Guice will let something bogus slip by, and will then inform you of the problems at runtime, as soon as you try to create your Injector.

    The other methods of Binder such as {@link #bindScope}, {@link #bindInterceptor}, {@link #install}, {@link #requestStaticInjection}, {@link #addError} and {@link #currentStage} are not part of the Binding EDSL; you can learn how to use these in the usual way, from the method documentation. @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson) @author kevinb@google.com (Kevin Bourrillion)]]> Bindings are created in several ways:

    • Explicitly in a module, via {@code bind()} and {@code bindConstant()} statements:
           bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);
           bindConstant().annotatedWith(ServerHost.class).to(args[0]);
    • Implicitly by the Injector by following a type's {@link ImplementedBy pointer} {@link ProvidedBy annotations} or by using its {@link Inject annotated} or default constructor.
    • By converting a bound instance to a different type.
    • For {@link Provider providers}, by delegating to the binding for the provided type.

    They exist on both modules and on injectors, and their behaviour is different for each:

    • Module bindings are incomplete and cannot be used to provide instances. This is because the applicable scopes and interceptors may not be known until an injector is created. From a tool's perspective, module bindings are like the injector's source code. They can be inspected or rewritten, but this analysis must be done statically.
    • Injector bindings are complete and valid and can be used to provide instances. From a tools' perspective, injector bindings are like reflection for an injector. They have full runtime information, including the complete graph of injections necessary to satisfy a binding.
    @param the bound type. The injected is always assignable to this type. @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson)]]>
    {@code @}Retention(RUNTIME) {@code @}Target({ FIELD, PARAMETER, METHOD }) {@code @}BindingAnnotation public {@code @}interface Transactional {} @author crazybob@google.com (Bob Lee)]]> Guice supports a model of development that draws clear boundaries between APIs, Implementations of these APIs, Modules which configure these implementations, and finally Applications which consist of a collection of Modules. It is the Application, which typically defines your {@code main()} method, that bootstraps the Guice Injector using the {@code Guice} class, as in this example:
         public class FooApplication {
           public static void main(String[] args) {
             Injector injector = Guice.createInjector(
                 new ModuleA(),
                 new ModuleB(),
                 . . .
                 new FooApplicationFlagsModule(args)
             );
    
             // Now just bootstrap the application and you're done
             FooStarter starter = injector.getInstance(FooStarter.class);
             starter.runApplication();
           }
         }
     
    ]]>
  • Every instance it constructs. The class being constructed must have exactly one of its constructors marked with {@code @Inject} or must have a constructor taking no parameters. The Injector then proceeds to perform method and field injections.
  • Pre-constructed instances passed to {@link Injector#injectMembers}, {@link com.google.inject.binder.LinkedBindingBuilder#toInstance(Object)} and {@link com.google.inject.binder.LinkedBindingBuilder#toProvider(Provider)}. In this case all constructors are, of course, ignored.
  • Static fields and methods of classes which any {@link Module} has specifically requested static injection for, using {@link Binder#requestStaticInjection}. In all cases, a member can be injected regardless of its Java access specifier (private, default, protected, public). @author crazybob@google.com (Bob Lee)]]> Whenever Guice creates an instance, it performs this injection automatically (after first performing constructor injection), so if you're able to let Guice create all your objects for you, you'll never need to use this method. @param instance to inject members on @see Binder#getMembersInjector(Class) for a preferred alternative that supports checks before run time]]> The returned map does not include bindings inherited from a {@link #getParent() parent injector}, should one exist. The returned map is guaranteed to iterate (for example, with its {@link java.util.Map#entrySet()} iterator) in the order of insertion. In other words, the order in which bindings appear in user Modules.

    This method is part of the Guice SPI and is intended for use by tools and extensions.]]> This method is part of the Guice SPI and is intended for use by tools and extensions. @throws ConfigurationException if this injector cannot find or create the binding.]]> This method is part of the Guice SPI and is intended for use by tools and extensions. @throws ConfigurationException if this injector cannot find or create the binding. @since 2.0]]> This method is part of the Guice SPI and is intended for use by tools and extensions.]]> Just-in-time bindings created for child injectors will be created in an ancestor injector whenever possible. This allows for scoped instances to be shared between injectors. Use explicit bindings to prevent bindings from being shared with the parent injector.

    No key may be bound by both an injector and one of its ancestors. This includes just-in-time bindings. The lone exception is the key for {@code Injector.class}, which is bound by each injector to itself. @since 2.0]]> Just-in-time bindings created for child injectors will be created in an ancestor injector whenever possible. This allows for scoped instances to be shared between injectors. Use explicit bindings to prevent bindings from being shared with the parent injector.

    No key may be bound by both an injector and one of its ancestors. This includes just-in-time bindings. The lone exception is the key for {@code Injector.class}, which is bound by each injector to itself. @since 2.0]]> Contains several default bindings:

    • This {@link Injector} instance itself
    • A {@code Provider} for each binding of type {@code T}
    • The {@link java.util.logging.Logger} for the class being injected
    • The {@link Stage} in which the Injector was created
    Injectors are created using the facade class {@link Guice}.

    An injector can also {@link #injectMembers(Object) inject the dependencies} of already-constructed instances. This can be used to interoperate with objects created by other frameworks or services.

    Injectors can be {@link #createChildInjector(Iterable) hierarchical}. Child injectors inherit the configuration of their parent injectors, but the converse does not hold.

    The injector's {@link #getBindings() internal bindings} are available for introspection. This enables tools and extensions to operate on an injector reflectively. @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson)]]> Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

    Example usage for a binding of type {@code Foo} annotated with {@code @Bar}:

    {@code new Key(Bar.class) {}}.]]> Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

    Example usage for a binding of type {@code Foo} annotated with {@code @Bar}:

    {@code new Key(new Bar()) {}}.]]> Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

    Example usage for a binding of type {@code Foo}:

    {@code new Key() {}}.]]> For example, {@code Key.get(Service.class, Transactional.class)} will match:

       {@literal @}Inject
       public void setService({@literal @}Transactional Service service) {
         ...
       }
     

    {@code Key} supports generic types via subclassing just like {@link TypeLiteral}.

    Keys do not differentiate between primitive types (int, char, etc.) and their correpsonding wrapper types (Integer, Character, etc.). Primitive types will be replaced with their wrapper types when keys are created. @author crazybob@google.com (Bob Lee)]]> Whenever Guice creates an instance, it performs this injection automatically (after first performing constructor injection), so if you're able to let Guice create all your objects for you, you'll never need to use this method. @param instance to inject members on. May be {@code null}.]]> type to inject members of @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> Do not invoke this method directly to install submodules. Instead use {@link Binder#install(Module)}, which ensures that {@link Provides provider methods} are discovered.]]> Your Module classes can use a more streamlined syntax by extending {@link AbstractModule} rather than implementing this interface directly.

    In addition to the bindings configured via {@link #configure}, bindings will be created for all methods annotated with {@literal @}{@link Provides}. Use scope and binding annotations on these methods to configure the bindings.]]> A private module can be nested within a regular module or within another private module using {@link Binder#install install()}. Its bindings live in a new environment that inherits bindings, type converters, scopes, and interceptors from the surrounding ("parent") environment. When you nest multiple private modules, the result is a tree of environments where the injector's environment is the root.

    Guice EDSL bindings can be exposed with {@link #expose(Class) expose()}. {@literal @}{@link com.google.inject.Provides Provides} bindings can be exposed with the {@literal @}{@link Exposed} annotation:

     public class FooBarBazModule extends PrivateModule {
       protected void configure() {
         bind(Foo.class).to(RealFoo.class);
         expose(Foo.class);
    
         install(new TransactionalBarModule());
         expose(Bar.class).annotatedWith(Transactional.class);
    
         bind(SomeImplementationDetail.class);
         install(new MoreImplementationDetailsModule());
       }
    
       {@literal @}Provides {@literal @}Exposed
       public Baz provideBaz() {
         return new SuperBaz();
       }
     }
     

    Private modules are implemented using {@link Injector#createChildInjector(Module[]) parent injectors}. When it can satisfy their dependencies, just-in-time bindings will be created in the root environment. Such bindings are shared among all environments in the tree.

    The scope of a binding is constrained to its environment. A singleton bound in a private module will be unique to its environment. But a binding for the same type in a different private module will yield a different instance.

    A shared binding that injects the {@code Injector} gets the root injector, which only has access to bindings in the root environment. An explicit binding that injects the {@code Injector} gets access to all bindings in the child environment.

    To promote a just-in-time binding to an explicit binding, bind it:

       bind(FooImpl.class);
     
    @author jessewilson@google.com (Jesse Wilson) @since 2.0]]>
  • When the default means for obtaining instances (an injectable or parameterless constructor) is insufficient for a particular binding, the module can specify a custom {@code Provider} instead, to control exactly how Guice creates or obtains instances for the binding.
  • An implementation class may always choose to have a {@code Provider} instance injected, rather than having a {@code T} injected directly. This may give you access to multiple instances, instances you wish to safely mutate and discard, instances which are out of scope (e.g. using a {@code @RequestScoped} object from within a {@code @SessionScoped} object), or instances that will be initialized lazily.
  • A custom {@link Scope} is implemented as a decorator of {@code Provider}, which decides when to delegate to the backing provider and when to provide the instance some other way.
  • The {@link Injector} offers access to the {@code Provider} it uses to fulfill requests for a given key, via the {@link Injector#getProvider} methods. @param the type of object this provides @author crazybob@google.com (Bob Lee)]]> Scope implementations are strongly encouraged to override {@link Object#toString} in the returned provider and include the backing provider's {@code toString()} output. @param key binding key @param unscoped locates an instance when one doesn't already exist in this scope. @return a new provider which only delegates to the given unscoped provider when an instance of the requested object doesn't already exist in this scope]]> no scope, meaning it has no state from the framework's perspective -- the {@code Injector} creates it, injects it once into the class that required it, and then immediately forgets it. Associating a scope with a particular binding allows the created instance to be "remembered" and possibly used again for other injections.

    An example of a scope is {@link Scopes#SINGLETON}. @author crazybob@google.com (Bob Lee)]]> {@code @}Retention(RUNTIME) {@code @}Target(TYPE) {@code @}ScopeAnnotation public {@code @}interface SessionScoped {} @author crazybob@google.com (Bob Lee)]]> This exists only in case a class has been annotated with a scope annotation such as {@link Singleton @Singleton}, and you need to override this to "no scope" in your binding. @since 2.0]]> Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.]]> }, this returns {@code Iterable} given the input {@code Iterable.class}. @param supertype a superclass of, or interface implemented by, this. @since 2.0]]> For example, to create a type literal for {@code List}, you can create an empty anonymous inner class:

    {@code TypeLiteral> list = new TypeLiteral>() {};}

    This syntax cannot be used to create type literals that have wildcard parameters, such as {@code Class} or {@code List}. Such type literals must be constructed programatically, either by {@link Method#getGenericReturnType extracting types from members} or by using the {@link Types} factory class.

    Along with modeling generic types, this class can resolve type parameters. For example, to figure out what type {@code keySet()} returns on a {@code Map}, use this code:

       {@code
    
       TypeLiteral> mapType
           = new TypeLiteral>() {};
       TypeLiteral keySetType
           = mapType.getReturnType(Map.class.getMethod("keySet"));
       System.out.println(keySetType); // prints "Set"}
    @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson)]]>
    Constructors annotated with {@code @AssistedInject} indicate that they can be instantiated by the {@link FactoryProvider}. Each constructor must exactly match one corresponding factory method within the factory interface.

    Constructor parameters must be either supplied by the factory interface and marked with @Assisted, or they must be injectable. @deprecated {@link FactoryProvider} now works better with the standard {@literal @Inject} annotation. When using that annotation, parameters are matched by name and type rather than by position. In addition, values that use the standard {@literal @Inject} constructor annotation are eligible for method interception. @author jmourits@google.com (Jerome Mourits) @author jessewilson@google.com (Jesse Wilson)]]> Defining a factory Create an interface whose methods return the constructed type, or any of its supertypes. The method's parameters are the arguments required to build the constructed type.

    public interface PaymentFactory {
       Payment create(Date startDate, Money amount);
     }
    You can name your factory methods whatever you like, such as create, createPayment or newPayment.

    Creating a type that accepts factory parameters

    {@code constructedType} is a concrete class with an {@literal @}{@link Inject}-annotated constructor. In addition to injector-supplied parameters, the constructor should have parameters that match each of the factory method's parameters. Each factory-supplied parameter requires an {@literal @}{@link Assisted} annotation. This serves to document that the parameter is not bound by your application's modules.
    public class RealPayment implements Payment {
       {@literal @}Inject
       public RealPayment(
          CreditService creditService,
          AuthService authService,
          {@literal @}Assisted Date startDate,
          {@literal @}Assisted Money amount) {
         ...
       }
     }
    Any parameter that permits a null value should also be annotated {@code @Nullable}.

    Configuring factories

    In your {@link com.google.inject.Module module}, bind the factory interface to the returned factory:
    bind(PaymentFactory.class).toProvider(
         FactoryProvider.newFactory(PaymentFactory.class, RealPayment.class));
    As a side-effect of this binding, Guice will inject the factory to initialize it for use. The factory cannot be used until the injector has been initialized.

    Using the factory

    Inject your factory into your application classes. When you use the factory, your arguments will be combined with values from the injector to construct an instance.
    public class PaymentAction {
       {@literal @}Inject private PaymentFactory paymentFactory;
    
       public void doPayment(Money amount) {
         Payment payment = paymentFactory.create(new Date(), amount);
         payment.apply();
       }
     }

    Making parameter types distinct

    The types of the factory method's parameters must be distinct. To use multiple parameters of the same type, use a named {@literal @}{@link Assisted} annotation to disambiguate the parameters. The names must be applied to the factory method's parameters:
    public interface PaymentFactory {
       Payment create(
           {@literal @}Assisted("startDate") Date startDate,
           {@literal @}Assisted("dueDate") Date dueDate,
           Money amount);
     } 
    ...and to the concrete type's constructor parameters:
    public class RealPayment implements Payment {
       {@literal @}Inject
       public RealPayment(
          CreditService creditService,
          AuthService authService,
          {@literal @}Assisted("startDate") Date startDate,
          {@literal @}Assisted("dueDate") Date dueDate,
          {@literal @}Assisted Money amount) {
         ...
       }
     }

    Values are created by Guice

    Returned factories use child injectors to create values. The values are eligible for method interception. In addition, {@literal @}{@literal Inject} members will be injected before they are returned.

    Backwards compatibility using {@literal @}AssistedInject

    Instead of the {@literal @}Inject annotation, you may annotate the constructed classes with {@literal @}{@link AssistedInject}. This triggers a limited backwards-compatability mode.

    Instead of matching factory method arguments to constructor parameters using their names, the parameters are matched by their order. The first factory method argument is used for the first {@literal @}Assisted constructor parameter, etc.. Annotation names have no effect.

    Returned values are not created by Guice. These types are not eligible for method interception. They do receive post-construction member injection. @param The factory interface @author jmourits@google.com (Jerome Mourits) @author jessewilson@google.com (Jesse Wilson) @author dtm@google.com (Daniel Martin)]]> bind(DataSource.class).toProvider(fromJndi(DataSource.class, "java:...")); ]]> It is an error to call this method without also calling one of the {@code to} methods on the returned binding builder.

    Scoping elements independently is supported. Use the {@code in} method to specify a binding scope.]]> public class SnacksModule extends AbstractModule { protected void configure() { MapBinder<String, Snack> mapbinder = MapBinder.newMapBinder(binder(), String.class, Snack.class); mapbinder.addBinding("twix").toInstance(new Twix()); mapbinder.addBinding("snickers").toProvider(SnickersProvider.class); mapbinder.addBinding("skittles").to(Skittles.class); } }

    With this binding, a {@link Map}{@code } can now be injected:

    
     class SnackMachine {
       {@literal @}Inject
       public SnackMachine(Map<String, Snack> snacks) { ... }
     }

    In addition to binding {@code Map}, a mapbinder will also bind {@code Map>} for lazy value provision:

    
     class SnackMachine {
       {@literal @}Inject
       public SnackMachine(Map<String, Provider<Snack>> snackProviders) { ... }
     }

    Creating mapbindings from different modules is supported. For example, it is okay to have both {@code CandyModule} and {@code ChipsModule} both create their own {@code MapBinder}, and to each contribute bindings to the snacks map. When that map is injected, it will contain entries from both modules.

    Values are resolved at map injection time. If a value is bound to a provider, that provider's get method will be called each time the map is injected (unless the binding is also scoped, or a map of providers is injected).

    Annotations are used to create different maps of the same key/value type. Each distinct annotation gets its own independent map.

    Keys must be distinct. If the same key is bound more than once, map injection will fail.

    Keys must be non-null. {@code addBinding(null)} will throw an unchecked exception.

    Values must be non-null to use map injection. If any value is null, map injection will fail (although injecting a map of providers will not). @author dpb@google.com (David P. Baker)]]> It is an error to call this method without also calling one of the {@code to} methods on the returned binding builder.

    Scoping elements independently is supported. Use the {@code in} method to specify a binding scope.]]> public class SnacksModule extends AbstractModule { protected void configure() { Multibinder<Snack> multibinder = Multibinder.newSetBinder(binder(), Snack.class); multibinder.addBinding().toInstance(new Twix()); multibinder.addBinding().toProvider(SnickersProvider.class); multibinder.addBinding().to(Skittles.class); } }

    With this binding, a {@link Set}{@code } can now be injected:

    
     class SnackMachine {
       {@literal @}Inject
       public SnackMachine(Set<Snack> snacks) { ... }
     }

    Create multibindings from different modules is supported. For example, it is okay to have both {@code CandyModule} and {@code ChipsModule} to both create their own {@code Multibinder}, and to each contribute bindings to the set of snacks. When that set is injected, it will contain elements from both modules.

    Elements are resolved at set injection time. If an element is bound to a provider, that provider's get method will be called each time the set is injected (unless the binding is also scoped).

    Annotations are be used to create different sets of the same element type. Each distinct annotation gets its own independent collection of elements.

    Elements must be distinct. If multiple bound elements have the same value, set injection will fail.

    Elements must be non-null. If any set element is null, set injection will fail. @author jessewilson@google.com (Jesse Wilson)]]> Apply this filter in web.xml above all other filters (typically), to all requests where you plan to use servlet scopes. This is also needed in order to dispatch requests to injectable filters and servlets:

      <filter>
        <filter-name>guiceFilter</filter-name>
        <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
      </filter>
    
      <filter-mapping>
        <filter-name>guiceFilter</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
      
    This filter must appear before every filter that makes use of Guice injection or servlet scopes functionality. Typically, you will only register this filter in web.xml and register any other filters (and servlets) using a {@link ServletModule}. @author crazybob@google.com (Bob Lee) @author dhanji@gmail.com (Dhanji R. Prasanna)]]>
    } when you want the HTTP request parameter map to be injected. @author crazybob@google.com (Bob Lee)]]> Servlet Mapping EDSL

    Part of the EDSL builder language for configuring servlets and filters with guice-servlet. Think of this as an in-code replacement for web.xml. Filters and servlets are configured here using simple java method calls. Here is a typical example of registering a filter when creating your Guice injector:

       Guice.createInjector(..., new ServletModule() {
    
         {@literal @}Override
         protected void configureServlets() {
           serve("*.html").with(MyServlet.class)
         }
       }
     
    This registers a servlet (subclass of {@code HttpServlet}) called {@code MyServlet} to service any web pages ending in {@code .html}. You can also use a path-style syntax to register servlets:
           serve("/my/*").with(MyServlet.class)
     
    Every servlet (or filter) is required to be a singleton. If you cannot annotate the class directly, you should add a separate {@code bind(..).in(Singleton.class)} rule elsewhere in your module. Mapping a servlet that is bound under any other scope is an error.

    Dispatch Order

    You are free to register as many servlets and filters as you like this way. They will be compared and dispatched in the order in which the filter methods are called:
    
       Guice.createInjector(..., new ServletModule() {
    
         {@literal @}Override
         protected void configureServlets() {
           filter("/*").through(MyFilter.class);
           filter("*.css").through(MyCssFilter.class);
           // etc..
    
           serve("*.html").with(MyServlet.class);
           serve("/my/*").with(MyServlet.class);
           // etc..
          }
        }
     
    This will traverse down the list of rules in lexical order. For example, a url "{@code /my/file.js}" (after it runs through the matching filters) will first be compared against the servlet mapping:
           serve("*.html").with(MyServlet.class);
     
    And failing that, it will descend to the next servlet mapping:
           serve("/my/*").with(MyServlet.class);
     
    Since this rule matches, Guice Servlet will dispatch to {@code MyServlet}. These two mapping rules can also be written in more compact form using varargs syntax:
           serve("*.html", "/my/*").with(MyServlet.class);
     
    This way you can map several URI patterns to the same servlet. A similar syntax is also available for filter mappings.

    Regular Expressions

    You can also map servlets (or filters) to URIs using regular expressions:
        serveRegex("(.)*ajax(.)*").with(MyAjaxServlet.class)
     
    This will map any URI containing the text "ajax" in it to {@code MyAjaxServlet}. Such as:
    • http://www.google.com/ajax.html
    • http://www.google.com/content/ajax/index
    • http://www.google.com/it/is_totally_ajaxian

    Initialization Parameters

    Servlets (and filters) allow you to pass in init params using the {@code } tag in web.xml. You can similarly pass in parameters to Servlets and filters registered in Guice-servlet using a {@link java.util.Map} of parameter name/value pairs. For example, to initialize {@code MyServlet} with two parameters ({@code name="Dhanji", site="google.com"}) you could write:
      Map<String, String> params = new HashMap<String, String>();
      params.put("name", "Dhanji");
      params.put("site", "google.com");
    
      ...
          serve("/*").with(MyServlet.class, params)
     

    Binding Keys

    You can also bind keys rather than classes. This lets you hide implementations with package-local visbility and expose them using only a Guice module and an annotation:
      ...
          filter("/*").through(Key.get(Filter.class, Fave.class));
     
    Where {@code Filter.class} refers to the Servlet API interface and {@code Fave.class} is a custom binding annotation. Elsewhere (in one of your own modules) you can bind this filter's implementation:
       bind(Filter.class).annotatedWith(Fave.class).to(MyFilterImpl.class);
     
    See {@link com.google.inject.Binder} for more information on binding syntax.

    Multiple Modules

    It is sometimes useful to capture servlet and filter mappings from multiple different modules. This is essential if you want to package and offer drop-in Guice plugins that provide servlet functionality.

    Guice Servlet allows you to register several instances of {@code ServletModule} to your injector. The order in which these modules are installed determines the dispatch order of filters and the precedence order of servlets. For example, if you had two servlet modules, {@code RpcModule} and {@code WebServiceModule} and they each contained a filter that mapped to the same URI pattern, {@code "/*"}:

    In {@code RpcModule}:

         filter("/*").through(RpcFilter.class);
     
    In {@code WebServiceModule}:
         filter("/*").through(WebServiceFilter.class);
     
    Then the order in which these filters are dispatched is determined by the order in which the modules are installed:
       install(new WebServiceModule());
       install(new RpcModule());
     
    In the case shown above {@code WebServiceFilter} will run first. @since 2.0]]>
    You should subclass this module to register servlets and filters in the {@link #configureServlets()} method. @author crazybob@google.com (Bob Lee) @author dhanji@gmail.com (Dhanji R. Prasanna)]]>
    any type to be returned by the visit method. Use {@link Void} with {@code return null} if no return type is needed. @since 2.0]]> any type to be returned by the visit method. Use {@link Void} with {@code return null} if no return type is needed. @since 2.0]]> any type to be returned by the visit method. Use {@link Void} with {@code return null} if no return type is needed. @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> any type to be returned by the visit method. Use {@link Void} with {@code return null} if no return type is needed. @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> any type to be returned by the visit method. Use {@link Void} with {@code return null} if no return type is needed. @author sberlin@gmail.com (Sam Berlin) @since 2.0]]> Use {@link #get} to build a freestanding dependency, or {@link InjectionPoint} to build one that's attached to a constructor, method or field. @author crazybob@google.com (Bob Lee) @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> Tools might specially handle types they know about; {@code StackTraceElement} is a good example. Tools should simply call {@code toString()} on the source object if the type is unfamiliar.]]> The elements of a module can be inspected, validated and rewritten. Use {@link Elements#getElements(com.google.inject.Module[]) Elements.getElements()} to read the elements from a module, and {@link Elements#getModule(Iterable) Elements.getModule()} to rewrite them. This can be used for static analysis and generation of Guice modules.

    The elements of an injector can be inspected and exercised. Use {@link com.google.inject.Injector#getBindings Injector.getBindings()} to reflect on Guice injectors. @author jessewilson@google.com (Jesse Wilson) @author crazybob@google.com (Bob Lee) @since 2.0]]> any type to be returned by the visit method. Use {@link Void} with {@code return null} if no return type is needed. @since 2.0]]> } of the valid injection points.]]> } of the valid injection points.]]> } of the valid injection points.]]> } of the valid injection points.]]> } of the valid injection points.]]> requestInjection(serviceInstance); @author mikeward@google.com (Mike Ward) @since 2.0]]> bindInterceptor(Matchers.subclassesOf(MyAction.class), Matchers.annotatedWith(Transactional.class), new MyTransactionInterceptor()); or from an injectable type listener using {@link TypeEncounter#bindInterceptor(Matcher, org.aopalliance.intercept.MethodInterceptor[]) TypeEncounter.bindInterceptor()}. @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> MembersInjector<PaymentService> membersInjector = getMembersInjector(PaymentService.class); @author crazybob@google.com (Bob Lee) @since 2.0]]> try { bindPropertiesFromFile(); } catch (IOException e) { addError(e); } @author crazybob@google.com (Bob Lee)]]> Tools might specially handle types they know about; {@code StackTraceElement} is a good example. Tools should simply call {@code toString()} on the source object if the type is unfamiliar. @param key one of the keys exposed by this module.]]> } is injected (as opposed to injecting {@code T} directly). @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> Provider<PaymentService> paymentServiceProvider = getProvider(PaymentService.class); @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> Scope recordScope = new RecordScope(); bindScope(RecordScoped.class, new RecordScope()); @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> } of the valid injection points.]]> requestStaticInjection(MyLegacyService.class); @author jessewilson@google.com (Jesse Wilson) @since 2.0]]> convertToTypes(Matchers.only(DateTime.class), new DateTimeConverter()); @author jessewilson@google.com (Jesse Wilson) @since 2.0]]>

  • Guice created the instance the method is on
  • Neither the enclosing type nor the method is final
  • And the method is package-private or more accessible
  • @param methodMatcher matches methods the interceptor should apply to. For example: {@code annotatedWith(Transactional.class)}. @param interceptors to bind]]>
    the injectable type encountered @since 2.0]]> the injectable type]]> Useful for extra type checking, {@linkplain TypeEncounter#register(InjectionListener) registering injection listeners}, and {@linkplain TypeEncounter#bindInterceptor( com.google.inject.matcher.Matcher, org.aopalliance.intercept.MethodInterceptor[]) binding method interceptors}. @since 2.0]]> register(only(new TypeLiteral<PaymentService<CreditCard>>() {}), listener); @author jessewilson@google.com (Jesse Wilson) @since 2.0]]>
    bind(DataSource.class) .toProvider(fromSpring(DataSource.class, "dataSource")); ]]> This interface must be extended to use application-specific exception types. Such subinterfaces may not define new methods:
     public interface RemoteProvider<T> extends ThrowingProvider<T, RemoteException> { }
     

    When this type is bound using {@link ThrowingProviderBinder}, the value returned or exception thrown by {@link #get} will be scoped. As a consequence, {@link #get} will invoked at most once within each scope. @author jmourits@google.com (Jerome Mourits) @author jessewilson@google.com (Jesse Wilson)]]> Builds a binding for a {@link ThrowingProvider} using a fluent API:

    ThrowingProviderBinder.create(binder())
        .bind(RemoteProvider.class, Customer.class)
        .to(RemoteCustomerProvider.class)
        .in(RequestScope.class);
     
    @author jmourits@google.com (Jerome Mourits) @author jessewilson@google.com (Jesse Wilson)]]>
    Module functionalTestModule = Modules.override(new ProductionModule()).with(new TestModule());

    Prefer to write smaller modules that can be reused and tested without overrides. @param modules the modules whose bindings are open to be overridden]]> Module functionalTestModule = Modules.override(getProductionModules()).with(getTestModules());

    Prefer to write smaller modules that can be reused and tested without overrides. @param modules the modules whose bindings are open to be overridden]]> sisu-guice-sisu-guice-3.1.1/latest-api-diffs/1.0.xml0000644000175000017500000025112611704661106020575 0ustar tonytony import static com.google.inject.Names.named; public class MyModule extends AbstractModule { protected void configure() { bind(Foo.class).to(FooImpl.class).in(Scopes.SINGLETON); bind(BarImpl.class); link(Bar.class).to(BarImpl.class); bindConstant(named("port")).to(8080); } } @author crazybob@google.com (Bob Lee)]]> bindings) which will be used to create an {@link Injector}. Guice provides this object to your application's {@link Module}s so they may each contribute their own bindings.

    The bindings contributed by {@code Module}s define how the {@code Injector} resolves dependencies. A {@link Key} consisting of a type and optional annotation uniquely identifies a binding within an {@code Injector}.

    You may bind from a key to:

    • Another binding, which this binding's key is now "aliased to"
    • Another binding, which references a {@link Provider} for this key
    • A preconstructed instance
    • A preconstructed instance which should be used as the {@link Provider} for this binding

    In addition, a binding may have an associated scope, such as {@link Scopes#SINGLETON}, and singleton bindings may specify eager or lazy initialization.

    See the users' guide appendix, "How the Injector resolves injection requests," to better understand binding resolution.

    After an {@code Injector} has been created, its bindings may be examined using methods like {@link Injector#getBinding(Key)}, but this read-only {@link Binding} type is not used when creating the bindings.]]> {@code @}Retention(RUNTIME) {@code @}Target({ FIELD, PARAMETER }) {@code @}BindingAnnotation public {@code @}interface Transactional {} @author crazybob@google.com (Bob Lee)]]>

  • Every instance it constructs. The class being constructed must have exactly one of its constructors marked with {@code @Inject} or must have a constructor taking no parameters. The Injector then proceeds to perform method and field injections.
  • Pre-constructed instances passed to {@link Injector#injectMembers}, {@link com.google.inject.binder.LinkedBindingBuilder#toInstance(Object)} and {@link com.google.inject.binder.LinkedBindingBuilder#toProvider(Provider)}. In this case all constructors are, of course, ignored.
  • Static fields and methods of classes which any {@link Module} has specifically requested static injection for, using {@link Binder#requestStaticInjection}. In all cases, a member can be injected regardless of its Java access specifier (private, default, protected, public). @author crazybob@google.com (Bob Lee)]]> The {@code Injector} API has a few additional features: it allows pre-constructed instances to have their fields and methods injected and offers programmatic introspection to support tool development.

    Contains several default bindings:

    • This {@link Injector} instance itself
    • A {@code Provider} for each binding of type {@code T}
    • The {@link java.util.logging.Logger} for the class being injected
    • The {@link Stage} in which the Injector was created
    Injectors are created using the facade class {@link Guice}. @author crazybob@google.com (Bob Lee)]]>
    Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

    Example usage for a binding of type {@code Foo} annotated with {@code @Bar}:

    {@code new Key(Bar.class) {}}.]]> Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

    Example usage for a binding of type {@code Foo} annotated with {@code @Bar}:

    {@code new Key(new Bar()) {}}.]]> Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

    Example usage for a binding of type {@code Foo}:

    {@code new Key() {}}.]]> For example, {@code Key.get(Service.class, Transactional.class)} will match:

       {@literal @}Inject
       public void setService({@literal @}Transactional Service service) {
         ...
       }
     

    {@code Key} supports generic types via subclassing just like {@link TypeLiteral}. @author crazybob@google.com (Bob Lee)]]> Your Module classes can use a more streamlined syntax by extending {@link AbstractModule} rather than implementing this interface directly.]]>

  • When the default means for obtaining instances (an injectable or parameterless constructor) is insufficient for a particular binding, the module can specify a custom {@code Provider} instead, to control exactly how Guice creates or obtains instances for the binding.
  • An implementation class may always choose to have a {@code Provider} instance injected, rather than having a {@code T} injected directly. This may give you access to multiple instances, instances you wish to safely mutate and discard, instances which are out of scope (e.g. using a {@code @RequestScoped} object from within a {@code @SessionScoped} object), or instances you don't want to initialize until they are absolutely needed.
  • A custom {@link Scope} is implemented as a decorator of {@code Provider}, which decides when to delegate to the backing provider and when to provide the instance some other way.
  • The {@link Injector} offers access to the {@code Provider} it uses to fulfill requests for a given key, via the {@link Injector#getProvider} methods. @param the type of object this provider provides @author crazybob@google.com (Bob Lee)]]> Scope implementations are strongly encouraged to override {@link Object#toString} in the returned provider and include the backing provider's {@code toString()} output. @param key binding key @param unscoped locates an instance when one doesn't already exist in this scope. @return a new provider which only delegates to the given unscoped provider when an instance of the requested object doesn't already exist in this scope]]> no scope, meaning it has no state from the framework's perspective -- the {@code Injector} creates it, injects it once into the class that required it, and then immediately forgets it. Associating a scope with a particular binding allows the created instance to be "remembered" and possibly used again for other injections. @see Scopes#SINGLETON @author crazybob@google.com (Bob Lee)]]> {@code @}Retention(RUNTIME) {@code @}Target(TYPE) {@code @}ScopeAnnotation public {@code @}interface SessionScoped {} @author crazybob@google.com (Bob Lee)]]> Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.]]> For example, to create a type literal for {@code List}, you can create an empty anonymous inner class:

    {@code TypeLiteral> list = new TypeLiteral>() {};}

    Assumes that type {@code T} implements {@link Object#equals} and {@link Object#hashCode()} as value (as opposed to identity) comparison. @author crazybob@google.com (Bob Lee)]]> bind(DataSource.class).toProvider(fromJndi(DataSource.class, "java:...")); ]]> } when you want the HTTP request parameter map to be injected. @author crazybob@google.com (Bob Lee)]]> Skipping only takes place after this method is called.]]> bind(DataSource.class) .toProvider(fromSpring(DataSource.class, "dataSource")); ]]> sisu-guice-sisu-guice-3.1.1/javadoc/0000755000175000017500000000000011704661106016021 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/packages.html0000755000175000017500000003422411704661106020475 0ustar tonytony Package Index | Guice

    Package Index

    com.google.inject Google Guice (pronounced "juice") is an ultra-lightweight dependency injection framework. 
    com.google.inject.assistedinject Extension for combining factory interfaces with injection; this extension requires guice-assistedinject-3.0.jar
    com.google.inject.binder Interfaces which make up Binder's expression language. 
    com.google.inject.grapher  
    com.google.inject.grapher.graphviz  
    com.google.inject.jndi JNDI integration; this extension requires guice-jndi-3.0.jar
    com.google.inject.matcher Used for matching things. 
    com.google.inject.multibindings Extension for binding multiple instances in a collection; this extension requires guice-multibindings-3.0.jar
    com.google.inject.name Support for binding to string-based names. 
    com.google.inject.persist Guice Persist: a lightweight persistence library for Guice; this extension requires guice-persist-3.0.jar
    com.google.inject.persist.finder Dynamic Finder API for Guice Persist. 
    com.google.inject.persist.jpa guice-persist's Java Persistence API (JPA) support. 
    com.google.inject.servlet Servlet API scopes, bindings and registration; this extension requires guice-servlet-3.0.jar
    com.google.inject.spi Guice service provider interface  
    com.google.inject.spring Spring integration; this extension requires guice-spring-3.0.jar
    com.google.inject.throwingproviders Extension for injecting objects that may throw at provision time; this extension requires guice-throwingproviders-3.0.jar
    com.google.inject.tools.jmx JMX integration; this extension requires guice-jmx-3.0.jar
    com.google.inject.util Helper methods for working with Guice. 
    sisu-guice-sisu-guice-3.1.1/javadoc/package-list0000755000175000017500000000075311704661106020320 0ustar tonytonycom.google.inject com.google.inject.assistedinject com.google.inject.binder com.google.inject.grapher com.google.inject.grapher.graphviz com.google.inject.jndi com.google.inject.matcher com.google.inject.multibindings com.google.inject.name com.google.inject.persist com.google.inject.persist.finder com.google.inject.persist.jpa com.google.inject.servlet com.google.inject.spi com.google.inject.spring com.google.inject.throwingproviders com.google.inject.tools.jmx com.google.inject.util sisu-guice-sisu-guice-3.1.1/javadoc/lists.js0000755000175000017500000006144611704661106017533 0ustar tonytonyvar DATA = [ { id:0, label:"com.google.inject", link:"com/google/inject/package-summary.html", type:"package" }, { id:1, label:"com.google.inject.AbstractModule", link:"com/google/inject/AbstractModule.html", type:"class" }, { id:2, label:"com.google.inject.Binder", link:"com/google/inject/Binder.html", type:"class" }, { id:3, label:"com.google.inject.Binding", link:"com/google/inject/Binding.html", type:"class" }, { id:4, label:"com.google.inject.BindingAnnotation", link:"com/google/inject/BindingAnnotation.html", type:"class" }, { id:5, label:"com.google.inject.ConfigurationException", link:"com/google/inject/ConfigurationException.html", type:"class" }, { id:6, label:"com.google.inject.CreationException", link:"com/google/inject/CreationException.html", type:"class" }, { id:7, label:"com.google.inject.Exposed", link:"com/google/inject/Exposed.html", type:"class" }, { id:8, label:"com.google.inject.Guice", link:"com/google/inject/Guice.html", type:"class" }, { id:9, label:"com.google.inject.ImplementedBy", link:"com/google/inject/ImplementedBy.html", type:"class" }, { id:10, label:"com.google.inject.Inject", link:"com/google/inject/Inject.html", type:"class" }, { id:11, label:"com.google.inject.Injector", link:"com/google/inject/Injector.html", type:"class" }, { id:12, label:"com.google.inject.Key", link:"com/google/inject/Key.html", type:"class" }, { id:13, label:"com.google.inject.MembersInjector", link:"com/google/inject/MembersInjector.html", type:"class" }, { id:14, label:"com.google.inject.Module", link:"com/google/inject/Module.html", type:"class" }, { id:15, label:"com.google.inject.OutOfScopeException", link:"com/google/inject/OutOfScopeException.html", type:"class" }, { id:16, label:"com.google.inject.PrivateBinder", link:"com/google/inject/PrivateBinder.html", type:"class" }, { id:17, label:"com.google.inject.PrivateModule", link:"com/google/inject/PrivateModule.html", type:"class" }, { id:18, label:"com.google.inject.ProvidedBy", link:"com/google/inject/ProvidedBy.html", type:"class" }, { id:19, label:"com.google.inject.Provider", link:"com/google/inject/Provider.html", type:"class" }, { id:20, label:"com.google.inject.Provides", link:"com/google/inject/Provides.html", type:"class" }, { id:21, label:"com.google.inject.ProvisionException", link:"com/google/inject/ProvisionException.html", type:"class" }, { id:22, label:"com.google.inject.Scope", link:"com/google/inject/Scope.html", type:"class" }, { id:23, label:"com.google.inject.ScopeAnnotation", link:"com/google/inject/ScopeAnnotation.html", type:"class" }, { id:24, label:"com.google.inject.Scopes", link:"com/google/inject/Scopes.html", type:"class" }, { id:25, label:"com.google.inject.Singleton", link:"com/google/inject/Singleton.html", type:"class" }, { id:26, label:"com.google.inject.Stage", link:"com/google/inject/Stage.html", type:"class" }, { id:27, label:"com.google.inject.TypeLiteral", link:"com/google/inject/TypeLiteral.html", type:"class" }, { id:28, label:"com.google.inject.assistedinject", link:"com/google/inject/assistedinject/package-summary.html", type:"package" }, { id:29, label:"com.google.inject.assistedinject.Assisted", link:"com/google/inject/assistedinject/Assisted.html", type:"class" }, { id:30, label:"com.google.inject.assistedinject.AssistedInject", link:"com/google/inject/assistedinject/AssistedInject.html", type:"class" }, { id:31, label:"com.google.inject.assistedinject.AssistedInjectBinding", link:"com/google/inject/assistedinject/AssistedInjectBinding.html", type:"class" }, { id:32, label:"com.google.inject.assistedinject.AssistedInjectTargetVisitor", link:"com/google/inject/assistedinject/AssistedInjectTargetVisitor.html", type:"class" }, { id:33, label:"com.google.inject.assistedinject.AssistedMethod", link:"com/google/inject/assistedinject/AssistedMethod.html", type:"class" }, { id:34, label:"com.google.inject.assistedinject.FactoryModuleBuilder", link:"com/google/inject/assistedinject/FactoryModuleBuilder.html", type:"class" }, { id:35, label:"com.google.inject.assistedinject.FactoryProvider", link:"com/google/inject/assistedinject/FactoryProvider.html", type:"class" }, { id:36, label:"com.google.inject.binder", link:"com/google/inject/binder/package-summary.html", type:"package" }, { id:37, label:"com.google.inject.binder.AnnotatedBindingBuilder", link:"com/google/inject/binder/AnnotatedBindingBuilder.html", type:"class" }, { id:38, label:"com.google.inject.binder.AnnotatedConstantBindingBuilder", link:"com/google/inject/binder/AnnotatedConstantBindingBuilder.html", type:"class" }, { id:39, label:"com.google.inject.binder.AnnotatedElementBuilder", link:"com/google/inject/binder/AnnotatedElementBuilder.html", type:"class" }, { id:40, label:"com.google.inject.binder.ConstantBindingBuilder", link:"com/google/inject/binder/ConstantBindingBuilder.html", type:"class" }, { id:41, label:"com.google.inject.binder.LinkedBindingBuilder", link:"com/google/inject/binder/LinkedBindingBuilder.html", type:"class" }, { id:42, label:"com.google.inject.binder.ScopedBindingBuilder", link:"com/google/inject/binder/ScopedBindingBuilder.html", type:"class" }, { id:43, label:"com.google.inject.grapher", link:"com/google/inject/grapher/package-summary.html", type:"package" }, { id:44, label:"com.google.inject.grapher.BindingEdge", link:"com/google/inject/grapher/BindingEdge.html", type:"class" }, { id:45, label:"com.google.inject.grapher.BindingEdge.Factory", link:"com/google/inject/grapher/BindingEdge.Factory.html", type:"class" }, { id:46, label:"com.google.inject.grapher.BindingEdge.Type", link:"com/google/inject/grapher/BindingEdge.Type.html", type:"class" }, { id:47, label:"com.google.inject.grapher.DependencyEdge", link:"com/google/inject/grapher/DependencyEdge.html", type:"class" }, { id:48, label:"com.google.inject.grapher.DependencyEdge.Factory", link:"com/google/inject/grapher/DependencyEdge.Factory.html", type:"class" }, { id:49, label:"com.google.inject.grapher.GrapherModule", link:"com/google/inject/grapher/GrapherModule.html", type:"class" }, { id:50, label:"com.google.inject.grapher.GraphingVisitor", link:"com/google/inject/grapher/GraphingVisitor.html", type:"class" }, { id:51, label:"com.google.inject.grapher.ImplementationNode", link:"com/google/inject/grapher/ImplementationNode.html", type:"class" }, { id:52, label:"com.google.inject.grapher.ImplementationNode.Factory", link:"com/google/inject/grapher/ImplementationNode.Factory.html", type:"class" }, { id:53, label:"com.google.inject.grapher.InjectorGrapher", link:"com/google/inject/grapher/InjectorGrapher.html", type:"class" }, { id:54, label:"com.google.inject.grapher.InterfaceNode", link:"com/google/inject/grapher/InterfaceNode.html", type:"class" }, { id:55, label:"com.google.inject.grapher.InterfaceNode.Factory", link:"com/google/inject/grapher/InterfaceNode.Factory.html", type:"class" }, { id:56, label:"com.google.inject.grapher.NameFactory", link:"com/google/inject/grapher/NameFactory.html", type:"class" }, { id:57, label:"com.google.inject.grapher.NodeAliasFactory", link:"com/google/inject/grapher/NodeAliasFactory.html", type:"class" }, { id:58, label:"com.google.inject.grapher.NodeIdFactory", link:"com/google/inject/grapher/NodeIdFactory.html", type:"class" }, { id:59, label:"com.google.inject.grapher.Renderer", link:"com/google/inject/grapher/Renderer.html", type:"class" }, { id:60, label:"com.google.inject.grapher.ShortNameFactory", link:"com/google/inject/grapher/ShortNameFactory.html", type:"class" }, { id:61, label:"com.google.inject.grapher.StringNodeIdFactory", link:"com/google/inject/grapher/StringNodeIdFactory.html", type:"class" }, { id:62, label:"com.google.inject.grapher.TransitiveDependencyVisitor", link:"com/google/inject/grapher/TransitiveDependencyVisitor.html", type:"class" }, { id:63, label:"com.google.inject.grapher.graphviz", link:"com/google/inject/grapher/graphviz/package-summary.html", type:"package" }, { id:64, label:"com.google.inject.grapher.graphviz.ArrowType", link:"com/google/inject/grapher/graphviz/ArrowType.html", type:"class" }, { id:65, label:"com.google.inject.grapher.graphviz.BindingEdgeFactory", link:"com/google/inject/grapher/graphviz/BindingEdgeFactory.html", type:"class" }, { id:66, label:"com.google.inject.grapher.graphviz.BindingEdgeFactory.GraphvizEdgeAdaptor", link:"com/google/inject/grapher/graphviz/BindingEdgeFactory.GraphvizEdgeAdaptor.html", type:"class" }, { id:67, label:"com.google.inject.grapher.graphviz.CompassPoint", link:"com/google/inject/grapher/graphviz/CompassPoint.html", type:"class" }, { id:68, label:"com.google.inject.grapher.graphviz.DependencyEdgeFactory", link:"com/google/inject/grapher/graphviz/DependencyEdgeFactory.html", type:"class" }, { id:69, label:"com.google.inject.grapher.graphviz.DependencyEdgeFactory.GraphvizEdgeAdaptor", link:"com/google/inject/grapher/graphviz/DependencyEdgeFactory.GraphvizEdgeAdaptor.html", type:"class" }, { id:70, label:"com.google.inject.grapher.graphviz.EdgeStyle", link:"com/google/inject/grapher/graphviz/EdgeStyle.html", type:"class" }, { id:71, label:"com.google.inject.grapher.graphviz.GraphvizEdge", link:"com/google/inject/grapher/graphviz/GraphvizEdge.html", type:"class" }, { id:72, label:"com.google.inject.grapher.graphviz.GraphvizModule", link:"com/google/inject/grapher/graphviz/GraphvizModule.html", type:"class" }, { id:73, label:"com.google.inject.grapher.graphviz.GraphvizNode", link:"com/google/inject/grapher/graphviz/GraphvizNode.html", type:"class" }, { id:74, label:"com.google.inject.grapher.graphviz.GraphvizRenderer", link:"com/google/inject/grapher/graphviz/GraphvizRenderer.html", type:"class" }, { id:75, label:"com.google.inject.grapher.graphviz.ImplementationNodeFactory", link:"com/google/inject/grapher/graphviz/ImplementationNodeFactory.html", type:"class" }, { id:76, label:"com.google.inject.grapher.graphviz.ImplementationNodeFactory.GraphvizNodeAdaptor", link:"com/google/inject/grapher/graphviz/ImplementationNodeFactory.GraphvizNodeAdaptor.html", type:"class" }, { id:77, label:"com.google.inject.grapher.graphviz.InterfaceNodeFactory", link:"com/google/inject/grapher/graphviz/InterfaceNodeFactory.html", type:"class" }, { id:78, label:"com.google.inject.grapher.graphviz.InterfaceNodeFactory.GraphvizNodeAdaptor", link:"com/google/inject/grapher/graphviz/InterfaceNodeFactory.GraphvizNodeAdaptor.html", type:"class" }, { id:79, label:"com.google.inject.grapher.graphviz.NodeShape", link:"com/google/inject/grapher/graphviz/NodeShape.html", type:"class" }, { id:80, label:"com.google.inject.grapher.graphviz.NodeStyle", link:"com/google/inject/grapher/graphviz/NodeStyle.html", type:"class" }, { id:81, label:"com.google.inject.grapher.graphviz.PortIdFactory", link:"com/google/inject/grapher/graphviz/PortIdFactory.html", type:"class" }, { id:82, label:"com.google.inject.grapher.graphviz.PortIdFactoryImpl", link:"com/google/inject/grapher/graphviz/PortIdFactoryImpl.html", type:"class" }, { id:83, label:"com.google.inject.jndi", link:"com/google/inject/jndi/package-summary.html", type:"package" }, { id:84, label:"com.google.inject.jndi.JndiIntegration", link:"com/google/inject/jndi/JndiIntegration.html", type:"class" }, { id:85, label:"com.google.inject.matcher", link:"com/google/inject/matcher/package-summary.html", type:"package" }, { id:86, label:"com.google.inject.matcher.AbstractMatcher", link:"com/google/inject/matcher/AbstractMatcher.html", type:"class" }, { id:87, label:"com.google.inject.matcher.Matcher", link:"com/google/inject/matcher/Matcher.html", type:"class" }, { id:88, label:"com.google.inject.matcher.Matchers", link:"com/google/inject/matcher/Matchers.html", type:"class" }, { id:89, label:"com.google.inject.multibindings", link:"com/google/inject/multibindings/package-summary.html", type:"package" }, { id:90, label:"com.google.inject.multibindings.MapBinder", link:"com/google/inject/multibindings/MapBinder.html", type:"class" }, { id:91, label:"com.google.inject.multibindings.MapBinderBinding", link:"com/google/inject/multibindings/MapBinderBinding.html", type:"class" }, { id:92, label:"com.google.inject.multibindings.Multibinder", link:"com/google/inject/multibindings/Multibinder.html", type:"class" }, { id:93, label:"com.google.inject.multibindings.MultibinderBinding", link:"com/google/inject/multibindings/MultibinderBinding.html", type:"class" }, { id:94, label:"com.google.inject.multibindings.MultibindingsTargetVisitor", link:"com/google/inject/multibindings/MultibindingsTargetVisitor.html", type:"class" }, { id:95, label:"com.google.inject.name", link:"com/google/inject/name/package-summary.html", type:"package" }, { id:96, label:"com.google.inject.name.Named", link:"com/google/inject/name/Named.html", type:"class" }, { id:97, label:"com.google.inject.name.Names", link:"com/google/inject/name/Names.html", type:"class" }, { id:98, label:"com.google.inject.persist", link:"com/google/inject/persist/package-summary.html", type:"package" }, { id:99, label:"com.google.inject.persist.PersistFilter", link:"com/google/inject/persist/PersistFilter.html", type:"class" }, { id:100, label:"com.google.inject.persist.PersistModule", link:"com/google/inject/persist/PersistModule.html", type:"class" }, { id:101, label:"com.google.inject.persist.PersistService", link:"com/google/inject/persist/PersistService.html", type:"class" }, { id:102, label:"com.google.inject.persist.Transactional", link:"com/google/inject/persist/Transactional.html", type:"class" }, { id:103, label:"com.google.inject.persist.UnitOfWork", link:"com/google/inject/persist/UnitOfWork.html", type:"class" }, { id:104, label:"com.google.inject.persist.finder", link:"com/google/inject/persist/finder/package-summary.html", type:"package" }, { id:105, label:"com.google.inject.persist.finder.DynamicFinder", link:"com/google/inject/persist/finder/DynamicFinder.html", type:"class" }, { id:106, label:"com.google.inject.persist.finder.Finder", link:"com/google/inject/persist/finder/Finder.html", type:"class" }, { id:107, label:"com.google.inject.persist.finder.FirstResult", link:"com/google/inject/persist/finder/FirstResult.html", type:"class" }, { id:108, label:"com.google.inject.persist.finder.MaxResults", link:"com/google/inject/persist/finder/MaxResults.html", type:"class" }, { id:109, label:"com.google.inject.persist.jpa", link:"com/google/inject/persist/jpa/package-summary.html", type:"package" }, { id:110, label:"com.google.inject.persist.jpa.JpaPersistModule", link:"com/google/inject/persist/jpa/JpaPersistModule.html", type:"class" }, { id:111, label:"com.google.inject.servlet", link:"com/google/inject/servlet/package-summary.html", type:"package" }, { id:112, label:"com.google.inject.servlet.GuiceFilter", link:"com/google/inject/servlet/GuiceFilter.html", type:"class" }, { id:113, label:"com.google.inject.servlet.GuiceServletContextListener", link:"com/google/inject/servlet/GuiceServletContextListener.html", type:"class" }, { id:114, label:"com.google.inject.servlet.InstanceFilterBinding", link:"com/google/inject/servlet/InstanceFilterBinding.html", type:"class" }, { id:115, label:"com.google.inject.servlet.InstanceServletBinding", link:"com/google/inject/servlet/InstanceServletBinding.html", type:"class" }, { id:116, label:"com.google.inject.servlet.LinkedFilterBinding", link:"com/google/inject/servlet/LinkedFilterBinding.html", type:"class" }, { id:117, label:"com.google.inject.servlet.LinkedServletBinding", link:"com/google/inject/servlet/LinkedServletBinding.html", type:"class" }, { id:118, label:"com.google.inject.servlet.RequestParameters", link:"com/google/inject/servlet/RequestParameters.html", type:"class" }, { id:119, label:"com.google.inject.servlet.RequestScoped", link:"com/google/inject/servlet/RequestScoped.html", type:"class" }, { id:120, label:"com.google.inject.servlet.ServletModule", link:"com/google/inject/servlet/ServletModule.html", type:"class" }, { id:121, label:"com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder", link:"com/google/inject/servlet/ServletModule.FilterKeyBindingBuilder.html", type:"class" }, { id:122, label:"com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder", link:"com/google/inject/servlet/ServletModule.ServletKeyBindingBuilder.html", type:"class" }, { id:123, label:"com.google.inject.servlet.ServletModuleBinding", link:"com/google/inject/servlet/ServletModuleBinding.html", type:"class" }, { id:124, label:"com.google.inject.servlet.ServletModuleTargetVisitor", link:"com/google/inject/servlet/ServletModuleTargetVisitor.html", type:"class" }, { id:125, label:"com.google.inject.servlet.ServletScopes", link:"com/google/inject/servlet/ServletScopes.html", type:"class" }, { id:126, label:"com.google.inject.servlet.SessionScoped", link:"com/google/inject/servlet/SessionScoped.html", type:"class" }, { id:127, label:"com.google.inject.servlet.UriPatternType", link:"com/google/inject/servlet/UriPatternType.html", type:"class" }, { id:128, label:"com.google.inject.spi", link:"com/google/inject/spi/package-summary.html", type:"package" }, { id:129, label:"com.google.inject.spi.BindingScopingVisitor", link:"com/google/inject/spi/BindingScopingVisitor.html", type:"class" }, { id:130, label:"com.google.inject.spi.BindingTargetVisitor", link:"com/google/inject/spi/BindingTargetVisitor.html", type:"class" }, { id:131, label:"com.google.inject.spi.ConstructorBinding", link:"com/google/inject/spi/ConstructorBinding.html", type:"class" }, { id:132, label:"com.google.inject.spi.ConvertedConstantBinding", link:"com/google/inject/spi/ConvertedConstantBinding.html", type:"class" }, { id:133, label:"com.google.inject.spi.DefaultBindingScopingVisitor", link:"com/google/inject/spi/DefaultBindingScopingVisitor.html", type:"class" }, { id:134, label:"com.google.inject.spi.DefaultBindingTargetVisitor", link:"com/google/inject/spi/DefaultBindingTargetVisitor.html", type:"class" }, { id:135, label:"com.google.inject.spi.DefaultElementVisitor", link:"com/google/inject/spi/DefaultElementVisitor.html", type:"class" }, { id:136, label:"com.google.inject.spi.Dependency", link:"com/google/inject/spi/Dependency.html", type:"class" }, { id:137, label:"com.google.inject.spi.DisableCircularProxiesOption", link:"com/google/inject/spi/DisableCircularProxiesOption.html", type:"class" }, { id:138, label:"com.google.inject.spi.Element", link:"com/google/inject/spi/Element.html", type:"class" }, { id:139, label:"com.google.inject.spi.ElementVisitor", link:"com/google/inject/spi/ElementVisitor.html", type:"class" }, { id:140, label:"com.google.inject.spi.Elements", link:"com/google/inject/spi/Elements.html", type:"class" }, { id:141, label:"com.google.inject.spi.ExposedBinding", link:"com/google/inject/spi/ExposedBinding.html", type:"class" }, { id:142, label:"com.google.inject.spi.HasDependencies", link:"com/google/inject/spi/HasDependencies.html", type:"class" }, { id:143, label:"com.google.inject.spi.InjectionListener", link:"com/google/inject/spi/InjectionListener.html", type:"class" }, { id:144, label:"com.google.inject.spi.InjectionPoint", link:"com/google/inject/spi/InjectionPoint.html", type:"class" }, { id:145, label:"com.google.inject.spi.InjectionRequest", link:"com/google/inject/spi/InjectionRequest.html", type:"class" }, { id:146, label:"com.google.inject.spi.InstanceBinding", link:"com/google/inject/spi/InstanceBinding.html", type:"class" }, { id:147, label:"com.google.inject.spi.InterceptorBinding", link:"com/google/inject/spi/InterceptorBinding.html", type:"class" }, { id:148, label:"com.google.inject.spi.LinkedKeyBinding", link:"com/google/inject/spi/LinkedKeyBinding.html", type:"class" }, { id:149, label:"com.google.inject.spi.MembersInjectorLookup", link:"com/google/inject/spi/MembersInjectorLookup.html", type:"class" }, { id:150, label:"com.google.inject.spi.Message", link:"com/google/inject/spi/Message.html", type:"class" }, { id:151, label:"com.google.inject.spi.PrivateElements", link:"com/google/inject/spi/PrivateElements.html", type:"class" }, { id:152, label:"com.google.inject.spi.ProviderBinding", link:"com/google/inject/spi/ProviderBinding.html", type:"class" }, { id:153, label:"com.google.inject.spi.ProviderInstanceBinding", link:"com/google/inject/spi/ProviderInstanceBinding.html", type:"class" }, { id:154, label:"com.google.inject.spi.ProviderKeyBinding", link:"com/google/inject/spi/ProviderKeyBinding.html", type:"class" }, { id:155, label:"com.google.inject.spi.ProviderLookup", link:"com/google/inject/spi/ProviderLookup.html", type:"class" }, { id:156, label:"com.google.inject.spi.ProviderWithDependencies", link:"com/google/inject/spi/ProviderWithDependencies.html", type:"class" }, { id:157, label:"com.google.inject.spi.ProviderWithExtensionVisitor", link:"com/google/inject/spi/ProviderWithExtensionVisitor.html", type:"class" }, { id:158, label:"com.google.inject.spi.RequireExplicitBindingsOption", link:"com/google/inject/spi/RequireExplicitBindingsOption.html", type:"class" }, { id:159, label:"com.google.inject.spi.ScopeBinding", link:"com/google/inject/spi/ScopeBinding.html", type:"class" }, { id:160, label:"com.google.inject.spi.StaticInjectionRequest", link:"com/google/inject/spi/StaticInjectionRequest.html", type:"class" }, { id:161, label:"com.google.inject.spi.Toolable", link:"com/google/inject/spi/Toolable.html", type:"class" }, { id:162, label:"com.google.inject.spi.TypeConverter", link:"com/google/inject/spi/TypeConverter.html", type:"class" }, { id:163, label:"com.google.inject.spi.TypeConverterBinding", link:"com/google/inject/spi/TypeConverterBinding.html", type:"class" }, { id:164, label:"com.google.inject.spi.TypeEncounter", link:"com/google/inject/spi/TypeEncounter.html", type:"class" }, { id:165, label:"com.google.inject.spi.TypeListener", link:"com/google/inject/spi/TypeListener.html", type:"class" }, { id:166, label:"com.google.inject.spi.TypeListenerBinding", link:"com/google/inject/spi/TypeListenerBinding.html", type:"class" }, { id:167, label:"com.google.inject.spi.UntargettedBinding", link:"com/google/inject/spi/UntargettedBinding.html", type:"class" }, { id:168, label:"com.google.inject.spring", link:"com/google/inject/spring/package-summary.html", type:"package" }, { id:169, label:"com.google.inject.spring.SpringIntegration", link:"com/google/inject/spring/SpringIntegration.html", type:"class" }, { id:170, label:"com.google.inject.throwingproviders", link:"com/google/inject/throwingproviders/package-summary.html", type:"package" }, { id:171, label:"com.google.inject.throwingproviders.CheckedProvider", link:"com/google/inject/throwingproviders/CheckedProvider.html", type:"class" }, { id:172, label:"com.google.inject.throwingproviders.CheckedProvides", link:"com/google/inject/throwingproviders/CheckedProvides.html", type:"class" }, { id:173, label:"com.google.inject.throwingproviders.ThrowingProvider", link:"com/google/inject/throwingproviders/ThrowingProvider.html", type:"class" }, { id:174, label:"com.google.inject.throwingproviders.ThrowingProviderBinder", link:"com/google/inject/throwingproviders/ThrowingProviderBinder.html", type:"class" }, { id:175, label:"com.google.inject.throwingproviders.ThrowingProviderBinder.SecondaryBinder", link:"com/google/inject/throwingproviders/ThrowingProviderBinder.SecondaryBinder.html", type:"class" }, { id:176, label:"com.google.inject.tools.jmx", link:"com/google/inject/tools/jmx/package-summary.html", type:"package" }, { id:177, label:"com.google.inject.tools.jmx.ManagedBindingMBean", link:"com/google/inject/tools/jmx/ManagedBindingMBean.html", type:"class" }, { id:178, label:"com.google.inject.tools.jmx.Manager", link:"com/google/inject/tools/jmx/Manager.html", type:"class" }, { id:179, label:"com.google.inject.util", link:"com/google/inject/util/package-summary.html", type:"package" }, { id:180, label:"com.google.inject.util.Modules", link:"com/google/inject/util/Modules.html", type:"class" }, { id:181, label:"com.google.inject.util.Modules.OverriddenModuleBuilder", link:"com/google/inject/util/Modules.OverriddenModuleBuilder.html", type:"class" }, { id:182, label:"com.google.inject.util.Providers", link:"com/google/inject/util/Providers.html", type:"class" }, { id:183, label:"com.google.inject.util.Types", link:"com/google/inject/util/Types.html", type:"class" } ]; sisu-guice-sisu-guice-3.1.1/javadoc/index.html0000755000175000017500000000014711704661106020023 0ustar tonytony sisu-guice-sisu-guice-3.1.1/javadoc/hierarchy.html0000755000175000017500000007542511704661106020705 0ustar tonytony Class Hierarchy | Guice

    Class Hierarchy

    Class Interfaces
     
    AbstractModule Module     
    GrapherModule  
    GraphvizModule  
    PersistModule  
    JpaPersistModule  
    ServletModule  
    Guice  
    Key  
    PrivateModule Module     
    Scopes  
    TypeLiteral  
    FactoryModuleBuilder  
    FactoryProvider Provider    HasDependencies     
    GraphingVisitor BindingTargetVisitor     
    InjectorGrapher  
    ShortNameFactory NameFactory     
    StringNodeIdFactory NodeIdFactory     
    TransitiveDependencyVisitor BindingTargetVisitor     
    BindingEdgeFactory BindingEdge.Factory     
    BindingEdgeFactory.GraphvizEdgeAdaptor BindingEdge     
    DependencyEdgeFactory DependencyEdge.Factory     
    DependencyEdgeFactory.GraphvizEdgeAdaptor DependencyEdge     
    GraphvizEdge  
    GraphvizNode  
    GraphvizRenderer NodeAliasFactory    Renderer     
    ImplementationNodeFactory ImplementationNode.Factory     
    ImplementationNodeFactory.GraphvizNodeAdaptor ImplementationNode     
    InterfaceNodeFactory InterfaceNode.Factory     
    InterfaceNodeFactory.GraphvizNodeAdaptor InterfaceNode     
    PortIdFactoryImpl PortIdFactory     
    JndiIntegration  
    AbstractMatcher Matcher     
    Matchers  
    MapBinder  
    Multibinder  
    Names  
    PersistFilter  
    DynamicFinder  
    GuiceFilter  
    GuiceServletContextListener  
    ServletScopes  
    DefaultBindingScopingVisitor BindingScopingVisitor     
    DefaultBindingTargetVisitor BindingTargetVisitor     
    DefaultElementVisitor ElementVisitor     
    Dependency  
    DisableCircularProxiesOption Element     
    Elements  
    InjectionPoint  
    InjectionRequest Element     
    InterceptorBinding Element     
    MembersInjectorLookup Element     
    Message Element    Serializable     
    ProviderLookup Element     
    RequireExplicitBindingsOption Element     
    ScopeBinding Element     
    StaticInjectionRequest Element     
    TypeConverterBinding Element     
    TypeListenerBinding Element     
    SpringIntegration  
    ThrowingProviderBinder  
    ThrowingProviderBinder.SecondaryBinder  
    Manager  
    Modules  
    Providers  
    Types  
    sisu-guice-sisu-guice-3.1.1/javadoc/current.xml0000755000175000017500000074006011704661106020237 0ustar tonytony sisu-guice-sisu-guice-3.1.1/javadoc/com/0000755000175000017500000000000011704661106016577 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/0000755000175000017500000000000011704661106020053 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/0000755000175000017500000000000011704661106021327 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/util/0000755000175000017500000000000011704661106022304 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/util/package-summary.html0000755000175000017500000002732011704661106026267 0ustar tonytony com.google.inject.util | Guice
    package

    com.google.inject.util

    Classes | Description

    Helper methods for working with Guice.

    more...

    Interfaces

    Modules.OverriddenModuleBuilder See the EDSL example at override()

    Classes

    Modules Static utility methods for creating and working with instances of Module
    Providers Static utility methods for creating and working with instances of Provider
    Types Static methods for working with types. 
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/util/package-descr.html0000755000175000017500000002361511704661106025675 0ustar tonytony com.google.inject.util Details | Guice
    package

    com.google.inject.util

    Classes | Description

    Helper methods for working with Guice.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/util/Types.html0000755000175000017500000007321611704661106024312 0ustar tonytony Types | Guice
    public final class

    Types

    extends Object
    java.lang.Object
       ↳ com.google.inject.util.Types

    Class Overview

    Static methods for working with types.

    Summary

    Public Methods
    static GenericArrayType arrayOf(Type componentType)
    Returns an array type whose elements are all instances of componentType.
    static ParameterizedType listOf(Type elementType)
    Returns a type modelling a List whose elements are of type elementType.
    static ParameterizedType mapOf(Type keyType, Type valueType)
    Returns a type modelling a Map whose keys are of type keyType and whose values are of type valueType.
    static ParameterizedType newParameterizedType(Type rawType, Type... typeArguments)
    Returns a new parameterized type, applying typeArguments to rawType.
    static ParameterizedType newParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments)
    Returns a new parameterized type, applying typeArguments to rawType and enclosed by ownerType.
    static ParameterizedType providerOf(Type providedType)
    Returns a type modelling a Provider that provides elements of type elementType.
    static ParameterizedType setOf(Type elementType)
    Returns a type modelling a Set whose elements are of type elementType.
    static WildcardType subtypeOf(Type bound)
    Returns a type that represents an unknown type that extends bound.
    static WildcardType supertypeOf(Type bound)
    Returns a type that represents an unknown supertype of bound.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Methods

    public static GenericArrayType arrayOf (Type componentType)

    Returns an array type whose elements are all instances of componentType.

    Returns
    • a java.io.Serializable serializable generic array type.

    public static ParameterizedType listOf (Type elementType)

    Returns a type modelling a List whose elements are of type elementType.

    Returns
    • a java.io.Serializable serializable parameterized type.

    public static ParameterizedType mapOf (Type keyType, Type valueType)

    Returns a type modelling a Map whose keys are of type keyType and whose values are of type valueType.

    Returns
    • a java.io.Serializable serializable parameterized type.

    public static ParameterizedType newParameterizedType (Type rawType, Type... typeArguments)

    Returns a new parameterized type, applying typeArguments to rawType. The returned type does not have an owner type.

    Returns
    • a java.io.Serializable serializable parameterized type.

    public static ParameterizedType newParameterizedTypeWithOwner (Type ownerType, Type rawType, Type... typeArguments)

    Returns a new parameterized type, applying typeArguments to rawType and enclosed by ownerType.

    Returns
    • a java.io.Serializable serializable parameterized type.

    public static ParameterizedType providerOf (Type providedType)

    Returns a type modelling a Provider that provides elements of type elementType.

    Returns
    • a java.io.Serializable serializable parameterized type.

    public static ParameterizedType setOf (Type elementType)

    Returns a type modelling a Set whose elements are of type elementType.

    Returns
    • a java.io.Serializable serializable parameterized type.

    public static WildcardType subtypeOf (Type bound)

    Returns a type that represents an unknown type that extends bound. For example, if bound is CharSequence.class, this returns ? extends CharSequence. If bound is Object.class, this returns ?, which is shorthand for ? extends Object.

    public static WildcardType supertypeOf (Type bound)

    Returns a type that represents an unknown supertype of bound. For example, if bound is String.class, this returns ? super String.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/util/Providers.html0000755000175000017500000004631011704661106025156 0ustar tonytony Providers | Guice
    public final class

    Providers

    extends Object
    java.lang.Object
       ↳ com.google.inject.util.Providers

    Class Overview

    Static utility methods for creating and working with instances of Provider.

    Summary

    Public Methods
    static <T> Provider<T> guicify(Provider<T> provider)
    Returns a Guice-friendly com.google.inject.Provider for the given JSR-330 javax.inject.Provider.
    static <T> Provider<T> of(T instance)
    Returns a provider which always provides instance.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Methods

    public static Provider<T> guicify (Provider<T> provider)

    Returns a Guice-friendly com.google.inject.Provider for the given JSR-330 javax.inject.Provider. The converse method is unnecessary, since Guice providers directly implement the JSR-330 interface.

    public static Provider<T> of (T instance)

    Returns a provider which always provides instance. This should not be necessary to use in your application, but is helpful for several types of unit tests.

    Parameters
    instance the instance that should always be provided. This is also permitted to be null, to enable aggressive testing, although in real life a Guice-supplied Provider will never return null.
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/util/Modules.html0000755000175000017500000006410011704661106024606 0ustar tonytony Modules | Guice
    public final class

    Modules

    extends Object
    java.lang.Object
       ↳ com.google.inject.util.Modules

    Class Overview

    Static utility methods for creating and working with instances of Module.

    Summary

    Nested Classes
    interface Modules.OverriddenModuleBuilder See the EDSL example at override()
    Constants
    Module EMPTY_MODULE
    Public Methods
    static Module combine(Module... modules)
    Returns a new module that installs all of modules.
    static Module combine(Iterable<? extends Module> modules)
    Returns a new module that installs all of modules.
    static Modules.OverriddenModuleBuilder override(Module... modules)
    Returns a builder that creates a module that overlays override modules over the given modules.
    static Modules.OverriddenModuleBuilder override(Iterable<? extends Module> modules)
    Returns a builder that creates a module that overlays override modules over the given modules.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Constants

    public static final Module EMPTY_MODULE

    Public Methods

    public static Module combine (Module... modules)

    Returns a new module that installs all of modules.

    public static Module combine (Iterable<? extends Module> modules)

    Returns a new module that installs all of modules.

    public static Modules.OverriddenModuleBuilder override (Module... modules)

    Returns a builder that creates a module that overlays override modules over the given modules. If a key is bound in both sets of modules, only the binding from the override modules is kept. If a single PrivateModule is supplied or all elements are from a single PrivateBinder, then this will overwrite the private bindings. Otherwise, private bindings will not be overwritten unless they are exposed. This can be used to replace the bindings of a production module with test bindings:

     Module functionalTestModule
         = Modules.override(new ProductionModule()).with(new TestModule());
     

    Prefer to write smaller modules that can be reused and tested without overrides.

    Parameters
    modules the modules whose bindings are open to be overridden

    public static Modules.OverriddenModuleBuilder override (Iterable<? extends Module> modules)

    Returns a builder that creates a module that overlays override modules over the given modules. If a key is bound in both sets of modules, only the binding from the override modules is kept. If a single PrivateModule is supplied or all elements are from a single PrivateBinder, then this will overwrite the private bindings. Otherwise, private bindings will not be overwritten unless they are exposed. This can be used to replace the bindings of a production module with test bindings:

     Module functionalTestModule
         = Modules.override(getProductionModules()).with(getTestModules());
     

    Prefer to write smaller modules that can be reused and tested without overrides.

    Parameters
    modules the modules whose bindings are open to be overridden
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/util/Modules.OverriddenModuleBuilder.html0000755000175000017500000003470311704661106031371 0ustar tonytony Modules.OverriddenModuleBuilder | Guice
    public static interface

    Modules.OverriddenModuleBuilder

    com.google.inject.util.Modules.OverriddenModuleBuilder

    Class Overview

    See the EDSL example at override().

    Summary

    Public Methods
    abstract Module with(Module... overrides)
    See the EDSL example at override().
    abstract Module with(Iterable<? extends Module> overrides)
    See the EDSL example at override().

    Public Methods

    public abstract Module with (Module... overrides)

    See the EDSL example at override().

    public abstract Module with (Iterable<? extends Module> overrides)

    See the EDSL example at override().

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/tools/0000755000175000017500000000000011704661106022467 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/tools/jmx/0000755000175000017500000000000011704661106023265 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/tools/jmx/package-summary.html0000755000175000017500000002536011704661106027252 0ustar tonytony com.google.inject.tools.jmx | Guice
    package

    com.google.inject.tools.jmx

    Classes | Description

    JMX integration; this extension requires guice-jmx-3.0.jar.

    more...

    Interfaces

    ManagedBindingMBean JMX interface to bindings. 

    Classes

    Manager Provides a JMX interface to Guice. 
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/tools/jmx/package-descr.html0000755000175000017500000002346711704661106026663 0ustar tonytony com.google.inject.tools.jmx Details | Guice
    package

    com.google.inject.tools.jmx

    Classes | Description

    JMX integration; this extension requires guice-jmx-3.0.jar.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/tools/jmx/Manager.html0000755000175000017500000005266311704661106025544 0ustar tonytony Manager | Guice
    public class

    Manager

    extends Object
    java.lang.Object
       ↳ com.google.inject.tools.jmx.Manager

    Class Overview

    Provides a JMX interface to Guice.

    Summary

    Public Constructors
    Manager()
    Public Methods
    static void main(String[] args)
    Run with no arguments for usage instructions.
    static void manage(String domain, Injector injector)
    Registers all the bindings of an Injector with the platform MBean server.
    static void manage(MBeanServer server, String domain, Injector injector)
    Registers all the bindings of an Injector with the given MBean server.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Constructors

    public Manager ()

    Public Methods

    public static void main (String[] args)

    Run with no arguments for usage instructions.

    Throws
    Exception

    public static void manage (String domain, Injector injector)

    Registers all the bindings of an Injector with the platform MBean server. Consider using the name of your root Module class as the domain.

    public static void manage (MBeanServer server, String domain, Injector injector)

    Registers all the bindings of an Injector with the given MBean server. Consider using the name of your root Module class as the domain.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/tools/jmx/ManagedBindingMBean.html0000755000175000017500000003422111704661106027712 0ustar tonytony ManagedBindingMBean | Guice
    public interface

    ManagedBindingMBean

    com.google.inject.tools.jmx.ManagedBindingMBean

    Class Overview

    JMX interface to bindings.

    Summary

    Public Methods
    abstract String getKey()
    Gets the binding key.
    abstract String getProvider()
    Gets the provider to which this binding is bound.
    abstract String getSource()
    Gets the source of this binding.

    Public Methods

    public abstract String getKey ()

    Gets the binding key.

    public abstract String getProvider ()

    Gets the provider to which this binding is bound.

    public abstract String getSource ()

    Gets the source of this binding.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/throwingproviders/0000755000175000017500000000000011704661106025126 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/throwingproviders/package-summary.html0000755000175000017500000003115411704661106031111 0ustar tonytony com.google.inject.throwingproviders | Guice
    package

    com.google.inject.throwingproviders

    Classes | Description

    Extension for injecting objects that may throw at provision time; this extension requires guice-throwingproviders-3.0.jar.

    more...

    Interfaces

    CheckedProvider<T> Alternative to the Guice Provider that throws a checked Exception. 
    ThrowingProvider<T, E extends Exception> This interface is deprecated. use CheckedProvider instead.  

    Classes

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/throwingproviders/package-descr.html0000755000175000017500000002501711704661106030515 0ustar tonytony com.google.inject.throwingproviders Details | Guice
    package

    com.google.inject.throwingproviders

    Classes | Description

    Extension for injecting objects that may throw at provision time; this extension requires guice-throwingproviders-3.0.jar.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/throwingproviders/ThrowingProviderBinder.html0000755000175000017500000005436211704661106032471 0ustar tonytony ThrowingProviderBinder | Guice
    public class

    ThrowingProviderBinder

    extends Object
    java.lang.Object
       ↳ com.google.inject.throwingproviders.ThrowingProviderBinder

    Class Overview

    Builds a binding for a CheckedProvider.

    You can use a fluent API and custom providers:

    ThrowingProviderBinder.create(binder())
        .bind(RemoteProvider.class, Customer.class)
        .to(RemoteCustomerProvider.class)
        .in(RequestScope.class);
     
    or, you can use throwing provider methods:
    class MyModule extends AbstractModule {
       configure() {
         ThrowingProviderBinder.install(this, binder());
       }
       
       @CheckedProvides(RemoteProvider.class)
       @RequestScope
       Customer provideCustomer(FlakyCustomerCreator creator) throws RemoteException {
         return creator.getCustomerOrThrow();
       }
     }
     

    Summary

    Nested Classes
    class ThrowingProviderBinder.SecondaryBinder<P extends CheckedProvider>  
    Public Methods
    <P extends CheckedProvider> SecondaryBinder<P> bind(Class<P> interfaceType, Type valueType)
    static ThrowingProviderBinder create(Binder binder)
    static Module forModule(Module module)
    Returns a module that installs @CheckedProvides methods.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Methods

    public SecondaryBinder<P> bind (Class<P> interfaceType, Type valueType)

    public static ThrowingProviderBinder create (Binder binder)

    public static Module forModule (Module module)

    Returns a module that installs @CheckedProvides methods.

    ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/throwingproviders/ThrowingProviderBinder.SecondaryBinder.htmlsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/throwingproviders/ThrowingProviderBinder.Secon0000755000175000017500000006144511704661106032574 0ustar tonytony ThrowingProviderBinder.SecondaryBinder | Guice
    public class

    ThrowingProviderBinder.SecondaryBinder

    extends Object
    java.lang.Object
       ↳ com.google.inject.throwingproviders.ThrowingProviderBinder.SecondaryBinder<P extends com.google.inject.throwingproviders.CheckedProvider>

    Summary

    Public Constructors
    ThrowingProviderBinder.SecondaryBinder(Class<P> interfaceType, Type valueType)
    Public Methods
    SecondaryBinder<P> annotatedWith(Class<? extends Annotation> annotationType)
    SecondaryBinder<P> annotatedWith(Annotation annotation)
    ScopedBindingBuilder to(P target)
    ScopedBindingBuilder to(Key<? extends P> targetKey)
    ScopedBindingBuilder to(Class<? extends P> targetType)
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Constructors

    public ThrowingProviderBinder.SecondaryBinder (Class<P> interfaceType, Type valueType)

    Public Methods

    public SecondaryBinder<P> annotatedWith (Class<? extends Annotation> annotationType)

    public SecondaryBinder<P> annotatedWith (Annotation annotation)

    public ScopedBindingBuilder to (P target)

    public ScopedBindingBuilder to (Key<? extends P> targetKey)

    public ScopedBindingBuilder to (Class<? extends P> targetType)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/throwingproviders/ThrowingProvider.html0000755000175000017500000003741311704661106031343 0ustar tonytony ThrowingProvider | Guice
    public interface

    ThrowingProvider

    implements CheckedProvider<T>
    com.google.inject.throwingproviders.ThrowingProvider<T, E extends java.lang.Exception>

    This interface is deprecated.
    use CheckedProvider instead.

    Class Overview

    Alternative to the Guice Provider that throws a checked Exception. Users may not inject T directly.

    This interface must be extended to use application-specific exception types. Such subinterfaces may not define new methods:

     public interface RemoteProvider<T> extends ThrowingProvider<T, RemoteException> { }
     

    When this type is bound using ThrowingProviderBinder, the value returned or exception thrown by get() will be scoped. As a consequence, get() will invoked at most once within each scope.

    Summary

    Public Methods
    abstract T get()
    [Expand]
    Inherited Methods
    From interface com.google.inject.throwingproviders.CheckedProvider

    Public Methods

    public abstract T get ()

    Throws
    Exception
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/throwingproviders/CheckedProvides.html0000755000175000017500000003472611704661106031075 0ustar tonytony CheckedProvides | Guice
    public abstract @interface

    CheckedProvides

    implements Annotation
    com.google.inject.throwingproviders.CheckedProvides

    Class Overview

    Annotates methods of a Module to create a CheckedProvider method binding that can throw exceptions. The method's return type is bound to a CheckedProvider that can be injected. Guice will pass dependencies to the method as parameters. Install @CheckedProvides methods by using forModule(com.google.inject.Module) on the module where the methods are declared.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/throwingproviders/CheckedProvider.html0000755000175000017500000003624311704661106031070 0ustar tonytony CheckedProvider | Guice
    public interface

    CheckedProvider

    com.google.inject.throwingproviders.CheckedProvider<T>
    Known Indirect Subclasses

    Class Overview

    Alternative to the Guice Provider that throws a checked Exception. Users may not inject T directly.

    This interface must be extended to use application-specific exception types. Such subinterfaces may not define new methods, but may narrow the exception type.

     public interface RemoteProvider<T> extends CheckedProvider<T> { 
       T get() throws CustomExceptionOne, CustomExceptionTwo;
     }
     

    When this type is bound using ThrowingProviderBinder, the value returned or exception thrown by get() will be scoped. As a consequence, get() will invoked at most once within each scope.

    Summary

    Public Methods
    abstract T get()

    Public Methods

    public abstract T get ()

    Throws
    Exception
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spring/0000755000175000017500000000000011704661106022631 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spring/package-summary.html0000755000175000017500000002403011704661106026607 0ustar tonytony com.google.inject.spring | Guice
    package

    com.google.inject.spring

    Classes | Description

    Spring integration; this extension requires guice-spring-3.0.jar.

    more...

    Classes

    SpringIntegration Integrates Guice with Spring. 
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spring/package-descr.html0000755000175000017500000002300011704661106026206 0ustar tonytony com.google.inject.spring Details | Guice
    package

    com.google.inject.spring

    Classes | Description

    Spring integration; this extension requires guice-spring-3.0.jar.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spring/SpringIntegration.html0000755000175000017500000004542611704661106027203 0ustar tonytony SpringIntegration | Guice
    public class

    SpringIntegration

    extends Object
    java.lang.Object
       ↳ com.google.inject.spring.SpringIntegration

    Class Overview

    Integrates Guice with Spring.

    Summary

    Public Methods
    static void bindAll(Binder binder, ListableBeanFactory beanFactory)
    Binds all Spring beans from the given factory by name.
    static <T> Provider<T> fromSpring(Class<T> type, String name)
    Creates a provider which looks up objects from Spring using the given name.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Methods

    public static void bindAll (Binder binder, ListableBeanFactory beanFactory)

    Binds all Spring beans from the given factory by name. For a Spring bean named "foo", this method creates a binding to the bean's type and @Named("foo").

    public static Provider<T> fromSpring (Class<T> type, String name)

    Creates a provider which looks up objects from Spring using the given name. Expects a binding to org.springframework.beans.factory.BeanFactory. Example usage:

     bind(DataSource.class)
       .toProvider(fromSpring(DataSource.class, "dataSource"));
     

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/0000755000175000017500000000000011704661106022122 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/package-summary.html0000755000175000017500000006707111704661106026114 0ustar tonytony com.google.inject.spi | Guice
    package

    com.google.inject.spi

    Classes | Description

    Guice service provider interface

    Interfaces

    BindingScopingVisitor<V> Visits each of the strategies used to scope an injection. 
    BindingTargetVisitor<T, V> Visits each of the strategies used to find an instance to satisfy an injection. 
    ConstructorBinding<T> A binding to the constructor of a concrete clss. 
    ConvertedConstantBinding<T> A binding created from converting a bound instance to a new type. 
    Element A core component of a module or injector. 
    ElementVisitor<V> Visit elements. 
    ExposedBinding<T> A binding to a key exposed from an enclosed private environment. 
    HasDependencies Implemented by bindings, providers and instances that expose their dependencies explicitly. 
    InjectionListener<I> Listens for injections into instances of type I
    InstanceBinding<T> A binding to a single instance. 
    LinkedKeyBinding<T> A binding to a linked key. 
    PrivateElements A private collection of elements that are hidden from the enclosing injector or module by default. 
    ProviderBinding<T extends Provider<?>> A binding to a Provider that delegates to the binding for the provided type. 
    ProviderInstanceBinding<T> A binding to a provider instance. 
    ProviderKeyBinding<T> A binding to a provider key. 
    ProviderWithDependencies<T> A provider with dependencies on other injected types. 
    ProviderWithExtensionVisitor<T> A Provider that is part of an extension which supports a custom BindingTargetVisitor. 
    TypeConverter Converts constant string values to a different type. 
    TypeEncounter<I> Context of an injectable type encounter. 
    TypeListener Listens for Guice to encounter injectable types. 
    UntargettedBinding<T> An untargetted binding. 

    Classes

    DefaultBindingScopingVisitor<V> No-op visitor for subclassing. 
    DefaultBindingTargetVisitor<T, V> No-op visitor for subclassing. 
    DefaultElementVisitor<V> No-op visitor for subclassing. 
    Dependency<T> A variable that can be resolved by an injector. 
    DisableCircularProxiesOption A request to disable circular proxies. 
    Elements Exposes elements of a module so they can be inspected, validated or rewritten
    InjectionPoint A constructor, field or method that can receive injections. 
    InjectionRequest<T> A request to inject the instance fields and methods of an instance. 
    InterceptorBinding Registration of interceptors for matching methods of matching classes. 
    MembersInjectorLookup<T> A lookup of the members injector for a type. 
    Message An error message and the context in which it occured. 
    ProviderLookup<T> A lookup of the provider for a type. 
    RequireExplicitBindingsOption A request to require explicit bindings. 
    ScopeBinding Registration of a scope annotation with the scope that implements it. 
    StaticInjectionRequest A request to inject the static fields and methods of a type. 
    TypeConverterBinding Registration of type converters for matching target types. 
    TypeListenerBinding Binds types (picked using a Matcher) to an type listener. 
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/package-descr.html0000755000175000017500000003577511704661106025525 0ustar tonytony com.google.inject.spi Details | Guice
    package

    com.google.inject.spi

    Classes | Description

    Guice service provider interface

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/UntargettedBinding.html0000755000175000017500000005454311704661106026607 0ustar tonytony UntargettedBinding | Guice
    public interface

    UntargettedBinding

    implements Binding<T>
    com.google.inject.spi.UntargettedBinding<T>

    Class Overview

    An untargetted binding. This binding indicates that the injector should use its implicit binding strategies to resolve injections.

    Summary

    [Expand]
    Inherited Methods
    From interface com.google.inject.Binding
    From interface com.google.inject.spi.Element
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/TypeListenerBinding.html0000755000175000017500000007704311704661106026750 0ustar tonytony TypeListenerBinding | Guice
    public final class

    TypeListenerBinding

    extends Object
    implements Element
    java.lang.Object
       ↳ com.google.inject.spi.TypeListenerBinding

    Class Overview

    Binds types (picked using a Matcher) to an type listener. Registrations are created explicitly in a module using bindListener(Matcher, TypeListener) statements:

         register(only(new TypeLiteral<PaymentService<CreditCard>>() {}), listener);

    Summary

    Public Methods
    <T> T acceptVisitor(ElementVisitor<T> visitor)
    Accepts an element visitor.
    void applyTo(Binder binder)
    Writes this module element to the given binder (optional operation).
    TypeListener getListener()
    Returns the registered listener.
    Object getSource()
    Returns an arbitrary object containing information about the "place" where this element was configured.
    Matcher<? super TypeLiteral<?>> getTypeMatcher()
    Returns the type matcher which chooses which types the listener should be notified of.
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.Element

    Public Methods

    public T acceptVisitor (ElementVisitor<T> visitor)

    Accepts an element visitor. Invokes the visitor method specific to this element's type.

    Parameters
    visitor to call back on

    public void applyTo (Binder binder)

    Writes this module element to the given binder (optional operation).

    Parameters
    binder to apply configuration element to

    public TypeListener getListener ()

    Returns the registered listener.

    public Object getSource ()

    Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

    Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

    public Matcher<? super TypeLiteral<?>> getTypeMatcher ()

    Returns the type matcher which chooses which types the listener should be notified of.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/TypeListener.html0000755000175000017500000004565011704661106025454 0ustar tonytony TypeListener | Guice
    public interface

    TypeListener

    com.google.inject.spi.TypeListener

    Class Overview

    Listens for Guice to encounter injectable types. If a given type has its constructor injected in one situation but only its methods and fields injected in another, Guice will notify this listener once.

    Useful for extra type checking, registering injection listeners, and binding method interceptors.

    Summary

    Public Methods
    abstract <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter)
    Invoked when Guice encounters a new type eligible for constructor or members injection.

    Public Methods

    public abstract void hear (TypeLiteral<I> type, TypeEncounter<I> encounter)

    Invoked when Guice encounters a new type eligible for constructor or members injection. Called during injector creation (or afterwords if Guice encounters a type at run time and creates a JIT binding).

    Parameters
    type encountered by Guice
    encounter context of this encounter, enables reporting errors, registering injection listeners and binding method interceptors for type.
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/TypeEncounter.html0000755000175000017500000010374011704661106025624 0ustar tonytony TypeEncounter | Guice
    public interface

    TypeEncounter

    com.google.inject.spi.TypeEncounter<I>

    Class Overview

    Context of an injectable type encounter. Enables reporting errors, registering injection listeners and binding method interceptors for injectable type I. It is an error to use an encounter after the hear() method has returned.

    Summary

    Public Methods
    abstract void addError(Message message)
    Records an error message to be presented to the user at a later time.
    abstract void addError(String message, Object... arguments)
    Records an error message for type I which will be presented to the user at a later time.
    abstract void addError(Throwable t)
    Records an exception for type I, the full details of which will be logged, and the message of which will be presented to the user at a later time.
    abstract void bindInterceptor(Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)
    Binds method interceptor[s] to methods matched in type I and its supertypes.
    abstract <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral)
    Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
    abstract <T> MembersInjector<T> getMembersInjector(Class<T> type)
    Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
    abstract <T> Provider<T> getProvider(Key<T> key)
    Returns the provider used to obtain instances for the given injection key.
    abstract <T> Provider<T> getProvider(Class<T> type)
    Returns the provider used to obtain instances for the given injection type.
    abstract void register(MembersInjector<? super I> membersInjector)
    Registers a members injector for type I.
    abstract void register(InjectionListener<? super I> listener)
    Registers an injection listener for type I.

    Public Methods

    public abstract void addError (Message message)

    Records an error message to be presented to the user at a later time.

    public abstract void addError (String message, Object... arguments)

    Records an error message for type I which will be presented to the user at a later time. Unlike throwing an exception, this enable us to continue configuring the Injector and discover more errors. Uses format(String, Object[]) to insert the arguments into the message.

    public abstract void addError (Throwable t)

    Records an exception for type I, the full details of which will be logged, and the message of which will be presented to the user at a later time. If your type listener calls something that you worry may fail, you should catch the exception and pass it to this method.

    public abstract void bindInterceptor (Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)

    Binds method interceptor[s] to methods matched in type I and its supertypes. A method is eligible for interception if:

    • Guice created the instance the method is on
    • Neither the enclosing type nor the method is final
    • And the method is package-private or more accessible

    Parameters
    methodMatcher matches methods the interceptor should apply to. For example: annotatedWith(Transactional.class).
    interceptors to bind

    public abstract MembersInjector<T> getMembersInjector (TypeLiteral<T> typeLiteral)

    Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. The returned members injector will not be valid until the main injector has been created. The members injector will throw an IllegalStateException if you try to use it beforehand.

    Parameters
    typeLiteral type to get members injector for

    public abstract MembersInjector<T> getMembersInjector (Class<T> type)

    Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. The returned members injector will not be valid until the main injector has been created. The members injector will throw an IllegalStateException if you try to use it beforehand.

    Parameters
    type type to get members injector for

    public abstract Provider<T> getProvider (Key<T> key)

    Returns the provider used to obtain instances for the given injection key. The returned provider will not be valid until the injector has been created. The provider will throw an IllegalStateException if you try to use it beforehand.

    public abstract Provider<T> getProvider (Class<T> type)

    Returns the provider used to obtain instances for the given injection type. The returned provider will not be valid until the injetor has been created. The provider will throw an IllegalStateException if you try to use it beforehand.

    public abstract void register (MembersInjector<? super I> membersInjector)

    Registers a members injector for type I. Guice will use the members injector after its performed its own injections on an instance of I.

    public abstract void register (InjectionListener<? super I> listener)

    Registers an injection listener for type I. Guice will notify the listener after all injections have been performed on an instance of I.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/TypeConverterBinding.html0000755000175000017500000010452511704661106027126 0ustar tonytony TypeConverterBinding | Guice
    public final class

    TypeConverterBinding

    extends Object
    implements Element
    java.lang.Object
       ↳ com.google.inject.spi.TypeConverterBinding

    Class Overview

    Registration of type converters for matching target types. Instances are created explicitly in a module using convertToTypes() statements:

         convertToTypes(Matchers.only(TypeLiteral.get(DateTime.class)), new DateTimeConverter());

    Summary

    Public Constructors
    TypeConverterBinding(Object source, Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter typeConverter)
    Public Methods
    <T> T acceptVisitor(ElementVisitor<T> visitor)
    Accepts an element visitor.
    void applyTo(Binder binder)
    Writes this module element to the given binder (optional operation).
    Object getSource()
    Returns an arbitrary object containing information about the "place" where this element was configured.
    TypeConverter getTypeConverter()
    Matcher<? super TypeLiteral<?>> getTypeMatcher()
    String toString()
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.Element

    Public Constructors

    public TypeConverterBinding (Object source, Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter typeConverter)

    Public Methods

    public T acceptVisitor (ElementVisitor<T> visitor)

    Accepts an element visitor. Invokes the visitor method specific to this element's type.

    Parameters
    visitor to call back on

    public void applyTo (Binder binder)

    Writes this module element to the given binder (optional operation).

    Parameters
    binder to apply configuration element to

    public Object getSource ()

    Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

    Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

    public TypeConverter getTypeConverter ()

    public Matcher<? super TypeLiteral<?>> getTypeMatcher ()

    public String toString ()

    Since: API Level

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/TypeConverter.html0000755000175000017500000004300411704661106025625 0ustar tonytony TypeConverter | Guice
    public interface

    TypeConverter

    com.google.inject.spi.TypeConverter

    Class Overview

    Converts constant string values to a different type.

    Summary

    Public Methods
    abstract Object convert(String value, TypeLiteral<?> toType)
    Converts a string value.

    Public Methods

    public abstract Object convert (String value, TypeLiteral<?> toType)

    Converts a string value. Throws an exception if a conversion error occurs.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/Toolable.html0000755000175000017500000004642211704661106024564 0ustar tonytony Toolable | Guice
    public abstract @interface

    Toolable

    implements Annotation
    com.google.inject.spi.Toolable

    Class Overview

    Instructs an Injector running in TOOL that a method should be injected. This is typically useful for for extensions to Guice that perform additional validation in an injected method or field. This only applies to objects that are already constructed when bindings are created (ie., something bound using toProvider, toInstance, or requestInjection.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/StaticInjectionRequest.html0000755000175000017500000010011111704661106027450 0ustar tonytony StaticInjectionRequest | Guice
    public final class

    StaticInjectionRequest

    extends Object
    implements Element
    java.lang.Object
       ↳ com.google.inject.spi.StaticInjectionRequest

    Class Overview

    A request to inject the static fields and methods of a type. Requests are created explicitly in a module using requestStaticInjection() statements:

         requestStaticInjection(MyLegacyService.class);

    Summary

    Public Methods
    <T> T acceptVisitor(ElementVisitor<T> visitor)
    Accepts an element visitor.
    void applyTo(Binder binder)
    Writes this module element to the given binder (optional operation).
    Set<InjectionPoint> getInjectionPoints()
    Returns the static methods and fields of type that will be injected to fulfill this request.
    Object getSource()
    Returns an arbitrary object containing information about the "place" where this element was configured.
    Class<?> getType()
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.Element

    Public Methods

    public T acceptVisitor (ElementVisitor<T> visitor)

    Accepts an element visitor. Invokes the visitor method specific to this element's type.

    Parameters
    visitor to call back on

    public void applyTo (Binder binder)

    Writes this module element to the given binder (optional operation).

    Parameters
    binder to apply configuration element to

    public Set<InjectionPoint> getInjectionPoints ()

    Returns the static methods and fields of type that will be injected to fulfill this request.

    Returns
    • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
    Throws
    ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

    public Object getSource ()

    Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

    Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

    public Class<?> getType ()

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/ScopeBinding.html0000755000175000017500000007552011704661106025370 0ustar tonytony ScopeBinding | Guice
    public final class

    ScopeBinding

    extends Object
    implements Element
    java.lang.Object
       ↳ com.google.inject.spi.ScopeBinding

    Class Overview

    Registration of a scope annotation with the scope that implements it. Instances are created explicitly in a module using bindScope() statements:

         Scope recordScope = new RecordScope();
         bindScope(RecordScoped.class, new RecordScope());

    Summary

    Public Methods
    <T> T acceptVisitor(ElementVisitor<T> visitor)
    Accepts an element visitor.
    void applyTo(Binder binder)
    Writes this module element to the given binder (optional operation).
    Class<? extends Annotation> getAnnotationType()
    Scope getScope()
    Object getSource()
    Returns an arbitrary object containing information about the "place" where this element was configured.
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.Element

    Public Methods

    public T acceptVisitor (ElementVisitor<T> visitor)

    Accepts an element visitor. Invokes the visitor method specific to this element's type.

    Parameters
    visitor to call back on

    public void applyTo (Binder binder)

    Writes this module element to the given binder (optional operation).

    Parameters
    binder to apply configuration element to

    public Class<? extends Annotation> getAnnotationType ()

    public Scope getScope ()

    public Object getSource ()

    Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

    Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/RequireExplicitBindingsOption.html0000755000175000017500000007060011704661106031003 0ustar tonytony RequireExplicitBindingsOption | Guice
    public final class

    RequireExplicitBindingsOption

    extends Object
    implements Element
    java.lang.Object
       ↳ com.google.inject.spi.RequireExplicitBindingsOption

    Class Overview

    A request to require explicit bindings.

    Summary

    Public Methods
    <T> T acceptVisitor(ElementVisitor<T> visitor)
    Accepts an element visitor.
    void applyTo(Binder binder)
    Writes this module element to the given binder (optional operation).
    Object getSource()
    Returns an arbitrary object containing information about the "place" where this element was configured.
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.Element

    Public Methods

    public T acceptVisitor (ElementVisitor<T> visitor)

    Accepts an element visitor. Invokes the visitor method specific to this element's type.

    Parameters
    visitor to call back on

    public void applyTo (Binder binder)

    Writes this module element to the given binder (optional operation).

    Parameters
    binder to apply configuration element to

    public Object getSource ()

    Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

    Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/ProviderWithExtensionVisitor.html0000755000175000017500000005476111704661106030733 0ustar tonytony ProviderWithExtensionVisitor | Guice
    public interface

    ProviderWithExtensionVisitor

    implements Provider<T>
    com.google.inject.spi.ProviderWithExtensionVisitor<T>

    Class Overview

    A Provider that is part of an extension which supports a custom BindingTargetVisitor.

    When an extension binds a provider instance, the provider can implement this interface to allow users using the acceptTargetVisitor(BindingTargetVisitor) method to visit a custom visitor designed for that extension. A typical implementation within the extension would look like

     
     <V, B> V acceptExtensionVisitor(BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding) {
       if(visitor instanceof MyCustomExtensionVisitor) {
         return ((MyCustomExtensionVisitor<B, V>)visitor).visitCustomExtension(customProperties, binding);
       } else {
         return visitor.visit(binding);
       }
     }
    'MyCustomExtensionVisitor' in the example above would be an interface the extension provides that users can implement in order to be notified of custom extension information. These visitor interfaces must extend from BindingTargetVisitor.

    Summary

    Public Methods
    abstract <B, V> V acceptExtensionVisitor(BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding)
    Instructs the extension determine if the visitor is an instance of a custom extension visitor, and if so, visit it using that method.
    [Expand]
    Inherited Methods
    From interface com.google.inject.Provider
    From interface javax.inject.Provider

    Public Methods

    public abstract V acceptExtensionVisitor (BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding)

    Instructs the extension determine if the visitor is an instance of a custom extension visitor, and if so, visit it using that method. If the visitor is not an instance of the custom extension visitor, this method MUST call visitor.visit(binding).

    Due to issues with generics, the type parameters of this method do not relate to the type of the provider. In practice, the 'B' type will always be a supertype of 'T'.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/ProviderWithDependencies.html0000755000175000017500000005114611704661106027757 0ustar tonytony ProviderWithDependencies | Guice
    public interface

    ProviderWithDependencies

    implements Provider<T> HasDependencies
    com.google.inject.spi.ProviderWithDependencies<T>

    Class Overview

    A provider with dependencies on other injected types. If a Provider has dependencies that aren't specified in injections, this interface should be used to expose all dependencies.

    Summary

    [Expand]
    Inherited Methods
    From interface com.google.inject.Provider
    From interface com.google.inject.spi.HasDependencies
    From interface javax.inject.Provider
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/ProviderLookup.html0000755000175000017500000010724411704661106026007 0ustar tonytony ProviderLookup | Guice
    public final class

    ProviderLookup

    extends Object
    implements Element
    java.lang.Object
       ↳ com.google.inject.spi.ProviderLookup<T>

    Class Overview

    A lookup of the provider for a type. Lookups are created explicitly in a module using getProvider() statements:

         Provider<PaymentService> paymentServiceProvider
             = getProvider(PaymentService.class);

    Summary

    Public Constructors
    ProviderLookup(Object source, Key<T> key)
    Public Methods
    <T> T acceptVisitor(ElementVisitor<T> visitor)
    Accepts an element visitor.
    void applyTo(Binder binder)
    Writes this module element to the given binder (optional operation).
    Provider<T> getDelegate()
    Returns the delegate provider, or null if it has not yet been initialized.
    Key<T> getKey()
    Provider<T> getProvider()
    Returns the looked up provider.
    Object getSource()
    Returns an arbitrary object containing information about the "place" where this element was configured.
    void initializeDelegate(Provider<T> delegate)
    Sets the actual provider.
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.Element

    Public Constructors

    public ProviderLookup (Object source, Key<T> key)

    Public Methods

    public T acceptVisitor (ElementVisitor<T> visitor)

    Accepts an element visitor. Invokes the visitor method specific to this element's type.

    Parameters
    visitor to call back on

    public void applyTo (Binder binder)

    Writes this module element to the given binder (optional operation).

    Parameters
    binder to apply configuration element to

    public Provider<T> getDelegate ()

    Returns the delegate provider, or null if it has not yet been initialized. The delegate will be initialized when this element is processed, or otherwise used to create an injector.

    public Key<T> getKey ()

    public Provider<T> getProvider ()

    Returns the looked up provider. The result is not valid until this lookup has been initialized, which usually happens when the injector is created. The provider will throw an IllegalStateException if you try to use it beforehand.

    public Object getSource ()

    Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

    Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

    public void initializeDelegate (Provider<T> delegate)

    Sets the actual provider.

    Throws
    IllegalStateException if the delegate is already set
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/ProviderKeyBinding.html0000755000175000017500000006026711704661106026564 0ustar tonytony ProviderKeyBinding | Guice
    public interface

    ProviderKeyBinding

    implements Binding<T>
    com.google.inject.spi.ProviderKeyBinding<T>

    Class Overview

    A binding to a provider key. To resolve injections, the provider key is first resolved, then that provider's get method is invoked.

    Summary

    Public Methods
    abstract Key<? extends Provider<? extends T>> getProviderKey()
    Returns the key used to resolve the provider's binding.
    [Expand]
    Inherited Methods
    From interface com.google.inject.Binding
    From interface com.google.inject.spi.Element

    Public Methods

    public abstract Key<? extends Provider<? extends T>> getProviderKey ()

    Returns the key used to resolve the provider's binding. That binding can be retrieved from an injector using Injector.getBinding(providerKey)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/ProviderInstanceBinding.html0000755000175000017500000006615311704661106027600 0ustar tonytony ProviderInstanceBinding | Guice
    public interface

    ProviderInstanceBinding

    implements Binding<T> HasDependencies
    com.google.inject.spi.ProviderInstanceBinding<T>

    Class Overview

    A binding to a provider instance. The provider's get method is invoked to resolve injections.

    Summary

    Public Methods
    abstract Set<InjectionPoint> getInjectionPoints()
    Returns the field and method injection points of the provider, injected at injector-creation time only.
    abstract Provider<? extends T> getProviderInstance()
    Returns the user-supplied, unscoped provider.
    [Expand]
    Inherited Methods
    From interface com.google.inject.Binding
    From interface com.google.inject.spi.Element
    From interface com.google.inject.spi.HasDependencies

    Public Methods

    public abstract Set<InjectionPoint> getInjectionPoints ()

    Returns the field and method injection points of the provider, injected at injector-creation time only.

    Returns
    • a possibly empty set

    public abstract Provider<? extends T> getProviderInstance ()

    Returns the user-supplied, unscoped provider.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/ProviderBinding.html0000755000175000017500000006071611704661106026112 0ustar tonytony ProviderBinding | Guice
    public interface

    ProviderBinding

    implements Binding<T>
    com.google.inject.spi.ProviderBinding<T extends com.google.inject.Provider<?>>

    Class Overview

    A binding to a Provider that delegates to the binding for the provided type. This binding is used whenever a Provider<T> is injected (as opposed to injecting T directly).

    Summary

    Public Methods
    abstract Key<?> getProvidedKey()
    Returns the key whose binding is used to provide instances.
    [Expand]
    Inherited Methods
    From interface com.google.inject.Binding
    From interface com.google.inject.spi.Element

    Public Methods

    public abstract Key<?> getProvidedKey ()

    Returns the key whose binding is used to provide instances. That binding can be retrieved from an injector using Injector.getBinding(providedKey)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/PrivateElements.html0000755000175000017500000006264711704661106026141 0ustar tonytony PrivateElements | Guice
    public interface

    PrivateElements

    implements Element
    com.google.inject.spi.PrivateElements

    Class Overview

    A private collection of elements that are hidden from the enclosing injector or module by default. See PrivateModule for details.

    Summary

    Public Methods
    abstract List<Element> getElements()
    Returns the configuration information in this private environment.
    abstract Set<Key<?>> getExposedKeys()
    Returns the unique exposed keys for these private elements.
    abstract Object getExposedSource(Key<?> key)
    Returns an arbitrary object containing information about the "place" where this key was exposed.
    abstract Injector getInjector()
    Returns the child injector that hosts these private elements, or null if the elements haven't been used to create an injector.
    [Expand]
    Inherited Methods
    From interface com.google.inject.spi.Element

    Public Methods

    public abstract List<Element> getElements ()

    Returns the configuration information in this private environment.

    public abstract Set<Key<?>> getExposedKeys ()

    Returns the unique exposed keys for these private elements.

    public abstract Object getExposedSource (Key<?> key)

    Returns an arbitrary object containing information about the "place" where this key was exposed. Used by Guice in the production of descriptive error messages.

    Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

    Parameters
    key one of the keys exposed by this module.

    public abstract Injector getInjector ()

    Returns the child injector that hosts these private elements, or null if the elements haven't been used to create an injector.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/Message.html0000755000175000017500000011473111704661106024406 0ustar tonytony Message | Guice
    public final class

    Message

    extends Object
    implements Element Serializable
    java.lang.Object
       ↳ com.google.inject.spi.Message

    Class Overview

    An error message and the context in which it occured. Messages are usually created internally by Guice and its extensions. Messages can be created explicitly in a module using addError() statements:

         try {
           bindPropertiesFromFile();
         } catch (IOException e) {
           addError(e);
         }

    Summary

    Public Constructors
    Message(Object source, String message)
    Message(String message)
    Message(List<Object> sources, String message, Throwable cause)
    Public Methods
    <T> T acceptVisitor(ElementVisitor<T> visitor)
    Accepts an element visitor.
    void applyTo(Binder binder)
    Writes this module element to the given binder (optional operation).
    boolean equals(Object o)
    Throwable getCause()
    Returns the throwable that caused this message, or null if this message was not caused by a throwable.
    String getMessage()
    Gets the error message text.
    String getSource()
    Returns an arbitrary object containing information about the "place" where this element was configured.
    List<Object> getSources()
    int hashCode()
    String toString()
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.Element

    Public Constructors

    public Message (Object source, String message)

    public Message (String message)

    public Message (List<Object> sources, String message, Throwable cause)

    Public Methods

    public T acceptVisitor (ElementVisitor<T> visitor)

    Accepts an element visitor. Invokes the visitor method specific to this element's type.

    Parameters
    visitor to call back on

    public void applyTo (Binder binder)

    Writes this module element to the given binder (optional operation).

    Parameters
    binder to apply configuration element to

    public boolean equals (Object o)

    Since: API Level

    public Throwable getCause ()

    Returns the throwable that caused this message, or null if this message was not caused by a throwable.

    public String getMessage ()

    Gets the error message text.

    public String getSource ()

    Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

    Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

    public List<Object> getSources ()

    public int hashCode ()

    Since: API Level

    public String toString ()

    Since: API Level

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/MembersInjectorLookup.html0000755000175000017500000011031411704661106027275 0ustar tonytony MembersInjectorLookup | Guice
    public final class

    MembersInjectorLookup

    extends Object
    implements Element
    java.lang.Object
       ↳ com.google.inject.spi.MembersInjectorLookup<T>

    Class Overview

    A lookup of the members injector for a type. Lookups are created explicitly in a module using getMembersInjector() statements:

         MembersInjector<PaymentService> membersInjector
             = getMembersInjector(PaymentService.class);

    Summary

    Public Constructors
    MembersInjectorLookup(Object source, TypeLiteral<T> type)
    Public Methods
    <T> T acceptVisitor(ElementVisitor<T> visitor)
    Accepts an element visitor.
    void applyTo(Binder binder)
    Writes this module element to the given binder (optional operation).
    MembersInjector<T> getDelegate()
    Returns the delegate members injector, or null if it has not yet been initialized.
    MembersInjector<T> getMembersInjector()
    Returns the looked up members injector.
    Object getSource()
    Returns an arbitrary object containing information about the "place" where this element was configured.
    TypeLiteral<T> getType()
    Gets the type containing the members to be injected.
    void initializeDelegate(MembersInjector<T> delegate)
    Sets the actual members injector.
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.Element

    Public Constructors

    public MembersInjectorLookup (Object source, TypeLiteral<T> type)

    Public Methods

    public T acceptVisitor (ElementVisitor<T> visitor)

    Accepts an element visitor. Invokes the visitor method specific to this element's type.

    Parameters
    visitor to call back on

    public void applyTo (Binder binder)

    Writes this module element to the given binder (optional operation).

    Parameters
    binder to apply configuration element to

    public MembersInjector<T> getDelegate ()

    Returns the delegate members injector, or null if it has not yet been initialized. The delegate will be initialized when this element is processed, or otherwise used to create an injector.

    public MembersInjector<T> getMembersInjector ()

    Returns the looked up members injector. The result is not valid until this lookup has been initialized, which usually happens when the injector is created. The members injector will throw an IllegalStateException if you try to use it beforehand.

    public Object getSource ()

    Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

    Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

    public TypeLiteral<T> getType ()

    Gets the type containing the members to be injected.

    public void initializeDelegate (MembersInjector<T> delegate)

    Sets the actual members injector.

    Throws
    IllegalStateException if the delegate is already set
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/LinkedKeyBinding.html0000755000175000017500000006001611704661106026170 0ustar tonytony LinkedKeyBinding | Guice
    public interface

    LinkedKeyBinding

    implements Binding<T>
    com.google.inject.spi.LinkedKeyBinding<T>

    Class Overview

    A binding to a linked key. The other key's binding is used to resolve injections.

    Summary

    Public Methods
    abstract Key<? extends T> getLinkedKey()
    Returns the linked key used to resolve injections.
    [Expand]
    Inherited Methods
    From interface com.google.inject.Binding
    From interface com.google.inject.spi.Element

    Public Methods

    public abstract Key<? extends T> getLinkedKey ()

    Returns the linked key used to resolve injections. That binding can be retrieved from an injector using Injector.getBinding(key).

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/InterceptorBinding.html0000755000175000017500000010117211704661106026606 0ustar tonytony InterceptorBinding | Guice
    public final class

    InterceptorBinding

    extends Object
    implements Element
    java.lang.Object
       ↳ com.google.inject.spi.InterceptorBinding

    Class Overview

    Registration of interceptors for matching methods of matching classes. Instances are created explicitly in a module using bindInterceptor() statements:

         bindInterceptor(Matchers.subclassesOf(MyAction.class),
             Matchers.annotatedWith(Transactional.class),
             new MyTransactionInterceptor());
    or from an injectable type listener using TypeEncounter.bindInterceptor().

    Summary

    Public Methods
    <T> T acceptVisitor(ElementVisitor<T> visitor)
    Accepts an element visitor.
    void applyTo(Binder binder)
    Writes this module element to the given binder (optional operation).
    Matcher<? super Class<?>> getClassMatcher()
    List<MethodInterceptor> getInterceptors()
    Matcher<? super Method> getMethodMatcher()
    Object getSource()
    Returns an arbitrary object containing information about the "place" where this element was configured.
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.Element

    Public Methods

    public T acceptVisitor (ElementVisitor<T> visitor)

    Accepts an element visitor. Invokes the visitor method specific to this element's type.

    Parameters
    visitor to call back on

    public void applyTo (Binder binder)

    Writes this module element to the given binder (optional operation).

    Parameters
    binder to apply configuration element to

    public Matcher<? super Class<?>> getClassMatcher ()

    public List<MethodInterceptor> getInterceptors ()

    public Matcher<? super Method> getMethodMatcher ()

    public Object getSource ()

    Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

    Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/InstanceBinding.html0000755000175000017500000006547211704661106026070 0ustar tonytony InstanceBinding | Guice
    public interface

    InstanceBinding

    implements Binding<T> HasDependencies
    com.google.inject.spi.InstanceBinding<T>

    Class Overview

    A binding to a single instance. The same instance is returned for every injection.

    Summary

    Public Methods
    abstract Set<InjectionPoint> getInjectionPoints()
    Returns the field and method injection points of the instance, injected at injector-creation time only.
    abstract T getInstance()
    Returns the user-supplied instance.
    [Expand]
    Inherited Methods
    From interface com.google.inject.Binding
    From interface com.google.inject.spi.Element
    From interface com.google.inject.spi.HasDependencies

    Public Methods

    public abstract Set<InjectionPoint> getInjectionPoints ()

    Returns the field and method injection points of the instance, injected at injector-creation time only.

    Returns
    • a possibly empty set

    public abstract T getInstance ()

    Returns the user-supplied instance.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/InjectionRequest.html0000755000175000017500000010461411704661106026314 0ustar tonytony InjectionRequest | Guice
    public final class

    InjectionRequest

    extends Object
    implements Element
    java.lang.Object
       ↳ com.google.inject.spi.InjectionRequest<T>

    Class Overview

    A request to inject the instance fields and methods of an instance. Requests are created explicitly in a module using requestInjection() statements:

         requestInjection(serviceInstance);

    Summary

    Public Constructors
    InjectionRequest(Object source, TypeLiteral<T> type, T instance)
    Public Methods
    <R> R acceptVisitor(ElementVisitor<R> visitor)
    void applyTo(Binder binder)
    Writes this module element to the given binder (optional operation).
    Set<InjectionPoint> getInjectionPoints()
    Returns the instance methods and fields of instance that will be injected to fulfill this request.
    T getInstance()
    Object getSource()
    Returns an arbitrary object containing information about the "place" where this element was configured.
    TypeLiteral<T> getType()
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.Element

    Public Constructors

    public InjectionRequest (Object source, TypeLiteral<T> type, T instance)

    Public Methods

    public R acceptVisitor (ElementVisitor<R> visitor)

    public void applyTo (Binder binder)

    Writes this module element to the given binder (optional operation).

    Parameters
    binder to apply configuration element to

    public Set<InjectionPoint> getInjectionPoints ()

    Returns the instance methods and fields of instance that will be injected to fulfill this request.

    Returns
    • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
    Throws
    ConfigurationException if there is a malformed injection point on the class of instance, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

    public T getInstance ()

    public Object getSource ()

    Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

    Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

    public TypeLiteral<T> getType ()

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/InjectionPoint.html0000755000175000017500000014436111704661106025760 0ustar tonytony InjectionPoint | Guice
    public final class

    InjectionPoint

    extends Object
    java.lang.Object
       ↳ com.google.inject.spi.InjectionPoint

    Class Overview

    A constructor, field or method that can receive injections. Typically this is a member with the @Inject annotation. For non-private, no argument constructors, the member may omit the annotation.

    Summary

    Public Methods
    boolean equals(Object o)
    static <T> InjectionPoint forConstructor(Constructor<T> constructor)
    Returns a new injection point for the specified constructor.
    static <T> InjectionPoint forConstructor(Constructor<T> constructor, TypeLiteral<? extends T> type)
    Returns a new injection point for the specified constructor of type.
    static InjectionPoint forConstructorOf(TypeLiteral<?> type)
    Returns a new injection point for the injectable constructor of type.
    static InjectionPoint forConstructorOf(Class<?> type)
    Returns a new injection point for the injectable constructor of type.
    static Set<InjectionPoint> forInstanceMethodsAndFields(TypeLiteral<?> type)
    Returns all instance method and field injection points on type.
    static Set<InjectionPoint> forInstanceMethodsAndFields(Class<?> type)
    Returns all instance method and field injection points on type.
    static Set<InjectionPoint> forStaticMethodsAndFields(TypeLiteral<?> type)
    Returns all static method and field injection points on type.
    static Set<InjectionPoint> forStaticMethodsAndFields(Class<?> type)
    Returns all static method and field injection points on type.
    TypeLiteral<?> getDeclaringType()
    Returns the generic type that defines this injection point.
    List<Dependency<?>> getDependencies()
    Returns the dependencies for this injection point.
    Member getMember()
    Returns the injected constructor, field, or method.
    int hashCode()
    boolean isOptional()
    Returns true if this injection point shall be skipped if the injector cannot resolve bindings for all required dependencies.
    boolean isToolable()
    Returns true if the element is annotated with @Toolable.
    String toString()
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Methods

    public boolean equals (Object o)

    Since: API Level

    public static InjectionPoint forConstructor (Constructor<T> constructor)

    Returns a new injection point for the specified constructor. If the declaring type of constructor is parameterized (such as List<T>), prefer the overload that includes a type literal.

    Parameters
    constructor any single constructor present on type.

    public static InjectionPoint forConstructor (Constructor<T> constructor, TypeLiteral<? extends T> type)

    Returns a new injection point for the specified constructor of type.

    Parameters
    constructor any single constructor present on type.
    type the concrete type that defines constructor.

    public static InjectionPoint forConstructorOf (TypeLiteral<?> type)

    Returns a new injection point for the injectable constructor of type.

    Parameters
    type a concrete type with exactly one constructor annotated @Inject, or a no-arguments constructor that is not private.
    Throws
    ConfigurationException if there is no injectable constructor, more than one injectable constructor, or if parameters of the injectable constructor are malformed, such as a parameter with multiple binding annotations.

    public static InjectionPoint forConstructorOf (Class<?> type)

    Returns a new injection point for the injectable constructor of type.

    Parameters
    type a concrete type with exactly one constructor annotated @Inject, or a no-arguments constructor that is not private.
    Throws
    ConfigurationException if there is no injectable constructor, more than one injectable constructor, or if parameters of the injectable constructor are malformed, such as a parameter with multiple binding annotations.

    public static Set<InjectionPoint> forInstanceMethodsAndFields (TypeLiteral<?> type)

    Returns all instance method and field injection points on type.

    Returns
    • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
    Throws
    ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

    public static Set<InjectionPoint> forInstanceMethodsAndFields (Class<?> type)

    Returns all instance method and field injection points on type.

    Returns
    • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
    Throws
    ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

    public static Set<InjectionPoint> forStaticMethodsAndFields (TypeLiteral<?> type)

    Returns all static method and field injection points on type.

    Returns
    • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
    Throws
    ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

    public static Set<InjectionPoint> forStaticMethodsAndFields (Class<?> type)

    Returns all static method and field injection points on type.

    Returns
    • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.
    Throws
    ConfigurationException if there is a malformed injection point on type, such as a field with multiple binding annotations. The exception's partial value is a Set<InjectionPoint> of the valid injection points.

    public TypeLiteral<?> getDeclaringType ()

    Returns the generic type that defines this injection point. If the member exists on a parameterized type, the result will include more type information than the member's raw declaring class.

    public List<Dependency<?>> getDependencies ()

    Returns the dependencies for this injection point. If the injection point is for a method or constructor, the dependencies will correspond to that member's parameters. Field injection points always have a single dependency for the field itself.

    Returns
    • a possibly-empty list

    public Member getMember ()

    Returns the injected constructor, field, or method.

    public int hashCode ()

    Since: API Level

    public boolean isOptional ()

    Returns true if this injection point shall be skipped if the injector cannot resolve bindings for all required dependencies. Both explicit bindings (as specified in a module), and implicit bindings (@ImplementedBy, default constructors etc.) may be used to satisfy optional injection points.

    public boolean isToolable ()

    Returns true if the element is annotated with @Toolable.

    public String toString ()

    Since: API Level

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/InjectionListener.html0000755000175000017500000004323411704661106026451 0ustar tonytony InjectionListener | Guice
    public interface

    InjectionListener

    com.google.inject.spi.InjectionListener<I>

    Class Overview

    Listens for injections into instances of type I. Useful for performing further injections, post-injection initialization, and more.

    Summary

    Public Methods
    abstract void afterInjection(I injectee)
    Invoked by Guice after it injects the fields and methods of instance.

    Public Methods

    public abstract void afterInjection (I injectee)

    Invoked by Guice after it injects the fields and methods of instance.

    Parameters
    injectee instance that Guice injected dependencies into
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/HasDependencies.html0000755000175000017500000005420211704661106026040 0ustar tonytony HasDependencies | Guice
    public interface

    HasDependencies

    com.google.inject.spi.HasDependencies
    Known Indirect Subclasses

    Class Overview

    Implemented by bindings, providers and instances that expose their dependencies explicitly.

    Summary

    Public Methods
    abstract Set<Dependency<?>> getDependencies()
    Returns the known dependencies for this type.

    Public Methods

    public abstract Set<Dependency<?>> getDependencies ()

    Returns the known dependencies for this type. If this has dependencies whose values are not known statically, a dependency for the Injector will be included in the returned set.

    Returns
    • a possibly empty set
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/ExposedBinding.html0000755000175000017500000006572411704661106025733 0ustar tonytony ExposedBinding | Guice
    public interface

    ExposedBinding

    implements Binding<T> HasDependencies
    com.google.inject.spi.ExposedBinding<T>

    Class Overview

    A binding to a key exposed from an enclosed private environment.

    Summary

    Public Methods
    abstract void applyTo(Binder binder)
    Unsupported.
    abstract PrivateElements getPrivateElements()
    Returns the enclosed environment that holds the original binding.
    [Expand]
    Inherited Methods
    From interface com.google.inject.Binding
    From interface com.google.inject.spi.Element
    From interface com.google.inject.spi.HasDependencies

    Public Methods

    public abstract void applyTo (Binder binder)

    Unsupported. Always throws UnsupportedOperationException.

    Parameters
    binder to apply configuration element to

    public abstract PrivateElements getPrivateElements ()

    Returns the enclosed environment that holds the original binding.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/Elements.html0000755000175000017500000007463611704661106024607 0ustar tonytony Elements | Guice
    public final class

    Elements

    extends Object
    java.lang.Object
       ↳ com.google.inject.spi.Elements

    Class Overview

    Exposes elements of a module so they can be inspected, validated or rewritten.

    Summary

    Public Constructors
    Elements()
    Public Methods
    static List<Element> getElements(Module... modules)
    Records the elements executed by modules.
    static List<Element> getElements(Stage stage, Module... modules)
    Records the elements executed by modules.
    static List<Element> getElements(Stage stage, Iterable<? extends Module> modules)
    Records the elements executed by modules.
    static List<Element> getElements(Iterable<? extends Module> modules)
    Records the elements executed by modules.
    static Module getModule(Iterable<? extends Element> elements)
    Returns the module composed of elements.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Constructors

    public Elements ()

    Public Methods

    public static List<Element> getElements (Module... modules)

    Records the elements executed by modules.

    public static List<Element> getElements (Stage stage, Module... modules)

    Records the elements executed by modules.

    public static List<Element> getElements (Stage stage, Iterable<? extends Module> modules)

    Records the elements executed by modules.

    public static List<Element> getElements (Iterable<? extends Module> modules)

    Records the elements executed by modules.

    public static Module getModule (Iterable<? extends Element> elements)

    Returns the module composed of elements.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/ElementVisitor.html0000755000175000017500000010777511704661106026005 0ustar tonytony ElementVisitor | Guice
    public interface

    ElementVisitor

    com.google.inject.spi.ElementVisitor<V>
    Known Indirect Subclasses

    Class Overview

    Visit elements.

    Summary

    Public Methods
    abstract <T> V visit(Binding<T> binding)
    Visit a mapping from a key (type and optional annotation) to the strategy for getting instances of the type.
    abstract V visit(DisableCircularProxiesOption option)
    Visit a disable circular proxies command.
    abstract V visit(InjectionRequest<?> request)
    Visit a request to inject the instance fields and methods of an instance.
    abstract V visit(InterceptorBinding binding)
    Visit a registration of interceptors for matching methods of matching classes.
    abstract <T> V visit(MembersInjectorLookup<T> lookup)
    Visit a lookup of the members injector.
    abstract V visit(Message message)
    Visit an error message and the context in which it occured.
    abstract V visit(PrivateElements elements)
    Visit a collection of configuration elements for a private binder.
    abstract <T> V visit(ProviderLookup<T> lookup)
    Visit a lookup of the provider for a type.
    abstract V visit(RequireExplicitBindingsOption option)
    Visit a require explicit bindings command.
    abstract V visit(ScopeBinding binding)
    Visit a registration of a scope annotation with the scope that implements it.
    abstract V visit(StaticInjectionRequest request)
    Visit a request to inject the static fields and methods of type.
    abstract V visit(TypeConverterBinding binding)
    Visit a registration of type converters for matching target types.
    abstract V visit(TypeListenerBinding binding)
    Visit an injectable type listener binding.

    Public Methods

    public abstract V visit (Binding<T> binding)

    Visit a mapping from a key (type and optional annotation) to the strategy for getting instances of the type.

    public abstract V visit (DisableCircularProxiesOption option)

    Visit a disable circular proxies command.

    public abstract V visit (InjectionRequest<?> request)

    Visit a request to inject the instance fields and methods of an instance.

    public abstract V visit (InterceptorBinding binding)

    Visit a registration of interceptors for matching methods of matching classes.

    public abstract V visit (MembersInjectorLookup<T> lookup)

    Visit a lookup of the members injector.

    public abstract V visit (Message message)

    Visit an error message and the context in which it occured.

    public abstract V visit (PrivateElements elements)

    Visit a collection of configuration elements for a private binder.

    public abstract V visit (ProviderLookup<T> lookup)

    Visit a lookup of the provider for a type.

    public abstract V visit (RequireExplicitBindingsOption option)

    Visit a require explicit bindings command.

    public abstract V visit (ScopeBinding binding)

    Visit a registration of a scope annotation with the scope that implements it.

    public abstract V visit (StaticInjectionRequest request)

    Visit a request to inject the static fields and methods of type.

    public abstract V visit (TypeConverterBinding binding)

    Visit a registration of type converters for matching target types.

    public abstract V visit (TypeListenerBinding binding)

    Visit an injectable type listener binding.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/Element.html0000755000175000017500000010103711704661106024406 0ustar tonytony Element | Guice
    public interface

    Element

    com.google.inject.spi.Element
    Known Indirect Subclasses

    Class Overview

    A core component of a module or injector.

    The elements of a module can be inspected, validated and rewritten. Use Elements.getElements() to read the elements from a module, and Elements.getModule() to rewrite them. This can be used for static analysis and generation of Guice modules.

    The elements of an injector can be inspected and exercised. Use Injector.getBindings() to reflect on Guice injectors.

    Summary

    Public Methods
    abstract <T> T acceptVisitor(ElementVisitor<T> visitor)
    Accepts an element visitor.
    abstract void applyTo(Binder binder)
    Writes this module element to the given binder (optional operation).
    abstract Object getSource()
    Returns an arbitrary object containing information about the "place" where this element was configured.

    Public Methods

    public abstract T acceptVisitor (ElementVisitor<T> visitor)

    Accepts an element visitor. Invokes the visitor method specific to this element's type.

    Parameters
    visitor to call back on

    public abstract void applyTo (Binder binder)

    Writes this module element to the given binder (optional operation).

    Parameters
    binder to apply configuration element to
    Throws
    UnsupportedOperationException if the applyTo method is not supported by this element.

    public abstract Object getSource ()

    Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

    Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/DisableCircularProxiesOption.html0000755000175000017500000007057111704661106030620 0ustar tonytony DisableCircularProxiesOption | Guice
    public final class

    DisableCircularProxiesOption

    extends Object
    implements Element
    java.lang.Object
       ↳ com.google.inject.spi.DisableCircularProxiesOption

    Class Overview

    A request to disable circular proxies.

    Summary

    Public Methods
    <T> T acceptVisitor(ElementVisitor<T> visitor)
    Accepts an element visitor.
    void applyTo(Binder binder)
    Writes this module element to the given binder (optional operation).
    Object getSource()
    Returns an arbitrary object containing information about the "place" where this element was configured.
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.Element

    Public Methods

    public T acceptVisitor (ElementVisitor<T> visitor)

    Accepts an element visitor. Invokes the visitor method specific to this element's type.

    Parameters
    visitor to call back on

    public void applyTo (Binder binder)

    Writes this module element to the given binder (optional operation).

    Parameters
    binder to apply configuration element to

    public Object getSource ()

    Returns an arbitrary object containing information about the "place" where this element was configured. Used by Guice in the production of descriptive error messages.

    Tools might specially handle types they know about; StackTraceElement is a good example. Tools should simply call toString() on the source object if the type is unfamiliar.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/Dependency.html0000755000175000017500000010112511704661106025071 0ustar tonytony Dependency | Guice
    public final class

    Dependency

    extends Object
    java.lang.Object
       ↳ com.google.inject.spi.Dependency<T>

    Class Overview

    A variable that can be resolved by an injector.

    Use get(Key) to build a freestanding dependency, or InjectionPoint to build one that's attached to a constructor, method or field.

    Summary

    Public Methods
    boolean equals(Object o)
    static Set<Dependency<?>> forInjectionPoints(Set<InjectionPoint> injectionPoints)
    Returns the dependencies from the given injection points.
    static <T> Dependency<T> get(Key<T> key)
    Returns a new dependency that is not attached to an injection point.
    InjectionPoint getInjectionPoint()
    Returns the injection point to which this dependency belongs, or null if this dependency isn't attached to a particular injection point.
    Key<T> getKey()
    Returns the key to the binding that satisfies this dependency.
    int getParameterIndex()
    Returns the index of this dependency in the injection point's parameter list, or -1 if this dependency does not belong to a parameter list.
    int hashCode()
    boolean isNullable()
    Returns true if null is a legal value for this dependency.
    String toString()
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Methods

    public boolean equals (Object o)

    Since: API Level

    public static Set<Dependency<?>> forInjectionPoints (Set<InjectionPoint> injectionPoints)

    Returns the dependencies from the given injection points.

    public static Dependency<T> get (Key<T> key)

    Returns a new dependency that is not attached to an injection point. The returned dependency is nullable.

    public InjectionPoint getInjectionPoint ()

    Returns the injection point to which this dependency belongs, or null if this dependency isn't attached to a particular injection point.

    public Key<T> getKey ()

    Returns the key to the binding that satisfies this dependency.

    public int getParameterIndex ()

    Returns the index of this dependency in the injection point's parameter list, or -1 if this dependency does not belong to a parameter list. Only method and constuctor dependencies are elements in a parameter list.

    public int hashCode ()

    Since: API Level

    public boolean isNullable ()

    Returns true if null is a legal value for this dependency.

    public String toString ()

    Since: API Level

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/DefaultElementVisitor.html0000755000175000017500000014753711704661106027312 0ustar tonytony DefaultElementVisitor | Guice
    public abstract class

    DefaultElementVisitor

    extends Object
    implements ElementVisitor<V>
    java.lang.Object
       ↳ com.google.inject.spi.DefaultElementVisitor<V>

    Class Overview

    No-op visitor for subclassing. All interface methods simply delegate to visitOther(Element), returning its result.

    Summary

    Public Constructors
    DefaultElementVisitor()
    Public Methods
    <T> V visit(Binding<T> binding)
    Visit a mapping from a key (type and optional annotation) to the strategy for getting instances of the type.
    V visit(DisableCircularProxiesOption option)
    Visit a disable circular proxies command.
    V visit(InjectionRequest<?> injectionRequest)
    Visit a request to inject the instance fields and methods of an instance.
    V visit(InterceptorBinding interceptorBinding)
    Visit a registration of interceptors for matching methods of matching classes.
    <T> V visit(MembersInjectorLookup<T> lookup)
    Visit a lookup of the members injector.
    V visit(Message message)
    Visit an error message and the context in which it occured.
    V visit(PrivateElements privateElements)
    Visit a collection of configuration elements for a private binder.
    <T> V visit(ProviderLookup<T> providerLookup)
    Visit a lookup of the provider for a type.
    V visit(RequireExplicitBindingsOption option)
    Visit a require explicit bindings command.
    V visit(ScopeBinding scopeBinding)
    Visit a registration of a scope annotation with the scope that implements it.
    V visit(StaticInjectionRequest staticInjectionRequest)
    Visit a request to inject the static fields and methods of type.
    V visit(TypeConverterBinding typeConverterBinding)
    Visit a registration of type converters for matching target types.
    V visit(TypeListenerBinding binding)
    Visit an injectable type listener binding.
    Protected Methods
    V visitOther(Element element)
    Default visit implementation.
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.ElementVisitor

    Public Constructors

    public DefaultElementVisitor ()

    Public Methods

    public V visit (Binding<T> binding)

    Visit a mapping from a key (type and optional annotation) to the strategy for getting instances of the type.

    public V visit (DisableCircularProxiesOption option)

    Visit a disable circular proxies command.

    public V visit (InjectionRequest<?> injectionRequest)

    Visit a request to inject the instance fields and methods of an instance.

    public V visit (InterceptorBinding interceptorBinding)

    Visit a registration of interceptors for matching methods of matching classes.

    public V visit (MembersInjectorLookup<T> lookup)

    Visit a lookup of the members injector.

    public V visit (Message message)

    Visit an error message and the context in which it occured.

    public V visit (PrivateElements privateElements)

    Visit a collection of configuration elements for a private binder.

    public V visit (ProviderLookup<T> providerLookup)

    Visit a lookup of the provider for a type.

    public V visit (RequireExplicitBindingsOption option)

    Visit a require explicit bindings command.

    public V visit (ScopeBinding scopeBinding)

    Visit a registration of a scope annotation with the scope that implements it.

    public V visit (StaticInjectionRequest staticInjectionRequest)

    Visit a request to inject the static fields and methods of type.

    public V visit (TypeConverterBinding typeConverterBinding)

    Visit a registration of type converters for matching target types.

    public V visit (TypeListenerBinding binding)

    Visit an injectable type listener binding.

    Protected Methods

    protected V visitOther (Element element)

    Default visit implementation. Returns null.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/DefaultBindingTargetVisitor.html0000755000175000017500000013320611704661106030426 0ustar tonytony DefaultBindingTargetVisitor | Guice
    public abstract class

    DefaultBindingTargetVisitor

    extends Object
    implements BindingTargetVisitor<T, V>
    java.lang.Object
       ↳ com.google.inject.spi.DefaultBindingTargetVisitor<T, V>

    Class Overview

    No-op visitor for subclassing. All interface methods simply delegate to visitOther(Binding), returning its result.

    Summary

    Public Constructors
    DefaultBindingTargetVisitor()
    Public Methods
    V visit(ConstructorBinding<? extends T> constructorBinding)
    Visit a constructor binding.
    V visit(ConvertedConstantBinding<? extends T> convertedConstantBinding)
    Visit a binding created from converting a bound instance to a new type.
    V visit(ExposedBinding<? extends T> exposedBinding)
    Visit a binding to a key exposed from an enclosed private environment.
    V visit(InstanceBinding<? extends T> instanceBinding)
    Visit a instance binding.
    V visit(LinkedKeyBinding<? extends T> linkedKeyBinding)
    Visit a linked key binding.
    V visit(ProviderBinding<? extends T> providerBinding)
    Visit a binding to a Provider that delegates to the binding for the provided type.
    V visit(ProviderInstanceBinding<? extends T> providerInstanceBinding)
    Visit a provider instance binding.
    V visit(ProviderKeyBinding<? extends T> providerKeyBinding)
    Visit a provider key binding.
    V visit(UntargettedBinding<? extends T> untargettedBinding)
    Visit an untargetted binding.
    Protected Methods
    V visitOther(Binding<? extends T> binding)
    Default visit implementation.
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.BindingTargetVisitor

    Public Constructors

    public DefaultBindingTargetVisitor ()

    Public Methods

    public V visit (ConstructorBinding<? extends T> constructorBinding)

    Visit a constructor binding. To resolve injections, an instance is instantiated by invoking constructor. This target is found only on injector bindings.

    public V visit (ConvertedConstantBinding<? extends T> convertedConstantBinding)

    Visit a binding created from converting a bound instance to a new type. The source binding has the same binding annotation but a different type. This target is found only on injector bindings.

    public V visit (ExposedBinding<? extends T> exposedBinding)

    Visit a binding to a key exposed from an enclosed private environment. This target is only found in injector bindings.

    public V visit (InstanceBinding<? extends T> instanceBinding)

    Visit a instance binding. The same instance is returned for every injection. This target is found in both module and injector bindings.

    public V visit (LinkedKeyBinding<? extends T> linkedKeyBinding)

    Visit a linked key binding. The other key's binding is used to resolve injections. This target is found in both module and injector bindings.

    public V visit (ProviderBinding<? extends T> providerBinding)

    Visit a binding to a Provider that delegates to the binding for the provided type. This target is found only on injector bindings.

    public V visit (ProviderInstanceBinding<? extends T> providerInstanceBinding)

    Visit a provider instance binding. The provider's get method is invoked to resolve injections. This target is found in both module and injector bindings.

    public V visit (ProviderKeyBinding<? extends T> providerKeyBinding)

    Visit a provider key binding. To resolve injections, the provider key is first resolved, then that provider's get method is invoked. This target is found in both module and injector bindings.

    public V visit (UntargettedBinding<? extends T> untargettedBinding)

    Visit an untargetted binding. This target is found only on module bindings. It indicates that the injector should use its implicit binding strategies to resolve injections.

    Protected Methods

    protected V visitOther (Binding<? extends T> binding)

    Default visit implementation. Returns null.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/DefaultBindingScopingVisitor.html0000755000175000017500000010123411704661106030576 0ustar tonytony DefaultBindingScopingVisitor | Guice
    public class

    DefaultBindingScopingVisitor

    extends Object
    implements BindingScopingVisitor<V>
    java.lang.Object
       ↳ com.google.inject.spi.DefaultBindingScopingVisitor<V>

    Class Overview

    No-op visitor for subclassing. All interface methods simply delegate to visitOther(), returning its result.

    Summary

    Public Constructors
    DefaultBindingScopingVisitor()
    Public Methods
    V visitEagerSingleton()
    Visit an eager singleton or single instance.
    V visitNoScoping()
    Visit an unspecified or unscoped strategy.
    V visitScope(Scope scope)
    Visit a scope instance.
    V visitScopeAnnotation(Class<? extends Annotation> scopeAnnotation)
    Visit a scope annotation.
    Protected Methods
    V visitOther()
    Default visit implementation.
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.BindingScopingVisitor

    Public Constructors

    public DefaultBindingScopingVisitor ()

    Public Methods

    public V visitEagerSingleton ()

    Visit an eager singleton or single instance. This scope strategy is found on both module and injector bindings.

    public V visitNoScoping ()

    Visit an unspecified or unscoped strategy. On a module, this strategy indicates that the injector should use scoping annotations to find a scope. On an injector, it indicates that no scope is applied to the binding. An unscoped binding will behave like a scoped one when it is linked to a scoped binding.

    public V visitScope (Scope scope)

    Visit a scope instance. This scope strategy is found on both module and injector bindings.

    public V visitScopeAnnotation (Class<? extends Annotation> scopeAnnotation)

    Visit a scope annotation. This scope strategy is found only on module bindings. The instance that implements this scope is registered by Binder.bindScope().

    Protected Methods

    protected V visitOther ()

    Default visit implementation. Returns null.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/ConvertedConstantBinding.html0000755000175000017500000007322211704661106027757 0ustar tonytony ConvertedConstantBinding | Guice
    public interface

    ConvertedConstantBinding

    implements Binding<T> HasDependencies
    com.google.inject.spi.ConvertedConstantBinding<T>

    Class Overview

    A binding created from converting a bound instance to a new type. The source binding has the same binding annotation but a different type.

    Summary

    Public Methods
    abstract Set<Dependency<?>> getDependencies()
    Returns a singleton set containing only the converted key.
    abstract Key<String> getSourceKey()
    Returns the key for the source binding.
    abstract TypeConverterBinding getTypeConverterBinding()
    Returns the type converter binding used to convert the constant.
    abstract T getValue()
    Returns the converted value.
    [Expand]
    Inherited Methods
    From interface com.google.inject.Binding
    From interface com.google.inject.spi.Element
    From interface com.google.inject.spi.HasDependencies

    Public Methods

    public abstract Set<Dependency<?>> getDependencies ()

    Returns a singleton set containing only the converted key.

    Returns
    • a possibly empty set

    public abstract Key<String> getSourceKey ()

    Returns the key for the source binding. That binding can e retrieved from an injector using Injector.getBinding(key).

    public abstract TypeConverterBinding getTypeConverterBinding ()

    Returns the type converter binding used to convert the constant.

    public abstract T getValue ()

    Returns the converted value.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/ConstructorBinding.html0000755000175000017500000007141011704661106026636 0ustar tonytony ConstructorBinding | Guice
    public interface

    ConstructorBinding

    implements Binding<T> HasDependencies
    com.google.inject.spi.ConstructorBinding<T>

    Class Overview

    A binding to the constructor of a concrete clss. To resolve injections, an instance is instantiated by invoking the constructor.

    Summary

    Public Methods
    abstract InjectionPoint getConstructor()
    Gets the constructor this binding injects.
    abstract Set<InjectionPoint> getInjectableMembers()
    Returns all instance method and field injection points on type.
    abstract Map<Method, List<MethodInterceptor>> getMethodInterceptors()
    Returns the interceptors applied to each method, in the order that they will be applied.
    [Expand]
    Inherited Methods
    From interface com.google.inject.Binding
    From interface com.google.inject.spi.Element
    From interface com.google.inject.spi.HasDependencies

    Public Methods

    public abstract InjectionPoint getConstructor ()

    Gets the constructor this binding injects.

    public abstract Set<InjectionPoint> getInjectableMembers ()

    Returns all instance method and field injection points on type.

    Returns
    • a possibly empty set of injection points. The set has a specified iteration order. All fields are returned and then all methods. Within the fields, supertype fields are returned before subtype fields. Similarly, supertype methods are returned before subtype methods.

    public abstract Map<Method, List<MethodInterceptor>> getMethodInterceptors ()

    Returns the interceptors applied to each method, in the order that they will be applied.

    Returns
    • a possibly empty map
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/BindingTargetVisitor.html0000755000175000017500000010716111704661106027122 0ustar tonytony BindingTargetVisitor | Guice
    public interface

    BindingTargetVisitor

    com.google.inject.spi.BindingTargetVisitor<T, V>
    Known Indirect Subclasses

    Class Overview

    Visits each of the strategies used to find an instance to satisfy an injection.

    Summary

    Public Methods
    abstract V visit(ConstructorBinding<? extends T> binding)
    Visit a constructor binding.
    abstract V visit(ConvertedConstantBinding<? extends T> binding)
    Visit a binding created from converting a bound instance to a new type.
    abstract V visit(ExposedBinding<? extends T> binding)
    Visit a binding to a key exposed from an enclosed private environment.
    abstract V visit(InstanceBinding<? extends T> binding)
    Visit a instance binding.
    abstract V visit(LinkedKeyBinding<? extends T> binding)
    Visit a linked key binding.
    abstract V visit(ProviderBinding<? extends T> binding)
    Visit a binding to a Provider that delegates to the binding for the provided type.
    abstract V visit(ProviderInstanceBinding<? extends T> binding)
    Visit a provider instance binding.
    abstract V visit(ProviderKeyBinding<? extends T> binding)
    Visit a provider key binding.
    abstract V visit(UntargettedBinding<? extends T> binding)
    Visit an untargetted binding.

    Public Methods

    public abstract V visit (ConstructorBinding<? extends T> binding)

    Visit a constructor binding. To resolve injections, an instance is instantiated by invoking constructor. This target is found only on injector bindings.

    public abstract V visit (ConvertedConstantBinding<? extends T> binding)

    Visit a binding created from converting a bound instance to a new type. The source binding has the same binding annotation but a different type. This target is found only on injector bindings.

    public abstract V visit (ExposedBinding<? extends T> binding)

    Visit a binding to a key exposed from an enclosed private environment. This target is only found in injector bindings.

    public abstract V visit (InstanceBinding<? extends T> binding)

    Visit a instance binding. The same instance is returned for every injection. This target is found in both module and injector bindings.

    public abstract V visit (LinkedKeyBinding<? extends T> binding)

    Visit a linked key binding. The other key's binding is used to resolve injections. This target is found in both module and injector bindings.

    public abstract V visit (ProviderBinding<? extends T> binding)

    Visit a binding to a Provider that delegates to the binding for the provided type. This target is found only on injector bindings.

    public abstract V visit (ProviderInstanceBinding<? extends T> binding)

    Visit a provider instance binding. The provider's get method is invoked to resolve injections. This target is found in both module and injector bindings.

    public abstract V visit (ProviderKeyBinding<? extends T> binding)

    Visit a provider key binding. To resolve injections, the provider key is first resolved, then that provider's get method is invoked. This target is found in both module and injector bindings.

    public abstract V visit (UntargettedBinding<? extends T> binding)

    Visit an untargetted binding. This target is found only on module bindings. It indicates that the injector should use its implicit binding strategies to resolve injections.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/spi/BindingScopingVisitor.html0000755000175000017500000005623211704661106027300 0ustar tonytony BindingScopingVisitor | Guice
    public interface

    BindingScopingVisitor

    com.google.inject.spi.BindingScopingVisitor<V>
    Known Indirect Subclasses

    Class Overview

    Visits each of the strategies used to scope an injection.

    Summary

    Public Methods
    abstract V visitEagerSingleton()
    Visit an eager singleton or single instance.
    abstract V visitNoScoping()
    Visit an unspecified or unscoped strategy.
    abstract V visitScope(Scope scope)
    Visit a scope instance.
    abstract V visitScopeAnnotation(Class<? extends Annotation> scopeAnnotation)
    Visit a scope annotation.

    Public Methods

    public abstract V visitEagerSingleton ()

    Visit an eager singleton or single instance. This scope strategy is found on both module and injector bindings.

    public abstract V visitNoScoping ()

    Visit an unspecified or unscoped strategy. On a module, this strategy indicates that the injector should use scoping annotations to find a scope. On an injector, it indicates that no scope is applied to the binding. An unscoped binding will behave like a scoped one when it is linked to a scoped binding.

    public abstract V visitScope (Scope scope)

    Visit a scope instance. This scope strategy is found on both module and injector bindings.

    public abstract V visitScopeAnnotation (Class<? extends Annotation> scopeAnnotation)

    Visit a scope annotation. This scope strategy is found only on module bindings. The instance that implements this scope is registered by Binder.bindScope().

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/0000755000175000017500000000000011704661106023013 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/package-summary.html0000755000175000017500000004165311704661106027003 0ustar tonytony com.google.inject.servlet | Guice
    package

    com.google.inject.servlet

    Classes | Description

    Servlet API scopes, bindings and registration; this extension requires guice-servlet-3.0.jar.

    more...

    Interfaces

    InstanceFilterBinding A binding to a single instance of a filter. 
    InstanceServletBinding A binding to a single instance of a servlet. 
    LinkedFilterBinding A linked binding to a filter. 
    LinkedServletBinding A linked binding to a servlet. 
    ServletModule.FilterKeyBindingBuilder See the EDSL examples at configureServlets() 
    ServletModule.ServletKeyBindingBuilder See the EDSL examples at configureServlets() 
    ServletModuleBinding A binding created by ServletModule
    ServletModuleTargetVisitor<T, V> A visitor for the servlet extension. 

    Classes

    GuiceFilter

    Apply this filter in web.xml above all other filters (typically), to all requests where you plan to use servlet scopes. 

    GuiceServletContextListener As of Guice 2.0 you can still use (your subclasses of) GuiceServletContextListener class as a logical place to create and configure your injector. 
    ServletModule Configures the servlet scopes and creates bindings for the servlet API objects so you can inject the request, response, session, etc. 
    ServletScopes Servlet scopes. 

    Enums

    UriPatternType An enumeration of the available URI-pattern matching styles 
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/package-descr.html0000755000175000017500000003041611704661106026401 0ustar tonytony com.google.inject.servlet Details | Guice
    package

    com.google.inject.servlet

    Classes | Description

    Servlet API scopes, bindings and registration; this extension requires guice-servlet-3.0.jar.

    Apply GuiceFilter to any servlets which will use the servlet scopes. Install ServletModule into your Injector to install everything at once.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/UriPatternType.html0000755000175000017500000006720411704661106026654 0ustar tonytony UriPatternType | Guice
    public final enum

    UriPatternType

    extends Enum<E extends Enum<E>>
    java.lang.Object
       ↳ java.lang.Enum<E extends java.lang.Enum<E>>
         ↳ com.google.inject.servlet.UriPatternType

    Class Overview

    An enumeration of the available URI-pattern matching styles

    Summary

    Enum Values
    UriPatternType  REGEX   
    UriPatternType  SERVLET   
    Public Methods
    static UriPatternType valueOf(String name)
    final static UriPatternType[] values()
    [Expand]
    Inherited Methods
    From class java.lang.Enum
    From class java.lang.Object
    From interface java.lang.Comparable

    Enum Values

    public static final UriPatternType REGEX

    Since: API Level

    public static final UriPatternType SERVLET

    Since: API Level

    Public Methods

    public static UriPatternType valueOf (String name)

    public static final UriPatternType[] values ()

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/SessionScoped.html0000755000175000017500000003677011704661106026502 0ustar tonytony SessionScoped | Guice
    public abstract @interface

    SessionScoped

    implements Annotation
    com.google.inject.servlet.SessionScoped

    Class Overview

    Apply this to implementation classes when you want one instance per session.

    See Also

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/ServletScopes.html0000755000175000017500000006341011704661106026511 0ustar tonytony ServletScopes | Guice
    public class

    ServletScopes

    extends Object
    java.lang.Object
       ↳ com.google.inject.servlet.ServletScopes

    Class Overview

    Servlet scopes.

    Summary

    Constants
    Scope REQUEST HTTP servlet request scope.
    Scope SESSION HTTP session scope.
    Public Methods
    static <T> Callable<T> continueRequest(Callable<T> callable, Map<Key<?>, Object> seedMap)
    Wraps the given callable in a contextual callable that "continues" the HTTP request in another thread.
    static <T> Callable<T> scopeRequest(Callable<T> callable, Map<Key<?>, Object> seedMap)
    Scopes the given callable inside a request scope.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Constants

    public static final Scope REQUEST

    HTTP servlet request scope.

    public static final Scope SESSION

    HTTP session scope.

    Public Methods

    public static Callable<T> continueRequest (Callable<T> callable, Map<Key<?>, Object> seedMap)

    Wraps the given callable in a contextual callable that "continues" the HTTP request in another thread. This acts as a way of transporting request context data from the request processing thread to to worker threads.

    There are some limitations:

    • Derived objects (i.e. anything marked @RequestScoped will not be transported.
    • State changes to the HttpServletRequest after this method is called will not be seen in the continued thread.
    • Only the HttpServletRequest, ServletContext and request parameter map are available in the continued thread. The response and session are not available.

    Parameters
    callable code to be executed in another thread, which depends on the request scope.
    seedMap the initial set of scoped instances for Guice to seed the request scope with. To seed a key with null, use null as the value.
    Returns
    • a callable that will invoke the given callable, making the request context available to it.
    Throws
    OutOfScopeException if this method is called from a non-request thread, or if the request has completed.

    public static Callable<T> scopeRequest (Callable<T> callable, Map<Key<?>, Object> seedMap)

    Scopes the given callable inside a request scope. This is not the same as the HTTP request scope, but is used if no HTTP request scope is in progress. In this way, keys can be scoped as @RequestScoped and exist in non-HTTP requests (for example: RPC requests) as well as in HTTP request threads.

    Parameters
    callable code to be executed which depends on the request scope. Typically in another thread, but not necessarily so.
    seedMap the initial set of scoped instances for Guice to seed the request scope with. To seed a key with null, use null as the value.
    Returns
    • a callable that when called will run inside the a request scope that exposes the instances in the seedMap as scoped keys.
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/ServletModuleTargetVisitor.html0000755000175000017500000007313411704661106031235 0ustar tonytony ServletModuleTargetVisitor | Guice
    public interface

    ServletModuleTargetVisitor

    implements BindingTargetVisitor<T, V>
    com.google.inject.servlet.ServletModuleTargetVisitor<T, V>

    Class Overview

    A visitor for the servlet extension. If your BindingTargetVisitor implements this interface, bindings created by using ServletModule will be visited through this interface.

    Summary

    Public Methods
    abstract V visit(InstanceFilterBinding binding)
    Visits a filter binding created by filter(String, String...) where through(Class) is called with a Filter.
    abstract V visit(InstanceServletBinding binding)
    Visits a servlet binding created by serve(String, String...) where with(Class), is called with an HttpServlet.
    abstract V visit(LinkedFilterBinding binding)
    Visits a filter binding created by filter(String, String...), where through(Class) is called with a Class or Key.
    abstract V visit(LinkedServletBinding binding)
    Visits a servlet binding created by serve(String, String...) where with(Class), is called with a Class or Key.
    [Expand]
    Inherited Methods
    From interface com.google.inject.spi.BindingTargetVisitor

    Public Methods

    public abstract V visit (InstanceFilterBinding binding)

    Visits a filter binding created by filter(String, String...) where through(Class) is called with a Filter. If multiple patterns were specified, this will be called multiple times.

    public abstract V visit (InstanceServletBinding binding)

    Visits a servlet binding created by serve(String, String...) where with(Class), is called with an HttpServlet. If multiple patterns were specified, this will be called multiple times.

    public abstract V visit (LinkedFilterBinding binding)

    Visits a filter binding created by filter(String, String...), where through(Class) is called with a Class or Key. If multiple patterns were specified, this will be called multiple times.

    public abstract V visit (LinkedServletBinding binding)

    Visits a servlet binding created by serve(String, String...) where with(Class), is called with a Class or Key. If multiple patterns were specified, this will be called multiple times.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/ServletModuleBinding.html0000755000175000017500000005111111704661106027770 0ustar tonytony ServletModuleBinding | Guice
    public interface

    ServletModuleBinding

    com.google.inject.servlet.ServletModuleBinding
    Known Indirect Subclasses

    Class Overview

    A binding created by ServletModule.

    Summary

    Public Methods
    abstract Map<String, String> getInitParams()
    Returns any context params supplied when creating the binding.
    abstract String getPattern()
    Returns the pattern used to match against the binding.
    abstract UriPatternType getUriPatternType()
    Returns the pattern type that this binding was created with.
    abstract boolean matchesUri(String uri)
    Returns true if the given URI will match this binding.

    Public Methods

    public abstract Map<String, String> getInitParams ()

    Returns any context params supplied when creating the binding.

    public abstract String getPattern ()

    Returns the pattern used to match against the binding.

    public abstract UriPatternType getUriPatternType ()

    Returns the pattern type that this binding was created with.

    public abstract boolean matchesUri (String uri)

    Returns true if the given URI will match this binding.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/ServletModule.html0000755000175000017500000015115611704661106026507 0ustar tonytony ServletModule | Guice
    public class

    ServletModule

    extends AbstractModule
    java.lang.Object
       ↳ com.google.inject.AbstractModule
         ↳ com.google.inject.servlet.ServletModule

    Class Overview

    Configures the servlet scopes and creates bindings for the servlet API objects so you can inject the request, response, session, etc.

    You should subclass this module to register servlets and filters in the configureServlets() method.

    Summary

    Nested Classes
    interface ServletModule.FilterKeyBindingBuilder See the EDSL examples at configureServlets() 
    interface ServletModule.ServletKeyBindingBuilder See the EDSL examples at configureServlets() 
    Public Constructors
    ServletModule()
    Protected Methods
    final void configure()
    Configures a Binder via the exposed methods.
    void configureServlets()

    Servlet Mapping EDSL

    Part of the EDSL builder language for configuring servlets and filters with guice-servlet.

    final ServletModule.FilterKeyBindingBuilder filter(String urlPattern, String... morePatterns)
    final ServletModule.FilterKeyBindingBuilder filterRegex(String regex, String... regexes)
    final ServletContext getServletContext()
    This method only works if you are using the GuiceServletContextListener to create your injector.
    final ServletModule.ServletKeyBindingBuilder serve(String urlPattern, String... morePatterns)
    final ServletModule.ServletKeyBindingBuilder serveRegex(String regex, String... regexes)
    [Expand]
    Inherited Methods
    From class com.google.inject.AbstractModule
    From class java.lang.Object
    From interface com.google.inject.Module

    Public Constructors

    public ServletModule ()

    Protected Methods

    protected final void configure ()

    Configures a Binder via the exposed methods.

    protected void configureServlets ()

    Servlet Mapping EDSL

    Part of the EDSL builder language for configuring servlets and filters with guice-servlet. Think of this as an in-code replacement for web.xml. Filters and servlets are configured here using simple java method calls. Here is a typical example of registering a filter when creating your Guice injector:

       Guice.createInjector(..., new ServletModule() {
    
         @Override
         protected void configureServlets() {
           serve("*.html").with(MyServlet.class)
         }
       }
     
    This registers a servlet (subclass of HttpServlet) called MyServlet to service any web pages ending in .html. You can also use a path-style syntax to register servlets:
           serve("/my/*").with(MyServlet.class)
     
    Every servlet (or filter) is required to be a singleton. If you cannot annotate the class directly, you should add a separate bind(..).in(Singleton.class) rule elsewhere in your module. Mapping a servlet that is bound under any other scope is an error.

    Dispatch Order

    You are free to register as many servlets and filters as you like this way. They will be compared and dispatched in the order in which the filter methods are called:
    
       Guice.createInjector(..., new ServletModule() {
    
         @Override
         protected void configureServlets() {
           filter("/*").through(MyFilter.class);
           filter("*.css").through(MyCssFilter.class);
           filter("*.jpg").through(new MyJpgFilter());
           // etc..
    
           serve("*.html").with(MyServlet.class);
           serve("/my/*").with(MyServlet.class);
           serve("*.jpg").with(new MyServlet());
           // etc..
          }
        }
     
    This will traverse down the list of rules in lexical order. For example, a url "/my/file.js" (after it runs through the matching filters) will first be compared against the servlet mapping:
           serve("*.html").with(MyServlet.class);
     
    And failing that, it will descend to the next servlet mapping:
           serve("/my/*").with(MyServlet.class);
     
    Since this rule matches, Guice Servlet will dispatch to MyServlet. These two mapping rules can also be written in more compact form using varargs syntax:
           serve("*.html", "/my/*").with(MyServlet.class);
     
    This way you can map several URI patterns to the same servlet. A similar syntax is also available for filter mappings.

    Regular Expressions

    You can also map servlets (or filters) to URIs using regular expressions:
        serveRegex("(.)*ajax(.)*").with(MyAjaxServlet.class)
     
    This will map any URI containing the text "ajax" in it to MyAjaxServlet. Such as:
    • http://www.google.com/ajax.html
    • http://www.google.com/content/ajax/index
    • http://www.google.com/it/is_totally_ajaxian

    Initialization Parameters

    Servlets (and filters) allow you to pass in init params using the <init-param> tag in web.xml. You can similarly pass in parameters to Servlets and filters registered in Guice-servlet using a java.util.Map of parameter name/value pairs. For example, to initialize MyServlet with two parameters (name="Dhanji", site="google.com") you could write:
      Map<String, String> params = new HashMap<String, String>();
      params.put("name", "Dhanji");
      params.put("site", "google.com");
    
      ...
          serve("/*").with(MyServlet.class, params)
     

    Binding Keys

    You can also bind keys rather than classes. This lets you hide implementations with package-local visbility and expose them using only a Guice module and an annotation:
      ...
          filter("/*").through(Key.get(Filter.class, Fave.class));
     
    Where Filter.class refers to the Servlet API interface and Fave.class is a custom binding annotation. Elsewhere (in one of your own modules) you can bind this filter's implementation:
       bind(Filter.class).annotatedWith(Fave.class).to(MyFilterImpl.class);
     
    See Binder for more information on binding syntax.

    Multiple Modules

    It is sometimes useful to capture servlet and filter mappings from multiple different modules. This is essential if you want to package and offer drop-in Guice plugins that provide servlet functionality.

    Guice Servlet allows you to register several instances of ServletModule to your injector. The order in which these modules are installed determines the dispatch order of filters and the precedence order of servlets. For example, if you had two servlet modules, RpcModule and WebServiceModule and they each contained a filter that mapped to the same URI pattern, "/*":

    In RpcModule:

         filter("/*").through(RpcFilter.class);
     
    In WebServiceModule:
         filter("/*").through(WebServiceFilter.class);
     
    Then the order in which these filters are dispatched is determined by the order in which the modules are installed:
       install(new WebServiceModule());
       install(new RpcModule());
     
    In the case shown above WebServiceFilter will run first.

    protected final ServletModule.FilterKeyBindingBuilder filter (String urlPattern, String... morePatterns)

    Parameters
    urlPattern Any Servlet-style pattern. examples: /*, /html/*, *.html, etc.

    protected final ServletModule.FilterKeyBindingBuilder filterRegex (String regex, String... regexes)

    Parameters
    regex Any Java-style regular expression.

    protected final ServletContext getServletContext ()

    This method only works if you are using the GuiceServletContextListener to create your injector. Otherwise, it returns null.

    Returns
    • The current servlet context.

    protected final ServletModule.ServletKeyBindingBuilder serve (String urlPattern, String... morePatterns)

    Parameters
    urlPattern Any Servlet-style pattern. examples: /*, /html/*, *.html, etc.

    protected final ServletModule.ServletKeyBindingBuilder serveRegex (String regex, String... regexes)

    Parameters
    regex Any Java-style regular expression.
    ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/ServletModule.ServletKeyBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/ServletModule.ServletKeyBindingBuilder0000755000175000017500000005126711704661106032444 0ustar tonytony ServletModule.ServletKeyBindingBuilder | Guice
    public static interface

    ServletModule.ServletKeyBindingBuilder

    com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder

    Class Overview

    See the EDSL examples at configureServlets()

    Summary

    Public Methods
    abstract void with(HttpServlet servlet)
    abstract void with(HttpServlet servlet, Map<String, String> initParams)
    abstract void with(Key<? extends HttpServlet> servletKey)
    abstract void with(Key<? extends HttpServlet> servletKey, Map<String, String> initParams)
    abstract void with(Class<? extends HttpServlet> servletKey)
    abstract void with(Class<? extends HttpServlet> servletKey, Map<String, String> initParams)

    Public Methods

    public abstract void with (HttpServlet servlet)

    public abstract void with (HttpServlet servlet, Map<String, String> initParams)

    public abstract void with (Key<? extends HttpServlet> servletKey)

    public abstract void with (Key<? extends HttpServlet> servletKey, Map<String, String> initParams)

    public abstract void with (Class<? extends HttpServlet> servletKey)

    public abstract void with (Class<? extends HttpServlet> servletKey, Map<String, String> initParams)

    ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/ServletModule.FilterKeyBindingBuilder.htmlsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/ServletModule.FilterKeyBindingBuilder.0000755000175000017500000005116211704661106032315 0ustar tonytony ServletModule.FilterKeyBindingBuilder | Guice
    public static interface

    ServletModule.FilterKeyBindingBuilder

    com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder

    Class Overview

    See the EDSL examples at configureServlets()

    Summary

    Public Methods
    abstract void through(Filter filter)
    abstract void through(Filter filter, Map<String, String> initParams)
    abstract void through(Key<? extends Filter> filterKey)
    abstract void through(Key<? extends Filter> filterKey, Map<String, String> initParams)
    abstract void through(Class<? extends Filter> filterKey)
    abstract void through(Class<? extends Filter> filterKey, Map<String, String> initParams)

    Public Methods

    public abstract void through (Filter filter)

    public abstract void through (Filter filter, Map<String, String> initParams)

    public abstract void through (Key<? extends Filter> filterKey)

    public abstract void through (Key<? extends Filter> filterKey, Map<String, String> initParams)

    public abstract void through (Class<? extends Filter> filterKey)

    public abstract void through (Class<? extends Filter> filterKey, Map<String, String> initParams)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/RequestScoped.html0000755000175000017500000003644111704661106026502 0ustar tonytony RequestScoped | Guice
    public abstract @interface

    RequestScoped

    implements Annotation
    com.google.inject.servlet.RequestScoped

    Class Overview

    Apply this to implementation classes when you want one instance per request.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/RequestParameters.html0000755000175000017500000003656111704661106027373 0ustar tonytony RequestParameters | Guice
    public abstract @interface

    RequestParameters

    implements Annotation
    com.google.inject.servlet.RequestParameters

    Class Overview

    Apply this to field or parameters of type Map<String, String[]> when you want the HTTP request parameter map to be injected.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/LinkedServletBinding.html0000755000175000017500000004372611704661106027766 0ustar tonytony LinkedServletBinding | Guice
    public interface

    LinkedServletBinding

    implements ServletModuleBinding
    com.google.inject.servlet.LinkedServletBinding

    Class Overview

    A linked binding to a servlet.

    Summary

    Public Methods
    abstract Key<? extends HttpServlet> getLinkedKey()
    Returns the key used to lookup the servlet instance.
    [Expand]
    Inherited Methods
    From interface com.google.inject.servlet.ServletModuleBinding

    Public Methods

    public abstract Key<? extends HttpServlet> getLinkedKey ()

    Returns the key used to lookup the servlet instance.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/LinkedFilterBinding.html0000755000175000017500000004370511704661106027564 0ustar tonytony LinkedFilterBinding | Guice
    public interface

    LinkedFilterBinding

    implements ServletModuleBinding
    com.google.inject.servlet.LinkedFilterBinding

    Class Overview

    A linked binding to a filter.

    Summary

    Public Methods
    abstract Key<? extends Filter> getLinkedKey()
    Returns the key used to lookup the filter instance.
    [Expand]
    Inherited Methods
    From interface com.google.inject.servlet.ServletModuleBinding

    Public Methods

    public abstract Key<? extends Filter> getLinkedKey ()

    Returns the key used to lookup the filter instance.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/InstanceServletBinding.html0000755000175000017500000004352211704661106030316 0ustar tonytony InstanceServletBinding | Guice
    public interface

    InstanceServletBinding

    implements ServletModuleBinding
    com.google.inject.servlet.InstanceServletBinding

    Class Overview

    A binding to a single instance of a servlet.

    Summary

    Public Methods
    abstract HttpServlet getServletInstance()
    Returns the servlet instance that will be used.
    [Expand]
    Inherited Methods
    From interface com.google.inject.servlet.ServletModuleBinding

    Public Methods

    public abstract HttpServlet getServletInstance ()

    Returns the servlet instance that will be used.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/InstanceFilterBinding.html0000755000175000017500000004347511704661106030126 0ustar tonytony InstanceFilterBinding | Guice
    public interface

    InstanceFilterBinding

    implements ServletModuleBinding
    com.google.inject.servlet.InstanceFilterBinding

    Class Overview

    A binding to a single instance of a filter.

    Summary

    Public Methods
    abstract Filter getFilterInstance()
    Returns the filter instance that will be used.
    [Expand]
    Inherited Methods
    From interface com.google.inject.servlet.ServletModuleBinding

    Public Methods

    public abstract Filter getFilterInstance ()

    Returns the filter instance that will be used.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/GuiceServletContextListener.html0000755000175000017500000005617111704661106031372 0ustar tonytony GuiceServletContextListener | Guice
    public abstract class

    GuiceServletContextListener

    extends Object
    java.lang.Object
       ↳ com.google.inject.servlet.GuiceServletContextListener

    Class Overview

    As of Guice 2.0 you can still use (your subclasses of) GuiceServletContextListener class as a logical place to create and configure your injector. This will ensure the injector is created when the web application is deployed.

    Summary

    Public Constructors
    GuiceServletContextListener()
    Public Methods
    void contextDestroyed(ServletContextEvent servletContextEvent)
    void contextInitialized(ServletContextEvent servletContextEvent)
    Protected Methods
    abstract Injector getInjector()
    Override this method to create (or otherwise obtain a reference to) your injector.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Constructors

    public GuiceServletContextListener ()

    Public Methods

    public void contextDestroyed (ServletContextEvent servletContextEvent)

    public void contextInitialized (ServletContextEvent servletContextEvent)

    Protected Methods

    protected abstract Injector getInjector ()

    Override this method to create (or otherwise obtain a reference to) your injector.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/servlet/GuiceFilter.html0000755000175000017500000005677311704661106026130 0ustar tonytony GuiceFilter | Guice
    public class

    GuiceFilter

    extends Object
    java.lang.Object
       ↳ com.google.inject.servlet.GuiceFilter

    Class Overview

    Apply this filter in web.xml above all other filters (typically), to all requests where you plan to use servlet scopes. This is also needed in order to dispatch requests to injectable filters and servlets:

      <filter>
        <filter-name>guiceFilter</filter-name>
        <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
      </filter>
    
      <filter-mapping>
        <filter-name>guiceFilter</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
      
    This filter must appear before every filter that makes use of Guice injection or servlet scopes functionality. Typically, you will only register this filter in web.xml and register any other filters (and servlets) using a ServletModule.

    Summary

    Public Constructors
    GuiceFilter()
    Public Methods
    void destroy()
    void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
    void init(FilterConfig filterConfig)
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Constructors

    public GuiceFilter ()

    Public Methods

    public void destroy ()

    public void doFilter (ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)

    Throws
    IOException
    ServletException

    public void init (FilterConfig filterConfig)

    Throws
    ServletException
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/0000755000175000017500000000000011704661106023020 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/package-summary.html0000755000175000017500000002752111704661106027006 0ustar tonytony com.google.inject.persist | Guice
    package

    com.google.inject.persist

    Classes | Description

    Guice Persist: a lightweight persistence library for Guice; this extension requires guice-persist-3.0.jar.

    more...

    Interfaces

    PersistService Persistence provider service. 
    UnitOfWork This interface is used to gain manual control over the unit of work. 

    Classes

    PersistFilter Apply this filter to enable the HTTP Request unit of work and to have guice-persist manage the lifecycle of active units of work. 
    PersistModule Install this module to add guice-persist library support for JPA persistence providers. 
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/package-descr.html0000755000175000017500000002425711704661106026414 0ustar tonytony com.google.inject.persist Details | Guice
    package

    com.google.inject.persist

    Classes | Description

    Guice Persist: a lightweight persistence library for Guice; this extension requires guice-persist-3.0.jar.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/jpa/0000755000175000017500000000000011704661106023572 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/jpa/package-summary.html0000755000175000017500000002420711704661106027556 0ustar tonytony com.google.inject.persist.jpa | Guice
    package

    com.google.inject.persist.jpa

    Classes | Description

    guice-persist's Java Persistence API (JPA) support.

    more...

    Classes

    JpaPersistModule JPA provider for guice persist. 
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/jpa/package-descr.html0000755000175000017500000002314711704661106027163 0ustar tonytony com.google.inject.persist.jpa Details | Guice
    package

    com.google.inject.persist.jpa

    Classes | Description

    guice-persist's Java Persistence API (JPA) support.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/jpa/JpaPersistModule.html0000755000175000017500000012315511704661106027724 0ustar tonytony JpaPersistModule | Guice
    public final class

    JpaPersistModule

    extends PersistModule
    java.lang.Object
       ↳ com.google.inject.AbstractModule
         ↳ com.google.inject.persist.PersistModule
           ↳ com.google.inject.persist.jpa.JpaPersistModule

    Class Overview

    JPA provider for guice persist.

    Summary

    Public Constructors
    JpaPersistModule(String jpaUnit)
    Public Methods
    <T> JpaPersistModule addFinder(Class<T> iface)
    Adds an interface to this module to use as a dynamic finder.
    JpaPersistModule properties(Properties properties)
    Configures the JPA persistence provider with a set of properties.
    Protected Methods
    void configurePersistence()
    MethodInterceptor getTransactionInterceptor()
    [Expand]
    Inherited Methods
    From class com.google.inject.persist.PersistModule
    From class com.google.inject.AbstractModule
    From class java.lang.Object
    From interface com.google.inject.Module

    Public Constructors

    public JpaPersistModule (String jpaUnit)

    Public Methods

    public JpaPersistModule addFinder (Class<T> iface)

    Adds an interface to this module to use as a dynamic finder.

    Parameters
    iface Any interface type whose methods are all dynamic finders.

    public JpaPersistModule properties (Properties properties)

    Configures the JPA persistence provider with a set of properties.

    Parameters
    properties A set of name value pairs that configure a JPA persistence provider as per the specification.

    Protected Methods

    protected void configurePersistence ()

    protected MethodInterceptor getTransactionInterceptor ()

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/finder/0000755000175000017500000000000011704661106024267 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/finder/package-summary.html0000755000175000017500000002514611704661106030256 0ustar tonytony com.google.inject.persist.finder | Guice
    package

    com.google.inject.persist.finder

    Classes | Description

    Dynamic Finder API for Guice Persist.

    more...

    Classes

    DynamicFinder Utility that helps you introspect dynamic finder methods. 
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/finder/package-descr.html0000755000175000017500000002405711704661106027661 0ustar tonytony com.google.inject.persist.finder Details | Guice
    package

    com.google.inject.persist.finder

    Classes | Description

    Dynamic Finder API for Guice Persist.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/finder/MaxResults.html0000755000175000017500000003324511704661106027276 0ustar tonytony MaxResults | Guice
    public abstract @interface

    MaxResults

    implements Annotation
    com.google.inject.persist.finder.MaxResults

    Class Overview

    Annotate any dynamic finder method's integer argument with this to pass in the maximum size of returned result window. Usefule for paging result sets. Complement of FirstResult.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/finder/FirstResult.html0000755000175000017500000003330211704661106027447 0ustar tonytony FirstResult | Guice
    public abstract @interface

    FirstResult

    implements Annotation
    com.google.inject.persist.finder.FirstResult

    Class Overview

    Annotate any dynamic finder method's integer argument with this to pass in the index of the first result in the result set you are interested in. Useful for paging result sets. Complemented by MaxResults.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/finder/Finder.html0000755000175000017500000003306711704661106026400 0ustar tonytony Finder | Guice
    public abstract @interface

    Finder

    implements Annotation
    com.google.inject.persist.finder.Finder

    Class Overview

    Marks a method stub as a dynamic finder. The method is intercepted and replaced with the specified JPAQL query. Provides result auto-boxing and automatic parameter binding.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/finder/DynamicFinder.html0000755000175000017500000005006011704661106027675 0ustar tonytony DynamicFinder | Guice
    public final class

    DynamicFinder

    extends Object
    java.lang.Object
       ↳ com.google.inject.persist.finder.DynamicFinder

    Class Overview

    Utility that helps you introspect dynamic finder methods.

    Summary

    Public Constructors
    DynamicFinder(Method method)
    Public Methods
    static DynamicFinder from(Method method)
    Returns some metadata if the method is annotated @Finder or null.
    Finder metadata()
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Constructors

    public DynamicFinder (Method method)

    Public Methods

    public static DynamicFinder from (Method method)

    Returns some metadata if the method is annotated @Finder or null.

    Parameters
    method a method you want to test as a dynamic finder

    public Finder metadata ()

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/UnitOfWork.html0000755000175000017500000003522211704661106025764 0ustar tonytony UnitOfWork | Guice
    public interface

    UnitOfWork

    com.google.inject.persist.UnitOfWork

    Class Overview

    This interface is used to gain manual control over the unit of work. This is mostly to do work in non-request, non-transactional threads. Or where more fine-grained control over the unit of work is required. Starting and ending a unit of work directly corresponds to opening and closing a Session, EntityManager or ObjectContainer respectively.

    The Unit of Work referred to by UnitOfWork will always be local to the calling thread. Be careful to end() in a finally block. Neither JPA, nor Hibernate supports threadsafe sessions (reasoning behind thread-locality of Unit of Work semantics).

    • Using UnitOfWork with the PersistFilter inside a request is not recommended.
    • Using UnitOfWork with session-per-txn strategy is not terribly clever either.
    • Using UnitOfWork with session-per-request strategy but *outside* a request (i.e. in a background or bootstrap thread) is probably a good use case.

    Summary

    Public Methods
    abstract void begin()
    Starts a Unit Of Work.
    abstract void end()
    Declares an end to the current Unit of Work.

    Public Methods

    public abstract void begin ()

    Starts a Unit Of Work. Underneath, causes a session to the data layer to be opened. If there is already one open, the invocation will do nothing. In this way, you can define arbitrary units-of-work that nest within one another safely. Transaction semantics are not affected.

    public abstract void end ()

    Declares an end to the current Unit of Work. Underneath, causes any open session to the data layer to close. If there is no Unit of work open, then the call returns silently. You can safely invoke end() repeatedly.

    Transaction semantics are not affected.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/Transactional.html0000755000175000017500000003414411704661106026521 0ustar tonytony Transactional | Guice
    public abstract @interface

    Transactional

    implements Annotation
    com.google.inject.persist.Transactional

    Class Overview

    Any method or class marked with this annotation will be considered for transactionality. Consult the documentation on http://code.google.com/p/google-guice for detailed semantics. Marking a method @Transactional will start a new transaction before the method executes and commit it after the method returns.

    If the method throws an exception, the transaction will be rolled back unless you have specifically requested not to in the #ignore() clause.

    Similarly, the set of exceptions that will trigger a rollback can be defined in the #rollbackOn() clause. By default, only unchecked exceptions trigger a rollback.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/PersistService.html0000755000175000017500000003370211704661106026670 0ustar tonytony PersistService | Guice
    public interface

    PersistService

    com.google.inject.persist.PersistService

    Class Overview

    Persistence provider service. Use this to manage the overall startup and stop of the persistence module(s). TODO(dhanji): Integrate with Service API when appropriate.

    Summary

    Public Methods
    abstract void start()
    Starts the underlying persistence engine and makes guice-persist ready for use.
    abstract void stop()
    Stops the underlying persistence engine.

    Public Methods

    public abstract void start ()

    Starts the underlying persistence engine and makes guice-persist ready for use. For instance, with JPA, it creates an EntityManagerFactory and may open connection pools. This method must be called by your code prior to using any guice-persist or JPA artifacts. If already started, calling this method does nothing, if already stopped, it also does nothing.

    public abstract void stop ()

    Stops the underlying persistence engine. For instance, with JPA, it closes the EntityManagerFactory. If already stopped, calling this method does nothing. If not yet started, it also does nothing.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/PersistModule.html0000755000175000017500000011372311704661106026517 0ustar tonytony PersistModule | Guice
    public abstract class

    PersistModule

    extends AbstractModule
    java.lang.Object
       ↳ com.google.inject.AbstractModule
         ↳ com.google.inject.persist.PersistModule
    Known Direct Subclasses

    Class Overview

    Install this module to add guice-persist library support for JPA persistence providers.

    Summary

    Public Constructors
    PersistModule()
    Protected Methods
    final void configure()
    Configures a Binder via the exposed methods.
    abstract void configurePersistence()
    abstract MethodInterceptor getTransactionInterceptor()
    [Expand]
    Inherited Methods
    From class com.google.inject.AbstractModule
    From class java.lang.Object
    From interface com.google.inject.Module

    Public Constructors

    public PersistModule ()

    Protected Methods

    protected final void configure ()

    Configures a Binder via the exposed methods.

    protected abstract void configurePersistence ()

    protected abstract MethodInterceptor getTransactionInterceptor ()

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/persist/PersistFilter.html0000755000175000017500000005547511704661106026530 0ustar tonytony PersistFilter | Guice
    public final class

    PersistFilter

    extends Object
    java.lang.Object
       ↳ com.google.inject.persist.PersistFilter

    Class Overview

    Apply this filter to enable the HTTP Request unit of work and to have guice-persist manage the lifecycle of active units of work. The filter automatically starts and stops the relevant PersistService upon javax.servlet.Filter#init(javax.servlet.FilterConfig) and javax.servlet.Filter#destroy() respectively.

    To be able to use the open session-in-view pattern (i.e. work per request), register this filter once in your Guice ServletModule. It is important that you register this filter before any other filter. For multiple providers, you should register this filter once per provider, inside a private module for each persist module installed (this must be the same private module where the specific persist module is itself installed).

    Example configuration:

    public class MyModule extends ServletModule {
        public void configureServlets() {
          filter("/*").through(PersistFilter.class);
    
          serve("/index.html").with(MyHtmlServlet.class);
          // Etc.
        
      }
     }

    This filter is thread safe and allows you to create injectors concurrently and deploy multiple guice-persist modules within the same injector, or even multiple injectors with persist modules withing the same JVM or web app.

    This filter requires the Guice Servlet extension.

    Summary

    Public Constructors
    PersistFilter(UnitOfWork unitOfWork, PersistService persistService)
    Public Methods
    void destroy()
    void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
    void init(FilterConfig filterConfig)
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Constructors

    public PersistFilter (UnitOfWork unitOfWork, PersistService persistService)

    Public Methods

    public void destroy ()

    public void doFilter (ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)

    Throws
    IOException
    ServletException

    public void init (FilterConfig filterConfig)

    Throws
    ServletException
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/package-summary.html0000755000175000017500000004674611704661106025327 0ustar tonytony com.google.inject | Guice
    package

    com.google.inject

    Classes | Description

    Google Guice (pronounced "juice") is an ultra-lightweight dependency injection framework.

    more...

    Interfaces

    Binder Collects configuration information (primarily bindings) which will be used to create an Injector
    Binding<T> A mapping from a key (type and optional annotation) to the strategy for getting instances of the type. 
    Injector Builds the graphs of objects that make up your application. 
    MembersInjector<T> Injects dependencies into the fields and methods on instances of type T
    Module A module contributes configuration information, typically interface bindings, which will be used to create an Injector
    PrivateBinder Returns a binder whose configuration information is hidden from its environment by default. 
    Provider<T> An object capable of providing instances of type T
    Scope A scope is a level of visibility that instances provided by Guice may have. 

    Classes

    AbstractModule A support class for Modules which reduces repetition and results in a more readable configuration. 
    Guice The entry point to the Guice framework. 
    Key<T> Binding key consisting of an injection type and an optional annotation. 
    PrivateModule A module whose configuration information is hidden from its environment by default. 
    Scopes Built-in scope implementations. 
    TypeLiteral<T> Represents a generic type T

    Enums

    Stage The stage we're running in. 

    Exceptions

    ConfigurationException Thrown when a programming error such as a misplaced annotation, illegal binding, or unsupported scope is found. 
    CreationException Thrown when errors occur while creating a Injector
    OutOfScopeException Thrown from get() when an attempt is made to access a scoped object while the scope in question is not currently active. 
    ProvisionException Indicates that there was a runtime failure while providing an instance. 
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/package-descr.html0000755000175000017500000003337611704661106024725 0ustar tonytony com.google.inject Details | Guice
    package

    com.google.inject

    Classes | Description

    Google Guice (pronounced "juice") is an ultra-lightweight dependency injection framework. Please refer to the Guice User's Guide for a gentle introduction.

    The principal public APIs in this package are:

    Inject
    The annotation you will use in your implementation classes to tell Guice where and how it should send in ("inject") the objects you depend on (your "dependencies").
    Module
    The interface you will implement in order to specify "bindings" -- instructions for how Guice should handle injection -- for a particular set of interfaces.
    Binder
    The object that Guice passes into your Module to collect these bindings.
    Provider
    The interface you will implement when you need to customize exactly how Guice creates instances for a particular binding.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/name/0000755000175000017500000000000011704661106022247 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/name/package-summary.html0000755000175000017500000002431111704661106026227 0ustar tonytony com.google.inject.name | Guice
    package

    com.google.inject.name

    Classes | Description

    Support for binding to string-based names.

    more...

    Classes

    Names Utility methods for use with @Named
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/name/package-descr.html0000755000175000017500000002315611704661106025640 0ustar tonytony com.google.inject.name Details | Guice
    package

    com.google.inject.name

    Classes | Description

    Support for binding to string-based names.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/name/Names.html0000755000175000017500000005015411704661106024210 0ustar tonytony Names | Guice
    public class

    Names

    extends Object
    java.lang.Object
       ↳ com.google.inject.name.Names

    Class Overview

    Utility methods for use with @Named.

    Summary

    Public Methods
    static void bindProperties(Binder binder, Map<String, String> properties)
    Creates a constant binding to @Named(key) for each entry in properties.
    static void bindProperties(Binder binder, Properties properties)
    Creates a constant binding to @Named(key) for each property.
    static Named named(String name)
    Creates a Named annotation with name as the value.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Methods

    public static void bindProperties (Binder binder, Map<String, String> properties)

    Creates a constant binding to @Named(key) for each entry in properties.

    public static void bindProperties (Binder binder, Properties properties)

    Creates a constant binding to @Named(key) for each property. This method binds all properties including those inherited from defaults.

    public static Named named (String name)

    Creates a Named annotation with name as the value.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/name/Named.html0000755000175000017500000003173311704661106024173 0ustar tonytony Named | Guice
    public abstract @interface

    Named

    implements Annotation
    com.google.inject.name.Named

    Class Overview

    Annotates named things.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/multibindings/0000755000175000017500000000000011704661106024177 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/multibindings/package-summary.html0000755000175000017500000003040111704661106030154 0ustar tonytony com.google.inject.multibindings | Guice
    package

    com.google.inject.multibindings

    Classes | Description

    Extension for binding multiple instances in a collection; this extension requires guice-multibindings-3.0.jar.

    more...

    Interfaces

    MapBinderBinding<T> A binding for a MapBinder. 
    MultibinderBinding<T> A binding for a Multibinder. 
    MultibindingsTargetVisitor<T, V> A visitor for the multibinder extension. 

    Classes

    MapBinder<K, V> An API to bind multiple map entries separately, only to later inject them as a complete map. 
    Multibinder<T> An API to bind multiple values separately, only to later inject them as a complete collection. 
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/multibindings/package-descr.html0000755000175000017500000002437611704661106027575 0ustar tonytony com.google.inject.multibindings Details | Guice
    package

    com.google.inject.multibindings

    Classes | Description

    Extension for binding multiple instances in a collection; this extension requires guice-multibindings-3.0.jar.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/multibindings/MultibindingsTargetVisitor.html0000755000175000017500000005502111704661106032432 0ustar tonytony MultibindingsTargetVisitor | Guice
    public interface

    MultibindingsTargetVisitor

    implements BindingTargetVisitor<T, V>
    com.google.inject.multibindings.MultibindingsTargetVisitor<T, V>

    Class Overview

    A visitor for the multibinder extension.

    If your BindingTargetVisitor implements this interface, bindings created by using Multibinder or MapBinder will be visited through this interface.

    Summary

    Public Methods
    abstract V visit(MapBinderBinding<? extends T> mapbinding)
    Visits a binding created through MapBinder.
    abstract V visit(MultibinderBinding<? extends T> multibinding)
    Visits a binding created through Multibinder.
    [Expand]
    Inherited Methods
    From interface com.google.inject.spi.BindingTargetVisitor

    Public Methods

    public abstract V visit (MapBinderBinding<? extends T> mapbinding)

    Visits a binding created through MapBinder.

    public abstract V visit (MultibinderBinding<? extends T> multibinding)

    Visits a binding created through Multibinder.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/multibindings/MultibinderBinding.html0000755000175000017500000004752711704661106030660 0ustar tonytony MultibinderBinding | Guice
    public interface

    MultibinderBinding

    com.google.inject.multibindings.MultibinderBinding<T>

    Class Overview

    A binding for a Multibinder.

    Summary

    Public Methods
    abstract boolean containsElement(Element element)
    Returns true if this Multibinder uses the given Element.
    abstract TypeLiteral<?> getElementTypeLiteral()
    Returns the TypeLiteral that describes the type of elements in the set.
    abstract List<Binding<?>> getElements()
    Returns all bindings that make up the set.
    abstract Key<T> getSetKey()
    Returns the key for the set.
    abstract boolean permitsDuplicates()
    Returns true if the multibinder permits duplicates.

    Public Methods

    public abstract boolean containsElement (Element element)

    Returns true if this Multibinder uses the given Element. This will be true for bindings that derive the elements of the set and other bindings that Multibinder uses internally. This will work for MultibinderBindings retrieved from an injector and getElements(Module...). Usually this is only necessary if you are working with elements retrieved from modules (without an Injector), otherwise getElements() and permitsDuplicates() are better options.

    If you need to introspect the details of the set, such as the values or if it permits duplicates, it is necessary to pass the elements through an Injector and use getElements() and permitsDuplicates().

    public abstract TypeLiteral<?> getElementTypeLiteral ()

    Returns the TypeLiteral that describes the type of elements in the set.

    The elements will always match the type Set's generic type. For example, if getSetKey returns a key of Set<String>, then this will always return a TypeLiteral<String>.

    public abstract List<Binding<?>> getElements ()

    Returns all bindings that make up the set. This is only supported on bindings returned from an injector. This will throw UnsupportedOperationException if it is called on an element retrieved from getElements(Module...).

    The elements will always match the type Set's generic type. For example, if getSetKey returns a key of Set<String>, then this will always return a list of type List<Binding<String>>.

    public abstract Key<T> getSetKey ()

    Returns the key for the set.

    public abstract boolean permitsDuplicates ()

    Returns true if the multibinder permits duplicates. This is only supported on bindings returned from an injector. This will throw UnsupportedOperationException if it is called on a MultibinderBinding retrieved from getElements(Module...).

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/multibindings/Multibinder.html0000755000175000017500000010233111704661106027346 0ustar tonytony Multibinder | Guice
    public abstract class

    Multibinder

    extends Object
    java.lang.Object
       ↳ com.google.inject.multibindings.Multibinder<T>

    Class Overview

    An API to bind multiple values separately, only to later inject them as a complete collection. Multibinder is intended for use in your application's module:

    
     public class SnacksModule extends AbstractModule {
       protected void configure() {
         Multibinder<Snack> multibinder
             = Multibinder.newSetBinder(binder(), Snack.class);
         multibinder.addBinding().toInstance(new Twix());
         multibinder.addBinding().toProvider(SnickersProvider.class);
         multibinder.addBinding().to(Skittles.class);
       }
     }

    With this binding, a Set<Snack> can now be injected:

    
     class SnackMachine {
       @Inject
       public SnackMachine(Set<Snack> snacks) { ... }
     }

    Contributing multibindings from different modules is supported. For example, it is okay to have both CandyModule and ChipsModule to both create their own Multibinder<Snack>, and to each contribute bindings to the set of snacks. When that set is injected, it will contain elements from both modules.

    The set's iteration order is consistent with the binding order. This is convenient when multiple elements are contributed by the same module because that module can order its bindings appropriately. Avoid relying on the iteration order of elements contributed by different modules, since there is no equivalent mechanism to order modules.

    The set is unmodifiable. Elements can only be added to the set by configuring the multibinder. Elements can never be removed from the set.

    Elements are resolved at set injection time. If an element is bound to a provider, that provider's get method will be called each time the set is injected (unless the binding is also scoped).

    Annotations are be used to create different sets of the same element type. Each distinct annotation gets its own independent collection of elements.

    Elements must be distinct. If multiple bound elements have the same value, set injection will fail.

    Elements must be non-null. If any set element is null, set injection will fail.

    Summary

    Public Methods
    abstract LinkedBindingBuilder<T> addBinding()
    Returns a binding builder used to add a new element in the set.
    static <T> Multibinder<T> newSetBinder(Binder binder, TypeLiteral<T> type)
    Returns a new multibinder that collects instances of type in a Set that is itself bound with no binding annotation.
    static <T> Multibinder<T> newSetBinder(Binder binder, TypeLiteral<T> type, Class<? extends Annotation> annotationType)
    Returns a new multibinder that collects instances of type in a Set that is itself bound with annotationType.
    static <T> Multibinder<T> newSetBinder(Binder binder, TypeLiteral<T> type, Annotation annotation)
    Returns a new multibinder that collects instances of type in a Set that is itself bound with annotation.
    static <T> Multibinder<T> newSetBinder(Binder binder, Class<T> type)
    Returns a new multibinder that collects instances of type in a Set that is itself bound with no binding annotation.
    static <T> Multibinder<T> newSetBinder(Binder binder, Class<T> type, Class<? extends Annotation> annotationType)
    Returns a new multibinder that collects instances of type in a Set that is itself bound with annotationType.
    static <T> Multibinder<T> newSetBinder(Binder binder, Class<T> type, Annotation annotation)
    Returns a new multibinder that collects instances of type in a Set that is itself bound with annotation.
    abstract Multibinder<T> permitDuplicates()
    Configures the bound set to silently discard duplicate elements.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Methods

    public abstract LinkedBindingBuilder<T> addBinding ()

    Returns a binding builder used to add a new element in the set. Each bound element must have a distinct value. Bound providers will be evaluated each time the set is injected.

    It is an error to call this method without also calling one of the to methods on the returned binding builder.

    Scoping elements independently is supported. Use the in method to specify a binding scope.

    public static Multibinder<T> newSetBinder (Binder binder, TypeLiteral<T> type)

    Returns a new multibinder that collects instances of type in a Set that is itself bound with no binding annotation.

    public static Multibinder<T> newSetBinder (Binder binder, TypeLiteral<T> type, Class<? extends Annotation> annotationType)

    Returns a new multibinder that collects instances of type in a Set that is itself bound with annotationType.

    public static Multibinder<T> newSetBinder (Binder binder, TypeLiteral<T> type, Annotation annotation)

    Returns a new multibinder that collects instances of type in a Set that is itself bound with annotation.

    public static Multibinder<T> newSetBinder (Binder binder, Class<T> type)

    Returns a new multibinder that collects instances of type in a Set that is itself bound with no binding annotation.

    public static Multibinder<T> newSetBinder (Binder binder, Class<T> type, Class<? extends Annotation> annotationType)

    Returns a new multibinder that collects instances of type in a Set that is itself bound with annotationType.

    public static Multibinder<T> newSetBinder (Binder binder, Class<T> type, Annotation annotation)

    Returns a new multibinder that collects instances of type in a Set that is itself bound with annotation.

    public abstract Multibinder<T> permitDuplicates ()

    Configures the bound set to silently discard duplicate elements. When multiple equal values are bound, the one that gets included is arbitrary. When multiple modules contribute elements to the set, this configuration option impacts all of them.

    Returns
    • this multibinder
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/multibindings/MapBinderBinding.html0000755000175000017500000005445511704661106030241 0ustar tonytony MapBinderBinding | Guice
    public interface

    MapBinderBinding

    com.google.inject.multibindings.MapBinderBinding<T>

    Class Overview

    A binding for a MapBinder.

    Although MapBinders may be injected through a variety of generic types (Map<K, V>, Map <K, Provider<V>>, Map<K, Set<V>>, Map>, and even Set<Map.Entry<K, Provider<V>>), a MapBinderBinding exists only on the Binding associated with the Map<K, V> key. Other bindings can be validated to be derived from this MapBinderBinding using containsElement(Element).

    Summary

    Public Methods
    abstract boolean containsElement(Element element)
    Returns true if this MapBinder contains the given Element in order to build the map or uses the given Element in order to support building and injecting the map.
    abstract List<Entry<?, Binding<?>>> getEntries()
    Returns all entries in the Map.
    abstract TypeLiteral<?> getKeyTypeLiteral()
    Returns the TypeLiteral describing the keys of the map.
    abstract Key<T> getMapKey()
    Returns the Key for the map.
    abstract TypeLiteral<?> getValueTypeLiteral()
    Returns the TypeLiteral describing the values of the map.
    abstract boolean permitsDuplicates()
    Returns true if the MapBinder permits duplicates.

    Public Methods

    public abstract boolean containsElement (Element element)

    Returns true if this MapBinder contains the given Element in order to build the map or uses the given Element in order to support building and injecting the map. This will work for MapBinderBindings retrieved from an injector and getElements(Module...). Usually this is only necessary if you are working with elements retrieved from modules (without an Injector), otherwise getEntries() and permitsDuplicates() are better options.

    If you need to introspect the details of the map, such as the keys, values or if it permits duplicates, it is necessary to pass the elements through an Injector and use getEntries() and permitsDuplicates().

    public abstract List<Entry<?, Binding<?>>> getEntries ()

    Returns all entries in the Map. The returned list of Map.Entries contains the key and a binding to the value. Duplicate keys or values will exist as separate Map.Entries in the returned list. This is only supported on bindings returned from an injector. This will throw UnsupportedOperationException if it is called on an element retrieved from getElements(Module...).

    The elements will always match the type Map's generic type. For example, if getMapKey returns a key of Map<String, Snack>, then this will always return a list of type List<Map.Entry<String, Binding<Snack>>>.

    public abstract TypeLiteral<?> getKeyTypeLiteral ()

    Returns the TypeLiteral describing the keys of the map.

    The TypeLiteral will always match the type Map's generic type. For example, if getMapKey returns a key of Map<String, Snack>, then this will always return a TypeLiteral<String>.

    public abstract Key<T> getMapKey ()

    Returns the Key for the map.

    public abstract TypeLiteral<?> getValueTypeLiteral ()

    Returns the TypeLiteral describing the values of the map.

    The TypeLiteral will always match the type Map's generic type. For example, if getMapKey returns a key of Map<String, Snack>, then this will always return a TypeLiteral<Snack>.

    public abstract boolean permitsDuplicates ()

    Returns true if the MapBinder permits duplicates. This is only supported on bindings returned from an injector. This will throw UnsupportedOperationException if it is called on a MapBinderBinding retrieved from getElements(Module...).

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/multibindings/MapBinder.html0000755000175000017500000010736011704661106026740 0ustar tonytony MapBinder | Guice
    public abstract class

    MapBinder

    extends Object
    java.lang.Object
       ↳ com.google.inject.multibindings.MapBinder<K, V>

    Class Overview

    An API to bind multiple map entries separately, only to later inject them as a complete map. MapBinder is intended for use in your application's module:

    
     public class SnacksModule extends AbstractModule {
       protected void configure() {
         MapBinder<String, Snack> mapbinder
             = MapBinder.newMapBinder(binder(), String.class, Snack.class);
         mapbinder.addBinding("twix").toInstance(new Twix());
         mapbinder.addBinding("snickers").toProvider(SnickersProvider.class);
         mapbinder.addBinding("skittles").to(Skittles.class);
       }
     }

    With this binding, a Map<String, Snack> can now be injected:

    
     class SnackMachine {
       @Inject
       public SnackMachine(Map<String, Snack> snacks) { ... }
     }

    In addition to binding Map<K, V>, a mapbinder will also bind Map<K, Provider<V>> for lazy value provision:

    
     class SnackMachine {
       @Inject
       public SnackMachine(Map<String, Provider<Snack>> snackProviders) { ... }
     }

    Contributing mapbindings from different modules is supported. For example, it is okay to have both CandyModule and ChipsModule both create their own MapBinder<String, Snack>, and to each contribute bindings to the snacks map. When that map is injected, it will contain entries from both modules.

    The map's iteration order is consistent with the binding order. This is convenient when multiple elements are contributed by the same module because that module can order its bindings appropriately. Avoid relying on the iteration order of elements contributed by different modules, since there is no equivalent mechanism to order modules.

    The map is unmodifiable. Elements can only be added to the map by configuring the MapBinder. Elements can never be removed from the map.

    Values are resolved at map injection time. If a value is bound to a provider, that provider's get method will be called each time the map is injected (unless the binding is also scoped, or a map of providers is injected).

    Annotations are used to create different maps of the same key/value type. Each distinct annotation gets its own independent map.

    Keys must be distinct. If the same key is bound more than once, map injection will fail. However, use permitDuplicates() in order to allow duplicate keys; extra bindings to Map<K, Set<V>> and Map<K, Set<Provider<V>> will be added.

    Keys must be non-null. addBinding(null) will throw an unchecked exception.

    Values must be non-null to use map injection. If any value is null, map injection will fail (although injecting a map of providers will not).

    Summary

    Public Methods
    abstract LinkedBindingBuilder<V> addBinding(K key)
    Returns a binding builder used to add a new entry in the map.
    static <K, V> MapBinder<K, V> newMapBinder(Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType)
    Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with no binding annotation.
    static <K, V> MapBinder<K, V> newMapBinder(Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType, Class<? extends Annotation> annotationType)
    Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotationType.
    static <K, V> MapBinder<K, V> newMapBinder(Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType, Annotation annotation)
    Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotation.
    static <K, V> MapBinder<K, V> newMapBinder(Binder binder, Class<K> keyType, Class<V> valueType)
    Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with no binding annotation.
    static <K, V> MapBinder<K, V> newMapBinder(Binder binder, Class<K> keyType, Class<V> valueType, Class<? extends Annotation> annotationType)
    Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotationType.
    static <K, V> MapBinder<K, V> newMapBinder(Binder binder, Class<K> keyType, Class<V> valueType, Annotation annotation)
    Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotation.
    abstract MapBinder<K, V> permitDuplicates()
    Configures the MapBinder to handle duplicate entries.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Methods

    public abstract LinkedBindingBuilder<V> addBinding (K key)

    Returns a binding builder used to add a new entry in the map. Each key must be distinct (and non-null). Bound providers will be evaluated each time the map is injected.

    It is an error to call this method without also calling one of the to methods on the returned binding builder.

    Scoping elements independently is supported. Use the in method to specify a binding scope.

    public static MapBinder<K, V> newMapBinder (Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType)

    Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with no binding annotation.

    public static MapBinder<K, V> newMapBinder (Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType, Class<? extends Annotation> annotationType)

    Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotationType.

    public static MapBinder<K, V> newMapBinder (Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType, Annotation annotation)

    Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotation.

    public static MapBinder<K, V> newMapBinder (Binder binder, Class<K> keyType, Class<V> valueType)

    Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with no binding annotation.

    public static MapBinder<K, V> newMapBinder (Binder binder, Class<K> keyType, Class<V> valueType, Class<? extends Annotation> annotationType)

    Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotationType.

    public static MapBinder<K, V> newMapBinder (Binder binder, Class<K> keyType, Class<V> valueType, Annotation annotation)

    Returns a new mapbinder that collects entries of keyType/valueType in a Map that is itself bound with annotation.

    public abstract MapBinder<K, V> permitDuplicates ()

    Configures the MapBinder to handle duplicate entries.

    When multiple equal keys are bound, the value that gets included in the map is arbitrary.

    In addition to the Map<K, V> and Map<K, Provider<V>> maps that are normally bound, a Map<K, Set<V>> and Map<K, Set<Provider<V>>> are also bound, which contain all values bound to each key.

    When multiple modules contribute elements to the map, this configuration option impacts all of them.

    Returns
    • this map binder
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/matcher/0000755000175000017500000000000011704661106022752 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/matcher/package-summary.html0000755000175000017500000002601211704661106026732 0ustar tonytony com.google.inject.matcher | Guice
    package

    com.google.inject.matcher

    Classes | Description

    Used for matching things.

    more...

    Interfaces

    Matcher<T> Returns true or false for a given input. 

    Classes

    AbstractMatcher<T> Implements and() and or()
    Matchers Matcher implementations. 
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/matcher/package-descr.html0000755000175000017500000002352111704661106026337 0ustar tonytony com.google.inject.matcher Details | Guice
    package

    com.google.inject.matcher

    Classes | Description

    Used for matching things. Primarily used to pick out methods to which to apply interceptors.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/matcher/Matchers.html0000755000175000017500000007477111704661106025431 0ustar tonytony Matchers | Guice
    public class

    Matchers

    extends Object
    java.lang.Object
       ↳ com.google.inject.matcher.Matchers

    Class Overview

    Matcher implementations. Supports matching classes and methods.

    Summary

    Public Methods
    static Matcher<AnnotatedElement> annotatedWith(Class<? extends Annotation> annotationType)
    Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.
    static Matcher<AnnotatedElement> annotatedWith(Annotation annotation)
    Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.
    static Matcher<Object> any()
    Returns a matcher which matches any input.
    static Matcher<Object> identicalTo(Object value)
    Returns a matcher which matches only the given object.
    static Matcher<Class> inPackage(Package targetPackage)
    Returns a matcher which matches classes in the given package.
    static Matcher<Class> inSubpackage(String targetPackageName)
    Returns a matcher which matches classes in the given package and its subpackages.
    static <T> Matcher<T> not(Matcher<? super T> p)
    Inverts the given matcher.
    static Matcher<Object> only(Object value)
    Returns a matcher which matches objects equal to the given object.
    static Matcher<Method> returns(Matcher<? super Class<?>> returnType)
    Returns a matcher which matches methods with matching return types.
    static Matcher<Class> subclassesOf(Class<?> superclass)
    Returns a matcher which matches subclasses of the given type (as well as the given type).
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Methods

    public static Matcher<AnnotatedElement> annotatedWith (Class<? extends Annotation> annotationType)

    Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.

    public static Matcher<AnnotatedElement> annotatedWith (Annotation annotation)

    Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.

    public static Matcher<Object> any ()

    Returns a matcher which matches any input.

    public static Matcher<Object> identicalTo (Object value)

    Returns a matcher which matches only the given object.

    public static Matcher<Class> inPackage (Package targetPackage)

    Returns a matcher which matches classes in the given package. Packages are specific to their classloader, so classes with the same package name may not have the same package at runtime.

    public static Matcher<Class> inSubpackage (String targetPackageName)

    Returns a matcher which matches classes in the given package and its subpackages. Unlike inPackage(), this matches classes from any classloader.

    public static Matcher<T> not (Matcher<? super T> p)

    Inverts the given matcher.

    public static Matcher<Object> only (Object value)

    Returns a matcher which matches objects equal to the given object.

    public static Matcher<Method> returns (Matcher<? super Class<?>> returnType)

    Returns a matcher which matches methods with matching return types.

    public static Matcher<Class> subclassesOf (Class<?> superclass)

    Returns a matcher which matches subclasses of the given type (as well as the given type).

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/matcher/Matcher.html0000755000175000017500000004140311704661106025230 0ustar tonytony Matcher | Guice
    public interface

    Matcher

    com.google.inject.matcher.Matcher<T>
    Known Indirect Subclasses

    Class Overview

    Returns true or false for a given input.

    Summary

    Public Methods
    abstract Matcher<T> and(Matcher<? super T> other)
    Returns a new matcher which returns true if both this and the given matcher return true.
    abstract boolean matches(T t)
    Returns true if this matches t, false otherwise.
    abstract Matcher<T> or(Matcher<? super T> other)
    Returns a new matcher which returns true if either this or the given matcher return true.

    Public Methods

    public abstract Matcher<T> and (Matcher<? super T> other)

    Returns a new matcher which returns true if both this and the given matcher return true.

    public abstract boolean matches (T t)

    Returns true if this matches t, false otherwise.

    public abstract Matcher<T> or (Matcher<? super T> other)

    Returns a new matcher which returns true if either this or the given matcher return true.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/matcher/AbstractMatcher.html0000755000175000017500000005644211704661106026725 0ustar tonytony AbstractMatcher | Guice
    public abstract class

    AbstractMatcher

    extends Object
    implements Matcher<T>
    java.lang.Object
       ↳ com.google.inject.matcher.AbstractMatcher<T>

    Class Overview

    Implements and() and or().

    Summary

    Public Constructors
    AbstractMatcher()
    Public Methods
    Matcher<T> and(Matcher<? super T> other)
    Returns a new matcher which returns true if both this and the given matcher return true.
    Matcher<T> or(Matcher<? super T> other)
    Returns a new matcher which returns true if either this or the given matcher return true.
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.matcher.Matcher

    Public Constructors

    public AbstractMatcher ()

    Public Methods

    public Matcher<T> and (Matcher<? super T> other)

    Returns a new matcher which returns true if both this and the given matcher return true.

    public Matcher<T> or (Matcher<? super T> other)

    Returns a new matcher which returns true if either this or the given matcher return true.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/jndi/0000755000175000017500000000000011704661106022253 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/jndi/package-summary.html0000755000175000017500000002400211704661106026230 0ustar tonytony com.google.inject.jndi | Guice
    package

    com.google.inject.jndi

    Classes | Description

    JNDI integration; this extension requires guice-jndi-3.0.jar.

    more...

    Classes

    JndiIntegration Integrates Guice with JNDI. 
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/jndi/package-descr.html0000755000175000017500000002276211704661106025646 0ustar tonytony com.google.inject.jndi Details | Guice
    package

    com.google.inject.jndi

    Classes | Description

    JNDI integration; this extension requires guice-jndi-3.0.jar.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/jndi/JndiIntegration.html0000755000175000017500000004155311704661106026244 0ustar tonytony JndiIntegration | Guice
    public class

    JndiIntegration

    extends Object
    java.lang.Object
       ↳ com.google.inject.jndi.JndiIntegration

    Class Overview

    Integrates Guice with JNDI. Requires a binding to javax.naming.Context.

    Summary

    Public Methods
    static <T> Provider<T> fromJndi(Class<T> type, String name)
    Creates a provider which looks up objects in JNDI using the given name.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Methods

    public static Provider<T> fromJndi (Class<T> type, String name)

    Creates a provider which looks up objects in JNDI using the given name. Example usage:

     bind(DataSource.class).toProvider(fromJndi(DataSource.class, "java:..."));
     

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/0000755000175000017500000000000011704661106022757 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/package-summary.html0000755000175000017500000005275311704661106026752 0ustar tonytony com.google.inject.grapher | Guice
    package

    com.google.inject.grapher

    Interfaces

    BindingEdge<K> Interface for an edge that connects an interface to the type or instance that is bound to implement it. 
    BindingEdge.Factory<K, T extends BindingEdge<K>> Factory interface for BindingEdges. 
    DependencyEdge<K> Interface for an edge from a class or InjectionPoint to the interface node that will satisfy the dependency. 
    DependencyEdge.Factory<K, T extends DependencyEdge<K>> Factory interface for DependencyEdges. 
    ImplementationNode<K> Node for classes and instances that have Dependencys and are bound to InterfaceNodes. 
    ImplementationNode.Factory<K, T extends ImplementationNode<K>> Factory interface for ImplementationNodes. 
    InterfaceNode<K> Node for an interface class that has been bound to an implementation class or instance. 
    InterfaceNode.Factory<K, T extends InterfaceNode<K>> Factory interface for InterfaceNodes. 
    NameFactory Interface for a service that provides nice Strings that we can display in the graph for the types that come up in Bindings. 
    NodeAliasFactory<K> Factory for aliasing one node ID to another. 
    NodeIdFactory<K> Factory for abstract identifiers for elements on the graph. 
    Renderer Interface for the service that renders the graph. 

    Classes

    GrapherModule Module for the common bindings for InjectorGrapher
    GraphingVisitor<K, N extends InterfaceNode<K>, M extends ImplementationNode<K>, B extends BindingEdge<K>, D extends DependencyEdge<K>> BindingTargetVisitor that adds nodes and edges to the graph based on the visited Binding
    InjectorGrapher Root class for graphing an Injector
    ShortNameFactory Reasonable implementation for NameFactory
    StringNodeIdFactory IdFactory implementation that for String node IDs. 
    TransitiveDependencyVisitor BindingTargetVisitor that returns a Collection of the Keys of each Binding's dependencies. 

    Enums

    BindingEdge.Type Classification for what kind of binding this edge represents. 
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/package-descr.html0000755000175000017500000003206211704661106026344 0ustar tonytony com.google.inject.grapher Details | Guice
    package

    com.google.inject.grapher

    Classes | Description

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/0000755000175000017500000000000011704661106024611 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/package-summary.html0000755000175000017500000005155011704661106030576 0ustar tonytony com.google.inject.grapher.graphviz | Guice
    package

    com.google.inject.grapher.graphviz

    Interfaces

    PortIdFactory Interface for a service that returns Graphviz port IDs, used for naming the rows in ImplementationNode-displaying GraphvizNodes. 

    Classes

    BindingEdgeFactory Graphviz-specific implementation of BindingEdge.Factory
    BindingEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts BindingEdge methods to display operations on a GraphvizEdge
    DependencyEdgeFactory Graphviz-specific implementation of DependencyEdge.Factory
    DependencyEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts DependencyEdge methods to display operations on a GraphvizEdge
    GraphvizEdge Data object to encapsulate the attributes of Graphviz edges that we're interested in drawing. 
    GraphvizModule Module that provides GraphvizRenderer as the Renderer and binds the other Graphviz factories. 
    GraphvizNode Data object to encapsulate the attributes of Graphviz nodes that we're interested in drawing. 
    GraphvizRenderer Renderer implementation that writes out a Graphviz DOT file of the graph. 
    ImplementationNodeFactory Graphviz-specific implementation of ImplementationNode.Factory
    ImplementationNodeFactory.GraphvizNodeAdaptor Adaptor class that converts ImplementationNode methods to display operations on a GraphvizNode
    InterfaceNodeFactory Graphviz-specific implementation of InterfaceNode.Factory
    InterfaceNodeFactory.GraphvizNodeAdaptor Adaptor class that converts InterfaceNode methods to display operations on a GraphvizNode
    PortIdFactoryImpl Implementation of PortIdFactory

    Enums

    ArrowType Arrow symbols that are available from Graphviz. 
    CompassPoint Enum for the "compass point" values used to control where edge end points appear on the graph. 
    EdgeStyle Styles for edges. 
    NodeShape Enum for the shapes that are most interesting for Guice graphing. 
    NodeStyle Styles for nodes. 
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/package-descr.html0000755000175000017500000003075511704661106030205 0ustar tonytony com.google.inject.grapher.graphviz Details | Guice
    package

    com.google.inject.grapher.graphviz

    Classes | Description

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/PortIdFactoryImpl.html0000755000175000017500000005503611704661106031066 0ustar tonytony PortIdFactoryImpl | Guice
    public class

    PortIdFactoryImpl

    extends Object
    implements PortIdFactory
    java.lang.Object
       ↳ com.google.inject.grapher.graphviz.PortIdFactoryImpl

    Class Overview

    Implementation of PortIdFactory. Bound in GraphvizModule.

    Summary

    Public Constructors
    PortIdFactoryImpl()
    Public Methods
    String getPortId(Member member)
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.grapher.graphviz.PortIdFactory

    Public Constructors

    public PortIdFactoryImpl ()

    Public Methods

    public String getPortId (Member member)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/PortIdFactory.html0000755000175000017500000004065011704661106030240 0ustar tonytony PortIdFactory | Guice
    public interface

    PortIdFactory

    com.google.inject.grapher.graphviz.PortIdFactory
    Known Indirect Subclasses

    Class Overview

    Interface for a service that returns Graphviz port IDs, used for naming the rows in ImplementationNode-displaying GraphvizNodes. Implemented by StringNodeIdFactory.

    Summary

    Public Methods
    abstract String getPortId(Member member)

    Public Methods

    public abstract String getPortId (Member member)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/NodeStyle.html0000755000175000017500000010522411704661106027414 0ustar tonytony NodeStyle | Guice
    public final enum

    NodeStyle

    extends Enum<E extends Enum<E>>
    java.lang.Object
       ↳ java.lang.Enum<E extends java.lang.Enum<E>>
         ↳ com.google.inject.grapher.graphviz.NodeStyle

    Class Overview

    Styles for nodes. Similar to EdgeStyle but with a few more options.

    See: http://www.graphviz.org/doc/info/attrs.html#k:style

    Summary

    Enum Values
    NodeStyle  BOLD   
    NodeStyle  DASHED   
    NodeStyle  DIAGONALS   
    NodeStyle  DOTTED   
    NodeStyle  FILLED   
    NodeStyle  INVISIBLE   
    NodeStyle  ROUNDED   
    NodeStyle  SOLID   
    Public Methods
    String toString()
    static NodeStyle valueOf(String name)
    final static NodeStyle[] values()
    [Expand]
    Inherited Methods
    From class java.lang.Enum
    From class java.lang.Object
    From interface java.lang.Comparable

    Enum Values

    public static final NodeStyle BOLD

    Since: API Level

    public static final NodeStyle DASHED

    Since: API Level

    public static final NodeStyle DIAGONALS

    Since: API Level

    public static final NodeStyle DOTTED

    Since: API Level

    public static final NodeStyle FILLED

    Since: API Level

    public static final NodeStyle INVISIBLE

    Since: API Level

    public static final NodeStyle ROUNDED

    Since: API Level

    public static final NodeStyle SOLID

    Since: API Level

    Public Methods

    public String toString ()

    Since: API Level

    public static NodeStyle valueOf (String name)

    public static final NodeStyle[] values ()

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/NodeShape.html0000755000175000017500000007436311704661106027365 0ustar tonytony NodeShape | Guice
    public final enum

    NodeShape

    extends Enum<E extends Enum<E>>
    java.lang.Object
       ↳ java.lang.Enum<E extends java.lang.Enum<E>>
         ↳ com.google.inject.grapher.graphviz.NodeShape

    Class Overview

    Enum for the shapes that are most interesting for Guice graphing.

    See: http://www.graphviz.org/doc/info/shapes.html

    Summary

    Enum Values
    NodeShape  BOX   
    NodeShape  ELLIPSE   
    NodeShape  NONE   
    Public Methods
    String toString()
    static NodeShape valueOf(String name)
    final static NodeShape[] values()
    [Expand]
    Inherited Methods
    From class java.lang.Enum
    From class java.lang.Object
    From interface java.lang.Comparable

    Enum Values

    public static final NodeShape BOX

    Since: API Level

    public static final NodeShape ELLIPSE

    Since: API Level

    public static final NodeShape NONE

    Since: API Level

    Public Methods

    public String toString ()

    Since: API Level

    public static NodeShape valueOf (String name)

    public static final NodeShape[] values ()

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/InterfaceNodeFactory.html0000755000175000017500000006106011704661106031543 0ustar tonytony InterfaceNodeFactory | Guice
    public class

    InterfaceNodeFactory

    extends Object
    implements InterfaceNode.Factory<K, T extends InterfaceNode<K>>
    java.lang.Object
       ↳ com.google.inject.grapher.graphviz.InterfaceNodeFactory

    Class Overview

    Graphviz-specific implementation of InterfaceNode.Factory. Uses a GraphvizEdgeAdaptor to delegate to a GraphvizNode.

    Summary

    Nested Classes
    class InterfaceNodeFactory.GraphvizNodeAdaptor Adaptor class that converts InterfaceNode methods to display operations on a GraphvizNode
    Public Constructors
    InterfaceNodeFactory(GraphvizRenderer renderer, NameFactory nameFactory)
    Public Methods
    InterfaceNode<String> newInterfaceNode(String nodeId)
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.grapher.InterfaceNode.Factory

    Public Constructors

    public InterfaceNodeFactory (GraphvizRenderer renderer, NameFactory nameFactory)

    Public Methods

    public InterfaceNode<String> newInterfaceNode (String nodeId)

    ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/InterfaceNodeFactory.GraphvizNodeAdaptor.htmlsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/InterfaceNodeFactory.Graphviz0000755000175000017500000006371511704661106032402 0ustar tonytony InterfaceNodeFactory.GraphvizNodeAdaptor | Guice
    protected class

    InterfaceNodeFactory.GraphvizNodeAdaptor

    extends Object
    implements InterfaceNode<K>
    java.lang.Object
       ↳ com.google.inject.grapher.graphviz.InterfaceNodeFactory.GraphvizNodeAdaptor

    Class Overview

    Adaptor class that converts InterfaceNode methods to display operations on a GraphvizNode.

    Summary

    Fields
    protected final GraphvizNode node
    Public Constructors
    InterfaceNodeFactory.GraphvizNodeAdaptor(GraphvizNode node)
    Public Methods
    void setKey(Key<?> key)
    void setSource(Object source)
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.grapher.InterfaceNode

    Fields

    protected final GraphvizNode node

    Public Constructors

    public InterfaceNodeFactory.GraphvizNodeAdaptor (GraphvizNode node)

    Public Methods

    public void setKey (Key<?> key)

    public void setSource (Object source)

    ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/ImplementationNodeFactory.htmlsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/ImplementationNodeFactory.htm0000755000175000017500000006605311704661106032463 0ustar tonytony ImplementationNodeFactory | Guice
    public class

    ImplementationNodeFactory

    extends Object
    implements ImplementationNode.Factory<K, T extends ImplementationNode<K>>
    java.lang.Object
       ↳ com.google.inject.grapher.graphviz.ImplementationNodeFactory

    Class Overview

    Graphviz-specific implementation of ImplementationNode.Factory. Uses a BindingEdgeFactory.GraphvizEdgeAdaptor to delegate to a GraphvizNode.

    Summary

    Nested Classes
    class ImplementationNodeFactory.GraphvizNodeAdaptor Adaptor class that converts ImplementationNode methods to display operations on a GraphvizNode
    Public Constructors
    ImplementationNodeFactory(GraphvizRenderer renderer, NameFactory nameFactory, PortIdFactory portIdFactory)
    Public Methods
    ImplementationNode<String> newImplementationNode(String nodeId)
    Protected Methods
    ImplementationNodeFactory.GraphvizNodeAdaptor newAdaptor(GraphvizNode node)
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.grapher.ImplementationNode.Factory

    Public Constructors

    public ImplementationNodeFactory (GraphvizRenderer renderer, NameFactory nameFactory, PortIdFactory portIdFactory)

    Public Methods

    public ImplementationNode<String> newImplementationNode (String nodeId)

    Protected Methods

    ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/ImplementationNodeFactory.GraphvizNodeAdaptor.htmlsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/ImplementationNodeFactory.Gra0000755000175000017500000007372711704661106032412 0ustar tonytony ImplementationNodeFactory.GraphvizNodeAdaptor | Guice
    protected class

    ImplementationNodeFactory.GraphvizNodeAdaptor

    extends Object
    implements ImplementationNode<K>
    java.lang.Object
       ↳ com.google.inject.grapher.graphviz.ImplementationNodeFactory.GraphvizNodeAdaptor

    Class Overview

    Adaptor class that converts ImplementationNode methods to display operations on a GraphvizNode.

    Summary

    Fields
    protected final GraphvizNode node
    Public Constructors
    ImplementationNodeFactory.GraphvizNodeAdaptor(GraphvizNode node)
    Public Methods
    void addMember(Member member)
    void setClassKey(Key<?> key)
    Sets the Key that this node is for.
    void setInstance(Object instance)
    Sets the Object that's the already-created instance.
    void setSource(Object source)
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.grapher.ImplementationNode

    Fields

    protected final GraphvizNode node

    Public Constructors

    public ImplementationNodeFactory.GraphvizNodeAdaptor (GraphvizNode node)

    Public Methods

    public void addMember (Member member)

    public void setClassKey (Key<?> key)

    Sets the Key that this node is for. Used when the node is representing a class that Guice will instantiate.

    public void setInstance (Object instance)

    Sets the Object that's the already-created instance. Used when this node is represeting the instance instead of a class.

    public void setSource (Object source)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/GraphvizRenderer.html0000755000175000017500000013375311704661106030777 0ustar tonytony GraphvizRenderer | Guice
    public class

    GraphvizRenderer

    extends Object
    implements NodeAliasFactory<K> Renderer
    java.lang.Object
       ↳ com.google.inject.grapher.graphviz.GraphvizRenderer

    Class Overview

    Renderer implementation that writes out a Graphviz DOT file of the graph. Bound in GraphvizModule.

    Specify the PrintWriter to output to with setOut(PrintWriter).

    Summary

    Public Constructors
    GraphvizRenderer()
    Public Methods
    void addEdge(GraphvizEdge edge)
    void addNode(GraphvizNode node)
    void newAlias(String fromId, String toId)
    void render()
    GraphvizRenderer setOut(PrintWriter out)
    GraphvizRenderer setRankdir(String rankdir)
    Protected Methods
    void finish()
    String getArrowString(List<ArrowType> arrows)
    Turns a List of ArrowTypes into a String that represents combining them.
    Map<String, String> getEdgeAttributes(GraphvizEdge edge)
    String getEdgeEndPoint(String nodeId, String portId, CompassPoint compassPoint)
    Map<String, String> getGraphAttributes()
    Map<String, String> getNodeAttributes(GraphvizNode node)
    String getNodeLabel(GraphvizNode node)
    Creates the "label" for a node.
    String htmlEscape(String str)
    void renderEdge(GraphvizEdge edge)
    void renderNode(GraphvizNode node)
    String resolveAlias(String id)
    void start()
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.grapher.NodeAliasFactory
    From interface com.google.inject.grapher.Renderer

    Public Constructors

    public GraphvizRenderer ()

    Public Methods

    public void addEdge (GraphvizEdge edge)

    public void addNode (GraphvizNode node)

    public void newAlias (String fromId, String toId)

    public void render ()

    public GraphvizRenderer setOut (PrintWriter out)

    public GraphvizRenderer setRankdir (String rankdir)

    Protected Methods

    protected void finish ()

    protected String getArrowString (List<ArrowType> arrows)

    Turns a List of ArrowTypes into a String that represents combining them. With Graphviz, that just means concatenating them.

    protected Map<String, String> getEdgeAttributes (GraphvizEdge edge)

    protected String getEdgeEndPoint (String nodeId, String portId, CompassPoint compassPoint)

    protected Map<String, String> getGraphAttributes ()

    protected Map<String, String> getNodeAttributes (GraphvizNode node)

    protected String getNodeLabel (GraphvizNode node)

    Creates the "label" for a node. This is a string of HTML that defines a table with a heading at the top and (in the case of ImplementationNodes) rows for each of the member fields.

    protected String htmlEscape (String str)

    protected void renderEdge (GraphvizEdge edge)

    protected void renderNode (GraphvizNode node)

    protected String resolveAlias (String id)

    protected void start ()

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/GraphvizNode.html0000755000175000017500000011052311704661106030104 0ustar tonytony GraphvizNode | Guice
    public class

    GraphvizNode

    extends Object
    java.lang.Object
       ↳ com.google.inject.grapher.graphviz.GraphvizNode

    Class Overview

    Data object to encapsulate the attributes of Graphviz nodes that we're interested in drawing.

    Summary

    Public Constructors
    GraphvizNode(String nodeId)
    Public Methods
    void addField(String portId, String title)
    void addSubtitle(int position, String subtitle)
    Map<String, String> getFields()
    String getHeaderBackgroundColor()
    String getHeaderTextColor()
    String getNodeId()
    NodeShape getShape()
    NodeStyle getStyle()
    List<String> getSubtitles()
    String getTitle()
    void setHeaderBackgroundColor(String headerBackgroundColor)
    void setHeaderTextColor(String headerTextColor)
    void setShape(NodeShape shape)
    void setStyle(NodeStyle style)
    void setTitle(String title)
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Constructors

    public GraphvizNode (String nodeId)

    Public Methods

    public void addField (String portId, String title)

    public void addSubtitle (int position, String subtitle)

    public Map<String, String> getFields ()

    public String getHeaderBackgroundColor ()

    public String getHeaderTextColor ()

    public String getNodeId ()

    public NodeShape getShape ()

    public NodeStyle getStyle ()

    public List<String> getSubtitles ()

    public String getTitle ()

    public void setHeaderBackgroundColor (String headerBackgroundColor)

    public void setHeaderTextColor (String headerTextColor)

    public void setShape (NodeShape shape)

    public void setStyle (NodeStyle style)

    public void setTitle (String title)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/GraphvizModule.html0000755000175000017500000011272211704661106030447 0ustar tonytony GraphvizModule | Guice
    public class

    GraphvizModule

    extends AbstractModule
    java.lang.Object
       ↳ com.google.inject.AbstractModule
         ↳ com.google.inject.grapher.graphviz.GraphvizModule

    Class Overview

    Module that provides GraphvizRenderer as the Renderer and binds the other Graphviz factories.

    Summary

    Public Constructors
    GraphvizModule()
    Protected Methods
    void configure()
    Configures a Binder via the exposed methods.
    [Expand]
    Inherited Methods
    From class com.google.inject.AbstractModule
    From class java.lang.Object
    From interface com.google.inject.Module

    Public Constructors

    public GraphvizModule ()

    Protected Methods

    protected void configure ()

    Configures a Binder via the exposed methods.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/GraphvizEdge.html0000755000175000017500000011533011704661106030064 0ustar tonytony GraphvizEdge | Guice
    public class

    GraphvizEdge

    extends Object
    java.lang.Object
       ↳ com.google.inject.grapher.graphviz.GraphvizEdge

    Class Overview

    Data object to encapsulate the attributes of Graphviz edges that we're interested in drawing.

    Summary

    Public Constructors
    GraphvizEdge(String tailNodeId, String headNodeId)
    Public Methods
    List<ArrowType> getArrowHead()
    List<ArrowType> getArrowTail()
    CompassPoint getHeadCompassPoint()
    String getHeadNodeId()
    String getHeadPortId()
    EdgeStyle getStyle()
    CompassPoint getTailCompassPoint()
    String getTailNodeId()
    String getTailPortId()
    void setArrowHead(List<ArrowType> arrowHead)
    void setArrowTail(List<ArrowType> arrowTail)
    void setHeadCompassPoint(CompassPoint headCompassPoint)
    void setHeadPortId(String headPortId)
    void setStyle(EdgeStyle style)
    void setTailCompassPoint(CompassPoint tailCompassPoint)
    void setTailPortId(String tailPortId)
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Constructors

    public GraphvizEdge (String tailNodeId, String headNodeId)

    Public Methods

    public List<ArrowType> getArrowHead ()

    public List<ArrowType> getArrowTail ()

    public CompassPoint getHeadCompassPoint ()

    public String getHeadNodeId ()

    public String getHeadPortId ()

    public EdgeStyle getStyle ()

    public CompassPoint getTailCompassPoint ()

    public String getTailNodeId ()

    public String getTailPortId ()

    public void setArrowHead (List<ArrowType> arrowHead)

    public void setArrowTail (List<ArrowType> arrowTail)

    public void setHeadCompassPoint (CompassPoint headCompassPoint)

    public void setHeadPortId (String headPortId)

    public void setStyle (EdgeStyle style)

    public void setTailCompassPoint (CompassPoint tailCompassPoint)

    public void setTailPortId (String tailPortId)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/EdgeStyle.html0000755000175000017500000007766311704661106027412 0ustar tonytony EdgeStyle | Guice
    public final enum

    EdgeStyle

    extends Enum<E extends Enum<E>>
    java.lang.Object
       ↳ java.lang.Enum<E extends java.lang.Enum<E>>
         ↳ com.google.inject.grapher.graphviz.EdgeStyle

    Class Overview

    Styles for edges.

    See: http://www.graphviz.org/doc/info/attrs.html#k:style

    Summary

    Enum Values
    EdgeStyle  BOLD   
    EdgeStyle  DASHED   
    EdgeStyle  DOTTED   
    EdgeStyle  INVISIBLE   
    EdgeStyle  SOLID   
    Public Methods
    String toString()
    static EdgeStyle valueOf(String name)
    final static EdgeStyle[] values()
    [Expand]
    Inherited Methods
    From class java.lang.Enum
    From class java.lang.Object
    From interface java.lang.Comparable

    Enum Values

    public static final EdgeStyle BOLD

    Since: API Level

    public static final EdgeStyle DASHED

    Since: API Level

    public static final EdgeStyle DOTTED

    Since: API Level

    public static final EdgeStyle INVISIBLE

    Since: API Level

    public static final EdgeStyle SOLID

    Since: API Level

    Public Methods

    public String toString ()

    Since: API Level

    public static EdgeStyle valueOf (String name)

    public static final EdgeStyle[] values ()

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/DependencyEdgeFactory.html0000755000175000017500000006611711704661106031710 0ustar tonytony DependencyEdgeFactory | Guice
    public class

    DependencyEdgeFactory

    extends Object
    implements DependencyEdge.Factory<K, T extends DependencyEdge<K>>
    java.lang.Object
       ↳ com.google.inject.grapher.graphviz.DependencyEdgeFactory

    Class Overview

    Graphviz-specific implementation of DependencyEdge.Factory. Uses a DependencyEdgeFactory.GraphvizEdgeAdaptor to delegate to a GraphvizEdge.

    Summary

    Nested Classes
    class DependencyEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts DependencyEdge methods to display operations on a GraphvizEdge
    Public Constructors
    DependencyEdgeFactory(GraphvizRenderer renderer, PortIdFactory portIdFactory)
    Public Methods
    DependencyEdge<String> newDependencyEdge(String fromId, InjectionPoint fromPoint, String toId)
    Protected Methods
    DependencyEdgeFactory.GraphvizEdgeAdaptor newAdaptor(GraphvizEdge edge)
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.grapher.DependencyEdge.Factory

    Public Constructors

    public DependencyEdgeFactory (GraphvizRenderer renderer, PortIdFactory portIdFactory)

    Public Methods

    public DependencyEdge<String> newDependencyEdge (String fromId, InjectionPoint fromPoint, String toId)

    Protected Methods

    ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/DependencyEdgeFactory.GraphvizEdgeAdaptor.htmlsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/DependencyEdgeFactory.Graphvi0000755000175000017500000005317411704661106032343 0ustar tonytony DependencyEdgeFactory.GraphvizEdgeAdaptor | Guice
    protected class

    DependencyEdgeFactory.GraphvizEdgeAdaptor

    extends Object
    implements DependencyEdge<K>
    java.lang.Object
       ↳ com.google.inject.grapher.graphviz.DependencyEdgeFactory.GraphvizEdgeAdaptor

    Class Overview

    Adaptor class that converts DependencyEdge methods to display operations on a GraphvizEdge.

    Summary

    Fields
    protected final GraphvizEdge edge
    Public Constructors
    DependencyEdgeFactory.GraphvizEdgeAdaptor(GraphvizEdge edge)
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Fields

    protected final GraphvizEdge edge

    Public Constructors

    public DependencyEdgeFactory.GraphvizEdgeAdaptor (GraphvizEdge edge)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/CompassPoint.html0000755000175000017500000011077411704661106030133 0ustar tonytony CompassPoint | Guice
    public final enum

    CompassPoint

    extends Enum<E extends Enum<E>>
    java.lang.Object
       ↳ java.lang.Enum<E extends java.lang.Enum<E>>
         ↳ com.google.inject.grapher.graphviz.CompassPoint

    Class Overview

    Enum for the "compass point" values used to control where edge end points appear on the graph.

    See: http://www.graphviz.org/doc/info/attrs.html#k:portPos

    Summary

    Enum Values
    CompassPoint  CENTER   
    CompassPoint  EAST   
    CompassPoint  EXTERIOR_SIDE   
    CompassPoint  NORTH   
    CompassPoint  NORTH_EAST   
    CompassPoint  NORTH_WEST   
    CompassPoint  SOUTH   
    CompassPoint  SOUTH_EAST   
    CompassPoint  SOUTH_WEST   
    CompassPoint  WEST   
    Public Methods
    String toString()
    static CompassPoint valueOf(String name)
    final static CompassPoint[] values()
    [Expand]
    Inherited Methods
    From class java.lang.Enum
    From class java.lang.Object
    From interface java.lang.Comparable

    Enum Values

    public static final CompassPoint CENTER

    Since: API Level

    public static final CompassPoint EAST

    Since: API Level

    public static final CompassPoint EXTERIOR_SIDE

    Since: API Level

    public static final CompassPoint NORTH

    Since: API Level

    public static final CompassPoint NORTH_EAST

    Since: API Level

    public static final CompassPoint NORTH_WEST

    Since: API Level

    public static final CompassPoint SOUTH

    Since: API Level

    public static final CompassPoint SOUTH_EAST

    Since: API Level

    public static final CompassPoint SOUTH_WEST

    Since: API Level

    public static final CompassPoint WEST

    Since: API Level

    Public Methods

    public String toString ()

    Since: API Level

    public static CompassPoint valueOf (String name)

    public static final CompassPoint[] values ()

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/BindingEdgeFactory.html0000755000175000017500000006436511704661106031207 0ustar tonytony BindingEdgeFactory | Guice
    public class

    BindingEdgeFactory

    extends Object
    implements BindingEdge.Factory<K, T extends BindingEdge<K>>
    java.lang.Object
       ↳ com.google.inject.grapher.graphviz.BindingEdgeFactory

    Class Overview

    Graphviz-specific implementation of BindingEdge.Factory. Uses a BindingEdgeFactory.GraphvizEdgeAdaptor to delegate to a GraphvizEdge.

    Summary

    Nested Classes
    class BindingEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts BindingEdge methods to display operations on a GraphvizEdge
    Public Constructors
    BindingEdgeFactory(GraphvizRenderer renderer)
    Public Methods
    BindingEdge<String> newBindingEdge(String fromId, String toId)
    Protected Methods
    BindingEdgeFactory.GraphvizEdgeAdaptor newAdaptor(GraphvizEdge edge)
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.grapher.BindingEdge.Factory

    Public Constructors

    public BindingEdgeFactory (GraphvizRenderer renderer)

    Public Methods

    public BindingEdge<String> newBindingEdge (String fromId, String toId)

    Protected Methods

    ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/BindingEdgeFactory.GraphvizEdgeAdaptor.htmlsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/BindingEdgeFactory.GraphvizEd0000755000175000017500000006104111704661106032272 0ustar tonytony BindingEdgeFactory.GraphvizEdgeAdaptor | Guice
    protected class

    BindingEdgeFactory.GraphvizEdgeAdaptor

    extends Object
    implements BindingEdge<K>
    java.lang.Object
       ↳ com.google.inject.grapher.graphviz.BindingEdgeFactory.GraphvizEdgeAdaptor

    Class Overview

    Adaptor class that converts BindingEdge methods to display operations on a GraphvizEdge.

    Summary

    Fields
    protected final GraphvizEdge edge
    Public Constructors
    BindingEdgeFactory.GraphvizEdgeAdaptor(GraphvizEdge edge)
    Public Methods
    void setType(BindingEdge.Type type)
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.grapher.BindingEdge

    Fields

    protected final GraphvizEdge edge

    Public Constructors

    public BindingEdgeFactory.GraphvizEdgeAdaptor (GraphvizEdge edge)

    Public Methods

    public void setType (BindingEdge.Type type)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/graphviz/ArrowType.html0000755000175000017500000011741311704661106027445 0ustar tonytony ArrowType | Guice
    public final enum

    ArrowType

    extends Enum<E extends Enum<E>>
    java.lang.Object
       ↳ java.lang.Enum<E extends java.lang.Enum<E>>
         ↳ com.google.inject.grapher.graphviz.ArrowType

    Class Overview

    Arrow symbols that are available from Graphviz. These can be composed by concatenation to make double arrows and such.

    See: http://www.graphviz.org/doc/info/arrows.html

    Summary

    Enum Values
    ArrowType  BOX   
    ArrowType  BOX_OPEN   
    ArrowType  CROW   
    ArrowType  DIAMOND   
    ArrowType  DIAMOND_OPEN   
    ArrowType  DOT   
    ArrowType  DOT_OPEN   
    ArrowType  INVERTED   
    ArrowType  INVERTED_OPEN   
    ArrowType  NONE   
    ArrowType  NORMAL   
    ArrowType  NORMAL_OPEN   
    ArrowType  TEE   
    ArrowType  VEE   
    Public Methods
    String toString()
    static ArrowType valueOf(String name)
    final static ArrowType[] values()
    [Expand]
    Inherited Methods
    From class java.lang.Enum
    From class java.lang.Object
    From interface java.lang.Comparable

    Enum Values

    public static final ArrowType BOX

    Since: API Level

    public static final ArrowType BOX_OPEN

    Since: API Level

    public static final ArrowType CROW

    Since: API Level

    public static final ArrowType DIAMOND

    Since: API Level

    public static final ArrowType DIAMOND_OPEN

    Since: API Level

    public static final ArrowType DOT

    Since: API Level

    public static final ArrowType DOT_OPEN

    Since: API Level

    public static final ArrowType INVERTED

    Since: API Level

    public static final ArrowType INVERTED_OPEN

    Since: API Level

    public static final ArrowType NONE

    Since: API Level

    public static final ArrowType NORMAL

    Since: API Level

    public static final ArrowType NORMAL_OPEN

    Since: API Level

    public static final ArrowType TEE

    Since: API Level

    public static final ArrowType VEE

    Since: API Level

    Public Methods

    public String toString ()

    Since: API Level

    public static ArrowType valueOf (String name)

    public static final ArrowType[] values ()

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/TransitiveDependencyVisitor.html0000755000175000017500000012104011704661106031355 0ustar tonytony TransitiveDependencyVisitor | Guice
    public class

    TransitiveDependencyVisitor

    extends Object
    implements BindingTargetVisitor<T, V>
    java.lang.Object
       ↳ com.google.inject.grapher.TransitiveDependencyVisitor

    Class Overview

    BindingTargetVisitor that returns a Collection of the Keys of each Binding's dependencies. Used by InjectorGropher to walk the dependency graph from a starting set of Bindings.

    Summary

    Public Constructors
    TransitiveDependencyVisitor()
    Public Methods
    Collection<Key<?>> visit(ConstructorBinding<?> binding)
    Collection<Key<?>> visit(ConvertedConstantBinding<?> binding)
    Collection<Key<?>> visit(ExposedBinding<?> binding)
    Collection<Key<?>> visit(InstanceBinding<?> binding)
    Collection<Key<?>> visit(LinkedKeyBinding<?> binding)
    Collection<Key<?>> visit(ProviderBinding<?> binding)
    Collection<Key<?>> visit(ProviderInstanceBinding<?> binding)
    Collection<Key<?>> visit(ProviderKeyBinding<?> binding)
    Collection<Key<?>> visit(UntargettedBinding<?> binding)
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.BindingTargetVisitor

    Public Constructors

    public TransitiveDependencyVisitor ()

    Public Methods

    public Collection<Key<?>> visit (ConstructorBinding<?> binding)

    public Collection<Key<?>> visit (ConvertedConstantBinding<?> binding)

    public Collection<Key<?>> visit (ExposedBinding<?> binding)

    public Collection<Key<?>> visit (InstanceBinding<?> binding)

    public Collection<Key<?>> visit (LinkedKeyBinding<?> binding)

    public Collection<Key<?>> visit (ProviderBinding<?> binding)

    public Collection<Key<?>> visit (ProviderInstanceBinding<?> binding)

    public Collection<Key<?>> visit (ProviderKeyBinding<?> binding)

    public Collection<Key<?>> visit (UntargettedBinding<?> binding)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/StringNodeIdFactory.html0000755000175000017500000006142211704661106027536 0ustar tonytony StringNodeIdFactory | Guice
    public class

    StringNodeIdFactory

    extends Object
    implements NodeIdFactory<K>
    java.lang.Object
       ↳ com.google.inject.grapher.StringNodeIdFactory

    Class Overview

    IdFactory implementation that for String node IDs. The IDs are comprised of letters, numbers and underscores.

    Summary

    Public Constructors
    StringNodeIdFactory()
    Public Methods
    String getClassNodeId(Key<?> key)
    String getInstanceNodeId(Key<?> key)
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.grapher.NodeIdFactory

    Public Constructors

    public StringNodeIdFactory ()

    Public Methods

    public String getClassNodeId (Key<?> key)

    public String getInstanceNodeId (Key<?> key)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/ShortNameFactory.html0000755000175000017500000010024311704661106027100 0ustar tonytony ShortNameFactory | Guice
    public class

    ShortNameFactory

    extends Object
    implements NameFactory
    java.lang.Object
       ↳ com.google.inject.grapher.ShortNameFactory

    Class Overview

    Reasonable implementation for NameFactory. Mostly takes various toString()s and strips package names out of them so that they'll fit on the graph.

    Summary

    Public Constructors
    ShortNameFactory()
    Public Methods
    String getAnnotationName(Key<?> key)
    String getClassName(Key<?> key)
    String getInstanceName(Object instance)
    String getMemberName(Member member)
    String getSourceName(Object source)
    Returns a name for a Guice "source" object.
    Protected Methods
    String getFileString(StackTraceElement stackTraceElement)
    String getMethodString(Method method)
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.grapher.NameFactory

    Public Constructors

    public ShortNameFactory ()

    Public Methods

    public String getAnnotationName (Key<?> key)

    public String getClassName (Key<?> key)

    public String getInstanceName (Object instance)

    public String getMemberName (Member member)

    public String getSourceName (Object source)

    Returns a name for a Guice "source" object. This will typically be either a StackTraceElement for when the binding is made to the instance, or a Method when a provider method is used.

    Protected Methods

    protected String getFileString (StackTraceElement stackTraceElement)

    protected String getMethodString (Method method)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/Renderer.html0000755000175000017500000004276411704661106025433 0ustar tonytony Renderer | Guice
    public interface

    Renderer

    com.google.inject.grapher.Renderer
    Known Indirect Subclasses

    Class Overview

    Interface for the service that renders the graph. It is assumed that the implementations for BindingEdge.Factory, ImplementationNode.Factory, etc. will have direct access to the internals of the Renderer implementation, so the only external interface needed is the render() call that InjectorGrapher calls when it's done.

    Summary

    Public Methods
    abstract void render()

    Public Methods

    public abstract void render ()

    Throws
    IOException
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/NodeIdFactory.html0000755000175000017500000004465511704661106026360 0ustar tonytony NodeIdFactory | Guice
    public interface

    NodeIdFactory

    com.google.inject.grapher.NodeIdFactory<K>
    Known Indirect Subclasses

    Class Overview

    Factory for abstract identifiers for elements on the graph. Most graph nodes will correspond directly to Keys, but we do this for additional flexibility and because instances do not have separate Keys from the interfaces they are bound to.

    Node IDs are treated as opaque values by GraphingVisitor and the other classes in this package.

    Summary

    Public Methods
    abstract K getClassNodeId(Key<?> key)
    abstract K getInstanceNodeId(Key<?> key)

    Public Methods

    public abstract K getClassNodeId (Key<?> key)

    public abstract K getInstanceNodeId (Key<?> key)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/NodeAliasFactory.html0000755000175000017500000004172411704661106027047 0ustar tonytony NodeAliasFactory | Guice
    public interface

    NodeAliasFactory

    com.google.inject.grapher.NodeAliasFactory<K>
    Known Indirect Subclasses

    Class Overview

    Factory for aliasing one node ID to another. Used when we don't want to render Keys from Bindings that are not interesting.

    Summary

    Public Methods
    abstract void newAlias(K fromId, K toId)
    Makes edges that would point to fromId point to toId instead.

    Public Methods

    public abstract void newAlias (K fromId, K toId)

    Makes edges that would point to fromId point to toId instead.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/NameFactory.html0000755000175000017500000005247411704661106026074 0ustar tonytony NameFactory | Guice
    public interface

    NameFactory

    com.google.inject.grapher.NameFactory
    Known Indirect Subclasses

    Class Overview

    Interface for a service that provides nice Strings that we can display in the graph for the types that come up in Bindings.

    Summary

    Public Methods
    abstract String getAnnotationName(Key<?> key)
    abstract String getClassName(Key<?> key)
    abstract String getInstanceName(Object instance)
    abstract String getMemberName(Member member)
    abstract String getSourceName(Object source)

    Public Methods

    public abstract String getAnnotationName (Key<?> key)

    public abstract String getClassName (Key<?> key)

    public abstract String getInstanceName (Object instance)

    public abstract String getMemberName (Member member)

    public abstract String getSourceName (Object source)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/InterfaceNode.html0000755000175000017500000004633311704661106026367 0ustar tonytony InterfaceNode | Guice
    public interface

    InterfaceNode

    com.google.inject.grapher.InterfaceNode<K>
    Known Indirect Subclasses

    Class Overview

    Node for an interface class that has been bound to an implementation class or instance. These nodes are basically defined by a Key.

    See Also

    Summary

    Nested Classes
    interface InterfaceNode.Factory<K, T extends InterfaceNode<K>> Factory interface for InterfaceNodes. 
    Public Methods
    abstract void setKey(Key<?> key)
    abstract void setSource(Object source)

    Public Methods

    public abstract void setKey (Key<?> key)

    public abstract void setSource (Object source)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/InterfaceNode.Factory.html0000755000175000017500000004340111704661106027766 0ustar tonytony InterfaceNode.Factory | Guice
    public static interface

    InterfaceNode.Factory

    com.google.inject.grapher.InterfaceNode.Factory<K, T extends com.google.inject.grapher.InterfaceNode<K>>
    Known Indirect Subclasses

    Class Overview

    Factory interface for InterfaceNodes. Renderer implementations will need to provide an implementation for this.

    Summary

    Public Methods
    abstract T newInterfaceNode(K nodeId)
    Creates a new InterfaceNode and adds it to the graph.

    Public Methods

    public abstract T newInterfaceNode (K nodeId)

    Creates a new InterfaceNode and adds it to the graph.

    Parameters
    nodeId ID for the node.
    Returns
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/InjectorGrapher.html0000755000175000017500000007231511704661106026746 0ustar tonytony InjectorGrapher | Guice
    public class

    InjectorGrapher

    extends Object
    java.lang.Object
       ↳ com.google.inject.grapher.InjectorGrapher

    Class Overview

    Root class for graphing an Injector. Bound in GrapherModule.

    Use of(Injector) to specify the Injector to use, and graph() to graph the Injector using the currently-bound Renderer.

    By default, this will graph the entire Injector. Use rootedAt(Class) or rootedAt(Key) to specify an initial set of Classes or Keys to use, and this will graph their transitive bindings and dependencies.

    Summary

    Public Constructors
    InjectorGrapher(BindingTargetVisitor<Object, Collection<Key<?>>> keyVisitor, BindingTargetVisitor<Object, Void> graphingVisitor, Renderer renderer)
    Public Methods
    void graph()
    Renders a graph with the bound Renderer.
    InjectorGrapher of(Injector injector)
    Sets the Injector to graph.
    InjectorGrapher rootedAt(Key...<?> keys)
    Sets an initial group of Keys to use as the starting point for the graph.
    InjectorGrapher rootedAt(Class...<?> classes)
    Sets an initial group of Classes to use as the starting point for the graph.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Constructors

    public InjectorGrapher (BindingTargetVisitor<Object, Collection<Key<?>>> keyVisitor, BindingTargetVisitor<Object, Void> graphingVisitor, Renderer renderer)

    Public Methods

    public void graph ()

    Renders a graph with the bound Renderer. The Injector must have already been specified with of(Injector).

    Throws
    IOException

    public InjectorGrapher of (Injector injector)

    Sets the Injector to graph.

    public InjectorGrapher rootedAt (Key...<?> keys)

    Sets an initial group of Keys to use as the starting point for the graph. The graph will be of these keys and their transitive dependencies and bindings.

    public InjectorGrapher rootedAt (Class...<?> classes)

    Sets an initial group of Classes to use as the starting point for the graph. The graph will be of these classes and their transitive dependencies and bindings.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/ImplementationNode.html0000755000175000017500000005406111704661106027451 0ustar tonytony ImplementationNode | Guice
    public interface

    ImplementationNode

    com.google.inject.grapher.ImplementationNode<K>
    Known Indirect Subclasses

    Class Overview

    Node for classes and instances that have Dependencys and are bound to InterfaceNodes. These nodes will often have fields for Members that are InjectionPoints.

    See Also

    Summary

    Nested Classes
    interface ImplementationNode.Factory<K, T extends ImplementationNode<K>> Factory interface for ImplementationNodes. 
    Public Methods
    abstract void addMember(Member member)
    abstract void setClassKey(Key<?> key)
    Sets the Key that this node is for.
    abstract void setInstance(Object instance)
    Sets the Object that's the already-created instance.
    abstract void setSource(Object source)

    Public Methods

    public abstract void addMember (Member member)

    public abstract void setClassKey (Key<?> key)

    Sets the Key that this node is for. Used when the node is representing a class that Guice will instantiate.

    public abstract void setInstance (Object instance)

    Sets the Object that's the already-created instance. Used when this node is represeting the instance instead of a class.

    public abstract void setSource (Object source)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/ImplementationNode.Factory.html0000755000175000017500000004357111704661106031063 0ustar tonytony ImplementationNode.Factory | Guice
    public static interface

    ImplementationNode.Factory

    com.google.inject.grapher.ImplementationNode.Factory<K, T extends com.google.inject.grapher.ImplementationNode<K>>
    Known Indirect Subclasses

    Class Overview

    Factory interface for ImplementationNodes. Renderer implementations will need to provide an implementation for this.

    Summary

    Public Methods
    abstract T newImplementationNode(K nodeId)
    Creates a new ImplementationNode and adds it to the graph.

    Public Methods

    public abstract T newImplementationNode (K nodeId)

    Creates a new ImplementationNode and adds it to the graph.

    Parameters
    nodeId ID for the node.
    Returns
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/GraphingVisitor.html0000755000175000017500000022300411704661106026770 0ustar tonytony GraphingVisitor | Guice
    public class

    GraphingVisitor

    extends Object
    implements BindingTargetVisitor<T, V>
    java.lang.Object
       ↳ com.google.inject.grapher.GraphingVisitor<K, N extends com.google.inject.grapher.InterfaceNode<K>, M extends com.google.inject.grapher.ImplementationNode<K>, B extends com.google.inject.grapher.BindingEdge<K>, D extends com.google.inject.grapher.DependencyEdge<K>>

    Class Overview

    BindingTargetVisitor that adds nodes and edges to the graph based on the visited Binding.

    This class is parameterized over the four graph element types (InterfaceNode, ImplementationNode, BindingEdge, and DependencyEdge) so that you can extend those interfaces and also extend this class, and the helper methods will all return your new types.

    Summary

    Public Constructors
    GraphingVisitor(NodeIdFactory<K> idFactory, Factory<K, N> interfaceNodeFactory, Factory<K, M> implementationNodeFactory, Factory<K, B> bindingEdgeFactory, Factory<K, D> dependencyEdgeFactory, NodeAliasFactory<K> nodeAliasFactory)
    Public Methods
    Void visit(ConstructorBinding<?> binding)
    Visitor for ConstructorBindings.
    Void visit(ConvertedConstantBinding<?> binding)
    Void visit(ExposedBinding<?> binding)
    Currently not displayed on the graph.
    Void visit(InstanceBinding<?> binding)
    Visitor for InstanceBinding.
    Void visit(LinkedKeyBinding<?> binding)
    Visitor for LinkedKeyBinding.
    Void visit(ProviderBinding<?> binding)
    Visitor for ProviderBinding.
    Void visit(ProviderInstanceBinding<?> binding)
    Void visit(ProviderKeyBinding<?> binding)
    Void visit(UntargettedBinding<?> binding)
    Currently not displayed on the graph.
    Protected Methods
    final K getClassNodeId(Binding<?> binding)
    Helper method to return the standard node ID for the Binding's Key.
    final K getInstanceNodeId(Binding<?> binding)
    Helper method to return the instance node ID for the Binding's Key.
    B newBindingEdge(K nodeId, K toId, BindingEdge.Type type)
    Creates a new BindingEdge from the given node to the specified node.
    M newClassImplementationNode(Binding<?> binding, InjectionPoint constructorInjectionPoint, Collection<InjectionPoint> memberInjectionPoints)
    Creates and returns a new ImplementationNode for the given Binding, where the Binding is for a class that Guice will instantiate, rather than a specific instance.
    D newDependencyEdge(K nodeId, InjectionPoint injectionPoint, Dependency<?> dependency)
    Creates a new DependencyEdge from the given node to a Dependency.
    Collection<D> newDependencyEdges(K nodeId, M node, Collection<Dependency<?>> dependencies)
    Adds DependencyEdges to the graph for each of the provided Dependencys.
    M newInstanceImplementationNode(Binding<?> binding, Object instance)
    Creates and returns a new ImplementationNode for the given Binding, where the Binding is for an instance, rather than a class.
    N newInterfaceNode(Binding<?> binding)
    Creates and returns a new InterfaceNode object for the given Binding.
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.spi.BindingTargetVisitor

    Public Constructors

    public GraphingVisitor (NodeIdFactory<K> idFactory, Factory<K, N> interfaceNodeFactory, Factory<K, M> implementationNodeFactory, Factory<K, B> bindingEdgeFactory, Factory<K, D> dependencyEdgeFactory, NodeAliasFactory<K> nodeAliasFactory)

    Public Methods

    public Void visit (ConstructorBinding<?> binding)

    Visitor for ConstructorBindings. These are for classes that Guice will instantiate to satisfy injection requests. We create a new ImplementationNode for the class, then add edges to everything that it depends on to be instantiated.

    public Void visit (ConvertedConstantBinding<?> binding)

    Visitor for ConvertedConstantBinding. The Binding's Key will be of an annotated primitive type, and the value of getSourceKey() will be of a String with the same annotation.

    We render this as an InterfaceNode that has a BindingEdge to the source Key. That will then be rendered by visit(InstanceBinding) as an InterfaceNode with a BindingEdge to the String instance.

    public Void visit (ExposedBinding<?> binding)

    Currently not displayed on the graph.

    public Void visit (InstanceBinding<?> binding)

    Visitor for InstanceBinding. We render two nodes in this case: a InterfaceNode for the binding's Key, and then an ImplementationNode for the instance Object itself. We run a binding node between them.

    We then render any DependencyEdges that the instance may have, which come either from InjectionPoints (method and field) on the instance, or on Dependencys the instance declares through the HasDependencies interface.

    public Void visit (LinkedKeyBinding<?> binding)

    Visitor for LinkedKeyBinding. This is the standard Binding you get from binding an interface class to an implementation class. We create an InterfaceNode, then draw a BindingEdge to the node of the implementing class.

    public Void visit (ProviderBinding<?> binding)

    Visitor for ProviderBinding. These Bindings arise from an InjectionPoint for the Provider interface. Since this isn't tremendously interesting information, we don't render this binding on the graph, and instead let the DependencyEdge go straight from the InjectionPoint to the node specified by getProvidedKey().

    public Void visit (UntargettedBinding<?> binding)

    Currently not displayed on the graph.

    Protected Methods

    protected final K getClassNodeId (Binding<?> binding)

    Helper method to return the standard node ID for the Binding's Key.

    protected final K getInstanceNodeId (Binding<?> binding)

    Helper method to return the instance node ID for the Binding's Key.

    protected B newBindingEdge (K nodeId, K toId, BindingEdge.Type type)

    Creates a new BindingEdge from the given node to the specified node.

    Parameters
    nodeId ID of the InterfaceNode that binds to the other.
    toId The node ID of a class or instance that is bound.
    type The BindingEdge.Type of this binding.
    Returns

    protected M newClassImplementationNode (Binding<?> binding, InjectionPoint constructorInjectionPoint, Collection<InjectionPoint> memberInjectionPoints)

    Creates and returns a new ImplementationNode for the given Binding, where the Binding is for a class that Guice will instantiate, rather than a specific instance.

    protected D newDependencyEdge (K nodeId, InjectionPoint injectionPoint, Dependency<?> dependency)

    Creates a new DependencyEdge from the given node to a Dependency.

    This method takes more comprehensive parameters than strictly necessary in case they would be useful to overriding implementations.

    Parameters
    nodeId ID of the ImplementationNode where the edges will start.
    injectionPoint The InjectionPoint that gave rise to this Dependency, if one exists. Used to figure out which Member the edge should point from.
    dependency The Dependency to represent with this edge.
    Returns

    protected Collection<D> newDependencyEdges (K nodeId, M node, Collection<Dependency<?>> dependencies)

    Adds DependencyEdges to the graph for each of the provided Dependencys. These will be from the given node ID to the Dependency's Key.

    If a Dependency has an associated InjectionPoint, its member will be added to the given ImplementationNode and the edge will start at the Member.

    Parameters
    nodeId ID of the node that should be the tail of the DependencyEdges.
    node An ImplementationNode to add Members to.
    dependencies Collection of Dependencys from the Binding.
    Returns

    protected M newInstanceImplementationNode (Binding<?> binding, Object instance)

    Creates and returns a new ImplementationNode for the given Binding, where the Binding is for an instance, rather than a class.

    protected N newInterfaceNode (Binding<?> binding)

    Creates and returns a new InterfaceNode object for the given Binding.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/GrapherModule.html0000755000175000017500000011413711704661106026415 0ustar tonytony GrapherModule | Guice
    public class

    GrapherModule

    extends AbstractModule
    java.lang.Object
       ↳ com.google.inject.AbstractModule
         ↳ com.google.inject.grapher.GrapherModule

    Class Overview

    Module for the common bindings for InjectorGrapher. You will also need to bind a Module that satisfies the Renderer dependency.

    If you want to use subtypes of the node and edge classes, or a different node ID type, you will need to override the GraphingVisitor binding to specify the new type parameters.

    Summary

    Public Constructors
    GrapherModule()
    Protected Methods
    void configure()
    Configures a Binder via the exposed methods.
    [Expand]
    Inherited Methods
    From class com.google.inject.AbstractModule
    From class java.lang.Object
    From interface com.google.inject.Module

    Public Constructors

    public GrapherModule ()

    Protected Methods

    protected void configure ()

    Configures a Binder via the exposed methods.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/DependencyEdge.html0000755000175000017500000004106511704661106026521 0ustar tonytony DependencyEdge | Guice
    public interface

    DependencyEdge

    com.google.inject.grapher.DependencyEdge<K>
    Known Indirect Subclasses

    Class Overview

    Interface for an edge from a class or InjectionPoint to the interface node that will satisfy the dependency.

    Summary

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/DependencyEdge.Factory.html0000755000175000017500000004420411704661106030125 0ustar tonytony DependencyEdge.Factory | Guice
    Nested Classes
    interface DependencyEdge.Factory<K, T extends DependencyEdge<K>> Factory interface for DependencyEdges. 
    public static interface

    DependencyEdge.Factory

    com.google.inject.grapher.DependencyEdge.Factory<K, T extends com.google.inject.grapher.DependencyEdge<K>>
    Known Indirect Subclasses

    Class Overview

    Factory interface for DependencyEdges. Renderer implementations will need to provide an implementation for this.

    Summary

    Public Methods
    abstract T newDependencyEdge(K fromId, InjectionPoint fromPoint, K toId)
    Creates a new DependencyEdge and adds it to the graph.

    Public Methods

    public abstract T newDependencyEdge (K fromId, InjectionPoint fromPoint, K toId)

    Creates a new DependencyEdge and adds it to the graph.

    Parameters
    fromId The ID for the class or instance node that has the dependency.
    fromPoint The point where the dependency will be @Injected.
    toId The ID for the interface node that satisfies the dependency.
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/BindingEdge.html0000755000175000017500000004446611704661106026025 0ustar tonytony BindingEdge | Guice
    public interface

    BindingEdge

    com.google.inject.grapher.BindingEdge<K>
    Known Indirect Subclasses

    Class Overview

    Interface for an edge that connects an interface to the type or instance that is bound to implement it.

    Summary

    Nested Classes
    interface BindingEdge.Factory<K, T extends BindingEdge<K>> Factory interface for BindingEdges. 
    enum BindingEdge.Type Classification for what kind of binding this edge represents. 
    Public Methods
    abstract void setType(BindingEdge.Type type)

    Public Methods

    public abstract void setType (BindingEdge.Type type)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/BindingEdge.Type.html0000755000175000017500000007432711704661106026744 0ustar tonytony BindingEdge.Type | Guice
    public static final enum

    BindingEdge.Type

    extends Enum<E extends Enum<E>>
    java.lang.Object
       ↳ java.lang.Enum<E extends java.lang.Enum<E>>
         ↳ com.google.inject.grapher.BindingEdge.Type

    Class Overview

    Classification for what kind of binding this edge represents.

    Summary

    Enum Values
    BindingEdge.Type  CONVERTED_CONSTANT  Binding is to the interface for a constant of a different type. 
    BindingEdge.Type  NORMAL  Binding is to an instance or class of the binding's same type. 
    BindingEdge.Type  PROVIDER  Binding is to an instance or class that provides the binding's type. 
    Public Methods
    static BindingEdge.Type valueOf(String name)
    final static Type[] values()
    [Expand]
    Inherited Methods
    From class java.lang.Enum
    From class java.lang.Object
    From interface java.lang.Comparable

    Enum Values

    public static final BindingEdge.Type CONVERTED_CONSTANT

    Since: API Level

    Binding is to the interface for a constant of a different type.

    public static final BindingEdge.Type NORMAL

    Since: API Level

    Binding is to an instance or class of the binding's same type.

    public static final BindingEdge.Type PROVIDER

    Since: API Level

    Binding is to an instance or class that provides the binding's type.

    Public Methods

    public static BindingEdge.Type valueOf (String name)

    public static final Type[] values ()

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/grapher/BindingEdge.Factory.html0000755000175000017500000004362211704661106027424 0ustar tonytony BindingEdge.Factory | Guice
    public static interface

    BindingEdge.Factory

    com.google.inject.grapher.BindingEdge.Factory<K, T extends com.google.inject.grapher.BindingEdge<K>>
    Known Indirect Subclasses

    Class Overview

    Factory interface for BindingEdges. Renderer implementations will need to provide an implementation for this.

    Summary

    Public Methods
    abstract T newBindingEdge(K fromId, K toId)
    Creates a new BindingEdge instance and adds it to the graph.

    Public Methods

    public abstract T newBindingEdge (K fromId, K toId)

    Creates a new BindingEdge instance and adds it to the graph.

    Parameters
    fromId Node ID for the interface node.
    toId Node ID for the implementation (class or instance) node.
    Returns
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/binder/0000755000175000017500000000000011704661106022572 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/binder/package-summary.html0000755000175000017500000003132711704661106026557 0ustar tonytony com.google.inject.binder | Guice
    package

    com.google.inject.binder

    Classes | Description

    Interfaces which make up Binder's expression language.

    more...

    Interfaces

    AnnotatedBindingBuilder<T> See the EDSL examples at Binder
    AnnotatedConstantBindingBuilder See the EDSL examples at Binder
    AnnotatedElementBuilder See the EDSL examples at Binder
    ConstantBindingBuilder Binds to a constant value. 
    LinkedBindingBuilder<T> See the EDSL examples at Binder
    ScopedBindingBuilder See the EDSL examples at Binder
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/binder/package-descr.html0000755000175000017500000002451111704661106026157 0ustar tonytony com.google.inject.binder Details | Guice
    package

    com.google.inject.binder

    Classes | Description

    Interfaces which make up Binder's expression language.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/binder/ScopedBindingBuilder.html0000755000175000017500000004325311704661106027511 0ustar tonytony ScopedBindingBuilder | Guice
    public interface

    ScopedBindingBuilder

    com.google.inject.binder.ScopedBindingBuilder
    Known Indirect Subclasses

    Class Overview

    See the EDSL examples at Binder.

    Summary

    Public Methods
    abstract void asEagerSingleton()
    Instructs the Injector to eagerly initialize this singleton-scoped binding upon creation.
    abstract void in(Scope scope)
    See the EDSL examples at Binder.
    abstract void in(Class<? extends Annotation> scopeAnnotation)
    See the EDSL examples at Binder.

    Public Methods

    public abstract void asEagerSingleton ()

    Instructs the Injector to eagerly initialize this singleton-scoped binding upon creation. Useful for application initialization logic. See the EDSL examples at Binder.

    public abstract void in (Scope scope)

    See the EDSL examples at Binder.

    public abstract void in (Class<? extends Annotation> scopeAnnotation)

    See the EDSL examples at Binder.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/binder/LinkedBindingBuilder.html0000755000175000017500000010263111704661106027476 0ustar tonytony LinkedBindingBuilder | Guice
    public interface

    LinkedBindingBuilder

    implements ScopedBindingBuilder
    com.google.inject.binder.LinkedBindingBuilder<T>
    Known Indirect Subclasses

    Class Overview

    See the EDSL examples at Binder.

    Summary

    Public Methods
    abstract ScopedBindingBuilder to(Key<? extends T> targetKey)
    See the EDSL examples at Binder.
    abstract ScopedBindingBuilder to(TypeLiteral<? extends T> implementation)
    See the EDSL examples at Binder.
    abstract ScopedBindingBuilder to(Class<? extends T> implementation)
    See the EDSL examples at Binder.
    abstract <S extends T> ScopedBindingBuilder toConstructor(Constructor<S> constructor)
    See the EDSL examples at Binder.
    abstract <S extends T> ScopedBindingBuilder toConstructor(Constructor<S> constructor, TypeLiteral<? extends S> type)
    See the EDSL examples at Binder.
    abstract void toInstance(T instance)
    See the EDSL examples at Binder.
    abstract ScopedBindingBuilder toProvider(Key<? extends Provider<? extends T>> providerKey)
    See the EDSL examples at Binder.
    abstract ScopedBindingBuilder toProvider(Provider<? extends T> provider)
    See the EDSL examples at Binder.
    abstract ScopedBindingBuilder toProvider(TypeLiteral<? extends Provider<? extends T>> providerType)
    See the EDSL examples at Binder.
    abstract ScopedBindingBuilder toProvider(Class<? extends Provider<? extends T>> providerType)
    See the EDSL examples at Binder.
    [Expand]
    Inherited Methods
    From interface com.google.inject.binder.ScopedBindingBuilder

    Public Methods

    public abstract ScopedBindingBuilder to (Key<? extends T> targetKey)

    See the EDSL examples at Binder.

    public abstract ScopedBindingBuilder to (TypeLiteral<? extends T> implementation)

    See the EDSL examples at Binder.

    public abstract ScopedBindingBuilder to (Class<? extends T> implementation)

    See the EDSL examples at Binder.

    public abstract ScopedBindingBuilder toConstructor (Constructor<S> constructor)

    See the EDSL examples at Binder.

    public abstract ScopedBindingBuilder toConstructor (Constructor<S> constructor, TypeLiteral<? extends S> type)

    See the EDSL examples at Binder.

    public abstract void toInstance (T instance)

    See the EDSL examples at Binder.

    public abstract ScopedBindingBuilder toProvider (Key<? extends Provider<? extends T>> providerKey)

    See the EDSL examples at Binder.

    public abstract ScopedBindingBuilder toProvider (Provider<? extends T> provider)

    See the EDSL examples at Binder.

    public abstract ScopedBindingBuilder toProvider (TypeLiteral<? extends Provider<? extends T>> providerType)

    See the EDSL examples at Binder.

    public abstract ScopedBindingBuilder toProvider (Class<? extends Provider<? extends T>> providerType)

    See the EDSL examples at Binder.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/binder/ConstantBindingBuilder.html0000755000175000017500000005730611704661106030071 0ustar tonytony ConstantBindingBuilder | Guice
    public interface

    ConstantBindingBuilder

    com.google.inject.binder.ConstantBindingBuilder

    Class Overview

    Binds to a constant value.

    Summary

    Public Methods
    abstract <E extends Enum<E>> void to(E value)
    Binds constant to the given value.
    abstract void to(boolean value)
    Binds constant to the given value.
    abstract void to(byte value)
    Binds constant to the given value.
    abstract void to(char value)
    Binds constant to the given value.
    abstract void to(double value)
    Binds constant to the given value.
    abstract void to(float value)
    Binds constant to the given value.
    abstract void to(int value)
    Binds constant to the given value.
    abstract void to(Class<?> value)
    Binds constant to the given value.
    abstract void to(String value)
    Binds constant to the given value.
    abstract void to(long value)
    Binds constant to the given value.
    abstract void to(short value)
    Binds constant to the given value.

    Public Methods

    public abstract void to (E value)

    Binds constant to the given value.

    public abstract void to (boolean value)

    Binds constant to the given value.

    public abstract void to (byte value)

    Binds constant to the given value.

    public abstract void to (char value)

    Binds constant to the given value.

    public abstract void to (double value)

    Binds constant to the given value.

    public abstract void to (float value)

    Binds constant to the given value.

    public abstract void to (int value)

    Binds constant to the given value.

    public abstract void to (Class<?> value)

    Binds constant to the given value.

    public abstract void to (String value)

    Binds constant to the given value.

    public abstract void to (long value)

    Binds constant to the given value.

    public abstract void to (short value)

    Binds constant to the given value.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/binder/AnnotatedElementBuilder.html0000755000175000017500000003426511704661106030233 0ustar tonytony AnnotatedElementBuilder | Guice
    public interface

    AnnotatedElementBuilder

    com.google.inject.binder.AnnotatedElementBuilder

    Class Overview

    See the EDSL examples at Binder.

    Summary

    Public Methods
    abstract void annotatedWith(Class<? extends Annotation> annotationType)
    See the EDSL examples at Binder.
    abstract void annotatedWith(Annotation annotation)
    See the EDSL examples at Binder.

    Public Methods

    public abstract void annotatedWith (Class<? extends Annotation> annotationType)

    See the EDSL examples at Binder.

    public abstract void annotatedWith (Annotation annotation)

    See the EDSL examples at Binder.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/binder/AnnotatedConstantBindingBuilder.html0000755000175000017500000003514111704661106031720 0ustar tonytony AnnotatedConstantBindingBuilder | Guice
    public interface

    AnnotatedConstantBindingBuilder

    com.google.inject.binder.AnnotatedConstantBindingBuilder

    Class Overview

    See the EDSL examples at Binder.

    Summary

    Public Methods
    abstract ConstantBindingBuilder annotatedWith(Class<? extends Annotation> annotationType)
    See the EDSL examples at Binder.
    abstract ConstantBindingBuilder annotatedWith(Annotation annotation)
    See the EDSL examples at Binder.

    Public Methods

    public abstract ConstantBindingBuilder annotatedWith (Class<? extends Annotation> annotationType)

    See the EDSL examples at Binder.

    public abstract ConstantBindingBuilder annotatedWith (Annotation annotation)

    See the EDSL examples at Binder.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/binder/AnnotatedBindingBuilder.html0000755000175000017500000006530611704661106030214 0ustar tonytony AnnotatedBindingBuilder | Guice
    public interface

    AnnotatedBindingBuilder

    implements LinkedBindingBuilder<T>
    com.google.inject.binder.AnnotatedBindingBuilder<T>

    Class Overview

    See the EDSL examples at Binder.

    Summary

    Public Methods
    abstract LinkedBindingBuilder<T> annotatedWith(Class<? extends Annotation> annotationType)
    See the EDSL examples at Binder.
    abstract LinkedBindingBuilder<T> annotatedWith(Annotation annotation)
    See the EDSL examples at Binder.
    [Expand]
    Inherited Methods
    From interface com.google.inject.binder.LinkedBindingBuilder
    From interface com.google.inject.binder.ScopedBindingBuilder

    Public Methods

    public abstract LinkedBindingBuilder<T> annotatedWith (Class<? extends Annotation> annotationType)

    See the EDSL examples at Binder.

    public abstract LinkedBindingBuilder<T> annotatedWith (Annotation annotation)

    See the EDSL examples at Binder.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/assistedinject/0000755000175000017500000000000011704661106024343 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/assistedinject/package-summary.html0000755000175000017500000003144311704661106030327 0ustar tonytony com.google.inject.assistedinject | Guice
    package

    com.google.inject.assistedinject

    Classes | Description

    Extension for combining factory interfaces with injection; this extension requires guice-assistedinject-3.0.jar.

    more...

    Interfaces

    AssistedInjectBinding<T> A binding for a factory created by FactoryModuleBuilder. 
    AssistedInjectTargetVisitor<T, V> A visitor for the AssistedInject extension. 
    AssistedMethod Details about how a method in an assisted inject factory will be assisted. 

    Classes

    FactoryModuleBuilder Provides a factory that combines the caller's arguments with injector-supplied values to construct objects. 
    FactoryProvider<F> This class is deprecated. use FactoryModuleBuilder instead.  
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/assistedinject/package-descr.html0000755000175000017500000002513511704661106027733 0ustar tonytony com.google.inject.assistedinject Details | Guice
    package

    com.google.inject.assistedinject

    Classes | Description

    Extension for combining factory interfaces with injection; this extension requires guice-assistedinject-3.0.jar.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/assistedinject/FactoryProvider.html0000755000175000017500000007543611704661106030375 0ustar tonytony FactoryProvider | Guice
    public class

    FactoryProvider

    extends Object
    implements Provider<T> HasDependencies
    java.lang.Object
       ↳ com.google.inject.assistedinject.FactoryProvider<F>

    This class is deprecated.
    use FactoryModuleBuilder instead.

    Class Overview

    Obsolete. Prefer FactoryModuleBuilder for its more concise API and additional capability.

    Provides a factory that combines the caller's arguments with injector-supplied values to construct objects.

    Defining a factory

    Create an interface whose methods return the constructed type, or any of its supertypes. The method's parameters are the arguments required to build the constructed type.
    public interface PaymentFactory {
       Payment create(Date startDate, Money amount);
     }
    You can name your factory methods whatever you like, such as create, createPayment or newPayment.

    Creating a type that accepts factory parameters

    constructedType is a concrete class with an @Inject-annotated constructor. In addition to injector-supplied parameters, the constructor should have parameters that match each of the factory method's parameters. Each factory-supplied parameter requires an @Assisted annotation. This serves to document that the parameter is not bound by your application's modules.
    public class RealPayment implements Payment {
       @Inject
       public RealPayment(
          CreditService creditService,
          AuthService authService,
          @Assisted Date startDate,
          @Assisted Money amount) {
         ...
       }
     }
    Any parameter that permits a null value should also be annotated @Nullable.

    Configuring factories

    In your module, bind the factory interface to the returned factory:
    bind(PaymentFactory.class).toProvider(
         FactoryProvider.newFactory(PaymentFactory.class, RealPayment.class));
    As a side-effect of this binding, Guice will inject the factory to initialize it for use. The factory cannot be used until the injector has been initialized.

    Using the factory

    Inject your factory into your application classes. When you use the factory, your arguments will be combined with values from the injector to construct an instance.
    public class PaymentAction {
       @Inject private PaymentFactory paymentFactory;
    
       public void doPayment(Money amount) {
         Payment payment = paymentFactory.create(new Date(), amount);
         payment.apply();
       }
     }

    Making parameter types distinct

    The types of the factory method's parameters must be distinct. To use multiple parameters of the same type, use a named @Assisted annotation to disambiguate the parameters. The names must be applied to the factory method's parameters:
    public interface PaymentFactory {
       Payment create(
           @Assisted("startDate") Date startDate,
           @Assisted("dueDate") Date dueDate,
           Money amount);
     } 
    ...and to the concrete type's constructor parameters:
    public class RealPayment implements Payment {
       @Inject
       public RealPayment(
          CreditService creditService,
          AuthService authService,
          @Assisted("startDate") Date startDate,
          @Assisted("dueDate") Date dueDate,
          @Assisted Money amount) {
         ...
       }
     }

    Values are created by Guice

    Returned factories use child injectors to create values. The values are eligible for method interception. In addition, @Inject members will be injected before they are returned.

    Backwards compatibility using @AssistedInject

    Instead of the @Inject annotation, you may annotate the constructed classes with @AssistedInject. This triggers a limited backwards-compatability mode.

    Instead of matching factory method arguments to constructor parameters using their names, the parameters are matched by their order. The first factory method argument is used for the first @Assisted constructor parameter, etc.. Annotation names have no effect.

    Returned values are not created by Guice. These types are not eligible for method interception. They do receive post-construction member injection.

    Summary

    Public Methods
    F get()
    Provides an instance of T.
    Set<Dependency<?>> getDependencies()
    Returns the known dependencies for this type.
    static <F> Provider<F> newFactory(TypeLiteral<F> factoryType, TypeLiteral<?> implementationType)
    static <F> Provider<F> newFactory(Class<F> factoryType, Class<?> implementationType)
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.Provider
    From interface com.google.inject.spi.HasDependencies
    From interface javax.inject.Provider

    Public Methods

    public F get ()

    Provides an instance of T. Must never return null.

    public Set<Dependency<?>> getDependencies ()

    Returns the known dependencies for this type. If this has dependencies whose values are not known statically, a dependency for the Injector will be included in the returned set.

    Returns
    • a possibly empty set

    public static Provider<F> newFactory (TypeLiteral<F> factoryType, TypeLiteral<?> implementationType)

    public static Provider<F> newFactory (Class<F> factoryType, Class<?> implementationType)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/assistedinject/FactoryModuleBuilder.html0000755000175000017500000016233011704661106031325 0ustar tonytony FactoryModuleBuilder | Guice
    public final class

    FactoryModuleBuilder

    extends Object
    java.lang.Object
       ↳ com.google.inject.assistedinject.FactoryModuleBuilder

    Class Overview

    Provides a factory that combines the caller's arguments with injector-supplied values to construct objects.

    Defining a factory

    Create an interface whose methods return the constructed type, or any of its supertypes. The method's parameters are the arguments required to build the constructed type.
    public interface PaymentFactory {
       Payment create(Date startDate, Money amount);
     }
    You can name your factory methods whatever you like, such as create, createPayment or newPayment.

    Creating a type that accepts factory parameters

    constructedType is a concrete class with an @Inject-annotated constructor. In addition to injector-supplied parameters, the constructor should have parameters that match each of the factory method's parameters. Each factory-supplied parameter requires an @Assisted annotation. This serves to document that the parameter is not bound by your application's modules.
    public class RealPayment implements Payment {
       @Inject
       public RealPayment(
          CreditService creditService,
          AuthService authService,
          @Assisted Date startDate,
          @Assisted Money amount) {
         ...
       }
     }

    Multiple factory methods for the same type

    If the factory contains many methods that return the same type, you can create multiple constructors in your concrete class, each constructor marked with with @AssistedInject, in order to match the different parameters types of the factory methods.
    public interface PaymentFactory {
        Payment create(Date startDate, Money amount);
        Payment createWithoutDate(Money amount);
     }
     
     public class RealPayment implements Payment {
      @AssistedInject
       public RealPayment(
          CreditService creditService,
          AuthService authService,
         @Assisted Date startDate,
         @Assisted Money amount) {
         ...
       }
       
      @AssistedInject
       public RealPayment(
          CreditService creditService,
          AuthService authService,
         @Assisted Money amount) {
         ...
       }   
     }

    Configuring simple factories

    In your module, install a FactoryModuleBuilder that creates the factory:
    install(new FactoryModuleBuilder()
         .implement(Payment.class, RealPayment.class)
         .build(PaymentFactory.class);
    As a side-effect of this binding, Guice will inject the factory to initialize it for use. The factory cannot be used until the injector has been initialized.

    Configuring complex factories

    Factories can create an arbitrary number of objects, one per each method. Each factory method can be configured using .implement.
    public interface OrderFactory {
        Payment create(Date startDate, Money amount);
        Shipment create(Customer customer, Item item);
        Receipt create(Payment payment, Shipment shipment);
     }
     
     [...]
     
     install(new FactoryModuleBuilder()
         .implement(Payment.class, RealPayment.class)
         // excluding .implement for Shipment means the implementation class
         // will be 'Shipment' itself, which is legal if it's not an interface.
         .implement(Receipt.class, RealReceipt.class)
         .build(OrderFactory.class);

    Using the factory

    Inject your factory into your application classes. When you use the factory, your arguments will be combined with values from the injector to construct an instance.
    public class PaymentAction {
       @Inject private PaymentFactory paymentFactory;
    
       public void doPayment(Money amount) {
         Payment payment = paymentFactory.create(new Date(), amount);
         payment.apply();
       }
     }

    Making parameter types distinct

    The types of the factory method's parameters must be distinct. To use multiple parameters of the same type, use a named @Assisted annotation to disambiguate the parameters. The names must be applied to the factory method's parameters:
    public interface PaymentFactory {
       Payment create(
           @Assisted("startDate") Date startDate,
           @Assisted("dueDate") Date dueDate,
           Money amount);
     } 
    ...and to the concrete type's constructor parameters:
    public class RealPayment implements Payment {
       @Inject
       public RealPayment(
          CreditService creditService,
          AuthService authService,
          @Assisted("startDate") Date startDate,
          @Assisted("dueDate") Date dueDate,
          @Assisted Money amount) {
         ...
       }
     }

    Values are created by Guice

    Returned factories use child injectors to create values. The values are eligible for method interception. In addition, @Inject members will be injected before they are returned.

    More configuration options

    In addition to simply specifying an implementation class for any returned type, factories' return values can be automatic or can be configured to use annotations:

    If you just want to return the types specified in the factory, do not configure any implementations:

    public interface FruitFactory {
       Apple getApple(Color color);
     }
     ...
     protected void configure() {
       install(new FactoryModuleBuilder().build(FruitFactory.class));
     }
    Note that any type returned by the factory in this manner needs to be an implementation class.

    To return two different implementations for the same interface from your factory, use binding annotations on your return types:

    interface CarFactory {
       @Named("fast") Car getFastCar(Color color);
       @Named("clean") Car getCleanCar(Color color);
     }
     ...
     protected void configure() {
       install(new FactoryModuleBuilder()
           .implement(Car.class, Names.named("fast"), Porsche.class)
           .implement(Car.class, Names.named("clean"), Prius.class)
           .build(CarFactory.class));
     }

    Implementation limitations

    As a limitation of the implementation, it is prohibited to declare a factory method that accepts a Provider as one of its arguments.

    Summary

    Public Constructors
    FactoryModuleBuilder()
    Public Methods
    <F> Module build(Key<F> factoryInterface)
    <F> Module build(TypeLiteral<F> factoryInterface)
    See the factory configuration examples at FactoryModuleBuilder.
    <F> Module build(Class<F> factoryInterface)
    See the factory configuration examples at FactoryModuleBuilder.
    <T> FactoryModuleBuilder implement(Key<T> source, TypeLiteral<? extends T> target)
    See the factory configuration examples at FactoryModuleBuilder.
    <T> FactoryModuleBuilder implement(Key<T> source, Class<? extends T> target)
    See the factory configuration examples at FactoryModuleBuilder.
    <T> FactoryModuleBuilder implement(TypeLiteral<T> source, TypeLiteral<? extends T> target)
    See the factory configuration examples at FactoryModuleBuilder.
    <T> FactoryModuleBuilder implement(TypeLiteral<T> source, Class<? extends T> target)
    See the factory configuration examples at FactoryModuleBuilder.
    <T> FactoryModuleBuilder implement(TypeLiteral<T> source, Class<? extends Annotation> annotationType, TypeLiteral<? extends T> target)
    See the factory configuration examples at FactoryModuleBuilder.
    <T> FactoryModuleBuilder implement(TypeLiteral<T> source, Class<? extends Annotation> annotationType, Class<? extends T> target)
    See the factory configuration examples at FactoryModuleBuilder.
    <T> FactoryModuleBuilder implement(TypeLiteral<T> source, Annotation annotation, TypeLiteral<? extends T> target)
    See the factory configuration examples at FactoryModuleBuilder.
    <T> FactoryModuleBuilder implement(TypeLiteral<T> source, Annotation annotation, Class<? extends T> target)
    See the factory configuration examples at FactoryModuleBuilder.
    <T> FactoryModuleBuilder implement(Class<T> source, TypeLiteral<? extends T> target)
    See the factory configuration examples at FactoryModuleBuilder.
    <T> FactoryModuleBuilder implement(Class<T> source, Class<? extends T> target)
    See the factory configuration examples at FactoryModuleBuilder.
    <T> FactoryModuleBuilder implement(Class<T> source, Class<? extends Annotation> annotationType, TypeLiteral<? extends T> target)
    See the factory configuration examples at FactoryModuleBuilder.
    <T> FactoryModuleBuilder implement(Class<T> source, Class<? extends Annotation> annotationType, Class<? extends T> target)
    See the factory configuration examples at FactoryModuleBuilder.
    <T> FactoryModuleBuilder implement(Class<T> source, Annotation annotation, TypeLiteral<? extends T> target)
    See the factory configuration examples at FactoryModuleBuilder.
    <T> FactoryModuleBuilder implement(Class<T> source, Annotation annotation, Class<? extends T> target)
    See the factory configuration examples at FactoryModuleBuilder.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Constructors

    public FactoryModuleBuilder ()

    Public Methods

    public Module build (Key<F> factoryInterface)

    public Module build (TypeLiteral<F> factoryInterface)

    See the factory configuration examples at FactoryModuleBuilder.

    public Module build (Class<F> factoryInterface)

    See the factory configuration examples at FactoryModuleBuilder.

    public FactoryModuleBuilder implement (Key<T> source, TypeLiteral<? extends T> target)

    See the factory configuration examples at FactoryModuleBuilder.

    public FactoryModuleBuilder implement (Key<T> source, Class<? extends T> target)

    See the factory configuration examples at FactoryModuleBuilder.

    public FactoryModuleBuilder implement (TypeLiteral<T> source, TypeLiteral<? extends T> target)

    See the factory configuration examples at FactoryModuleBuilder.

    public FactoryModuleBuilder implement (TypeLiteral<T> source, Class<? extends T> target)

    See the factory configuration examples at FactoryModuleBuilder.

    public FactoryModuleBuilder implement (TypeLiteral<T> source, Class<? extends Annotation> annotationType, TypeLiteral<? extends T> target)

    See the factory configuration examples at FactoryModuleBuilder.

    public FactoryModuleBuilder implement (TypeLiteral<T> source, Class<? extends Annotation> annotationType, Class<? extends T> target)

    See the factory configuration examples at FactoryModuleBuilder.

    public FactoryModuleBuilder implement (TypeLiteral<T> source, Annotation annotation, TypeLiteral<? extends T> target)

    See the factory configuration examples at FactoryModuleBuilder.

    public FactoryModuleBuilder implement (TypeLiteral<T> source, Annotation annotation, Class<? extends T> target)

    See the factory configuration examples at FactoryModuleBuilder.

    public FactoryModuleBuilder implement (Class<T> source, TypeLiteral<? extends T> target)

    See the factory configuration examples at FactoryModuleBuilder.

    public FactoryModuleBuilder implement (Class<T> source, Class<? extends T> target)

    See the factory configuration examples at FactoryModuleBuilder.

    public FactoryModuleBuilder implement (Class<T> source, Class<? extends Annotation> annotationType, TypeLiteral<? extends T> target)

    See the factory configuration examples at FactoryModuleBuilder.

    public FactoryModuleBuilder implement (Class<T> source, Class<? extends Annotation> annotationType, Class<? extends T> target)

    See the factory configuration examples at FactoryModuleBuilder.

    public FactoryModuleBuilder implement (Class<T> source, Annotation annotation, TypeLiteral<? extends T> target)

    See the factory configuration examples at FactoryModuleBuilder.

    public FactoryModuleBuilder implement (Class<T> source, Annotation annotation, Class<? extends T> target)

    See the factory configuration examples at FactoryModuleBuilder.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/assistedinject/AssistedMethod.html0000755000175000017500000004157711704661106030172 0ustar tonytony AssistedMethod | Guice
    public interface

    AssistedMethod

    com.google.inject.assistedinject.AssistedMethod

    Class Overview

    Details about how a method in an assisted inject factory will be assisted.

    Summary

    Public Methods
    abstract Set<Dependency<?>> getDependencies()
    Returns all non-assisted dependencies required to construct and inject the implementation.
    abstract Method getFactoryMethod()
    Returns the factory method that is being assisted.
    abstract Constructor<?> getImplementationConstructor()
    Returns the constructor that will be used to construct instances of the implementation.
    abstract TypeLiteral<?> getImplementationType()
    Returns the implementation type that will be created when the method is used.

    Public Methods

    public abstract Set<Dependency<?>> getDependencies ()

    Returns all non-assisted dependencies required to construct and inject the implementation.

    public abstract Method getFactoryMethod ()

    Returns the factory method that is being assisted.

    public abstract Constructor<?> getImplementationConstructor ()

    Returns the constructor that will be used to construct instances of the implementation.

    public abstract TypeLiteral<?> getImplementationType ()

    Returns the implementation type that will be created when the method is used.

    ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/assistedinject/AssistedInjectTargetVisitor.htmlsisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/assistedinject/AssistedInjectTargetVisitor.htm0000755000175000017500000005264711704661106032541 0ustar tonytony AssistedInjectTargetVisitor | Guice
    public interface

    AssistedInjectTargetVisitor

    implements BindingTargetVisitor<T, V>
    com.google.inject.assistedinject.AssistedInjectTargetVisitor<T, V>

    Class Overview

    A visitor for the AssistedInject extension.

    If your BindingTargetVisitor implements this interface, bindings created by using FactoryModuleBuilder will be visited through this interface.

    Summary

    Public Methods
    abstract V visit(AssistedInjectBinding<? extends T> assistedInjectBinding)
    Visits an AssistedInjectBinding created through FactoryModuleBuilder.
    [Expand]
    Inherited Methods
    From interface com.google.inject.spi.BindingTargetVisitor

    Public Methods

    public abstract V visit (AssistedInjectBinding<? extends T> assistedInjectBinding)

    Visits an AssistedInjectBinding created through FactoryModuleBuilder.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/assistedinject/AssistedInjectBinding.html0000755000175000017500000003500611704661106031447 0ustar tonytony AssistedInjectBinding | Guice
    public interface

    AssistedInjectBinding

    com.google.inject.assistedinject.AssistedInjectBinding<T>

    Class Overview

    A binding for a factory created by FactoryModuleBuilder.

    Summary

    Public Methods
    abstract Collection<AssistedMethod> getAssistedMethods()
    Returns an AssistedMethod for each method in the factory.
    abstract Key<T> getKey()
    Returns the Key for the factory binding.

    Public Methods

    public abstract Collection<AssistedMethod> getAssistedMethods ()

    Returns an AssistedMethod for each method in the factory.

    public abstract Key<T> getKey ()

    Returns the Key for the factory binding.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/assistedinject/AssistedInject.html0000755000175000017500000003645711704661106030167 0ustar tonytony AssistedInject | Guice
    public abstract @interface

    AssistedInject

    implements Annotation
    com.google.inject.assistedinject.AssistedInject

    Class Overview

    When used in tandem with FactoryModuleBuilder, constructors annotated with @AssistedInject indicate that multiple constructors can be injected, each with different parameters. AssistedInject annotations should not be mixed with @Inject annotations. The assisted parameters must exactly match one corresponding factory method within the factory interface, but the parameters do not need to be in the same order. Constructors annotated with AssistedInject are created by Guice and receive all the benefits (such as AOP).

    Obsolete Usage: When used in tandem with FactoryProvider, constructors annotated with @AssistedInject trigger a "backwards compatibility mode". The assisted parameters must exactly match one corresponding factory method within the factory interface and all must be in the same order as listed in the factory. In this backwards compatable mode, constructors annotated with AssistedInject are not created by Guice and thus receive none of the benefits.

    Constructor parameters must be either supplied by the factory interface and marked with @Assisted, or they must be injectable.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/assistedinject/Assisted.html0000755000175000017500000003371111704661106027020 0ustar tonytony Assisted | Guice
    public abstract @interface

    Assisted

    implements Annotation
    com.google.inject.assistedinject.Assisted

    Class Overview

    Annotates an injected parameter or field whose value comes from an argument to a factory method.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/TypeLiteral.html0000755000175000017500000011236711704661106024470 0ustar tonytony TypeLiteral | Guice
    public class

    TypeLiteral

    extends Object
    java.lang.Object
       ↳ com.google.inject.TypeLiteral<T>

    Class Overview

    Represents a generic type T. Java doesn't yet provide a way to represent generic types, so this class does. Forces clients to create a subclass of this class which enables retrieval the type information even at runtime.

    For example, to create a type literal for List<String>, you can create an empty anonymous inner class:

    TypeLiteral<List<String>> list = new TypeLiteral<List<String>>() {;}

    Along with modeling generic types, this class can resolve type parameters. For example, to figure out what type keySet() returns on a Map<Integer, String>, use this code:

       TypeLiteral<Map<Integer, String>> mapType
           = new TypeLiteral<Map<Integer, String>>() {;
       TypeLiteral keySetType
           = mapType.getReturnType(Map.class.getMethod("keySet"));
       System.out.println(keySetType); // prints "Set"}

    Summary

    Protected Constructors
    TypeLiteral()
    Constructs a new type literal.
    Public Methods
    final boolean equals(Object o)
    static <T> TypeLiteral<T> get(Class<T> type)
    Gets type literal for the given Class instance.
    static TypeLiteral<?> get(Type type)
    Gets type literal for the given Type instance.
    List<TypeLiteral<?>> getExceptionTypes(Member methodOrConstructor)
    Returns the resolved generic exception types thrown by constructor.
    TypeLiteral<?> getFieldType(Field field)
    Returns the resolved generic type of field.
    List<TypeLiteral<?>> getParameterTypes(Member methodOrConstructor)
    Returns the resolved generic parameter types of methodOrConstructor.
    final Class<? super T> getRawType()
    Returns the raw (non-generic) type for this type.
    TypeLiteral<?> getReturnType(Method method)
    Returns the resolved generic return type of method.
    TypeLiteral<?> getSupertype(Class<?> supertype)
    Returns the generic form of supertype.
    final Type getType()
    Gets underlying Type instance.
    final int hashCode()
    final String toString()
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Protected Constructors

    protected TypeLiteral ()

    Constructs a new type literal. Derives represented class from type parameter.

    Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

    Public Methods

    public final boolean equals (Object o)

    public static TypeLiteral<T> get (Class<T> type)

    Gets type literal for the given Class instance.

    public static TypeLiteral<?> get (Type type)

    Gets type literal for the given Type instance.

    public List<TypeLiteral<?>> getExceptionTypes (Member methodOrConstructor)

    Returns the resolved generic exception types thrown by constructor.

    Parameters
    methodOrConstructor a method or constructor defined by this or any supertype.

    public TypeLiteral<?> getFieldType (Field field)

    Returns the resolved generic type of field.

    Parameters
    field a field defined by this or any superclass.

    public List<TypeLiteral<?>> getParameterTypes (Member methodOrConstructor)

    Returns the resolved generic parameter types of methodOrConstructor.

    Parameters
    methodOrConstructor a method or constructor defined by this or any supertype.

    public final Class<? super T> getRawType ()

    Returns the raw (non-generic) type for this type.

    public TypeLiteral<?> getReturnType (Method method)

    Returns the resolved generic return type of method.

    Parameters
    method a method defined by this or any supertype.

    public TypeLiteral<?> getSupertype (Class<?> supertype)

    Returns the generic form of supertype. For example, if this is ArrayList<String>, this returns Iterable<String> given the input Iterable.class.

    Parameters
    supertype a superclass of, or interface implemented by, this.

    public final Type getType ()

    Gets underlying Type instance.

    public final int hashCode ()

    public final String toString ()

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/Stage.html0000755000175000017500000007312211704661106023270 0ustar tonytony Stage | Guice
    public final enum

    Stage

    extends Enum<E extends Enum<E>>
    java.lang.Object
       ↳ java.lang.Enum<E extends java.lang.Enum<E>>
         ↳ com.google.inject.Stage

    Class Overview

    The stage we're running in.

    Summary

    Enum Values
    Stage  DEVELOPMENT  We want fast startup times at the expense of runtime performance and some up front error checking. 
    Stage  PRODUCTION  We want to catch errors as early as possible and take performance hits up front. 
    Stage  TOOL  We're running in a tool (an IDE plugin for example). 
    Public Methods
    static Stage valueOf(String name)
    final static Stage[] values()
    [Expand]
    Inherited Methods
    From class java.lang.Enum
    From class java.lang.Object
    From interface java.lang.Comparable

    Enum Values

    public static final Stage DEVELOPMENT

    Since: API Level

    We want fast startup times at the expense of runtime performance and some up front error checking.

    public static final Stage PRODUCTION

    Since: API Level

    We want to catch errors as early as possible and take performance hits up front.

    public static final Stage TOOL

    Since: API Level

    We're running in a tool (an IDE plugin for example). We need binding meta data but not a functioning Injector. Do not inject members of instances. Do not load eager singletons. Do as little as possible so our tools run nice and snappy. Injectors created in this stage cannot be used to satisfy injections.

    Public Methods

    public static Stage valueOf (String name)

    public static final Stage[] values ()

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/Singleton.html0000755000175000017500000004025111704661106024164 0ustar tonytony Singleton | Guice
    public abstract @interface

    Singleton

    implements Annotation
    com.google.inject.Singleton

    Class Overview

    Apply this to implementation classes when you want only one instance (per Injector) to be reused for all injections for that binding.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/Scopes.html0000755000175000017500000005575511704661106023475 0ustar tonytony Scopes | Guice
    public class

    Scopes

    extends Object
    java.lang.Object
       ↳ com.google.inject.Scopes

    Class Overview

    Built-in scope implementations.

    Summary

    Constants
    Scope NO_SCOPE No scope; the same as not applying any scope at all.
    Scope SINGLETON One instance per Injector.
    Public Methods
    static boolean isSingleton(Binding<?> binding)
    Returns true if binding is singleton-scoped.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Constants

    public static final Scope NO_SCOPE

    No scope; the same as not applying any scope at all. Each time the Injector obtains an instance of an object with "no scope", it injects this instance then immediately forgets it. When the next request for the same binding arrives it will need to obtain the instance over again.

    This exists only in case a class has been annotated with a scope annotation such as @Singleton, and you need to override this to "no scope" in your binding.

    public static final Scope SINGLETON

    One instance per Injector. Also see @Singleton.

    Public Methods

    public static boolean isSingleton (Binding<?> binding)

    Returns true if binding is singleton-scoped. If the binding is a linked key binding and belongs to an injector (ie. it was retrieved via Injector.getBinding()), then this method will also true if the target binding is singleton-scoped.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/ScopeAnnotation.html0000755000175000017500000004056411704661106025335 0ustar tonytony ScopeAnnotation | Guice
    public abstract @interface

    ScopeAnnotation

    implements Annotation
    com.google.inject.ScopeAnnotation

    Class Overview

    Annotates annotations which are used for scoping. Only one such annotation may apply to a single implementation class. You must also annotate scope annotations with @Retention(RUNTIME). For example:

       @Retention(RUNTIME)
       @Target(TYPE, METHOD)
       @ScopeAnnotation
       public @interface SessionScoped {}
     

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/Scope.html0000755000175000017500000004404711704661106023302 0ustar tonytony Scope | Guice
    public interface

    Scope

    com.google.inject.Scope

    Class Overview

    A scope is a level of visibility that instances provided by Guice may have. By default, an instance created by the Injector has no scope, meaning it has no state from the framework's perspective -- the Injector creates it, injects it once into the class that required it, and then immediately forgets it. Associating a scope with a particular binding allows the created instance to be "remembered" and possibly used again for other injections.

    An example of a scope is SINGLETON.

    Summary

    Public Methods
    abstract <T> Provider<T> scope(Key<T> key, Provider<T> unscoped)
    Scopes a provider.
    abstract String toString()
    A short but useful description of this scope.

    Public Methods

    public abstract Provider<T> scope (Key<T> key, Provider<T> unscoped)

    Scopes a provider. The returned provider returns objects from this scope. If an object does not exist in this scope, the provider can use the given unscoped provider to retrieve one.

    Scope implementations are strongly encouraged to override toString() in the returned provider and include the backing provider's toString() output.

    Parameters
    key binding key
    unscoped locates an instance when one doesn't already exist in this scope.
    Returns
    • a new provider which only delegates to the given unscoped provider when an instance of the requested object doesn't already exist in this scope

    public abstract String toString ()

    A short but useful description of this scope. For comparison, the standard scopes that ship with guice use the descriptions "Scopes.SINGLETON", "ServletScopes.SESSION" and "ServletScopes.REQUEST".

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/ProvisionException.html0000755000175000017500000007375111704661106026104 0ustar tonytony ProvisionException | Guice
    public final class

    ProvisionException

    extends RuntimeException
    java.lang.Object
       ↳ java.lang.Throwable
         ↳ java.lang.Exception
           ↳ java.lang.RuntimeException
             ↳ com.google.inject.ProvisionException

    Class Overview

    Indicates that there was a runtime failure while providing an instance.

    Summary

    Public Constructors
    ProvisionException(Iterable<Message> messages)
    Creates a ProvisionException containing messages.
    ProvisionException(String message)
    ProvisionException(String message, Throwable cause)
    Public Methods
    Collection<Message> getErrorMessages()
    Returns messages for the errors that caused this exception.
    String getMessage()
    [Expand]
    Inherited Methods
    From class java.lang.Throwable
    From class java.lang.Object

    Public Constructors

    public ProvisionException (Iterable<Message> messages)

    Creates a ProvisionException containing messages.

    public ProvisionException (String message)

    public ProvisionException (String message, Throwable cause)

    Public Methods

    public Collection<Message> getErrorMessages ()

    Returns messages for the errors that caused this exception.

    public String getMessage ()

    Since: API Level

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/Provides.html0000755000175000017500000004032511704661106024017 0ustar tonytony Provides | Guice
    public abstract @interface

    Provides

    implements Annotation
    com.google.inject.Provides

    Class Overview

    Annotates methods of a Module to create a provider method binding. The method's return type is bound to it's returned value. Guice will pass dependencies to the method as parameters.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/Provider.html0000755000175000017500000005121011704661106024011 0ustar tonytony Provider | Guice
    public interface

    Provider

    implements Provider<T>
    com.google.inject.Provider<T>
    Known Indirect Subclasses

    Class Overview

    An object capable of providing instances of type T. Providers are used in numerous ways by Guice:

    • When the default means for obtaining instances (an injectable or parameterless constructor) is insufficient for a particular binding, the module can specify a custom Provider instead, to control exactly how Guice creates or obtains instances for the binding.
    • An implementation class may always choose to have a Provider<T> instance injected, rather than having a T injected directly. This may give you access to multiple instances, instances you wish to safely mutate and discard, instances which are out of scope (e.g. using a @RequestScoped object from within a @SessionScoped object), or instances that will be initialized lazily.
    • A custom Scope is implemented as a decorator of Provider<T>, which decides when to delegate to the backing provider and when to provide the instance some other way.
    • The Injector offers access to the Provider<T> it uses to fulfill requests for a given key, via the getProvider(Key) methods.

    Summary

    Public Methods
    abstract T get()
    Provides an instance of T.
    [Expand]
    Inherited Methods
    From interface javax.inject.Provider

    Public Methods

    public abstract T get ()

    Provides an instance of T. Must never return null.

    Throws
    OutOfScopeException when an attempt is made to access a scoped object while the scope in question is not currently active
    ProvisionException if an instance cannot be provided. Such exceptions include messages and throwables to describe why provision failed.
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/ProvidedBy.html0000755000175000017500000004002411704661106024267 0ustar tonytony ProvidedBy | Guice
    public abstract @interface

    ProvidedBy

    implements Annotation
    com.google.inject.ProvidedBy

    Class Overview

    A pointer to the default provider type for a type.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/PrivateModule.html0000755000175000017500000020341611704661106025006 0ustar tonytony PrivateModule | Guice
    public abstract class

    PrivateModule

    extends Object
    implements Module
    java.lang.Object
       ↳ com.google.inject.PrivateModule

    Class Overview

    A module whose configuration information is hidden from its environment by default. Only bindings that are explicitly exposed will be available to other modules and to the users of the injector. This module may expose the bindings it creates and the bindings of the modules it installs.

    A private module can be nested within a regular module or within another private module using install(). Its bindings live in a new environment that inherits bindings, type converters, scopes, and interceptors from the surrounding ("parent") environment. When you nest multiple private modules, the result is a tree of environments where the injector's environment is the root.

    Guice EDSL bindings can be exposed with expose(). @Provides bindings can be exposed with the @Exposed annotation:

     public class FooBarBazModule extends PrivateModule {
       protected void configure() {
         bind(Foo.class).to(RealFoo.class);
         expose(Foo.class);
    
         install(new TransactionalBarModule());
         expose(Bar.class).annotatedWith(Transactional.class);
    
         bind(SomeImplementationDetail.class);
         install(new MoreImplementationDetailsModule());
       }
    
       @Provides @Exposed
       public Baz provideBaz() {
         return new SuperBaz();
       }
     }
     

    Private modules are implemented using parent injectors. When it can satisfy their dependencies, just-in-time bindings will be created in the root environment. Such bindings are shared among all environments in the tree.

    The scope of a binding is constrained to its environment. A singleton bound in a private module will be unique to its environment. But a binding for the same type in a different private module will yield a different instance.

    A shared binding that injects the Injector gets the root injector, which only has access to bindings in the root environment. An explicit binding that injects the Injector gets access to all bindings in the child environment.

    To promote a just-in-time binding to an explicit binding, bind it:

       bind(FooImpl.class);
     

    Summary

    Public Constructors
    PrivateModule()
    Public Methods
    synchronized final void configure(Binder binder)
    Contributes bindings and other configurations for this module to binder.
    Protected Methods
    final void addError(Message message)
    final void addError(String message, Object... arguments)
    final void addError(Throwable t)
    final <T> LinkedBindingBuilder<T> bind(Key<T> key)
    final <T> AnnotatedBindingBuilder<T> bind(TypeLiteral<T> typeLiteral)
    final <T> AnnotatedBindingBuilder<T> bind(Class<T> clazz)
    final AnnotatedConstantBindingBuilder bindConstant()
    final void bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)
    void bindListener(Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)
    final void bindScope(Class<? extends Annotation> scopeAnnotation, Scope scope)
    final PrivateBinder binder()
    Returns the current binder.
    abstract void configure()
    Creates bindings and other configurations private to this module.
    final void convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)
    final Stage currentStage()
    final <T> void expose(Key<T> key)
    Makes the binding for key available to other modules and the injector.
    final AnnotatedElementBuilder expose(TypeLiteral<?> type)
    Makes a binding for type available to other modules and the injector.
    final AnnotatedElementBuilder expose(Class<?> type)
    Makes a binding for type available to other modules and the injector.
    <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> type)
    <T> MembersInjector<T> getMembersInjector(Class<T> type)
    final <T> Provider<T> getProvider(Key<T> key)
    final <T> Provider<T> getProvider(Class<T> type)
    final void install(Module module)
    final void requestInjection(Object instance)
    final void requestStaticInjection(Class...<?> types)
    final void requireBinding(Key<?> key)
    Instructs Guice to require a binding to the given key.
    final void requireBinding(Class<?> type)
    Instructs Guice to require a binding to the given type.
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.Module

    Public Constructors

    public PrivateModule ()

    Public Methods

    public final synchronized void configure (Binder binder)

    Contributes bindings and other configurations for this module to binder.

    Do not invoke this method directly to install submodules. Instead use install(Module), which ensures that provider methods are discovered.

    Protected Methods

    protected final void addError (Message message)

    protected final void addError (String message, Object... arguments)

    protected final void addError (Throwable t)

    protected final LinkedBindingBuilder<T> bind (Key<T> key)

    See Also

    protected final AnnotatedBindingBuilder<T> bind (TypeLiteral<T> typeLiteral)

    protected final AnnotatedBindingBuilder<T> bind (Class<T> clazz)

    See Also

    protected final AnnotatedConstantBindingBuilder bindConstant ()

    See Also

    protected final void bindInterceptor (Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)

    protected void bindListener (Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)

    protected final void bindScope (Class<? extends Annotation> scopeAnnotation, Scope scope)

    protected final PrivateBinder binder ()

    Returns the current binder.

    protected abstract void configure ()

    Creates bindings and other configurations private to this module. Use expose() to make the bindings in this module available externally.

    protected final void convertToTypes (Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)

    protected final Stage currentStage ()

    See Also

    protected final void expose (Key<T> key)

    Makes the binding for key available to other modules and the injector.

    protected final AnnotatedElementBuilder expose (TypeLiteral<?> type)

    Makes a binding for type available to other modules and the injector. Use annotatedWith() to expose type with a binding annotation.

    protected final AnnotatedElementBuilder expose (Class<?> type)

    Makes a binding for type available to other modules and the injector. Use annotatedWith() to expose type with a binding annotation.

    protected MembersInjector<T> getMembersInjector (TypeLiteral<T> type)

    protected MembersInjector<T> getMembersInjector (Class<T> type)

    protected final Provider<T> getProvider (Key<T> key)

    See Also

    protected final Provider<T> getProvider (Class<T> type)

    protected final void install (Module module)

    See Also

    protected final void requestInjection (Object instance)

    protected final void requestStaticInjection (Class...<?> types)

    protected final void requireBinding (Key<?> key)

    Instructs Guice to require a binding to the given key.

    protected final void requireBinding (Class<?> type)

    Instructs Guice to require a binding to the given type.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/PrivateBinder.html0000755000175000017500000012077611704661106024773 0ustar tonytony PrivateBinder | Guice
    public interface

    PrivateBinder

    implements Binder
    com.google.inject.PrivateBinder

    Class Overview

    Returns a binder whose configuration information is hidden from its environment by default. See PrivateModule for details.

    Summary

    Public Methods
    abstract void expose(Key<?> key)
    Makes the binding for key available to the enclosing environment
    abstract AnnotatedElementBuilder expose(TypeLiteral<?> type)
    Makes a binding for type available to the enclosing environment.
    abstract AnnotatedElementBuilder expose(Class<?> type)
    Makes a binding for type available to the enclosing environment.
    abstract PrivateBinder skipSources(Class... classesToSkip)
    Returns a binder that skips classesToSkip when identify the calling code.
    abstract PrivateBinder withSource(Object source)
    Returns a binder that uses source as the reference location for configuration errors.
    [Expand]
    Inherited Methods
    From interface com.google.inject.Binder

    Public Methods

    public abstract void expose (Key<?> key)

    Makes the binding for key available to the enclosing environment

    public abstract AnnotatedElementBuilder expose (TypeLiteral<?> type)

    Makes a binding for type available to the enclosing environment. Use annotatedWith() to expose type with a binding annotation.

    public abstract AnnotatedElementBuilder expose (Class<?> type)

    Makes a binding for type available to the enclosing environment. Use annotatedWith() to expose type with a binding annotation.

    public abstract PrivateBinder skipSources (Class... classesToSkip)

    Returns a binder that skips classesToSkip when identify the calling code. The caller's StackTraceElement is used to locate the source of configuration errors.

    Parameters
    classesToSkip library classes that create bindings on behalf of their clients.
    Returns
    • a binder that shares its configuration with this binder.

    public abstract PrivateBinder withSource (Object source)

    Returns a binder that uses source as the reference location for configuration errors. This is typically a StackTraceElement for .java source but it could any binding source, such as the path to a .properties file.

    Parameters
    source any object representing the source location and has a concise toString() value
    Returns
    • a binder that shares its configuration with this binder
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/OutOfScopeException.html0000755000175000017500000006640611704661106026141 0ustar tonytony OutOfScopeException | Guice
    public final class

    OutOfScopeException

    extends RuntimeException
    java.lang.Object
       ↳ java.lang.Throwable
         ↳ java.lang.Exception
           ↳ java.lang.RuntimeException
             ↳ com.google.inject.OutOfScopeException

    Class Overview

    Thrown from get() when an attempt is made to access a scoped object while the scope in question is not currently active.

    Summary

    Public Constructors
    OutOfScopeException(String message)
    OutOfScopeException(String message, Throwable cause)
    OutOfScopeException(Throwable cause)
    [Expand]
    Inherited Methods
    From class java.lang.Throwable
    From class java.lang.Object

    Public Constructors

    public OutOfScopeException (String message)

    public OutOfScopeException (String message, Throwable cause)

    public OutOfScopeException (Throwable cause)

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/Module.html0000755000175000017500000005073311704661106023455 0ustar tonytony Module | Guice
    public interface

    Module

    com.google.inject.Module
    Known Indirect Subclasses

    Class Overview

    A module contributes configuration information, typically interface bindings, which will be used to create an Injector. A Guice-based application is ultimately composed of little more than a set of Modules and some bootstrapping code.

    Your Module classes can use a more streamlined syntax by extending AbstractModule rather than implementing this interface directly.

    In addition to the bindings configured via configure(Binder), bindings will be created for all methods annotated with @Provides. Use scope and binding annotations on these methods to configure the bindings.

    Summary

    Public Methods
    abstract void configure(Binder binder)
    Contributes bindings and other configurations for this module to binder.

    Public Methods

    public abstract void configure (Binder binder)

    Contributes bindings and other configurations for this module to binder.

    Do not invoke this method directly to install submodules. Instead use install(Module), which ensures that provider methods are discovered.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/MembersInjector.html0000755000175000017500000003675311704661106025326 0ustar tonytony MembersInjector | Guice
    public interface

    MembersInjector

    com.google.inject.MembersInjector<T>

    Class Overview

    Injects dependencies into the fields and methods on instances of type T. Ignores the presence or absence of an injectable constructor.

    Summary

    Public Methods
    abstract void injectMembers(T instance)
    Injects dependencies into the fields and methods of instance.

    Public Methods

    public abstract void injectMembers (T instance)

    Injects dependencies into the fields and methods of instance. Ignores the presence or absence of an injectable constructor.

    Whenever Guice creates an instance, it performs this injection automatically (after first performing constructor injection), so if you're able to let Guice create all your objects for you, you'll never need to use this method.

    Parameters
    instance to inject members on. May be null.
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/Key.html0000755000175000017500000014334711704661106022764 0ustar tonytony Key | Guice
    public class

    Key

    extends Object
    java.lang.Object
       ↳ com.google.inject.Key<T>

    Class Overview

    Binding key consisting of an injection type and an optional annotation. Matches the type and annotation at a point of injection.

    For example, Key.get(Service.class, Transactional.class) will match:

       @Inject
       public void setService(@Transactional Service service) {
         ...
       }
     

    Key supports generic types via subclassing just like TypeLiteral.

    Keys do not differentiate between primitive types (int, char, etc.) and their correpsonding wrapper types (Integer, Character, etc.). Primitive types will be replaced with their wrapper types when keys are created.

    Summary

    Protected Constructors
    Key()
    Constructs a new key.
    Key(Class<? extends Annotation> annotationType)
    Constructs a new key.
    Key(Annotation annotation)
    Constructs a new key.
    Public Methods
    final boolean equals(Object o)
    static <T> Key<T> get(TypeLiteral<T> typeLiteral)
    Gets a key for an injection type.
    static <T> Key<T> get(TypeLiteral<T> typeLiteral, Class<? extends Annotation> annotationType)
    Gets a key for an injection type and an annotation type.
    static <T> Key<T> get(TypeLiteral<T> typeLiteral, Annotation annotation)
    Gets a key for an injection type and an annotation.
    static <T> Key<T> get(Class<T> type)
    Gets a key for an injection type.
    static <T> Key<T> get(Class<T> type, Class<? extends Annotation> annotationType)
    Gets a key for an injection type and an annotation type.
    static <T> Key<T> get(Class<T> type, Annotation annotation)
    Gets a key for an injection type and an annotation.
    static Key<?> get(Type type)
    Gets a key for an injection type.
    static Key<?> get(Type type, Class<? extends Annotation> annotationType)
    Gets a key for an injection type and an annotation type.
    static Key<?> get(Type type, Annotation annotation)
    Gets a key for an injection type and an annotation.
    final Annotation getAnnotation()
    Gets the annotation.
    final Class<? extends Annotation> getAnnotationType()
    Gets the annotation type.
    final TypeLiteral<T> getTypeLiteral()
    Gets the key type.
    boolean hasAttributes()
    Returns true if this key has annotation attributes.
    final int hashCode()
    <T> Key<T> ofType(TypeLiteral<T> type)
    Returns a new key of the specified type with the same annotation as this key.
    <T> Key<T> ofType(Class<T> type)
    Returns a new key of the specified type with the same annotation as this key.
    Key<?> ofType(Type type)
    Returns a new key of the specified type with the same annotation as this key.
    final String toString()
    Key<T> withoutAttributes()
    Returns this key without annotation attributes, i.e.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Protected Constructors

    protected Key ()

    Constructs a new key. Derives the type from this class's type parameter.

    Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

    Example usage for a binding of type Foo:

    new Key<Foo>() {}.

    protected Key (Class<? extends Annotation> annotationType)

    Constructs a new key. Derives the type from this class's type parameter.

    Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

    Example usage for a binding of type Foo annotated with @Bar:

    new Key<Foo>(Bar.class) {}.

    protected Key (Annotation annotation)

    Constructs a new key. Derives the type from this class's type parameter.

    Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.

    Example usage for a binding of type Foo annotated with @Bar:

    new Key<Foo>(new Bar()) {}.

    Public Methods

    public final boolean equals (Object o)

    public static Key<T> get (TypeLiteral<T> typeLiteral)

    Gets a key for an injection type.

    public static Key<T> get (TypeLiteral<T> typeLiteral, Class<? extends Annotation> annotationType)

    Gets a key for an injection type and an annotation type.

    public static Key<T> get (TypeLiteral<T> typeLiteral, Annotation annotation)

    Gets a key for an injection type and an annotation.

    public static Key<T> get (Class<T> type)

    Gets a key for an injection type.

    public static Key<T> get (Class<T> type, Class<? extends Annotation> annotationType)

    Gets a key for an injection type and an annotation type.

    public static Key<T> get (Class<T> type, Annotation annotation)

    Gets a key for an injection type and an annotation.

    public static Key<?> get (Type type)

    Gets a key for an injection type.

    public static Key<?> get (Type type, Class<? extends Annotation> annotationType)

    Gets a key for an injection type and an annotation type.

    public static Key<?> get (Type type, Annotation annotation)

    Gets a key for an injection type and an annotation.

    public final Annotation getAnnotation ()

    Gets the annotation.

    public final Class<? extends Annotation> getAnnotationType ()

    Gets the annotation type.

    public final TypeLiteral<T> getTypeLiteral ()

    Gets the key type.

    public boolean hasAttributes ()

    Returns true if this key has annotation attributes.

    public final int hashCode ()

    public Key<T> ofType (TypeLiteral<T> type)

    Returns a new key of the specified type with the same annotation as this key.

    public Key<T> ofType (Class<T> type)

    Returns a new key of the specified type with the same annotation as this key.

    public Key<?> ofType (Type type)

    Returns a new key of the specified type with the same annotation as this key.

    public final String toString ()

    public Key<T> withoutAttributes ()

    Returns this key without annotation attributes, i.e. with only the annotation type.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/Injector.html0000755000175000017500000014471511704661106024011 0ustar tonytony Injector | Guice
    public interface

    Injector

    com.google.inject.Injector

    Class Overview

    Builds the graphs of objects that make up your application. The injector tracks the dependencies for each type and uses bindings to inject them. This is the core of Guice, although you rarely interact with it directly. This "behind-the-scenes" operation is what distinguishes dependency injection from its cousin, the service locator pattern.

    Contains several default bindings:

    • This Injector instance itself
    • A Provider<T> for each binding of type T
    • The java.util.logging.Logger for the class being injected
    • The Stage in which the Injector was created
    Injectors are created using the facade class Guice.

    An injector can also inject the dependencies of already-constructed instances. This can be used to interoperate with objects created by other frameworks or services.

    Injectors can be hierarchical. Child injectors inherit the configuration of their parent injectors, but the converse does not hold.

    The injector's internal bindings are available for introspection. This enables tools and extensions to operate on an injector reflectively.

    Summary

    Public Methods
    abstract Injector createChildInjector(Module... modules)
    Returns a new injector that inherits all state from this injector.
    abstract Injector createChildInjector(Iterable<? extends Module> modules)
    Returns a new injector that inherits all state from this injector.
    abstract <T> List<Binding<T>> findBindingsByType(TypeLiteral<T> type)
    Returns all explicit bindings for type.
    abstract Map<Key<?>, Binding<?>> getAllBindings()
    Returns a snapshot of this injector's bindings, both explicit and just-in-time.
    abstract <T> Binding<T> getBinding(Key<T> key)
    Returns the binding for the given injection key.
    abstract <T> Binding<T> getBinding(Class<T> type)
    Returns the binding for the given type.
    abstract Map<Key<?>, Binding<?>> getBindings()
    Returns this injector's explicit bindings.
    abstract <T> Binding<T> getExistingBinding(Key<T> key)
    Returns the binding if it already exists, or null if does not exist.
    abstract <T> T getInstance(Key<T> key)
    Returns the appropriate instance for the given injection key; equivalent to getProvider(key).get().
    abstract <T> T getInstance(Class<T> type)
    Returns the appropriate instance for the given injection type; equivalent to getProvider(type).get().
    abstract <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral)
    Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
    abstract <T> MembersInjector<T> getMembersInjector(Class<T> type)
    Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
    abstract Injector getParent()
    Returns this injector's parent, or null if this is a top-level injector.
    abstract <T> Provider<T> getProvider(Key<T> key)
    Returns the provider used to obtain instances for the given injection key.
    abstract <T> Provider<T> getProvider(Class<T> type)
    Returns the provider used to obtain instances for the given type.
    abstract Map<Class<? extends Annotation>, Scope> getScopeBindings()
    Returns a map containing all scopes in the injector.
    abstract Set<TypeConverterBinding> getTypeConverterBindings()
    Returns a set containing all type converter bindings in the injector.
    abstract void injectMembers(Object instance)
    Injects dependencies into the fields and methods of instance.

    Public Methods

    public abstract Injector createChildInjector (Module... modules)

    Returns a new injector that inherits all state from this injector. All bindings, scopes, interceptors and type converters are inherited -- they are visible to the child injector. Elements of the child injector are not visible to its parent.

    Just-in-time bindings created for child injectors will be created in an ancestor injector whenever possible. This allows for scoped instances to be shared between injectors. Use explicit bindings to prevent bindings from being shared with the parent injector.

    No key may be bound by both an injector and one of its ancestors. This includes just-in-time bindings. The lone exception is the key for Injector.class, which is bound by each injector to itself.

    public abstract Injector createChildInjector (Iterable<? extends Module> modules)

    Returns a new injector that inherits all state from this injector. All bindings, scopes, interceptors and type converters are inherited -- they are visible to the child injector. Elements of the child injector are not visible to its parent.

    Just-in-time bindings created for child injectors will be created in an ancestor injector whenever possible. This allows for scoped instances to be shared between injectors. Use explicit bindings to prevent bindings from being shared with the parent injector. Optional injections in just-in-time bindings (created in the parent injector) may be silently ignored if the optional dependencies are from the child injector.

    No key may be bound by both an injector and one of its ancestors. This includes just-in-time bindings. The lone exception is the key for Injector.class, which is bound by each injector to itself.

    public abstract List<Binding<T>> findBindingsByType (TypeLiteral<T> type)

    Returns all explicit bindings for type.

    This method is part of the Guice SPI and is intended for use by tools and extensions.

    public abstract Map<Key<?>, Binding<?>> getAllBindings ()

    Returns a snapshot of this injector's bindings, both explicit and just-in-time. The returned map is immutable; it contains only the bindings that were present when getAllBindings() was invoked. Subsequent calls may return a map with additional just-in-time bindings.

    The returned map does not include bindings inherited from a parent injector, should one exist.

    This method is part of the Guice SPI and is intended for use by tools and extensions.

    public abstract Binding<T> getBinding (Key<T> key)

    Returns the binding for the given injection key. This will be an explicit bindings if the key was bound explicitly by a module, or an implicit binding otherwise. The implicit binding will be created if necessary.

    This method is part of the Guice SPI and is intended for use by tools and extensions.

    Throws
    ConfigurationException if this injector cannot find or create the binding.

    public abstract Binding<T> getBinding (Class<T> type)

    Returns the binding for the given type. This will be an explicit bindings if the injection key was bound explicitly by a module, or an implicit binding otherwise. The implicit binding will be created if necessary.

    This method is part of the Guice SPI and is intended for use by tools and extensions.

    Throws
    ConfigurationException if this injector cannot find or create the binding.

    public abstract Map<Key<?>, Binding<?>> getBindings ()

    Returns this injector's explicit bindings.

    The returned map does not include bindings inherited from a parent injector, should one exist. The returned map is guaranteed to iterate (for example, with its entrySet() iterator) in the order of insertion. In other words, the order in which bindings appear in user Modules.

    This method is part of the Guice SPI and is intended for use by tools and extensions.

    public abstract Binding<T> getExistingBinding (Key<T> key)

    Returns the binding if it already exists, or null if does not exist. Unlike getBinding(Key), this does not attempt to create just-in-time bindings for keys that aren't bound.

    This method is part of the Guice SPI and is intended for use by tools and extensions.

    public abstract T getInstance (Key<T> key)

    Returns the appropriate instance for the given injection key; equivalent to getProvider(key).get(). When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time.

    Throws
    ConfigurationException if this injector cannot find or create the provider.
    ProvisionException if there was a runtime failure while providing an instance.

    public abstract T getInstance (Class<T> type)

    Returns the appropriate instance for the given injection type; equivalent to getProvider(type).get(). When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time.

    Throws
    ConfigurationException if this injector cannot find or create the provider.
    ProvisionException if there was a runtime failure while providing an instance.

    public abstract MembersInjector<T> getMembersInjector (TypeLiteral<T> typeLiteral)

    Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.

    Parameters
    typeLiteral type to get members injector for

    public abstract MembersInjector<T> getMembersInjector (Class<T> type)

    Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. When feasible, use getMembersInjector(TypeLiteral) instead to get increased up front error detection.

    Parameters
    type type to get members injector for

    public abstract Injector getParent ()

    Returns this injector's parent, or null if this is a top-level injector.

    public abstract Provider<T> getProvider (Key<T> key)

    Returns the provider used to obtain instances for the given injection key. When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time.

    Throws
    ConfigurationException if this injector cannot find or create the provider.

    public abstract Provider<T> getProvider (Class<T> type)

    Returns the provider used to obtain instances for the given type. When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time.

    Throws
    ConfigurationException if this injector cannot find or create the provider.

    public abstract Map<Class<? extends Annotation>, Scope> getScopeBindings ()

    Returns a map containing all scopes in the injector. The maps keys are scoping annotations like Singleton.class, and the values are scope instances, such as Scopes.SINGLETON. The returned map is immutable.

    This method is part of the Guice SPI and is intended for use by tools and extensions.

    public abstract Set<TypeConverterBinding> getTypeConverterBindings ()

    Returns a set containing all type converter bindings in the injector. The returned set is immutable.

    This method is part of the Guice SPI and is intended for use by tools and extensions.

    public abstract void injectMembers (Object instance)

    Injects dependencies into the fields and methods of instance. Ignores the presence or absence of an injectable constructor.

    Whenever Guice creates an instance, it performs this injection automatically (after first performing constructor injection), so if you're able to let Guice create all your objects for you, you'll never need to use this method.

    Parameters
    instance to inject members on
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/Inject.html0000755000175000017500000004263211704661106023443 0ustar tonytony Inject | Guice
    public abstract @interface

    Inject

    implements Annotation
    com.google.inject.Inject

    Class Overview

    Annotates members of your implementation class (constructors, methods and fields) into which the Injector should inject values. The Injector fulfills injection requests for:

    • Every instance it constructs. The class being constructed must have exactly one of its constructors marked with @Inject or must have a constructor taking no parameters. The Injector then proceeds to perform method and field injections.
    • Pre-constructed instances passed to injectMembers(Object), toInstance(Object) and toProvider(Provider). In this case all constructors are, of course, ignored.
    • Static fields and methods of classes which any Module has specifically requested static injection for, using requestStaticInjection(Class...).
    In all cases, a member can be injected regardless of its Java access specifier (private, default, protected, public).

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/ImplementedBy.html0000755000175000017500000004003511704661106024760 0ustar tonytony ImplementedBy | Guice
    public abstract @interface

    ImplementedBy

    implements Annotation
    com.google.inject.ImplementedBy

    Class Overview

    A pointer to the default implementation of a type.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/Guice.html0000755000175000017500000006634011704661106023265 0ustar tonytony Guice | Guice
    public final class

    Guice

    extends Object
    java.lang.Object
       ↳ com.google.inject.Guice

    Class Overview

    The entry point to the Guice framework. Creates Injectors from Modules.

    Guice supports a model of development that draws clear boundaries between APIs, Implementations of these APIs, Modules which configure these implementations, and finally Applications which consist of a collection of Modules. It is the Application, which typically defines your main() method, that bootstraps the Guice Injector using the Guice class, as in this example:

         public class FooApplication {
           public static void main(String[] args) {
             Injector injector = Guice.createInjector(
                 new ModuleA(),
                 new ModuleB(),
                 . . .
                 new FooApplicationFlagsModule(args)
             );
    
             // Now just bootstrap the application and you're done
             FooStarter starter = injector.getInstance(FooStarter.class);
             starter.runApplication();
           }
         }
     

    Summary

    Public Methods
    static Injector createInjector(Module... modules)
    Creates an injector for the given set of modules.
    static Injector createInjector(Stage stage, Module... modules)
    Creates an injector for the given set of modules, in a given development stage.
    static Injector createInjector(Stage stage, Iterable<? extends Module> modules)
    Creates an injector for the given set of modules, in a given development stage.
    static Injector createInjector(Iterable<? extends Module> modules)
    Creates an injector for the given set of modules.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Methods

    public static Injector createInjector (Module... modules)

    Creates an injector for the given set of modules.

    Throws
    CreationException if one or more errors occur during injector construction

    public static Injector createInjector (Stage stage, Module... modules)

    Creates an injector for the given set of modules, in a given development stage.

    Throws
    CreationException if one or more errors occur during injector creation.

    public static Injector createInjector (Stage stage, Iterable<? extends Module> modules)

    Creates an injector for the given set of modules, in a given development stage.

    Throws
    CreationException if one or more errors occur during injector construction

    public static Injector createInjector (Iterable<? extends Module> modules)

    Creates an injector for the given set of modules.

    Throws
    CreationException if one or more errors occur during injector creation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/Exposed.html0000755000175000017500000004021611704661106023632 0ustar tonytony Exposed | Guice
    public abstract @interface

    Exposed

    implements Annotation
    com.google.inject.Exposed

    Class Overview

    Acccompanies a @Provides method annotation in a private module to indicate that the provided binding is exposed.

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/CreationException.html0000755000175000017500000006765011704661106025661 0ustar tonytony CreationException | Guice
    public class

    CreationException

    extends RuntimeException
    java.lang.Object
       ↳ java.lang.Throwable
         ↳ java.lang.Exception
           ↳ java.lang.RuntimeException
             ↳ com.google.inject.CreationException

    Class Overview

    Thrown when errors occur while creating a Injector. Includes a list of encountered errors. Clients should catch this exception, log it, and stop execution.

    Summary

    Public Constructors
    CreationException(Collection<Message> messages)
    Creates a CreationException containing messages.
    Public Methods
    Collection<Message> getErrorMessages()
    Returns messages for the errors that caused this exception.
    String getMessage()
    [Expand]
    Inherited Methods
    From class java.lang.Throwable
    From class java.lang.Object

    Public Constructors

    public CreationException (Collection<Message> messages)

    Creates a CreationException containing messages.

    Public Methods

    public Collection<Message> getErrorMessages ()

    Returns messages for the errors that caused this exception.

    public String getMessage ()

    Since: API Level

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/ConfigurationException.html0000755000175000017500000007560511704661106026723 0ustar tonytony ConfigurationException | Guice
    public final class

    ConfigurationException

    extends RuntimeException
    java.lang.Object
       ↳ java.lang.Throwable
         ↳ java.lang.Exception
           ↳ java.lang.RuntimeException
             ↳ com.google.inject.ConfigurationException

    Class Overview

    Thrown when a programming error such as a misplaced annotation, illegal binding, or unsupported scope is found. Clients should catch this exception, log it, and stop execution.

    Summary

    Public Constructors
    ConfigurationException(Iterable<Message> messages)
    Creates a ConfigurationException containing messages.
    Public Methods
    Collection<Message> getErrorMessages()
    Returns messages for the errors that caused this exception.
    String getMessage()
    <E> E getPartialValue()
    Returns a value that was only partially computed due to this exception.
    ConfigurationException withPartialValue(Object partialValue)
    Returns a copy of this configuration exception with the specified partial value.
    [Expand]
    Inherited Methods
    From class java.lang.Throwable
    From class java.lang.Object

    Public Constructors

    public ConfigurationException (Iterable<Message> messages)

    Creates a ConfigurationException containing messages.

    Public Methods

    public Collection<Message> getErrorMessages ()

    Returns messages for the errors that caused this exception.

    public String getMessage ()

    Since: API Level

    public E getPartialValue ()

    Returns a value that was only partially computed due to this exception. The caller can use this while collecting additional configuration problems.

    Returns
    • the partial value, or null if none was set. The type of the partial value is specified by the throwing method.

    public ConfigurationException withPartialValue (Object partialValue)

    Returns a copy of this configuration exception with the specified partial value.

    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/BindingAnnotation.html0000755000175000017500000004061011704661106025626 0ustar tonytony BindingAnnotation | Guice
    public abstract @interface

    BindingAnnotation

    implements Annotation
    com.google.inject.BindingAnnotation

    Class Overview

    Annotates annotations which are used for binding. Only one such annotation may apply to a single injection point. You must also annotate binder annotations with @Retention(RUNTIME). For example:

       @Retention(RUNTIME)
       @Target({ FIELD, PARAMETER, METHOD })
       @BindingAnnotation
       public @interface Transactional {}
     

    Summary

    [Expand]
    Inherited Methods
    From interface java.lang.annotation.Annotation
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/Binding.html0000755000175000017500000007403311704661106023601 0ustar tonytony Binding | Guice
    public interface

    Binding

    implements Element
    com.google.inject.Binding<T>
    Known Indirect Subclasses

    Class Overview

    A mapping from a key (type and optional annotation) to the strategy for getting instances of the type. This interface is part of the introspection API and is intended primarily for use by tools.

    Bindings are created in several ways:

    • Explicitly in a module, via bind() and bindConstant() statements:
           bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);
           bindConstant().annotatedWith(ServerHost.class).to(args[0]);
    • Implicitly by the Injector by following a type's pointer annotations or by using its annotated or default constructor.
    • By converting a bound instance to a different type.
    • For providers, by delegating to the binding for the provided type.

    They exist on both modules and on injectors, and their behaviour is different for each:

    • Module bindings are incomplete and cannot be used to provide instances. This is because the applicable scopes and interceptors may not be known until an injector is created. From a tool's perspective, module bindings are like the injector's source code. They can be inspected or rewritten, but this analysis must be done statically.
    • Injector bindings are complete and valid and can be used to provide instances. From a tools' perspective, injector bindings are like reflection for an injector. They have full runtime information, including the complete graph of injections necessary to satisfy a binding.

    Summary

    Public Methods
    abstract <V> V acceptScopingVisitor(BindingScopingVisitor<V> visitor)
    Accepts a scoping visitor.
    abstract <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> visitor)
    Accepts a target visitor.
    abstract Key<T> getKey()
    Returns the key for this binding.
    abstract Provider<T> getProvider()
    Returns the scoped provider guice uses to fulfill requests for this binding.
    [Expand]
    Inherited Methods
    From interface com.google.inject.spi.Element

    Public Methods

    public abstract V acceptScopingVisitor (BindingScopingVisitor<V> visitor)

    Accepts a scoping visitor. Invokes the visitor method specific to this binding's scoping.

    Parameters
    visitor to call back on

    public abstract V acceptTargetVisitor (BindingTargetVisitor<? super T, V> visitor)

    Accepts a target visitor. Invokes the visitor method specific to this binding's target.

    Parameters
    visitor to call back on

    public abstract Key<T> getKey ()

    Returns the key for this binding.

    public abstract Provider<T> getProvider ()

    Returns the scoped provider guice uses to fulfill requests for this binding.

    Throws
    UnsupportedOperationException when invoked on a Binding created via getElements(Module...). This method is only supported on Bindings returned from an injector.
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/Binder.html0000755000175000017500000021376211704661106023436 0ustar tonytony Binder | Guice
    public interface

    Binder

    com.google.inject.Binder
    Known Indirect Subclasses

    Class Overview

    Collects configuration information (primarily bindings) which will be used to create an Injector. Guice provides this object to your application's Module implementors so they may each contribute their own bindings and other registrations.

    The Guice Binding EDSL

    Guice uses an embedded domain-specific language, or EDSL, to help you create bindings simply and readably. This approach is great for overall usability, but it does come with a small cost: it is difficult to learn how to use the Binding EDSL by reading method-level javadocs. Instead, you should consult the series of examples below. To save space, these examples omit the opening binder, just as you will if your module extends AbstractModule.
         bind(ServiceImpl.class);
    This statement does essentially nothing; it "binds the ServiceImpl class to itself" and does not change Guice's default behavior. You may still want to use this if you prefer your Module class to serve as an explicit manifest for the services it provides. Also, in rare cases, Guice may be unable to validate a binding at injector creation time unless it is given explicitly.
         bind(Service.class).to(ServiceImpl.class);
    Specifies that a request for a Service instance with no binding annotations should be treated as if it were a request for a ServiceImpl instance. This overrides the function of any @ImplementedBy or @ProvidedBy annotations found on Service, since Guice will have already "moved on" to ServiceImpl before it reaches the point when it starts looking for these annotations.
         bind(Service.class).toProvider(ServiceProvider.class);
    In this example, ServiceProvider must extend or implement Provider<Service>. This binding specifies that Guice should resolve an unannotated injection request for Service by first resolving an instance of ServiceProvider in the regular way, then calling get() on the resulting Provider instance to obtain the Service instance.

    The Provider you use here does not have to be a "factory"; that is, a provider which always creates each instance it provides. However, this is generally a good practice to follow. You can then use Guice's concept of scopes to guide when creation should happen -- "letting Guice work for you".

         bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);
    Like the previous example, but only applies to injection requests that use the binding annotation @Red. If your module also includes bindings for particular values of the @Red annotation (see below), then this binding will serve as a "catch-all" for any values of @Red that have no exact match in the bindings.
         bind(ServiceImpl.class).in(Singleton.class);
         // or, alternatively
         bind(ServiceImpl.class).in(Scopes.SINGLETON);
    Either of these statements places the ServiceImpl class into singleton scope. Guice will create only one instance of ServiceImpl and will reuse it for all injection requests of this type. Note that it is still possible to bind another instance of ServiceImpl if the second binding is qualified by an annotation as in the previous example. Guice is not overly concerned with preventing you from creating multiple instances of your "singletons", only with enabling your application to share only one instance if that's all you tell Guice you need.

    Note: a scope specified in this way overrides any scope that was specified with an annotation on the ServiceImpl class.

    Besides Singleton/SINGLETON, there are servlet-specific scopes available in com.google.inject.servlet.ServletScopes, and your Modules can contribute their own custom scopes for use here as well.

         bind(new TypeLiteral<PaymentService<CreditCard>>() {})
             .to(CreditCardPaymentService.class);
    This admittedly odd construct is the way to bind a parameterized type. It tells Guice how to honor an injection request for an element of type PaymentService<CreditCard>. The class CreditCardPaymentService must implement the PaymentService<CreditCard> interface. Guice cannot currently bind or inject a generic type, such as Set<E>; all type parameters must be fully specified.
         bind(Service.class).toInstance(new ServiceImpl());
         // or, alternatively
         bind(Service.class).toInstance(SomeLegacyRegistry.getService());
    In this example, your module itself, not Guice, takes responsibility for obtaining a ServiceImpl instance, then asks Guice to always use this single instance to fulfill all Service injection requests. When the Injector is created, it will automatically perform field and method injection for this instance, but any injectable constructor on ServiceImpl is simply ignored. Note that using this approach results in "eager loading" behavior that you can't control.
         bindConstant().annotatedWith(ServerHost.class).to(args[0]);
    Sets up a constant binding. Constant injections must always be annotated. When a constant binding's value is a string, it is eligile for conversion to all primitive types, to all enums, and to class literals. Conversions for other types can be configured using convertToTypes().
       @Color("red") Color red; // A member variable (field)
        . . .
         red = MyModule.class.getDeclaredField("red").getAnnotation(Color.class);
         bind(Service.class).annotatedWith(red).to(RedService.class);
    If your binding annotation has parameters you can apply different bindings to different specific values of your annotation. Getting your hands on the right instance of the annotation is a bit of a pain -- one approach, shown above, is to apply a prototype annotation to a field in your module class, so that you can read this annotation instance and give it to Guice.
         bind(Service.class)
             .annotatedWith(Names.named("blue"))
             .to(BlueService.class);
    Differentiating by names is a common enough use case that we provided a standard annotation, @Named. Because of Guice's library support, binding by name is quite easier than in the arbitrary binding annotation case we just saw. However, remember that these names will live in a single flat namespace with all the other names used in your application.
         Constructor loneCtor = getLoneCtorFromServiceImplViaReflection();
         bind(ServiceImpl.class)
             .toConstructor(loneCtor);
    In this example, we directly tell Guice which constructor to use in a concrete class implementation. It means that we do not need to place @Inject on any of the constructors and that Guice treats the provided constructor as though it were annotated so. It is useful for cases where you cannot modify existing classes and is a bit simpler than using a Provider.

    The above list of examples is far from exhaustive. If you can think of how the concepts of one example might coexist with the concepts from another, you can most likely weave the two together. If the two concepts make no sense with each other, you most likely won't be able to do it. In a few cases Guice will let something bogus slip by, and will then inform you of the problems at runtime, as soon as you try to create your Injector.

    The other methods of Binder such as bindScope(Class, Scope), bindInterceptor(Matcher>, Matcher, MethodInterceptor...), install(Module), requestStaticInjection(Class...), addError(String, Object...) and currentStage() are not part of the Binding EDSL; you can learn how to use these in the usual way, from the method documentation.

    Summary

    Public Methods
    abstract void addError(Message message)
    Records an error message to be presented to the user at a later time.
    abstract void addError(String message, Object... arguments)
    Records an error message which will be presented to the user at a later time.
    abstract void addError(Throwable t)
    Records an exception, the full details of which will be logged, and the message of which will be presented to the user at a later time.
    abstract <T> LinkedBindingBuilder<T> bind(Key<T> key)
    See the EDSL examples at Binder.
    abstract <T> AnnotatedBindingBuilder<T> bind(TypeLiteral<T> typeLiteral)
    See the EDSL examples at Binder.
    abstract <T> AnnotatedBindingBuilder<T> bind(Class<T> type)
    See the EDSL examples at Binder.
    abstract AnnotatedConstantBindingBuilder bindConstant()
    See the EDSL examples at Binder.
    abstract void bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)
    Binds method interceptor[s] to methods matched by class and method matchers.
    abstract void bindListener(Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)
    Registers a listener for injectable types.
    abstract void bindScope(Class<? extends Annotation> annotationType, Scope scope)
    Binds a scope to an annotation.
    abstract void convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)
    Binds a type converter.
    abstract Stage currentStage()
    Gets the current stage.
    abstract void disableCircularProxies()
    Prevents Guice from constructing a Proxy when a circular dependency is found.
    abstract <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral)
    Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
    abstract <T> MembersInjector<T> getMembersInjector(Class<T> type)
    Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.
    abstract <T> Provider<T> getProvider(Key<T> key)
    Returns the provider used to obtain instances for the given injection key.
    abstract <T> Provider<T> getProvider(Class<T> type)
    Returns the provider used to obtain instances for the given injection type.
    abstract void install(Module module)
    Uses the given module to configure more bindings.
    abstract PrivateBinder newPrivateBinder()
    Creates a new private child environment for bindings and other configuration.
    abstract <T> void requestInjection(TypeLiteral<T> type, T instance)
    Upon successful creation, the Injector will inject instance fields and methods of the given object.
    abstract void requestInjection(Object instance)
    Upon successful creation, the Injector will inject instance fields and methods of the given object.
    abstract void requestStaticInjection(Class...<?> types)
    Upon successful creation, the Injector will inject static fields and methods in the given classes.
    abstract void requireExplicitBindings()
    Instructs the Injector that bindings must be listed in a Module in order to be injected.
    abstract Binder skipSources(Class... classesToSkip)
    Returns a binder that skips classesToSkip when identify the calling code.
    abstract Binder withSource(Object source)
    Returns a binder that uses source as the reference location for configuration errors.

    Public Methods

    public abstract void addError (Message message)

    Records an error message to be presented to the user at a later time.

    public abstract void addError (String message, Object... arguments)

    Records an error message which will be presented to the user at a later time. Unlike throwing an exception, this enable us to continue configuring the Injector and discover more errors. Uses format(String, Object[]) to insert the arguments into the message.

    public abstract void addError (Throwable t)

    Records an exception, the full details of which will be logged, and the message of which will be presented to the user at a later time. If your Module calls something that you worry may fail, you should catch the exception and pass it into this.

    public abstract LinkedBindingBuilder<T> bind (Key<T> key)

    See the EDSL examples at Binder.

    public abstract AnnotatedBindingBuilder<T> bind (TypeLiteral<T> typeLiteral)

    See the EDSL examples at Binder.

    public abstract AnnotatedBindingBuilder<T> bind (Class<T> type)

    See the EDSL examples at Binder.

    public abstract AnnotatedConstantBindingBuilder bindConstant ()

    See the EDSL examples at Binder.

    public abstract void bindInterceptor (Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)

    Binds method interceptor[s] to methods matched by class and method matchers. A method is eligible for interception if:

    • Guice created the instance the method is on
    • Neither the enclosing type nor the method is final
    • And the method is package-private, protected, or public

    Parameters
    classMatcher matches classes the interceptor should apply to. For example: only(Runnable.class).
    methodMatcher matches methods the interceptor should apply to. For example: annotatedWith(Transactional.class).
    interceptors to bind

    public abstract void bindListener (Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)

    Registers a listener for injectable types. Guice will notify the listener when it encounters injectable types matched by the given type matcher.

    Parameters
    typeMatcher that matches injectable types the listener should be notified of
    listener for injectable types matched by typeMatcher

    public abstract void bindScope (Class<? extends Annotation> annotationType, Scope scope)

    Binds a scope to an annotation.

    public abstract void convertToTypes (Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)

    Binds a type converter. The injector will use the given converter to convert string constants to matching types as needed.

    Parameters
    typeMatcher matches types the converter can handle
    converter converts values

    public abstract Stage currentStage ()

    Gets the current stage.

    public abstract void disableCircularProxies ()

    Prevents Guice from constructing a Proxy when a circular dependency is found. By default, circular proxies are not disabled.

    If a parent injector disables circular proxies, then all child injectors (and private modules within that injector) also disable circular proxies. If a parent does not disable circular proxies, a child injector or private module may optionally declare itself as disabling circular proxies. If it does, the behavior is limited only to that child or any grandchildren. No siblings of the child will disable circular proxies.

    public abstract MembersInjector<T> getMembersInjector (TypeLiteral<T> typeLiteral)

    Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. The returned members injector will not be valid until the main Injector has been created. The members injector will throw an IllegalStateException if you try to use it beforehand.

    Parameters
    typeLiteral type to get members injector for

    public abstract MembersInjector<T> getMembersInjector (Class<T> type)

    Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. The returned members injector will not be valid until the main Injector has been created. The members injector will throw an IllegalStateException if you try to use it beforehand.

    Parameters
    type type to get members injector for

    public abstract Provider<T> getProvider (Key<T> key)

    Returns the provider used to obtain instances for the given injection key. The returned provider will not be valid until the Injector has been created. The provider will throw an IllegalStateException if you try to use it beforehand.

    public abstract Provider<T> getProvider (Class<T> type)

    Returns the provider used to obtain instances for the given injection type. The returned provider will not be valid until the Injector has been created. The provider will throw an IllegalStateException if you try to use it beforehand.

    public abstract void install (Module module)

    Uses the given module to configure more bindings.

    public abstract PrivateBinder newPrivateBinder ()

    Creates a new private child environment for bindings and other configuration. The returned binder can be used to add and configuration information in this environment. See PrivateModule for details.

    Returns
    • a binder that inherits configuration from this binder. Only exposed configuration on the returned binder will be visible to this binder.

    public abstract void requestInjection (TypeLiteral<T> type, T instance)

    Upon successful creation, the Injector will inject instance fields and methods of the given object.

    Parameters
    type of instance
    instance for which members will be injected

    public abstract void requestInjection (Object instance)

    Upon successful creation, the Injector will inject instance fields and methods of the given object.

    Parameters
    instance for which members will be injected

    public abstract void requestStaticInjection (Class...<?> types)

    Upon successful creation, the Injector will inject static fields and methods in the given classes.

    Parameters
    types for which static members will be injected

    public abstract void requireExplicitBindings ()

    Instructs the Injector that bindings must be listed in a Module in order to be injected. Classes that are not explicitly bound in a module cannot be injected. Bindings created through a linked binding ( bind(Foo.class).to(FooImpl.class)) are allowed, but the implicit binding (FooImpl) cannot be directly injected unless it is also explicitly bound (bind(FooImpl.class)).

    Tools can still retrieve bindings for implicit bindings (bindings created through a linked binding) if explicit bindings are required, however getProvider() will fail.

    By default, explicit bindings are not required.

    If a parent injector requires explicit bindings, then all child injectors (and private modules within that injector) also require explicit bindings. If a parent does not require explicit bindings, a child injector or private module may optionally declare itself as requiring explicit bindings. If it does, the behavior is limited only to that child or any grandchildren. No siblings of the child will require explicit bindings.

    If the parent did not require explicit bindings but the child does, it is possible that a linked binding in the child may add a JIT binding to the parent. The child will not be allowed to reference the target binding directly, but the parent and other children of the parent may be able to.

    public abstract Binder skipSources (Class... classesToSkip)

    Returns a binder that skips classesToSkip when identify the calling code. The caller's StackTraceElement is used to locate the source of configuration errors.

    Parameters
    classesToSkip library classes that create bindings on behalf of their clients.
    Returns
    • a binder that shares its configuration with this binder.

    public abstract Binder withSource (Object source)

    Returns a binder that uses source as the reference location for configuration errors. This is typically a StackTraceElement for .java source but it could any binding source, such as the path to a .properties file.

    Parameters
    source any object representing the source location and has a concise toString() value
    Returns
    • a binder that shares its configuration with this binder
    sisu-guice-sisu-guice-3.1.1/javadoc/com/google/inject/AbstractModule.html0000755000175000017500000017663411704661106025152 0ustar tonytony AbstractModule | Guice
    public abstract class

    AbstractModule

    extends Object
    implements Module
    java.lang.Object
       ↳ com.google.inject.AbstractModule
    Known Direct Subclasses
    Known Indirect Subclasses

    Class Overview

    A support class for Modules which reduces repetition and results in a more readable configuration. Simply extend this class, implement configure(), and call the inherited methods which mirror those found in Binder. For example:

     public class MyModule extends AbstractModule {
       protected void configure() {
         bind(Service.class).to(ServiceImpl.class).in(Singleton.class);
         bind(CreditCardPaymentService.class);
         bind(PaymentService.class).to(CreditCardPaymentService.class);
         bindConstant().annotatedWith(Names.named("port")).to(8080);
       }
     }
     

    Summary

    Public Constructors
    AbstractModule()
    Public Methods
    synchronized final void configure(Binder builder)
    Contributes bindings and other configurations for this module to binder.
    Protected Methods
    void addError(Message message)
    void addError(String message, Object... arguments)
    void addError(Throwable t)
    <T> LinkedBindingBuilder<T> bind(Key<T> key)
    <T> AnnotatedBindingBuilder<T> bind(TypeLiteral<T> typeLiteral)
    <T> AnnotatedBindingBuilder<T> bind(Class<T> clazz)
    AnnotatedConstantBindingBuilder bindConstant()
    void bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)
    void bindListener(Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)
    void bindScope(Class<? extends Annotation> scopeAnnotation, Scope scope)
    Binder binder()
    Gets direct access to the underlying Binder.
    abstract void configure()
    Configures a Binder via the exposed methods.
    void convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)
    Stage currentStage()
    <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> type)
    <T> MembersInjector<T> getMembersInjector(Class<T> type)
    <T> Provider<T> getProvider(Key<T> key)
    <T> Provider<T> getProvider(Class<T> type)
    void install(Module module)
    void requestInjection(Object instance)
    void requestStaticInjection(Class...<?> types)
    void requireBinding(Key<?> key)
    Adds a dependency from this module to key.
    void requireBinding(Class<?> type)
    Adds a dependency from this module to type.
    [Expand]
    Inherited Methods
    From class java.lang.Object
    From interface com.google.inject.Module

    Public Constructors

    public AbstractModule ()

    Public Methods

    public final synchronized void configure (Binder builder)

    Contributes bindings and other configurations for this module to binder.

    Do not invoke this method directly to install submodules. Instead use install(Module), which ensures that provider methods are discovered.

    Protected Methods

    protected void addError (Message message)

    protected void addError (String message, Object... arguments)

    protected void addError (Throwable t)

    protected LinkedBindingBuilder<T> bind (Key<T> key)

    See Also

    protected AnnotatedBindingBuilder<T> bind (TypeLiteral<T> typeLiteral)

    protected AnnotatedBindingBuilder<T> bind (Class<T> clazz)

    See Also

    protected AnnotatedConstantBindingBuilder bindConstant ()

    See Also

    protected void bindInterceptor (Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)

    protected void bindListener (Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)

    protected void bindScope (Class<? extends Annotation> scopeAnnotation, Scope scope)

    protected Binder binder ()

    Gets direct access to the underlying Binder.

    protected abstract void configure ()

    Configures a Binder via the exposed methods.

    protected void convertToTypes (Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)

    protected Stage currentStage ()

    See Also

    protected MembersInjector<T> getMembersInjector (TypeLiteral<T> type)

    protected MembersInjector<T> getMembersInjector (Class<T> type)

    protected Provider<T> getProvider (Key<T> key)

    See Also

    protected Provider<T> getProvider (Class<T> type)

    protected void install (Module module)

    See Also

    protected void requestInjection (Object instance)

    protected void requestStaticInjection (Class...<?> types)

    protected void requireBinding (Key<?> key)

    Adds a dependency from this module to key. When the injector is created, Guice will report an error if key cannot be injected. Note that this requirement may be satisfied by implicit binding, such as a public no-arguments constructor.

    protected void requireBinding (Class<?> type)

    Adds a dependency from this module to type. When the injector is created, Guice will report an error if type cannot be injected. Note that this requirement may be satisfied by implicit binding, such as a public no-arguments constructor.

    sisu-guice-sisu-guice-3.1.1/javadoc/classes.html0000755000175000017500000021117411704661106020355 0ustar tonytony Class Index | Guice

    Class Index

    A B C D E F G H I J K L M N O P R S T U

    A

    AbstractMatcher<T> Implements and() and or()
    AbstractModule A support class for Modules which reduces repetition and results in a more readable configuration. 
    AnnotatedBindingBuilder<T> See the EDSL examples at Binder
    AnnotatedConstantBindingBuilder See the EDSL examples at Binder
    AnnotatedElementBuilder See the EDSL examples at Binder
    ArrowType Arrow symbols that are available from Graphviz. 
    Assisted Annotates an injected parameter or field whose value comes from an argument to a factory method. 
    AssistedInject

    When used in tandem with FactoryModuleBuilder, constructors annotated with @AssistedInject indicate that multiple constructors can be injected, each with different parameters. 

    AssistedInjectBinding<T> A binding for a factory created by FactoryModuleBuilder. 
    AssistedInjectTargetVisitor<T, V> A visitor for the AssistedInject extension. 
    AssistedMethod Details about how a method in an assisted inject factory will be assisted. 

    B

    Binder Collects configuration information (primarily bindings) which will be used to create an Injector
    Binding<T> A mapping from a key (type and optional annotation) to the strategy for getting instances of the type. 
    BindingAnnotation Annotates annotations which are used for binding. 
    BindingEdge<K> Interface for an edge that connects an interface to the type or instance that is bound to implement it. 
    BindingEdge.Factory<K, T extends BindingEdge<K>> Factory interface for BindingEdges. 
    BindingEdge.Type Classification for what kind of binding this edge represents. 
    BindingEdgeFactory Graphviz-specific implementation of BindingEdge.Factory
    BindingEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts BindingEdge methods to display operations on a GraphvizEdge
    BindingScopingVisitor<V> Visits each of the strategies used to scope an injection. 
    BindingTargetVisitor<T, V> Visits each of the strategies used to find an instance to satisfy an injection. 

    C

    CheckedProvider<T> Alternative to the Guice Provider that throws a checked Exception. 
    CheckedProvides Annotates methods of a Module to create a CheckedProvider method binding that can throw exceptions. 
    CompassPoint Enum for the "compass point" values used to control where edge end points appear on the graph. 
    ConfigurationException Thrown when a programming error such as a misplaced annotation, illegal binding, or unsupported scope is found. 
    ConstantBindingBuilder Binds to a constant value. 
    ConstructorBinding<T> A binding to the constructor of a concrete clss. 
    ConvertedConstantBinding<T> A binding created from converting a bound instance to a new type. 
    CreationException Thrown when errors occur while creating a Injector

    D

    DefaultBindingScopingVisitor<V> No-op visitor for subclassing. 
    DefaultBindingTargetVisitor<T, V> No-op visitor for subclassing. 
    DefaultElementVisitor<V> No-op visitor for subclassing. 
    Dependency<T> A variable that can be resolved by an injector. 
    DependencyEdge<K> Interface for an edge from a class or InjectionPoint to the interface node that will satisfy the dependency. 
    DependencyEdge.Factory<K, T extends DependencyEdge<K>> Factory interface for DependencyEdges. 
    DependencyEdgeFactory Graphviz-specific implementation of DependencyEdge.Factory
    DependencyEdgeFactory.GraphvizEdgeAdaptor Adaptor class that converts DependencyEdge methods to display operations on a GraphvizEdge
    DisableCircularProxiesOption A request to disable circular proxies. 
    DynamicFinder Utility that helps you introspect dynamic finder methods. 

    E

    EdgeStyle Styles for edges. 
    Element A core component of a module or injector. 
    Elements Exposes elements of a module so they can be inspected, validated or rewritten
    ElementVisitor<V> Visit elements. 
    Exposed Acccompanies a @Provides method annotation in a private module to indicate that the provided binding is exposed. 
    ExposedBinding<T> A binding to a key exposed from an enclosed private environment. 

    F

    FactoryModuleBuilder Provides a factory that combines the caller's arguments with injector-supplied values to construct objects. 
    FactoryProvider<F> This class is deprecated. use FactoryModuleBuilder instead.  
    Finder Marks a method stub as a dynamic finder. 
    FirstResult Annotate any dynamic finder method's integer argument with this to pass in the index of the first result in the result set you are interested in. 

    G

    GrapherModule Module for the common bindings for InjectorGrapher
    GraphingVisitor<K, N extends InterfaceNode<K>, M extends ImplementationNode<K>, B extends BindingEdge<K>, D extends DependencyEdge<K>> BindingTargetVisitor that adds nodes and edges to the graph based on the visited Binding
    GraphvizEdge Data object to encapsulate the attributes of Graphviz edges that we're interested in drawing. 
    GraphvizModule Module that provides GraphvizRenderer as the Renderer and binds the other Graphviz factories. 
    GraphvizNode Data object to encapsulate the attributes of Graphviz nodes that we're interested in drawing. 
    GraphvizRenderer Renderer implementation that writes out a Graphviz DOT file of the graph. 
    Guice The entry point to the Guice framework. 
    GuiceFilter

    Apply this filter in web.xml above all other filters (typically), to all requests where you plan to use servlet scopes. 

    GuiceServletContextListener As of Guice 2.0 you can still use (your subclasses of) GuiceServletContextListener class as a logical place to create and configure your injector. 

    H

    HasDependencies Implemented by bindings, providers and instances that expose their dependencies explicitly. 

    I

    ImplementationNode<K> Node for classes and instances that have Dependencys and are bound to InterfaceNodes. 
    ImplementationNode.Factory<K, T extends ImplementationNode<K>> Factory interface for ImplementationNodes. 
    ImplementationNodeFactory Graphviz-specific implementation of ImplementationNode.Factory
    ImplementationNodeFactory.GraphvizNodeAdaptor Adaptor class that converts ImplementationNode methods to display operations on a GraphvizNode
    ImplementedBy A pointer to the default implementation of a type. 
    Inject Annotates members of your implementation class (constructors, methods and fields) into which the Injector should inject values. 
    InjectionListener<I> Listens for injections into instances of type I
    InjectionPoint A constructor, field or method that can receive injections. 
    InjectionRequest<T> A request to inject the instance fields and methods of an instance. 
    Injector Builds the graphs of objects that make up your application. 
    InjectorGrapher Root class for graphing an Injector
    InstanceBinding<T> A binding to a single instance. 
    InstanceFilterBinding A binding to a single instance of a filter. 
    InstanceServletBinding A binding to a single instance of a servlet. 
    InterceptorBinding Registration of interceptors for matching methods of matching classes. 
    InterfaceNode<K> Node for an interface class that has been bound to an implementation class or instance. 
    InterfaceNode.Factory<K, T extends InterfaceNode<K>> Factory interface for InterfaceNodes. 
    InterfaceNodeFactory Graphviz-specific implementation of InterfaceNode.Factory
    InterfaceNodeFactory.GraphvizNodeAdaptor Adaptor class that converts InterfaceNode methods to display operations on a GraphvizNode

    J

    JndiIntegration Integrates Guice with JNDI. 
    JpaPersistModule JPA provider for guice persist. 

    K

    Key<T> Binding key consisting of an injection type and an optional annotation. 

    L

    LinkedBindingBuilder<T> See the EDSL examples at Binder
    LinkedFilterBinding A linked binding to a filter. 
    LinkedKeyBinding<T> A binding to a linked key. 
    LinkedServletBinding A linked binding to a servlet. 

    M

    ManagedBindingMBean JMX interface to bindings. 
    Manager Provides a JMX interface to Guice. 
    MapBinder<K, V> An API to bind multiple map entries separately, only to later inject them as a complete map. 
    MapBinderBinding<T> A binding for a MapBinder. 
    Matcher<T> Returns true or false for a given input. 
    Matchers Matcher implementations. 
    MaxResults Annotate any dynamic finder method's integer argument with this to pass in the maximum size of returned result window. 
    MembersInjector<T> Injects dependencies into the fields and methods on instances of type T
    MembersInjectorLookup<T> A lookup of the members injector for a type. 
    Message An error message and the context in which it occured. 
    Module A module contributes configuration information, typically interface bindings, which will be used to create an Injector
    Modules Static utility methods for creating and working with instances of Module
    Modules.OverriddenModuleBuilder See the EDSL example at override()
    Multibinder<T> An API to bind multiple values separately, only to later inject them as a complete collection. 
    MultibinderBinding<T> A binding for a Multibinder. 
    MultibindingsTargetVisitor<T, V> A visitor for the multibinder extension. 

    N

    Named Annotates named things. 
    NameFactory Interface for a service that provides nice Strings that we can display in the graph for the types that come up in Bindings. 
    Names Utility methods for use with @Named
    NodeAliasFactory<K> Factory for aliasing one node ID to another. 
    NodeIdFactory<K> Factory for abstract identifiers for elements on the graph. 
    NodeShape Enum for the shapes that are most interesting for Guice graphing. 
    NodeStyle Styles for nodes. 

    O

    OutOfScopeException Thrown from get() when an attempt is made to access a scoped object while the scope in question is not currently active. 

    P

    PersistFilter Apply this filter to enable the HTTP Request unit of work and to have guice-persist manage the lifecycle of active units of work. 
    PersistModule Install this module to add guice-persist library support for JPA persistence providers. 
    PersistService Persistence provider service. 
    PortIdFactory Interface for a service that returns Graphviz port IDs, used for naming the rows in ImplementationNode-displaying GraphvizNodes. 
    PortIdFactoryImpl Implementation of PortIdFactory
    PrivateBinder Returns a binder whose configuration information is hidden from its environment by default. 
    PrivateElements A private collection of elements that are hidden from the enclosing injector or module by default. 
    PrivateModule A module whose configuration information is hidden from its environment by default. 
    ProvidedBy A pointer to the default provider type for a type. 
    Provider<T> An object capable of providing instances of type T
    ProviderBinding<T extends Provider<?>> A binding to a Provider that delegates to the binding for the provided type. 
    ProviderInstanceBinding<T> A binding to a provider instance. 
    ProviderKeyBinding<T> A binding to a provider key. 
    ProviderLookup<T> A lookup of the provider for a type. 
    Providers Static utility methods for creating and working with instances of Provider
    ProviderWithDependencies<T> A provider with dependencies on other injected types. 
    ProviderWithExtensionVisitor<T> A Provider that is part of an extension which supports a custom BindingTargetVisitor. 
    Provides Annotates methods of a Module to create a provider method binding. 
    ProvisionException Indicates that there was a runtime failure while providing an instance. 

    R

    Renderer Interface for the service that renders the graph. 
    RequestParameters Apply this to field or parameters of type Map<String, String[]> when you want the HTTP request parameter map to be injected. 
    RequestScoped Apply this to implementation classes when you want one instance per request. 
    RequireExplicitBindingsOption A request to require explicit bindings. 

    S

    Scope A scope is a level of visibility that instances provided by Guice may have. 
    ScopeAnnotation Annotates annotations which are used for scoping. 
    ScopeBinding Registration of a scope annotation with the scope that implements it. 
    ScopedBindingBuilder See the EDSL examples at Binder
    Scopes Built-in scope implementations. 
    ServletModule Configures the servlet scopes and creates bindings for the servlet API objects so you can inject the request, response, session, etc. 
    ServletModule.FilterKeyBindingBuilder See the EDSL examples at configureServlets() 
    ServletModule.ServletKeyBindingBuilder See the EDSL examples at configureServlets() 
    ServletModuleBinding A binding created by ServletModule
    ServletModuleTargetVisitor<T, V> A visitor for the servlet extension. 
    ServletScopes Servlet scopes. 
    SessionScoped Apply this to implementation classes when you want one instance per session. 
    ShortNameFactory Reasonable implementation for NameFactory
    Singleton Apply this to implementation classes when you want only one instance (per Injector) to be reused for all injections for that binding. 
    SpringIntegration Integrates Guice with Spring. 
    Stage The stage we're running in. 
    StaticInjectionRequest A request to inject the static fields and methods of a type. 
    StringNodeIdFactory IdFactory implementation that for String node IDs. 

    T

    ThrowingProvider<T, E extends Exception> This interface is deprecated. use CheckedProvider instead.  
    ThrowingProviderBinder

    Builds a binding for a CheckedProvider

    ThrowingProviderBinder.SecondaryBinder<P extends CheckedProvider>  
    Toolable Instructs an Injector running in TOOL that a method should be injected. 
    Transactional

    Any method or class marked with this annotation will be considered for transactionality. 

    TransitiveDependencyVisitor BindingTargetVisitor that returns a Collection of the Keys of each Binding's dependencies. 
    TypeConverter Converts constant string values to a different type. 
    TypeConverterBinding Registration of type converters for matching target types. 
    TypeEncounter<I> Context of an injectable type encounter. 
    TypeListener Listens for Guice to encounter injectable types. 
    TypeListenerBinding Binds types (picked using a Matcher) to an type listener. 
    TypeLiteral<T> Represents a generic type T
    Types Static methods for working with types. 

    U

    UnitOfWork This interface is used to gain manual control over the unit of work. 
    UntargettedBinding<T> An untargetted binding. 
    UriPatternType An enumeration of the available URI-pattern matching styles 
    sisu-guice-sisu-guice-3.1.1/javadoc/assets/0000755000175000017500000000000011704661106017323 5ustar tonytonysisu-guice-sisu-guice-3.1.1/javadoc/assets/triangle-none.gif0000755000175000017500000000036011704661106022556 0ustar tonytony‰PNG  IHDR  HЦДtEXtSoftwareAdobe ImageReadyqЩe<PLTEхцъЋГжeuГэюёЬWhЎџџџџџџИ6хуtRNSџџџџџџџоƒНYZIDATxкb`gg`g VV€b`ea VV66 @ ЌlllЌ €˜XY™€Т@ 0R0&F#X!D 3˜С d12ƒ#+LЁ†1hЌgIENDЎB`‚sisu-guice-sisu-guice-3.1.1/javadoc/assets/style.css0000755000175000017500000001320411704661106021200 0ustar tonytony.jd-toptitle { padding-left: 6px; margin-bottom: 30px; font-size: 160%; font-weight: bold; } div#jd-content table { border: none; } div#jd-content td, div#jd-content th { font-size: small; } div#jd-content table.jd-linktable { margin-top: 3px; border-spacing: 0; } div#jd-content p.jd-deprecated-warning { margin-top: 0; margin-bottom: 10px; } div#jd-content table.jd-linktable th { vertical-align: top; text-align: left; padding-top: 2px; padding-bottom: 2px; padding-left: 7px; padding-right: 7px; border: none; border-top: 1px solid #d2d7d0; background-color: #F7FCF4; } div#jd-content table.jd-linktable td { border: none; } div#jd-content table.jd-linktable td p { padding: 0; margin: 0; line-height: 110%; } div#jd-content table.jd-linktable .jd-linkcol { vertical-align: top; padding-top: 3px; padding-bottom: 0; padding-left: 7px; padding-right: 7px; border-top: 1px solid #d2d7d0; background-color: #E5F1E0; line-height: 110%; } div#jd-content table.jd-linktable .jd-descrcol { vertical-align: top; padding-top: 3px; padding-bottom: 0; padding-left: 7px; padding-right: 7px; border-top: 1px solid #d2d7d0; background-color: #F7FCF4; line-height: 110%; } div#jd-content table.jd-linktable .jd-descrcol p { padding: 0; margin: 0; line-height: 110%; } div#jd-content table.jd-linktable .jd-valcol { vertical-align: top; padding-top: 3px; padding-bottom: 0; padding-left: 7px; padding-right: 7px; border-top: 1px solid #d2d7d0; background-color: #E5F1E0; line-height: 110%; } div#jd-content table.jd-linktable .jd-commentrow { vertical-align: top; padding-top: 3px; padding-bottom: 4px; padding-left: 7px; padding-right: 7px; background-color: #F7FCF4; line-height: 110%; } div#jd-content div.jd-inheritedlinks { vertical-align: top; margin-top: 9px; padding-left: 7px; padding-right: 7px; background-color: #F7FCF4; line-height: 110%; } div#jd-content .jd-page_title-prefix { padding-top: 2em; margin-bottom: -14pt; } div#jd-content { margin-left: 0; margin-right: 10px; margin-bottom: 0; } div#jd-content h1 { padding-left: 10px; } div#jd-content h2 { padding-left: 10px; } div#jd-content h4 { margin-top: 9px; margin-bottom: 1px; } div#jd-content .jd-descr h5 { margin-bottom: 8px; } div#jd-content .sidebox h3 { margin: 1em 0 0 0; } div#jd-content .jd-letterlist { margin-top: 20px; margin-bottom: 0; } div#jd-content .jd-lettertable { margin-top: 15px; margin-right: 10px; } div#jd-content .jd-letterentries { list-style: none; margin-left: 0; } div#jd-content .jd-letterentrycomments { color: gray; } div#jd-content table.jd-inheritance-table { margin-top: 0; margin-left: 10px; margin-right: 10px; border-spacing: 0; } div#jd-content table.jd-inheritance-table td { border: none; margin: 0; padding: 0; background-color: white; } div#jd-content table.jd-inheritance-table .jd-inheritance-space { width: 10px; } div#jd-content table.jd-inheritance-table .jd-inheritance-interface-cell { padding-left: 17px; } div#jd-content h4.jd-details-title { margin: 0; background-color: #E5F1E0; padding: 2px; padding-left: 10px; padding-right: 10px; margin-top: 15px; } div#jd-content .jd-details { margin-top: 0; margin-left: -10px; } div#jd-content .jd-details-descr { line-height: 120%; padding-left: 10px; padding-top: 10px; padding-right: 20px; } div#jd-content .jd-descr h5, div#jd-content .jd-details h5 { font-style: normal; text-decoration: none; font-size: 120%; } div#jd-content .jd-more { } div#jd-content .jd-descr { padding-top: 0; } div#jd-content .jd-tagdata { margin-top: 6px; margin-bottom: 6px; } div#jd-content .jd-tagtitle { margin-top: 0px; } div#jd-content .jd-tagtable { margin-top: 10px; border-spacing: 0; } div#jd-content .jd-tagtable th { background: white; padding-left: 10px; padding-right: 10px; line-height: 120%; } div#jd-content .jd-tagtable th, div#jd-content .jd-tagtable td { line-height: 120%; border: none; margin: 0; text-align: left; padding-top: 0px; padding-bottom: 5px; } div#jd-content .Code,code,pre,samp,var { color: #004000; } div#jd-content pre.Code { padding-left: 20px; } /* XXX I would really like to apply font-size: 9pt only if var/samp is NOT inside of a .jd-descr div. */ div#jd-content .jd-descr code,var,samp { padding-left: 0px; } #search_autocomplete { font-size: 80%; } div#jd-searchbox table.jd-autocomplete-table-hidden { display: none; } div#jd-searchbox table.jd-autocomplete-table-showing { z-index: 10; border: 1px solid #3366cc; position: relative; top: -14px; left: 5px; background-color: white; } div#jd-searchbox td.jd-autocomplete { font-family: Arial, sans-serif; padding-left: 6px; padding-right: 6px; padding-top: 1px; padding-bottom: 1px; font-size: 80%; border: none; margin: 0; line-height: 105%; } div#jd-searchbox td.jd-selected { background-color: #E5F1E0; } div#jd-searchbox td.jd-linktype { color: #999999; } div#jd-content .jd-expando-trigger { margin-left: -8px; margin-right: 0px; border: none; } div#jd-build-id { color: #666; width: 100%; text-align: right; padding-right: 5px; padding-bottom: 3px; } @media print { #jd-searchbox, .jd-nav { display: none; } div#jd-content { margin-top: 0px; } } sisu-guice-sisu-guice-3.1.1/javadoc/assets/search_autocomplete.js0000755000175000017500000002075011704661106023716 0ustar tonytonyvar gSelectedIndex = -1; var gSelectedID = -1; var gMatches = new Array(); var gLastText = ""; var ROW_COUNT = 20; var gInitialized = false; var DEFAULT_TEXT = "search developer docs"; var HAS_SEARCH_PAGE = false; function set_row_selected(row, selected) { var c1 = row.cells[0]; // var c2 = row.cells[1]; if (selected) { c1.className = "jd-autocomplete jd-selected"; // c2.className = "jd-autocomplete jd-selected jd-linktype"; } else { c1.className = "jd-autocomplete"; // c2.className = "jd-autocomplete jd-linktype"; } } function set_row_values(toroot, row, match) { var link = row.cells[0].childNodes[0]; link.innerHTML = match.__hilabel || match.label; link.href = toroot + match.link // row.cells[1].innerHTML = match.type; } function sync_selection_table(toroot) { var filtered = document.getElementById("search_filtered"); var r; //TR DOM object var i; //TR iterator gSelectedID = -1; filtered.onmouseover = function() { if(gSelectedIndex >= 0) { set_row_selected(this.rows[gSelectedIndex], false); gSelectedIndex = -1; } } //initialize the table; draw it for the first time (but not visible). if (!gInitialized) { for (i=0; i 0) { document.getElementById("search_filtered_div").className = "showing"; var N = gMatches.length < ROW_COUNT ? gMatches.length : ROW_COUNT; for (i=0; i ROW_COUNT) { r = filtered.rows[ROW_COUNT]; r.className = "show-row"; c1 = r.cells[0]; c1.innerHTML = "plus " + (gMatches.length-ROW_COUNT) + " more"; } else { filtered.rows[ROW_COUNT].className = "hide-row"; }*/ //if we have no results, hide the table } else { document.getElementById("search_filtered_div").className = "no-display"; } } function search_changed(e, kd, toroot) { var search = document.getElementById("search_autocomplete"); var text = search.value.replace(/(^ +)|( +$)/g, ''); // 13 = enter if (e.keyCode == 13) { document.getElementById("search_filtered_div").className = "no-display"; if (kd && gSelectedIndex >= 0) { window.location = toroot + gMatches[gSelectedIndex].link; return false; } else if (gSelectedIndex < 0) { if (HAS_SEARCH_PAGE) { return true; } else { sync_selection_table(toroot); return false; } } } // 38 -- arrow up else if (kd && (e.keyCode == 38)) { if (gSelectedIndex >= 0) { gSelectedIndex--; } sync_selection_table(toroot); return false; } // 40 -- arrow down else if (kd && (e.keyCode == 40)) { if (gSelectedIndex < gMatches.length-1 && gSelectedIndex < ROW_COUNT-1) { gSelectedIndex++; } sync_selection_table(toroot); return false; } else if (!kd) { gMatches = new Array(); matchedCount = 0; gSelectedIndex = -1; for (var i=0; i= 0) { if (l < 0) l = 0; l += tmp; s = s.substr(tmp + 1); } return l; }; // helper function that counts the occurrences of a given character in // a given string var _countChar = function(s, c) { var n = 0; for (var i=0; i= 0) { // exact part match var partsAfter = _countChar(labelLower.substr(t + 1), '.'); score *= 200 / (partsAfter + 1); } else { t = _lastSearch(labelLower, partPrefixAlnumRE); if (t >= 0) { // part prefix match var partsAfter = _countChar(labelLower.substr(t + 1), '.'); score *= 20 / (partsAfter + 1); } } return score; }; for (var i=0; i$1'); } } function search_focus_changed(obj, focused) { if (focused) { if(obj.value == DEFAULT_TEXT){ obj.value = ""; obj.style.color="#000000"; } } else { if(obj.value == ""){ obj.value = DEFAULT_TEXT; obj.style.color="#aaaaaa"; } document.getElementById("search_filtered_div").className = "no-display"; } } function submit_search() { if (HAS_SEARCH_PAGE) { var query = document.getElementById('search_autocomplete').value; document.location = toRoot + 'search.html#q=' + query + '&t=0'; } return false; } sisu-guice-sisu-guice-3.1.1/javadoc/assets/prettify.js0000755000175000017500000004456711704661106021552 0ustar tonytony(function(){ var o=true,r=null,z=false;window.PR_SHOULD_USE_CONTINUATION=o;window.PR_TAB_WIDTH=8;window.PR_normalizedHtml=window.PR=window.prettyPrintOne=window.prettyPrint=void 0;window._pr_isIE6=function(){var N=navigator&&navigator.userAgent&&/\bMSIE 6\./.test(navigator.userAgent);window._pr_isIE6=function(){return N};return N}; var aa="!",ba="!=",ca="!==",F="#",da="%",ea="%=",G="&",fa="&&",ja="&&=",ka="&=",H="(",la="*",ma="*=",na="+=",oa=",",pa="-=",qa="->",ra="/",sa="/=",ta=":",ua="::",va=";",I="<",wa="<<",xa="<<=",ya="<=",za="=",Aa="==",Ba="===",J=">",Ca=">=",Da=">>",Ea=">>=",Fa=">>>",Ga=">>>=",Ha="?",Ia="@",L="[",M="^",Ta="^=",Ua="^^",Va="^^=",Wa="{",O="|",Xa="|=",Ya="||",Za="||=",$a="~",ab="break",bb="case",cb="continue",db="delete",eb="do",fb="else",gb="finally",hb="instanceof",ib="return",jb="throw",kb="try",lb="typeof", mb="(?:^^|[+-]",nb="\\$1",ob=")\\s*",pb="&",qb="<",rb=">",sb=""",tb="&#",ub="x",vb="'",wb='"',xb=" ",yb="XMP",zb="\n',ic="\t",jc="\n",kc="[^<]+| sisu-guice-sisu-guice-3.1.1/extensions/struts2/src/com/0000755000175000017500000000000011704661106021604 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/struts2/src/com/google/0000755000175000017500000000000011704661106023060 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/struts2/src/com/google/inject/0000755000175000017500000000000011704661106024334 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/struts2/src/com/google/inject/struts2/0000755000175000017500000000000011704661106025762 5ustar tonytony././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/struts2/src/com/google/inject/struts2/Struts2GuicePluginModule.javasisu-guice-sisu-guice-3.1.1/extensions/struts2/src/com/google/inject/struts2/Struts2GuicePluginModul0000644000175000017500000000177511704661106032442 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.struts2; import com.google.inject.AbstractModule; /** * Initializes the Struts 2 Guice Plugin. * Must be added to the injector returned by * {@link GuiceServletContextListener.getInjector()}. * * @author benmccann.com */ public class Struts2GuicePluginModule extends AbstractModule { @Override protected void configure() { requestStaticInjection(Struts2Factory.class); } } sisu-guice-sisu-guice-3.1.1/extensions/struts2/src/com/google/inject/struts2/Struts2Factory.java0000644000175000017500000001657611704661106031562 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.struts2; import com.google.inject.AbstractModule; import com.google.inject.Binder; import com.google.inject.Injector; import com.google.inject.internal.Annotations; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.ObjectFactory; import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.config.entities.InterceptorConfig; import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.interceptor.Interceptor; import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Logger; /** * Cleanup up version from Bob's GuiceObjectFactory. Now works properly with * GS2 and fixes several bugs. * * @author dhanji@gmail.com * @author benmccann.com */ public class Struts2Factory extends ObjectFactory { private static final long serialVersionUID = 1L; private static final Logger logger = Logger.getLogger(Struts2Factory.class.getName()); private static final String ERROR_NO_INJECTOR = "Cannot find a Guice injector. Are you sure you registered a GuiceServletContextListener " + "that uses the Struts2GuicePluginModule in your application's web.xml?"; private static @com.google.inject.Inject Injector injector; private final List interceptors = new ArrayList(); private volatile Injector strutsInjector; @Override public boolean isNoArgConstructorRequired() { return false; } @Inject(value = "guice.module", required = false) void setModule(String moduleClassName) { throw new RuntimeException("The struts2 plugin no longer supports" + " specifying a module via the 'guice.module' property in XML." + " Please install your module via a GuiceServletContextListener instead."); } Set> boundClasses = new HashSet>(); public Class getClassInstance(String name) throws ClassNotFoundException { Class clazz = super.getClassInstance(name); synchronized (this) { if (strutsInjector == null) { // We can only bind each class once. if (!boundClasses.contains(clazz)) { try { // Calling these methods now helps us detect ClassNotFoundErrors // early. clazz.getDeclaredFields(); clazz.getDeclaredMethods(); boundClasses.add(clazz); } catch (Throwable t) { // Struts should still work even though some classes aren't in the // classpath. It appears we always get the exception here when // this is the case. return clazz; } } } } return clazz; } @Override @SuppressWarnings("unchecked") public Object buildBean(Class clazz, Map extraContext) { if (strutsInjector == null) { synchronized (this) { if (strutsInjector == null) { createInjector(); } } } return strutsInjector.getInstance(clazz); } private void createInjector() { logger.info("Loading struts2 Guice support..."); // Something is wrong, since this should be there if GuiceServletContextListener // was present. if (injector == null) { logger.severe(ERROR_NO_INJECTOR); throw new RuntimeException(ERROR_NO_INJECTOR); } this.strutsInjector = injector.createChildInjector(new AbstractModule() { protected void configure() { // Tell the injector about all the action classes, etc., so it // can validate them at startup. for (Class boundClass : boundClasses) { // TODO: Set source from Struts XML. bind(boundClass); } // Validate the interceptor class. for (ProvidedInterceptor interceptor : interceptors) { interceptor.validate(binder()); } } }); // Inject interceptors. for (ProvidedInterceptor interceptor : interceptors) { interceptor.inject(); } logger.info("Injector created successfully."); } @SuppressWarnings("unchecked") public Interceptor buildInterceptor(InterceptorConfig interceptorConfig, Map interceptorRefParams) throws ConfigurationException { // Ensure the interceptor class is present. Class interceptorClass; try { interceptorClass = (Class) getClassInstance(interceptorConfig.getClassName()); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } ProvidedInterceptor providedInterceptor = new ProvidedInterceptor( interceptorConfig, interceptorRefParams, interceptorClass); interceptors.add(providedInterceptor); return providedInterceptor; } private Interceptor superBuildInterceptor(InterceptorConfig interceptorConfig, Map interceptorRefParams) throws ConfigurationException { return super.buildInterceptor(interceptorConfig, interceptorRefParams); } private class ProvidedInterceptor implements Interceptor { private static final long serialVersionUID = 1L; private final InterceptorConfig config; private final Map params; private final Class interceptorClass; private Interceptor delegate; ProvidedInterceptor(InterceptorConfig config, Map params, Class interceptorClass) { this.config = config; this.params = params; this.interceptorClass = interceptorClass; } void validate(Binder binder) { // TODO: Set source from Struts XML. if (hasScope(interceptorClass)) { binder.addError("Scoping interceptors is not currently supported." + " Please remove the scope annotation from " + interceptorClass.getName() + "."); } // Make sure it implements Interceptor. if (!Interceptor.class.isAssignableFrom(interceptorClass)) { binder.addError(interceptorClass.getName() + " must implement " + Interceptor.class.getName() + "."); } } void inject() { delegate = superBuildInterceptor(config, params); } public void destroy() { if (null != delegate) { delegate.destroy(); } } public void init() { throw new AssertionError(); } public String intercept(ActionInvocation invocation) throws Exception { return delegate.intercept(invocation); } } /** * Returns true if the given class has a scope annotation. */ private static boolean hasScope(Class interceptorClass) { for (Annotation annotation : interceptorClass.getAnnotations()) { if (Annotations.isScopeAnnotation(annotation.annotationType())) { return true; } } return false; } } sisu-guice-sisu-guice-3.1.1/extensions/struts2/src/com/google/inject/struts2/GuiceObjectFactory.java0000644000175000017500000001664711704661106032356 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.struts2; import com.google.inject.AbstractModule; import com.google.inject.Binder; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Module; import com.google.inject.internal.Annotations; import com.google.inject.servlet.ServletModule; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.ObjectFactory; import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.config.entities.InterceptorConfig; import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.interceptor.Interceptor; import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Logger; /** * @deprecated Use {@link com.google.inject.servlet.Struts2Factory} instead. */ @Deprecated public class GuiceObjectFactory extends ObjectFactory { static final Logger logger = Logger.getLogger(GuiceObjectFactory.class.getName()); Module module; volatile Injector injector; boolean developmentMode = false; List interceptors = new ArrayList(); @Override public boolean isNoArgConstructorRequired() { return false; } @Inject(value = "guice.module", required = false) void setModule(String moduleClassName) { try { // Instantiate user's module. @SuppressWarnings({"unchecked"}) Class moduleClass = (Class) Class.forName(moduleClassName); this.module = moduleClass.newInstance(); } catch (Exception e) { throw new RuntimeException(e); } } @Inject(value = "struts.devMode", required = false) void setDevelopmentMode(String developmentMode) { this.developmentMode = developmentMode.trim().equals("true"); } Set> boundClasses = new HashSet>(); public Class getClassInstance(String name) throws ClassNotFoundException { Class clazz = super.getClassInstance(name); synchronized (this) { if (injector == null) { // We can only bind each class once. if (!boundClasses.contains(clazz)) { try { // Calling these methods now helps us detect ClassNotFoundErrors // early. clazz.getDeclaredFields(); clazz.getDeclaredMethods(); boundClasses.add(clazz); } catch (Throwable t) { // Struts should still work even though some classes aren't in the // classpath. It appears we always get the exception here when // this is the case. return clazz; } } } } return clazz; } @SuppressWarnings("unchecked") public Object buildBean(Class clazz, Map extraContext) { if (injector == null) { synchronized (this) { if (injector == null) { createInjector(); } } } return injector.getInstance(clazz); } private void createInjector() { try { logger.info("Creating injector..."); this.injector = Guice.createInjector(new AbstractModule() { protected void configure() { // Install default servlet bindings. install(new ServletModule()); // Install user's module. if (module != null) { logger.info("Installing " + module + "..."); install(module); } else { logger.info("No module found. Set 'guice.module' to a Module " + "class name if you'd like to use one."); } // Tell the injector about all the action classes, etc., so it // can validate them at startup. for (Class boundClass : boundClasses) { // TODO: Set source from Struts XML. bind(boundClass); } // Validate the interceptor class. for (ProvidedInterceptor interceptor : interceptors) { interceptor.validate(binder()); } } }); // Inject interceptors. for (ProvidedInterceptor interceptor : interceptors) { interceptor.inject(); } } catch (Throwable t) { t.printStackTrace(); System.exit(1); } logger.info("Injector created successfully."); } @SuppressWarnings("unchecked") public Interceptor buildInterceptor(InterceptorConfig interceptorConfig, Map interceptorRefParams) throws ConfigurationException { // Ensure the interceptor class is present. Class interceptorClass; try { interceptorClass = getClassInstance(interceptorConfig.getClassName()); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } ProvidedInterceptor providedInterceptor = new ProvidedInterceptor( interceptorConfig, interceptorRefParams, interceptorClass); interceptors.add(providedInterceptor); return providedInterceptor; } Interceptor superBuildInterceptor(InterceptorConfig interceptorConfig, Map interceptorRefParams) throws ConfigurationException { return super.buildInterceptor(interceptorConfig, interceptorRefParams); } class ProvidedInterceptor implements Interceptor { final InterceptorConfig config; final Map params; final Class interceptorClass; Interceptor delegate; ProvidedInterceptor(InterceptorConfig config, Map params, Class interceptorClass) { this.config = config; this.params = params; this.interceptorClass = interceptorClass; } void validate(Binder binder) { // TODO: Set source from Struts XML. if (hasScope(interceptorClass)) { binder.addError("Scoping interceptors is not currently supported." + " Please remove the scope annotation from " + interceptorClass.getName() + "."); } // Make sure it implements Interceptor. if (!Interceptor.class.isAssignableFrom(interceptorClass)) { binder.addError(interceptorClass.getName() + " must implement " + Interceptor.class.getName() + "."); } } void inject() { delegate = superBuildInterceptor(config, params); } public void destroy() { if (null != delegate) { delegate.destroy(); } } public void init() { throw new AssertionError(); } public String intercept(ActionInvocation invocation) throws Exception { return delegate.intercept(invocation); } } /** * Returns true if the given class has a scope annotation. */ private static boolean hasScope(Class interceptorClass) { for (Annotation annotation : interceptorClass.getAnnotations()) { if (Annotations.isScopeAnnotation(annotation.annotationType())) { return true; } } return false; } } sisu-guice-sisu-guice-3.1.1/extensions/struts2/pom.xml0000644000175000017500000000211511704661106021553 0ustar tonytony 4.0.0 org.sonatype.sisu.inject guice-extensions 3.1.1 guice-struts2 Sisu Guice - Extensions - Struts2 org.sonatype.sisu.inject guice-servlet ${project.version} javax.servlet servlet-api 2.5 provided org.apache.struts struts2-core 2.2.3.1 provided sisu-guice-sisu-guice-3.1.1/extensions/struts2/example/0000755000175000017500000000000011704661106021672 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/struts2/example/struts2-example.iml0000644000175000017500000000756211704661106025466 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/0000755000175000017500000000000011704661106022461 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/struts.xml0000644000175000017500000000106511704661106024551 0ustar tonytony /Counter.jsp sisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/0000755000175000017500000000000011704661106023237 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/0000755000175000017500000000000011704661106024513 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/inject/0000755000175000017500000000000011704661106025767 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/inject/struts2/0000755000175000017500000000000011704661106027415 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/inject/struts2/example/0000755000175000017500000000000011704661106031050 5ustar tonytony././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/inject/struts2/example/ServiceImpl.javasisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/inject/struts2/example/Service0000644000175000017500000000024111704661106032370 0ustar tonytonypackage com.google.inject.struts2.example; public class ServiceImpl implements Service { public String getStatus() { return "We're looking good."; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/inject/struts2/example/Service.javasisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/inject/struts2/example/Service0000644000175000017500000000014011704661106032366 0ustar tonytonypackage com.google.inject.struts2.example; public interface Service { String getStatus(); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/inject/struts2/example/Main.javasisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/inject/struts2/example/Main.ja0000644000175000017500000000242411704661106032252 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.struts2.example; import org.mortbay.jetty.Connector; import org.mortbay.jetty.Server; import org.mortbay.jetty.nio.SelectChannelConnector; import org.mortbay.jetty.webapp.WebAppContext; /** * Starts the example web server on port 8080. Run from "./struts2/example". */ public class Main { public static void main(String[] args) throws Exception { Server server = new Server(); Connector connector = new SelectChannelConnector(); connector.setPort(8080); server.setConnectors(new Connector[] { connector }); WebAppContext webapp = new WebAppContext("./root", "/example"); server.addHandler(webapp); server.start(); server.join(); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/inject/struts2/example/ExampleListener.javasisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/inject/struts2/example/Example0000644000175000017500000000313411704661106032367 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.struts2.example; import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Singleton; import com.google.inject.servlet.GuiceServletContextListener; import com.google.inject.servlet.ServletModule; import com.google.inject.struts2.Struts2GuicePluginModule; /** * Example application module. * * @author crazybob@google.com (Bob Lee) */ public class ExampleListener extends GuiceServletContextListener { public Injector getInjector() { return Guice.createInjector( new Struts2GuicePluginModule(), new ServletModule() { @Override protected void configureServlets() { // Struts 2 setup bind(StrutsPrepareAndExecuteFilter.class).in(Singleton.class); filter("/*").through(StrutsPrepareAndExecuteFilter.class); // Our app-specific code bind(Service.class).to(ServiceImpl.class); } }); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/inject/struts2/example/Counter.javasisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/inject/struts2/example/Counter0000644000175000017500000000161111704661106032411 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.struts2.example; import com.google.inject.servlet.SessionScoped; /** * Session-scoped counter. */ @SessionScoped public class Counter { int count = 0; /** Increments the count and returns the new value. */ public synchronized int increment() { return count++; } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/inject/struts2/example/Count.javasisu-guice-sisu-guice-3.1.1/extensions/struts2/example/src/com/google/inject/struts2/example/Count.j0000644000175000017500000000235211704661106032315 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.struts2.example; import com.google.inject.Inject; import static com.opensymphony.xwork2.Action.SUCCESS; public class Count { final Counter counter; final Service service; String message; @Inject public Count(Counter counter, Service service) { this.counter = counter; this.service = service; } public String execute() { return SUCCESS; } public int getCount() { return counter.increment(); } public String getStatus() { return service.getStatus(); } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } } sisu-guice-sisu-guice-3.1.1/extensions/struts2/example/root/0000755000175000017500000000000011704661106022655 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/struts2/example/root/WEB-INF/0000755000175000017500000000000011704661106023704 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/struts2/example/root/WEB-INF/web.xml0000644000175000017500000000102611704661106025202 0ustar tonytony com.google.inject.struts2.example.ExampleListener guice com.google.inject.servlet.GuiceFilter guice /* sisu-guice-sisu-guice-3.1.1/extensions/struts2/example/root/Counter.jsp0000644000175000017500000000047211704661106025015 0ustar tonytony<%@ taglib prefix="s" uri="/struts-tags" %>

    Counter Example

    Hits in this session:

    Status:

    Message:

    sisu-guice-sisu-guice-3.1.1/extensions/struts2/example/build.xml0000644000175000017500000000045511704661106023517 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/struts2/example/build.properties0000644000175000017500000000005311704661106025105 0ustar tonytonylib.dir=../lib src.dir=src build.dir=build sisu-guice-sisu-guice-3.1.1/extensions/struts2/build.xml0000644000175000017500000000134411704661106022062 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/struts2/build.properties0000644000175000017500000000017311704661106023455 0ustar tonytonylib.dir=../../lib ext.lib.dir=lib src.dir=src test.dir=test build.dir=build module=com.google.inject.struts2 fragment=true sisu-guice-sisu-guice-3.1.1/extensions/spring/0000755000175000017500000000000011704661106020113 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/spring/test/0000755000175000017500000000000011704661106021072 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/spring/test/com/0000755000175000017500000000000011704661106021650 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/spring/test/com/google/0000755000175000017500000000000011704661106023124 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/spring/test/com/google/inject/0000755000175000017500000000000011704661106024400 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/spring/test/com/google/inject/spring/0000755000175000017500000000000011704661106025702 5ustar tonytony././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/spring/test/com/google/inject/spring/SpringIntegrationTest.javasisu-guice-sisu-guice-3.1.1/extensions/spring/test/com/google/inject/spring/SpringIntegrationTest.ja0000644000175000017500000000703411704661106032530 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spring; import static com.google.inject.spring.SpringIntegration.fromSpring; import com.google.inject.AbstractModule; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.name.Names; import junit.framework.TestCase; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; /** * @author crazybob@google.com (Bob Lee) */ public class SpringIntegrationTest extends TestCase { public void testBindFromSpring() throws CreationException { final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); RootBeanDefinition singleton = new RootBeanDefinition(Singleton.class); beanFactory.registerBeanDefinition("singleton", singleton); RootBeanDefinition prototype = new RootBeanDefinition(Prototype.class, false); beanFactory.registerBeanDefinition("prototype", prototype); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(BeanFactory.class).toInstance(beanFactory); bind(Singleton.class) .toProvider(fromSpring(Singleton.class, "singleton")); bind(Prototype.class) .toProvider(fromSpring(Prototype.class, "prototype")); } }); assertNotNull(injector.getInstance(Singleton.class)); assertSame(injector.getInstance(Singleton.class), injector.getInstance(Singleton.class)); assertNotNull(injector.getInstance(Prototype.class)); assertNotSame(injector.getInstance(Prototype.class), injector.getInstance(Prototype.class)); } public void testBindAll() throws CreationException { final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); RootBeanDefinition singleton = new RootBeanDefinition(Singleton.class); beanFactory.registerBeanDefinition("singleton", singleton); RootBeanDefinition prototype = new RootBeanDefinition(Prototype.class, false); beanFactory.registerBeanDefinition("prototype", prototype); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { SpringIntegration.bindAll(binder(), beanFactory); } }); Key singletonKey = Key.get(Singleton.class, Names.named("singleton")); Key prototypeKey = Key.get(Prototype.class, Names.named("prototype")); assertNotNull(injector.getInstance(singletonKey)); assertSame(injector.getInstance(singletonKey), injector.getInstance(singletonKey)); assertNotNull(injector.getInstance(prototypeKey)); assertNotSame(injector.getInstance(prototypeKey), injector.getInstance(prototypeKey)); } static class Singleton {} static class Prototype {} } sisu-guice-sisu-guice-3.1.1/extensions/spring/src/0000755000175000017500000000000011704661106020702 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/spring/src/com/0000755000175000017500000000000011704661106021460 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/spring/src/com/google/0000755000175000017500000000000011704661106022734 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/spring/src/com/google/inject/0000755000175000017500000000000011704661106024210 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/spring/src/com/google/inject/spring/0000755000175000017500000000000011704661106025512 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/spring/src/com/google/inject/spring/package-info.java0000644000175000017500000000131211704661106030676 0ustar tonytony/* * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Spring integration; this extension requires {@code guice-spring-3.0.jar}. */ package com.google.inject.spring;sisu-guice-sisu-guice-3.1.1/extensions/spring/src/com/google/inject/spring/SpringIntegration.java0000644000175000017500000000752411704661106032033 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spring; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Binder; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.name.Names; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.ListableBeanFactory; /** * Integrates Guice with Spring. * * @author crazybob@google.com (Bob Lee) */ public class SpringIntegration { private SpringIntegration() {} /** * Creates a provider which looks up objects from Spring using the given name. * Expects a binding to {@link * org.springframework.beans.factory.BeanFactory}. Example usage: * *
       * bind(DataSource.class)
       *   .toProvider(fromSpring(DataSource.class, "dataSource"));
       * 
    */ public static Provider fromSpring(Class type, String name) { return new InjectableSpringProvider(type, name); } /** * Binds all Spring beans from the given factory by name. For a Spring bean * named "foo", this method creates a binding to the bean's type and * {@code @Named("foo")}. * * @see com.google.inject.name.Named * @see com.google.inject.name.Names#named(String) */ public static void bindAll(Binder binder, ListableBeanFactory beanFactory) { binder = binder.skipSources(SpringIntegration.class); for (String name : beanFactory.getBeanDefinitionNames()) { Class type = beanFactory.getType(name); bindBean(binder, beanFactory, name, type); } } static void bindBean(Binder binder, ListableBeanFactory beanFactory, String name, Class type) { SpringProvider provider = SpringProvider.newInstance(type, name); try { provider.initialize(beanFactory); } catch (Exception e) { binder.addError(e); return; } binder.bind(type) .annotatedWith(Names.named(name)) .toProvider(provider); } static class SpringProvider implements Provider { BeanFactory beanFactory; boolean singleton; final Class type; final String name; public SpringProvider(Class type, String name) { this.type = checkNotNull(type, "type"); this.name = checkNotNull(name, "name"); } static SpringProvider newInstance(Class type, String name) { return new SpringProvider(type, name); } void initialize(BeanFactory beanFactory) { this.beanFactory = beanFactory; if (!beanFactory.isTypeMatch(name, type)) { throw new ClassCastException("Spring bean named '" + name + "' does not implement " + type.getName() + "."); } singleton = beanFactory.isSingleton(name); } public T get() { return singleton ? getSingleton() : type.cast(beanFactory.getBean(name)); } volatile T instance; private T getSingleton() { if (instance == null) { instance = type.cast(beanFactory.getBean(name)); } return instance; } } static class InjectableSpringProvider extends SpringProvider { InjectableSpringProvider(Class type, String name) { super(type, name); } @Inject @Override void initialize(BeanFactory beanFactory) { super.initialize(beanFactory); } } } sisu-guice-sisu-guice-3.1.1/extensions/spring/spring.iml0000644000175000017500000000301211704661106022114 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/spring/pom.xml0000644000175000017500000000136511704661106021435 0ustar tonytony 4.0.0 org.sonatype.sisu.inject guice-extensions 3.1.1 guice-spring Sisu Guice - Extensions - Spring org.springframework spring-beans 3.0.6.RELEASE provided sisu-guice-sisu-guice-3.1.1/extensions/spring/build.xml0000644000175000017500000000125011704661106021732 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/spring/build.properties0000644000175000017500000000023111704661106023324 0ustar tonytonylib.dir=../../lib src.dir=src test.dir=test build.dir=build test.class=com.google.inject.spring.SpringTest module=com.google.inject.spring fragment=true sisu-guice-sisu-guice-3.1.1/extensions/servlet/0000755000175000017500000000000012273115427020277 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/servlet/test/0000755000175000017500000000000011704661106021254 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/0000755000175000017500000000000011704661106022032 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/0000755000175000017500000000000011704661106023306 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/0000755000175000017500000000000011704661106024562 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/0000755000175000017500000000000011704661106026246 5ustar tonytony././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/VarargsServletDispatchIntegrationTest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/VarargsServletDispatch0000644000175000017500000001556111704661106032633 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Singleton; import junit.framework.TestCase; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; /** * Tests the FilterPipeline that dispatches to guice-managed servlets, * is a full integration test, with a real injector. * * @author Dhanji R. Prasanna (dhanji gmail com) */ public class VarargsServletDispatchIntegrationTest extends TestCase { private static int inits, services, destroys, doFilters; @Override public void setUp() { inits = 0; services = 0; destroys = 0; doFilters = 0; GuiceFilter.reset(); } public final void testDispatchRequestToManagedPipelineServlets() throws ServletException, IOException { final Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { serve("/*", "/index.html").with(TestServlet.class); // These servets should never fire... (ordering test) serve("*.html", "/o/*", "/index/*", "*.jsp").with(Key.get(NeverServlet.class)); } }); final FilterPipeline pipeline = injector.getInstance(FilterPipeline.class); pipeline.initPipeline(null); //create ourselves a mock request with test URI HttpServletRequest requestMock = createMock(HttpServletRequest.class); expect(requestMock.getRequestURI()) .andReturn("/index.html") .times(1); expect(requestMock.getContextPath()) .andReturn("") .anyTimes(); //dispatch request replay(requestMock); pipeline.dispatch(requestMock, null, createMock(FilterChain.class)); pipeline.destroyPipeline(); verify(requestMock); assertTrue("lifecycle states did not fire correct number of times-- inits: " + inits + "; dos: " + services + "; destroys: " + destroys, inits == 2 && services == 1 && destroys == 2); } public final void testVarargsSkipDispatchRequestToManagedPipelineServlets() throws ServletException, IOException { final Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { serve("/notindex", "/&*", "/index.html").with(TestServlet.class); // These servets should never fire... (ordering test) serve("*.html", "/*", "/index/*", "*.jsp").with(Key.get(NeverServlet.class)); } }); final FilterPipeline pipeline = injector.getInstance(FilterPipeline.class); pipeline.initPipeline(null); //create ourselves a mock request with test URI HttpServletRequest requestMock = createMock(HttpServletRequest.class); expect(requestMock.getRequestURI()) .andReturn("/index.html") .times(3); expect(requestMock.getContextPath()) .andReturn("") .anyTimes(); //dispatch request replay(requestMock); pipeline.dispatch(requestMock, null, createMock(FilterChain.class)); pipeline.destroyPipeline(); verify(requestMock); assertTrue("lifecycle states did not fire correct number of times-- inits: " + inits + "; dos: " + services + "; destroys: " + destroys, inits == 2 && services == 1 && destroys == 2); } public final void testDispatchRequestToManagedPipelineWithFilter() throws ServletException, IOException { final Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { filter("/*").through(TestFilter.class); serve("/*").with(TestServlet.class); // These servets should never fire... serve("*.html", "/y/*", "/index/*", "*.jsp").with(Key.get(NeverServlet.class)); } }); final FilterPipeline pipeline = injector.getInstance(FilterPipeline.class); pipeline.initPipeline(null); //create ourselves a mock request with test URI HttpServletRequest requestMock = createMock(HttpServletRequest.class); expect(requestMock.getRequestURI()) .andReturn("/index.html") .times(2); expect(requestMock.getContextPath()) .andReturn("") .anyTimes(); //dispatch request replay(requestMock); pipeline.dispatch(requestMock, null, createMock(FilterChain.class)); pipeline.destroyPipeline(); verify(requestMock); assertTrue("lifecycle states did not fire correct number of times-- inits: " + inits + "; dos: " + services + "; destroys: " + destroys, inits == 3 && services == 1 && destroys == 3 && doFilters == 1); } @Singleton public static class TestServlet extends HttpServlet { public void init(ServletConfig filterConfig) throws ServletException { inits++; } public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { services++; } public void destroy() { destroys++; } } @Singleton public static class NeverServlet extends HttpServlet { public void init(ServletConfig filterConfig) throws ServletException { inits++; } public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { assertTrue("NeverServlet was fired, when it should not have been.", false); } public void destroy() { destroys++; } } @Singleton public static class TestFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { inits++; } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { doFilters++; filterChain.doFilter(servletRequest, servletResponse); } public void destroy() { destroys++; } } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/VarargsFilterDispatchIntegrationTest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/VarargsFilterDispatchI0000644000175000017500000001270211704661106032537 0ustar tonytonypackage com.google.inject.servlet; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Singleton; import junit.framework.TestCase; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; /** * * This tests that filter stage of the pipeline dispatches * correctly to guice-managed filters. * * WARNING(dhanji): Non-parallelizable test =( * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public class VarargsFilterDispatchIntegrationTest extends TestCase { private static int inits, doFilters, destroys; @Override public final void setUp() { inits = 0; doFilters = 0; destroys = 0; GuiceFilter.reset(); } public final void testDispatchRequestToManagedPipeline() throws ServletException, IOException { final Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { // This is actually a double match for "/*" filter("/*", "*.html", "/*").through(Key.get(TestFilter.class)); // These filters should never fire filter("/index/*").through(Key.get(TestFilter.class)); filter("*.jsp").through(Key.get(TestFilter.class)); } }); final FilterPipeline pipeline = injector.getInstance(FilterPipeline.class); pipeline.initPipeline(null); //create ourselves a mock request with test URI HttpServletRequest requestMock = createMock(HttpServletRequest.class); expect(requestMock.getRequestURI()) .andReturn("/index.html") .anyTimes(); expect(requestMock.getContextPath()) .andReturn("") .anyTimes(); //dispatch request replay(requestMock); pipeline.dispatch(requestMock, null, createMock(FilterChain.class)); pipeline.destroyPipeline(); verify(requestMock); assertTrue("lifecycle states did not" + " fire correct number of times-- inits: " + inits + "; dos: " + doFilters + "; destroys: " + destroys, inits == 1 && doFilters == 3 && destroys == 1); } public final void testDispatchThatNoFiltersFire() throws ServletException, IOException { final Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { filter("/public/*", "*.html", "*.xml").through(Key.get(TestFilter.class)); // These filters should never fire filter("/index/*").through(Key.get(TestFilter.class)); filter("*.jsp").through(Key.get(TestFilter.class)); } }); final FilterPipeline pipeline = injector.getInstance(FilterPipeline.class); pipeline.initPipeline(null); //create ourselves a mock request with test URI HttpServletRequest requestMock = createMock(HttpServletRequest.class); expect(requestMock.getRequestURI()) .andReturn("/index.xhtml") .anyTimes(); expect(requestMock.getContextPath()) .andReturn("") .anyTimes(); //dispatch request replay(requestMock); pipeline.dispatch(requestMock, null, createMock(FilterChain.class)); pipeline.destroyPipeline(); verify(requestMock); assertTrue("lifecycle states did not " + "fire correct number of times-- inits: " + inits + "; dos: " + doFilters + "; destroys: " + destroys, inits == 1 && doFilters == 0 && destroys == 1); } public final void testDispatchFilterPipelineWithRegexMatching() throws ServletException, IOException { final Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { filterRegex("/[A-Za-z]*", "/index").through(TestFilter.class); //these filters should never fire filterRegex("\\w").through(Key.get(TestFilter.class)); } }); final FilterPipeline pipeline = injector.getInstance(FilterPipeline.class); pipeline.initPipeline(null); //create ourselves a mock request with test URI HttpServletRequest requestMock = createMock(HttpServletRequest.class); expect(requestMock.getRequestURI()) .andReturn("/index") .anyTimes(); expect(requestMock.getContextPath()) .andReturn("") .anyTimes(); //dispatch request replay(requestMock); pipeline.dispatch(requestMock, null, createMock(FilterChain.class)); pipeline.destroyPipeline(); verify(requestMock); assertTrue("lifecycle states did not fire " + "correct number of times-- inits: " + inits + "; dos: " + doFilters + "; destroys: " + destroys, inits == 1 && doFilters == 2 && destroys == 1); } @Singleton public static class TestFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { inits++; } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { doFilters++; filterChain.doFilter(servletRequest, servletResponse); } public void destroy() { destroys++; } } } sisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ServletTestUtils.java0000644000175000017500000000730011704661106032416 0ustar tonytony// Copyright 2011 Google Inc. All Rights Reserved. package com.google.inject.servlet; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import java.io.Serializable; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.Map; import javax.servlet.FilterChain; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * Utilities for servlet tests. * * @author sameb@google.com (Sam Berlin) */ public class ServletTestUtils { private ServletTestUtils() {} private static class ThrowingInvocationHandler implements InvocationHandler { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { throw new UnsupportedOperationException("No methods are supported on this object"); } } /** * Returns a FilterChain that does nothing. */ public static FilterChain newNoOpFilterChain() { return new FilterChain() { public void doFilter(ServletRequest request, ServletResponse response) { } }; } /** * Returns a fake, HttpServletRequest which stores attributes in a HashMap. */ public static HttpServletRequest newFakeHttpServletRequest() { HttpServletRequest delegate = (HttpServletRequest) Proxy.newProxyInstance( HttpServletRequest.class.getClassLoader(), new Class[] { HttpServletRequest.class }, new ThrowingInvocationHandler()); return new HttpServletRequestWrapper(delegate) { final Map attributes = Maps.newHashMap(); final HttpSession session = newFakeHttpSession(); @Override public String getMethod() { return "GET"; } @Override public Object getAttribute(String name) { return attributes.get(name); } @Override public void setAttribute(String name, Object value) { attributes.put(name, value); } @Override public Map getParameterMap() { return ImmutableMap.of(); } @Override public String getRequestURI() { return "/"; } @Override public String getContextPath() { return ""; } @Override public HttpSession getSession() { return session; } }; } /** * Returns a fake, HttpServletResponse which throws an exception if any of its * methods are called. */ public static HttpServletResponse newFakeHttpServletResponse() { return (HttpServletResponse) Proxy.newProxyInstance( HttpServletResponse.class.getClassLoader(), new Class[] { HttpServletResponse.class }, new ThrowingInvocationHandler()); } private static class FakeHttpSessionHandler implements InvocationHandler, Serializable { final Map attributes = Maps.newHashMap(); public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if ("setAttribute".equals(name)) { attributes.put((String) args[0], args[1]); return null; } else if ("getAttribute".equals(name)) { return attributes.get(args[0]); } else { throw new UnsupportedOperationException(); } } } /** * Returns a fake, serializable HttpSession which stores attributes in a HashMap. */ public static HttpSession newFakeHttpSession() { return (HttpSession) Proxy.newProxyInstance(HttpSession.class.getClassLoader(), new Class[] { HttpSession.class }, new FakeHttpSessionHandler()); } } sisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ServletTest.java0000644000175000017500000004034411704661106031402 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static com.google.inject.Asserts.reserialize; import static com.google.inject.servlet.ServletTestUtils.newFakeHttpServletRequest; import static com.google.inject.servlet.ServletTestUtils.newFakeHttpServletResponse; import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.PARAMETER; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.inject.AbstractModule; import com.google.inject.BindingAnnotation; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provider; import com.google.inject.servlet.ServletScopes.NullObject; import com.google.inject.util.Providers; import junit.framework.TestCase; import java.io.IOException; import java.io.Serializable; import java.lang.annotation.Retention; import java.lang.annotation.Target; import java.util.Map; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; import javax.servlet.http.HttpSession; /** * @author crazybob@google.com (Bob Lee) */ public class ServletTest extends TestCase { private static final Key HTTP_REQ_KEY = Key.get(HttpServletRequest.class); private static final Key HTTP_RESP_KEY = Key.get(HttpServletResponse.class); private static final Key> REQ_PARAMS_KEY = new Key>(RequestParameters.class) {}; private static final Key IN_REQUEST_KEY = Key.get(InRequest.class); private static final Key IN_REQUEST_NULL_KEY = Key.get(InRequest.class, Null.class); private static final Key IN_SESSION_KEY = Key.get(InSession.class); private static final Key IN_SESSION_NULL_KEY = Key.get(InSession.class, Null.class); @Override public void setUp() { //we need to clear the reference to the pipeline every test =( GuiceFilter.reset(); } public void testRequestAndResponseBindings() throws Exception { final Injector injector = createInjector(); final HttpServletRequest request = newFakeHttpServletRequest(); final HttpServletResponse response = newFakeHttpServletResponse(); final boolean[] invoked = new boolean[1]; GuiceFilter filter = new GuiceFilter(); FilterChain filterChain = new FilterChain() { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) { invoked[0] = true; assertSame(request, servletRequest); assertSame(request, injector.getInstance(ServletRequest.class)); assertSame(request, injector.getInstance(HTTP_REQ_KEY)); assertSame(response, servletResponse); assertSame(response, injector.getInstance(ServletResponse.class)); assertSame(response, injector.getInstance(HTTP_RESP_KEY)); assertSame(servletRequest.getParameterMap(), injector.getInstance(REQ_PARAMS_KEY)); } }; filter.doFilter(request, response, filterChain); assertTrue(invoked[0]); } public void testRequestAndResponseBindings_wrappingFilter() throws Exception { final HttpServletRequest request = newFakeHttpServletRequest(); final ImmutableMap wrappedParamMap = ImmutableMap.of("wrap", new String[]{"a", "b"}); final HttpServletRequestWrapper requestWrapper = new HttpServletRequestWrapper(request) { @Override public Map getParameterMap() { return wrappedParamMap; } @Override public Object getAttribute(String attr) { // Ensure that attributes are stored on the original request object. throw new UnsupportedOperationException(); } }; final HttpServletResponse response = newFakeHttpServletResponse(); final HttpServletResponseWrapper responseWrapper = new HttpServletResponseWrapper(response); final boolean[] filterInvoked = new boolean[1]; final Injector injector = createInjector(new ServletModule() { @Override protected void configureServlets() { filter("/*").through(new Filter() { @Inject Provider servletReqProvider; @Inject Provider reqProvider; @Inject Provider servletRespProvider; @Inject Provider respProvider; public void init(FilterConfig filterConfig) {} public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { filterInvoked[0] = true; assertSame(req, servletReqProvider.get()); assertSame(req, reqProvider.get()); assertSame(resp, servletRespProvider.get()); assertSame(resp, respProvider.get()); chain.doFilter(requestWrapper, responseWrapper); assertSame(req, reqProvider.get()); assertSame(resp, respProvider.get()); } public void destroy() {} }); } }); GuiceFilter filter = new GuiceFilter(); final boolean[] chainInvoked = new boolean[1]; FilterChain filterChain = new FilterChain() { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) { chainInvoked[0] = true; assertSame(requestWrapper, servletRequest); assertSame(requestWrapper, injector.getInstance(ServletRequest.class)); assertSame(requestWrapper, injector.getInstance(HTTP_REQ_KEY)); assertSame(responseWrapper, servletResponse); assertSame(responseWrapper, injector.getInstance(ServletResponse.class)); assertSame(responseWrapper, injector.getInstance(HTTP_RESP_KEY)); assertSame(servletRequest.getParameterMap(), injector.getInstance(REQ_PARAMS_KEY)); InRequest inRequest = injector.getInstance(InRequest.class); assertSame(inRequest, injector.getInstance(InRequest.class)); } }; filter.doFilter(request, response, filterChain); assertTrue(chainInvoked[0]); assertTrue(filterInvoked[0]); } public void testRequestAndResponseBindings_matchesPassedParameters() throws Exception { final int[] filterInvoked = new int[1]; final boolean[] servletInvoked = new boolean[1]; final Injector injector = createInjector(new ServletModule() { @Override protected void configureServlets() { final HttpServletRequest[] previousReq = new HttpServletRequest[1]; final HttpServletResponse[] previousResp = new HttpServletResponse[1]; final Provider servletReqProvider = getProvider(ServletRequest.class); final Provider reqProvider = getProvider(HttpServletRequest.class); final Provider servletRespProvider = getProvider(ServletResponse.class); final Provider respProvider = getProvider(HttpServletResponse.class); Filter filter = new Filter() { public void init(FilterConfig filterConfig) {} public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { filterInvoked[0]++; assertSame(req, servletReqProvider.get()); assertSame(req, reqProvider.get()); if (previousReq[0] != null) { assertEquals(req, previousReq[0]); } assertSame(resp, servletRespProvider.get()); assertSame(resp, respProvider.get()); if (previousResp[0] != null) { assertEquals(resp, previousResp[0]); } chain.doFilter( previousReq[0] = new HttpServletRequestWrapper((HttpServletRequest) req), previousResp[0] = new HttpServletResponseWrapper((HttpServletResponse) resp)); assertSame(req, reqProvider.get()); assertSame(resp, respProvider.get()); } public void destroy() {} }; filter("/*").through(filter); filter("/*").through(filter); // filter twice to test wrapping in filters serve("/*").with(new HttpServlet() { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) { servletInvoked[0] = true; assertSame(req, servletReqProvider.get()); assertSame(req, reqProvider.get()); assertSame(resp, servletRespProvider.get()); assertSame(resp, respProvider.get()); } }); } }); GuiceFilter filter = new GuiceFilter(); filter.doFilter(newFakeHttpServletRequest(), newFakeHttpServletResponse(), new FilterChain() { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) { throw new IllegalStateException("Shouldn't get here"); } }); assertEquals(2, filterInvoked[0]); assertTrue(servletInvoked[0]); } public void testNewRequestObject() throws CreationException, IOException, ServletException { final Injector injector = createInjector(); final HttpServletRequest request = newFakeHttpServletRequest(); GuiceFilter filter = new GuiceFilter(); final boolean[] invoked = new boolean[1]; FilterChain filterChain = new FilterChain() { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) { invoked[0] = true; assertNotNull(injector.getInstance(InRequest.class)); assertNull(injector.getInstance(IN_REQUEST_NULL_KEY)); } }; filter.doFilter(request, null, filterChain); assertTrue(invoked[0]); } public void testExistingRequestObject() throws CreationException, IOException, ServletException { final Injector injector = createInjector(); final HttpServletRequest request = newFakeHttpServletRequest(); GuiceFilter filter = new GuiceFilter(); final boolean[] invoked = new boolean[1]; FilterChain filterChain = new FilterChain() { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) { invoked[0] = true; InRequest inRequest = injector.getInstance(InRequest.class); assertSame(inRequest, injector.getInstance(InRequest.class)); assertNull(injector.getInstance(IN_REQUEST_NULL_KEY)); assertNull(injector.getInstance(IN_REQUEST_NULL_KEY)); } }; filter.doFilter(request, null, filterChain); assertTrue(invoked[0]); } public void testNewSessionObject() throws CreationException, IOException, ServletException { final Injector injector = createInjector(); final HttpServletRequest request = newFakeHttpServletRequest(); GuiceFilter filter = new GuiceFilter(); final boolean[] invoked = new boolean[1]; FilterChain filterChain = new FilterChain() { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) { invoked[0] = true; assertNotNull(injector.getInstance(InSession.class)); assertNull(injector.getInstance(IN_SESSION_NULL_KEY)); } }; filter.doFilter(request, null, filterChain); assertTrue(invoked[0]); } public void testExistingSessionObject() throws CreationException, IOException, ServletException { final Injector injector = createInjector(); final HttpServletRequest request = newFakeHttpServletRequest(); GuiceFilter filter = new GuiceFilter(); final boolean[] invoked = new boolean[1]; FilterChain filterChain = new FilterChain() { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) { invoked[0] = true; InSession inSession = injector.getInstance(InSession.class); assertSame(inSession, injector.getInstance(InSession.class)); assertNull(injector.getInstance(IN_SESSION_NULL_KEY)); assertNull(injector.getInstance(IN_SESSION_NULL_KEY)); } }; filter.doFilter(request, null, filterChain); assertTrue(invoked[0]); } public void testHttpSessionIsSerializable() throws IOException, ClassNotFoundException, ServletException { final Injector injector = createInjector(); final HttpServletRequest request = newFakeHttpServletRequest(); final HttpSession session = request.getSession(); GuiceFilter filter = new GuiceFilter(); final boolean[] invoked = new boolean[1]; FilterChain filterChain = new FilterChain() { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) { invoked[0] = true; assertNotNull(injector.getInstance(InSession.class)); assertNull(injector.getInstance(IN_SESSION_NULL_KEY)); } }; filter.doFilter(request, null, filterChain); assertTrue(invoked[0]); HttpSession deserializedSession = reserialize(session); String inSessionKey = IN_SESSION_KEY.toString(); String inSessionNullKey = IN_SESSION_NULL_KEY.toString(); assertTrue(deserializedSession.getAttribute(inSessionKey) instanceof InSession); assertEquals(NullObject.INSTANCE, deserializedSession.getAttribute(inSessionNullKey)); } public void testGuiceFilterConstructors() throws Exception { final RuntimeException servletException = new RuntimeException(); final RuntimeException chainException = new RuntimeException(); final Injector injector = createInjector(new ServletModule() { @Override protected void configureServlets() { serve("/*").with(new HttpServlet() { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) { throw servletException; } }); } }); final HttpServletRequest request = newFakeHttpServletRequest(); FilterChain filterChain = new FilterChain() { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) { throw chainException; } }; try { new GuiceFilter().doFilter(request, null, filterChain); fail(); } catch (RuntimeException e) { assertSame(servletException, e); } try { injector.getInstance(GuiceFilter.class).doFilter(request, null, filterChain); fail(); } catch (RuntimeException e) { assertSame(servletException, e); } try { injector.getInstance(Key.get(GuiceFilter.class, ScopingOnly.class)) .doFilter(request, null, filterChain); fail(); } catch (RuntimeException e) { assertSame(chainException, e); } } private Injector createInjector(Module... modules) throws CreationException { return Guice.createInjector(Lists.asList(new AbstractModule() { @Override protected void configure() { install(new ServletModule()); bind(InSession.class); bind(IN_SESSION_NULL_KEY).toProvider(Providers.of(null)).in(SessionScoped.class); bind(InRequest.class); bind(IN_REQUEST_NULL_KEY).toProvider(Providers.of(null)).in(RequestScoped.class); } }, modules)); } @SessionScoped static class InSession implements Serializable {} @RequestScoped static class InRequest {} @BindingAnnotation @Retention(RUNTIME) @Target({PARAMETER, METHOD, FIELD}) @interface Null {} } sisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ServletSpiVisitor.java0000644000175000017500000001156511704661106032601 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.inject.Binding; import com.google.inject.Injector; import com.google.inject.Stage; import com.google.inject.spi.DefaultBindingTargetVisitor; import junit.framework.AssertionFailedError; import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Logger; import javax.servlet.Filter; import javax.servlet.ServletContext; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * A visitor for testing the servlet SPI extension. * * @author sameb@google.com (Sam Berlin) */ class ServletSpiVisitor extends DefaultBindingTargetVisitor implements ServletModuleTargetVisitor { int otherCount = 0; int currentCount = 0; List actual = Lists.newArrayList(); /* The set of classes that are allowed to be "other" bindings. */ Set allowedClasses; ServletSpiVisitor(boolean forInjector) { ImmutableSet.Builder builder = ImmutableSet.builder(); // always ignore these things... builder.add(ServletRequest.class, ServletResponse.class, ManagedFilterPipeline.class, ManagedServletPipeline.class, FilterPipeline.class, ServletContext.class, HttpServletRequest.class, Filter.class, HttpServletResponse.class, HttpSession.class, Map.class, HttpServlet.class, InternalServletModule.BackwardsCompatibleServletContextProvider.class, GuiceFilter.class); if(forInjector) { // only ignore these if this is for the live injector, any other time it'd be an error! builder.add(Injector.class, Stage.class, Logger.class); } this.allowedClasses = builder.build(); } public Integer visit(InstanceFilterBinding binding) { actual.add(new Params(binding, binding.getFilterInstance())); return currentCount++; } public Integer visit(InstanceServletBinding binding) { actual.add(new Params(binding, binding.getServletInstance())); return currentCount++; } public Integer visit(LinkedFilterBinding binding) { actual.add(new Params(binding, binding.getLinkedKey())); return currentCount++; } public Integer visit(LinkedServletBinding binding) { actual.add(new Params(binding, binding.getLinkedKey())); return currentCount++; } @Override protected Integer visitOther(Binding binding) { if(!allowedClasses.contains(binding.getKey().getTypeLiteral().getRawType())) { throw new AssertionFailedError("invalid other binding: " + binding); } otherCount++; return currentCount++; } static class Params { private final String pattern; private final Object keyOrInstance; private final Map params; private final UriPatternType patternType; Params(ServletModuleBinding binding, Object keyOrInstance) { this.pattern = binding.getPattern(); this.keyOrInstance = keyOrInstance; this.params = binding.getInitParams(); this.patternType = binding.getUriPatternType(); } Params(String pattern, Object keyOrInstance, Map params, UriPatternType patternType) { this.pattern = pattern; this.keyOrInstance = keyOrInstance; this.params = params; this.patternType = patternType; } @Override public boolean equals(Object obj) { if(obj instanceof Params) { Params o = (Params)obj; return Objects.equal(pattern, o.pattern) && Objects.equal(keyOrInstance, o.keyOrInstance) && Objects.equal(params, o.params) && Objects.equal(patternType, o.patternType); } else { return false; } } @Override public int hashCode() { return Objects.hashCode(pattern, keyOrInstance, params, patternType); } @Override public String toString() { return Objects.toStringHelper(Params.class) .add("pattern", pattern) .add("keyOrInstance", keyOrInstance) .add("initParams", params) .add("patternType", patternType) .toString(); } } }sisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ServletScopesTest.java0000644000175000017500000002031611704661106032554 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static com.google.inject.name.Names.named; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.common.collect.ImmutableMap; import com.google.inject.AbstractModule; import com.google.inject.Binding; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.PrivateModule; import com.google.inject.Provides; import com.google.inject.ScopeAnnotation; import com.google.inject.Scopes; import com.google.inject.Singleton; import com.google.inject.name.Named; import com.google.inject.spi.Element; import com.google.inject.spi.Elements; import com.google.inject.spi.PrivateElements; import com.google.inject.util.Providers; import junit.framework.TestCase; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; import java.util.List; import java.util.Map; /** * Tests for {@link ServletScopes}. * * @author forster@google.com (Mike Forster) */ public class ServletScopesTest extends TestCase { public void testIsRequestScopedPositive() { final Key a = Key.get(String.class, named("A")); final Key b = Key.get(String.class, named("B")); final Key c = Key.get(String.class, named("C")); final Key d = Key.get(String.class, named("D")); final Key e = Key.get(Object.class, named("E")); final Key f = Key.get(String.class, named("F")); final Key g = Key.get(String.class, named("G")); Module requestScopedBindings = new AbstractModule() { @Override protected void configure() { bind(a).to(b); bind(b).to(c); bind(c).toProvider(Providers.of("c")).in(ServletScopes.REQUEST); bind(d).toProvider(Providers.of("d")).in(RequestScoped.class); bind(e).to(AnnotatedRequestScopedClass.class); install(new PrivateModule() { @Override protected void configure() { bind(f).toProvider(Providers.of("f")).in(RequestScoped.class); expose(f); } }); } @Provides @Named("G") @RequestScoped String provideG() { return "g"; } }; @SuppressWarnings("unchecked") // we know the module contains only bindings List moduleBindings = Elements.getElements(requestScopedBindings); ImmutableMap, Binding> map = indexBindings(moduleBindings); // linked bindings are not followed by modules assertFalse(ServletScopes.isRequestScoped(map.get(a))); assertFalse(ServletScopes.isRequestScoped(map.get(b))); assertTrue(ServletScopes.isRequestScoped(map.get(c))); assertTrue(ServletScopes.isRequestScoped(map.get(d))); // annotated classes are not followed by modules assertFalse(ServletScopes.isRequestScoped(map.get(e))); assertTrue(ServletScopes.isRequestScoped(map.get(f))); assertTrue(ServletScopes.isRequestScoped(map.get(g))); Injector injector = Guice.createInjector(requestScopedBindings, new ServletModule()); assertTrue(ServletScopes.isRequestScoped(injector.getBinding(a))); assertTrue(ServletScopes.isRequestScoped(injector.getBinding(b))); assertTrue(ServletScopes.isRequestScoped(injector.getBinding(c))); assertTrue(ServletScopes.isRequestScoped(injector.getBinding(d))); assertTrue(ServletScopes.isRequestScoped(injector.getBinding(e))); assertTrue(ServletScopes.isRequestScoped(injector.getBinding(f))); assertTrue(ServletScopes.isRequestScoped(injector.getBinding(g))); } public void testIsRequestScopedNegative() { final Key a = Key.get(String.class, named("A")); final Key b = Key.get(String.class, named("B")); final Key c = Key.get(String.class, named("C")); final Key d = Key.get(String.class, named("D")); final Key e = Key.get(String.class, named("E")); final Key f = Key.get(String.class, named("F")); final Key g = Key.get(String.class, named("G")); final Key h = Key.get(String.class, named("H")); final Key i = Key.get(String.class, named("I")); final Key j = Key.get(String.class, named("J")); Module requestScopedBindings = new AbstractModule() { @Override protected void configure() { bind(a).to(b); bind(b).to(c); bind(c).toProvider(Providers.of("c")).in(Scopes.NO_SCOPE); bind(d).toInstance("d"); bind(e).toProvider(Providers.of("e")).asEagerSingleton(); bind(f).toProvider(Providers.of("f")).in(Scopes.SINGLETON); bind(g).toProvider(Providers.of("g")).in(Singleton.class); bind(h).toProvider(Providers.of("h")).in(CustomScoped.class); bindScope(CustomScoped.class, Scopes.NO_SCOPE); install(new PrivateModule() { @Override protected void configure() { bind(i).toProvider(Providers.of("i")).in(CustomScoped.class); expose(i); } }); } @Provides @Named("J") @CustomScoped String provideJ() { return "j"; } }; @SuppressWarnings("unchecked") // we know the module contains only bindings List moduleBindings = Elements.getElements(requestScopedBindings); ImmutableMap, Binding> map = indexBindings(moduleBindings); assertFalse(ServletScopes.isRequestScoped(map.get(a))); assertFalse(ServletScopes.isRequestScoped(map.get(b))); assertFalse(ServletScopes.isRequestScoped(map.get(c))); assertFalse(ServletScopes.isRequestScoped(map.get(d))); assertFalse(ServletScopes.isRequestScoped(map.get(e))); assertFalse(ServletScopes.isRequestScoped(map.get(f))); assertFalse(ServletScopes.isRequestScoped(map.get(g))); assertFalse(ServletScopes.isRequestScoped(map.get(h))); assertFalse(ServletScopes.isRequestScoped(map.get(i))); assertFalse(ServletScopes.isRequestScoped(map.get(j))); Injector injector = Guice.createInjector(requestScopedBindings); assertFalse(ServletScopes.isRequestScoped(injector.getBinding(a))); assertFalse(ServletScopes.isRequestScoped(injector.getBinding(b))); assertFalse(ServletScopes.isRequestScoped(injector.getBinding(c))); assertFalse(ServletScopes.isRequestScoped(injector.getBinding(d))); assertFalse(ServletScopes.isRequestScoped(injector.getBinding(e))); assertFalse(ServletScopes.isRequestScoped(injector.getBinding(f))); assertFalse(ServletScopes.isRequestScoped(injector.getBinding(g))); assertFalse(ServletScopes.isRequestScoped(injector.getBinding(h))); assertFalse(ServletScopes.isRequestScoped(injector.getBinding(i))); assertFalse(ServletScopes.isRequestScoped(injector.getBinding(j))); } @RequestScoped static class AnnotatedRequestScopedClass {} @Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RUNTIME) @ScopeAnnotation private @interface CustomScoped {} private ImmutableMap, Binding> indexBindings(Iterable elements) { ImmutableMap.Builder, Binding> builder = ImmutableMap.builder(); for (Element element : elements) { if (element instanceof Binding) { Binding binding = (Binding) element; builder.put(binding.getKey(), binding); } else if (element instanceof PrivateElements) { PrivateElements privateElements = (PrivateElements) element; Map, Binding> privateBindings = indexBindings(privateElements.getElements()); for (Key exposed : privateElements.getExposedKeys()) { builder.put(exposed, privateBindings.get(exposed)); } } } return builder.build(); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ServletPipelineRequestDispatcherTest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ServletPipelineRequest0000644000175000017500000002432611704661106032663 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static com.google.inject.servlet.ManagedServletPipeline.REQUEST_DISPATCHER_REQUEST; import static org.easymock.EasyMock.anyObject; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.eq; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.expectLastCall; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.inject.Binding; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.TypeLiteral; import com.google.inject.spi.BindingScopingVisitor; import com.google.inject.util.Providers; import junit.framework.TestCase; import java.io.IOException; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.UUID; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Tests forwarding and inclusion (RequestDispatcher actions from the * servlet spec). * * @author Dhanji R. Prasanna (dhanji@gmail com) */ public class ServletPipelineRequestDispatcherTest extends TestCase { private static final Key HTTP_SERLVET_KEY = Key.get(HttpServlet.class); private static final String A_KEY = "thinglyDEgintly" + new Date() + UUID.randomUUID(); private static final String A_VALUE = ServletPipelineRequestDispatcherTest.class.toString() + new Date() + UUID.randomUUID(); public final void testIncludeManagedServlet() throws IOException, ServletException { String pattern = "blah.html"; final ServletDefinition servletDefinition = new ServletDefinition(pattern, Key.get(HttpServlet.class), UriPatternType.get(UriPatternType.SERVLET, pattern), new HashMap(), null); final Injector injector = createMock(Injector.class); final Binding binding = createMock(Binding.class); final HttpServletRequest requestMock = createMock(HttpServletRequest.class); expect(requestMock.getAttribute(A_KEY)) .andReturn(A_VALUE); requestMock.setAttribute(REQUEST_DISPATCHER_REQUEST, true); requestMock.removeAttribute(REQUEST_DISPATCHER_REQUEST); final boolean[] run = new boolean[1]; final HttpServlet mockServlet = new HttpServlet() { protected void service(HttpServletRequest request, HttpServletResponse httpServletResponse) throws ServletException, IOException { run[0] = true; final Object o = request.getAttribute(A_KEY); assertEquals("Wrong attrib returned - " + o, A_VALUE, o); } }; expect(binding.acceptScopingVisitor((BindingScopingVisitor) anyObject())) .andReturn(true); expect(injector.getBinding(Key.get(HttpServlet.class))) .andReturn(binding); expect(injector.getInstance(HTTP_SERLVET_KEY)) .andReturn(mockServlet); final Key servetDefsKey = Key .get(TypeLiteral.get(ServletDefinition.class)); Binding mockBinding = createMock(Binding.class); expect(injector.findBindingsByType(eq(servetDefsKey.getTypeLiteral()))) .andReturn(ImmutableList.>of(mockBinding)); Provider bindingProvider = Providers.of(servletDefinition); expect(mockBinding.getProvider()) .andReturn(bindingProvider); replay(injector, binding, requestMock, mockBinding); // Have to init the Servlet before we can dispatch to it. servletDefinition.init(null, injector, Sets.newSetFromMap(Maps.newIdentityHashMap())); final RequestDispatcher dispatcher = new ManagedServletPipeline( injector) .getRequestDispatcher(pattern); assertNotNull(dispatcher); dispatcher.include(requestMock, createMock(HttpServletResponse.class)); assertTrue("Include did not dispatch to our servlet!", run[0]); verify(injector, requestMock, mockBinding); } public final void testForwardToManagedServlet() throws IOException, ServletException { String pattern = "blah.html"; final ServletDefinition servletDefinition = new ServletDefinition(pattern, Key.get(HttpServlet.class), UriPatternType.get(UriPatternType.SERVLET, pattern), new HashMap(), null); final Injector injector = createMock(Injector.class); final Binding binding = createMock(Binding.class); final HttpServletRequest requestMock = createMock(HttpServletRequest.class); final HttpServletResponse mockResponse = createMock(HttpServletResponse.class); expect(requestMock.getAttribute(A_KEY)) .andReturn(A_VALUE); requestMock.setAttribute(REQUEST_DISPATCHER_REQUEST, true); requestMock.removeAttribute(REQUEST_DISPATCHER_REQUEST); expect(mockResponse.isCommitted()) .andReturn(false); mockResponse.resetBuffer(); expectLastCall().once(); final List paths = new ArrayList(); final HttpServlet mockServlet = new HttpServlet() { protected void service(HttpServletRequest request, HttpServletResponse httpServletResponse) throws ServletException, IOException { paths.add(request.getRequestURI()); final Object o = request.getAttribute(A_KEY); assertEquals("Wrong attrib returned - " + o, A_VALUE, o); } }; expect(binding.acceptScopingVisitor((BindingScopingVisitor) anyObject())) .andReturn(true); expect(injector.getBinding(Key.get(HttpServlet.class))) .andReturn(binding); expect(injector.getInstance(HTTP_SERLVET_KEY)) .andReturn(mockServlet); final Key servetDefsKey = Key .get(TypeLiteral.get(ServletDefinition.class)); Binding mockBinding = createMock(Binding.class); expect(injector.findBindingsByType(eq(servetDefsKey.getTypeLiteral()))) .andReturn(ImmutableList.>of(mockBinding)); Provider bindingProvider = Providers.of(servletDefinition); expect(mockBinding.getProvider()) .andReturn(bindingProvider); replay(injector, binding, requestMock, mockResponse, mockBinding); // Have to init the Servlet before we can dispatch to it. servletDefinition.init(null, injector, Sets.newSetFromMap(Maps.newIdentityHashMap())); final RequestDispatcher dispatcher = new ManagedServletPipeline(injector) .getRequestDispatcher(pattern); assertNotNull(dispatcher); dispatcher.forward(requestMock, mockResponse); assertTrue("Include did not dispatch to our servlet!", paths.contains(pattern)); verify(injector, requestMock, mockResponse, mockBinding); } public final void testForwardToManagedServletFailureOnCommittedBuffer() throws IOException, ServletException { IllegalStateException expected = null; try { forwardToManagedServletFailureOnCommittedBuffer(); } catch (IllegalStateException ise) { expected = ise; } finally { assertNotNull("Expected IllegalStateException was not thrown", expected); } } public final void forwardToManagedServletFailureOnCommittedBuffer() throws IOException, ServletException { String pattern = "blah.html"; final ServletDefinition servletDefinition = new ServletDefinition(pattern, Key.get(HttpServlet.class), UriPatternType.get(UriPatternType.SERVLET, pattern), new HashMap(), null); final Injector injector = createMock(Injector.class); final Binding binding = createMock(Binding.class); final HttpServletRequest mockRequest = createMock(HttpServletRequest.class); final HttpServletResponse mockResponse = createMock(HttpServletResponse.class); expect(mockResponse.isCommitted()) .andReturn(true); final HttpServlet mockServlet = new HttpServlet() { protected void service(HttpServletRequest request, HttpServletResponse httpServletResponse) throws ServletException, IOException { final Object o = request.getAttribute(A_KEY); assertEquals("Wrong attrib returned - " + o, A_VALUE, o); } }; expect(binding.acceptScopingVisitor((BindingScopingVisitor) anyObject())) .andReturn(true); expect(injector.getBinding(Key.get(HttpServlet.class))) .andReturn(binding); expect(injector.getInstance(Key.get(HttpServlet.class))) .andReturn(mockServlet); final Key servetDefsKey = Key .get(TypeLiteral.get(ServletDefinition.class)); Binding mockBinding = createMock(Binding.class); expect(injector.findBindingsByType(eq(servetDefsKey.getTypeLiteral()))) .andReturn(ImmutableList.>of(mockBinding)); Provider bindingProvider = Providers.of(servletDefinition); expect(mockBinding.getProvider()) .andReturn(bindingProvider); replay(injector, binding, mockRequest, mockResponse, mockBinding); // Have to init the Servlet before we can dispatch to it. servletDefinition.init(null, injector, Sets.newSetFromMap(Maps.newIdentityHashMap())); final RequestDispatcher dispatcher = new ManagedServletPipeline(injector) .getRequestDispatcher(pattern); assertNotNull(dispatcher); try { dispatcher.forward(mockRequest, mockResponse); } finally { verify(injector, mockRequest, mockResponse, mockBinding); } } } sisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ServletModuleTest.java0000644000175000017500000000614011704661106032544 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.common.collect.Lists; import com.google.inject.Binding; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.spi.DefaultBindingTargetVisitor; import com.google.inject.spi.Elements; import junit.framework.TestCase; import java.util.List; /** * Tests for ServletModule, to ensure it captures bindings correctly. * * @author sameb@google.com (Sam Berlin) */ public class ServletModuleTest extends TestCase { public void testServletModuleReuse() { Module module = new Module(); Elements.getElements(module); // use the module once (to, say, introspect bindings) Injector injector = Guice.createInjector(module); // use it again. Visitor visitor = new Visitor(); // Validate only a single servlet binding & a single filter binding exist. for(Binding binding : injector.getAllBindings().values()) { binding.acceptTargetVisitor(visitor); } assertEquals("wrong linked servlets: " + visitor.linkedServlets, 0, visitor.linkedServlets.size()); assertEquals("wrong linked filters: " + visitor.linkedFilters, 0, visitor.linkedFilters.size()); assertEquals("wrong instance servlets: " + visitor.instanceServlets, 1, visitor.instanceServlets.size()); assertEquals("wrong instance filters: " + visitor.instanceFilters, 1, visitor.instanceFilters.size()); } private static class Module extends ServletModule { @Override protected void configureServlets() { serve("/sam/*").with(new DummyServlet()); filter("/tara/*").through(new DummyFilterImpl()); } } private static class Visitor extends DefaultBindingTargetVisitor implements ServletModuleTargetVisitor { List linkedFilters = Lists.newArrayList(); List linkedServlets = Lists.newArrayList(); List instanceFilters = Lists.newArrayList(); List instanceServlets = Lists.newArrayList(); public Void visit(LinkedFilterBinding binding) { linkedFilters.add(binding); return null; } public Void visit(InstanceFilterBinding binding) { instanceFilters.add(binding); return null; } public Void visit(LinkedServletBinding binding) { linkedServlets.add(binding); return null; } public Void visit(InstanceServletBinding binding) { instanceServlets.add(binding); return null; } } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ServletDispatchIntegrationTest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ServletDispatchIntegra0000644000175000017500000002013611704661106032611 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static com.google.inject.servlet.ManagedServletPipeline.REQUEST_DISPATCHER_REQUEST; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Singleton; import junit.framework.TestCase; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Tests the FilterPipeline that dispatches to guice-managed servlets, * is a full integration test, with a real injector. * * @author Dhanji R. Prasanna (dhanji gmail com) */ public class ServletDispatchIntegrationTest extends TestCase { private static int inits, services, destroys, doFilters; @Override public void setUp() { inits = 0; services = 0; destroys = 0; doFilters = 0; GuiceFilter.reset(); } public final void testDispatchRequestToManagedPipelineServlets() throws ServletException, IOException { final Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { serve("/*").with(TestServlet.class); // These servets should never fire... (ordering test) serve("*.html").with(NeverServlet.class); serve("/test/*").with(Key.get(NeverServlet.class)); serve("/index/*").with(Key.get(NeverServlet.class)); serve("*.jsp").with(Key.get(NeverServlet.class)); } }); final FilterPipeline pipeline = injector.getInstance(FilterPipeline.class); pipeline.initPipeline(null); //create ourselves a mock request with test URI HttpServletRequest requestMock = createMock(HttpServletRequest.class); expect(requestMock.getRequestURI()) .andReturn("/index.html") .times(1); expect(requestMock.getContextPath()) .andReturn("") .anyTimes(); //dispatch request replay(requestMock); pipeline.dispatch(requestMock, null, createMock(FilterChain.class)); pipeline.destroyPipeline(); verify(requestMock); assertTrue("lifecycle states did not fire correct number of times-- inits: " + inits + "; dos: " + services + "; destroys: " + destroys, inits == 2 && services == 1 && destroys == 2); } public final void testDispatchRequestToManagedPipelineWithFilter() throws ServletException, IOException { final Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { filter("/*").through(TestFilter.class); serve("/*").with(TestServlet.class); // These servets should never fire... serve("*.html").with(NeverServlet.class); serve("/test/*").with(Key.get(NeverServlet.class)); serve("/index/*").with(Key.get(NeverServlet.class)); serve("*.jsp").with(Key.get(NeverServlet.class)); } }); final FilterPipeline pipeline = injector.getInstance(FilterPipeline.class); pipeline.initPipeline(null); //create ourselves a mock request with test URI HttpServletRequest requestMock = createMock(HttpServletRequest.class); expect(requestMock.getRequestURI()) .andReturn("/index.html") .times(2); expect(requestMock.getContextPath()) .andReturn("") .anyTimes(); //dispatch request replay(requestMock); pipeline.dispatch(requestMock, null, createMock(FilterChain.class)); pipeline.destroyPipeline(); verify(requestMock); assertTrue("lifecycle states did not fire correct number of times-- inits: " + inits + "; dos: " + services + "; destroys: " + destroys + "; doFilters: " + doFilters, inits == 3 && services == 1 && destroys == 3 && doFilters == 1); } @Singleton public static class TestServlet extends HttpServlet { public void init(ServletConfig filterConfig) throws ServletException { inits++; } public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { services++; } public void destroy() { destroys++; } } @Singleton public static class NeverServlet extends HttpServlet { public void init(ServletConfig filterConfig) throws ServletException { inits++; } public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { assertTrue("NeverServlet was fired, when it should not have been.", false); } public void destroy() { destroys++; } } @Singleton public static class TestFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { inits++; } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { doFilters++; filterChain.doFilter(servletRequest, servletResponse); } public void destroy() { destroys++; } } @Singleton public static class ForwardingServlet extends HttpServlet { public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { final HttpServletRequest request = (HttpServletRequest) servletRequest; request.getRequestDispatcher("/blah.jsp") .forward(servletRequest, servletResponse); } } @Singleton public static class ForwardedServlet extends HttpServlet { static int forwardedTo = 0; // Reset for test. public ForwardedServlet() { forwardedTo = 0; } public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { final HttpServletRequest request = (HttpServletRequest) servletRequest; assertTrue((Boolean) request.getAttribute(REQUEST_DISPATCHER_REQUEST)); forwardedTo++; } } public void testForwardUsingRequestDispatcher() throws IOException, ServletException { Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { serve("/").with(ForwardingServlet.class); serve("/blah.jsp").with(ForwardedServlet.class); } }); final HttpServletRequest requestMock = createMock(HttpServletRequest.class); HttpServletResponse responseMock = createMock(HttpServletResponse.class); expect(requestMock.getRequestURI()) .andReturn("/") .anyTimes(); expect(requestMock.getContextPath()) .andReturn("") .anyTimes(); requestMock.setAttribute(REQUEST_DISPATCHER_REQUEST, true); expect(requestMock.getAttribute(REQUEST_DISPATCHER_REQUEST)).andReturn(true); requestMock.removeAttribute(REQUEST_DISPATCHER_REQUEST); expect(responseMock.isCommitted()).andReturn(false); responseMock.resetBuffer(); replay(requestMock, responseMock); new GuiceFilter() .doFilter(requestMock, responseMock, createMock(FilterChain.class)); assertEquals("Incorrect number of forwards", 1, ForwardedServlet.forwardedTo); verify(requestMock, responseMock); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ServletDefinitionTest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ServletDefinitionTest.0000644000175000017500000000720711704661106032552 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static org.easymock.EasyMock.anyObject; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.inject.Binding; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.spi.BindingScopingVisitor; import junit.framework.TestCase; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; /** * Basic unit test for lifecycle of a ServletDefinition (wrapper). * * @author Dhanji R. Prasanna (dhanji@gmail com) */ public class ServletDefinitionTest extends TestCase { public final void testServletInitAndConfig() throws ServletException { Injector injector = createMock(Injector.class); Binding binding = createMock(Binding.class); expect(binding.acceptScopingVisitor((BindingScopingVisitor) anyObject())) .andReturn(true); expect(injector.getBinding(Key.get(HttpServlet.class))) .andReturn(binding); final HttpServlet mockServlet = new HttpServlet() { }; expect(injector.getInstance(Key.get(HttpServlet.class))) .andReturn(mockServlet) .anyTimes(); replay(injector, binding); //some init params //noinspection SSBasedInspection final Map initParams = new HashMap() { { put("ahsd", "asdas24dok"); put("ahssd", "asdasd124ok"); put("ahfsasd", "asda124sdok"); put("ahsasgd", "a124sdasdok"); put("ahsd124124", "as124124124dasdok"); } }; String pattern = "/*"; final ServletDefinition servletDefinition = new ServletDefinition(pattern, Key.get(HttpServlet.class), UriPatternType.get(UriPatternType.SERVLET, pattern), initParams, null); ServletContext servletContext = createMock(ServletContext.class); final String contextName = "thing__!@@44__SRV" + getClass(); expect(servletContext.getServletContextName()) .andReturn(contextName); replay(servletContext); servletDefinition.init(servletContext, injector, Sets.newSetFromMap(Maps.newIdentityHashMap())); assertNotNull(mockServlet.getServletContext()); assertEquals(contextName, mockServlet.getServletContext().getServletContextName()); assertEquals(Key.get(HttpServlet.class).toString(), mockServlet.getServletName()); final ServletConfig servletConfig = mockServlet.getServletConfig(); final Enumeration names = servletConfig.getInitParameterNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); assertTrue(initParams.containsKey(name)); assertEquals(initParams.get(name), servletConfig.getInitParameter(name)); } verify(injector, binding, servletContext); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ServletDefinitionPathsTest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ServletDefinitionPaths0000644000175000017500000002717511704661106032642 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static com.google.inject.servlet.ManagedServletPipeline.REQUEST_DISPATCHER_REQUEST; import static org.easymock.EasyMock.anyObject; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.inject.Binding; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.spi.BindingScopingVisitor; import junit.framework.TestCase; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Ensures servlet spec compliance for CGI-style variables and general * path/pattern matching. * * @author Dhanji R. Prasanna (dhanji@gmail com) */ public class ServletDefinitionPathsTest extends TestCase { // Data-driven test. public final void testServletPathMatching() throws IOException, ServletException { servletPath("/index.html", "*.html", "/index.html"); servletPath("/somewhere/index.html", "*.html", "/somewhere/index.html"); servletPath("/somewhere/index.html", "/*", ""); servletPath("/index.html", "/*", ""); servletPath("/", "/*", ""); servletPath("//", "/*", ""); servletPath("/////", "/*", ""); servletPath("", "/*", ""); servletPath("/thing/index.html", "/thing/*", "/thing"); servletPath("/thing/wing/index.html", "/thing/*", "/thing"); } private void servletPath(final String requestPath, String mapping, final String expectedServletPath) throws IOException, ServletException { Injector injector = createMock(Injector.class); Binding binding = createMock(Binding.class); HttpServletRequest request = createMock(HttpServletRequest.class); HttpServletResponse response = createMock(HttpServletResponse.class); expect(binding.acceptScopingVisitor((BindingScopingVisitor) anyObject())) .andReturn(true); expect(injector.getBinding(Key.get(HttpServlet.class))) .andReturn(binding); final boolean[] run = new boolean[1]; //get an instance of this servlet expect(injector.getInstance(Key.get(HttpServlet.class))) .andReturn(new HttpServlet() { @Override protected void service(HttpServletRequest servletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { final String path = servletRequest.getServletPath(); assertEquals(String.format("expected [%s] but was [%s]", expectedServletPath, path), expectedServletPath, path); run[0] = true; } }); expect(request.getServletPath()) .andReturn(requestPath); replay(injector, binding, request); ServletDefinition servletDefinition = new ServletDefinition(mapping, Key.get(HttpServlet.class), UriPatternType.get(UriPatternType.SERVLET, mapping), new HashMap(), null); servletDefinition.init(null, injector, Sets.newSetFromMap(Maps.newIdentityHashMap())); servletDefinition.doService(request, response); assertTrue("Servlet did not run!", run[0]); verify(injector, binding, request); } // Data-driven test. public final void testPathInfoWithServletStyleMatching() throws IOException, ServletException { pathInfoWithServletStyleMatching("/path/index.html", "/path", "/*", "/index.html", ""); pathInfoWithServletStyleMatching("/path//hulaboo///index.html", "/path", "/*", "/hulaboo/index.html", ""); pathInfoWithServletStyleMatching("/path/", "/path", "/*", "/", ""); pathInfoWithServletStyleMatching("/path////////", "/path", "/*", "/", ""); // a servlet mapping of /thing/* pathInfoWithServletStyleMatching("/path/thing////////", "/path", "/thing/*", "/", "/thing"); pathInfoWithServletStyleMatching("/path/thing/stuff", "/path", "/thing/*", "/stuff", "/thing"); pathInfoWithServletStyleMatching("/path/thing/stuff.html", "/path", "/thing/*", "/stuff.html", "/thing"); pathInfoWithServletStyleMatching("/path/thing", "/path", "/thing/*", null, "/thing"); // *.xx style mapping pathInfoWithServletStyleMatching("/path/thing.thing", "/path", "*.thing", null, "/thing.thing"); pathInfoWithServletStyleMatching("/path///h.thing", "/path", "*.thing", null, "/h.thing"); pathInfoWithServletStyleMatching("/path///...//h.thing", "/path", "*.thing", null, "/.../h.thing"); pathInfoWithServletStyleMatching("/path/my/h.thing", "/path", "*.thing", null, "/my/h.thing"); } private void pathInfoWithServletStyleMatching(final String requestUri, final String contextPath, String mapping, final String expectedPathInfo, final String servletPath) throws IOException, ServletException { Injector injector = createMock(Injector.class); Binding binding = createMock(Binding.class); HttpServletRequest request = createMock(HttpServletRequest.class); HttpServletResponse response = createMock(HttpServletResponse.class); expect(binding.acceptScopingVisitor((BindingScopingVisitor) anyObject())) .andReturn(true); expect(injector.getBinding(Key.get(HttpServlet.class))) .andReturn(binding); final boolean[] run = new boolean[1]; //get an instance of this servlet expect(injector.getInstance(Key.get(HttpServlet.class))) .andReturn(new HttpServlet() { @Override protected void service(HttpServletRequest servletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { final String path = servletRequest.getPathInfo(); if (null == expectedPathInfo) { assertNull(String.format("expected [%s] but was [%s]", expectedPathInfo, path), path); } else { assertEquals(String.format("expected [%s] but was [%s]", expectedPathInfo, path), expectedPathInfo, path); } //assert memoizer //noinspection StringEquality assertSame("memo field did not work", path, servletRequest.getPathInfo()); run[0] = true; } }); expect(request.getRequestURI()) .andReturn(requestUri); expect(request.getServletPath()) .andReturn(servletPath) .anyTimes(); expect(request.getContextPath()) .andReturn(contextPath); expect(request.getAttribute(REQUEST_DISPATCHER_REQUEST)).andReturn(null); replay(injector, binding, request); ServletDefinition servletDefinition = new ServletDefinition(mapping, Key.get(HttpServlet.class), UriPatternType.get(UriPatternType.SERVLET, mapping), new HashMap(), null); servletDefinition.init(null, injector, Sets.newSetFromMap(Maps.newIdentityHashMap())); servletDefinition.doService(request, response); assertTrue("Servlet did not run!", run[0]); verify(injector, binding, request); } // Data-driven test. public final void testPathInfoWithRegexMatching() throws IOException, ServletException { // first a mapping of /* pathInfoWithRegexMatching("/path/index.html", "/path", "/(.)*", "/index.html", ""); pathInfoWithRegexMatching("/path//hulaboo///index.html", "/path", "/(.)*", "/hulaboo/index.html", ""); pathInfoWithRegexMatching("/path/", "/path", "/(.)*", "/", ""); pathInfoWithRegexMatching("/path////////", "/path", "/(.)*", "/", ""); // a servlet mapping of /thing/* pathInfoWithRegexMatching("/path/thing////////", "/path", "/thing/(.)*", "/", "/thing"); pathInfoWithRegexMatching("/path/thing/stuff", "/path", "/thing/(.)*", "/stuff", "/thing"); pathInfoWithRegexMatching("/path/thing/stuff.html", "/path", "/thing/(.)*", "/stuff.html", "/thing"); pathInfoWithRegexMatching("/path/thing", "/path", "/thing/(.)*", null, "/thing"); // *.xx style mapping pathInfoWithRegexMatching("/path/thing.thing", "/path", ".*\\.thing", null, "/thing.thing"); pathInfoWithRegexMatching("/path///h.thing", "/path", ".*\\.thing", null, "/h.thing"); pathInfoWithRegexMatching("/path///...//h.thing", "/path", ".*\\.thing", null, "/.../h.thing"); pathInfoWithRegexMatching("/path/my/h.thing", "/path", ".*\\.thing", null, "/my/h.thing"); // path pathInfoWithRegexMatching("/path/test.com/com.test.MyServletModule", "", "/path/[^/]+/(.*)", "com.test.MyServletModule", "/path/test.com/com.test.MyServletModule"); } public final void pathInfoWithRegexMatching(final String requestUri, final String contextPath, String mapping, final String expectedPathInfo, final String servletPath) throws IOException, ServletException { Injector injector = createMock(Injector.class); Binding binding = createMock(Binding.class); HttpServletRequest request = createMock(HttpServletRequest.class); HttpServletResponse response = createMock(HttpServletResponse.class); expect(binding.acceptScopingVisitor((BindingScopingVisitor) anyObject())) .andReturn(true); expect(injector.getBinding(Key.get(HttpServlet.class))) .andReturn(binding); final boolean[] run = new boolean[1]; //get an instance of this servlet expect(injector.getInstance(Key.get(HttpServlet.class))) .andReturn(new HttpServlet() { @Override protected void service(HttpServletRequest servletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { final String path = servletRequest.getPathInfo(); if (null == expectedPathInfo) { assertNull(String.format("expected [%s] but was [%s]", expectedPathInfo, path), path); } else { assertEquals(String.format("expected [%s] but was [%s]", expectedPathInfo, path), expectedPathInfo, path); } //assert memoizer //noinspection StringEquality assertSame("memo field did not work", path, servletRequest.getPathInfo()); run[0] = true; } }); expect(request.getRequestURI()) .andReturn(requestUri); expect(request.getServletPath()) .andReturn(servletPath) .anyTimes(); expect(request.getContextPath()) .andReturn(contextPath); expect(request.getAttribute(REQUEST_DISPATCHER_REQUEST)).andReturn(null); replay(injector, binding, request); ServletDefinition servletDefinition = new ServletDefinition(mapping, Key.get(HttpServlet.class), UriPatternType.get(UriPatternType.REGEX, mapping), new HashMap(), null); servletDefinition.init(null, injector, Sets.newSetFromMap(Maps.newIdentityHashMap())); servletDefinition.doService(request, response); assertTrue("Servlet did not run!", run[0]); verify(injector, binding, request); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ScopeRequestIntegrationTest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ScopeRequestIntegratio0000644000175000017500000001371111704661106032644 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.OutOfScopeException; import com.google.inject.Provider; import com.google.inject.ProvisionException; import com.google.inject.Singleton; import com.google.inject.name.Named; import com.google.inject.name.Names; import junit.framework.TestCase; import java.io.IOException; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import javax.servlet.ServletException; /** * Tests continuation of requests */ public class ScopeRequestIntegrationTest extends TestCase { private static final String A_VALUE = "thereaoskdao"; private static final String A_DIFFERENT_VALUE = "hiaoskd"; private static final String SHOULDNEVERBESEEN = "Shouldneverbeseen!"; public final void testNonHttpRequestScopedCallable() throws ServletException, IOException, InterruptedException, ExecutionException { ExecutorService executor = Executors.newSingleThreadExecutor(); // We use servlet module here because we want to test that @RequestScoped // behaves properly with the non-HTTP request scope logic. Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { bindConstant().annotatedWith(Names.named(SomeObject.INVALID)).to(SHOULDNEVERBESEEN); bind(SomeObject.class).in(RequestScoped.class); } }); SomeObject someObject = new SomeObject(A_VALUE); OffRequestCallable offRequestCallable = injector.getInstance(OffRequestCallable.class); executor.submit(ServletScopes.scopeRequest(offRequestCallable, ImmutableMap., Object>of(Key.get(SomeObject.class), someObject))).get(); assertSame(injector.getInstance(OffRequestCallable.class), offRequestCallable); // Make sure the value was passed on. assertEquals(someObject.value, offRequestCallable.value); assertFalse(SHOULDNEVERBESEEN.equals(someObject.value)); // Now create a new request and assert that the scopes don't cross. someObject = new SomeObject(A_DIFFERENT_VALUE); executor.submit(ServletScopes.scopeRequest(offRequestCallable, ImmutableMap., Object>of(Key.get(SomeObject.class), someObject))).get(); assertSame(injector.getInstance(OffRequestCallable.class), offRequestCallable); // Make sure the value was passed on. assertEquals(someObject.value, offRequestCallable.value); assertFalse(SHOULDNEVERBESEEN.equals(someObject.value)); executor.shutdown(); executor.awaitTermination(2, TimeUnit.SECONDS); } public final void testWrongValueClasses() throws Exception { Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { bindConstant().annotatedWith(Names.named(SomeObject.INVALID)).to(SHOULDNEVERBESEEN); bind(SomeObject.class).in(RequestScoped.class); } }); OffRequestCallable offRequestCallable = injector.getInstance(OffRequestCallable.class); try { ServletScopes.scopeRequest(offRequestCallable, ImmutableMap., Object>of(Key.get(SomeObject.class), "Boo!")); fail(); } catch(IllegalArgumentException iae) { assertEquals("Value[Boo!] of type[java.lang.String] is not compatible with key[" + Key.get(SomeObject.class) + "]", iae.getMessage()); } } public final void testNullReplacement() throws Exception { Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { bindConstant().annotatedWith(Names.named(SomeObject.INVALID)).to(SHOULDNEVERBESEEN); bind(SomeObject.class).in(RequestScoped.class); } }); Callable callable = injector.getInstance(Caller.class); try { assertNotNull(callable.call()); fail(); } catch(ProvisionException pe) { assertTrue(pe.getCause() instanceof OutOfScopeException); } // Validate that an actual null entry in the map results in a null injected object. Map, Object> map = Maps.newHashMap(); map.put(Key.get(SomeObject.class), null); callable = ServletScopes.scopeRequest(injector.getInstance(Caller.class), map); assertNull(callable.call()); } @RequestScoped public static class SomeObject { private static final String INVALID = "invalid"; @Inject public SomeObject(@Named(INVALID) String value) { this.value = value; } private final String value; } @Singleton public static class OffRequestCallable implements Callable { @Inject Provider someObject; public String value; public String call() throws Exception { // Inside this request, we should always get the same instance. assertSame(someObject.get(), someObject.get()); value = someObject.get().value; assertFalse(SHOULDNEVERBESEEN.equals(value)); return value; } } private static class Caller implements Callable { @Inject Provider someObject; public SomeObject call() throws Exception { return someObject.get(); } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/MultipleServletInjectorsTest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/MultipleServletInjecto0000644000175000017500000000725311704661106032654 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static com.google.inject.servlet.GuiceServletContextListener.INJECTOR_NAME; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.eq; import static org.easymock.EasyMock.expectLastCall; import static org.easymock.EasyMock.isA; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import com.google.inject.Guice; import com.google.inject.Injector; import junit.framework.TestCase; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.http.HttpServlet; /** * This gorgeous test asserts that multiple servlet pipelines can * run in the SAME JVM. booya. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public class MultipleServletInjectorsTest extends TestCase { private Injector injectorOne; private Injector injectorTwo; public final void testTwoInjectors() { ServletContext fakeContextOne = createMock(ServletContext.class); ServletContext fakeContextTwo = createMock(ServletContext.class); fakeContextOne.setAttribute(eq(INJECTOR_NAME), isA(Injector.class)); expectLastCall().once(); fakeContextTwo.setAttribute(eq(INJECTOR_NAME), isA(Injector.class)); expectLastCall().once(); replay(fakeContextOne); // Simulate the start of a servlet container. new GuiceServletContextListener() { @Override protected Injector getInjector() { // Cache this injector in the test for later testing... return injectorOne = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { // This creates a ManagedFilterPipeline internally... serve("/*").with(DummyServlet.class); } }); } }.contextInitialized(new ServletContextEvent(fakeContextOne)); ServletContext contextOne = injectorOne.getInstance(ServletContext.class); assertNotNull(contextOne); // Now simulate a second injector with a slightly different config. replay(fakeContextTwo); new GuiceServletContextListener() { @Override protected Injector getInjector() { return injectorTwo = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { // This creates a ManagedFilterPipeline internally... filter("/8").through(DummyFilterImpl.class); serve("/*").with(HttpServlet.class); } }); } }.contextInitialized(new ServletContextEvent(fakeContextTwo)); ServletContext contextTwo = injectorTwo.getInstance(ServletContext.class); // Make sure they are different. assertNotNull(contextTwo); assertNotSame(contextOne, contextTwo); // Make sure they are as expected assertSame(fakeContextOne, contextOne); assertSame(fakeContextTwo, contextTwo); // Make sure they are consistent. assertSame(contextOne, injectorOne.getInstance(ServletContext.class)); assertSame(contextTwo, injectorTwo.getInstance(ServletContext.class)); verify(fakeContextOne, fakeContextTwo); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/MultiModuleDispatchIntegrationTest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/MultiModuleDispatchInt0000644000175000017500000000614111704661106032566 0ustar tonytonypackage com.google.inject.servlet; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Singleton; import junit.framework.TestCase; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; /** * * This tests that filter stage of the pipeline dispatches * correctly to guice-managed filters with multiple modules. * * WARNING(dhanji): Non-parallelizable test =( * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public class MultiModuleDispatchIntegrationTest extends TestCase { private static int inits, doFilters, destroys; @Override public final void setUp() { inits = 0; doFilters = 0; destroys = 0; GuiceFilter.reset(); } public final void testDispatchRequestToManagedPipeline() throws ServletException, IOException { final Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { filter("/*").through(TestFilter.class); // These filters should never fire filter("*.jsp").through(Key.get(TestFilter.class)); } }, new ServletModule() { @Override protected void configureServlets() { filter("*.html").through(TestFilter.class); filter("/*").through(Key.get(TestFilter.class)); // These filters should never fire filter("/index/*").through(Key.get(TestFilter.class)); } }); final FilterPipeline pipeline = injector.getInstance(FilterPipeline.class); pipeline.initPipeline(null); //create ourselves a mock request with test URI HttpServletRequest requestMock = createMock(HttpServletRequest.class); expect(requestMock.getRequestURI()) .andReturn("/index.html") .anyTimes(); expect(requestMock.getContextPath()) .andReturn("") .anyTimes(); //dispatch request replay(requestMock); pipeline.dispatch(requestMock, null, createMock(FilterChain.class)); pipeline.destroyPipeline(); verify(requestMock); assertTrue("lifecycle states did not" + " fire correct number of times-- inits: " + inits + "; dos: " + doFilters + "; destroys: " + destroys, inits == 1 && doFilters == 3 && destroys == 1); } @Singleton public static class TestFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { inits++; } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { doFilters++; filterChain.doFilter(servletRequest, servletResponse); } public void destroy() { destroys++; } } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/InvalidScopeBindingTest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/InvalidScopeBindingTes0000644000175000017500000000526511704661106032530 0ustar tonytonypackage com.google.inject.servlet; import static org.easymock.EasyMock.createMock; import com.google.inject.Guice; import com.google.inject.Scopes; import com.google.inject.Singleton; import junit.framework.TestCase; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; /** * Ensures that an error is thrown if a Servlet or Filter is bound * under any scope other than singleton, explicitly. * * @author dhanji@gmail.com */ public class InvalidScopeBindingTest extends TestCase { @Override protected void tearDown() throws Exception { GuiceFilter.reset(); } public final void testServletInNonSingletonScopeThrowsServletException(){ GuiceFilter guiceFilter = new GuiceFilter(); Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { serve("/*").with(MyNonSingletonServlet.class); } }); ServletException se = null; try { guiceFilter.init(createMock(FilterConfig.class)); } catch (ServletException e) { se = e; } finally { assertNotNull("Servlet exception was not thrown with wrong scope binding", se); } } public final void testFilterInNonSingletonScopeThrowsServletException(){ GuiceFilter guiceFilter = new GuiceFilter(); Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { filter("/*").through(MyNonSingletonFilter.class); } }); ServletException se = null; try { guiceFilter.init(createMock(FilterConfig.class)); } catch (ServletException e) { se = e; } finally { assertNotNull("Servlet exception was not thrown with wrong scope binding", se); } } public final void testHappyCaseFilter(){ GuiceFilter guiceFilter = new GuiceFilter(); Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { // Annotated scoping variant. filter("/*").through(MySingletonFilter.class); // Explicit scoping variant. bind(DummyFilterImpl.class).in(Scopes.SINGLETON); filter("/*").through(DummyFilterImpl.class); } }); ServletException se = null; try { guiceFilter.init(createMock(FilterConfig.class)); } catch (ServletException e) { se = e; } finally { assertNull("Servlet exception was thrown with correct scope binding", se); } } @RequestScoped public static class MyNonSingletonServlet extends HttpServlet { } @SessionScoped public static class MyNonSingletonFilter extends DummyFilterImpl { } @Singleton public static class MySingletonFilter extends DummyFilterImpl { } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/InjectedFilterPipelineTest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/InjectedFilterPipeline0000644000175000017500000001330711704661106032556 0ustar tonytonypackage com.google.inject.servlet; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.expectLastCall; import static org.easymock.EasyMock.isA; import static org.easymock.EasyMock.isNull; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.reset; import static org.easymock.EasyMock.verify; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Singleton; import junit.framework.TestCase; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; /** * Exactly the same as {@linkplain com.google.inject.servlet.FilterPipelineTest} except * that we test that the static pipeline is not used. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public class InjectedFilterPipelineTest extends TestCase { private Injector injector1; private Injector injector2; @Override public final void setUp() { injector1 = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { filter("/*").through(TestFilter.class); filter("*.html").through(TestFilter.class); filter("/*").through(Key.get(TestFilter.class)); filter("*.jsp").through(Key.get(TestFilter.class)); // These filters should never fire filter("/index/*").through(Key.get(NeverFilter.class)); filter("/public/login/*").through(Key.get(NeverFilter.class)); } }); // Test second injector with exactly opposite pipeline config injector2 = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { // These filters should never fire filter("*.html").through(NeverFilter.class); filter("/non-jsp/*").through(Key.get(NeverFilter.class)); // only these filters fire. filter("/index/*").through(Key.get(TestFilter.class)); filter("/public/login/*").through(Key.get(TestFilter.class)); } }); } @Override public final void tearDown() { } public final void testDispatchThruInjectedGuiceFilter() throws ServletException, IOException { //create mocks FilterConfig filterConfig = createMock(FilterConfig.class); ServletContext servletContext = createMock(ServletContext.class); HttpServletRequest request = createMock(HttpServletRequest.class); FilterChain proceedingFilterChain = createMock(FilterChain.class); //begin mock script *** expect(filterConfig.getServletContext()) .andReturn(servletContext) .once(); expect(request.getRequestURI()) .andReturn("/non-jsp/login.html") // use a path that will fail in injector2 .anyTimes(); expect(request.getContextPath()) .andReturn("") .anyTimes(); //at the end, proceed down webapp's normal filter chain proceedingFilterChain.doFilter(isA(HttpServletRequest.class), (ServletResponse) isNull()); expectLastCall().once(); //run mock script *** replay(filterConfig, servletContext, request, proceedingFilterChain); GuiceFilter webFilter = injector1.getInstance(GuiceFilter.class); webFilter.init(filterConfig); webFilter.doFilter(request, null, proceedingFilterChain); webFilter.destroy(); //assert expectations verify(filterConfig, servletContext, request, proceedingFilterChain); // reset mocks and run them against the other injector reset(filterConfig, servletContext, request, proceedingFilterChain); // Create a second proceeding filter chain FilterChain proceedingFilterChain2 = createMock(FilterChain.class); //begin mock script *** expect(filterConfig.getServletContext()) .andReturn(servletContext) .once(); expect(request.getRequestURI()) .andReturn("/public/login/login.jsp") // use a path that will fail in injector1 .anyTimes(); expect(request.getContextPath()) .andReturn("") .anyTimes(); //at the end, proceed down webapp's normal filter chain proceedingFilterChain2.doFilter(isA(HttpServletRequest.class), (ServletResponse) isNull()); expectLastCall().once(); // Never fire on this pipeline replay(filterConfig, servletContext, request, proceedingFilterChain2, proceedingFilterChain); webFilter = injector2.getInstance(GuiceFilter.class); webFilter.init(filterConfig); webFilter.doFilter(request, null, proceedingFilterChain2); webFilter.destroy(); // Verify that we have not crossed the streams, Venkman! verify(filterConfig, servletContext, request, proceedingFilterChain, proceedingFilterChain2); } @Singleton public static class TestFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { filterChain.doFilter(servletRequest, servletResponse); } public void destroy() { } } @Singleton public static class NeverFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { fail("This filter should never have fired"); } public void destroy() { } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/FilterPipelineTest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/FilterPipelineTest.jav0000644000175000017500000000721311704661106032526 0ustar tonytonypackage com.google.inject.servlet; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.expectLastCall; import static org.easymock.EasyMock.isA; import static org.easymock.EasyMock.isNull; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import com.google.inject.Guice; import com.google.inject.Key; import com.google.inject.Singleton; import junit.framework.TestCase; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; /** * This is a basic whitebox test that verifies the glue between * GuiceFilter and ManagedFilterPipeline is working. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public class FilterPipelineTest extends TestCase { @Override public final void setUp() { GuiceFilter.reset(); Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { filter("/*").through(TestFilter.class); filter("*.html").through(TestFilter.class); filter("/*").through(Key.get(TestFilter.class)); filter("*.jsp").through(Key.get(TestFilter.class)); // These filters should never fire filter("/index/*").through(Key.get(NeverFilter.class)); filter("/public/login/*").through(Key.get(NeverFilter.class)); } }); } @Override public final void tearDown() { GuiceFilter.reset(); } public final void testDispatchThruGuiceFilter() throws ServletException, IOException { //create mocks FilterConfig filterConfig = createMock(FilterConfig.class); ServletContext servletContext = createMock(ServletContext.class); HttpServletRequest request = createMock(HttpServletRequest.class); FilterChain proceedingFilterChain = createMock(FilterChain.class); //begin mock script *** expect(filterConfig.getServletContext()) .andReturn(servletContext) .once(); expect(request.getRequestURI()) .andReturn("/public/login.jsp") .anyTimes(); expect(request.getContextPath()) .andReturn("") .anyTimes(); //at the end, proceed down webapp's normal filter chain proceedingFilterChain.doFilter(isA(HttpServletRequest.class), (ServletResponse) isNull()); expectLastCall().once(); //run mock script *** replay(filterConfig, servletContext, request, proceedingFilterChain); final GuiceFilter webFilter = new GuiceFilter(); webFilter.init(filterConfig); webFilter.doFilter(request, null, proceedingFilterChain); webFilter.destroy(); //assert expectations verify(filterConfig, servletContext, request, proceedingFilterChain); } @Singleton public static class TestFilter implements Filter { public void init(FilterConfig filterConfig) { } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { filterChain.doFilter(servletRequest, servletResponse); } public void destroy() { } } @Singleton public static class NeverFilter implements Filter { public void init(FilterConfig filterConfig) { } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) { fail("This filter should never have fired"); } public void destroy() { } } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/FilterDispatchIntegrationTest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/FilterDispatchIntegrat0000644000175000017500000003130611704661106032577 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static com.google.inject.servlet.ManagedServletPipeline.REQUEST_DISPATCHER_REQUEST; import static com.google.inject.servlet.ServletTestUtils.newFakeHttpServletRequest; import static com.google.inject.servlet.ServletTestUtils.newNoOpFilterChain; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.expectLastCall; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Singleton; import junit.framework.TestCase; import org.easymock.EasyMock; import org.easymock.IMocksControl; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * * This tests that filter stage of the pipeline dispatches * correctly to guice-managed filters. * * WARNING(dhanji): Non-parallelizable test =( * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public class FilterDispatchIntegrationTest extends TestCase { private static int inits, doFilters, destroys; private IMocksControl control; @Override public final void setUp() { inits = 0; doFilters = 0; destroys = 0; control = EasyMock.createControl(); GuiceFilter.reset(); } public final void testDispatchRequestToManagedPipeline() throws ServletException, IOException { final Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { filter("/*").through(TestFilter.class); filter("*.html").through(TestFilter.class); filter("/*").through(Key.get(TestFilter.class)); // These filters should never fire filter("/index/*").through(Key.get(TestFilter.class)); filter("*.jsp").through(Key.get(TestFilter.class)); // Bind a servlet serve("*.html").with(TestServlet.class); } }); final FilterPipeline pipeline = injector.getInstance(FilterPipeline.class); pipeline.initPipeline(null); // create ourselves a mock request with test URI HttpServletRequest requestMock = control.createMock(HttpServletRequest.class); expect(requestMock.getRequestURI()) .andReturn("/index.html") .anyTimes(); expect(requestMock.getContextPath()) .andReturn("") .anyTimes(); requestMock.setAttribute(REQUEST_DISPATCHER_REQUEST, true); requestMock.removeAttribute(REQUEST_DISPATCHER_REQUEST); HttpServletResponse responseMock = control.createMock(HttpServletResponse.class); expect(responseMock.isCommitted()) .andReturn(false) .anyTimes(); responseMock.resetBuffer(); expectLastCall().anyTimes(); FilterChain filterChain = control.createMock(FilterChain.class); //dispatch request control.replay(); pipeline.dispatch(requestMock, responseMock, filterChain); pipeline.destroyPipeline(); control.verify(); TestServlet servlet = injector.getInstance(TestServlet.class); assertEquals(2, servlet.processedUris.size()); assertTrue(servlet.processedUris.contains("/index.html")); assertTrue(servlet.processedUris.contains(TestServlet.FORWARD_TO)); assertTrue("lifecycle states did not" + " fire correct number of times-- inits: " + inits + "; dos: " + doFilters + "; destroys: " + destroys, inits == 1 && doFilters == 3 && destroys == 1); } public final void testDispatchThatNoFiltersFire() throws ServletException, IOException { final Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { filter("/public/*").through(TestFilter.class); filter("*.html").through(TestFilter.class); filter("*.xml").through(Key.get(TestFilter.class)); // These filters should never fire filter("/index/*").through(Key.get(TestFilter.class)); filter("*.jsp").through(Key.get(TestFilter.class)); } }); final FilterPipeline pipeline = injector.getInstance(FilterPipeline.class); pipeline.initPipeline(null); //create ourselves a mock request with test URI HttpServletRequest requestMock = control.createMock(HttpServletRequest.class); expect(requestMock.getRequestURI()) .andReturn("/index.xhtml") .anyTimes(); expect(requestMock.getContextPath()) .andReturn("") .anyTimes(); //dispatch request FilterChain filterChain = control.createMock(FilterChain.class); filterChain.doFilter(requestMock, null); control.replay(); pipeline.dispatch(requestMock, null, filterChain); pipeline.destroyPipeline(); control.verify(); assertTrue("lifecycle states did not " + "fire correct number of times-- inits: " + inits + "; dos: " + doFilters + "; destroys: " + destroys, inits == 1 && doFilters == 0 && destroys == 1); } public final void testDispatchFilterPipelineWithRegexMatching() throws ServletException, IOException { final Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { filterRegex("/[A-Za-z]*").through(TestFilter.class); filterRegex("/index").through(TestFilter.class); //these filters should never fire filterRegex("\\w").through(Key.get(TestFilter.class)); } }); final FilterPipeline pipeline = injector.getInstance(FilterPipeline.class); pipeline.initPipeline(null); //create ourselves a mock request with test URI HttpServletRequest requestMock = control.createMock(HttpServletRequest.class); expect(requestMock.getRequestURI()) .andReturn("/index") .anyTimes(); expect(requestMock.getContextPath()) .andReturn("") .anyTimes(); // dispatch request FilterChain filterChain = control.createMock(FilterChain.class); filterChain.doFilter(requestMock, null); control.replay(); pipeline.dispatch(requestMock, null, filterChain); pipeline.destroyPipeline(); control.verify(); assertTrue("lifecycle states did not fire " + "correct number of times-- inits: " + inits + "; dos: " + doFilters + "; destroys: " + destroys, inits == 1 && doFilters == 2 && destroys == 1); } @Singleton public static class TestFilter implements Filter { public void init(FilterConfig filterConfig) { inits++; } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { doFilters++; filterChain.doFilter(servletRequest, servletResponse); } public void destroy() { destroys++; } } @Singleton public static class TestServlet extends HttpServlet { public static final String FORWARD_FROM = "/index.html"; public static final String FORWARD_TO = "/forwarded.html"; public List processedUris = new ArrayList(); @Override protected void service(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { String requestUri = httpServletRequest.getRequestURI(); processedUris.add(requestUri); // If the client is requesting /index.html then we forward to /forwarded.html if (FORWARD_FROM.equals(requestUri)) { httpServletRequest.getRequestDispatcher(FORWARD_TO) .forward(httpServletRequest, httpServletResponse); } } @Override public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException { service((HttpServletRequest) servletRequest, (HttpServletResponse) servletResponse); } } public void testFilterOrder() throws Exception { AtomicInteger counter = new AtomicInteger(); final CountFilter f1 = new CountFilter(counter); final CountFilter f2 = new CountFilter(counter); Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { filter("/").through(f1); install(new ServletModule() { @Override protected void configureServlets() { filter("/").through(f2); } }); } }); HttpServletRequest request = newFakeHttpServletRequest(); final FilterPipeline pipeline = injector.getInstance(FilterPipeline.class); pipeline.initPipeline(null); pipeline.dispatch(request, null, newNoOpFilterChain()); assertEquals(0, f1.calledAt); assertEquals(1, f2.calledAt); } /** A filter that keeps count of when it was called by increment a counter. */ private static class CountFilter implements Filter { private final AtomicInteger counter; private int calledAt = -1; public CountFilter(AtomicInteger counter) { this.counter = counter; } public void destroy() { } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException { if (calledAt != -1) { fail("not expecting to be called twice"); } calledAt = counter.getAndIncrement(); chain.doFilter(request, response); } public void init(FilterConfig filterConfig) {} } public final void testFilterExceptionPrunesStack() throws Exception { Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { filter("/").through(TestFilter.class); filter("/nothing").through(TestFilter.class); filter("/").through(ThrowingFilter.class); } }); HttpServletRequest request = newFakeHttpServletRequest(); FilterPipeline pipeline = injector.getInstance(FilterPipeline.class); pipeline.initPipeline(null); try { pipeline.dispatch(request, null, null); fail("expected exception"); } catch(ServletException ex) { for (StackTraceElement element : ex.getStackTrace()) { String className = element.getClassName(); assertTrue("was: " + element, !className.equals(FilterChainInvocation.class.getName()) && !className.equals(FilterDefinition.class.getName())); } } } public final void testServletExceptionPrunesStack() throws Exception { Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { filter("/").through(TestFilter.class); filter("/nothing").through(TestFilter.class); serve("/").with(ThrowingServlet.class); } }); HttpServletRequest request = newFakeHttpServletRequest(); FilterPipeline pipeline = injector.getInstance(FilterPipeline.class); pipeline.initPipeline(null); try { pipeline.dispatch(request, null, null); fail("expected exception"); } catch(ServletException ex) { for (StackTraceElement element : ex.getStackTrace()) { String className = element.getClassName(); assertTrue("was: " + element, !className.equals(FilterChainInvocation.class.getName()) && !className.equals(FilterDefinition.class.getName())); } } } @Singleton private static class ThrowingServlet extends HttpServlet { @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException { throw new ServletException("failure!"); } } @Singleton private static class ThrowingFilter implements Filter { @Override public void destroy() { } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException { throw new ServletException("we failed!"); } @Override public void init(FilterConfig filterConfig) { } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/FilterDefinitionTest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/FilterDefinitionTest.j0000644000175000017500000001736711704661106032535 0ustar tonytonypackage com.google.inject.servlet; import static org.easymock.EasyMock.anyObject; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.inject.Binding; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.spi.BindingScopingVisitor; import junit.framework.TestCase; import java.io.IOException; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; /** * Tests the lifecycle of the encapsulated {@link FilterDefinition} class. * * @author Dhanji R. Prasanna (dhanji@gmail com) */ public class FilterDefinitionTest extends TestCase { public final void testFilterInitAndConfig() throws ServletException { Injector injector = createMock(Injector.class); Binding binding = createMock(Binding.class); final MockFilter mockFilter = new MockFilter(); expect(binding.acceptScopingVisitor((BindingScopingVisitor) anyObject())) .andReturn(true); expect(injector.getBinding(Key.get(Filter.class))) .andReturn(binding); expect(injector.getInstance(Key.get(Filter.class))) .andReturn(mockFilter) .anyTimes(); replay(binding, injector); //some init params //noinspection SSBasedInspection final Map initParams = new HashMap() {{ put("ahsd", "asdas24dok"); put("ahssd", "asdasd124ok"); put("ahfsasd", "asda124sdok"); put("ahsasgd", "a124sdasdok"); put("ahsd124124", "as124124124dasdok"); }}; ServletContext servletContext = createMock(ServletContext.class); final String contextName = "thing__!@@44"; expect(servletContext.getServletContextName()).andReturn(contextName); replay(servletContext); String pattern = "/*"; final FilterDefinition filterDef = new FilterDefinition(pattern, Key.get(Filter.class), UriPatternType.get(UriPatternType.SERVLET, pattern), initParams, null); filterDef.init(servletContext, injector, Sets.newSetFromMap(Maps.newIdentityHashMap())); assertTrue(filterDef.getFilter() instanceof MockFilter); final FilterConfig filterConfig = mockFilter.getConfig(); assertTrue(null != filterConfig); assertTrue(contextName.equals(filterConfig.getServletContext().getServletContextName())); assertTrue(Key.get(Filter.class).toString().equals(filterConfig.getFilterName())); final Enumeration names = filterConfig.getInitParameterNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); assertTrue(initParams.containsKey(name)); assertTrue(initParams.get(name).equals(filterConfig.getInitParameter(name))); } verify(binding, injector, servletContext); } public final void testFilterCreateDispatchDestroy() throws ServletException, IOException { Injector injector = createMock(Injector.class); Binding binding = createMock(Binding.class); HttpServletRequest request = createMock(HttpServletRequest.class); final MockFilter mockFilter = new MockFilter(); expect(binding.acceptScopingVisitor((BindingScopingVisitor) anyObject())) .andReturn(true); expect(injector.getBinding(Key.get(Filter.class))) .andReturn(binding); expect(injector.getInstance(Key.get(Filter.class))) .andReturn(mockFilter) .anyTimes(); expect(request.getRequestURI()).andReturn("/index.html"); expect(request.getContextPath()) .andReturn("") .anyTimes(); replay(injector, binding, request); String pattern = "/*"; final FilterDefinition filterDef = new FilterDefinition(pattern, Key.get(Filter.class), UriPatternType.get(UriPatternType.SERVLET, pattern), new HashMap(), null); //should fire on mockfilter now filterDef.init(createMock(ServletContext.class), injector, Sets.newSetFromMap(Maps.newIdentityHashMap())); assertTrue(filterDef.getFilter() instanceof MockFilter); assertTrue("Init did not fire", mockFilter.isInit()); final boolean proceed[] = new boolean[1]; filterDef.doFilter(request, null, new FilterChainInvocation(null, null, null) { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) { proceed[0] = true; } }); assertTrue("Filter did not proceed down chain", proceed[0]); filterDef.destroy(Sets.newSetFromMap(Maps.newIdentityHashMap())); assertTrue("Destroy did not fire", mockFilter.isDestroy()); verify(injector, request); } public final void testFilterCreateDispatchDestroySupressChain() throws ServletException, IOException { Injector injector = createMock(Injector.class); Binding binding = createMock(Binding.class); HttpServletRequest request = createMock(HttpServletRequest.class); final MockFilter mockFilter = new MockFilter() { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) { //suppress rest of chain... } }; expect(binding.acceptScopingVisitor((BindingScopingVisitor) anyObject())) .andReturn(true); expect(injector.getBinding(Key.get(Filter.class))) .andReturn(binding); expect(injector.getInstance(Key.get(Filter.class))) .andReturn(mockFilter) .anyTimes(); expect(request.getRequestURI()).andReturn("/index.html"); expect(request.getContextPath()) .andReturn("") .anyTimes(); replay(injector, binding, request); String pattern = "/*"; final FilterDefinition filterDef = new FilterDefinition(pattern, Key.get(Filter.class), UriPatternType.get(UriPatternType.SERVLET, pattern), new HashMap(), null); //should fire on mockfilter now filterDef.init(createMock(ServletContext.class), injector, Sets.newSetFromMap(Maps.newIdentityHashMap())); assertTrue(filterDef.getFilter() instanceof MockFilter); assertTrue("init did not fire", mockFilter.isInit()); final boolean proceed[] = new boolean[1]; filterDef.doFilter(request, null, new FilterChainInvocation(null, null, null) { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) { proceed[0] = true; } }); assertTrue("filter did not suppress chain", !proceed[0]); filterDef.destroy(Sets.newSetFromMap(Maps.newIdentityHashMap())); assertTrue("destroy did not fire", mockFilter.isDestroy()); verify(injector, request); } private static class MockFilter implements Filter { private boolean init; private boolean destroy; private FilterConfig config; public void init(FilterConfig filterConfig) { init = true; this.config = filterConfig; } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { //proceed filterChain.doFilter(servletRequest, servletResponse); } public void destroy() { destroy = true; } public boolean isInit() { return init; } public boolean isDestroy() { return destroy; } public FilterConfig getConfig() { return config; } } } sisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ExtensionSpiTest.java0000644000175000017500000002536411704661106032413 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static com.google.inject.servlet.UriPatternType.REGEX; import static com.google.inject.servlet.UriPatternType.SERVLET; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.inject.Binding; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.name.Names; import com.google.inject.servlet.ServletSpiVisitor.Params; import com.google.inject.spi.Element; import com.google.inject.spi.Elements; import junit.framework.TestCase; import java.util.Iterator; import java.util.List; /** * A very basic test that servletmodule works with bindings. * * @author sameb@google.com (Sam Berlin) */ public class ExtensionSpiTest extends TestCase { private DummyFilterImpl dummyFilter1 = new DummyFilterImpl(); private DummyFilterImpl dummyFilter2 = new DummyFilterImpl(); private DummyFilterImpl dummyFilter3 = new DummyFilterImpl(); private DummyFilterImpl dummyFilter4 = new DummyFilterImpl(); private DummyServlet dummyServlet1 = new DummyServlet(); private DummyServlet dummyServlet2 = new DummyServlet(); private DummyServlet dummyServlet3 = new DummyServlet(); private DummyServlet dummyServlet4 = new DummyServlet(); public final void testSpiOnElements() { ServletSpiVisitor visitor = new ServletSpiVisitor(false); int count = 0; for(Element element : Elements.getElements(new Module())) { if(element instanceof Binding) { assertEquals(count++, ((Binding)element).acceptTargetVisitor(visitor)); } } validateVisitor(visitor); } public final void testSpiOnInjector() { ServletSpiVisitor visitor = new ServletSpiVisitor(true); int count = 0; Injector injector = Guice.createInjector(new Module()); for(Binding binding : injector.getBindings().values()) { assertEquals(count++, binding.acceptTargetVisitor(visitor)); } validateVisitor(visitor); } private void validateVisitor(ServletSpiVisitor visitor) { assertEquals(48, visitor.currentCount - visitor.otherCount); // This is the expected param list, in order.. List expected = ImmutableList.of( new Params("/class", Key.get(DummyFilterImpl.class), ImmutableMap.of(), SERVLET), new Params("/class/2", Key.get(DummyFilterImpl.class), ImmutableMap.of(), SERVLET), new Params("/key", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of(), SERVLET), new Params("/key/2", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of(), SERVLET), new Params("/instance", dummyFilter1, ImmutableMap.of(), SERVLET), new Params("/instance/2", dummyFilter1, ImmutableMap.of(), SERVLET), new Params("/class/keyvalues", Key.get(DummyFilterImpl.class), ImmutableMap.of("key", "value"), SERVLET), new Params("/class/keyvalues/2", Key.get(DummyFilterImpl.class), ImmutableMap.of("key", "value"), SERVLET), new Params("/key/keyvalues", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of("key", "value"), SERVLET), new Params("/key/keyvalues/2", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of("key", "value"), SERVLET), new Params("/instance/keyvalues", dummyFilter2, ImmutableMap.of("key", "value"), SERVLET), new Params("/instance/keyvalues/2", dummyFilter2, ImmutableMap.of("key", "value"), SERVLET), new Params("/class[0-9]", Key.get(DummyFilterImpl.class), ImmutableMap.of(), REGEX), new Params("/class[0-9]/2", Key.get(DummyFilterImpl.class), ImmutableMap.of(), REGEX), new Params("/key[0-9]", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of(), REGEX), new Params("/key[0-9]/2", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of(), REGEX), new Params("/instance[0-9]", dummyFilter3, ImmutableMap.of(), REGEX), new Params("/instance[0-9]/2", dummyFilter3, ImmutableMap.of(), REGEX), new Params("/class[0-9]/keyvalues", Key.get(DummyFilterImpl.class), ImmutableMap.of("key", "value"), REGEX), new Params("/class[0-9]/keyvalues/2", Key.get(DummyFilterImpl.class), ImmutableMap.of("key", "value"), REGEX), new Params("/key[0-9]/keyvalues", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of("key", "value"), REGEX), new Params("/key[0-9]/keyvalues/2", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of("key", "value"), REGEX), new Params("/instance[0-9]/keyvalues", dummyFilter4, ImmutableMap.of("key", "value"), REGEX), new Params("/instance[0-9]/keyvalues/2", dummyFilter4, ImmutableMap.of("key", "value"), REGEX), new Params("/class", Key.get(DummyServlet.class), ImmutableMap.of(), SERVLET), new Params("/class/2", Key.get(DummyServlet.class), ImmutableMap.of(), SERVLET), new Params("/key", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of(), SERVLET), new Params("/key/2", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of(), SERVLET), new Params("/instance", dummyServlet1, ImmutableMap.of(), SERVLET), new Params("/instance/2", dummyServlet1, ImmutableMap.of(), SERVLET), new Params("/class/keyvalues", Key.get(DummyServlet.class), ImmutableMap.of("key", "value"), SERVLET), new Params("/class/keyvalues/2", Key.get(DummyServlet.class), ImmutableMap.of("key", "value"), SERVLET), new Params("/key/keyvalues", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of("key", "value"), SERVLET), new Params("/key/keyvalues/2", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of("key", "value"), SERVLET), new Params("/instance/keyvalues", dummyServlet2, ImmutableMap.of("key", "value"), SERVLET), new Params("/instance/keyvalues/2", dummyServlet2, ImmutableMap.of("key", "value"), SERVLET), new Params("/class[0-9]", Key.get(DummyServlet.class), ImmutableMap.of(), REGEX), new Params("/class[0-9]/2", Key.get(DummyServlet.class), ImmutableMap.of(), REGEX), new Params("/key[0-9]", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of(), REGEX), new Params("/key[0-9]/2", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of(), REGEX), new Params("/instance[0-9]", dummyServlet3, ImmutableMap.of(), REGEX), new Params("/instance[0-9]/2", dummyServlet3, ImmutableMap.of(), REGEX), new Params("/class[0-9]/keyvalues", Key.get(DummyServlet.class), ImmutableMap.of("key", "value"), REGEX), new Params("/class[0-9]/keyvalues/2", Key.get(DummyServlet.class), ImmutableMap.of("key", "value"), REGEX), new Params("/key[0-9]/keyvalues", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of("key", "value"), REGEX), new Params("/key[0-9]/keyvalues/2", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of("key", "value"), REGEX), new Params("/instance[0-9]/keyvalues", dummyServlet4, ImmutableMap.of("key", "value"), REGEX), new Params("/instance[0-9]/keyvalues/2", dummyServlet4, ImmutableMap.of("key", "value"), REGEX) ); assertEquals(expected.size(), visitor.actual.size()); Iterator actualIterator = visitor.actual.iterator(); int i = 0; for(Params param : expected) { assertEquals("wrong " + i++ + "th param", param, actualIterator.next()); } } private class Module extends ServletModule { @Override protected void configureServlets() { binder().requireExplicitBindings(); filter("/class", "/class/2").through(DummyFilterImpl.class); filter("/key", "/key/2").through( Key.get(DummyFilterImpl.class, Names.named("foo"))); filter("/instance", "/instance/2").through(dummyFilter1); filter("/class/keyvalues", "/class/keyvalues/2").through( DummyFilterImpl.class, ImmutableMap.of("key", "value")); filter("/key/keyvalues", "/key/keyvalues/2").through( Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of("key", "value")); filter("/instance/keyvalues", "/instance/keyvalues/2").through( dummyFilter2, ImmutableMap.of("key", "value")); filterRegex("/class[0-9]", "/class[0-9]/2").through(DummyFilterImpl.class); filterRegex("/key[0-9]", "/key[0-9]/2").through( Key.get(DummyFilterImpl.class, Names.named("foo"))); filterRegex("/instance[0-9]", "/instance[0-9]/2").through(dummyFilter3); filterRegex("/class[0-9]/keyvalues", "/class[0-9]/keyvalues/2").through( DummyFilterImpl.class, ImmutableMap.of("key", "value")); filterRegex("/key[0-9]/keyvalues", "/key[0-9]/keyvalues/2").through( Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of("key", "value")); filterRegex("/instance[0-9]/keyvalues", "/instance[0-9]/keyvalues/2").through( dummyFilter4, ImmutableMap.of("key", "value")); serve("/class", "/class/2").with(DummyServlet.class); serve("/key", "/key/2").with( Key.get(DummyServlet.class, Names.named("foo"))); serve("/instance", "/instance/2").with(dummyServlet1); serve("/class/keyvalues", "/class/keyvalues/2").with( DummyServlet.class, ImmutableMap.of("key", "value")); serve("/key/keyvalues", "/key/keyvalues/2").with( Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of("key", "value")); serve("/instance/keyvalues", "/instance/keyvalues/2").with( dummyServlet2, ImmutableMap.of("key", "value")); serveRegex("/class[0-9]", "/class[0-9]/2").with(DummyServlet.class); serveRegex("/key[0-9]", "/key[0-9]/2").with( Key.get(DummyServlet.class, Names.named("foo"))); serveRegex("/instance[0-9]", "/instance[0-9]/2").with(dummyServlet3); serveRegex("/class[0-9]/keyvalues", "/class[0-9]/keyvalues/2").with( DummyServlet.class, ImmutableMap.of("key", "value")); serveRegex("/key[0-9]/keyvalues", "/key[0-9]/keyvalues/2").with( Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of("key", "value")); serveRegex("/instance[0-9]/keyvalues", "/instance[0-9]/keyvalues/2").with( dummyServlet4, ImmutableMap.of("key", "value")); } } } sisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/EdslTest.java0000644000175000017500000000727311704661106030651 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Singleton; import com.google.inject.Stage; import junit.framework.TestCase; import java.util.HashMap; /** * Sanity checks the EDSL and resultant bound module(s). * * @author Dhanji R. Prasanna (dhanji gmail com) */ public class EdslTest extends TestCase { public final void testExplicitBindingsWorksWithGuiceServlet() { Injector injector = Guice.createInjector( new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); } }, new ServletModule() { @Override protected void configureServlets() { bind(DummyServlet.class).in(Singleton.class); serve("/*").with(DummyServlet.class); } }); assertNotNull(injector.getInstance(DummyServlet.class)); } public final void testConfigureServlets() { //the various possible config calls-- Module webModule = new ServletModule() { @Override protected void configureServlets() { filter("/*").through(DummyFilterImpl.class); filter("*.html").through(DummyFilterImpl.class); filter("/*").through(Key.get(DummyFilterImpl.class)); filter("/*").through(new DummyFilterImpl()); filter("*.html").through(DummyFilterImpl.class, new HashMap()); filterRegex("/person/[0-9]*").through(DummyFilterImpl.class); filterRegex("/person/[0-9]*").through(DummyFilterImpl.class, new HashMap()); filterRegex("/person/[0-9]*").through(Key.get(DummyFilterImpl.class)); filterRegex("/person/[0-9]*").through(Key.get(DummyFilterImpl.class), new HashMap()); filterRegex("/person/[0-9]*").through(new DummyFilterImpl()); filterRegex("/person/[0-9]*").through(new DummyFilterImpl(), new HashMap()); serve("/1/*").with(DummyServlet.class); serve("/2/*").with(Key.get(DummyServlet.class)); serve("/3/*").with(new DummyServlet()); serve("/4/*").with(DummyServlet.class, new HashMap()); serve("*.htm").with(Key.get(DummyServlet.class)); serve("*.html").with(Key.get(DummyServlet.class), new HashMap()); serveRegex("/person/[0-8]*").with(DummyServlet.class); serveRegex("/person/[0-9]*").with(DummyServlet.class, new HashMap()); serveRegex("/person/[0-6]*").with(Key.get(DummyServlet.class)); serveRegex("/person/[0-9]/2/*").with(Key.get(DummyServlet.class), new HashMap()); serveRegex("/person/[0-5]*").with(new DummyServlet()); serveRegex("/person/[0-9]/3/*").with(new DummyServlet(), new HashMap()); } }; //verify that it doesn't blow up! Guice.createInjector(Stage.TOOL, webModule); } } sisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/DummyServlet.java0000644000175000017500000000155111704661106031553 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.inject.Singleton; import javax.servlet.http.HttpServlet; /** * Used in unit tests to verify the EDSL. * * @author Dhanji R. Prasanna (dhanji@gmail com) */ @Singleton public class DummyServlet extends HttpServlet { } sisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/DummyFilterImpl.java0000644000175000017500000000257411704661106032204 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; /** * Used in unit tests to verify the EDSL. * * @author Dhanji R. Prasanna (dhanji@gmail com) */ public class DummyFilterImpl implements Filter { int num; public DummyFilterImpl() { } public DummyFilterImpl(int num) { this.num = num; } public void init(FilterConfig filterConfig) throws ServletException { } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { } public void destroy() { } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ContinuingRequestIntegrationTest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ContinuingRequestInteg0000644000175000017500000001562111704661106032653 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.Singleton; import junit.framework.TestCase; import java.io.IOException; import java.util.List; import java.util.concurrent.AbstractExecutorService; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Tests continuation of requests */ public class ContinuingRequestIntegrationTest extends TestCase { private static final String PARAM_VALUE = "there"; private static final String PARAM_NAME = "hi"; private final AtomicBoolean failed = new AtomicBoolean(false); private final AbstractExecutorService sameThreadExecutor = new AbstractExecutorService() { public void shutdown() { } public List shutdownNow() { return ImmutableList.of(); } public boolean isShutdown() { return true; } public boolean isTerminated() { return true; } public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { return true; } public void execute(Runnable command) { command.run(); } @Override public Future submit(Callable task) { try { task.call(); fail(); } catch (Exception e) { // Expected. assertTrue(e instanceof IllegalStateException); failed.set(true); } return null; } }; private ExecutorService executor; private Injector injector; @Override protected void tearDown() throws Exception { injector.getInstance(GuiceFilter.class).destroy(); } public final void testRequestContinuesInOtherThread() throws ServletException, IOException, InterruptedException { executor = Executors.newSingleThreadExecutor(); injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { serve("/*").with(ContinuingServlet.class); bind(ExecutorService.class).toInstance(executor); } }); FilterConfig filterConfig = createMock(FilterConfig.class); expect(filterConfig.getServletContext()).andReturn(createMock(ServletContext.class)); GuiceFilter guiceFilter = injector.getInstance(GuiceFilter.class); HttpServletRequest request = createMock(HttpServletRequest.class); expect(request.getRequestURI()).andReturn("/"); expect(request.getContextPath()) .andReturn("") .anyTimes(); expect(request.getMethod()).andReturn("GET"); FilterChain filterChain = createMock(FilterChain.class); expect(request.getParameter(PARAM_NAME)).andReturn(PARAM_VALUE); replay(request, filterConfig, filterChain); guiceFilter.init(filterConfig); guiceFilter.doFilter(request, null, filterChain); // join. executor.shutdown(); executor.awaitTermination(10, TimeUnit.SECONDS); assertEquals(PARAM_VALUE, injector.getInstance(OffRequestCallable.class).value); verify(request, filterConfig, filterChain); } public final void testRequestContinuationDiesInHttpRequestThread() throws ServletException, IOException, InterruptedException { executor = sameThreadExecutor; injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { serve("/*").with(ContinuingServlet.class); bind(ExecutorService.class).toInstance(executor); bind(SomeObject.class); } }); FilterConfig filterConfig = createMock(FilterConfig.class); expect(filterConfig.getServletContext()).andReturn(createMock(ServletContext.class)); GuiceFilter guiceFilter = injector.getInstance(GuiceFilter.class); HttpServletRequest request = createMock(HttpServletRequest.class); expect(request.getRequestURI()).andReturn("/"); expect(request.getContextPath()) .andReturn("") .anyTimes(); expect(request.getMethod()).andReturn("GET"); FilterChain filterChain = createMock(FilterChain.class); replay(request, filterConfig, filterChain); guiceFilter.init(filterConfig); guiceFilter.doFilter(request, null, filterChain); // join. executor.shutdown(); executor.awaitTermination(10, TimeUnit.SECONDS); assertTrue(failed.get()); assertFalse(PARAM_VALUE.equals(injector.getInstance(OffRequestCallable.class).value)); verify(request, filterConfig, filterChain); } @RequestScoped public static class SomeObject { } @Singleton public static class ContinuingServlet extends HttpServlet { @Inject OffRequestCallable callable; @Inject ExecutorService executorService; private SomeObject someObject; @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { assertNull(someObject); // Seed with someobject. someObject = new SomeObject(); Callable task = ServletScopes.continueRequest(callable, ImmutableMap., Object>of(Key.get(SomeObject.class), someObject)); executorService.submit(task); } } @Singleton public static class OffRequestCallable implements Callable { @Inject Provider request; @Inject Provider response; @Inject Provider someObject; public String value; public String call() throws Exception { assertNull(response.get()); // Inside this request, we should always get the same instance. assertSame(someObject.get(), someObject.get()); return value = request.get().getParameter(PARAM_NAME); } } } sisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/ContextPathTest.java0000644000175000017500000002427111704661106032220 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static org.easymock.EasyMock.createControl; import static org.easymock.EasyMock.expect; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Scopes; import com.google.inject.name.Named; import com.google.inject.name.Names; import junit.framework.TestCase; import org.easymock.IMocksControl; import java.io.IOException; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** Tests to make sure that servlets with a context path are handled right. */ public class ContextPathTest extends TestCase { @Inject @Named("foo") private TestServlet fooServlet; @Inject @Named("bar") private TestServlet barServlet; private IMocksControl globalControl; private Injector injector; private ServletContext servletContext; private FilterConfig filterConfig; private GuiceFilter guiceFilter; @Override public final void setUp() throws Exception { injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { bind(TestServlet.class).annotatedWith(Names.named("foo")) .to(TestServlet.class).in(Scopes.SINGLETON); bind(TestServlet.class).annotatedWith(Names.named("bar")) .to(TestServlet.class).in(Scopes.SINGLETON); serve("/foo/*").with(Key.get(TestServlet.class, Names.named("foo"))); serve("/bar/*").with(Key.get(TestServlet.class, Names.named("bar"))); // TODO: add a filter(..) call and validate it is correct } }); injector.injectMembers(this); assertNotNull(fooServlet); assertNotNull(barServlet); assertNotSame(fooServlet, barServlet); globalControl = createControl(); servletContext = globalControl.createMock(ServletContext.class); filterConfig = globalControl.createMock(FilterConfig.class); expect(servletContext.getAttribute(GuiceServletContextListener.INJECTOR_NAME)) .andReturn(injector).anyTimes(); expect(filterConfig.getServletContext()).andReturn(servletContext).anyTimes(); globalControl.replay(); guiceFilter = new GuiceFilter(); guiceFilter.init(filterConfig); } @Override public final void tearDown() { assertNotNull(fooServlet); assertNotNull(barServlet); fooServlet = null; barServlet = null; guiceFilter.destroy(); guiceFilter = null; injector = null; filterConfig = null; servletContext = null; globalControl.verify(); } public void testSimple() throws Exception { IMocksControl testControl = createControl(); TestFilterChain testFilterChain = new TestFilterChain(); HttpServletRequest req = testControl.createMock(HttpServletRequest.class); HttpServletResponse res = testControl.createMock(HttpServletResponse.class); expect(req.getMethod()).andReturn("GET").anyTimes(); expect(req.getRequestURI()).andReturn("/bar/foo").anyTimes(); expect(req.getServletPath()).andReturn("/bar/foo").anyTimes(); expect(req.getContextPath()).andReturn("").anyTimes(); testControl.replay(); guiceFilter.doFilter(req, res, testFilterChain); assertFalse(testFilterChain.isTriggered()); assertFalse(fooServlet.isTriggered()); assertTrue(barServlet.isTriggered()); testControl.verify(); } // // each of the following "runTest" calls takes three path parameters: // // The value of "getRequestURI()" // The value of "getServletPath()" // The value of "getContextPath()" // // these values have been captured using a filter in Apache Tomcat 6.0.32 // and are used for real-world values that a servlet container would send into // the GuiceFilter. // // the remaining three booleans are: // // True if the request gets passed down the filter chain // True if the request hits the "foo" servlet // True if the request hits the "bar" sevlet // // After adjusting the request URI for the web app deployment location, all // calls // should always produce the same result. // // ROOT Web app, using Tomcat default servlet public void testRootDefault() throws Exception { // fetching /. Should go up the filter chain (only mappings on /foo/* and /bar/*). runTest("/", "/", "", true, false, false); // fetching /bar/. Should hit the bar servlet runTest("/bar/", "/bar/", "", false, false, true); // fetching /foo/xxx. Should hit the foo servlet runTest("/foo/xxx", "/foo/xxx", "", false, true, false); // fetching /xxx. Should go up the chain runTest("/xxx", "/xxx", "", true, false, false); } // ROOT Web app, using explicit backing servlet mounted at /* public void testRootExplicit() throws Exception { // fetching /. Should go up the filter chain (only mappings on /foo/* and /bar/*). runTest("/", "", "", true, false, false); // fetching /bar/. Should hit the bar servlet runTest("/bar/", "", "", false, false, true); // fetching /foo/xxx. Should hit the foo servlet runTest("/foo/xxx", "", "", false, true, false); // fetching /xxx. Should go up the chain runTest("/xxx", "", "", true, false, false); } // ROOT Web app, using two backing servlets, mounted at /bar/* and /foo/* public void testRootSpecific() throws Exception { // fetching /. Should go up the filter chain (only mappings on /foo/* and /bar/*). runTest("/", "/", "", true, false, false); // fetching /bar/. Should hit the bar servlet runTest("/bar/", "/bar", "", false, false, true); // fetching /foo/xxx. Should hit the foo servlet runTest("/foo/xxx", "/foo", "", false, true, false); // fetching /xxx. Should go up the chain runTest("/xxx", "/xxx", "", true, false, false); } // Web app located at /webtest, using Tomcat default servlet public void testWebtestDefault() throws Exception { // fetching /. Should go up the filter chain (only mappings on /foo/* and /bar/*). runTest("/webtest/", "/", "/webtest", true, false, false); // fetching /bar/. Should hit the bar servlet runTest("/webtest/bar/", "/bar/", "/webtest", false, false, true); // fetching /foo/xxx. Should hit the foo servlet runTest("/webtest/foo/xxx", "/foo/xxx", "/webtest", false, true, false); // fetching /xxx. Should go up the chain runTest("/webtest/xxx", "/xxx", "/webtest", true, false, false); } // Web app located at /webtest, using explicit backing servlet mounted at /* public void testWebtestExplicit() throws Exception { // fetching /. Should go up the filter chain (only mappings on /foo/* and /bar/*). runTest("/webtest/", "", "/webtest", true, false, false); // fetching /bar/. Should hit the bar servlet runTest("/webtest/bar/", "", "/webtest", false, false, true); // fetching /foo/xxx. Should hit the foo servlet runTest("/webtest/foo/xxx", "", "/webtest", false, true, false); // fetching /xxx. Should go up the chain runTest("/webtest/xxx", "", "/webtest", true, false, false); } // Web app located at /webtest, using two backing servlets, mounted at /bar/* // and /foo/* public void testWebtestSpecific() throws Exception { // fetching /. Should go up the filter chain (only mappings on /foo/* and // /bar/*). runTest("/webtest/", "/", "/webtest", true, false, false); // fetching /bar/. Should hit the bar servlet runTest("/webtest/bar/", "/bar", "/webtest", false, false, true); // fetching /foo/xxx. Should hit the foo servlet runTest("/webtest/foo/xxx", "/foo", "/webtest", false, true, false); // fetching /xxx. Should go up the chain runTest("/webtest/xxx", "/xxx", "/webtest", true, false, false); } private void runTest(final String requestURI, final String servletPath, final String contextPath, final boolean filterResult, final boolean fooResult, final boolean barResult) throws Exception { IMocksControl testControl = createControl(); barServlet.clear(); fooServlet.clear(); TestFilterChain testFilterChain = new TestFilterChain(); HttpServletRequest req = testControl.createMock(HttpServletRequest.class); HttpServletResponse res = testControl.createMock(HttpServletResponse.class); expect(req.getMethod()).andReturn("GET").anyTimes(); expect(req.getRequestURI()).andReturn(requestURI).anyTimes(); expect(req.getServletPath()).andReturn(servletPath).anyTimes(); expect(req.getContextPath()).andReturn(contextPath).anyTimes(); testControl.replay(); guiceFilter.doFilter(req, res, testFilterChain); assertEquals(filterResult, testFilterChain.isTriggered()); assertEquals(fooResult, fooServlet.isTriggered()); assertEquals(barResult, barServlet.isTriggered()); testControl.verify(); } public static class TestServlet extends HttpServlet { private boolean triggered = false; @Override public void doGet(HttpServletRequest req, HttpServletResponse resp) { triggered = true; } public boolean isTriggered() { return triggered; } public void clear() { triggered = false; } } public static class TestFilterChain implements FilterChain { private boolean triggered = false; public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException { triggered = true; } public boolean isTriggered() { return triggered; } public void clear() { triggered = false; } } } sisu-guice-sisu-guice-3.1.1/extensions/servlet/test/com/google/inject/servlet/AllTests.java0000644000175000017500000000352311704661106030647 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import junit.framework.Test; import junit.framework.TestSuite; /** * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public class AllTests { public static Test suite() { TestSuite suite = new TestSuite(); // Filter tests. suite.addTestSuite(EdslTest.class); suite.addTestSuite(FilterDefinitionTest.class); suite.addTestSuite(FilterDispatchIntegrationTest.class); suite.addTestSuite(FilterPipelineTest.class); // Servlet + integration tests. suite.addTestSuite(ServletModuleTest.class); suite.addTestSuite(ServletTest.class); suite.addTestSuite(ServletDefinitionTest.class); suite.addTestSuite(ServletDefinitionPathsTest.class); suite.addTestSuite(ServletPipelineRequestDispatcherTest.class); suite.addTestSuite(ServletDispatchIntegrationTest.class); suite.addTestSuite(InvalidScopeBindingTest.class); // Varargs URL mapping tests. suite.addTestSuite(VarargsFilterDispatchIntegrationTest.class); suite.addTestSuite(VarargsServletDispatchIntegrationTest.class); // Multiple modules tests. suite.addTestSuite(MultiModuleDispatchIntegrationTest.class); // Extension SPI tests. suite.addTestSuite(ExtensionSpiTest.class); return suite; } } sisu-guice-sisu-guice-3.1.1/extensions/servlet/src/0000755000175000017500000000000011704661106021064 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/0000755000175000017500000000000011704661106021642 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/0000755000175000017500000000000011704661106023116 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/0000755000175000017500000000000011704661106024372 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/0000755000175000017500000000000011704661106026056 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/package-info.java0000644000175000017500000000174511704661106031254 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Servlet API scopes, bindings and registration; this extension requires {@code * guice-servlet-3.0.jar}. * *

    Apply {@link com.google.inject.servlet.GuiceFilter} to any servlets which will use the servlet * scopes. Install {@link com.google.inject.servlet.ServletModule} into your {@link * com.google.inject.Injector} to install everything at once. */ package com.google.inject.servlet;sisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/UriPatternType.java0000755000175000017500000000745411704661106031675 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * An enumeration of the available URI-pattern matching styles * * @since 3.0 */ public enum UriPatternType { SERVLET, REGEX; static UriPatternMatcher get(UriPatternType type, String pattern) { switch (type) { case SERVLET: return new ServletStyleUriPatternMatcher(pattern); case REGEX: return new RegexUriPatternMatcher(pattern); default: return null; } } /** * Matches URIs using the pattern grammar of the Servlet API and web.xml. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ private static class ServletStyleUriPatternMatcher implements UriPatternMatcher { private final String pattern; private final Kind patternKind; private static enum Kind { PREFIX, SUFFIX, LITERAL, } public ServletStyleUriPatternMatcher(String pattern) { if (pattern.startsWith("*")) { this.pattern = pattern.substring(1); this.patternKind = Kind.PREFIX; } else if (pattern.endsWith("*")) { this.pattern = pattern.substring(0, pattern.length() - 1); this.patternKind = Kind.SUFFIX; } else { this.pattern = pattern; this.patternKind = Kind.LITERAL; } } public boolean matches(String uri) { if (null == uri) { return false; } if (patternKind == Kind.PREFIX) { return uri.endsWith(pattern); } else if (patternKind == Kind.SUFFIX) { return uri.startsWith(pattern); } //else treat as a literal return pattern.equals(uri); } public String extractPath(String path) { if (patternKind == Kind.PREFIX) { return null; } else if (patternKind == Kind.SUFFIX) { String extract = pattern; //trim the trailing '/' if (extract.endsWith("/")) { extract = extract.substring(0, extract.length() - 1); } return extract; } //else treat as literal return path; } public UriPatternType getPatternType() { return UriPatternType.SERVLET; } } /** * Matches URIs using a regular expression. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ private static class RegexUriPatternMatcher implements UriPatternMatcher { private final Pattern pattern; public RegexUriPatternMatcher(String pattern) { this.pattern = Pattern.compile(pattern); } public boolean matches(String uri) { return null != uri && this.pattern.matcher(uri).matches(); } public String extractPath(String path) { Matcher matcher = pattern.matcher(path); if (matcher.matches() && matcher.groupCount() >= 1) { // Try to capture the everything before the regex begins to match // the path. This is a rough approximation to try and get parity // with the servlet style mapping where the path is a capture of // the URI before the wildcard. int end = matcher.start(1); if (end < path.length()) { return path.substring(0, end); } } return null; } public UriPatternType getPatternType() { return UriPatternType.REGEX; } } } sisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/UriPatternMatcher.java0000755000175000017500000000314111704661106032324 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; /** * A general interface for matching a URI against a URI pattern. Guice-servlet provides regex and * servlet-style pattern matching out of the box. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ interface UriPatternMatcher { /** * @param uri A "contextual" (i.e. relative) Request URI, *not* a complete one. * @return Returns true if the uri matches the pattern. */ boolean matches(String uri); /** * @param pattern The Path that this service pattern can match against. * @return Returns a canonical servlet path from this pattern. For instance, if the pattern is * {@code /home/*} then the path extracted will be {@code /home}. Each pattern matcher * implementation must decide and publish what a canonical path represents. * * NOTE(dhanji): This method returns null for the regex pattern matcher. */ String extractPath(String pattern); /** Returns the type of pattern this is. */ UriPatternType getPatternType(); } sisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/SessionScoped.java0000644000175000017500000000217711704661106031511 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.inject.ScopeAnnotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Apply this to implementation classes when you want one instance per session. * * @see com.google.inject.Scopes#SINGLETON * @author crazybob@google.com (Bob Lee) */ @Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RetentionPolicy.RUNTIME) @ScopeAnnotation public @interface SessionScoped {} ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ServletsModuleBuilder.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ServletsModuleBuilder.j0000755000175000017500000000733111704661106032524 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.common.collect.Sets; import com.google.inject.Binder; import com.google.inject.Key; import com.google.inject.internal.UniqueAnnotations; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import javax.servlet.http.HttpServlet; /** * Builds the guice module that binds configured servlets, with their * wrapper ServletDefinitions. Is part of the binding EDSL. Very similar to * {@link com.google.inject.servlet.FiltersModuleBuilder}. * * @author Dhanji R. Prasanna (dhanji@gmail.com) */ class ServletsModuleBuilder { private final Set servletUris = Sets.newHashSet(); private final Binder binder; public ServletsModuleBuilder(Binder binder) { this.binder = binder; } //the first level of the EDSL-- public ServletModule.ServletKeyBindingBuilder serve(List urlPatterns) { return new ServletKeyBindingBuilderImpl(urlPatterns, UriPatternType.SERVLET); } public ServletModule.ServletKeyBindingBuilder serveRegex(List regexes) { return new ServletKeyBindingBuilderImpl(regexes, UriPatternType.REGEX); } //non-static inner class so it can access state of enclosing module class class ServletKeyBindingBuilderImpl implements ServletModule.ServletKeyBindingBuilder { private final List uriPatterns; private final UriPatternType uriPatternType; private ServletKeyBindingBuilderImpl(List uriPatterns, UriPatternType uriPatternType) { this.uriPatterns = uriPatterns; this.uriPatternType = uriPatternType; } public void with(Class servletKey) { with(Key.get(servletKey)); } public void with(Key servletKey) { with(servletKey, new HashMap()); } public void with(HttpServlet servlet) { with(servlet, new HashMap()); } public void with(Class servletKey, Map initParams) { with(Key.get(servletKey), initParams); } public void with(Key servletKey, Map initParams) { with(servletKey, initParams, null); } private void with(Key servletKey, Map initParams, HttpServlet servletInstance) { for (String pattern : uriPatterns) { // Ensure two servlets aren't bound to the same pattern. if (!servletUris.add(pattern)) { binder.addError("More than one servlet was mapped to the same URI pattern: " + pattern); } else { binder.bind(Key.get(ServletDefinition.class, UniqueAnnotations.create())).toProvider( new ServletDefinition(pattern, servletKey, UriPatternType .get(uriPatternType, pattern), initParams, servletInstance)); } } } public void with(HttpServlet servlet, Map initParams) { Key servletKey = Key.get(HttpServlet.class, UniqueAnnotations.create()); binder.bind(servletKey).toInstance(servlet); with(servletKey, initParams, servlet); } } } sisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ServletScopes.java0000644000175000017500000003174311704661106031532 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import com.google.inject.Binding; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.OutOfScopeException; import com.google.inject.Provider; import com.google.inject.Scope; import com.google.inject.Scopes; import com.google.inject.internal.LinkedBindingImpl; import com.google.inject.spi.BindingScopingVisitor; import com.google.inject.spi.ExposedBinding; import java.lang.annotation.Annotation; import java.util.Map; import java.util.concurrent.Callable; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * Servlet scopes. * * @author crazybob@google.com (Bob Lee) */ public class ServletScopes { private ServletScopes() {} /** Keys bound in request-scope which are handled directly by GuiceFilter. */ private static final ImmutableSet> REQUEST_CONTEXT_KEYS = ImmutableSet.of( Key.get(HttpServletRequest.class), Key.get(HttpServletResponse.class), new Key>(RequestParameters.class) {}); /** * A threadlocal scope map for non-http request scopes. The {@link #REQUEST} * scope falls back to this scope map if no http request is available, and * requires {@link #scopeRequest} to be called as an alertnative. */ private static final ThreadLocal> requestScopeContext = new ThreadLocal>(); /** A sentinel attribute value representing null. */ enum NullObject { INSTANCE } /** * HTTP servlet request scope. */ public static final Scope REQUEST = new Scope() { public Provider scope(final Key key, final Provider creator) { final String name = key.toString(); return new Provider() { public T get() { // Check if the alternate request scope should be used, if no HTTP // request is in progress. if (null == GuiceFilter.localContext.get()) { // NOTE(dhanji): We don't need to synchronize on the scope map // unlike the HTTP request because we're the only ones who have // a reference to it, and it is only available via a threadlocal. Map scopeMap = requestScopeContext.get(); if (null != scopeMap) { @SuppressWarnings("unchecked") T t = (T) scopeMap.get(name); // Accounts for @Nullable providers. if (NullObject.INSTANCE == t) { return null; } if (t == null) { t = creator.get(); if (!Scopes.isCircularProxy(t)) { // Store a sentinel for provider-given null values. scopeMap.put(name, t != null ? t : NullObject.INSTANCE); } } return t; } // else: fall into normal HTTP request scope and out of scope // exception is thrown. } // Always synchronize and get/set attributes on the underlying request // object since Filters may wrap the request and change the value of // {@code GuiceFilter.getRequest()}. // // This _correctly_ throws up if the thread is out of scope. HttpServletRequest request = GuiceFilter.getOriginalRequest(); if (REQUEST_CONTEXT_KEYS.contains(key)) { // Don't store these keys as attributes, since they are handled by // GuiceFilter itself. return creator.get(); } synchronized (request) { Object obj = request.getAttribute(name); if (NullObject.INSTANCE == obj) { return null; } @SuppressWarnings("unchecked") T t = (T) obj; if (t == null) { t = creator.get(); if (!Scopes.isCircularProxy(t)) { request.setAttribute(name, (t != null) ? t : NullObject.INSTANCE); } } return t; } } @Override public String toString() { return String.format("%s[%s]", creator, REQUEST); } }; } @Override public String toString() { return "ServletScopes.REQUEST"; } }; /** * HTTP session scope. */ public static final Scope SESSION = new Scope() { public Provider scope(Key key, final Provider creator) { final String name = key.toString(); return new Provider() { public T get() { HttpSession session = GuiceFilter.getRequest().getSession(); synchronized (session) { Object obj = session.getAttribute(name); if (NullObject.INSTANCE == obj) { return null; } @SuppressWarnings("unchecked") T t = (T) obj; if (t == null) { t = creator.get(); if (!Scopes.isCircularProxy(t)) { session.setAttribute(name, (t != null) ? t : NullObject.INSTANCE); } } return t; } } @Override public String toString() { return String.format("%s[%s]", creator, SESSION); } }; } @Override public String toString() { return "ServletScopes.SESSION"; } }; /** * Wraps the given callable in a contextual callable that "continues" the * HTTP request in another thread. This acts as a way of transporting * request context data from the request processing thread to to worker * threads. *

    * There are some limitations: *

      *
    • Derived objects (i.e. anything marked @RequestScoped will not be * transported.
    • *
    • State changes to the HttpServletRequest after this method is called * will not be seen in the continued thread.
    • *
    • Only the HttpServletRequest, ServletContext and request parameter * map are available in the continued thread. The response and session * are not available.
    • *
    * * @param callable code to be executed in another thread, which depends on * the request scope. * @param seedMap the initial set of scoped instances for Guice to seed the * request scope with. To seed a key with null, use {@code null} as * the value. * @return a callable that will invoke the given callable, making the request * context available to it. * @throws OutOfScopeException if this method is called from a non-request * thread, or if the request has completed. * * @since 3.0 */ public static Callable continueRequest(final Callable callable, final Map, Object> seedMap) { Preconditions.checkArgument(null != seedMap, "Seed map cannot be null, try passing in Collections.emptyMap() instead."); // Snapshot the seed map and add all the instances to our continuing HTTP request. final ContinuingHttpServletRequest continuingRequest = new ContinuingHttpServletRequest(GuiceFilter.getRequest()); for (Map.Entry, Object> entry : seedMap.entrySet()) { Object value = validateAndCanonicalizeValue(entry.getKey(), entry.getValue()); continuingRequest.setAttribute(entry.getKey().toString(), value); } return new Callable() { private final HttpServletRequest request = continuingRequest; public T call() throws Exception { GuiceFilter.Context context = GuiceFilter.localContext.get(); Preconditions.checkState(null == context, "Cannot continue request in the same thread as a HTTP request!"); // Only set up the request continuation if we're running in a // new vanilla thread. GuiceFilter.localContext.set(new GuiceFilter.Context(request, request, null)); try { return callable.call(); } finally { // Clear the copied context if we set one up. if (null == context) { GuiceFilter.localContext.remove(); } } } }; } /** * Returns true if {@code binding} is request-scoped. If the binding is a * {@link com.google.inject.spi.LinkedKeyBinding linked key binding} and * belongs to an injector (i. e. it was retrieved via * {@link Injector#getBinding Injector.getBinding()}), then this method will * also return true if the target binding is request-scoped. */ public static boolean isRequestScoped(Binding binding) { do { boolean requestScoped = binding.acceptScopingVisitor(new BindingScopingVisitor() { @Override public Boolean visitNoScoping() { return false; } @Override public Boolean visitScopeAnnotation(Class scopeAnnotation) { return scopeAnnotation == RequestScoped.class; } @Override public Boolean visitScope(Scope scope) { return scope == ServletScopes.REQUEST; } @Override public Boolean visitEagerSingleton() { return false; } }); if (requestScoped) { return true; } if (binding instanceof LinkedBindingImpl) { LinkedBindingImpl linkedBinding = (LinkedBindingImpl) binding; Injector injector = linkedBinding.getInjector(); if (injector != null) { binding = injector.getBinding(linkedBinding.getLinkedKey()); continue; } } else if (binding instanceof ExposedBinding) { ExposedBinding exposedBinding = (ExposedBinding) binding; Injector injector = exposedBinding.getPrivateElements().getInjector(); if (injector != null) { binding = injector.getBinding(exposedBinding.getKey()); continue; } } return false; } while (true); } /** * Scopes the given callable inside a request scope. This is not the same * as the HTTP request scope, but is used if no HTTP request scope is in * progress. In this way, keys can be scoped as @RequestScoped and exist * in non-HTTP requests (for example: RPC requests) as well as in HTTP * request threads. * * @param callable code to be executed which depends on the request scope. * Typically in another thread, but not necessarily so. * @param seedMap the initial set of scoped instances for Guice to seed the * request scope with. To seed a key with null, use {@code null} as * the value. * @return a callable that when called will run inside the a request scope * that exposes the instances in the {@code seedMap} as scoped keys. * @since 3.0 */ public static Callable scopeRequest(final Callable callable, Map, Object> seedMap) { Preconditions.checkArgument(null != seedMap, "Seed map cannot be null, try passing in Collections.emptyMap() instead."); // Copy the seed values into our local scope map. final Map scopeMap = Maps.newHashMap(); for (Map.Entry, Object> entry : seedMap.entrySet()) { Object value = validateAndCanonicalizeValue(entry.getKey(), entry.getValue()); scopeMap.put(entry.getKey().toString(), value); } return new Callable() { public T call() throws Exception { Preconditions.checkState(null == GuiceFilter.localContext.get(), "An HTTP request is already in progress, cannot scope a new request in this thread."); Preconditions.checkState(null == requestScopeContext.get(), "A request scope is already in progress, cannot scope a new request in this thread."); requestScopeContext.set(scopeMap); try { return callable.call(); } finally { requestScopeContext.remove(); } } }; } /** * Validates the key and object, ensuring the value matches the key type, and * canonicalizing null objects to the null sentinel. */ private static Object validateAndCanonicalizeValue(Key key, Object object) { if (object == null || object == NullObject.INSTANCE) { return NullObject.INSTANCE; } if (!key.getTypeLiteral().getRawType().isInstance(object)) { throw new IllegalArgumentException("Value[" + object + "] of type[" + object.getClass().getName() + "] is not compatible with key[" + key + "]"); } return object; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ServletModuleTargetVisitor.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ServletModuleTargetVisi0000644000175000017500000000456611704661106032610 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package com.google.inject.servlet; import com.google.inject.servlet.ServletModule.FilterKeyBindingBuilder; import com.google.inject.servlet.ServletModule.ServletKeyBindingBuilder; import com.google.inject.spi.BindingTargetVisitor; import javax.servlet.Filter; import javax.servlet.http.HttpServlet; /** * A visitor for the servlet extension. * * If your {@link BindingTargetVisitor} implements this interface, bindings created by using * {@link ServletModule} will be visited through this interface. * * @since 3.0 * @author sameb@google.com (Sam Berlin) */ public interface ServletModuleTargetVisitor extends BindingTargetVisitor { /** * Visits a filter binding created by {@link ServletModule#filter}, where * {@link FilterKeyBindingBuilder#through} is called with a Class or Key. * * If multiple patterns were specified, this will be called multiple times. */ V visit(LinkedFilterBinding binding); /** * Visits a filter binding created by {@link ServletModule#filter} where * {@link FilterKeyBindingBuilder#through} is called with a {@link Filter}. * * If multiple patterns were specified, this will be called multiple times. */ V visit(InstanceFilterBinding binding); /** * Visits a servlet binding created by {@link ServletModule#serve} where * {@link ServletKeyBindingBuilder#with}, is called with a Class or Key. * * If multiple patterns were specified, this will be called multiple times. */ V visit(LinkedServletBinding binding); /** * Visits a servlet binding created by {@link ServletModule#serve} where * {@link ServletKeyBindingBuilder#with}, is called with an {@link HttpServlet}. * * If multiple patterns were specified, this will be called multiple times. */ V visit(InstanceServletBinding binding); }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ServletModuleBinding.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ServletModuleBinding.ja0000644000175000017500000000230611704661106032460 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import java.util.Map; /** * A binding created by {@link ServletModule}. * * @author sameb@google.com (Sam Berlin) * @since 3.0 */ public interface ServletModuleBinding { /** Returns the pattern type that this binding was created with. */ UriPatternType getUriPatternType(); /** Returns the pattern used to match against the binding. */ String getPattern(); /** Returns any context params supplied when creating the binding. */ Map getInitParams(); /** Returns true if the given URI will match this binding. */ boolean matchesUri(String uri); } sisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ServletModule.java0000644000175000017500000002617411704661106031525 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static com.google.common.base.Preconditions.checkState; import com.google.common.collect.ImmutableList; import com.google.inject.AbstractModule; import com.google.inject.Key; import java.util.Map; import javax.servlet.Filter; import javax.servlet.ServletContext; import javax.servlet.http.HttpServlet; /** * Configures the servlet scopes and creates bindings for the servlet API * objects so you can inject the request, response, session, etc. * *

    * You should subclass this module to register servlets and * filters in the {@link #configureServlets()} method. * * @author crazybob@google.com (Bob Lee) * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public class ServletModule extends AbstractModule { @Override protected final void configure() { checkState(filtersModuleBuilder == null, "Re-entry is not allowed."); checkState(servletsModuleBuilder == null, "Re-entry is not allowed."); filtersModuleBuilder = new FiltersModuleBuilder(binder()); servletsModuleBuilder = new ServletsModuleBuilder(binder()); try { // Install common bindings (skipped if already installed). install(new InternalServletModule()); // Install local filter and servlet bindings. configureServlets(); } finally { filtersModuleBuilder = null; servletsModuleBuilder = null; } } /** *

    Servlet Mapping EDSL

    * *

    Part of the EDSL builder language for configuring servlets * and filters with guice-servlet. Think of this as an in-code replacement for web.xml. * Filters and servlets are configured here using simple java method calls. Here is a typical * example of registering a filter when creating your Guice injector: * *

       *   Guice.createInjector(..., new ServletModule() {
       *
       *     {@literal @}Override
       *     protected void configureServlets() {
       *       serve("*.html").with(MyServlet.class)
       *     }
       *   }
       * 
    * * This registers a servlet (subclass of {@code HttpServlet}) called {@code MyServlet} to service * any web pages ending in {@code .html}. You can also use a path-style syntax to register * servlets: * *
       *       serve("/my/*").with(MyServlet.class)
       * 
    * * Every servlet (or filter) is required to be a singleton. If you cannot annotate the class * directly, you should add a separate {@code bind(..).in(Singleton.class)} rule elsewhere in * your module. Mapping a servlet that is bound under any other scope is an error. * *

    *

    Dispatch Order

    * You are free to register as many servlets and filters as you like this way. They will * be compared and dispatched in the order in which the filter methods are called: * *
       *
       *   Guice.createInjector(..., new ServletModule() {
       *
       *     {@literal @}Override
       *     protected void configureServlets() {
       *       filter("/*").through(MyFilter.class);
       *       filter("*.css").through(MyCssFilter.class);
       *       filter("*.jpg").through(new MyJpgFilter());
       *       // etc..
       *
       *       serve("*.html").with(MyServlet.class);
       *       serve("/my/*").with(MyServlet.class);
       *       serve("*.jpg").with(new MyServlet());
       *       // etc..
       *      }
       *    }
       * 
    * This will traverse down the list of rules in lexical order. For example, a url * "{@code /my/file.js}" (after it runs through the matching filters) will first * be compared against the servlet mapping: * *
       *       serve("*.html").with(MyServlet.class);
       * 
    * And failing that, it will descend to the next servlet mapping: * *
       *       serve("/my/*").with(MyServlet.class);
       * 
    * * Since this rule matches, Guice Servlet will dispatch to {@code MyServlet}. These * two mapping rules can also be written in more compact form using varargs syntax: * *
       *       serve("*.html", "/my/*").with(MyServlet.class);
       * 
    * * This way you can map several URI patterns to the same servlet. A similar syntax is * also available for filter mappings. * *

    *

    Regular Expressions

    * You can also map servlets (or filters) to URIs using regular expressions: *
       *    serveRegex("(.)*ajax(.)*").with(MyAjaxServlet.class)
       * 
    * * This will map any URI containing the text "ajax" in it to {@code MyAjaxServlet}. Such as: *
      *
    • http://www.google.com/ajax.html
    • *
    • http://www.google.com/content/ajax/index
    • *
    • http://www.google.com/it/is_totally_ajaxian
    • *
    * * *

    Initialization Parameters

    * * Servlets (and filters) allow you to pass in init params * using the {@code } tag in web.xml. You can similarly pass in parameters to * Servlets and filters registered in Guice-servlet using a {@link java.util.Map} of parameter * name/value pairs. For example, to initialize {@code MyServlet} with two parameters * ({@code name="Dhanji", site="google.com"}) you could write: * *
       *  Map<String, String> params = new HashMap<String, String>();
       *  params.put("name", "Dhanji");
       *  params.put("site", "google.com");
       *
       *  ...
       *      serve("/*").with(MyServlet.class, params)
       * 
    * *

    *

    Binding Keys

    * * You can also bind keys rather than classes. This lets you hide * implementations with package-local visbility and expose them using * only a Guice module and an annotation: * *
       *  ...
       *      filter("/*").through(Key.get(Filter.class, Fave.class));
       * 
    * * Where {@code Filter.class} refers to the Servlet API interface and {@code Fave.class} is a * custom binding annotation. Elsewhere (in one of your own modules) you can bind this * filter's implementation: * *
       *   bind(Filter.class).annotatedWith(Fave.class).to(MyFilterImpl.class);
       * 
    * * See {@link com.google.inject.Binder} for more information on binding syntax. * *

    *

    Multiple Modules

    * * It is sometimes useful to capture servlet and filter mappings from multiple different * modules. This is essential if you want to package and offer drop-in Guice plugins that * provide servlet functionality. * *

    * Guice Servlet allows you to register several instances of {@code ServletModule} to your * injector. The order in which these modules are installed determines the dispatch order * of filters and the precedence order of servlets. For example, if you had two servlet modules, * {@code RpcModule} and {@code WebServiceModule} and they each contained a filter that mapped * to the same URI pattern, {@code "/*"}: * *

    * In {@code RpcModule}: *

       *     filter("/*").through(RpcFilter.class);
       * 
    * * In {@code WebServiceModule}: *
       *     filter("/*").through(WebServiceFilter.class);
       * 
    * * Then the order in which these filters are dispatched is determined by the order in which * the modules are installed: * *
       *   install(new WebServiceModule());
       *   install(new RpcModule());
       * 
    * * In the case shown above {@code WebServiceFilter} will run first. * * @since 2.0 */ protected void configureServlets() { } private FiltersModuleBuilder filtersModuleBuilder; private ServletsModuleBuilder servletsModuleBuilder; private FiltersModuleBuilder getFiltersModuleBuilder() { checkState(filtersModuleBuilder != null, "This method can only be used inside configureServlets()"); return filtersModuleBuilder; } private ServletsModuleBuilder getServletModuleBuilder() { checkState(servletsModuleBuilder != null, "This method can only be used inside configureServlets()"); return servletsModuleBuilder; } /** * @param urlPattern Any Servlet-style pattern. examples: /*, /html/*, *.html, etc. * @since 2.0 */ protected final FilterKeyBindingBuilder filter(String urlPattern, String... morePatterns) { return getFiltersModuleBuilder() .filter(ImmutableList.builder().add(urlPattern).add(morePatterns).build()); } /** * @param regex Any Java-style regular expression. * @since 2.0 */ protected final FilterKeyBindingBuilder filterRegex(String regex, String... regexes) { return getFiltersModuleBuilder() .filterRegex(ImmutableList.builder().add(regex).add(regexes).build()); } /** * @param urlPattern Any Servlet-style pattern. examples: /*, /html/*, *.html, etc. * @since 2.0 */ protected final ServletKeyBindingBuilder serve(String urlPattern, String... morePatterns) { return getServletModuleBuilder() .serve(ImmutableList.builder().add(urlPattern).add(morePatterns).build()); } /** * @param regex Any Java-style regular expression. * @since 2.0 */ protected final ServletKeyBindingBuilder serveRegex(String regex, String... regexes) { return getServletModuleBuilder() .serveRegex(ImmutableList.builder().add(regex).add(regexes).build()); } /** * This method only works if you are using the {@linkplain GuiceServletContextListener} to * create your injector. Otherwise, it returns null. * @return The current servlet context. * @since 3.0 */ protected final ServletContext getServletContext() { return GuiceFilter.getServletContext(); } /** * See the EDSL examples at {@link ServletModule#configureServlets()} * * @since 2.0 */ public static interface FilterKeyBindingBuilder { void through(Class filterKey); void through(Key filterKey); /** @since 3.0 */ void through(Filter filter); void through(Class filterKey, Map initParams); void through(Key filterKey, Map initParams); /** @since 3.0 */ void through(Filter filter, Map initParams); } /** * See the EDSL examples at {@link ServletModule#configureServlets()} * * @since 2.0 */ public static interface ServletKeyBindingBuilder { void with(Class servletKey); void with(Key servletKey); /** @since 3.0 */ void with(HttpServlet servlet); void with(Class servletKey, Map initParams); void with(Key servletKey, Map initParams); /** @since 3.0 */ void with(HttpServlet servlet, Map initParams); } } sisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ServletDefinition.java0000755000175000017500000002344011704661106032364 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static com.google.inject.servlet.ManagedServletPipeline.REQUEST_DISPATCHER_REQUEST; import com.google.common.collect.Iterators; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Scopes; import com.google.inject.spi.BindingTargetVisitor; import com.google.inject.spi.ProviderInstanceBinding; import com.google.inject.spi.ProviderWithExtensionVisitor; import java.io.IOException; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; /** * An internal representation of a servlet definition mapped to a particular URI pattern. Also * performs the request dispatch to that servlet. How nice and OO =) * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ class ServletDefinition implements ProviderWithExtensionVisitor { private final String pattern; private final Key servletKey; private final UriPatternMatcher patternMatcher; private final Map initParams; // set only if this was bound using a servlet instance. private final HttpServlet servletInstance; //always set in init, our servlet is always presumed to be a singleton private final AtomicReference httpServlet = new AtomicReference(); public ServletDefinition(String pattern, Key servletKey, UriPatternMatcher patternMatcher, Map initParams, HttpServlet servletInstance) { this.pattern = pattern; this.servletKey = servletKey; this.patternMatcher = patternMatcher; this.initParams = Collections.unmodifiableMap(new HashMap(initParams)); this.servletInstance = servletInstance; } public ServletDefinition get() { return this; } public V acceptExtensionVisitor(BindingTargetVisitor visitor, ProviderInstanceBinding binding) { if(visitor instanceof ServletModuleTargetVisitor) { if(servletInstance != null) { return ((ServletModuleTargetVisitor)visitor).visit( new InstanceServletBindingImpl(initParams, pattern, servletInstance, patternMatcher)); } else { return ((ServletModuleTargetVisitor)visitor).visit( new LinkedServletBindingImpl(initParams, pattern, servletKey, patternMatcher)); } } else { return visitor.visit(binding); } } boolean shouldServe(String uri) { return patternMatcher.matches(uri); } public void init(final ServletContext servletContext, Injector injector, Set initializedSoFar) throws ServletException { // This absolutely must be a singleton, and so is only initialized once. if (!Scopes.isSingleton(injector.getBinding(servletKey))) { throw new ServletException("Servlets must be bound as singletons. " + servletKey + " was not bound in singleton scope."); } HttpServlet httpServlet = injector.getInstance(servletKey); this.httpServlet.set(httpServlet); // Only fire init() if we have not appeared before in the filter chain. if (initializedSoFar.contains(httpServlet)) { return; } //initialize our servlet with the configured context params and servlet context httpServlet.init(new ServletConfig() { public String getServletName() { return servletKey.toString(); } public ServletContext getServletContext() { return servletContext; } public String getInitParameter(String s) { return initParams.get(s); } public Enumeration getInitParameterNames() { return Iterators.asEnumeration(initParams.keySet().iterator()); } }); // Mark as initialized. initializedSoFar.add(httpServlet); } public void destroy(Set destroyedSoFar) { HttpServlet reference = httpServlet.get(); // Do nothing if this Servlet was invalid (usually due to not being scoped // properly). According to Servlet Spec: it is "out of service", and does not // need to be destroyed. // Also prevent duplicate destroys to the same singleton that may appear // more than once on the filter chain. if (null == reference || destroyedSoFar.contains(reference)) { return; } try { reference.destroy(); } finally { destroyedSoFar.add(reference); } } /** * Wrapper around the service chain to ensure a servlet is servicing what it must and provides it * with a wrapped request. * * @return Returns true if this servlet triggered for the given request. Or false if * guice-servlet should continue dispatching down the servlet pipeline. * * @throws IOException If thrown by underlying servlet * @throws ServletException If thrown by underlying servlet */ public boolean service(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { final HttpServletRequest request = (HttpServletRequest) servletRequest; final String path = request.getRequestURI().substring(request.getContextPath().length()); final boolean serve = shouldServe(path); //invocations of the chain end at the first matched servlet if (serve) { doService(servletRequest, servletResponse); } //return false if no servlet matched (so we can proceed down to the web.xml servlets) return serve; } /** * Utility that delegates to the actual service method of the servlet wrapped with a contextual * request (i.e. with correctly computed path info). * * We need to suppress deprecation coz we use HttpServletRequestWrapper, which implements * deprecated API for backwards compatibility. */ void doService(final ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException { HttpServletRequest request = new HttpServletRequestWrapper( (HttpServletRequest) servletRequest) { private boolean pathComputed; private String path; private boolean pathInfoComputed; private String pathInfo; @Override public String getPathInfo() { if (!isPathInfoComputed()) { int servletPathLength = getServletPath().length(); pathInfo = getRequestURI().substring(getContextPath().length()) .replaceAll("[/]{2,}", "/"); pathInfo = pathInfo.length() > servletPathLength ? pathInfo.substring(servletPathLength) : null; // Corner case: when servlet path and request path match exactly (without trailing '/'), // then pathinfo is null if ("".equals(pathInfo) && servletPathLength != 0) { pathInfo = null; } pathInfoComputed = true; } return pathInfo; } // NOTE(dhanji): These two are a bit of a hack to help ensure that request dispatcher-sent // requests don't use the same path info that was memoized for the original request. // NOTE(iqshum): I don't think this is possible, since the dispatcher-sent request would // perform its own wrapping. private boolean isPathInfoComputed() { return pathInfoComputed && !(null != servletRequest.getAttribute(REQUEST_DISPATCHER_REQUEST)); } private boolean isPathComputed() { return pathComputed && !(null != servletRequest.getAttribute(REQUEST_DISPATCHER_REQUEST)); } @Override public String getServletPath() { return computePath(); } @Override public String getPathTranslated() { final String info = getPathInfo(); return (null == info) ? null : getRealPath(info); } // Memoizer pattern. private String computePath() { if (!isPathComputed()) { String servletPath = super.getServletPath(); path = patternMatcher.extractPath(servletPath); pathComputed = true; if (null == path) { path = servletPath; } } return path; } }; doServiceImpl(request, (HttpServletResponse) servletResponse); } private void doServiceImpl(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { GuiceFilter.Context previous = GuiceFilter.localContext.get(); HttpServletRequest originalRequest = (previous != null) ? previous.getOriginalRequest() : request; GuiceFilter.localContext.set(new GuiceFilter.Context(originalRequest, request, response)); try { httpServlet.get().service(request, response); } finally { GuiceFilter.localContext.set(previous); } } String getKey() { return servletKey.toString(); } String getPattern() { return pattern; } } sisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ScopingOnly.java0000644000175000017500000000226111704661106031166 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.BindingAnnotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * Annotates a {@link GuiceFilter} that provides scope functionality, but * doesn't dispatch to {@link ServletModule} bound servlets or filters. * * @author iqshum@google.com (Isaac Shum) */ @Retention(RUNTIME) @Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @BindingAnnotation public @interface ScopingOnly {} sisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/RequestScoped.java0000644000175000017500000000212411704661106031506 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.inject.ScopeAnnotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Apply this to implementation classes when you want one instance per request. * * @author crazybob@google.com (Bob Lee) */ @Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RetentionPolicy.RUNTIME) @ScopeAnnotation public @interface RequestScoped {} sisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/RequestParameters.java0000644000175000017500000000225711704661106032403 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.BindingAnnotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * Apply this to field or parameters of type {@code Map} * when you want the HTTP request parameter map to be injected. * * @author crazybob@google.com (Bob Lee) */ @Retention(RUNTIME) @Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @BindingAnnotation public @interface RequestParameters {} ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ManagedServletPipeline.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ManagedServletPipeline.0000755000175000017500000001555111704661106032460 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.inject.Binding; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Singleton; import com.google.inject.TypeLiteral; import java.io.IOException; import java.util.List; import java.util.Set; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; /** * A wrapping dispatcher for servlets, in much the same way as {@link ManagedFilterPipeline} is for * filters. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ @Singleton class ManagedServletPipeline { private final ServletDefinition[] servletDefinitions; private static final TypeLiteral SERVLET_DEFS = TypeLiteral.get(ServletDefinition.class); @Inject public ManagedServletPipeline(Injector injector) { this.servletDefinitions = collectServletDefinitions(injector); } boolean hasServletsMapped() { return servletDefinitions.length > 0; } /** * Introspects the injector and collects all instances of bound {@code List} * into a master list. * * We have a guarantee that {@link com.google.inject.Injector#getBindings()} returns a map * that preserves insertion order in entry-set iterators. */ private ServletDefinition[] collectServletDefinitions(Injector injector) { List servletDefinitions = Lists.newArrayList(); for (Binding entry : injector.findBindingsByType(SERVLET_DEFS)) { servletDefinitions.add(entry.getProvider().get()); } // Copy to a fixed size array for speed. return servletDefinitions.toArray(new ServletDefinition[servletDefinitions.size()]); } public void init(ServletContext servletContext, Injector injector) throws ServletException { Set initializedSoFar = Sets.newSetFromMap(Maps.newIdentityHashMap()); for (ServletDefinition servletDefinition : servletDefinitions) { servletDefinition.init(servletContext, injector, initializedSoFar); } } public boolean service(ServletRequest request, ServletResponse response) throws IOException, ServletException { //stop at the first matching servlet and service for (ServletDefinition servletDefinition : servletDefinitions) { if (servletDefinition.service(request, response)) { return true; } } //there was no match... return false; } public void destroy() { Set destroyedSoFar = Sets.newSetFromMap(Maps.newIdentityHashMap()); for (ServletDefinition servletDefinition : servletDefinitions) { servletDefinition.destroy(destroyedSoFar); } } /** * @return Returns a request dispatcher wrapped with a servlet mapped to * the given path or null if no mapping was found. */ RequestDispatcher getRequestDispatcher(String path) { final String newRequestUri = path; // TODO(dhanji): check servlet spec to see if the following is legal or not. // Need to strip query string if requested... for (final ServletDefinition servletDefinition : servletDefinitions) { if (servletDefinition.shouldServe(path)) { return new RequestDispatcher() { public void forward(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException { Preconditions.checkState(!servletResponse.isCommitted(), "Response has been committed--you can only call forward before" + " committing the response (hint: don't flush buffers)"); // clear buffer before forwarding servletResponse.resetBuffer(); ServletRequest requestToProcess; if (servletRequest instanceof HttpServletRequest) { requestToProcess = new RequestDispatcherRequestWrapper(servletRequest, newRequestUri); } else { // This should never happen, but instead of throwing an exception // we will allow a happy case pass thru for maximum tolerance to // legacy (and internal) code. requestToProcess = servletRequest; } // now dispatch to the servlet doServiceImpl(servletDefinition, requestToProcess, servletResponse); } public void include(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException { // route to the target servlet doServiceImpl(servletDefinition, servletRequest, servletResponse); } private void doServiceImpl(ServletDefinition servletDefinition, ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException { servletRequest.setAttribute(REQUEST_DISPATCHER_REQUEST, Boolean.TRUE); try { servletDefinition.doService(servletRequest, servletResponse); } finally { servletRequest.removeAttribute(REQUEST_DISPATCHER_REQUEST); } } }; } } //otherwise, can't process return null; } /** * A Marker constant attribute that when present in the request indicates to Guice servlet that * this request has been generated by a request dispatcher rather than the servlet pipeline. * In accordance with section 8.4.2 of the Servlet 2.4 specification. */ public static final String REQUEST_DISPATCHER_REQUEST = "javax.servlet.forward.servlet_path"; private static class RequestDispatcherRequestWrapper extends HttpServletRequestWrapper { private final String newRequestUri; public RequestDispatcherRequestWrapper(ServletRequest servletRequest, String newRequestUri) { super((HttpServletRequest) servletRequest); this.newRequestUri = newRequestUri; } @Override public String getRequestURI() { return newRequestUri; } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ManagedFilterPipeline.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ManagedFilterPipeline.j0000755000175000017500000001452611704661106032434 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.inject.Binding; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Provider; import com.google.inject.Singleton; import com.google.inject.TypeLiteral; import java.io.IOException; import java.util.List; import java.util.Set; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; /** * Central routing/dispatch class handles lifecycle of managed filters, and delegates to the servlet * pipeline. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ @Singleton class ManagedFilterPipeline implements FilterPipeline{ private final FilterDefinition[] filterDefinitions; private final ManagedServletPipeline servletPipeline; private final Provider servletContext; //Unfortunately, we need the injector itself in order to create filters + servlets private final Injector injector; //Guards a DCL, so needs to be volatile private volatile boolean initialized = false; private static final TypeLiteral FILTER_DEFS = TypeLiteral.get(FilterDefinition.class); @Inject public ManagedFilterPipeline(Injector injector, ManagedServletPipeline servletPipeline, Provider servletContext) { this.injector = injector; this.servletPipeline = servletPipeline; this.servletContext = servletContext; this.filterDefinitions = collectFilterDefinitions(injector); } /** * Introspects the injector and collects all instances of bound {@code List} * into a master list. * * We have a guarantee that {@link com.google.inject.Injector#getBindings()} returns a map * that preserves insertion order in entry-set iterators. */ private FilterDefinition[] collectFilterDefinitions(Injector injector) { List filterDefinitions = Lists.newArrayList(); for (Binding entry : injector.findBindingsByType(FILTER_DEFS)) { filterDefinitions.add(entry.getProvider().get()); } // Copy to a fixed-size array for speed of iteration. return filterDefinitions.toArray(new FilterDefinition[filterDefinitions.size()]); } public synchronized void initPipeline(ServletContext servletContext) throws ServletException { //double-checked lock, prevents duplicate initialization if (initialized) return; // Used to prevent duplicate initialization. Set initializedSoFar = Sets.newSetFromMap(Maps.newIdentityHashMap()); for (FilterDefinition filterDefinition : filterDefinitions) { filterDefinition.init(servletContext, injector, initializedSoFar); } //next, initialize servlets... servletPipeline.init(servletContext, injector); //everything was ok... initialized = true; } public void dispatch(ServletRequest request, ServletResponse response, FilterChain proceedingFilterChain) throws IOException, ServletException { //lazy init of filter pipeline (OK by the servlet specification). This is needed //in order for us not to force users to create a GuiceServletContextListener subclass. if (!initialized) { initPipeline(servletContext.get()); } //obtain the servlet pipeline to dispatch against new FilterChainInvocation(filterDefinitions, servletPipeline, proceedingFilterChain) .doFilter(withDispatcher(request, servletPipeline), response); } /** * Used to create an proxy that dispatches either to the guice-servlet pipeline or the regular * pipeline based on uri-path match. This proxy also provides minimal forwarding support. * * We cannot forward from a web.xml Servlet/JSP to a guice-servlet (because the filter pipeline * is not called again). However, we can wrap requests with our own dispatcher to forward the * *other* way. web.xml Servlets/JSPs can forward to themselves as per normal. * * This is not a problem cuz we intend for people to migrate from web.xml to guice-servlet, * incrementally, but not the other way around (which, we should actively discourage). */ @SuppressWarnings({ "JavaDoc", "deprecation" }) private ServletRequest withDispatcher(ServletRequest servletRequest, final ManagedServletPipeline servletPipeline) { // don't wrap the request if there are no servlets mapped. This prevents us from inserting our // wrapper unless it's actually going to be used. This is necessary for compatibility for apps // that downcast their HttpServletRequests to a concrete implementation. if (!servletPipeline.hasServletsMapped()) { return servletRequest; } HttpServletRequest request = (HttpServletRequest) servletRequest; //noinspection OverlyComplexAnonymousInnerClass return new HttpServletRequestWrapper(request) { @Override public RequestDispatcher getRequestDispatcher(String path) { final RequestDispatcher dispatcher = servletPipeline.getRequestDispatcher(path); return (null != dispatcher) ? dispatcher : super.getRequestDispatcher(path); } }; } public void destroyPipeline() { //destroy servlets first servletPipeline.destroy(); //go down chain and destroy all our filters Set destroyedSoFar = Sets.newSetFromMap(Maps.newIdentityHashMap()); for (FilterDefinition filterDefinition : filterDefinitions) { filterDefinition.destroy(destroyedSoFar); } } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/LinkedServletBindingImpl.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/LinkedServletBindingImp0000644000175000017500000000310411704661106032513 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.common.base.Objects; import com.google.inject.Key; import java.util.Map; import javax.servlet.http.HttpServlet; /** * Default implementation of LinkedServletBinding. * * @author sameb@google.com (Sam Berlin) */ class LinkedServletBindingImpl extends AbstractServletModuleBinding> implements LinkedServletBinding { LinkedServletBindingImpl(Map initParams, String pattern, Key target, UriPatternMatcher patternMatcher) { super(initParams, pattern, target, patternMatcher); } public Key getLinkedKey() { return getTarget(); } @Override public String toString() { return Objects.toStringHelper(LinkedServletBinding.class) .add("pattern", getPattern()) .add("initParams", getInitParams()) .add("uriPatternType", getUriPatternType()) .add("linkedServletKey", getLinkedKey()) .toString(); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/LinkedServletBinding.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/LinkedServletBinding.ja0000644000175000017500000000171411704661106032443 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.inject.Key; import javax.servlet.http.HttpServlet; /** * A linked binding to a servlet. * * @author sameb@google.com * @since 3.0 */ public interface LinkedServletBinding extends ServletModuleBinding { /** Returns the key used to lookup the servlet instance. */ Key getLinkedKey(); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/LinkedFilterBindingImpl.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/LinkedFilterBindingImpl0000644000175000017500000000304711704661106032476 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.common.base.Objects; import com.google.inject.Key; import java.util.Map; import javax.servlet.Filter; /** * Default implementation of LinkedFilterBinding. * * @author sameb@google.com (Sam Berlin) */ class LinkedFilterBindingImpl extends AbstractServletModuleBinding> implements LinkedFilterBinding { LinkedFilterBindingImpl(Map initParams, String pattern, Key target, UriPatternMatcher patternMatcher) { super(initParams, pattern, target, patternMatcher); } public Key getLinkedKey() { return getTarget(); } @Override public String toString() { return Objects.toStringHelper(LinkedFilterBinding.class) .add("pattern", getPattern()) .add("initParams", getInitParams()) .add("uriPatternType", getUriPatternType()) .add("linkedFilterKey", getLinkedKey()) .toString(); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/LinkedFilterBinding.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/LinkedFilterBinding.jav0000644000175000017500000000167211704661106032435 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.inject.Key; import javax.servlet.Filter; /** * A linked binding to a filter. * * @author sameb@google.com * @since 3.0 */ public interface LinkedFilterBinding extends ServletModuleBinding { /** Returns the key used to lookup the filter instance. */ Key getLinkedKey(); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/InternalServletModule.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/InternalServletModule.j0000644000175000017500000001112511704661106032520 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import static com.google.inject.servlet.ServletScopes.REQUEST; import static com.google.inject.servlet.ServletScopes.SESSION; import com.google.inject.AbstractModule; import com.google.inject.Provider; import com.google.inject.Provides; import com.google.inject.Singleton; import java.util.Map; import java.util.logging.Logger; import javax.servlet.ServletContext; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * This is a left-factoring of all ServletModules installed in the system. * In other words, this module contains the bindings common to all ServletModules, * and is bound exactly once per injector. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ final class InternalServletModule extends AbstractModule { /** * Special Provider that tries to obtain an injected servlet context, specific * to the current injector, failing which, it falls back to the static singleton * instance that is available in the legacy Guice Servlet. */ @Singleton static class BackwardsCompatibleServletContextProvider implements Provider { private ServletContext injectedServletContext; // This setter is called by the GuiceServletContextListener void set(ServletContext injectedServletContext) { this.injectedServletContext = injectedServletContext; } public ServletContext get() { if (null != injectedServletContext) { return injectedServletContext; } Logger.getLogger(InternalServletModule.class.getName()) .warning("You are attempting to use a deprecated API (specifically," + " attempting to @Inject ServletContext inside an eagerly created" + " singleton. While we allow this for backwards compatibility, be" + " warned that this MAY have unexpected behavior if you have more" + " than one injector (with ServletModule) running in the same JVM." + " Please consult the Guice documentation at" + " http://code.google.com/p/google-guice/wiki/Servlets for more" + " information."); return GuiceFilter.getServletContext(); } } @Override protected void configure() { bindScope(RequestScoped.class, REQUEST); bindScope(SessionScoped.class, SESSION); bind(ServletRequest.class).to(HttpServletRequest.class); bind(ServletResponse.class).to(HttpServletResponse.class); // inject the pipeline into GuiceFilter so it can route requests correctly // Unfortunate staticness... =( // NOTE(dhanji): This is maintained for legacy purposes. requestStaticInjection(GuiceFilter.class); bind(ManagedFilterPipeline.class); bind(ManagedServletPipeline.class); bind(FilterPipeline.class).to(ManagedFilterPipeline.class).asEagerSingleton(); bind(ServletContext.class).toProvider(BackwardsCompatibleServletContextProvider.class); bind(BackwardsCompatibleServletContextProvider.class); } @Provides @Singleton @ScopingOnly GuiceFilter provideScopingOnlyGuiceFilter() { return new GuiceFilter(new DefaultFilterPipeline()); } @Provides @RequestScoped HttpServletRequest provideHttpServletRequest() { return GuiceFilter.getRequest(); } @Provides @RequestScoped HttpServletResponse provideHttpServletResponse() { return GuiceFilter.getResponse(); } @Provides HttpSession provideHttpSession() { return GuiceFilter.getRequest().getSession(); } @SuppressWarnings("unchecked") // defined by getParameterMap() @Provides @RequestScoped @RequestParameters Map provideRequestParameters( ServletRequest req) { return req.getParameterMap(); } @Override public boolean equals(Object o) { // Is only ever installed internally, so we don't need to check state. return o instanceof InternalServletModule; } @Override public int hashCode() { return InternalServletModule.class.hashCode(); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/InstanceServletBindingImpl.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/InstanceServletBindingI0000644000175000017500000000301611704661106032516 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.common.base.Objects; import java.util.Map; import javax.servlet.http.HttpServlet; /** * Default implementation of InstanceServletBinding. * * @author sameb@google.com (Sam Berlin) */ class InstanceServletBindingImpl extends AbstractServletModuleBinding implements InstanceServletBinding { InstanceServletBindingImpl(Map initParams, String pattern, HttpServlet target, UriPatternMatcher patternMatcher) { super(initParams, pattern, target, patternMatcher); } public HttpServlet getServletInstance() { return getTarget(); } @Override public String toString() { return Objects.toStringHelper(InstanceServletBinding.class) .add("pattern", getPattern()) .add("initParams", getInitParams()) .add("uriPatternType", getUriPatternType()) .add("servletInstance", getServletInstance()) .toString(); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/InstanceServletBinding.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/InstanceServletBinding.0000644000175000017500000000165711704661106032474 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import javax.servlet.http.HttpServlet; /** * A binding to a single instance of a servlet. * * @author sameb@google.com * @since 3.0 */ public interface InstanceServletBinding extends ServletModuleBinding { /** Returns the servlet instance that will be used. */ HttpServlet getServletInstance(); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/InstanceFilterBindingImpl.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/InstanceFilterBindingIm0000644000175000017500000000275411704661106032504 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.common.base.Objects; import java.util.Map; import javax.servlet.Filter; /** * Default implementation of InstanceFilterBinding. * * @author sameb@google.com (Sam Berlin) */ class InstanceFilterBindingImpl extends AbstractServletModuleBinding implements InstanceFilterBinding { InstanceFilterBindingImpl(Map initParams, String pattern, Filter target, UriPatternMatcher patternMatcher) { super(initParams, pattern, target, patternMatcher); } public Filter getFilterInstance() { return getTarget(); } @Override public String toString() { return Objects.toStringHelper(InstanceFilterBinding.class) .add("pattern", getPattern()) .add("initParams", getInitParams()) .add("uriPatternType", getUriPatternType()) .add("filterInstance", getFilterInstance()) .toString(); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/InstanceFilterBinding.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/InstanceFilterBinding.j0000644000175000017500000000163411704661106032442 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import javax.servlet.Filter; /** * A binding to a single instance of a filter. * * @author sameb@google.com * @since 3.0 */ public interface InstanceFilterBinding extends ServletModuleBinding { /** Returns the filter instance that will be used. */ Filter getFilterInstance(); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/GuiceServletContextListener.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/GuiceServletContextList0000644000175000017500000000435311704661106032610 0ustar tonytony/** * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.inject.Injector; import java.lang.ref.WeakReference; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; /** * As of Guice 2.0 you can still use (your subclasses of) {@code GuiceServletContextListener} * class as a logical place to create and configure your injector. This will ensure the injector * is created when the web application is deployed. * * @author Kevin Bourrillion (kevinb@google.com) * @since 2.0 */ public abstract class GuiceServletContextListener implements ServletContextListener { static final String INJECTOR_NAME = Injector.class.getName(); public void contextInitialized(ServletContextEvent servletContextEvent) { final ServletContext servletContext = servletContextEvent.getServletContext(); // Set the Servletcontext early for those people who are using this class. // NOTE(dhanji): This use of the servletContext is deprecated. GuiceFilter.servletContext = new WeakReference(servletContext); Injector injector = getInjector(); injector.getInstance(InternalServletModule.BackwardsCompatibleServletContextProvider.class) .set(servletContext); servletContext.setAttribute(INJECTOR_NAME, injector); } public void contextDestroyed(ServletContextEvent servletContextEvent) { ServletContext servletContext = servletContextEvent.getServletContext(); servletContext.removeAttribute(INJECTOR_NAME); } /** * Override this method to create (or otherwise obtain a reference to) your * injector. */ protected abstract Injector getInjector(); } sisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/GuiceFilter.java0000644000175000017500000001600711704661106031127 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.inject.Inject; import com.google.inject.OutOfScopeException; import java.io.IOException; import java.lang.ref.WeakReference; import java.util.logging.Logger; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** *

    * Apply this filter in web.xml above all other filters (typically), to all requests where you plan * to use servlet scopes. This is also needed in order to dispatch requests to injectable filters * and servlets: *

     *  <filter>
     *    <filter-name>guiceFilter</filter-name>
     *    <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
     *  </filter>
     *
     *  <filter-mapping>
     *    <filter-name>guiceFilter</filter-name>
     *    <url-pattern>/*</url-pattern>
     *  </filter-mapping>
     *  
    * * This filter must appear before every filter that makes use of Guice injection or servlet * scopes functionality. Typically, you will only register this filter in web.xml and register * any other filters (and servlets) using a {@link ServletModule}. * * @author crazybob@google.com (Bob Lee) * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public class GuiceFilter implements Filter { static final ThreadLocal localContext = new ThreadLocal(); static volatile FilterPipeline pipeline = new DefaultFilterPipeline(); /** * We allow both the static and dynamic versions of the pipeline to exist. */ private final FilterPipeline injectedPipeline; /** Used to inject the servlets configured via {@link ServletModule} */ static volatile WeakReference servletContext = new WeakReference(null); private static final String MULTIPLE_INJECTORS_WARNING = "Multiple Servlet injectors detected. This is a warning " + "indicating that you have more than one " + GuiceFilter.class.getSimpleName() + " running " + "in your web application. If this is deliberate, you may safely " + "ignore this message. If this is NOT deliberate however, " + "your application may not work as expected."; private static final Logger LOGGER = Logger.getLogger(GuiceFilter.class.getName()); public GuiceFilter() { // Use the static FilterPipeline this(null); } @Inject protected GuiceFilter(FilterPipeline filterPipeline) { injectedPipeline = filterPipeline; } //VisibleForTesting @Inject static void setPipeline(FilterPipeline pipeline) { // This can happen if you create many injectors and they all have their own // servlet module. This is legal, caveat a small warning. if (GuiceFilter.pipeline instanceof ManagedFilterPipeline) { LOGGER.config(MULTIPLE_INJECTORS_WARNING); } // We overwrite the default pipeline GuiceFilter.pipeline = pipeline; } //VisibleForTesting static void reset() { pipeline = new DefaultFilterPipeline(); localContext.remove(); } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { FilterPipeline filterPipeline = getFilterPipeline(); Context previous = GuiceFilter.localContext.get(); HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; HttpServletRequest originalRequest = (previous != null) ? previous.getOriginalRequest() : request; localContext.set(new Context(originalRequest, request, response)); try { //dispatch across the servlet pipeline, ensuring web.xml's filterchain is honored filterPipeline.dispatch(servletRequest, servletResponse, filterChain); } finally { localContext.set(previous); } } static HttpServletRequest getOriginalRequest() { return getContext().getOriginalRequest(); } static HttpServletRequest getRequest() { return getContext().getRequest(); } static HttpServletResponse getResponse() { return getContext().getResponse(); } static ServletContext getServletContext() { return servletContext.get(); } private static Context getContext() { Context context = localContext.get(); if (context == null) { throw new OutOfScopeException("Cannot access scoped object. Either we" + " are not currently inside an HTTP Servlet request, or you may" + " have forgotten to apply " + GuiceFilter.class.getName() + " as a servlet filter for this request."); } return context; } static class Context { final HttpServletRequest originalRequest; final HttpServletRequest request; final HttpServletResponse response; Context(HttpServletRequest originalRequest, HttpServletRequest request, HttpServletResponse response) { this.originalRequest = originalRequest; this.request = request; this.response = response; } HttpServletRequest getOriginalRequest() { return originalRequest; } HttpServletRequest getRequest() { return request; } HttpServletResponse getResponse() { return response; } } public void init(FilterConfig filterConfig) throws ServletException { final ServletContext servletContext = filterConfig.getServletContext(); // Store servlet context in a weakreference, for injection GuiceFilter.servletContext = new WeakReference(servletContext); // In the default pipeline, this is a noop. However, if replaced // by a managed pipeline, a lazy init will be triggered the first time // dispatch occurs. FilterPipeline filterPipeline = getFilterPipeline(); filterPipeline.initPipeline(servletContext); } public void destroy() { try { // Destroy all registered filters & servlets in that order FilterPipeline filterPipeline = getFilterPipeline(); filterPipeline.destroyPipeline(); } finally { reset(); servletContext.clear(); } } private FilterPipeline getFilterPipeline() { // Prefer the injected pipeline, but fall back on the static one for web.xml users. return (null != injectedPipeline) ? injectedPipeline : pipeline; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/FiltersModuleBuilder.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/FiltersModuleBuilder.ja0000755000175000017500000000657211704661106032474 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.inject.Binder; import com.google.inject.Key; import com.google.inject.internal.UniqueAnnotations; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.Filter; /** * Builds the guice module that binds configured filters, with their * wrapper FilterDefinitions. Is part of the binding EDSL. All Filters * and Servlets are always bound as singletons. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ class FiltersModuleBuilder { private final Binder binder; public FiltersModuleBuilder(Binder binder) { this.binder = binder; } public ServletModule.FilterKeyBindingBuilder filter(List patterns) { return new FilterKeyBindingBuilderImpl(patterns, UriPatternType.SERVLET); } public ServletModule.FilterKeyBindingBuilder filterRegex(List regexes) { return new FilterKeyBindingBuilderImpl(regexes, UriPatternType.REGEX); } //non-static inner class so it can access state of enclosing module class class FilterKeyBindingBuilderImpl implements ServletModule.FilterKeyBindingBuilder { private final List uriPatterns; private final UriPatternType uriPatternType; private FilterKeyBindingBuilderImpl(List uriPatterns, UriPatternType uriPatternType) { this.uriPatterns = uriPatterns; this.uriPatternType = uriPatternType; } public void through(Class filterKey) { through(Key.get(filterKey)); } public void through(Key filterKey) { through(filterKey, new HashMap()); } public void through(Filter filter) { through(filter, new HashMap()); } public void through(Class filterKey, Map initParams) { // Careful you don't accidentally make this method recursive, thank you IntelliJ IDEA! through(Key.get(filterKey), initParams); } public void through(Key filterKey, Map initParams) { through(filterKey, initParams, null); } private void through(Key filterKey, Map initParams, Filter filterInstance) { for (String pattern : uriPatterns) { binder.bind(FilterDefinition.class).annotatedWith(UniqueAnnotations.create()).toProvider( new FilterDefinition(pattern, filterKey, UriPatternType.get(uriPatternType, pattern), initParams, filterInstance)); } } public void through(Filter filter, Map initParams) { Key filterKey = Key.get(Filter.class, UniqueAnnotations.create()); binder.bind(filterKey).toInstance(filter); through(filterKey, initParams, filter); } } } sisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/FilterPipeline.java0000755000175000017500000000336311704661106031644 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.inject.ImplementedBy; import java.io.IOException; import javax.servlet.FilterChain; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; /** * An internal dispatcher for guice-servlet registered servlets and filters. * By default, we assume a Guice 1.0 style servlet module is in play. In other * words, we dispatch directly to the web.xml pipeline after setting up scopes. * *

    * If on the other hand, {@link ServletModule} is used to register managed * servlets and/or filters, then a different pipeline is bound instead. Which, * after dispatching to Guice-injected filters and servlets continues to the web.xml * pipeline (if necessary). * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ @ImplementedBy(DefaultFilterPipeline.class) public interface FilterPipeline { void initPipeline(ServletContext context) throws ServletException; void destroyPipeline(); void dispatch(ServletRequest request, ServletResponse response, FilterChain defaultFilterChain) throws IOException, ServletException; } sisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/FilterDefinition.java0000755000175000017500000001345111704661106032166 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.common.collect.Iterators; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Scopes; import com.google.inject.spi.BindingTargetVisitor; import com.google.inject.spi.ProviderInstanceBinding; import com.google.inject.spi.ProviderWithExtensionVisitor; import java.io.IOException; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import javax.servlet.Filter; import javax.servlet.FilterConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; /** * An internal representation of a filter definition against a particular URI pattern. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ class FilterDefinition implements ProviderWithExtensionVisitor { private final String pattern; private final Key filterKey; private final UriPatternMatcher patternMatcher; private final Map initParams; // set only if this was bound to an instance of a Filter. private final Filter filterInstance; // always set after init is called. private final AtomicReference filter = new AtomicReference(); public FilterDefinition(String pattern, Key filterKey, UriPatternMatcher patternMatcher, Map initParams, Filter filterInstance) { this.pattern = pattern; this.filterKey = filterKey; this.patternMatcher = patternMatcher; this.initParams = Collections.unmodifiableMap(new HashMap(initParams)); this.filterInstance = filterInstance; } public FilterDefinition get() { return this; } public V acceptExtensionVisitor(BindingTargetVisitor visitor, ProviderInstanceBinding binding) { if(visitor instanceof ServletModuleTargetVisitor) { if(filterInstance != null) { return ((ServletModuleTargetVisitor)visitor).visit( new InstanceFilterBindingImpl(initParams, pattern, filterInstance, patternMatcher)); } else { return ((ServletModuleTargetVisitor)visitor).visit( new LinkedFilterBindingImpl(initParams, pattern, filterKey, patternMatcher)); } } else { return visitor.visit(binding); } } private boolean shouldFilter(String uri) { return patternMatcher.matches(uri); } public void init(final ServletContext servletContext, Injector injector, Set initializedSoFar) throws ServletException { // This absolutely must be a singleton, and so is only initialized once. if (!Scopes.isSingleton(injector.getBinding(filterKey))) { throw new ServletException("Filters must be bound as singletons. " + filterKey + " was not bound in singleton scope."); } Filter filter = injector.getInstance(filterKey); this.filter.set(filter); // Only fire init() if this Singleton filter has not already appeared earlier // in the filter chain. if (initializedSoFar.contains(filter)) { return; } //initialize our filter with the configured context params and servlet context filter.init(new FilterConfig() { public String getFilterName() { return filterKey.toString(); } public ServletContext getServletContext() { return servletContext; } public String getInitParameter(String s) { return initParams.get(s); } public Enumeration getInitParameterNames() { return Iterators.asEnumeration(initParams.keySet().iterator()); } }); initializedSoFar.add(filter); } public void destroy(Set destroyedSoFar) { // filters are always singletons Filter reference = filter.get(); // Do nothing if this Filter was invalid (usually due to not being scoped // properly), or was already destroyed. According to Servlet Spec: it is // "out of service", and does not need to be destroyed. // Also prevent duplicate destroys to the same singleton that may appear // more than once on the filter chain. if (null == reference || destroyedSoFar.contains(reference)) { return; } try { reference.destroy(); } finally { destroyedSoFar.add(reference); } } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChainInvocation filterChainInvocation) throws IOException, ServletException { final HttpServletRequest request = (HttpServletRequest) servletRequest; final String path = request.getRequestURI().substring(request.getContextPath().length()); if (shouldFilter(path)) { filter.get() .doFilter(servletRequest, servletResponse, filterChainInvocation); } else { //otherwise proceed down chain anyway filterChainInvocation.doFilter(servletRequest, servletResponse); } } //VisibleForTesting Filter getFilter() { return filter.get(); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/FilterChainInvocation.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/FilterChainInvocation.j0000755000175000017500000001140111704661106032453 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import java.io.IOException; import java.util.List; import java.util.Set; import javax.servlet.FilterChain; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * A Filter chain impl which basically passes itself to the "current" filter and iterates the chain * on {@code doFilter()}. Modeled on something similar in Apache Tomcat. * * Following this, it attempts to dispatch to guice-servlet's registered servlets using the * ManagedServletPipeline. * * And the end, it proceeds to the web.xml (default) servlet filter chain, if needed. * * @author Dhanji R. Prasanna * @since 1.0 */ class FilterChainInvocation implements FilterChain { private static final Set SERVLET_INTERNAL_METHODS = ImmutableSet.of( FilterDefinition.class.getName() + ".doFilter", FilterChainInvocation.class.getName() + ".doFilter"); private final FilterDefinition[] filterDefinitions; private final FilterChain proceedingChain; private final ManagedServletPipeline servletPipeline; //state variable tracks current link in filterchain private int index = -1; // whether or not we've caught an exception & cleaned up stack traces private boolean cleanedStacks = false; public FilterChainInvocation(FilterDefinition[] filterDefinitions, ManagedServletPipeline servletPipeline, FilterChain proceedingChain) { this.filterDefinitions = filterDefinitions; this.servletPipeline = servletPipeline; this.proceedingChain = proceedingChain; } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { index++; GuiceFilter.Context previous = GuiceFilter.localContext.get(); HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; HttpServletRequest originalRequest = (previous != null) ? previous.getOriginalRequest() : request; GuiceFilter.localContext.set(new GuiceFilter.Context(originalRequest, request, response)); try { //dispatch down the chain while there are more filters if (index < filterDefinitions.length) { filterDefinitions[index].doFilter(servletRequest, servletResponse, this); } else { //we've reached the end of the filterchain, let's try to dispatch to a servlet final boolean serviced = servletPipeline.service(servletRequest, servletResponse); //dispatch to the normal filter chain only if one of our servlets did not match if (!serviced) { proceedingChain.doFilter(servletRequest, servletResponse); } } } catch (Throwable t) { // Only clean on the first pass through -- one exception deep in a filter // will propogate upward & hit this catch clause multiple times. We don't // want to iterate through the stack elements for every filter. if (!cleanedStacks) { cleanedStacks = true; pruneStacktrace(t); } Throwables.propagateIfInstanceOf(t, ServletException.class); Throwables.propagateIfInstanceOf(t, IOException.class); throw Throwables.propagate(t); } finally { GuiceFilter.localContext.set(previous); } } /** * Removes stacktrace elements related to AOP internal mechanics from the * throwable's stack trace and any causes it may have. */ private void pruneStacktrace(Throwable throwable) { for (Throwable t = throwable; t != null; t = t.getCause()) { StackTraceElement[] stackTrace = t.getStackTrace(); List pruned = Lists.newArrayList(); for (StackTraceElement element : stackTrace) { String name = element.getClassName() + "." + element.getMethodName(); if (!SERVLET_INTERNAL_METHODS.contains(name)) { pruned.add(element); } } t.setStackTrace(pruned.toArray(new StackTraceElement[pruned.size()])); } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/DefaultFilterPipeline.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/DefaultFilterPipeline.j0000755000175000017500000000263511704661106032462 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import java.io.IOException; import javax.servlet.FilterChain; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; /** * This default pipeline simply dispatches to web.xml's servlet pipeline. * * @author dhanji@gmail.com (Dhanji R. Prasanna) * @see com.google.inject.servlet.ManagedFilterPipeline See Also ManagedFilterPipeline. */ class DefaultFilterPipeline implements FilterPipeline { public void initPipeline(ServletContext context) { } public void destroyPipeline() { } public void dispatch(ServletRequest request, ServletResponse response, FilterChain proceedingFilterChain) throws IOException, ServletException { proceedingFilterChain.doFilter(request, response); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ContinuingHttpServletRequest.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/ContinuingHttpServletRe0000644000175000017500000000450211704661106032613 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import com.google.common.collect.Maps; import com.google.inject.OutOfScopeException; import java.io.IOException; import java.util.Map; import javax.servlet.ServletInputStream; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpSession; /** * A wrapper for requests that makes requests immutable, taking a snapshot * of the original request. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ class ContinuingHttpServletRequest extends HttpServletRequestWrapper { // We clear out the attributes as they are mutable and not thread-safe. private final Map attributes = Maps.newHashMap(); public ContinuingHttpServletRequest(HttpServletRequest request) { super(request); } @Override public HttpSession getSession() { throw new OutOfScopeException("Cannot access the session in a continued request"); } @Override public HttpSession getSession(boolean create) { throw new UnsupportedOperationException("Cannot access the session in a continued request"); } @Override public ServletInputStream getInputStream() throws IOException { throw new UnsupportedOperationException("Cannot access raw request on a continued request"); } @Override public void setAttribute(String name, Object o) { attributes.put(name, o); } @Override public void removeAttribute(String name) { attributes.remove(name); } @Override public Object getAttribute(String name) { return attributes.get(name); } @Override public Cookie[] getCookies() { // TODO(dhanji): Cookies themselves are mutable. Is this a problem? return super.getCookies().clone(); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/AbstractServletModuleBinding.javasisu-guice-sisu-guice-3.1.1/extensions/servlet/src/com/google/inject/servlet/AbstractServletModuleBi0000644000175000017500000000314311704661106032533 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.servlet; import java.util.Map; /** * Abstract implementation for all servlet module bindings * * @author sameb@google.com (Sam Berlin) */ class AbstractServletModuleBinding implements ServletModuleBinding { private final Map initParams; private final String pattern; private final T target; private final UriPatternMatcher patternMatcher; AbstractServletModuleBinding(Map initParams, String pattern, T target, UriPatternMatcher patternMatcher) { this.initParams = initParams; this.pattern = pattern; this.target = target; this.patternMatcher = patternMatcher; } public Map getInitParams() { return initParams; } public String getPattern() { return pattern; } protected T getTarget() { return target; } public UriPatternType getUriPatternType() { return patternMatcher.getPatternType(); } public boolean matchesUri(String uri) { return patternMatcher.matches(uri); } } sisu-guice-sisu-guice-3.1.1/extensions/servlet/servlet.iml0000644000175000017500000000244411704661106022470 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/servlet/pom.xml0000644000175000017500000000161611704661106021616 0ustar tonytony 4.0.0 org.sonatype.sisu.inject guice-extensions 3.1.1 guice-servlet Sisu Guice - Extensions - Servlet javax.servlet servlet-api 2.5 provided org.easymock easymock 3.0 test sisu-guice-sisu-guice-3.1.1/extensions/servlet/build.xml0000644000175000017500000000142611704661106022121 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/servlet/build.properties0000644000175000017500000000025111704661106023510 0ustar tonytonylib.dir=../../lib ext.lib.dir=lib src.dir=src test.dir=test build.dir=build test.class=com.google.inject.servlet.AllTests module=com.google.inject.servlet fragment=true sisu-guice-sisu-guice-3.1.1/extensions/service/0000755000175000017500000000000011704661106020251 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/service/test/0000755000175000017500000000000011704661106021230 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/service/test/com/0000755000175000017500000000000011704661106022006 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/service/test/com/google/0000755000175000017500000000000011704661106023262 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/service/test/com/google/inject/0000755000175000017500000000000011704661106024536 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/service/test/com/google/inject/service/0000755000175000017500000000000011704661106026176 5ustar tonytony././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/service/test/com/google/inject/service/SingleServiceIntegrationTest.javasisu-guice-sisu-guice-3.1.1/extensions/service/test/com/google/inject/service/SingleServiceIntegrati0000644000175000017500000000474411704661106032543 0ustar tonytonypackage com.google.inject.service; import junit.framework.TestCase; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; /** * Tests using Async Service. */ public class SingleServiceIntegrationTest extends TestCase { public final void testAsyncServiceLifecycle() throws Exception { ExecutorService executor = Executors.newSingleThreadExecutor(); final CountDownLatch startLatch = new CountDownLatch(1); final CountDownLatch stopLatch = new CountDownLatch(1); AsyncService service = new AsyncService(executor) { @Override protected void onStart() { assertEquals(1, startLatch.getCount()); assertEquals(1, stopLatch.getCount()); startLatch.countDown(); } @Override protected void onStop() { assertEquals(0, startLatch.getCount()); assertEquals(1, stopLatch.getCount()); stopLatch.countDown(); } }; Future future = service.start(); // This should not pass! TODO(sameb): Why? Looks like it should to me assertTrue(startLatch.await(2, TimeUnit.SECONDS)); // onStart() is called before the state is set to STARTED, so we need // to wait until the Future finishes to guarantee it really was started. // This still manages to test what we want because the startLatch check // is before this. future.get(1, TimeUnit.SECONDS); service.stop(); assertTrue(stopLatch.await(2, TimeUnit.SECONDS)); executor.shutdown(); assertEquals(0, startLatch.getCount()); assertEquals(0, stopLatch.getCount()); } public final void testAsyncServiceBlockingLifecycle() throws InterruptedException, ExecutionException, TimeoutException { ExecutorService executor = Executors.newSingleThreadExecutor(); final AtomicInteger integer = new AtomicInteger(2); AsyncService service = new AsyncService(executor) { @Override protected void onStart() { assertEquals(2, integer.getAndDecrement()); } @Override protected void onStop() { assertEquals(1, integer.getAndDecrement()); } }; service.start().get(2, TimeUnit.SECONDS); service.stop().get(2, TimeUnit.SECONDS); executor.shutdown(); assertEquals(0, integer.get()); } } sisu-guice-sisu-guice-3.1.1/extensions/service/src/0000755000175000017500000000000011704661106021040 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/service/src/com/0000755000175000017500000000000011704661106021616 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/service/src/com/google/0000755000175000017500000000000011704661106023072 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/service/src/com/google/inject/0000755000175000017500000000000011704661106024346 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/service/src/com/google/inject/service/0000755000175000017500000000000011704661106026006 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/service/src/com/google/inject/service/Service.java0000644000175000017500000000500611704661106030252 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.service; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; /** * An object with an operational state, asynchronous {@link #start()} and * {@link #stop()} lifecycle methods to transition in and out of this state. * Example services include http servers, RPC systems and timer tasks. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public interface Service { /** * If the service has already been started, this method returns * immediately without taking action. A stopped service may not be restarted. * * @return a future for the startup result, regardless of whether this call * initiated startup. Calling {@link Future#get} will block until the * service has finished starting, and returns the resultant state. If * the service fails to start, {@link Future#get} will throw an {@link * ExecutionException}. If it has already finished starting, * {@link Future#get} returns immediately. */ Future start(); /** * If the service is {@link State#STARTED} initiates service shutdown and * returns immediately. If the service has already been stopped, this * method returns immediately without taking action. * * @return a future for the shutdown result, regardless of whether this call * initiated shutdown. Calling {@link Future#get} will block until the * service has finished shutting down, and either returns {@link * State#STOPPED} or throws an {@link ExecutionException}. If it has * already finished stopping, {@link Future#get} returns immediately. */ Future stop(); /** * Returns the current state of this service. One of {@link State} possible * values, or null if this is a brand new object, i.e., has not been put into * any state yet. */ State state(); /** * The lifecycle states of a service. */ enum State { STARTED, STOPPED, FAILED } } sisu-guice-sisu-guice-3.1.1/extensions/service/src/com/google/inject/service/CompositeService.java0000644000175000017500000000756711704661106032153 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.service; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import java.util.List; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; /** * A service that composes other services together in a fixed order. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public class CompositeService { private final Injector injector; private final Set> services = Sets.newLinkedHashSet(); /** * Represents the state of this composite service. Will equal FAILED * even if only one component service fails to start or stop. In other * words, all component services must start successfully for this * service to be considered started and similarly for stopped. */ private volatile Service.State compositeState; private boolean composed; @Inject CompositeService(Injector injector) { this.injector = injector; } public CompositeService add(Class service) { return add(Key.get(service)); } public CompositeService add(Key service) { Preconditions.checkState(!composed, "Cannot reuse a CompositeService after it has been compose()d. Please create a new one."); // Verify that the binding exists. Throws an exception if not. injector.getBinding(service); services.add(service); return this; } public Service compose() { Preconditions.checkState(!composed, "Cannot reuse a CompositeService after it has been compose()d. Please create a new one."); composed = true; // Defensive copy. final List> services = ImmutableList.copyOf(this.services); return new Service() { public Future start() { final List> tasks = Lists.newArrayList(); for (Key service : services) { tasks.add(injector.getInstance(service).start()); } return futureGet(tasks, State.STARTED); } public Future stop() { final List> tasks = Lists.newArrayList(); for (Key service : services) { tasks.add(injector.getInstance(service).stop()); } return futureGet(tasks, State.STOPPED); } public State state() { return compositeState; } }; } private FutureTask futureGet(final List> tasks, final Service.State state) { return new FutureTask(new Callable() { public Service.State call() { boolean ok = true; for (Future task : tasks) { try { ok = state == task.get(); } catch (InterruptedException e) { return compositeState = Service.State.FAILED; } catch (ExecutionException e) { return compositeState = Service.State.FAILED; } } return compositeState = ok ? state : Service.State.FAILED; } }); } } sisu-guice-sisu-guice-3.1.1/extensions/service/src/com/google/inject/service/AsyncService.java0000644000175000017500000000574611704661106031263 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.service; import com.google.common.base.Preconditions; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; /** * An asynchronous implementation of {@link com.google.inject.service.Service} * that provides convenience callbacks to create your own services. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public abstract class AsyncService implements Service { private final ExecutorService executor; /** * A runnable that does nothing. */ private static final Runnable NOOP = new Runnable() { public void run() { } }; private volatile State state; public AsyncService(ExecutorService executor) { this.executor = executor; } public synchronized final Future start() { Preconditions.checkState(state != State.STOPPED, "Cannot restart a service that has been stopped"); // Starts are idempotent. if (state == State.STARTED) { return new FutureTask(NOOP, State.STARTED); } return executor.submit(new Callable() { public State call() { onStart(); return state = State.STARTED; } }); } /** * Called back when this service must do its start work. Typically occurs * in a background thread. The result of this method is returned to the * original caller of {@link Service#start()} and can thus be used to * return a status message after start completes (or fails as the case * may be). */ protected abstract void onStart(); public synchronized final Future stop() { Preconditions.checkState(state != null, "Must start this service before you stop it!"); // Likewise, stops are idempotent. if (state == State.STOPPED) { return new FutureTask(NOOP, State.STOPPED); } return executor.submit(new Callable() { public State call() { onStop(); return state = State.STOPPED; } }); } /** * Called back when this service must shutdown. Typically occurs * in a background thread. The result of this method is returned to the * original caller of {@link Service#stop()} and can thus be used to * return a status message after stop completes (or fails as the case * may be). */ protected abstract void onStop(); public final State state() { return state; } } sisu-guice-sisu-guice-3.1.1/extensions/service/service.iml0000644000175000017500000000105011704661106022410 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/service/pom.xml0000644000175000017500000000103111704661106021561 0ustar tonytony 4.0.0 org.sonatype.sisu.inject guice-extensions 3.0-SNAPSHOT guice-service Sisu Guice - Extensions - Service sisu-guice-sisu-guice-3.1.1/extensions/pom.xml0000644000175000017500000000543611704661106020136 0ustar tonytony 4.0.0 org.sonatype.sisu.inject guice-parent 3.1.1 pom guice-extensions Sisu Guice - Extensions assistedinject grapher jmx jndi multibindings persist servlet spring struts2 throwingproviders org.sonatype.sisu sisu-guice ${project.version} org.sonatype.sisu sisu-guice ${project.version} tests test maven-remote-resources-plugin org.codehaus.mojo animal-sniffer-maven-plugin org.apache.felix maven-bundle-plugin org.sonatype.sisu.guice guice.with.jarjar false cglib cglib 2.2.2 test sisu-guice-sisu-guice-3.1.1/extensions/persist/0000755000175000017500000000000012273115427020304 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/persist/test/0000755000175000017500000000000011704661106021261 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/persist/test/log4j.properties0000644000175000017500000000040111704661106024411 0ustar tonytonylog4j.rootLogger=warn, console log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.Target=System.out log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%p [%c{1}] - %m %n sisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/0000755000175000017500000000000011704661106022037 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/0000755000175000017500000000000011704661106023313 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/0000755000175000017500000000000011704661106024567 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/0000755000175000017500000000000011704661106026260 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/0000755000175000017500000000000011704661106027032 5ustar tonytony././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/ManualLocalTransactionsWithCustomMatcherTest.javasisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/ManualLocalTransac0000644000175000017500000000707411704661106032471 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.persist.PersistService; import com.google.inject.persist.Transactional; import com.google.inject.persist.UnitOfWork; import junit.framework.TestCase; import java.util.Date; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; /** * Created with IntelliJ IDEA. On: 2/06/2007 * * For instance, a session-per-request strategy will control the opening and closing of the EM at * its own (manual) discretion. As opposed to a transactional unit of work. * * @author Dhanji R. Prasanna (dhanji@gmail.com) * @since 1.0 */ public class ManualLocalTransactionsWithCustomMatcherTest extends TestCase { private Injector injector; private static final String UNIQUE_TEXT = "some unique text" + new Date(); private static final String UNIQUE_TEXT_2 = "some other unique text" + new Date(); @Override public void setUp() { injector = Guice.createInjector(new JpaPersistModule("testUnit")); //startup persistence injector.getInstance(PersistService.class).start(); } @Override public void tearDown() { injector.getInstance(EntityManagerFactory.class).close(); } public void testSimpleCrossTxnWork() { //pretend that the request was started here EntityManager em = injector.getInstance(EntityManager.class); JpaTestEntity entity = injector .getInstance(ManualLocalTransactionsWithCustomMatcherTest.TransactionalObject.class) .runOperationInTxn(); injector.getInstance(ManualLocalTransactionsWithCustomMatcherTest.TransactionalObject.class) .runOperationInTxn2(); //persisted entity should remain in the same em (which should still be open) assertTrue("EntityManager appears to have been closed across txns!", injector.getInstance(EntityManager.class).contains(entity)); assertTrue("EntityManager appears to have been closed across txns!", em.contains(entity)); assertTrue("EntityManager appears to have been closed across txns!", em.isOpen()); injector.getInstance(UnitOfWork.class).end(); //try to query them back out em = injector.getInstance(EntityManager.class); assertNotNull(em.createQuery("from JpaTestEntity where text = :text") .setParameter("text", UNIQUE_TEXT).getSingleResult()); assertNotNull(em.createQuery("from JpaTestEntity where text = :text") .setParameter("text", UNIQUE_TEXT_2).getSingleResult()); em.close(); } public static class TransactionalObject { @Inject EntityManager em; @Transactional public JpaTestEntity runOperationInTxn() { JpaTestEntity entity = new JpaTestEntity(); entity.setText(UNIQUE_TEXT); em.persist(entity); return entity; } @Transactional public void runOperationInTxn2() { JpaTestEntity entity = new JpaTestEntity(); entity.setText(UNIQUE_TEXT_2); em.persist(entity); } } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/ManualLocalTransactionsTest.javasisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/ManualLocalTransac0000644000175000017500000000675011704661106032471 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.persist.PersistService; import com.google.inject.persist.Transactional; import com.google.inject.persist.UnitOfWork; import junit.framework.TestCase; import java.util.Date; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; /** * For instance, a session-per-request strategy will control the opening and closing of the EM at * its own (manual) discretion. As opposed to a transactional unit of work. * * @author Dhanji R. Prasanna (dhanji@gmail.com) */ public class ManualLocalTransactionsTest extends TestCase { private Injector injector; private static final String UNIQUE_TEXT = "some unique text" + new Date(); private static final String UNIQUE_TEXT_2 = "some other unique text" + new Date(); public void setUp() { injector = Guice.createInjector(new JpaPersistModule("testUnit")); //startup persistence injector.getInstance(PersistService.class).start(); } public void tearDown() { injector.getInstance(EntityManagerFactory.class).close(); } public void testSimpleCrossTxnWork() { injector.getInstance(UnitOfWork.class).begin(); //pretend that the request was started here EntityManager em = injector.getInstance(EntityManager.class); JpaTestEntity entity = injector.getInstance(TransactionalObject.class).runOperationInTxn(); injector.getInstance(TransactionalObject.class).runOperationInTxn2(); //persisted entity should remain in the same em (which should still be open) assertTrue("EntityManager appears to have been closed across txns!", injector.getInstance(EntityManager.class).contains(entity)); assertTrue("EntityManager appears to have been closed across txns!", em.contains(entity)); assertTrue("EntityManager appears to have been closed across txns!", em.isOpen()); injector.getInstance(UnitOfWork.class).end(); injector.getInstance(UnitOfWork.class).begin(); //try to query them back out em = injector.getInstance(EntityManager.class); assertNotNull(em.createQuery("from JpaTestEntity where text = :text") .setParameter("text", UNIQUE_TEXT).getSingleResult()); assertNotNull(em.createQuery("from JpaTestEntity where text = :text") .setParameter("text", UNIQUE_TEXT_2).getSingleResult()); em.close(); assertFalse(em.isOpen()); } public static class TransactionalObject { @Inject EntityManager em; @Transactional public JpaTestEntity runOperationInTxn() { JpaTestEntity entity = new JpaTestEntity(); entity.setText(UNIQUE_TEXT); em.persist(entity); return entity; } @Transactional public void runOperationInTxn2() { JpaTestEntity entity = new JpaTestEntity(); entity.setText(UNIQUE_TEXT_2); em.persist(entity); } } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/ManualLocalTransactionsConfidenceTest.javasisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/ManualLocalTransac0000644000175000017500000000561011704661106032463 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.persist.PersistService; import com.google.inject.persist.Transactional; import junit.framework.TestCase; import java.util.Date; import javax.persistence.EntityManager; import javax.persistence.PersistenceException; /** * @author Dhanji R. Prasanna (dhanji@gmail.com) */ public class ManualLocalTransactionsConfidenceTest extends TestCase { private Injector injector; private static final String UNIQUE_TEXT_3 = ManualLocalTransactionsConfidenceTest.class.getSimpleName() + "CONSTRAINT_VIOLATING some other unique text" + new Date(); @Override public void setUp() { injector = Guice.createInjector(new JpaPersistModule("testUnit")); //startup persistence injector.getInstance(PersistService.class).start(); } @Override public final void tearDown() { injector.getInstance(PersistService.class).stop(); } public void testThrowingCleanupInterceptorConfidence() { Exception e = null; try { System.out.println( "\n\n******************************* EXPECTED EXCEPTION NORMAL TEST BEHAVIOR **********"); injector.getInstance(TransactionalObject.class).runOperationInTxn(); fail(); } catch (RuntimeException re) { e = re; System.out.println( "\n\n******************************* EXPECTED EXCEPTION NORMAL TEST BEHAVIOR **********"); re.printStackTrace(System.out); System.out.println( "\n\n**********************************************************************************"); } assertNotNull("No exception was thrown!", e); assertTrue("Exception thrown was not what was expected (i.e. commit-time)", e instanceof PersistenceException); } public static class TransactionalObject { @Inject EntityManager em; @Transactional public void runOperationInTxn() { JpaParentTestEntity entity = new JpaParentTestEntity(); JpaTestEntity child = new JpaTestEntity(); child.setText(UNIQUE_TEXT_3); em.persist(child); entity.getChildren().add(child); em.persist(entity); entity = new JpaParentTestEntity(); entity.getChildren().add(child); em.persist(entity); } } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/ManagedLocalTransactionsTest.javasisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/ManagedLocalTransa0000644000175000017500000001373511704661106032446 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.persist.PersistService; import com.google.inject.persist.Transactional; import com.google.inject.persist.UnitOfWork; import junit.framework.TestCase; import java.io.IOException; import java.util.Date; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.NoResultException; /** * @author Dhanji R. Prasanna (dhanji@gmail.com) */ public class ManagedLocalTransactionsTest extends TestCase { private Injector injector; private static final String UNIQUE_TEXT = "some unique text" + new Date(); private static final String UNIQUE_TEXT_MERGE = "meRG_Esome unique text" + new Date(); private static final String TRANSIENT_UNIQUE_TEXT = "some other unique text" + new Date(); @Override public void setUp() { injector = Guice.createInjector(new JpaPersistModule("testUnit")); //startup persistence injector.getInstance(PersistService.class).start(); } @Override public final void tearDown() { injector.getInstance(UnitOfWork.class).end(); injector.getInstance(EntityManagerFactory.class).close(); } public void testSimpleTransaction() { injector.getInstance(TransactionalObject.class).runOperationInTxn(); EntityManager em = injector.getInstance(EntityManager.class); assertFalse("txn was not closed by transactional service", em.getTransaction().isActive()); //test that the data has been stored Object result = em.createQuery("from JpaTestEntity where text = :text") .setParameter("text", UNIQUE_TEXT).getSingleResult(); injector.getInstance(UnitOfWork.class).end(); assertTrue("odd result returned fatal", result instanceof JpaTestEntity); assertEquals("queried entity did not match--did automatic txn fail?", UNIQUE_TEXT, ((JpaTestEntity) result).getText()); } public void testSimpleTransactionWithMerge() { JpaTestEntity entity = injector.getInstance(TransactionalObject.class) .runOperationInTxnWithMerge(); EntityManager em = injector.getInstance(EntityManager.class); assertFalse("txn was not closed by transactional service", em.getTransaction().isActive()); //test that the data has been stored assertTrue("Em was closed after txn!", em.isOpen()); Object result = em.createQuery("from JpaTestEntity where text = :text") .setParameter("text", UNIQUE_TEXT_MERGE).getSingleResult(); injector.getInstance(UnitOfWork.class).end(); assertTrue(result instanceof JpaTestEntity); assertEquals("queried entity did not match--did automatic txn fail?", UNIQUE_TEXT_MERGE, ((JpaTestEntity) result).getText()); } public void testSimpleTransactionRollbackOnChecked() { try { injector.getInstance(TransactionalObject.class).runOperationInTxnThrowingChecked(); } catch (IOException e) { //ignore injector.getInstance(UnitOfWork.class).end(); } EntityManager em = injector.getInstance(EntityManager.class); assertFalse("Previous EM was not closed by transactional service (rollback didnt happen?)", em.getTransaction().isActive()); //test that the data has been stored try { Object result = em.createQuery("from JpaTestEntity where text = :text") .setParameter("text", TRANSIENT_UNIQUE_TEXT).getSingleResult(); injector.getInstance(UnitOfWork.class).end(); fail("a result was returned! rollback sure didnt happen!!!"); } catch (NoResultException e) {} } public void testSimpleTransactionRollbackOnUnchecked() { try { injector.getInstance(TransactionalObject.class).runOperationInTxnThrowingUnchecked(); } catch (RuntimeException re) { //ignore injector.getInstance(UnitOfWork.class).end(); } EntityManager em = injector.getInstance(EntityManager.class); assertFalse("Session was not closed by transactional service (rollback didnt happen?)", em.getTransaction().isActive()); try { Object result = em.createQuery("from JpaTestEntity where text = :text") .setParameter("text", TRANSIENT_UNIQUE_TEXT).getSingleResult(); injector.getInstance(UnitOfWork.class).end(); fail("a result was returned! rollback sure didnt happen!!!"); } catch (NoResultException e) {} } public static class TransactionalObject { private final EntityManager em; @Inject public TransactionalObject(EntityManager em) { this.em = em; } @Transactional public void runOperationInTxn() { JpaTestEntity entity = new JpaTestEntity(); entity.setText(UNIQUE_TEXT); em.persist(entity); } @Transactional public JpaTestEntity runOperationInTxnWithMerge() { JpaTestEntity entity = new JpaTestEntity(); entity.setText(UNIQUE_TEXT_MERGE); return em.merge(entity); } @Transactional(rollbackOn = IOException.class) public void runOperationInTxnThrowingChecked() throws IOException { JpaTestEntity entity = new JpaTestEntity(); entity.setText(TRANSIENT_UNIQUE_TEXT); em.persist(entity); throw new IOException(); } @Transactional public void runOperationInTxnThrowingUnchecked() { JpaTestEntity entity = new JpaTestEntity(); entity.setText(TRANSIENT_UNIQUE_TEXT); em.persist(entity); throw new IllegalStateException(); } } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/ManagedLocalTransactionsAcrossRequestTest.javasisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/ManagedLocalTransa0000644000175000017500000001761411704661106032446 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.name.Named; import com.google.inject.persist.PersistService; import com.google.inject.persist.Transactional; import com.google.inject.persist.UnitOfWork; import com.google.inject.persist.finder.Finder; import junit.framework.TestCase; import java.io.IOException; import java.util.Date; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.NoResultException; /** * @author Dhanji R. Prasanna (dhanji@gmail.com) */ public class ManagedLocalTransactionsAcrossRequestTest extends TestCase { private Injector injector; private static final String UNIQUE_TEXT = "some unique text" + new Date(); private static final String UNIQUE_TEXT_MERGE = "meRG_Esome unique text" + new Date(); private static final String UNIQUE_TEXT_MERGE_FORDF = "aSdoaksdoaksdmeRG_Esome unique text" + new Date(); private static final String TRANSIENT_UNIQUE_TEXT = "some other unique text" + new Date(); @Override public void setUp() { injector = Guice.createInjector(new JpaPersistModule("testUnit")); //startup persistence injector.getInstance(PersistService.class).start(); } @Override public final void tearDown() { injector.getInstance(EntityManagerFactory.class).close(); } public void testSimpleTransaction() { injector.getInstance(TransactionalObject.class).runOperationInTxn(); EntityManager em = injector.getInstance(EntityManager.class); assertFalse(em.getTransaction().isActive()); //test that the data has been stored Object result = em.createQuery("from JpaTestEntity where text = :text") .setParameter("text", UNIQUE_TEXT).getSingleResult(); injector.getInstance(UnitOfWork.class).end(); assertTrue("odd result returned fatal", result instanceof JpaTestEntity); assertEquals("queried entity did not match--did automatic txn fail?", UNIQUE_TEXT, ((JpaTestEntity) result).getText()); injector.getInstance(UnitOfWork.class).end(); } public void testSimpleTransactionWithMerge() { EntityManager emOrig = injector.getInstance(EntityManager.class); JpaTestEntity entity = injector.getInstance(TransactionalObject.class) .runOperationInTxnWithMerge(); assertNotNull("Entity was not given an id (was not persisted correctly?)", entity.getId()); EntityManager em = injector.getInstance(EntityManager.class); assertFalse(em.getTransaction().isActive()); //test that the data has been stored assertTrue("Em was closed after txn!", em.isOpen()); assertEquals("Em was not kept open across txns", emOrig, em); assertTrue("Merge did not store state or did not return persistent copy", em.contains(entity)); Object result = em.createQuery("from JpaTestEntity where text = :text") .setParameter("text", UNIQUE_TEXT_MERGE).getSingleResult(); injector.getInstance(UnitOfWork.class).end(); assertTrue(result instanceof JpaTestEntity); assertEquals("queried entity did not match--did automatic txn fail?", UNIQUE_TEXT_MERGE, ((JpaTestEntity) result).getText()); injector.getInstance(UnitOfWork.class).end(); } public void disabled_testSimpleTransactionWithMergeAndDF() { EntityManager emOrig = injector.getInstance(EntityManager.class); JpaTestEntity entity = injector.getInstance(TransactionalObject.class) .runOperationInTxnWithMergeForDf(); EntityManager em = injector.getInstance(EntityManager.class); assertFalse("txn was not closed by transactional service", em.getTransaction().isActive()); //test that the data has been stored assertTrue("Em was closed after txn!", em.isOpen()); assertEquals("Em was not kept open across txns", emOrig, em); assertTrue("Merge did not store state or did not return persistent copy", em.contains(entity)); Object result = injector.getInstance(TransactionalObject.class).find(UNIQUE_TEXT_MERGE_FORDF); injector.getInstance(UnitOfWork.class).end(); assertNotNull(result); assertTrue(result instanceof JpaTestEntity); assertEquals("queried entity did not match--did automatic txn fail?", UNIQUE_TEXT_MERGE_FORDF, ((JpaTestEntity) result).getText()); injector.getInstance(UnitOfWork.class).end(); } public void testSimpleTransactionRollbackOnChecked() { try { injector.getInstance(TransactionalObject.class).runOperationInTxnThrowingChecked(); } catch (IOException e) { //ignore injector.getInstance(UnitOfWork.class).end(); } EntityManager em = injector.getInstance(EntityManager.class); assertFalse("Previous EM was not closed by transactional service (rollback didnt happen?)", em.getTransaction().isActive()); //test that the data has been stored try { Object result = em.createQuery("from JpaTestEntity where text = :text") .setParameter("text", TRANSIENT_UNIQUE_TEXT).getSingleResult(); injector.getInstance(UnitOfWork.class).end(); fail(); } catch (NoResultException e) {} injector.getInstance(UnitOfWork.class).end(); } public void testSimpleTransactionRollbackOnUnchecked() { try { injector.getInstance(TransactionalObject.class).runOperationInTxnThrowingUnchecked(); } catch (RuntimeException re) { //ignore injector.getInstance(UnitOfWork.class).end(); } EntityManager em = injector.getInstance(EntityManager.class); assertFalse("Session was not closed by transactional service (rollback didnt happen?)", em.getTransaction().isActive()); try { Object result = em.createQuery("from JpaTestEntity where text = :text") .setParameter("text", TRANSIENT_UNIQUE_TEXT).getSingleResult(); injector.getInstance(UnitOfWork.class).end(); fail(); } catch (NoResultException e) {} injector.getInstance(UnitOfWork.class).end(); } public static class TransactionalObject { private final EntityManager em; @Inject public TransactionalObject(EntityManager em) { this.em = em; } @Transactional public void runOperationInTxn() { JpaTestEntity entity = new JpaTestEntity(); entity.setText(UNIQUE_TEXT); em.persist(entity); } @Transactional public JpaTestEntity runOperationInTxnWithMerge() { JpaTestEntity entity = new JpaTestEntity(); entity.setText(UNIQUE_TEXT_MERGE); return em.merge(entity); } @Transactional public JpaTestEntity runOperationInTxnWithMergeForDf() { JpaTestEntity entity = new JpaTestEntity(); entity.setText(UNIQUE_TEXT_MERGE_FORDF); return em.merge(entity); } @Transactional(rollbackOn = IOException.class) public void runOperationInTxnThrowingChecked() throws IOException { JpaTestEntity entity = new JpaTestEntity(); entity.setText(TRANSIENT_UNIQUE_TEXT); em.persist(entity); throw new IOException(); } @Transactional public void runOperationInTxnThrowingUnchecked() { JpaTestEntity entity = new JpaTestEntity(); entity.setText(TRANSIENT_UNIQUE_TEXT); em.persist(entity); throw new IllegalStateException(); } @Finder(query = "from JpaTestEntity where text = :text") public JpaTestEntity find(@Named("text") String text) { return null; } } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/JpaWorkManagerTest.javasisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/JpaWorkManagerTest0000644000175000017500000000665411704661106032500 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.persist.PersistService; import com.google.inject.persist.Transactional; import com.google.inject.persist.UnitOfWork; import junit.framework.TestCase; import java.util.Date; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Query; /** * @author Dhanji R. Prasanna (dhanji@gmail.com) */ public class JpaWorkManagerTest extends TestCase { private Injector injector; private static final String UNIQUE_TEXT_3 = JpaWorkManagerTest.class.getSimpleName() + "CONSTRAINT_VIOLATING some other unique text" + new Date(); @Override public void setUp() { injector = Guice.createInjector(new JpaPersistModule("testUnit")); //startup persistence injector.getInstance(PersistService.class).start(); } @Override public void tearDown() { injector.getInstance(EntityManagerFactory.class).close(); } public void testWorkManagerInSession() { injector.getInstance(UnitOfWork.class).begin(); try { injector.getInstance(TransactionalObject.class).runOperationInTxn(); } finally { injector.getInstance(UnitOfWork.class).end(); } injector.getInstance(UnitOfWork.class).begin(); injector.getInstance(EntityManager.class).getTransaction().begin(); try { final Query query = injector.getInstance(EntityManager.class) .createQuery("select e from JpaTestEntity as e where text = :text"); query.setParameter("text", UNIQUE_TEXT_3); final Object o = query.getSingleResult(); assertNotNull("no result!!", o); assertTrue("Unknown type returned " + o.getClass(), o instanceof JpaTestEntity); JpaTestEntity ent = (JpaTestEntity) o; assertEquals("Incorrect result returned or not persisted properly" + ent.getText(), UNIQUE_TEXT_3, ent.getText()); } finally { injector.getInstance(EntityManager.class).getTransaction().commit(); injector.getInstance(UnitOfWork.class).end(); } } public void testCloseMoreThanOnce() { injector.getInstance(PersistService.class).stop(); try { injector.getInstance(PersistService.class).stop(); fail(); } catch (IllegalStateException e) { // Ignored. } } public static class TransactionalObject { @Inject EntityManager em; @Transactional public void runOperationInTxn() { JpaTestEntity testEntity = new JpaTestEntity(); testEntity.setText(UNIQUE_TEXT_3); em.persist(testEntity); } @Transactional public void runOperationInTxnError() { JpaTestEntity testEntity = new JpaTestEntity(); testEntity.setText(UNIQUE_TEXT_3 + "transient never in db!" + hashCode()); em.persist(testEntity); } } } sisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/JpaTestEntity.java0000644000175000017500000000325611704661106032452 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; /** @author Dhanji R. Prasanna (dhanji@gmail.com) */ @Entity public class JpaTestEntity { private Long id; private String text; @Id @GeneratedValue public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getText() { return text; } public void setText(String text) { this.text = text; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } JpaTestEntity that = (JpaTestEntity) o; if (id != null ? !id.equals(that.id) : that.id != null) { return false; } if (text != null ? !text.equals(that.text) : that.text != null) { return false; } return true; } @Override public int hashCode() { int result = id != null ? id.hashCode() : 0; result = 31 * result + (text != null ? text.hashCode() : 0); return result; } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/JpaParentTestEntity.javasisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/JpaParentTestEntit0000644000175000017500000000262611704661106032513 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import java.util.ArrayList; import java.util.List; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.OneToMany; /** * Created with IntelliJ IDEA. * On: 2/06/2007 * * @author Dhanji R. Prasanna (dhanji@gmail.com) * @since 1.0 */ @Entity public class JpaParentTestEntity { private Long id; private List children = new ArrayList(); @Id @GeneratedValue public Long getId() { return id; } public void setId(Long id) { this.id = id; } @OneToMany public List getChildren() { return children; } public void setChildren(List children) { this.children = children; } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/JoiningLocalTransactionsTest.javasisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/JoiningLocalTransa0000644000175000017500000001320111704661106032473 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.persist.PersistService; import com.google.inject.persist.Transactional; import com.google.inject.persist.UnitOfWork; import junit.framework.TestCase; import java.io.IOException; import java.util.Date; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.NoResultException; /** * @author Dhanji R. Prasanna (dhanji@gmail.com) */ public class JoiningLocalTransactionsTest extends TestCase { private Injector injector; private static final String UNIQUE_TEXT = JoiningLocalTransactionsTest.class + "some unique text" + new Date(); private static final String TRANSIENT_UNIQUE_TEXT = JoiningLocalTransactionsTest.class + "some other unique text" + new Date(); @Override public void setUp() { injector = Guice.createInjector(new JpaPersistModule("testUnit")); //startup persistence injector.getInstance(PersistService.class).start(); } //cleanup entitymanager in case some of the rollback tests left it in an open state @Override public final void tearDown() { injector.getInstance(UnitOfWork.class).end(); injector.getInstance(EntityManagerFactory.class).close(); } public void testSimpleTransaction() { injector.getInstance(JoiningLocalTransactionsTest.TransactionalObject.class) .runOperationInTxn(); EntityManager em = injector.getInstance(EntityManager.class); assertFalse("txn was not closed by transactional service", em.getTransaction().isActive()); //test that the data has been stored Object result = em.createQuery("from JpaTestEntity where text = :text") .setParameter("text", UNIQUE_TEXT).getSingleResult(); injector.getInstance(UnitOfWork.class).end(); assertTrue("odd result returned fatal", result instanceof JpaTestEntity); assertEquals("queried entity did not match--did automatic txn fail?", UNIQUE_TEXT, ((JpaTestEntity) result).getText()); } public void testSimpleTransactionRollbackOnChecked() { try { injector.getInstance(JoiningLocalTransactionsTest.TransactionalObject.class) .runOperationInTxnThrowingChecked(); } catch (IOException e) { //ignore injector.getInstance(UnitOfWork.class).end(); } EntityManager em = injector.getInstance(EntityManager.class); assertFalse("EM was not closed by transactional service (rollback didnt happen?)", em.getTransaction().isActive()); //test that the data has been stored try { Object result = em.createQuery("from JpaTestEntity where text = :text") .setParameter("text", TRANSIENT_UNIQUE_TEXT).getSingleResult(); injector.getInstance(UnitOfWork.class).end(); fail("a result was returned! rollback sure didnt happen!!!"); } catch (NoResultException e) { } } public void testSimpleTransactionRollbackOnUnchecked() { try { injector.getInstance(JoiningLocalTransactionsTest.TransactionalObject.class) .runOperationInTxnThrowingUnchecked(); } catch (RuntimeException re) { //ignore injector.getInstance(UnitOfWork.class).end(); } EntityManager em = injector.getInstance(EntityManager.class); assertFalse("Session was not closed by transactional service (rollback didnt happen?)", em.getTransaction().isActive()); try { Object result = em.createQuery("from JpaTestEntity where text = :text") .setParameter("text", TRANSIENT_UNIQUE_TEXT).getSingleResult(); injector.getInstance(UnitOfWork.class).end(); fail("a result was returned! rollback sure didnt happen!!!"); } catch (NoResultException e) {} } public static class TransactionalObject { private final EntityManager em; @Inject public TransactionalObject(EntityManager em) { this.em = em; } @Transactional public void runOperationInTxn() { runOperationInTxnInternal(); } @Transactional(rollbackOn = IOException.class) public void runOperationInTxnInternal() { JpaTestEntity entity = new JpaTestEntity(); entity.setText(UNIQUE_TEXT); em.persist(entity); } @Transactional(rollbackOn = IOException.class) public void runOperationInTxnThrowingChecked() throws IOException { runOperationInTxnThrowingCheckedInternal(); } @Transactional private void runOperationInTxnThrowingCheckedInternal() throws IOException { JpaTestEntity entity = new JpaTestEntity(); entity.setText(TRANSIENT_UNIQUE_TEXT); em.persist(entity); throw new IOException(); } @Transactional public void runOperationInTxnThrowingUnchecked() { runOperationInTxnThrowingUncheckedInternal(); } @Transactional(rollbackOn = IOException.class) public void runOperationInTxnThrowingUncheckedInternal() { JpaTestEntity entity = new JpaTestEntity(); entity.setText(TRANSIENT_UNIQUE_TEXT); em.persist(entity); throw new IllegalStateException(); } } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/EntityManagerProvisionTest.javasisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/EntityManagerProvi0000644000175000017500000000652411704661106032553 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Provider; import com.google.inject.persist.PersistService; import com.google.inject.persist.Transactional; import junit.framework.TestCase; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; /** * A test around providing sessions (starting, closing etc.) * * @author Dhanji R. Prasanna (dhanji@gmail.com) */ public class EntityManagerProvisionTest extends TestCase { private Injector injector; public void setUp() { injector = Guice.createInjector(new JpaPersistModule("testUnit")); //startup persistence injector.getInstance(PersistService.class).start(); } public final void tearDown() { injector.getInstance(EntityManagerFactory.class).close(); } public void testEntityManagerLifecyclePerTxn() { //obtain em JpaDao dao = injector.getInstance(JpaDao.class); //obtain same em again (bound to txn) JpaTestEntity te = new JpaTestEntity(); dao.persist(te); //im not sure this hack works... assertFalse("Duplicate entity managers crossing-scope", dao.lastEm.equals(injector.getInstance(EntityManager.class))); //try to start a new em in a new txn dao = injector.getInstance(JpaDao.class); assertFalse("EntityManager wasnt closed and reopened properly around txn" + " (persistent object persists)", dao.contains(te)); } public void testEntityManagerLifecyclePerTxn2() { //obtain em JpaDao dao = injector.getInstance(JpaDao.class); //obtain same em again (bound to txn) JpaTestEntity te = new JpaTestEntity(); dao.persist(te); //im not sure this hack works... assertFalse("Duplicate entity managers crossing-scope", dao.lastEm.equals(injector.getInstance(EntityManager.class))); //try to start a new em in a new txn dao = injector.getInstance(JpaDao.class); assertFalse("EntityManager wasnt closed and reopened properly around txn" + " (persistent object persists)", dao.contains(te)); } public static class JpaDao { private final Provider em; EntityManager lastEm; @Inject public JpaDao(Provider em) { this.em = em; } @Transactional public void persist(T t) { lastEm = em.get(); assertTrue("em is not open!", lastEm.isOpen()); assertTrue("no active txn!", lastEm.getTransaction().isActive()); lastEm.persist(t); assertTrue("Persisting object failed", lastEm.contains(t)); } @Transactional public boolean contains(T t) { if (null == lastEm) { lastEm = em.get(); } return lastEm.contains(t); } } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/EntityManagerPerRequestProvisionTest.javasisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/EntityManagerPerRe0000644000175000017500000000666411704661106032476 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.persist.PersistService; import com.google.inject.persist.Transactional; import com.google.inject.persist.UnitOfWork; import junit.framework.TestCase; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; /** * A test around providing sessions (starting, closing etc.) * * @author Dhanji R. Prasanna (dhanji@gmail.com) */ public class EntityManagerPerRequestProvisionTest extends TestCase { private Injector injector; @Override public void setUp() { injector = Guice.createInjector(new JpaPersistModule("testUnit")); //startup persistence injector.getInstance(PersistService.class).start(); injector.getInstance(UnitOfWork.class).begin(); } @Override public final void tearDown() { injector.getInstance(UnitOfWork.class).end(); injector.getInstance(EntityManagerFactory.class).close(); } public void testEntityManagerLifecyclePerTxn() { //obtain em JpaDao dao = injector.getInstance(JpaDao.class); //obtain same em again (bound to txn) JpaTestEntity te = new JpaTestEntity(); dao.persist(te); //im not sure this hack works... assertEquals("Entity managers closed inside same thread-scope", injector.getInstance(EntityManager.class), JpaDao.em); //try to start a new em in a new txn dao = injector.getInstance(JpaDao.class); assertTrue("EntityManager was closed and reopened around txn" + " (persistent object does not persist)", dao.contains(te)); } public void testEntityManagerLifecyclePerTxn2() { //obtain em JpaDao dao = injector.getInstance(JpaDao.class); //obtain same em again (bound to txn) JpaTestEntity te = new JpaTestEntity(); dao.persist(te); //im not sure this hack works... assertEquals("Duplicate entity managers crossing-scope", injector.getInstance(EntityManager.class), JpaDao.em); assertEquals("Duplicate entity managers crossing-scope", injector.getInstance(EntityManager.class), JpaDao.em); //try to start a new em in a new txn dao = injector.getInstance(JpaDao.class); assertTrue("EntityManager was closed and reopened around txn" + " (persistent object doesnt persist)", dao.contains(te)); } public static class JpaDao { static EntityManager em; @Inject public JpaDao(EntityManager em) { JpaDao.em = em; } @Transactional public void persist(T t) { assertTrue("em is not open!", em.isOpen()); assertTrue("no active txn!", em.getTransaction().isActive()); em.persist(t); assertTrue("Persisting object failed", em.contains(t)); } @Transactional public boolean contains(T t) { return em.contains(t); } } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/EntityManagerFactoryProvisionTest.javasisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/EntityManagerFacto0000644000175000017500000000327111704661106032504 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.persist.PersistService; import com.google.inject.persist.UnitOfWork; import junit.framework.TestCase; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; /** * @author Dhanji R. Prasanna (dhanji@gmail.com) */ public class EntityManagerFactoryProvisionTest extends TestCase { private Injector injector; public void setUp() { injector = Guice.createInjector(new JpaPersistModule("testUnit")); } public final void tearDown() { injector.getInstance(UnitOfWork.class).end(); injector.getInstance(EntityManagerFactory.class).close(); } public void testSessionCreateOnInjection() { assertTrue("SINGLETON VIOLATION " + UnitOfWork.class.getName(), injector.getInstance(UnitOfWork.class) .equals(injector.getInstance(UnitOfWork.class))); //startup persistence injector.getInstance(PersistService.class).start(); //obtain em assertTrue(injector.getInstance(EntityManager.class).isOpen()); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/DynamicFinderTest.javasisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/DynamicFinderTest.0000644000175000017500000000602211704661106032407 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Provider; import com.google.inject.persist.PersistService; import com.google.inject.persist.Transactional; import com.google.inject.persist.finder.Finder; import junit.framework.TestCase; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.UUID; import javax.persistence.EntityManager; /** * A test around providing sessions (starting, closing etc.) * * @author Dhanji R. Prasanna (dhanji@gmail.com) */ public class DynamicFinderTest extends TestCase { private Injector injector; public void setUp() { injector = Guice.createInjector(new JpaPersistModule("testUnit").addFinder(JpaFinder.class)); //startup persistence injector.getInstance(PersistService.class).start(); } public final void tearDown() { injector.getInstance(PersistService.class).stop(); } public void testDynamicFinderListAll() { //obtain em JpaDao dao = injector.getInstance(JpaDao.class); //obtain same em again (bound to txn) JpaTestEntity te = new JpaTestEntity(); te.setText("HIAjsOKAOSD" + new Date() + UUID.randomUUID().toString()); dao.persist(te); //im not sure this hack works... assertFalse("Duplicate entity managers crossing-scope", dao.lastEm.equals(injector.getInstance(EntityManager.class))); List list = injector.getInstance(JpaFinder.class).listAll(); assertNotNull(list); assertFalse(list.isEmpty()); assertEquals(1, list.size()); assertEquals(te, list.get(0)); } public static interface JpaFinder { @Finder(query = "from JpaTestEntity", returnAs = ArrayList.class) public List listAll(); } public static class JpaDao { private final Provider em; EntityManager lastEm; @Inject public JpaDao(Provider em) { this.em = em; } @Transactional public void persist(T t) { lastEm = em.get(); assertTrue("em is not open!", lastEm.isOpen()); assertTrue("no active txn!", lastEm.getTransaction().isActive()); lastEm.persist(t); assertTrue("Persisting object failed", lastEm.contains(t)); } @Transactional public boolean contains(T t) { if (null == lastEm) { lastEm = em.get(); } return lastEm.contains(t); } } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/CustomPropsEntityManagerFactoryProvisionTest.javasisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/CustomPropsEntityM0000644000175000017500000000351711704661106032573 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.persist.PersistService; import com.google.inject.persist.UnitOfWork; import junit.framework.TestCase; import java.util.Properties; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; /** * @author Dhanji R. Prasanna (dhanji@gmail.com) */ public class CustomPropsEntityManagerFactoryProvisionTest extends TestCase { private Injector injector; @Override public void setUp() { Properties props = new Properties(); props.put("blah", "blah"); injector = Guice.createInjector(new JpaPersistModule("testUnit").properties(props)); } @Override public final void tearDown() { injector.getInstance(UnitOfWork.class).end(); injector.getInstance(EntityManagerFactory.class).close(); } public void testSessionCreateOnInjection() { assertEquals("SINGLETON VIOLATION " + UnitOfWork.class.getName(), injector.getInstance(UnitOfWork.class), injector.getInstance(UnitOfWork.class)); //startup persistence injector.getInstance(PersistService.class).start(); //obtain em assertTrue(injector.getInstance(EntityManager.class).isOpen()); } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/ClassLevelManagedLocalTransactionsTest.javasisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/jpa/ClassLevelManagedL0000644000175000017500000001534211704661106032410 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.persist.PersistService; import com.google.inject.persist.Transactional; import junit.framework.TestCase; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Date; import java.util.List; import javax.persistence.EntityManager; /** * This test asserts class level @Transactional annotation behavior. * * Class-level @Transactional is a shortcut if all non-private methods in the class are meant to be * transactional. * * @author Dhanji R. Prasanna (dhanji@gmail.com) */ public class ClassLevelManagedLocalTransactionsTest extends TestCase { private Injector injector; private static final String UNIQUE_TEXT = "JPAsome unique text88888" + new Date(); private static final String UNIQUE_TEXT_2 = "JPAsome asda unique teasdalsdplasdxt" + new Date(); private static final String TRANSIENT_UNIQUE_TEXT = "JPAsome other unique texaksoksojadasdt" + new Date(); public void setUp() { injector = Guice.createInjector(new JpaPersistModule("testUnit")); //startup persistence injector.getInstance(PersistService.class).start(); } public void tearDown() { injector.getInstance(PersistService.class).stop(); injector = null; } public void testSimpleTransaction() { injector.getInstance(TransactionalObject.class).runOperationInTxn(); EntityManager session = injector.getInstance(EntityManager.class); assertFalse("EntityManager was not closed by transactional service", session.getTransaction().isActive()); //test that the data has been stored session.getTransaction().begin(); Object result = session.createQuery("from JpaTestEntity where text = :text") .setParameter("text", UNIQUE_TEXT).getSingleResult(); session.getTransaction().commit(); assertTrue("odd result returned fatal", result instanceof JpaTestEntity); assertEquals("queried entity did not match--did automatic txn fail?", UNIQUE_TEXT, (((JpaTestEntity) result).getText())); } public void testSimpleTransactionRollbackOnChecked() { try { injector.getInstance(TransactionalObject2.class).runOperationInTxnThrowingChecked(); } catch (IOException e) { //ignore } EntityManager session = injector.getInstance(EntityManager.class); assertFalse("EntityManager was not closed by transactional service (rollback didnt happen?)", session.getTransaction().isActive()); //test that the data has been stored session.getTransaction().begin(); List result = session.createQuery("from JpaTestEntity where text = :text") .setParameter("text", TRANSIENT_UNIQUE_TEXT).getResultList(); session.getTransaction().commit(); assertTrue("a result was returned! rollback sure didnt happen!!!", result.isEmpty()); } public void testSimpleTransactionRollbackOnCheckedExcepting() { Exception ex = null; try { injector.getInstance(TransactionalObject3.class).runOperationInTxnThrowingCheckedExcepting(); fail("Exception was not thrown by test txn-al method!"); } catch (IOException e) { //ignored } EntityManager session = injector.getInstance(EntityManager.class); assertFalse("Txn was not closed by transactional service (commit didnt happen?)", session.getTransaction().isActive()); //test that the data has been stored session.getTransaction().begin(); Object result = session.createQuery("from JpaTestEntity where text = :text") .setParameter("text", UNIQUE_TEXT_2).getSingleResult(); session.getTransaction().commit(); assertNotNull("a result was not returned! rollback happened anyway (ignore failed)!!!", result); } public void testSimpleTransactionRollbackOnUnchecked() { try { injector.getInstance(TransactionalObject4.class).runOperationInTxnThrowingUnchecked(); } catch (RuntimeException re) { //ignore } EntityManager session = injector.getInstance(EntityManager.class); assertFalse("EntityManager was not closed by transactional service (rollback didnt happen?)", session.getTransaction().isActive()); //test that the data has been stored session.getTransaction().begin(); List result = session.createQuery("from JpaTestEntity where text = :text") .setParameter("text", TRANSIENT_UNIQUE_TEXT).getResultList(); session.getTransaction().commit(); assertTrue("a result was returned! rollback sure didnt happen!!!", result.isEmpty()); } @Transactional public static class TransactionalObject { @Inject EntityManager session; public void runOperationInTxn() { assertTrue(session.getTransaction().isActive()); JpaTestEntity entity = new JpaTestEntity(); entity.setText(UNIQUE_TEXT); session.persist(entity); } } @Transactional public static class TransactionalObject4 { @Inject EntityManager session; @Transactional public void runOperationInTxnThrowingUnchecked() { assertTrue(session.getTransaction().isActive()); JpaTestEntity entity = new JpaTestEntity(); entity.setText(TRANSIENT_UNIQUE_TEXT); session.persist(entity); throw new IllegalStateException(); } } @Transactional(rollbackOn = IOException.class, ignore = FileNotFoundException.class) public static class TransactionalObject3 { @Inject EntityManager session; public void runOperationInTxnThrowingCheckedExcepting() throws IOException { assertTrue(session.getTransaction().isActive()); JpaTestEntity entity = new JpaTestEntity(); entity.setText(UNIQUE_TEXT_2); session.persist(entity); throw new FileNotFoundException(); } } @Transactional(rollbackOn = IOException.class) public static class TransactionalObject2 { @Inject EntityManager session; public void runOperationInTxnThrowingChecked() throws IOException { assertTrue(session.getTransaction().isActive()); JpaTestEntity entity = new JpaTestEntity(); entity.setText(TRANSIENT_UNIQUE_TEXT); session.persist(entity); throw new IOException(); } } } sisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/EdslTest.java0000644000175000017500000000116011704661106030650 0ustar tonytonypackage com.google.inject.persist; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Stage; import com.google.inject.persist.jpa.JpaPersistModule; import junit.framework.TestCase; /** * @author dhanji@google.com (Dhanji R. Prasanna) */ public class EdslTest extends TestCase { public void testModuleConfigUsingJpa() throws Exception { Guice.createInjector(Stage.PRODUCTION, new AbstractModule() { @Override protected void configure() { install(new JpaPersistModule("myunit")); binder().requireExplicitBindings(); }; }); } } sisu-guice-sisu-guice-3.1.1/extensions/persist/test/com/google/inject/persist/AllTests.java0000644000175000017500000000456611704661106030671 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist; import com.google.inject.persist.jpa.ClassLevelManagedLocalTransactionsTest; import com.google.inject.persist.jpa.CustomPropsEntityManagerFactoryProvisionTest; import com.google.inject.persist.jpa.EntityManagerFactoryProvisionTest; import com.google.inject.persist.jpa.EntityManagerPerRequestProvisionTest; import com.google.inject.persist.jpa.EntityManagerProvisionTest; import com.google.inject.persist.jpa.JoiningLocalTransactionsTest; import com.google.inject.persist.jpa.JpaWorkManagerTest; import com.google.inject.persist.jpa.ManagedLocalTransactionsAcrossRequestTest; import com.google.inject.persist.jpa.ManagedLocalTransactionsTest; import com.google.inject.persist.jpa.ManualLocalTransactionsTest; import com.google.inject.persist.jpa.ManualLocalTransactionsWithCustomMatcherTest; import junit.framework.Test; import junit.framework.TestSuite; /** * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public class AllTests { public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(EdslTest.class); suite.addTestSuite(ClassLevelManagedLocalTransactionsTest.class); suite.addTestSuite(CustomPropsEntityManagerFactoryProvisionTest.class); suite.addTestSuite(EntityManagerFactoryProvisionTest.class); suite.addTestSuite(EntityManagerPerRequestProvisionTest.class); suite.addTestSuite(EntityManagerProvisionTest.class); suite.addTestSuite(JoiningLocalTransactionsTest.class); suite.addTestSuite(JpaWorkManagerTest.class); suite.addTestSuite(ManagedLocalTransactionsAcrossRequestTest.class); suite.addTestSuite(ManagedLocalTransactionsTest.class); suite.addTestSuite(ManualLocalTransactionsTest.class); suite.addTestSuite(ManualLocalTransactionsWithCustomMatcherTest.class); return suite; } }sisu-guice-sisu-guice-3.1.1/extensions/persist/test/META-INF/0000755000175000017500000000000011704661106022421 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/persist/test/META-INF/persistence.xml0000644000175000017500000000262711704661106025476 0ustar tonytony org.hibernate.ejb.HibernatePersistence com.google.inject.persist.jpa.JpaTestEntity com.google.inject.persist.jpa.JpaParentTestEntity true sisu-guice-sisu-guice-3.1.1/extensions/persist/src/0000755000175000017500000000000011704661106021071 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/0000755000175000017500000000000011704661106021647 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/0000755000175000017500000000000011704661106023123 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/0000755000175000017500000000000011704661106024377 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/0000755000175000017500000000000011704661106026070 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/package-info.java0000644000175000017500000000136711704661106031266 0ustar tonytony/* * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Guice Persist: a lightweight persistence library for Guice; this extension requires {@code * guice-persist-3.0.jar}. */ package com.google.inject.persist;sisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/jpa/0000755000175000017500000000000011704661106026642 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/jpa/package-info.java0000644000175000017500000000014511704661106032031 0ustar tonytony/** * guice-persist's Java Persistence API (JPA) support. */ package com.google.inject.persist.jpa;././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/jpa/JpaPersistService.javasisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/jpa/JpaPersistService.j0000644000175000017500000000757411704661106032437 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.common.base.Preconditions; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; import com.google.inject.persist.PersistService; import com.google.inject.persist.UnitOfWork; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.Properties; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; /** * @author Dhanji R. Prasanna (dhanji@gmail.com) */ @Singleton class JpaPersistService implements Provider, UnitOfWork, PersistService { private final ThreadLocal entityManager = new ThreadLocal(); private final String persistenceUnitName; private final Provider persistenceProperties; @Inject public JpaPersistService(@Jpa String persistenceUnitName, @Nullable @Jpa Provider persistenceProperties) { this.persistenceUnitName = persistenceUnitName; this.persistenceProperties = persistenceProperties; } public EntityManager get() { if (!isWorking()) { begin(); } EntityManager em = entityManager.get(); Preconditions.checkState(null != em, "Requested EntityManager outside work unit. " + "Try calling UnitOfWork.begin() first, or use a PersistFilter if you " + "are inside a servlet environment."); return em; } public boolean isWorking() { return entityManager.get() != null; } public void begin() { Preconditions.checkState(null == entityManager.get(), "Work already begun on this thread. Looks like you have called UnitOfWork.begin() twice" + " without a balancing call to end() in between."); entityManager.set(emFactory.createEntityManager()); } public void end() { EntityManager em = entityManager.get(); // Let's not penalize users for calling end() multiple times. if (null == em) { return; } em.close(); entityManager.remove(); } private volatile EntityManagerFactory emFactory; public synchronized void start() { Preconditions.checkState(null == emFactory, "Persistence service was already initialized."); if (null != persistenceProperties) { this.emFactory = Persistence .createEntityManagerFactory(persistenceUnitName, persistenceProperties.get()); } else { this.emFactory = Persistence.createEntityManagerFactory(persistenceUnitName); } } public synchronized void stop() { Preconditions.checkState(emFactory.isOpen(), "Persistence service was already shut down."); emFactory.close(); } @Singleton public static class EntityManagerFactoryProvider implements Provider { private final JpaPersistService emProvider; @Inject public EntityManagerFactoryProvider(JpaPersistService emProvider) { this.emProvider = emProvider; } public EntityManagerFactory get() { assert null != emProvider.emFactory; return emProvider.emFactory; } } @Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) private @interface Nullable { } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/jpa/JpaPersistModule.javasisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/jpa/JpaPersistModule.ja0000644000175000017500000001421411704661106032412 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.inject.Inject; import com.google.inject.Singleton; import com.google.inject.persist.PersistModule; import com.google.inject.persist.PersistService; import com.google.inject.persist.UnitOfWork; import com.google.inject.persist.finder.DynamicFinder; import com.google.inject.persist.finder.Finder; import com.google.inject.util.Providers; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import java.lang.reflect.AccessibleObject; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.List; import java.util.Properties; import javax.inject.Provider; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; /** * JPA provider for guice persist. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public final class JpaPersistModule extends PersistModule { private final String jpaUnit; public JpaPersistModule(String jpaUnit) { Preconditions.checkArgument(null != jpaUnit && jpaUnit.length() > 0, "JPA unit name must be a non-empty string."); this.jpaUnit = jpaUnit; } private Properties properties; private Class> propertiesProvider; private MethodInterceptor transactionInterceptor; @Override protected void configurePersistence() { bindConstant().annotatedWith(Jpa.class).to(jpaUnit); if (null != properties) { bind(Properties.class).annotatedWith(Jpa.class).toInstance(properties); } else if (null != propertiesProvider) { bind(Properties.class).annotatedWith(Jpa.class) .toProvider(propertiesProvider); } else { bind(Properties.class).annotatedWith(Jpa.class) .toProvider(Providers.of(null)); } bind(JpaPersistService.class).in(Singleton.class); bind(PersistService.class).to(JpaPersistService.class); bind(UnitOfWork.class).to(JpaPersistService.class); bind(EntityManager.class).toProvider(JpaPersistService.class); bind(EntityManagerFactory.class) .toProvider(JpaPersistService.EntityManagerFactoryProvider.class); transactionInterceptor = new JpaLocalTxnInterceptor(); requestInjection(transactionInterceptor); // Bind dynamic finders. for (Class finder : dynamicFinders) { bindFinder(finder); } } @Override protected MethodInterceptor getTransactionInterceptor() { return transactionInterceptor; } /** * Configures the JPA persistence provider with a set of properties. * * @param properties A set of name value pairs that configure a JPA persistence * provider as per the specification. */ public JpaPersistModule properties(Properties properties) { this.properties = properties; return this; } public JpaPersistModule properties(Class> provider) { this.propertiesProvider = provider; return this; } private final List> dynamicFinders = Lists.newArrayList(); /** * Adds an interface to this module to use as a dynamic finder. * * @param iface Any interface type whose methods are all dynamic finders. */ public JpaPersistModule addFinder(Class iface) { dynamicFinders.add(iface); return this; } private void bindFinder(Class iface) { if (!isDynamicFinderValid(iface)) { return; } InvocationHandler finderInvoker = new InvocationHandler() { @Inject JpaFinderProxy finderProxy; public Object invoke(final Object thisObject, final Method method, final Object[] args) throws Throwable { // Don't intercept non-finder methods like equals and hashcode. if (!method.isAnnotationPresent(Finder.class)) { // NOTE(dhanji): This is not ideal, we are using the invocation handler's equals // and hashcode as a proxy (!) for the proxy's equals and hashcode. return method.invoke(this, args); } return finderProxy.invoke(new MethodInvocation() { public Method getMethod() { return method; } public Object[] getArguments() { return null == args ? new Object[0] : args; } public Object proceed() throws Throwable { return method.invoke(thisObject, args); } public Object getThis() { throw new UnsupportedOperationException("Bottomless proxies don't expose a this."); } public AccessibleObject getStaticPart() { throw new UnsupportedOperationException(); } }); } }; requestInjection(finderInvoker); @SuppressWarnings("unchecked") // Proxy must produce instance of type given. T proxy = (T) Proxy .newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] { iface }, finderInvoker); bind(iface).toInstance(proxy); } private boolean isDynamicFinderValid(Class iface) { boolean valid = true; if (!iface.isInterface()) { addError(iface + " is not an interface. Dynamic Finders must be interfaces."); valid = false; } for (Method method : iface.getMethods()) { DynamicFinder finder = DynamicFinder.from(method); if (null == finder) { addError("Dynamic Finder methods must be annotated with @Finder, but " + iface + "." + method.getName() + " was not"); valid = false; } } return valid; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/jpa/JpaLocalTxnInterceptor.javasisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/jpa/JpaLocalTxnIntercep0000644000175000017500000001144111704661106032437 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.inject.Inject; import com.google.inject.persist.Transactional; import com.google.inject.persist.UnitOfWork; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import java.lang.reflect.Method; import javax.persistence.EntityManager; import javax.persistence.EntityTransaction; /** * @author Dhanji R. Prasanna (dhanji@gmail.com) */ class JpaLocalTxnInterceptor implements MethodInterceptor { @Inject private final JpaPersistService emProvider = null; @Inject private final UnitOfWork unitOfWork = null; @Transactional private static class Internal {} // Tracks if the unit of work was begun implicitly by this transaction. private final ThreadLocal didWeStartWork = new ThreadLocal(); public Object invoke(MethodInvocation methodInvocation) throws Throwable { // Should we start a unit of work? if (!emProvider.isWorking()) { emProvider.begin(); didWeStartWork.set(true); } Transactional transactional = readTransactionMetadata(methodInvocation); EntityManager em = this.emProvider.get(); // Allow 'joining' of transactions if there is an enclosing @Transactional method. if (em.getTransaction().isActive()) { return methodInvocation.proceed(); } final EntityTransaction txn = em.getTransaction(); txn.begin(); Object result; try { result = methodInvocation.proceed(); } catch (Exception e) { //commit transaction only if rollback didnt occur if (rollbackIfNecessary(transactional, e, txn)) { txn.commit(); } //propagate whatever exception is thrown anyway throw e; } finally { // Close the em if necessary (guarded so this code doesn't run unless catch fired). if (null != didWeStartWork.get() && !txn.isActive()) { didWeStartWork.remove(); unitOfWork.end(); } } //everything was normal so commit the txn (do not move into try block above as it // interferes with the advised method's throwing semantics) try { txn.commit(); } finally { //close the em if necessary if (null != didWeStartWork.get() ) { didWeStartWork.remove(); unitOfWork.end(); } } //or return result return result; } // TODO(dhanji): Cache this method's results. private Transactional readTransactionMetadata(MethodInvocation methodInvocation) { Transactional transactional; Method method = methodInvocation.getMethod(); Class targetClass = methodInvocation.getThis().getClass(); transactional = method.getAnnotation(Transactional.class); if (null == transactional) { // If none on method, try the class. transactional = targetClass.getAnnotation(Transactional.class); } if (null == transactional) { // If there is no transactional annotation present, use the default transactional = Internal.class.getAnnotation(Transactional.class); } return transactional; } /** * Returns True if rollback DID NOT HAPPEN (i.e. if commit should continue). * * @param transactional The metadata annotaiton of the method * @param e The exception to test for rollback * @param txn A JPA Transaction to issue rollbacks on */ private boolean rollbackIfNecessary(Transactional transactional, Exception e, EntityTransaction txn) { boolean commit = true; //check rollback clauses for (Class rollBackOn : transactional.rollbackOn()) { //if one matched, try to perform a rollback if (rollBackOn.isInstance(e)) { commit = false; //check ignore clauses (supercedes rollback clause) for (Class exceptOn : transactional.ignore()) { //An exception to the rollback clause was found, DON'T rollback // (i.e. commit and throw anyway) if (exceptOn.isInstance(e)) { commit = true; break; } } //rollback only if nothing matched the ignore check if (!commit) { txn.rollback(); } //otherwise continue to commit break; } } return commit; } } sisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/jpa/JpaFinderProxy.java0000644000175000017500000002441211704661106032414 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.common.collect.MapMaker; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; import com.google.inject.name.Named; import com.google.inject.persist.finder.Finder; import com.google.inject.persist.finder.FirstResult; import com.google.inject.persist.finder.MaxResults; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.Query; /** * TODO(dhanji): Make this work!! * * @author Dhanji R. Prasanna (dhanji@gmail.com) */ @Singleton class JpaFinderProxy implements MethodInterceptor { private final Map finderCache = new MapMaker().weakKeys().makeMap(); private final Provider emProvider; @Inject public JpaFinderProxy(Provider emProvider) { this.emProvider = emProvider; } public Object invoke(MethodInvocation methodInvocation) throws Throwable { EntityManager em = emProvider.get(); //obtain a cached finder descriptor (or create a new one) JpaFinderProxy.FinderDescriptor finderDescriptor = getFinderDescriptor(methodInvocation); Object result = null; //execute as query (named params or otherwise) Query jpaQuery = finderDescriptor.createQuery(em); if (finderDescriptor.isBindAsRawParameters) { bindQueryRawParameters(jpaQuery, finderDescriptor, methodInvocation.getArguments()); } else { bindQueryNamedParameters(jpaQuery, finderDescriptor, methodInvocation.getArguments()); } //depending upon return type, decorate or return the result as is if (JpaFinderProxy.ReturnType.PLAIN.equals(finderDescriptor.returnType)) { result = jpaQuery.getSingleResult(); } else if (JpaFinderProxy.ReturnType.COLLECTION.equals(finderDescriptor.returnType)) { result = getAsCollection(finderDescriptor, jpaQuery.getResultList()); } else if (JpaFinderProxy.ReturnType.ARRAY.equals(finderDescriptor.returnType)) { result = jpaQuery.getResultList().toArray(); } return result; } private Object getAsCollection(JpaFinderProxy.FinderDescriptor finderDescriptor, List results) { Collection collection; try { collection = (Collection) finderDescriptor.returnCollectionTypeConstructor.newInstance(); } catch (InstantiationException e) { throw new RuntimeException( "Specified collection class of Finder's returnAs could not be instantated: " + finderDescriptor.returnCollectionType, e); } catch (IllegalAccessException e) { throw new RuntimeException( "Specified collection class of Finder's returnAs could not be instantated (do not have access privileges): " + finderDescriptor.returnCollectionType, e); } catch (InvocationTargetException e) { throw new RuntimeException( "Specified collection class of Finder's returnAs could not be instantated (it threw an exception): " + finderDescriptor.returnCollectionType, e); } collection.addAll(results); return collection; } private void bindQueryNamedParameters(Query jpaQuery, JpaFinderProxy.FinderDescriptor descriptor, Object[] arguments) { for (int i = 0; i < arguments.length; i++) { Object argument = arguments[i]; Object annotation = descriptor.parameterAnnotations[i]; if (null == annotation) //noinspection UnnecessaryContinue { continue; //skip param as it's not bindable } else if (annotation instanceof Named) { Named named = (Named) annotation; jpaQuery.setParameter(named.value(), argument); } else if (annotation instanceof javax.inject.Named) { javax.inject.Named named = (javax.inject.Named) annotation; jpaQuery.setParameter(named.value(), argument); } else if (annotation instanceof FirstResult) { jpaQuery.setFirstResult((Integer) argument); } else if (annotation instanceof MaxResults) { jpaQuery.setMaxResults((Integer) argument); } } } private void bindQueryRawParameters(Query jpaQuery, JpaFinderProxy.FinderDescriptor descriptor, Object[] arguments) { for (int i = 0, index = 1; i < arguments.length; i++) { Object argument = arguments[i]; Object annotation = descriptor.parameterAnnotations[i]; if (null == annotation) { //bind it as a raw param (1-based index, yes I know its different from Hibernate, blargh) jpaQuery.setParameter(index, argument); index++; } else if (annotation instanceof FirstResult) { jpaQuery.setFirstResult((Integer) argument); } else if (annotation instanceof MaxResults) { jpaQuery.setMaxResults((Integer) argument); } } } private JpaFinderProxy.FinderDescriptor getFinderDescriptor(MethodInvocation invocation) { Method method = invocation.getMethod(); JpaFinderProxy.FinderDescriptor finderDescriptor = finderCache.get(method); if (null != finderDescriptor) { return finderDescriptor; } //otherwise reflect and cache finder info... finderDescriptor = new JpaFinderProxy.FinderDescriptor(); //determine return type finderDescriptor.returnClass = invocation.getMethod().getReturnType(); finderDescriptor.returnType = determineReturnType(finderDescriptor.returnClass); //determine finder query characteristics Finder finder = invocation.getMethod().getAnnotation(Finder.class); String query = finder.query(); if (!"".equals(query.trim())) { finderDescriptor.setQuery(query); } else { finderDescriptor.setNamedQuery(finder.namedQuery()); } //determine parameter annotations Annotation[][] parameterAnnotations = method.getParameterAnnotations(); Object[] discoveredAnnotations = new Object[parameterAnnotations.length]; for (int i = 0; i < parameterAnnotations.length; i++) { Annotation[] annotations = parameterAnnotations[i]; //each annotation per param for (Annotation annotation : annotations) { //discover the named, first or max annotations then break out Class annotationType = annotation.annotationType(); if (Named.class.equals(annotationType) || javax.inject.Named.class.equals(annotationType)) { discoveredAnnotations[i] = annotation; finderDescriptor.isBindAsRawParameters = false; break; } else if (FirstResult.class.equals(annotationType)) { discoveredAnnotations[i] = annotation; break; } else if (MaxResults.class.equals(annotationType)) { discoveredAnnotations[i] = annotation; break; } //leave as null for no binding } } //set the discovered set to our finder cache object finderDescriptor.parameterAnnotations = discoveredAnnotations; //discover the returned collection implementation if this finder returns a collection if (JpaFinderProxy.ReturnType.COLLECTION.equals(finderDescriptor.returnType) && finderDescriptor.returnClass != Collection.class) { finderDescriptor.returnCollectionType = finder.returnAs(); try { finderDescriptor.returnCollectionTypeConstructor = finderDescriptor.returnCollectionType .getConstructor(); finderDescriptor.returnCollectionTypeConstructor.setAccessible(true); //UGH! } catch (NoSuchMethodException e) { throw new RuntimeException( "Finder's collection return type specified has no default constructor! returnAs: " + finderDescriptor.returnCollectionType, e); } } //cache it cacheFinderDescriptor(method, finderDescriptor); return finderDescriptor; } /** * writes to a chm (used to provide copy-on-write but this is bettah!) * * @param method The key * @param finderDescriptor The descriptor to cache */ private void cacheFinderDescriptor(Method method, FinderDescriptor finderDescriptor) { //write to concurrent map finderCache.put(method, finderDescriptor); } private JpaFinderProxy.ReturnType determineReturnType(Class returnClass) { if (Collection.class.isAssignableFrom(returnClass)) { return JpaFinderProxy.ReturnType.COLLECTION; } else if (returnClass.isArray()) { return JpaFinderProxy.ReturnType.ARRAY; } return JpaFinderProxy.ReturnType.PLAIN; } /** * A wrapper data class that caches information about a finder method. */ private static class FinderDescriptor { private volatile boolean isKeyedQuery = false; volatile boolean isBindAsRawParameters = true; //should we treat the query as having ? instead of :named params volatile JpaFinderProxy.ReturnType returnType; volatile Class returnClass; volatile Class returnCollectionType; volatile Constructor returnCollectionTypeConstructor; volatile Object[] parameterAnnotations; //contract is: null = no bind, @Named = param, @FirstResult/@MaxResults for paging private String query; private String name; void setQuery(String query) { this.query = query; } void setNamedQuery(String name) { this.name = name; isKeyedQuery = true; } public boolean isKeyedQuery() { return isKeyedQuery; } Query createQuery(EntityManager em) { return isKeyedQuery ? em.createNamedQuery(name) : em.createQuery(query); } } private static enum ReturnType { PLAIN, COLLECTION, ARRAY } } sisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/jpa/Jpa.java0000644000175000017500000000170111704661106030216 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.jpa; import com.google.inject.BindingAnnotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * A binding annotation for internal JPA module properties. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ @Retention(RetentionPolicy.RUNTIME) @BindingAnnotation @interface Jpa {} sisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/finder/0000755000175000017500000000000011704661106027337 5ustar tonytony././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/finder/package-info.javasisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/finder/package-info.jav0000644000175000017500000000013211704661106032361 0ustar tonytony/** * Dynamic Finder API for Guice Persist. */ package com.google.inject.persist.finder;sisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/finder/MaxResults.java0000644000175000017500000000220611704661106032311 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.finder; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Annotate any dynamic finder method's integer argument with this to pass in * the maximum size of returned result window. Usefule for paging result sets. * Complement of {@link FirstResult}. * * @author Dhanji R. Prasanna (dhanji@gmail.com) */ @Target(ElementType.PARAMETER) @Retention(RetentionPolicy.RUNTIME) public @interface MaxResults { } sisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/finder/FirstResult.java0000644000175000017500000000224211704661106032470 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.finder; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Annotate any dynamic finder method's integer argument with this to pass in * the index of the first result in the result set you are interested in. * Useful for paging result sets. Complemented by {@link MaxResults}. * * @author Dhanji R. Prasanna (dhanji@gmail.com) */ @Target(ElementType.PARAMETER) @Retention(RetentionPolicy.RUNTIME) public @interface FirstResult { } sisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/finder/Finder.java0000644000175000017500000000340711704661106031415 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.finder; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.Collection; /** * Marks a method stub as a dynamic finder. The method is intercepted and replaced with the * specified JPAQL query. Provides result auto-boxing and automatic parameter binding. * * @author Dhanji R. Prasanna (dhanji@gmail.com) */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Finder { /** * Returns the configured named query's name. Specify a named query's name * here. This name is typically specified in your JPA configuration. */ String namedQuery() default ""; /** * Returns the configured query string. Directly specify a JPAQL query here. */ String query() default ""; /** * Returns the configured autoboxing collection class. * Use this clause to specify a collection impl to autobox result lists into. The impl must * have a default no-arg constructor and be a subclass of {@code java.util.Collection}. */ Class returnAs() default Collection.class; }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/finder/DynamicFinder.javasisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/finder/DynamicFinder.ja0000644000175000017500000000254311704661106032373 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist.finder; import java.lang.reflect.Method; /** * Utility that helps you introspect dynamic finder methods. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public final class DynamicFinder { private final Method method; private final Finder finder; public DynamicFinder(Method method) { this.method = method; this.finder = method.getAnnotation(Finder.class); } /** * Returns some metadata if the method is annotated {@code @Finder} or null. * * @param method a method you want to test as a dynamic finder */ public static DynamicFinder from(Method method) { return method.isAnnotationPresent(Finder.class) ? new DynamicFinder(method) : null; } public Finder metadata() { return finder; } } sisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/UnitOfWork.java0000755000175000017500000000451611704661106031013 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist; /** * This interface is used to gain manual control over the unit of work. This is mostly to do * work in non-request, non-transactional threads. Or where more fine-grained control over the unit * of work is required. Starting and ending a unit of work directly corresponds to opening and * closing a {@code Session}, {@code EntityManager} or {@code ObjectContainer} respectively. *

    The * Unit of Work referred to by UnitOfWork will always be local to the calling thread. Be careful to * end() in a finally block. Neither JPA, nor Hibernate supports threadsafe sessions (reasoning * behind thread-locality of Unit of Work semantics). * *

      *
    • Using UnitOfWork with the PersistFilter inside a request is not recommended.
    • *
    • Using UnitOfWork with session-per-txn strategy is not terribly clever either.
    • *
    • Using UnitOfWork with session-per-request strategy but *outside* a request (i.e. in a * background or bootstrap thread) is probably a good use case.
    • *
    * * @author Dhanji R. Prasanna (dhanji@gmail com) */ public interface UnitOfWork { /** * Starts a Unit Of Work. Underneath, causes a session to the data layer to be opened. If there * is already one open, the invocation will do nothing. In this way, you can define arbitrary * units-of-work that nest within one another safely. * * Transaction semantics are not affected. */ void begin(); /** * Declares an end to the current Unit of Work. Underneath, causes any open session to the data * layer to close. If there is no Unit of work open, then the call returns silently. You can * safely invoke end() repeatedly. *

    * Transaction semantics are not affected. */ void end(); } sisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/Transactional.java0000644000175000017500000000466511704661106031550 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** *

    Any method or class marked with this annotation will be considered for transactionality. * Consult the documentation on http://code.google.com/p/google-guice for detailed semantics. * Marking a method {@code @Transactional} will start a new transaction before the method * executes and commit it after the method returns. *

    * If the method throws an exception, the transaction will be rolled back unless * you have specifically requested not to in the {@link #ignore()} clause. *

    * Similarly, the set of exceptions that will trigger a rollback can be defined in * the {@link #rollbackOn()} clause. By default, only unchecked exceptions trigger a * rollback. * * @author Dhanji R. Prasanna (dhanji@gmail.com) */ @Target({ ElementType.METHOD, ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface Transactional { /** * A list of exceptions to rollback on, if thrown by the transactional method. * These exceptions are propagated correctly after a rollback. */ Class[] rollbackOn() default RuntimeException.class; /** * A list of exceptions to not rollback on. A caveat to the rollbackOn clause. * The disjunction of rollbackOn and ignore represents the list of exceptions * that will trigger a rollback. * The complement of rollbackOn and the universal set plus any exceptions in the * ignore set represents the list of exceptions that will trigger a commit. * Note that ignore exceptions take precedence over rollbackOn, but with subtype * granularity. */ Class[] ignore() default { }; } sisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/PersistService.java0000644000175000017500000000304411704661106031706 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist; /** * Persistence provider service. Use this to manage the overall * startup and stop of the persistence module(s). * * TODO(dhanji): Integrate with Service API when appropriate. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public interface PersistService { /** * Starts the underlying persistence engine and makes guice-persist ready for * use. For instance, with JPA, it creates an EntityManagerFactory and may * open connection pools. This method must be called by your code prior to * using any guice-persist or JPA artifacts. If already started, * calling this method does nothing, if already stopped, it also does * nothing. */ void start(); /** * Stops the underlying persistence engine. For instance, with JPA, it * closes the {@code EntityManagerFactory}. If already stopped, calling this * method does nothing. If not yet started, it also does nothing. */ void stop(); } sisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/PersistModule.java0000644000175000017500000000330511704661106031533 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist; import static com.google.inject.matcher.Matchers.annotatedWith; import static com.google.inject.matcher.Matchers.any; import com.google.inject.AbstractModule; import org.aopalliance.intercept.MethodInterceptor; /** * Install this module to add guice-persist library support for JPA persistence * providers. * * @author dhanji@gmail.com (Dhanji R. Prasanna) */ public abstract class PersistModule extends AbstractModule { @Override protected final void configure() { configurePersistence(); requireBinding(PersistService.class); requireBinding(UnitOfWork.class); /*if[AOP]*/ // wrapping in an if[AOP] just to allow this to compile in NO_AOP -- it won't be used // class-level @Transacational bindInterceptor(annotatedWith(Transactional.class), any(), getTransactionInterceptor()); // method-level @Transacational bindInterceptor(any(), annotatedWith(Transactional.class), getTransactionInterceptor()); /*end[AOP]*/ } protected abstract void configurePersistence(); protected abstract MethodInterceptor getTransactionInterceptor(); } sisu-guice-sisu-guice-3.1.1/extensions/persist/src/com/google/inject/persist/PersistFilter.java0000644000175000017500000000623011704661106031533 0ustar tonytony/** * Copyright (C) 2010 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.persist; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; /** * Apply this filter to enable the HTTP Request unit of work and to have * guice-persist manage the lifecycle of active units of work. * The filter automatically starts and stops the relevant {@link PersistService} * upon {@link javax.servlet.Filter#init(javax.servlet.FilterConfig)} and * {@link javax.servlet.Filter#destroy()} respectively. * *

    To be able to use the open session-in-view pattern (i.e. work per request), * register this filter once in your Guice {@code ServletModule}. It is * important that you register this filter before any other filter. * * For multiple providers, you should register this filter once per provider, inside * a private module for each persist module installed (this must be the same private * module where the specific persist module is itself installed). * *

    * Example configuration: *

    {@code
     *  public class MyModule extends ServletModule {
     *    public void configureServlets() {
     *      filter("/*").through(PersistFilter.class);
     *
     *      serve("/index.html").with(MyHtmlServlet.class);
     *      // Etc.
     *    }
     *  }
     * }
    *

    * This filter is thread safe and allows you to create injectors concurrently * and deploy multiple guice-persist modules within the same injector, or even * multiple injectors with persist modules withing the same JVM or web app. *

    * This filter requires the Guice Servlet extension. * * @author Dhanji R. Prasanna (dhanji@gmail.com) */ @Singleton public final class PersistFilter implements Filter { private final UnitOfWork unitOfWork; private final PersistService persistService; @Inject public PersistFilter(UnitOfWork unitOfWork, PersistService persistService) { this.unitOfWork = unitOfWork; this.persistService = persistService; } public void init(FilterConfig filterConfig) throws ServletException { persistService.start(); } public void destroy() { persistService.stop(); } public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException { unitOfWork.begin(); try { filterChain.doFilter(servletRequest, servletResponse); } finally { unitOfWork.end(); } } } sisu-guice-sisu-guice-3.1.1/extensions/persist/pom.xml0000644000175000017500000000265711704661106021631 0ustar tonytony 4.0.0 org.sonatype.sisu.inject guice-extensions 3.1.1 guice-persist Sisu Guice - Extensions - Persist javax.persistence persistence-api 1.0 provided javax.servlet servlet-api 2.5 provided org.slf4j slf4j-simple 1.6.3 test org.hibernate hibernate-entitymanager 3.4.0.GA test org.hsqldb hsqldb-j5 2.2.4 test sisu-guice-sisu-guice-3.1.1/extensions/persist/persist.iml0000644000175000017500000000217011704661106022476 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/persist/build.xml0000644000175000017500000000133511704661106022125 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/persist/build.properties0000644000175000017500000000025111704661106023515 0ustar tonytonylib.dir=../../lib ext.lib.dir=lib src.dir=src test.dir=test build.dir=build test.class=com.google.inject.persist.AllTests module=com.google.inject.persist fragment=true sisu-guice-sisu-guice-3.1.1/extensions/multibindings/0000755000175000017500000000000011704661106021461 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/multibindings/test/0000755000175000017500000000000011704661106022440 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/multibindings/test/com/0000755000175000017500000000000011704661106023216 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/multibindings/test/com/google/0000755000175000017500000000000011704661106024472 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/multibindings/test/com/google/inject/0000755000175000017500000000000011704661106025746 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/multibindings/test/com/google/inject/multibindings/0000755000175000017500000000000011704661106030616 5ustar tonytony././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/multibindings/test/com/google/inject/multibindings/SpiUtils.javasisu-guice-sisu-guice-3.1.1/extensions/multibindings/test/com/google/inject/multibindings/SpiUtils.j0000644000175000017500000005277211704661106032562 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.multibindings; import static com.google.inject.multibindings.MapBinder.entryOfProviderOf; import static com.google.inject.multibindings.MapBinder.mapOf; import static com.google.inject.multibindings.MapBinder.mapOfProviderOf; import static com.google.inject.multibindings.MapBinder.mapOfSetOfProviderOf; import static com.google.inject.multibindings.Multibinder.setOf; import static com.google.inject.multibindings.SpiUtils.BindType.INSTANCE; import static com.google.inject.multibindings.SpiUtils.BindType.LINKED; import static com.google.inject.multibindings.SpiUtils.BindType.PROVIDER_INSTANCE; import static com.google.inject.multibindings.SpiUtils.VisitType.BOTH; import static com.google.inject.multibindings.SpiUtils.VisitType.INJECTOR; import static com.google.inject.multibindings.SpiUtils.VisitType.MODULE; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import com.google.common.collect.Lists; import com.google.inject.Binding; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.TypeLiteral; import com.google.inject.spi.DefaultBindingTargetVisitor; import com.google.inject.spi.Element; import com.google.inject.spi.Elements; import com.google.inject.spi.InstanceBinding; import com.google.inject.spi.LinkedKeyBinding; import com.google.inject.spi.ProviderInstanceBinding; import com.google.inject.spi.ProviderLookup; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; /** * Utilities for testing the Multibinder & MapBinder extension SPI. * * @author sameb@google.com (Sam Berlin) */ public class SpiUtils { /** The kind of test we should perform. A live Injector, a raw Elements (Module) test, or both. */ enum VisitType { INJECTOR, MODULE, BOTH } /** * Asserts that MapBinderBinding visitors for work correctly. * * @param The type of the binding * @param mapKey The key the map belongs to. * @param keyType the TypeLiteral of the key of the map * @param valueType the TypeLiteral of the value of the map * @param modules The modules that define the mapbindings * @param visitType The kind of test we should perform. A live Injector, a raw Elements (Module) test, or both. * @param allowDuplicates If duplicates are allowed. * @param expectedMapBindings The number of other mapbinders we expect to see. * @param results The kind of bindings contained in the mapbinder. */ static void assertMapVisitor(Key mapKey, TypeLiteral keyType, TypeLiteral valueType, Iterable modules, VisitType visitType, boolean allowDuplicates, int expectedMapBindings, MapResult... results) { if(visitType == null) { fail("must test something"); } if (visitType == BOTH || visitType == INJECTOR) { mapInjectorTest(mapKey, keyType, valueType, modules, allowDuplicates, expectedMapBindings, results); } if (visitType == BOTH || visitType == MODULE) { mapModuleTest(mapKey, keyType, valueType, modules, allowDuplicates, expectedMapBindings, results); } } @SuppressWarnings("unchecked") private static void mapInjectorTest(Key mapKey, TypeLiteral keyType, TypeLiteral valueType, Iterable modules, boolean allowDuplicates, int expectedMapBindings, MapResult... results) { Injector injector = Guice.createInjector(modules); Visitor visitor = new Visitor(); Binding mapBinding = injector.getBinding(mapKey); MapBinderBinding mapbinder = (MapBinderBinding)mapBinding.acceptTargetVisitor(visitor); assertNotNull(mapbinder); assertEquals(keyType, mapbinder.getKeyTypeLiteral()); assertEquals(valueType, mapbinder.getValueTypeLiteral()); assertEquals(allowDuplicates, mapbinder.permitsDuplicates()); List>> entries = Lists.newArrayList(mapbinder.getEntries()); List mapResults = Lists.newArrayList(results); assertEquals("wrong entries, expected: " + mapResults + ", but was: " + entries, mapResults.size(), entries.size()); for(MapResult result : mapResults) { Map.Entry> found = null; for(Map.Entry> entry : entries) { Object key = entry.getKey(); Binding value = entry.getValue(); if(!key.equals(result.k)) { continue; } switch (result.v.type) { case INSTANCE: if (value instanceof InstanceBinding && ((InstanceBinding) value).getInstance().equals(result.v.instance)) { found = entry; } break; case LINKED: if (value instanceof LinkedKeyBinding && ((LinkedKeyBinding) value).getKey().equals(result.v.key)) { found = entry; } break; case PROVIDER_INSTANCE: if (value instanceof ProviderInstanceBinding && ((ProviderInstanceBinding) value).getProviderInstance().get().equals( result.v.instance)) { found = entry; } break; } } if(found == null) { fail("Could not find entry: " + result + " in remaining entries: " + entries); } else { assertTrue(mapbinder.containsElement(found.getValue())); entries.remove(found); } } if(!entries.isEmpty()) { fail("Found all entries of: " + mapResults + ", but more were left over: " + entries); } Key mapOfProvider = adapt(mapKey, mapOfProviderOf(keyType, valueType)); Key mapOfSetOfProvider = adapt(mapKey, mapOfSetOfProviderOf(keyType, valueType)); Key mapOfSet = adapt(mapKey, mapOf(keyType, setOf(valueType))); Key setOfEntry = adapt(mapKey, setOf(entryOfProviderOf(keyType, valueType))); boolean entrySetMatch = false; boolean mapProviderMatch = false; boolean mapSetMatch = false; boolean mapSetProviderMatch = false; List otherMapBindings = Lists.newArrayList(); List otherMatches = Lists.newArrayList(); for(Binding b : injector.getAllBindings().values()) { boolean contains = mapbinder.containsElement(b); Object visited = b.acceptTargetVisitor(visitor); if(visited instanceof MapBinderBinding) { if(visited.equals(mapbinder)) { assertTrue(contains); } else { otherMapBindings.add(visited); } } else if(b.getKey().equals(mapOfProvider)) { assertTrue(contains); mapProviderMatch = true; } else if(b.getKey().equals(mapOfSet)) { assertTrue(contains); mapSetMatch = true; } else if(b.getKey().equals(mapOfSetOfProvider)) { assertTrue(contains); mapSetProviderMatch = true; } else if(b.getKey().equals(setOfEntry)) { assertTrue(contains); entrySetMatch = true; // Validate that this binding is also a MultibinderBinding. assertTrue(b.acceptTargetVisitor(visitor) instanceof MultibinderBinding); } else if (contains) { otherMatches.add(b); } } int sizeOfOther = otherMatches.size(); if(allowDuplicates) { sizeOfOther--; // account for 1 duplicate binding } sizeOfOther = sizeOfOther / 2; // account for 1 value & 1 Map.Entry of each expected binding. assertEquals("Incorrect other matches: " + otherMatches, mapResults.size(), sizeOfOther); assertTrue(entrySetMatch); assertTrue(mapProviderMatch); assertEquals(allowDuplicates, mapSetMatch); assertEquals(allowDuplicates, mapSetProviderMatch); assertEquals("other MapBindings found: " + otherMapBindings, expectedMapBindings, otherMapBindings.size()); } /** Adapts a key, keeping the original annotation, using the new type literal. */ private static Key adapt(Key mapKey, TypeLiteral resultType) { if(mapKey.getAnnotation() != null) { return Key.get(resultType, mapKey.getAnnotation()); } else if(mapKey.getAnnotationType() != null) { return Key.get(resultType, mapKey.getAnnotationType()); } else { return Key.get(resultType); } } @SuppressWarnings("unchecked") private static void mapModuleTest(Key mapKey, TypeLiteral keyType, TypeLiteral valueType, Iterable modules, boolean allowDuplicates, int expectedMapBindings, MapResult... results) { List elements = Elements.getElements(modules); Visitor visitor = new Visitor(); MapBinderBinding mapbinder = null; for(Element element : elements) { if(element instanceof Binding && ((Binding)element).getKey().equals(mapKey)) { mapbinder = (MapBinderBinding)((Binding)element).acceptTargetVisitor(visitor); break; } } assertNotNull(mapbinder); assertEquals(keyType, mapbinder.getKeyTypeLiteral()); assertEquals(valueType, mapbinder.getValueTypeLiteral()); List mapResults = Lists.newArrayList(results); Key mapOfProvider = adapt(mapKey, mapOfProviderOf(keyType, valueType)); Key mapOfSetOfProvider = adapt(mapKey, mapOfSetOfProviderOf(keyType, valueType)); Key mapOfSet = adapt(mapKey, mapOf(keyType, setOf(valueType))); Key setOfEntry = adapt(mapKey, setOf(entryOfProviderOf(keyType, valueType))); boolean entrySetMatch = false; boolean mapProviderMatch = false; boolean mapSetMatch = false; boolean mapSetProviderMatch = false; List otherMapBindings = Lists.newArrayList(); List otherMatches = Lists.newArrayList(); List otherElements = Lists.newArrayList(); for(Element element : elements) { boolean contains = mapbinder.containsElement(element); if(!contains) { otherElements.add(element); } boolean matched = false; Key key = null; Binding b = null; if(element instanceof Binding) { b = (Binding)element; key = b.getKey(); Object visited = b.acceptTargetVisitor(visitor); if(visited instanceof MapBinderBinding) { matched = true; if(visited.equals(mapbinder)) { assertTrue(contains); } else { otherMapBindings.add(visited); } } } else if(element instanceof ProviderLookup) { key = ((ProviderLookup)element).getKey(); } if(!matched && key != null) { if(key.equals(mapOfProvider)) { matched = true; assertTrue(contains); mapProviderMatch = true; } else if(key.equals(mapOfSet)) { matched = true; assertTrue(contains); mapSetMatch = true; } else if(key.equals(mapOfSetOfProvider)) { matched = true; assertTrue(contains); mapSetProviderMatch = true; } else if(key.equals(setOfEntry)) { matched = true; assertTrue(contains); entrySetMatch = true; // Validate that this binding is also a MultibinderBinding. if(b != null) { assertTrue(b.acceptTargetVisitor(visitor) instanceof MultibinderBinding); } } } if(!matched && contains) { otherMatches.add(element); } } int otherMatchesSize = otherMatches.size(); if(allowDuplicates) { otherMatchesSize--; // allow for 1 duplicate binding } otherMatchesSize = otherMatchesSize / 3; // value, ProviderLookup per value, Map.Entry per value assertEquals("incorrect number of contains, leftover matches: " + otherMatches, mapResults .size(), otherMatchesSize); assertTrue(entrySetMatch); assertTrue(mapProviderMatch); assertEquals(allowDuplicates, mapSetMatch); assertEquals(allowDuplicates, mapSetProviderMatch); assertEquals("other MapBindings found: " + otherMapBindings, expectedMapBindings, otherMapBindings.size()); // Validate that we can construct an injector out of the remaining bindings. Guice.createInjector(Elements.getModule(otherElements)); } /** * Asserts that MultibinderBinding visitors work correctly. * * @param The type of the binding * @param setKey The key the set belongs to. * @param elementType the TypeLiteral of the element * @param modules The modules that define the multibindings * @param visitType The kind of test we should perform. A live Injector, a raw Elements (Module) test, or both. * @param allowDuplicates If duplicates are allowed. * @param expectedMultibindings The number of other multibinders we expect to see. * @param results The kind of bindings contained in the multibinder. */ static void assertSetVisitor(Key setKey, TypeLiteral elementType, Iterable modules, VisitType visitType, boolean allowDuplicates, int expectedMultibindings, BindResult... results) { if(visitType == null) { fail("must test something"); } if(visitType == BOTH || visitType == INJECTOR) { setInjectorTest(setKey, elementType, modules, allowDuplicates, expectedMultibindings, results); } if(visitType == BOTH || visitType == MODULE) { setModuleTest(setKey, elementType, modules, allowDuplicates, expectedMultibindings, results); } } @SuppressWarnings("unchecked") private static void setInjectorTest(Key setKey, TypeLiteral elementType, Iterable modules, boolean allowDuplicates, int otherMultibindings, BindResult... results) { Injector injector = Guice.createInjector(modules); Visitor visitor = new Visitor(); Binding binding = injector.getBinding(setKey); MultibinderBinding multibinder = (MultibinderBinding)binding.acceptTargetVisitor(visitor); assertNotNull(multibinder); assertEquals(elementType, multibinder.getElementTypeLiteral()); assertEquals(allowDuplicates, multibinder.permitsDuplicates()); List> elements = Lists.newArrayList(multibinder.getElements()); List bindResults = Lists.newArrayList(results); assertEquals("wrong bind elements, expected: " + bindResults + ", but was: " + multibinder.getElements(), bindResults.size(), elements.size()); for(BindResult result : bindResults) { Binding found = null; for(Binding item : elements) { switch (result.type) { case INSTANCE: if (item instanceof InstanceBinding && ((InstanceBinding) item).getInstance().equals(result.instance)) { found = item; } break; case LINKED: if (item instanceof LinkedKeyBinding && ((LinkedKeyBinding) item).getKey().equals(result.key)) { found = item; } break; case PROVIDER_INSTANCE: if (item instanceof ProviderInstanceBinding && ((ProviderInstanceBinding) item).getProviderInstance().get().equals( result.instance)) { found = item; } break; } } if(found == null) { fail("Could not find element: " + result + " in remaining elements: " + elements); } else { elements.remove(found); } } if(!elements.isEmpty()) { fail("Found all elements of: " + bindResults + ", but more were left over: " + elements); } Set setOfElements = new HashSet(multibinder.getElements()); List otherMultibinders = Lists.newArrayList(); List otherContains = Lists.newArrayList(); for(Binding b : injector.getAllBindings().values()) { boolean contains = multibinder.containsElement(b); Object visited = b.acceptTargetVisitor(visitor); if(visited != null) { if(visited.equals(multibinder)) { assertTrue(contains); } else { otherMultibinders.add(visited); } } else if(setOfElements.contains(b)) { assertTrue(contains); } else if(contains) { otherContains.add(b); } } if(allowDuplicates) { assertEquals("contained more than it should: " + otherContains, 1, otherContains.size()); } else { assertTrue("contained more than it should: " + otherContains, otherContains.isEmpty()); } assertEquals("other multibindings found: " + otherMultibinders, otherMultibindings, otherMultibinders.size()); } @SuppressWarnings("unchecked") private static void setModuleTest(Key setKey, TypeLiteral elementType, Iterable modules, boolean allowDuplicates, int otherMultibindings, BindResult... results) { List bindResults = Lists.newArrayList(results); List elements = Elements.getElements(modules); Visitor visitor = new Visitor(); MultibinderBinding multibinder = null; for(Element element : elements) { if(element instanceof Binding && ((Binding)element).getKey().equals(setKey)) { multibinder = (MultibinderBinding)((Binding)element).acceptTargetVisitor(visitor); break; } } assertNotNull(multibinder); assertEquals(elementType, multibinder.getElementTypeLiteral()); List otherMultibinders = Lists.newArrayList(); Set otherContains = new HashSet(); List otherElements = Lists.newArrayList(); for(Element element : elements) { boolean contains = multibinder.containsElement(element); if(!contains) { otherElements.add(element); } boolean matched = false; if(element instanceof Binding) { Binding binding = (Binding)element; Object visited = binding.acceptTargetVisitor(visitor); if(visited != null) { matched = true; if(visited.equals(multibinder)) { assertTrue(contains); } else { otherMultibinders.add(visited); } } } if(!matched && contains) { otherContains.add(element); } } if(allowDuplicates) { assertEquals("wrong contained elements: " + otherContains, bindResults.size() + 1, otherContains.size()); } else { assertEquals("wrong contained elements: " + otherContains, bindResults.size(), otherContains.size()); } assertEquals("other multibindings found: " + otherMultibinders, otherMultibindings, otherMultibinders.size()); // Validate that we can construct an injector out of the remaining bindings. Guice.createInjector(Elements.getModule(otherElements)); } static MapResult instance(K k, V v) { return new MapResult(k, new BindResult(INSTANCE, v, null)); } static MapResult linked(K k, Class clazz) { return new MapResult(k, new BindResult(LINKED, null, Key.get(clazz))); } static MapResult linked(K k, Key key) { return new MapResult(k, new BindResult(LINKED, null, key)); } static MapResult providerInstance(K k, V v) { return new MapResult(k, new BindResult(PROVIDER_INSTANCE, v, null)); } private static class MapResult { private final K k; private final BindResult v; MapResult(K k, BindResult v) { this.k = k; this.v = v; } @Override public String toString() { return "entry[key[" + k + "],value[" + v + "]]"; } } static BindResult instance(T t) { return new BindResult(INSTANCE, t, null); } static BindResult linked(Class clazz) { return new BindResult(LINKED, null, Key.get(clazz)); } static BindResult linked(Key key) { return new BindResult(LINKED, null, key); } static BindResult providerInstance(T t) { return new BindResult(PROVIDER_INSTANCE, t, null); } /** The kind of binding. */ static enum BindType { INSTANCE, LINKED, PROVIDER_INSTANCE } /** The result of the binding. */ private static class BindResult { private final BindType type; private final Key key; private final T instance; private BindResult(BindType type, T instance, Key key) { this.type = type; this.instance = instance; this.key = key; } @Override public String toString() { switch(type) { case INSTANCE: return "instance[" + instance + "]"; case LINKED: return "linkedKey[" + key + "]"; case PROVIDER_INSTANCE: return "providerInstance[" + instance + "]"; } return null; } } private static class Visitor extends DefaultBindingTargetVisitor implements MultibindingsTargetVisitor { public Object visit(MultibinderBinding multibinding) { return multibinding; } public Object visit(MapBinderBinding mapbinding) { return mapbinding; } } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/multibindings/test/com/google/inject/multibindings/MultibinderTest.javasisu-guice-sisu-guice-3.1.1/extensions/multibindings/test/com/google/inject/multibindings/Multibinde0000644000175000017500000006043311704661106032643 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.multibindings; import static com.google.inject.Asserts.assertContains; import static com.google.inject.multibindings.SpiUtils.VisitType.BOTH; import static com.google.inject.multibindings.SpiUtils.VisitType.MODULE; import static com.google.inject.multibindings.SpiUtils.assertSetVisitor; import static com.google.inject.multibindings.SpiUtils.instance; import static com.google.inject.multibindings.SpiUtils.providerInstance; import static com.google.inject.name.Names.named; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.inject.AbstractModule; import com.google.inject.Binding; import com.google.inject.BindingAnnotation; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provider; import com.google.inject.ProvisionException; import com.google.inject.Stage; import com.google.inject.TypeLiteral; import com.google.inject.name.Names; import com.google.inject.spi.Dependency; import com.google.inject.spi.HasDependencies; import com.google.inject.spi.InstanceBinding; import com.google.inject.spi.LinkedKeyBinding; import com.google.inject.util.Modules; import com.google.inject.util.Providers; import junit.framework.TestCase; import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Method; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; /** * @author jessewilson@google.com (Jesse Wilson) */ public class MultibinderTest extends TestCase { final TypeLiteral> setOfString = new TypeLiteral>() {}; final TypeLiteral> setOfInteger = new TypeLiteral>() {}; final TypeLiteral stringType = TypeLiteral.get(String.class); final TypeLiteral intType = TypeLiteral.get(Integer.class); public void testMultibinderAggregatesMultipleModules() { Module abc = new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.addBinding().toInstance("A"); multibinder.addBinding().toInstance("B"); multibinder.addBinding().toInstance("C"); } }; Module de = new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.addBinding().toInstance("D"); multibinder.addBinding().toInstance("E"); } }; Injector injector = Guice.createInjector(abc, de); Key> setKey = Key.get(setOfString); Set abcde = injector.getInstance(setKey); Set results = setOf("A", "B", "C", "D", "E"); assertEquals(results, abcde); assertSetVisitor(setKey, stringType, setOf(abc, de), BOTH, false, 0, instance("A"), instance("B"), instance("C"), instance("D"), instance("E")); } public void testMultibinderAggregationForAnnotationInstance() { Module module = new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class, Names.named("abc")); multibinder.addBinding().toInstance("A"); multibinder.addBinding().toInstance("B"); multibinder = Multibinder.newSetBinder(binder(), String.class, Names.named("abc")); multibinder.addBinding().toInstance("C"); } }; Injector injector = Guice.createInjector(module); Key> setKey = Key.get(setOfString, Names.named("abc")); Set abc = injector.getInstance(setKey); Set results = setOf("A", "B", "C"); assertEquals(results, abc); assertSetVisitor(setKey, stringType, setOf(module), BOTH, false, 0, instance("A"), instance("B"), instance("C")); } public void testMultibinderAggregationForAnnotationType() { Module module = new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class, Abc.class); multibinder.addBinding().toInstance("A"); multibinder.addBinding().toInstance("B"); multibinder = Multibinder.newSetBinder(binder(), String.class, Abc.class); multibinder.addBinding().toInstance("C"); } }; Injector injector = Guice.createInjector(module); Key> setKey = Key.get(setOfString, Abc.class); Set abcde = injector.getInstance(setKey); Set results = setOf("A", "B", "C"); assertEquals(results, abcde); assertSetVisitor(setKey, stringType, setOf(module), BOTH, false, 0, instance("A"), instance("B"), instance("C")); } public void testMultibinderWithMultipleAnnotationValueSets() { Module module = new AbstractModule() { protected void configure() { Multibinder abcMultibinder = Multibinder.newSetBinder(binder(), String.class, named("abc")); abcMultibinder.addBinding().toInstance("A"); abcMultibinder.addBinding().toInstance("B"); abcMultibinder.addBinding().toInstance("C"); Multibinder deMultibinder = Multibinder.newSetBinder(binder(), String.class, named("de")); deMultibinder.addBinding().toInstance("D"); deMultibinder.addBinding().toInstance("E"); } }; Injector injector = Guice.createInjector(module); Key> abcSetKey = Key.get(setOfString, named("abc")); Set abc = injector.getInstance(abcSetKey); Key> deSetKey = Key.get(setOfString, named("de")); Set de = injector.getInstance(deSetKey); Set abcResults = setOf("A", "B", "C"); assertEquals(abcResults, abc); Set deResults = setOf("D", "E"); assertEquals(deResults, de); assertSetVisitor(abcSetKey, stringType, setOf(module), BOTH, false, 1, instance("A"), instance("B"), instance("C")); assertSetVisitor(deSetKey, stringType, setOf(module), BOTH, false, 1, instance("D"), instance("E")); } public void testMultibinderWithMultipleAnnotationTypeSets() { Module module = new AbstractModule() { protected void configure() { Multibinder abcMultibinder = Multibinder.newSetBinder(binder(), String.class, Abc.class); abcMultibinder.addBinding().toInstance("A"); abcMultibinder.addBinding().toInstance("B"); abcMultibinder.addBinding().toInstance("C"); Multibinder deMultibinder = Multibinder.newSetBinder(binder(), String.class, De.class); deMultibinder.addBinding().toInstance("D"); deMultibinder.addBinding().toInstance("E"); } }; Injector injector = Guice.createInjector(module); Key> abcSetKey = Key.get(setOfString, Abc.class); Set abc = injector.getInstance(abcSetKey); Key> deSetKey = Key.get(setOfString, De.class); Set de = injector.getInstance(deSetKey); Set abcResults = setOf("A", "B", "C"); assertEquals(abcResults, abc); Set deResults = setOf("D", "E"); assertEquals(deResults, de); assertSetVisitor(abcSetKey, stringType, setOf(module), BOTH, false, 1, instance("A"), instance("B"), instance("C")); assertSetVisitor(deSetKey, stringType, setOf(module), BOTH, false, 1, instance("D"), instance("E")); } public void testMultibinderWithMultipleSetTypes() { Module module = new AbstractModule() { protected void configure() { Multibinder.newSetBinder(binder(), String.class) .addBinding().toInstance("A"); Multibinder.newSetBinder(binder(), Integer.class) .addBinding().toInstance(1); } }; Injector injector = Guice.createInjector(module); assertEquals(setOf("A"), injector.getInstance(Key.get(setOfString))); assertEquals(setOf(1), injector.getInstance(Key.get(setOfInteger))); assertSetVisitor(Key.get(setOfString), stringType, setOf(module), BOTH, false, 1, instance("A")); assertSetVisitor(Key.get(setOfInteger), intType, setOf(module), BOTH, false, 1, instance(1)); } public void testMultibinderWithEmptySet() { Module module = new AbstractModule() { protected void configure() { Multibinder.newSetBinder(binder(), String.class); } }; Injector injector = Guice.createInjector(module); Set set = injector.getInstance(Key.get(setOfString)); assertEquals(Collections.emptySet(), set); assertSetVisitor(Key.get(setOfString), stringType, setOf(module), BOTH, false, 0); } public void testMultibinderSetIsUnmodifiable() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { Multibinder.newSetBinder(binder(), String.class) .addBinding().toInstance("A"); } }); Set set = injector.getInstance(Key.get(setOfString)); try { set.clear(); fail(); } catch(UnsupportedOperationException expected) { } } public void testMultibinderSetIsLazy() { Module module = new AbstractModule() { protected void configure() { Multibinder.newSetBinder(binder(), Integer.class) .addBinding().toProvider(new Provider() { int nextValue = 1; public Integer get() { return nextValue++; } }); } }; Injector injector = Guice.createInjector(module); assertEquals(setOf(1), injector.getInstance(Key.get(setOfInteger))); assertEquals(setOf(2), injector.getInstance(Key.get(setOfInteger))); assertEquals(setOf(3), injector.getInstance(Key.get(setOfInteger))); assertSetVisitor(Key.get(setOfInteger), intType, setOf(module), BOTH, false, 0, providerInstance(1)); } public void testMultibinderSetForbidsDuplicateElements() { Module module = new AbstractModule() { protected void configure() { final Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.addBinding().toInstance("A"); multibinder.addBinding().toInstance("A"); } }; Injector injector = Guice.createInjector(module); try { injector.getInstance(Key.get(setOfString)); fail(); } catch(ProvisionException expected) { assertContains(expected.getMessage(), "1) Set injection failed due to duplicated element \"A\""); } // But we can still visit the module! assertSetVisitor(Key.get(setOfString), stringType, setOf(module), MODULE, false, 0, instance("A"), instance("A")); } public void testMultibinderSetPermitDuplicateElements() { Module ab = new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.addBinding().toInstance("A"); multibinder.addBinding().toInstance("B"); } }; Module bc = new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.permitDuplicates(); multibinder.addBinding().toInstance("B"); multibinder.addBinding().toInstance("C"); } }; Injector injector = Guice.createInjector(ab, bc); assertEquals(setOf("A", "B", "C"), injector.getInstance(Key.get(setOfString))); assertSetVisitor(Key.get(setOfString), stringType, setOf(ab, bc), BOTH, true, 0, instance("A"), instance("B"), instance("B"), instance("C")); } public void testMultibinderSetPermitDuplicateCallsToPermitDuplicates() { Module ab = new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.permitDuplicates(); multibinder.addBinding().toInstance("A"); multibinder.addBinding().toInstance("B"); } }; Module bc = new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.permitDuplicates(); multibinder.addBinding().toInstance("B"); multibinder.addBinding().toInstance("C"); } }; Injector injector = Guice.createInjector(ab, bc); assertEquals(setOf("A", "B", "C"), injector.getInstance(Key.get(setOfString))); assertSetVisitor(Key.get(setOfString), stringType, setOf(ab, bc), BOTH, true, 0, instance("A"), instance("B"), instance("B"), instance("C")); } public void testMultibinderSetForbidsNullElements() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { Multibinder.newSetBinder(binder(), String.class) .addBinding().toProvider(Providers.of(null)); } }); try { injector.getInstance(Key.get(setOfString)); fail(); } catch(ProvisionException expected) { assertContains(expected.getMessage(), "1) Set injection failed due to null element"); } } public void testSourceLinesInMultibindings() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { Multibinder.newSetBinder(binder(), Integer.class).addBinding(); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "No implementation for java.lang.Integer", "at " + getClass().getName()); } } /** * We just want to make sure that multibinder's binding depends on each of its values. We don't * really care about the underlying structure of those bindings, which are implementation details. */ public void testMultibinderDependencies() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.addBinding().toInstance("A"); multibinder.addBinding().to(Key.get(String.class, Names.named("b"))); bindConstant().annotatedWith(Names.named("b")).to("B"); } }); Binding> binding = injector.getBinding(new Key>() {}); HasDependencies withDependencies = (HasDependencies) binding; Set elements = Sets.newHashSet(); for (Dependency dependency : withDependencies.getDependencies()) { elements.add((String) injector.getInstance(dependency.getKey())); } assertEquals(ImmutableSet.of("A", "B"), elements); } /** * We just want to make sure that multibinder's binding depends on each of its values. We don't * really care about the underlying structure of those bindings, which are implementation details. */ public void testMultibinderDependenciesInToolStage() { Injector injector = Guice.createInjector(Stage.TOOL, new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.addBinding().toInstance("A"); multibinder.addBinding().to(Key.get(String.class, Names.named("b"))); bindConstant().annotatedWith(Names.named("b")).to("B"); }}); Binding> binding = injector.getBinding(new Key>() {}); HasDependencies withDependencies = (HasDependencies) binding; InstanceBinding instanceBinding = null; LinkedKeyBinding linkedBinding = null; // The non-tool stage test can test this by calling injector.getInstance to ensure // the right values are returned -- in tool stage we can't do that. It's also a // little difficult to validate the dependencies & bindings, because they're // bindings created internally within Multibinder. // To workaround this, we just validate that the dependencies lookup to a single // InstanceBinding whose value is "A" and another LinkedBinding whose target is // the Key of @Named("b") String=B for (Dependency dependency : withDependencies.getDependencies()) { Binding b = injector.getBinding(dependency.getKey()); if(b instanceof InstanceBinding) { if(instanceBinding != null) { fail("Already have an instance binding of: " + instanceBinding + ", and now want to add: " + b); } else { instanceBinding = (InstanceBinding)b; } } else if(b instanceof LinkedKeyBinding) { if(linkedBinding != null) { fail("Already have a linked binding of: " + linkedBinding + ", and now want to add: " + b); } else { linkedBinding = (LinkedKeyBinding)b; } } else { fail("Unexpected dependency of: " + dependency); } } assertNotNull(instanceBinding); assertNotNull(linkedBinding); assertEquals("A", instanceBinding.getInstance()); assertEquals(Key.get(String.class, Names.named("b")), linkedBinding.getLinkedKey()); } /** * Our implementation maintains order, but doesn't guarantee it in the API spec. * TODO: specify the iteration order? */ public void testBindOrderEqualsIterationOrder() { Injector injector = Guice.createInjector( new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.addBinding().toInstance("leonardo"); multibinder.addBinding().toInstance("donatello"); install(new AbstractModule() { protected void configure() { Multibinder.newSetBinder(binder(), String.class) .addBinding().toInstance("michaelangelo"); } }); } }, new AbstractModule() { protected void configure() { Multibinder.newSetBinder(binder(), String.class).addBinding().toInstance("raphael"); } }); List inOrder = ImmutableList.copyOf(injector.getInstance(Key.get(setOfString))); assertEquals(ImmutableList.of("leonardo", "donatello", "michaelangelo", "raphael"), inOrder); } @Retention(RUNTIME) @BindingAnnotation @interface Abc {} @Retention(RUNTIME) @BindingAnnotation @interface De {} private Set setOf(T... elements) { Set result = Sets.newHashSet(); result.addAll(Arrays.asList(elements)); return result; } /** * With overrides, we should get the union of all multibindings. */ public void testModuleOverrideAndMultibindings() { Module ab = new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.addBinding().toInstance("A"); multibinder.addBinding().toInstance("B"); } }; Module cd = new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.addBinding().toInstance("C"); multibinder.addBinding().toInstance("D"); } }; Module ef = new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.addBinding().toInstance("E"); multibinder.addBinding().toInstance("F"); } }; Module abcd = Modules.override(ab).with(cd); Injector injector = Guice.createInjector(abcd, ef); assertEquals(ImmutableSet.of("A", "B", "C", "D", "E", "F"), injector.getInstance(Key.get(setOfString))); assertSetVisitor(Key.get(setOfString), stringType, setOf(abcd, ef), BOTH, false, 0, instance("A"), instance("B"), instance("C"), instance("D"), instance("E"), instance("F")); } /** * With overrides, we should get the union of all multibindings. */ public void testModuleOverrideAndMultibindingsWithPermitDuplicates() { Module abc = new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.addBinding().toInstance("A"); multibinder.addBinding().toInstance("B"); multibinder.addBinding().toInstance("C"); multibinder.permitDuplicates(); } }; Module cd = new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.addBinding().toInstance("C"); multibinder.addBinding().toInstance("D"); multibinder.permitDuplicates(); } }; Module ef = new AbstractModule() { protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), String.class); multibinder.addBinding().toInstance("E"); multibinder.addBinding().toInstance("F"); multibinder.permitDuplicates(); } }; Module abcd = Modules.override(abc).with(cd); Injector injector = Guice.createInjector(abcd, ef); assertEquals(ImmutableSet.of("A", "B", "C", "D", "E", "F"), injector.getInstance(Key.get(setOfString))); assertSetVisitor(Key.get(setOfString), stringType, setOf(abcd, ef), BOTH, true, 0, instance("A"), instance("B"), instance("C"), instance("C"), instance("D"), instance("E"), instance("F")); } @BindingAnnotation @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) private static @interface Marker {} @Marker public void testMultibinderMatching() throws Exception { Method m = MultibinderTest.class.getDeclaredMethod("testMultibinderMatching"); assertNotNull(m); final Annotation marker = m.getAnnotation(Marker.class); Injector injector = Guice.createInjector(new AbstractModule() { @Override public void configure() { Multibinder mb1 = Multibinder.newSetBinder(binder(), Integer.class, Marker.class); Multibinder mb2 = Multibinder.newSetBinder(binder(), Integer.class, marker); mb1.addBinding().toInstance(1); mb2.addBinding().toInstance(2); // This assures us that the two binders are equivalent, so we expect the instance added to // each to have been added to one set. assertEquals(mb1, mb2); } }); TypeLiteral> t = new TypeLiteral>() {}; Set s1 = injector.getInstance(Key.get(t, Marker.class)); Set s2 = injector.getInstance(Key.get(t, marker)); // This assures us that the two sets are in fact equal. They may not be same set (as in Java // object identical), but we shouldn't expect that, since probably Guice creates the set each // time in case the elements are dependent on scope. assertEquals(s1, s2); // This ensures that MultiBinder is internally using the correct set name -- // making sure that instances of marker annotations have the same set name as // MarkerAnnotation.class. Set expected = new HashSet(); expected.add(1); expected.add(2); assertEquals(expected, s1); } public void failing_testSetAndMapValueConflict() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { Multibinder.newSetBinder(binder(), String.class) .addBinding().toInstance("A"); MapBinder.newMapBinder(binder(), String.class, String.class) .addBinding("B").toInstance("b"); } }); assertEquals(ImmutableSet.of("A"), injector.getInstance(Key.get(setOfString))); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/multibindings/test/com/google/inject/multibindings/MapBinderTest.javasisu-guice-sisu-guice-3.1.1/extensions/multibindings/test/com/google/inject/multibindings/MapBinderT0000644000175000017500000007006211704661106032533 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.multibindings; import static com.google.inject.Asserts.assertContains; import static com.google.inject.multibindings.SpiUtils.VisitType.BOTH; import static com.google.inject.multibindings.SpiUtils.VisitType.MODULE; import static com.google.inject.multibindings.SpiUtils.assertMapVisitor; import static com.google.inject.multibindings.SpiUtils.instance; import static com.google.inject.multibindings.SpiUtils.providerInstance; import static com.google.inject.name.Names.named; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import com.google.inject.AbstractModule; import com.google.inject.Binding; import com.google.inject.BindingAnnotation; import com.google.inject.ConfigurationException; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provider; import com.google.inject.ProvisionException; import com.google.inject.Stage; import com.google.inject.TypeLiteral; import com.google.inject.name.Names; import com.google.inject.spi.DefaultElementVisitor; import com.google.inject.spi.Dependency; import com.google.inject.spi.Element; import com.google.inject.spi.Elements; import com.google.inject.spi.HasDependencies; import com.google.inject.util.Modules; import com.google.inject.util.Providers; import junit.framework.TestCase; import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Method; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * @author dpb@google.com (David P. Baker) */ public class MapBinderTest extends TestCase { final TypeLiteral> mapOfString = new TypeLiteral>() {}; final TypeLiteral> mapOfInteger = new TypeLiteral>() {}; final TypeLiteral>> mapOfSetOfString = new TypeLiteral>>() {}; private final TypeLiteral stringType = TypeLiteral.get(String.class); private final TypeLiteral intType = TypeLiteral.get(Integer.class); private final TypeLiteral> stringSetType = new TypeLiteral>() {}; public void testMapBinderAggregatesMultipleModules() { Module abc = new AbstractModule() { @Override protected void configure() { MapBinder multibinder = MapBinder.newMapBinder( binder(), String.class, String.class); multibinder.addBinding("a").toInstance("A"); multibinder.addBinding("b").toInstance("B"); multibinder.addBinding("c").toInstance("C"); } }; Module de = new AbstractModule() { @Override protected void configure() { MapBinder multibinder = MapBinder.newMapBinder( binder(), String.class, String.class); multibinder.addBinding("d").toInstance("D"); multibinder.addBinding("e").toInstance("E"); } }; Injector injector = Guice.createInjector(abc, de); Map abcde = injector.getInstance(Key.get(mapOfString)); assertEquals(mapOf("a", "A", "b", "B", "c", "C", "d", "D", "e", "E"), abcde); assertMapVisitor(Key.get(mapOfString), stringType, stringType, setOf(abc, de), BOTH, false, 0, instance("a", "A"), instance("b", "B"), instance("c", "C"), instance("d", "D"), instance("e", "E")); } public void testMapBinderAggregationForAnnotationInstance() { Module module = new AbstractModule() { @Override protected void configure() { MapBinder multibinder = MapBinder.newMapBinder( binder(), String.class, String.class, Names.named("abc")); multibinder.addBinding("a").toInstance("A"); multibinder.addBinding("b").toInstance("B"); multibinder = MapBinder.newMapBinder( binder(), String.class, String.class, Names.named("abc")); multibinder.addBinding("c").toInstance("C"); } }; Injector injector = Guice.createInjector(module); Key> key = Key.get(mapOfString, Names.named("abc")); Map abc = injector.getInstance(key); assertEquals(mapOf("a", "A", "b", "B", "c", "C"), abc); assertMapVisitor(key, stringType, stringType, setOf(module), BOTH, false, 0, instance("a", "A"), instance("b", "B"), instance("c", "C")); } public void testMapBinderAggregationForAnnotationType() { Module module = new AbstractModule() { @Override protected void configure() { MapBinder multibinder = MapBinder.newMapBinder( binder(), String.class, String.class, Abc.class); multibinder.addBinding("a").toInstance("A"); multibinder.addBinding("b").toInstance("B"); multibinder = MapBinder.newMapBinder( binder(), String.class, String.class, Abc.class); multibinder.addBinding("c").toInstance("C"); } }; Injector injector = Guice.createInjector(module); Key> key = Key.get(mapOfString, Abc.class); Map abc = injector.getInstance(key); assertEquals(mapOf("a", "A", "b", "B", "c", "C"), abc); assertMapVisitor(key, stringType, stringType, setOf(module), BOTH, false, 0, instance("a", "A"), instance("b", "B"), instance("c", "C")); } public void testMapBinderWithMultipleAnnotationValueSets() { Module module = new AbstractModule() { @Override protected void configure() { MapBinder abcMapBinder = MapBinder.newMapBinder( binder(), String.class, String.class, named("abc")); abcMapBinder.addBinding("a").toInstance("A"); abcMapBinder.addBinding("b").toInstance("B"); abcMapBinder.addBinding("c").toInstance("C"); MapBinder deMapBinder = MapBinder.newMapBinder( binder(), String.class, String.class, named("de")); deMapBinder.addBinding("d").toInstance("D"); deMapBinder.addBinding("e").toInstance("E"); } }; Injector injector = Guice.createInjector(module); Key> abcKey = Key.get(mapOfString, named("abc")); Map abc = injector.getInstance(abcKey); Key> deKey = Key.get(mapOfString, named("de")); Map de = injector.getInstance(deKey); assertEquals(mapOf("a", "A", "b", "B", "c", "C"), abc); assertEquals(mapOf("d", "D", "e", "E"), de); assertMapVisitor(abcKey, stringType, stringType, setOf(module), BOTH, false, 1, instance("a", "A"), instance("b", "B"), instance("c", "C")); assertMapVisitor(deKey, stringType, stringType, setOf(module), BOTH, false, 1, instance("d", "D"), instance("e", "E")); } public void testMapBinderWithMultipleAnnotationTypeSets() { Module module = new AbstractModule() { @Override protected void configure() { MapBinder abcMapBinder = MapBinder.newMapBinder( binder(), String.class, String.class, Abc.class); abcMapBinder.addBinding("a").toInstance("A"); abcMapBinder.addBinding("b").toInstance("B"); abcMapBinder.addBinding("c").toInstance("C"); MapBinder deMapBinder = MapBinder.newMapBinder( binder(), String.class, String.class, De.class); deMapBinder.addBinding("d").toInstance("D"); deMapBinder.addBinding("e").toInstance("E"); } }; Injector injector = Guice.createInjector(module); Key> abcKey = Key.get(mapOfString, Abc.class); Map abc = injector.getInstance(abcKey); Key> deKey = Key.get(mapOfString, De.class); Map de = injector.getInstance(deKey); assertEquals(mapOf("a", "A", "b", "B", "c", "C"), abc); assertEquals(mapOf("d", "D", "e", "E"), de); assertMapVisitor(abcKey, stringType, stringType, setOf(module), BOTH, false, 1, instance("a", "A"), instance("b", "B"), instance("c", "C")); assertMapVisitor(deKey, stringType, stringType, setOf(module), BOTH, false, 1, instance("d", "D"), instance("e", "E")); } public void testMapBinderWithMultipleTypes() { Module module = new AbstractModule() { @Override protected void configure() { MapBinder.newMapBinder(binder(), String.class, String.class) .addBinding("a").toInstance("A"); MapBinder.newMapBinder(binder(), String.class, Integer.class) .addBinding("1").toInstance(1); } }; Injector injector = Guice.createInjector(module); assertEquals(mapOf("a", "A"), injector.getInstance(Key.get(mapOfString))); assertEquals(mapOf("1", 1), injector.getInstance(Key.get(mapOfInteger))); assertMapVisitor(Key.get(mapOfString), stringType, stringType, setOf(module), BOTH, false, 1, instance("a", "A")); assertMapVisitor(Key.get(mapOfInteger), stringType, intType, setOf(module), BOTH, false, 1, instance("1", 1)); } public void testMapBinderWithEmptyMap() { Module module = new AbstractModule() { @Override protected void configure() { MapBinder.newMapBinder(binder(), String.class, String.class); } }; Injector injector = Guice.createInjector(module); Map map = injector.getInstance(Key.get(mapOfString)); assertEquals(Collections.emptyMap(), map); assertMapVisitor(Key.get(mapOfString), stringType, stringType, setOf(module), BOTH, false, 0); } public void testMapBinderMapIsUnmodifiable() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { MapBinder.newMapBinder(binder(), String.class, String.class) .addBinding("a").toInstance("A"); } }); Map map = injector.getInstance(Key.get(mapOfString)); try { map.clear(); fail(); } catch(UnsupportedOperationException expected) { } } public void testMapBinderMapIsLazy() { Module module = new AbstractModule() { @Override protected void configure() { MapBinder.newMapBinder(binder(), String.class, Integer.class) .addBinding("num").toProvider(new Provider() { int nextValue = 1; public Integer get() { return nextValue++; } }); } }; Injector injector = Guice.createInjector(module); assertEquals(mapOf("num", 1), injector.getInstance(Key.get(mapOfInteger))); assertEquals(mapOf("num", 2), injector.getInstance(Key.get(mapOfInteger))); assertEquals(mapOf("num", 3), injector.getInstance(Key.get(mapOfInteger))); assertMapVisitor(Key.get(mapOfInteger), stringType, intType, setOf(module), BOTH, false, 0, providerInstance("num", 1)); } public void testMapBinderMapForbidsDuplicateKeys() { Module module = new AbstractModule() { @Override protected void configure() { MapBinder multibinder = MapBinder.newMapBinder( binder(), String.class, String.class); multibinder.addBinding("a").toInstance("A"); multibinder.addBinding("a").toInstance("B"); } }; try { Guice.createInjector(module); fail(); } catch(CreationException expected) { assertContains(expected.getMessage(), "Map injection failed due to duplicated key \"a\""); } assertMapVisitor(Key.get(mapOfString), stringType, stringType, setOf(module), MODULE, false, 0, instance("a", "A"), instance("a", "B")); } public void testMapBinderMapPermitDuplicateElements() { Module ab = new AbstractModule() { @Override protected void configure() { MapBinder multibinder = MapBinder.newMapBinder( binder(), String.class, String.class); multibinder.addBinding("a").toInstance("A"); multibinder.addBinding("b").toInstance("B"); multibinder.permitDuplicates(); } }; Module bc = new AbstractModule() { @Override protected void configure() { MapBinder multibinder = MapBinder.newMapBinder( binder(), String.class, String.class); multibinder.addBinding("b").toInstance("B"); multibinder.addBinding("c").toInstance("C"); multibinder.permitDuplicates(); } }; final Set> allBindings = new HashSet>(); for (Element element : Elements.getElements(ab, bc)) { element.acceptVisitor(new DefaultElementVisitor() { @Override public Void visit(Binding binding) { Key key = binding.getKey(); assertTrue(String.format("Duplicate binding for %s", key), allBindings.add(binding.getKey())); return null; } }); } Injector injector = Guice.createInjector(ab, bc); assertEquals(mapOf("a", "A", "b", "B", "c", "C"), injector.getInstance(Key.get(mapOfString))); assertMapVisitor(Key.get(mapOfString), stringType, stringType, setOf(ab, bc), BOTH, true, 0, instance("a", "A"), instance("b", "B"), instance("b", "B"), instance("c", "C")); } public void testMapBinderMultimap() { AbstractModule ab1c = new AbstractModule() { @Override protected void configure() { MapBinder multibinder = MapBinder.newMapBinder( binder(), String.class, String.class); multibinder.addBinding("a").toInstance("A"); multibinder.addBinding("b").toInstance("B1"); multibinder.addBinding("c").toInstance("C"); } }; AbstractModule b2c = new AbstractModule() { @Override protected void configure() { MapBinder multibinder = MapBinder.newMapBinder( binder(), String.class, String.class); multibinder.addBinding("b").toInstance("B2"); multibinder.addBinding("c").toInstance("C"); multibinder.permitDuplicates(); } }; Injector injector = Guice.createInjector(ab1c, b2c); assertEquals(mapOf("a", setOf("A"), "b", setOf("B1", "B2"), "c", setOf("C")), injector.getInstance(Key.get(mapOfSetOfString))); assertMapVisitor(Key.get(mapOfString), stringType, stringType, setOf(ab1c, b2c), BOTH, true, 0, instance("a", "A"), instance("b", "B1"), instance("b", "B2"), instance("c", "C"), instance("c", "C")); } public void testMapBinderMultimapWithAnotation() { AbstractModule ab1 = new AbstractModule() { @Override protected void configure() { MapBinder multibinder = MapBinder.newMapBinder( binder(), String.class, String.class, Abc.class); multibinder.addBinding("a").toInstance("A"); multibinder.addBinding("b").toInstance("B1"); } }; AbstractModule b2c = new AbstractModule() { @Override protected void configure() { MapBinder multibinder = MapBinder.newMapBinder( binder(), String.class, String.class, Abc.class); multibinder.addBinding("b").toInstance("B2"); multibinder.addBinding("c").toInstance("C"); multibinder.permitDuplicates(); } }; Injector injector = Guice.createInjector(ab1, b2c); assertEquals(mapOf("a", setOf("A"), "b", setOf("B1", "B2"), "c", setOf("C")), injector.getInstance(Key.get(mapOfSetOfString, Abc.class))); try { injector.getInstance(Key.get(mapOfSetOfString)); fail(); } catch (ConfigurationException expected) {} assertMapVisitor(Key.get(mapOfString, Abc.class), stringType, stringType, setOf(ab1, b2c), BOTH, true, 0, instance("a", "A"), instance("b", "B1"), instance("b", "B2"), instance("c", "C")); } public void testMapBinderMultimapIsUnmodifiable() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { MapBinder mapBinder = MapBinder.newMapBinder( binder(), String.class, String.class); mapBinder.addBinding("a").toInstance("A"); mapBinder.permitDuplicates(); } }); Map> map = injector.getInstance(Key.get(mapOfSetOfString)); try { map.clear(); fail(); } catch(UnsupportedOperationException expected) { } try { map.get("a").clear(); fail(); } catch(UnsupportedOperationException expected) { } } public void testMapBinderMapForbidsNullKeys() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { MapBinder.newMapBinder(binder(), String.class, String.class).addBinding(null); } }); fail(); } catch (CreationException expected) {} } public void testMapBinderMapForbidsNullValues() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { MapBinder.newMapBinder(binder(), String.class, String.class) .addBinding("null").toProvider(Providers.of(null)); } }); try { injector.getInstance(Key.get(mapOfString)); fail(); } catch(ProvisionException expected) { assertContains(expected.getMessage(), "1) Map injection failed due to null value for key \"null\""); } } public void testMapBinderProviderIsScoped() { final Provider counter = new Provider() { int next = 1; public Integer get() { return next++; } }; Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { MapBinder.newMapBinder(binder(), String.class, Integer.class) .addBinding("one").toProvider(counter).asEagerSingleton(); } }); assertEquals(1, (int) injector.getInstance(Key.get(mapOfInteger)).get("one")); assertEquals(1, (int) injector.getInstance(Key.get(mapOfInteger)).get("one")); } public void testSourceLinesInMapBindings() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { MapBinder.newMapBinder(binder(), String.class, Integer.class) .addBinding("one"); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) No implementation for java.lang.Integer", "at " + getClass().getName()); } } /** We just want to make sure that mapbinder's binding depends on the underlying multibinder. */ public void testMultibinderDependencies() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { MapBinder mapBinder = MapBinder.newMapBinder(binder(), Integer.class, String.class); mapBinder.addBinding(1).toInstance("A"); mapBinder.addBinding(2).to(Key.get(String.class, Names.named("b"))); bindConstant().annotatedWith(Names.named("b")).to("B"); } }); Binding> binding = injector.getBinding(new Key>() {}); HasDependencies withDependencies = (HasDependencies) binding; Key setKey = new Key>>>() {}; assertEquals(ImmutableSet.>of(Dependency.get(setKey)), withDependencies.getDependencies()); } /** We just want to make sure that mapbinder's binding depends on the underlying multibinder. */ public void testMultibinderDependenciesInToolStage() { Injector injector = Guice.createInjector(Stage.TOOL, new AbstractModule() { protected void configure() { MapBinder mapBinder = MapBinder.newMapBinder(binder(), Integer.class, String.class); mapBinder.addBinding(1).toInstance("A"); mapBinder.addBinding(2).to(Key.get(String.class, Names.named("b"))); bindConstant().annotatedWith(Names.named("b")).to("B"); }}); Binding> binding = injector.getBinding(new Key>() {}); HasDependencies withDependencies = (HasDependencies) binding; Key setKey = new Key>>>() {}; assertEquals(ImmutableSet.>of(Dependency.get(setKey)), withDependencies.getDependencies()); } /** * Our implementation maintains order, but doesn't guarantee it in the API spec. * TODO: specify the iteration order? */ public void testBindOrderEqualsIterationOrder() { Injector injector = Guice.createInjector( new AbstractModule() { protected void configure() { MapBinder mapBinder = MapBinder.newMapBinder(binder(), String.class, String.class); mapBinder.addBinding("leonardo").toInstance("blue"); mapBinder.addBinding("donatello").toInstance("purple"); install(new AbstractModule() { protected void configure() { MapBinder.newMapBinder(binder(), String.class, String.class) .addBinding("michaelangelo").toInstance("orange"); } }); } }, new AbstractModule() { protected void configure() { MapBinder.newMapBinder(binder(), String.class, String.class) .addBinding("raphael").toInstance("red"); } }); Map map = injector.getInstance(new Key>() {}); Iterator> iterator = map.entrySet().iterator(); assertEquals(Maps.immutableEntry("leonardo", "blue"), iterator.next()); assertEquals(Maps.immutableEntry("donatello", "purple"), iterator.next()); assertEquals(Maps.immutableEntry("michaelangelo", "orange"), iterator.next()); assertEquals(Maps.immutableEntry("raphael", "red"), iterator.next()); } /** * With overrides, we should get the union of all map bindings. */ public void testModuleOverrideAndMapBindings() { Module ab = new AbstractModule() { protected void configure() { MapBinder multibinder = MapBinder.newMapBinder(binder(), String.class, String.class); multibinder.addBinding("a").toInstance("A"); multibinder.addBinding("b").toInstance("B"); } }; Module cd = new AbstractModule() { protected void configure() { MapBinder multibinder = MapBinder.newMapBinder(binder(), String.class, String.class); multibinder.addBinding("c").toInstance("C"); multibinder.addBinding("d").toInstance("D"); } }; Module ef = new AbstractModule() { protected void configure() { MapBinder multibinder = MapBinder.newMapBinder(binder(), String.class, String.class); multibinder.addBinding("e").toInstance("E"); multibinder.addBinding("f").toInstance("F"); } }; Module abcd = Modules.override(ab).with(cd); Injector injector = Guice.createInjector(abcd, ef); assertEquals(mapOf("a", "A", "b", "B", "c", "C", "d", "D", "e", "E", "f", "F"), injector.getInstance(Key.get(mapOfString))); assertMapVisitor(Key.get(mapOfString), stringType, stringType, setOf(abcd, ef), BOTH, false, 0, instance("a", "A"), instance("b", "B"), instance("c", "C"), instance("d", "D"), instance( "e", "E"), instance("f", "F")); } /** * With overrides, we should get the union of all map bindings. */ public void testModuleOverrideAndMapBindingsWithPermitDuplicates() { Module abc = new AbstractModule() { protected void configure() { MapBinder multibinder = MapBinder.newMapBinder(binder(), String.class, String.class); multibinder.addBinding("a").toInstance("A"); multibinder.addBinding("b").toInstance("B"); multibinder.addBinding("c").toInstance("C"); multibinder.permitDuplicates(); } }; Module cd = new AbstractModule() { protected void configure() { MapBinder multibinder = MapBinder.newMapBinder(binder(), String.class, String.class); multibinder.addBinding("c").toInstance("C"); multibinder.addBinding("d").toInstance("D"); multibinder.permitDuplicates(); } }; Module ef = new AbstractModule() { protected void configure() { MapBinder multibinder = MapBinder.newMapBinder(binder(), String.class, String.class); multibinder.addBinding("e").toInstance("E"); multibinder.addBinding("f").toInstance("F"); multibinder.permitDuplicates(); } }; Module abcd = Modules.override(abc).with(cd); Injector injector = Guice.createInjector(abcd, ef); assertEquals(mapOf("a", "A", "b", "B", "c", "C", "d", "D", "e", "E", "f", "F"), injector.getInstance(Key.get(mapOfString))); assertMapVisitor(Key.get(mapOfString), stringType, stringType, setOf(abcd, ef), BOTH, true, 0, instance("a", "A"), instance("b", "B"), instance("c", "C"), instance("c", "C"), instance( "d", "D"), instance("e", "E"), instance("f", "F")); } @Retention(RUNTIME) @BindingAnnotation @interface Abc {} @Retention(RUNTIME) @BindingAnnotation @interface De {} @SuppressWarnings("unchecked") private Map mapOf(Object... elements) { Map result = new HashMap(); for (int i = 0; i < elements.length; i += 2) { result.put((K)elements[i], (V)elements[i+1]); } return result; } @SuppressWarnings("unchecked") private Set setOf(V... elements) { return new HashSet(Arrays.asList(elements)); } @BindingAnnotation @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) private static @interface Marker {} @Marker public void testMapBinderMatching() throws Exception { Method m = MapBinderTest.class.getDeclaredMethod("testMapBinderMatching"); assertNotNull(m); final Annotation marker = m.getAnnotation(Marker.class); Injector injector = Guice.createInjector(new AbstractModule() { @Override public void configure() { MapBinder mb1 = MapBinder.newMapBinder(binder(), Integer.class, Integer.class, Marker.class); MapBinder mb2 = MapBinder.newMapBinder(binder(), Integer.class, Integer.class, marker); mb1.addBinding(1).toInstance(1); mb2.addBinding(2).toInstance(2); // This assures us that the two binders are equivalent, so we expect the instance added to // each to have been added to one set. assertEquals(mb1, mb2); } }); TypeLiteral> t = new TypeLiteral>() {}; Map s1 = injector.getInstance(Key.get(t, Marker.class)); Map s2 = injector.getInstance(Key.get(t, marker)); // This assures us that the two sets are in fact equal. They may not be same set (as in Java // object identical), but we shouldn't expect that, since probably Guice creates the set each // time in case the elements are dependent on scope. assertEquals(s1, s2); // This ensures that MultiBinder is internally using the correct set name -- // making sure that instances of marker annotations have the same set name as // MarkerAnnotation.class. Map expected = new HashMap(); expected.put(1, 1); expected.put(2, 2); assertEquals(expected, s1); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/multibindings/test/com/google/inject/multibindings/AllTests.javasisu-guice-sisu-guice-3.1.1/extensions/multibindings/test/com/google/inject/multibindings/AllTests.j0000644000175000017500000000171311704661106032526 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.multibindings; import junit.framework.Test; import junit.framework.TestSuite; /** * @author jessewilson@google.com (Jesse Wilson) */ public class AllTests { public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(MapBinderTest.class); suite.addTestSuite(MultibinderTest.class); return suite; } } sisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/0000755000175000017500000000000011704661106022250 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/0000755000175000017500000000000011704661106023026 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/0000755000175000017500000000000011704661106024302 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/0000755000175000017500000000000011704661106025556 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/0000755000175000017500000000000011704661106030426 5ustar tonytony././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/package-info.javasisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/package-inf0000644000175000017500000000140111704661106032512 0ustar tonytony/* * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Extension for binding multiple instances in a collection; this extension requires {@code * guice-multibindings-3.0.jar}. */ package com.google.inject.multibindings;././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/RealElement.javasisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/RealElement0000644000175000017500000000334011704661106032546 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.multibindings; import java.lang.annotation.Annotation; import java.util.concurrent.atomic.AtomicInteger; /** * @author jessewilson@google.com (Jesse Wilson) */ class RealElement implements Element { private static final AtomicInteger nextUniqueId = new AtomicInteger(1); private final int uniqueId; private final String setName; RealElement(String setName) { uniqueId = nextUniqueId.getAndIncrement(); this.setName = setName; } public String setName() { return setName; } public int uniqueId() { return uniqueId; } public Class annotationType() { return Element.class; } @Override public String toString() { return "@" + Element.class.getName() + "(setName=" + setName + ",uniqueId=" + uniqueId + ")"; } @Override public boolean equals(Object o) { return o instanceof Element && ((Element) o).setName().equals(setName()) && ((Element) o).uniqueId() == uniqueId(); } @Override public int hashCode() { return 127 * ("setName".hashCode() ^ setName.hashCode()) + 127 * ("uniqueId".hashCode() ^ uniqueId); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/MultibindingsTargetVisitor.javasisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/Multibindin0000644000175000017500000000246411704661106032635 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.multibindings; import com.google.inject.spi.BindingTargetVisitor; /** * A visitor for the multibinder extension. *

    * If your {@link BindingTargetVisitor} implements this interface, bindings created by using * {@link Multibinder} or {@link MapBinder} will be visited through this interface. * * @since 3.0 * @author sameb@google.com (Sam Berlin) */ public interface MultibindingsTargetVisitor extends BindingTargetVisitor { /** * Visits a binding created through {@link Multibinder}. */ V visit(MultibinderBinding multibinding); /** * Visits a binding created through {@link MapBinder}. */ V visit(MapBinderBinding mapbinding); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/MultibinderBinding.javasisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/Multibinder0000644000175000017500000000617411704661106032637 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.multibindings; import com.google.inject.Binding; import com.google.inject.Key; import com.google.inject.TypeLiteral; import com.google.inject.spi.Element; import com.google.inject.spi.Elements; import java.util.List; /** * A binding for a Multibinder. * * @param The fully qualified type of the set, including Set. For example: * MultibinderBinding<Set<Boolean>> * * @since 3.0 * @author sameb@google.com (Sam Berlin) */ public interface MultibinderBinding { /** Returns the key for the set. */ Key getSetKey(); /** * Returns the TypeLiteral that describes the type of elements in the set. *

    * The elements will always match the type Set's generic type. For example, if getSetKey returns a * key of Set<String>, then this will always return a * TypeLiteral<String>. */ TypeLiteral getElementTypeLiteral(); /** * Returns all bindings that make up the set. This is only supported on bindings returned from an * injector. This will throw {@link UnsupportedOperationException} if it is called on an element * retrieved from {@link Elements#getElements}. *

    * The elements will always match the type Set's generic type. For example, if getSetKey returns a * key of Set<String>, then this will always return a list of type * List<Binding<String>>. */ List> getElements(); /** * Returns true if the multibinder permits duplicates. This is only supported on bindings returned * from an injector. This will throw {@link UnsupportedOperationException} if it is called on a * MultibinderBinding retrieved from {@link Elements#getElements}. */ boolean permitsDuplicates(); /** * Returns true if this Multibinder uses the given Element. This will be true for bindings that * derive the elements of the set and other bindings that Multibinder uses internally. This will * work for MultibinderBindings retrieved from an injector and {@link Elements#getElements}. * Usually this is only necessary if you are working with elements retrieved from modules (without * an Injector), otherwise {@link #getElements} and {@link #permitsDuplicates} are better options. *

    * If you need to introspect the details of the set, such as the values or if it permits * duplicates, it is necessary to pass the elements through an Injector and use * {@link #getElements()} and {@link #permitsDuplicates()}. */ boolean containsElement(Element element); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/Multibinder.javasisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/Multibinder0000644000175000017500000004105211704661106032631 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.multibindings; import static com.google.inject.name.Names.named; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.inject.AbstractModule; import com.google.inject.Binder; import com.google.inject.Binding; import com.google.inject.ConfigurationException; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.TypeLiteral; import com.google.inject.binder.LinkedBindingBuilder; import com.google.inject.internal.Annotations; import com.google.inject.internal.Errors; import com.google.inject.spi.BindingTargetVisitor; import com.google.inject.spi.Dependency; import com.google.inject.spi.HasDependencies; import com.google.inject.spi.Message; import com.google.inject.spi.ProviderInstanceBinding; import com.google.inject.spi.ProviderWithExtensionVisitor; import com.google.inject.spi.Toolable; import com.google.inject.util.Types; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; /** * An API to bind multiple values separately, only to later inject them as a * complete collection. Multibinder is intended for use in your application's * module: *

    
     * public class SnacksModule extends AbstractModule {
     *   protected void configure() {
     *     Multibinder<Snack> multibinder
     *         = Multibinder.newSetBinder(binder(), Snack.class);
     *     multibinder.addBinding().toInstance(new Twix());
     *     multibinder.addBinding().toProvider(SnickersProvider.class);
     *     multibinder.addBinding().to(Skittles.class);
     *   }
     * }
    * *

    With this binding, a {@link Set}{@code } can now be injected: *

    
     * class SnackMachine {
     *   {@literal @}Inject
     *   public SnackMachine(Set<Snack> snacks) { ... }
     * }
    * *

    Contributing multibindings from different modules is supported. For * example, it is okay for both {@code CandyModule} and {@code ChipsModule} * to create their own {@code Multibinder}, and to each contribute * bindings to the set of snacks. When that set is injected, it will contain * elements from both modules. * *

    The set's iteration order is consistent with the binding order. This is * convenient when multiple elements are contributed by the same module because * that module can order its bindings appropriately. Avoid relying on the * iteration order of elements contributed by different modules, since there is * no equivalent mechanism to order modules. * *

    The set is unmodifiable. Elements can only be added to the set by * configuring the multibinder. Elements can never be removed from the set. * *

    Elements are resolved at set injection time. If an element is bound to a * provider, that provider's get method will be called each time the set is * injected (unless the binding is also scoped). * *

    Annotations are be used to create different sets of the same element * type. Each distinct annotation gets its own independent collection of * elements. * *

    Elements must be distinct. If multiple bound elements * have the same value, set injection will fail. * *

    Elements must be non-null. If any set element is null, * set injection will fail. * * @author jessewilson@google.com (Jesse Wilson) */ public abstract class Multibinder { private Multibinder() {} /** * Returns a new multibinder that collects instances of {@code type} in a {@link Set} that is * itself bound with no binding annotation. */ public static Multibinder newSetBinder(Binder binder, TypeLiteral type) { binder = binder.skipSources(RealMultibinder.class, Multibinder.class); RealMultibinder result = new RealMultibinder(binder, type, Key.get(Multibinder.setOf(type))); binder.install(result); return result; } /** * Returns a new multibinder that collects instances of {@code type} in a {@link Set} that is * itself bound with no binding annotation. */ public static Multibinder newSetBinder(Binder binder, Class type) { return newSetBinder(binder, TypeLiteral.get(type)); } /** * Returns a new multibinder that collects instances of {@code type} in a {@link Set} that is * itself bound with {@code annotation}. */ public static Multibinder newSetBinder( Binder binder, TypeLiteral type, Annotation annotation) { binder = binder.skipSources(RealMultibinder.class, Multibinder.class); RealMultibinder result = new RealMultibinder(binder, type, Key.get(Multibinder.setOf(type), annotation)); binder.install(result); return result; } /** * Returns a new multibinder that collects instances of {@code type} in a {@link Set} that is * itself bound with {@code annotation}. */ public static Multibinder newSetBinder( Binder binder, Class type, Annotation annotation) { return newSetBinder(binder, TypeLiteral.get(type), annotation); } /** * Returns a new multibinder that collects instances of {@code type} in a {@link Set} that is * itself bound with {@code annotationType}. */ public static Multibinder newSetBinder(Binder binder, TypeLiteral type, Class annotationType) { binder = binder.skipSources(RealMultibinder.class, Multibinder.class); RealMultibinder result = new RealMultibinder(binder, type, Key.get(Multibinder.setOf(type), annotationType)); binder.install(result); return result; } /** * Returns a new multibinder that collects instances of {@code type} in a {@link Set} that is * itself bound with {@code annotationType}. */ public static Multibinder newSetBinder(Binder binder, Class type, Class annotationType) { return newSetBinder(binder, TypeLiteral.get(type), annotationType); } @SuppressWarnings("unchecked") // wrapping a T in a Set safely returns a Set static TypeLiteral> setOf(TypeLiteral elementType) { Type type = Types.setOf(elementType.getType()); return (TypeLiteral>) TypeLiteral.get(type); } /** * Configures the bound set to silently discard duplicate elements. When multiple equal values are * bound, the one that gets included is arbitrary. When multiple modules contribute elements to * the set, this configuration option impacts all of them. * * @return this multibinder * @since 3.0 */ public abstract Multibinder permitDuplicates(); /** * Returns a binding builder used to add a new element in the set. Each * bound element must have a distinct value. Bound providers will be * evaluated each time the set is injected. * *

    It is an error to call this method without also calling one of the * {@code to} methods on the returned binding builder. * *

    Scoping elements independently is supported. Use the {@code in} method * to specify a binding scope. */ public abstract LinkedBindingBuilder addBinding(); /** * The actual multibinder plays several roles: * *

    As a Multibinder, it acts as a factory for LinkedBindingBuilders for * each of the set's elements. Each binding is given an annotation that * identifies it as a part of this set. * *

    As a Module, it installs the binding to the set itself. As a module, * this implements equals() and hashcode() in order to trick Guice into * executing its configure() method only once. That makes it so that * multiple multibinders can be created for the same target collection, but * only one is bound. Since the list of bindings is retrieved from the * injector itself (and not the multibinder), each multibinder has access to * all contributions from all multibinders. * *

    As a Provider, this constructs the set instances. * *

    We use a subclass to hide 'implements Module, Provider' from the public * API. */ static final class RealMultibinder extends Multibinder implements Module, ProviderWithExtensionVisitor>, HasDependencies, MultibinderBinding> { private final TypeLiteral elementType; private final String setName; private final Key> setKey; private final Key permitDuplicatesKey; /* the target injector's binder. non-null until initialization, null afterwards */ private Binder binder; /* a binding for each element in the set. null until initialization, non-null afterwards */ private ImmutableList> bindings; private Set> dependencies; /** whether duplicates are allowed. Possibly configured by a different instance */ private boolean permitDuplicates; private RealMultibinder(Binder binder, TypeLiteral elementType, Key> setKey) { this.binder = checkNotNull(binder, "binder"); this.elementType = checkNotNull(elementType, "elementType"); this.setKey = checkNotNull(setKey, "setKey"); this.setName = nameOf(setKey); this.permitDuplicatesKey = Key.get(Boolean.class, named(toString() + " permits duplicates")); } /** * Returns the name the set should use. This is based on the annotation. * If the annotation has an instance and is not a marker annotation, * we ask the annotation for its toString. If it was a marker annotation * or just an annotation type, we use the annotation's name. Otherwise, * the name is the empty string. */ private String nameOf(Key key) { Annotation annotation = setKey.getAnnotation(); Class annotationType = setKey.getAnnotationType(); if (annotation != null && !Annotations.isMarker(annotationType)) { return setKey.getAnnotation().toString(); } else if(setKey.getAnnotationType() != null) { return "@" + setKey.getAnnotationType().getName(); } else { return ""; } } @SuppressWarnings("unchecked") public void configure(Binder binder) { checkConfiguration(!isInitialized(), "Multibinder was already initialized"); binder.bind(setKey).toProvider(this); } @Override public Multibinder permitDuplicates() { binder.install(new PermitDuplicatesModule(permitDuplicatesKey)); return this; } @Override public LinkedBindingBuilder addBinding() { checkConfiguration(!isInitialized(), "Multibinder was already initialized"); return binder.bind(Key.get(elementType, new RealElement(setName))); } /** * Invoked by Guice at Injector-creation time to prepare providers for each * element in this set. At this time the set's size is known, but its * contents are only evaluated when get() is invoked. */ @Toolable @Inject void initialize(Injector injector) { List> bindings = Lists.newArrayList(); List> dependencies = Lists.newArrayList(); for (Binding entry : injector.findBindingsByType(elementType)) { if (keyMatches(entry.getKey())) { @SuppressWarnings("unchecked") // protected by findBindingsByType() Binding binding = (Binding) entry; bindings.add(binding); dependencies.add(Dependency.get(binding.getKey())); } } this.bindings = ImmutableList.copyOf(bindings); this.dependencies = ImmutableSet.copyOf(dependencies); this.permitDuplicates = permitsDuplicates(injector); this.binder = null; } boolean permitsDuplicates(Injector injector) { return injector.getBindings().containsKey(permitDuplicatesKey); } private boolean keyMatches(Key key) { return key.getTypeLiteral().equals(elementType) && key.getAnnotation() instanceof Element && ((Element) key.getAnnotation()).setName().equals(setName); } private boolean isInitialized() { return binder == null; } public Set get() { checkConfiguration(isInitialized(), "Multibinder is not initialized"); Set result = new LinkedHashSet(); for (Binding binding : bindings) { final T newValue = binding.getProvider().get(); checkConfiguration(newValue != null, "Set injection failed due to null element"); checkConfiguration(result.add(newValue) || permitDuplicates, "Set injection failed due to duplicated element \"%s\"", newValue); } return Collections.unmodifiableSet(result); } @SuppressWarnings("unchecked") public V acceptExtensionVisitor( BindingTargetVisitor visitor, ProviderInstanceBinding binding) { if(visitor instanceof MultibindingsTargetVisitor) { return ((MultibindingsTargetVisitor, V>)visitor).visit(this); } else { return visitor.visit(binding); } } String getSetName() { return setName; } public TypeLiteral getElementTypeLiteral() { return elementType; } public Key> getSetKey() { return setKey; } @SuppressWarnings("unchecked") public List> getElements() { if(isInitialized()) { return (List)bindings; // safe because bindings is immutable. } else { throw new UnsupportedOperationException("getElements() not supported for module bindings"); } } public boolean permitsDuplicates() { if(isInitialized()) { return permitDuplicates; } else { throw new UnsupportedOperationException("permitsDuplicates() not supported for module bindings"); } } public boolean containsElement(com.google.inject.spi.Element element) { if(element instanceof Binding) { Binding binding = (Binding)element; return keyMatches(binding.getKey()) || binding.getKey().equals(permitDuplicatesKey) || binding.getKey().equals(setKey); } else { return false; } } public Set> getDependencies() { if (!isInitialized()) { return ImmutableSet.>of(Dependency.get(Key.get(Injector.class))); } else { return dependencies; } } @Override public boolean equals(Object o) { return o instanceof RealMultibinder && ((RealMultibinder) o).setKey.equals(setKey); } @Override public int hashCode() { return setKey.hashCode(); } @Override public String toString() { return new StringBuilder() .append(setName) .append(setName.length() > 0 ? " " : "") .append("Multibinder<") .append(elementType) .append(">") .toString(); } } /** * We install the permit duplicates configuration as its own binding, all by itself. This way, * if only one of a multibinder's users remember to call permitDuplicates(), they're still * permitted. */ private static class PermitDuplicatesModule extends AbstractModule { private final Key key; PermitDuplicatesModule(Key key) { this.key = key; } @Override protected void configure() { bind(key).toInstance(true); } @Override public boolean equals(Object o) { return o instanceof PermitDuplicatesModule && ((PermitDuplicatesModule) o).key.equals(key); } @Override public int hashCode() { return getClass().hashCode() ^ key.hashCode(); } } static void checkConfiguration(boolean condition, String format, Object... args) { if (condition) { return; } throw new ConfigurationException(ImmutableSet.of(new Message(Errors.format(format, args)))); } static T checkNotNull(T reference, String name) { if (reference != null) { return reference; } NullPointerException npe = new NullPointerException(name); throw new ConfigurationException(ImmutableSet.of( new Message(ImmutableList.of(), npe.toString(), npe))); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/MapBinderBinding.javasisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/MapBinderBi0000644000175000017500000001013311704661106032463 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.multibindings; import com.google.inject.Binding; import com.google.inject.Key; import com.google.inject.TypeLiteral; import com.google.inject.spi.Element; import com.google.inject.spi.Elements; import java.util.List; import java.util.Map; /** * A binding for a MapBinder. *

    * Although MapBinders may be injected through a variety of generic types (Map<K, V>, Map * <K, Provider<V>>, Map<K, Set<V>>, Map>, and even Set<Map.Entry<K, Provider<V>>), a * MapBinderBinding exists only on the Binding associated with the Map<K, V> key. Other * bindings can be validated to be derived from this MapBinderBinding using * {@link #containsElement(Element)}. * * @param The fully qualified type of the map, including Map. For example: * MapBinderBinding<Map<String, Snack>> * * @since 3.0 * @author sameb@google.com (Sam Berlin) */ public interface MapBinderBinding { /** Returns the {@link Key} for the map. */ Key getMapKey(); /** * Returns the TypeLiteral describing the keys of the map. *

    * The TypeLiteral will always match the type Map's generic type. For example, if getMapKey * returns a key of Map<String, Snack>, then this will always return a * TypeLiteral<String>. */ TypeLiteral getKeyTypeLiteral(); /** * Returns the TypeLiteral describing the values of the map. *

    * The TypeLiteral will always match the type Map's generic type. For example, if getMapKey * returns a key of Map<String, Snack>, then this will always return a * TypeLiteral<Snack>. */ TypeLiteral getValueTypeLiteral(); /** * Returns all entries in the Map. The returned list of Map.Entries contains the key and a binding * to the value. Duplicate keys or values will exist as separate Map.Entries in the returned list. * This is only supported on bindings returned from an injector. This will throw * {@link UnsupportedOperationException} if it is called on an element retrieved from * {@link Elements#getElements}. *

    * The elements will always match the type Map's generic type. For example, if getMapKey returns a * key of Map<String, Snack>, then this will always return a list of type * List<Map.Entry<String, Binding<Snack>>>. */ List>> getEntries(); /** * Returns true if the MapBinder permits duplicates. This is only supported on bindings returned * from an injector. This will throw {@link UnsupportedOperationException} if it is called on a * MapBinderBinding retrieved from {@link Elements#getElements}. */ boolean permitsDuplicates(); /** * Returns true if this MapBinder contains the given Element in order to build the map or uses the * given Element in order to support building and injecting the map. This will work for * MapBinderBindings retrieved from an injector and {@link Elements#getElements}. Usually this is * only necessary if you are working with elements retrieved from modules (without an Injector), * otherwise {@link #getEntries} and {@link #permitsDuplicates} are better options. *

    * If you need to introspect the details of the map, such as the keys, values or if it permits * duplicates, it is necessary to pass the elements through an Injector and use * {@link #getEntries()} and {@link #permitsDuplicates()}. */ boolean containsElement(Element element); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/MapBinder.javasisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/MapBinder.j0000644000175000017500000006436711704661106032462 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.multibindings; import static com.google.inject.multibindings.Multibinder.checkConfiguration; import static com.google.inject.multibindings.Multibinder.checkNotNull; import static com.google.inject.multibindings.Multibinder.setOf; import static com.google.inject.util.Types.newParameterizedTypeWithOwner; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.inject.Binder; import com.google.inject.Binding; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provider; import com.google.inject.TypeLiteral; import com.google.inject.binder.LinkedBindingBuilder; import com.google.inject.multibindings.Multibinder.RealMultibinder; import com.google.inject.spi.BindingTargetVisitor; import com.google.inject.spi.Dependency; import com.google.inject.spi.ProviderInstanceBinding; import com.google.inject.spi.ProviderLookup; import com.google.inject.spi.ProviderWithDependencies; import com.google.inject.spi.ProviderWithExtensionVisitor; import com.google.inject.spi.Toolable; import com.google.inject.util.Types; import java.lang.annotation.Annotation; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; /** * An API to bind multiple map entries separately, only to later inject them as * a complete map. MapBinder is intended for use in your application's module: *

    
     * public class SnacksModule extends AbstractModule {
     *   protected void configure() {
     *     MapBinder<String, Snack> mapbinder
     *         = MapBinder.newMapBinder(binder(), String.class, Snack.class);
     *     mapbinder.addBinding("twix").toInstance(new Twix());
     *     mapbinder.addBinding("snickers").toProvider(SnickersProvider.class);
     *     mapbinder.addBinding("skittles").to(Skittles.class);
     *   }
     * }
    * *

    With this binding, a {@link Map}{@code } can now be * injected: *

    
     * class SnackMachine {
     *   {@literal @}Inject
     *   public SnackMachine(Map<String, Snack> snacks) { ... }
     * }
    * *

    In addition to binding {@code Map}, a mapbinder will also bind * {@code Map>} for lazy value provision: *

    
     * class SnackMachine {
     *   {@literal @}Inject
     *   public SnackMachine(Map<String, Provider<Snack>> snackProviders) { ... }
     * }
    * *

    Contributing mapbindings from different modules is supported. For example, * it is okay to have both {@code CandyModule} and {@code ChipsModule} both * create their own {@code MapBinder}, and to each contribute * bindings to the snacks map. When that map is injected, it will contain * entries from both modules. * *

    The map's iteration order is consistent with the binding order. This is * convenient when multiple elements are contributed by the same module because * that module can order its bindings appropriately. Avoid relying on the * iteration order of elements contributed by different modules, since there is * no equivalent mechanism to order modules. * *

    The map is unmodifiable. Elements can only be added to the map by * configuring the MapBinder. Elements can never be removed from the map. * *

    Values are resolved at map injection time. If a value is bound to a * provider, that provider's get method will be called each time the map is * injected (unless the binding is also scoped, or a map of providers is injected). * *

    Annotations are used to create different maps of the same key/value * type. Each distinct annotation gets its own independent map. * *

    Keys must be distinct. If the same key is bound more than * once, map injection will fail. However, use {@link #permitDuplicates()} in * order to allow duplicate keys; extra bindings to {@code Map>} and * {@code Map>} will be added. * *

    Keys must be non-null. {@code addBinding(null)} will * throw an unchecked exception. * *

    Values must be non-null to use map injection. If any * value is null, map injection will fail (although injecting a map of providers * will not). * * @author dpb@google.com (David P. Baker) */ public abstract class MapBinder { private MapBinder() {} /** * Returns a new mapbinder that collects entries of {@code keyType}/{@code valueType} in a * {@link Map} that is itself bound with no binding annotation. */ public static MapBinder newMapBinder(Binder binder, TypeLiteral keyType, TypeLiteral valueType) { binder = binder.skipSources(MapBinder.class, RealMapBinder.class); return newMapBinder(binder, keyType, valueType, Key.get(mapOf(keyType, valueType)), Key.get(mapOfProviderOf(keyType, valueType)), Key.get(mapOf(keyType, setOf(valueType))), Key.get(mapOfSetOfProviderOf(keyType, valueType)), Multibinder.newSetBinder(binder, entryOfProviderOf(keyType, valueType))); } /** * Returns a new mapbinder that collects entries of {@code keyType}/{@code valueType} in a * {@link Map} that is itself bound with no binding annotation. */ public static MapBinder newMapBinder(Binder binder, Class keyType, Class valueType) { return newMapBinder(binder, TypeLiteral.get(keyType), TypeLiteral.get(valueType)); } /** * Returns a new mapbinder that collects entries of {@code keyType}/{@code valueType} in a * {@link Map} that is itself bound with {@code annotation}. */ public static MapBinder newMapBinder(Binder binder, TypeLiteral keyType, TypeLiteral valueType, Annotation annotation) { binder = binder.skipSources(MapBinder.class, RealMapBinder.class); return newMapBinder(binder, keyType, valueType, Key.get(mapOf(keyType, valueType), annotation), Key.get(mapOfProviderOf(keyType, valueType), annotation), Key.get(mapOf(keyType, setOf(valueType)), annotation), Key.get(mapOfSetOfProviderOf(keyType, valueType), annotation), Multibinder.newSetBinder(binder, entryOfProviderOf(keyType, valueType), annotation)); } /** * Returns a new mapbinder that collects entries of {@code keyType}/{@code valueType} in a * {@link Map} that is itself bound with {@code annotation}. */ public static MapBinder newMapBinder(Binder binder, Class keyType, Class valueType, Annotation annotation) { return newMapBinder(binder, TypeLiteral.get(keyType), TypeLiteral.get(valueType), annotation); } /** * Returns a new mapbinder that collects entries of {@code keyType}/{@code valueType} in a * {@link Map} that is itself bound with {@code annotationType}. */ public static MapBinder newMapBinder(Binder binder, TypeLiteral keyType, TypeLiteral valueType, Class annotationType) { binder = binder.skipSources(MapBinder.class, RealMapBinder.class); return newMapBinder(binder, keyType, valueType, Key.get(mapOf(keyType, valueType), annotationType), Key.get(mapOfProviderOf(keyType, valueType), annotationType), Key.get(mapOf(keyType, setOf(valueType)), annotationType), Key.get(mapOfSetOfProviderOf(keyType, valueType), annotationType), Multibinder.newSetBinder(binder, entryOfProviderOf(keyType, valueType), annotationType)); } /** * Returns a new mapbinder that collects entries of {@code keyType}/{@code valueType} in a * {@link Map} that is itself bound with {@code annotationType}. */ public static MapBinder newMapBinder(Binder binder, Class keyType, Class valueType, Class annotationType) { return newMapBinder( binder, TypeLiteral.get(keyType), TypeLiteral.get(valueType), annotationType); } @SuppressWarnings("unchecked") // a map of is safely a Map static TypeLiteral> mapOf( TypeLiteral keyType, TypeLiteral valueType) { return (TypeLiteral>) TypeLiteral.get( Types.mapOf(keyType.getType(), valueType.getType())); } @SuppressWarnings("unchecked") // a provider map is safely a Map> static TypeLiteral>> mapOfProviderOf( TypeLiteral keyType, TypeLiteral valueType) { return (TypeLiteral>>) TypeLiteral.get( Types.mapOf(keyType.getType(), Types.providerOf(valueType.getType()))); } @SuppressWarnings("unchecked") // a provider map > is safely a Map>> static TypeLiteral>>> mapOfSetOfProviderOf( TypeLiteral keyType, TypeLiteral valueType) { return (TypeLiteral>>>) TypeLiteral.get( Types.mapOf(keyType.getType(), Types.setOf(Types.providerOf(valueType.getType())))); } @SuppressWarnings("unchecked") // a provider entry is safely a Map.Entry> static TypeLiteral>> entryOfProviderOf( TypeLiteral keyType, TypeLiteral valueType) { return (TypeLiteral>>) TypeLiteral.get(newParameterizedTypeWithOwner( Map.class, Entry.class, keyType.getType(), Types.providerOf(valueType.getType()))); } private static MapBinder newMapBinder(Binder binder, TypeLiteral keyType, TypeLiteral valueType, Key> mapKey, Key>> providerMapKey, Key>> multimapKey, Key>>> providerMultimapKey, Multibinder>> entrySetBinder) { RealMapBinder mapBinder = new RealMapBinder( binder, keyType, valueType, mapKey, providerMapKey, multimapKey, providerMultimapKey, entrySetBinder); binder.install(mapBinder); return mapBinder; } /** * Configures the {@code MapBinder} to handle duplicate entries. *

    When multiple equal keys are bound, the value that gets included in the map is * arbitrary. *

    In addition to the {@code Map} and {@code Map>} * maps that are normally bound, a {@code Map>} and * {@code Map>>} are also bound, which contain * all values bound to each key. *

    * When multiple modules contribute elements to the map, this configuration * option impacts all of them. * * @return this map binder * @since 3.0 */ public abstract MapBinder permitDuplicates(); /** * Returns a binding builder used to add a new entry in the map. Each * key must be distinct (and non-null). Bound providers will be evaluated each * time the map is injected. * *

    It is an error to call this method without also calling one of the * {@code to} methods on the returned binding builder. * *

    Scoping elements independently is supported. Use the {@code in} method * to specify a binding scope. */ public abstract LinkedBindingBuilder addBinding(K key); /** * The actual mapbinder plays several roles: * *

    As a MapBinder, it acts as a factory for LinkedBindingBuilders for * each of the map's values. It delegates to a {@link Multibinder} of * entries (keys to value providers). * *

    As a Module, it installs the binding to the map itself, as well as to * a corresponding map whose values are providers. It uses the entry set * multibinder to construct the map and the provider map. * *

    As a module, this implements equals() and hashcode() in order to trick * Guice into executing its configure() method only once. That makes it so * that multiple mapbinders can be created for the same target map, but * only one is bound. Since the list of bindings is retrieved from the * injector itself (and not the mapbinder), each mapbinder has access to * all contributions from all equivalent mapbinders. * *

    Rather than binding a single Map.Entry<K, V>, the map binder * binds keys and values independently. This allows the values to be properly * scoped. * *

    We use a subclass to hide 'implements Module' from the public API. */ private static final class RealMapBinder extends MapBinder implements Module { private final TypeLiteral keyType; private final TypeLiteral valueType; private final Key> mapKey; private final Key>> providerMapKey; private final Key>> multimapKey; private final Key>>> providerMultimapKey; private final RealMultibinder>> entrySetBinder; /* the target injector's binder. non-null until initialization, null afterwards */ private Binder binder; private boolean permitDuplicates; private ImmutableList>> mapBindings; private RealMapBinder(Binder binder, TypeLiteral keyType, TypeLiteral valueType, Key> mapKey, Key>> providerMapKey, Key>> multimapKey, Key>>> providerMultimapKey, Multibinder>> entrySetBinder) { this.keyType = keyType; this.valueType = valueType; this.mapKey = mapKey; this.providerMapKey = providerMapKey; this.multimapKey = multimapKey; this.providerMultimapKey = providerMultimapKey; this.entrySetBinder = (RealMultibinder>>) entrySetBinder; this.binder = binder; } @Override public MapBinder permitDuplicates() { entrySetBinder.permitDuplicates(); binder.install(new MultimapBinder( multimapKey, providerMultimapKey, entrySetBinder.getSetKey())); return this; } /** * This creates two bindings. One for the {@code Map.Entry>} * and another for {@code V}. */ @Override public LinkedBindingBuilder addBinding(K key) { checkNotNull(key, "key"); checkConfiguration(!isInitialized(), "MapBinder was already initialized"); Key valueKey = Key.get(valueType, new RealElement(entrySetBinder.getSetName())); entrySetBinder.addBinding().toInstance(new MapEntry>(key, binder.getProvider(valueKey), valueKey)); return binder.bind(valueKey); } public void configure(Binder binder) { checkConfiguration(!isInitialized(), "MapBinder was already initialized"); final ImmutableSet> dependencies = ImmutableSet.>of(Dependency.get(entrySetBinder.getSetKey())); // Binds a Map> from a collection of Set>. final Provider>>> entrySetProvider = binder .getProvider(entrySetBinder.getSetKey()); binder.bind(providerMapKey).toProvider(new RealMapBinderProviderWithDependencies>>(mapKey) { private Map> providerMap; @SuppressWarnings({ "unused", "unchecked" }) @Toolable @Inject void initialize(Injector injector) { RealMapBinder.this.binder = null; permitDuplicates = entrySetBinder.permitsDuplicates(injector); Map> providerMapMutable = new LinkedHashMap>(); List>> bindingsMutable = Lists.newArrayList(); for (Entry> entry : entrySetProvider.get()) { Provider previous = providerMapMutable.put(entry.getKey(), entry.getValue()); checkConfiguration(previous == null || permitDuplicates, "Map injection failed due to duplicated key \"%s\"", entry.getKey()); Key valueKey = (Key)((MapEntry)entry).getValueKey(); bindingsMutable.add(new MapEntry(entry.getKey(), injector.getBinding(valueKey), valueKey)); } providerMap = ImmutableMap.copyOf(providerMapMutable); mapBindings = ImmutableList.copyOf(bindingsMutable); } public Map> get() { return providerMap; } public Set> getDependencies() { return dependencies; } }); final Provider>> mapProvider = binder.getProvider(providerMapKey); binder.bind(mapKey).toProvider(new RealMapWithExtensionProvider>(mapKey) { public Map get() { Map map = new LinkedHashMap(); for (Entry> entry : mapProvider.get().entrySet()) { V value = entry.getValue().get(); K key = entry.getKey(); checkConfiguration(value != null, "Map injection failed due to null value for key \"%s\"", key); map.put(key, value); } return Collections.unmodifiableMap(map); } public Set> getDependencies() { return dependencies; } @SuppressWarnings("unchecked") public R acceptExtensionVisitor(BindingTargetVisitor visitor, ProviderInstanceBinding binding) { if (visitor instanceof MultibindingsTargetVisitor) { return ((MultibindingsTargetVisitor, R>)visitor).visit(this); } else { return visitor.visit(binding); } } public Key> getMapKey() { return mapKey; } public TypeLiteral getKeyTypeLiteral() { return keyType; } public TypeLiteral getValueTypeLiteral() { return valueType; } @SuppressWarnings("unchecked") public List>> getEntries() { if (isInitialized()) { return (List)mapBindings; // safe because mapBindings is immutable } else { throw new UnsupportedOperationException("getElements() not supported for module bindings"); } } public boolean permitsDuplicates() { if (isInitialized()) { return permitDuplicates; } else { throw new UnsupportedOperationException("permitsDuplicates() not supported for module bindings"); } } public boolean containsElement(com.google.inject.spi.Element element) { if (entrySetBinder.containsElement(element)) { return true; } else { Key key; if (element instanceof Binding) { key = ((Binding)element).getKey(); } else if (element instanceof ProviderLookup) { key = ((ProviderLookup)element).getKey(); } else { return false; // cannot match; } return key.equals(mapKey) || key.equals(providerMapKey) || key.equals(multimapKey) || key.equals(providerMultimapKey) || key.equals(entrySetBinder.getSetKey()) || matchesValueKey(key); } } }); } /** Returns true if the key indicates this is a value in the map. */ private boolean matchesValueKey(Key key) { return key.getAnnotation() instanceof Element && ((Element) key.getAnnotation()).setName().equals(entrySetBinder.getSetName()) && key.getTypeLiteral().equals(valueType); } private boolean isInitialized() { return binder == null; } @Override public boolean equals(Object o) { return o instanceof RealMapBinder && ((RealMapBinder) o).mapKey.equals(mapKey); } @Override public int hashCode() { return mapKey.hashCode(); } /** * Binds {@code Map>} and {{@code Map>>}. */ private static final class MultimapBinder implements Module { private final Key>> multimapKey; private final Key>>> providerMultimapKey; private final Key>>> entrySetKey; public MultimapBinder( Key>> multimapKey, Key>>> providerMultimapKey, Key>>> entrySetKey) { this.multimapKey = multimapKey; this.providerMultimapKey = providerMultimapKey; this.entrySetKey = entrySetKey; } public void configure(Binder binder) { final ImmutableSet> dependencies = ImmutableSet.>of(Dependency.get(entrySetKey)); final Provider>>> entrySetProvider = binder.getProvider(entrySetKey); // Binds a Map>> from a collection of Map> if // permitDuplicates was called. binder.bind(providerMultimapKey).toProvider( new RealMapBinderProviderWithDependencies>>>(multimapKey) { private Map>> providerMultimap; @SuppressWarnings("unused") @Inject void initialize(Injector injector) { Map>> providerMultimapMutable = new LinkedHashMap>>(); for (Entry> entry : entrySetProvider.get()) { if (!providerMultimapMutable.containsKey(entry.getKey())) { providerMultimapMutable.put( entry.getKey(), ImmutableSet.>builder()); } providerMultimapMutable.get(entry.getKey()).add(entry.getValue()); } ImmutableMap.Builder>> providerMultimapBuilder = ImmutableMap.builder(); for (Entry>> entry : providerMultimapMutable.entrySet()) { providerMultimapBuilder.put(entry.getKey(), entry.getValue().build()); } providerMultimap = providerMultimapBuilder.build(); } public Map>> get() { return providerMultimap; } public Set> getDependencies() { return dependencies; } }); final Provider>>> multimapProvider = binder.getProvider(providerMultimapKey); binder.bind(multimapKey).toProvider(new RealMapBinderProviderWithDependencies>>(multimapKey) { public Map> get() { ImmutableMap.Builder> multimapBuilder = ImmutableMap.builder(); for (Entry>> entry : multimapProvider.get().entrySet()) { K key = entry.getKey(); ImmutableSet.Builder valuesBuilder = ImmutableSet.builder(); for (Provider valueProvider : entry.getValue()) { V value = valueProvider.get(); checkConfiguration(value != null, "Multimap injection failed due to null value for key \"%s\"", key); valuesBuilder.add(value); } multimapBuilder.put(key, valuesBuilder.build()); } return multimapBuilder.build(); } public Set> getDependencies() { return dependencies; } }); } @Override public int hashCode() { return multimapKey.hashCode(); } @Override public boolean equals(Object o) { return o instanceof MultimapBinder && ((MultimapBinder) o).multimapKey.equals(multimapKey); } } private static final class MapEntry implements Map.Entry { private final K key; private final V value; private final Key valueKey; private MapEntry(K key, V value, Key valueKey) { this.key = key; this.value = value; this.valueKey = valueKey; } public Key getValueKey() { return valueKey; } public K getKey() { return key; } public V getValue() { return value; } public V setValue(V value) { throw new UnsupportedOperationException(); } @Override public boolean equals(Object obj) { return obj instanceof Map.Entry && key.equals(((Map.Entry) obj).getKey()) && value.equals(((Map.Entry) obj).getValue()); } @Override public int hashCode() { return 127 * ("key".hashCode() ^ key.hashCode()) + 127 * ("value".hashCode() ^ value.hashCode()); } @Override public String toString() { return "MapEntry(" + key + ", " + value + ")"; } } private static abstract class RealMapWithExtensionProvider extends RealMapBinderProviderWithDependencies implements ProviderWithExtensionVisitor, MapBinderBinding { public RealMapWithExtensionProvider(Object equality) { super(equality); } } /** * A base class for ProviderWithDependencies that need equality * based on a specific object. */ private static abstract class RealMapBinderProviderWithDependencies implements ProviderWithDependencies { private final Object equality; public RealMapBinderProviderWithDependencies(Object equality) { this.equality = equality; } @Override public boolean equals(Object obj) { return this.getClass() == obj.getClass() && equality.equals(((RealMapBinderProviderWithDependencies)obj).equality); } } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/Element.javasisu-guice-sisu-guice-3.1.1/extensions/multibindings/src/com/google/inject/multibindings/Element.jav0000644000175000017500000000217211704661106032523 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.multibindings; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.BindingAnnotation; import java.lang.annotation.Retention; /** * An internal binding annotation applied to each element in a multibinding. * All elements are assigned a globally-unique id to allow different modules * to contribute multibindings independently. * * @author jessewilson@google.com (Jesse Wilson) */ @Retention(RUNTIME) @BindingAnnotation @interface Element { String setName(); int uniqueId(); } sisu-guice-sisu-guice-3.1.1/extensions/multibindings/pom.xml0000644000175000017500000000103611704661106022776 0ustar tonytony 4.0.0 org.sonatype.sisu.inject guice-extensions 3.1.1 guice-multibindings Sisu Guice - Extensions - MultiBindings sisu-guice-sisu-guice-3.1.1/extensions/multibindings/multibindings.iml0000644000175000017500000000111111704661106025026 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/multibindings/build.xml0000644000175000017500000000125711704661106023307 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/multibindings/build.properties0000644000175000017500000000024511704661106024677 0ustar tonytonylib.dir=../../lib src.dir=src test.dir=test build.dir=build test.class=com.google.inject.multibindings.AllTests module=com.google.inject.multibindings fragment=true sisu-guice-sisu-guice-3.1.1/extensions/mini/0000755000175000017500000000000011704661106017545 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/mini/test/0000755000175000017500000000000011704661106020524 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/mini/test/com/0000755000175000017500000000000011704661106021302 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/mini/test/com/google/0000755000175000017500000000000011704661106022556 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/mini/test/com/google/inject/0000755000175000017500000000000011704661106024032 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/mini/test/com/google/inject/mini/0000755000175000017500000000000011704661106024766 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/mini/test/com/google/inject/mini/MiniGuiceTest.java0000644000175000017500000001245111704661106030345 0ustar tonytony/* * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.mini; import com.google.inject.Provides; import junit.framework.TestCase; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Provider; import javax.inject.Singleton; public final class MiniGuiceTest extends TestCase { public void testBasicInjection() { G g = MiniGuice.inject(G.class, new Object() { @Provides E provideE(F f) { return new E(f); } @Provides F provideF() { return new F(); } }); assertNotNull(g.a); assertNotNull(g.b); assertNotNull(g.c); assertNotNull(g.d); assertNotNull(g.e); assertNotNull(g.e.f); } static class A { @Inject A() {} } static class B { @Inject B() {} } @Singleton static class C { @Inject C() {} } @Singleton static class D { @Inject D() {} } static class E { F f; E(F f) { this.f = f; } } static class F {} static class G { @Inject A a; @Inject B b; C c; D d; @Inject E e; @Inject G(C c, D d) { this.c = c; this.d = d; } } public void testProviderInjection() { H h = MiniGuice.inject(H.class); assertNotNull(h.aProvider.get()); assertNotNull(h.aProvider.get()); assertNotSame(h.aProvider.get(), h.aProvider.get()); } static class H { @Inject Provider aProvider; @Inject H() {} } public void testSingletons() { J j = MiniGuice.inject(J.class, new Object() { @Provides @Singleton F provideK() { return new F(); } }); assertSame(j.fProvider.get(), j.fProvider.get()); assertSame(j.iProvider.get(), j.iProvider.get()); } @Singleton static class I { @Inject I() {} } static class J { @Inject Provider fProvider; @Inject Provider iProvider; @Inject J() {} } public void testBindingAnnotations() { final A one = new A(); final A two = new A(); K k = MiniGuice.inject(K.class, new Object() { @Provides @Named("one") A getOne() { return one; } @Provides @Named("two") A getTwo() { return two; } }); assertNotNull(k.a); assertSame(one, k.aOne); assertSame(two, k.aTwo); } public static class K { @Inject A a; @Inject @Named("one") A aOne; @Inject @Named("two") A aTwo; } public void testSingletonBindingAnnotationAndProvider() { final AtomicReference a1 = new AtomicReference(); final AtomicReference a2 = new AtomicReference(); L l = MiniGuice.inject(L.class, new Object() { @Provides @Singleton @Named("one") F provideF(Provider aProvider) { a1.set(aProvider.get()); a2.set(aProvider.get()); return new F(); } }); assertNotNull(a1.get()); assertNotNull(a2.get()); assertNotSame(a1.get(), a2.get()); assertSame(l, l.lProvider.get()); } @Singleton public static class L { @Inject @Named("one") F f; @Inject Provider lProvider; } public void testSingletonInGraph() { M m = MiniGuice.inject(M.class, new Object() { @Provides @Singleton F provideF() { return new F(); } }); assertSame(m.f1, m.f2); assertSame(m.f1, m.n1.f1); assertSame(m.f1, m.n1.f2); assertSame(m.f1, m.n2.f1); assertSame(m.f1, m.n2.f2); assertSame(m.f1, m.n1.fProvider.get()); assertSame(m.f1, m.n2.fProvider.get()); } public static class M { @Inject N n1; @Inject N n2; @Inject F f1; @Inject F f2; } public static class N { @Inject F f1; @Inject F f2; @Inject Provider fProvider; } public void testNoJitBindingsForAnnotations() { try { MiniGuice.inject(O.class); fail(); } catch (IllegalArgumentException expected) { } } public static class O { @Inject @Named("a") A a; } public void testSubclasses() { Q q = MiniGuice.inject(Q.class, new Object() { @Provides F provideF() { return new F(); } }); assertNotNull(q.f); } public static class P { @Inject F f; } public static class Q extends P { @Inject Q() {} } public void testSingletonsAreEager() { final AtomicBoolean sInjected = new AtomicBoolean(); R.injected = false; MiniGuice.inject(A.class, new Object() { @Provides F provideF(R r) { return new F(); } @Provides @Singleton S provideS() { sInjected.set(true); return new S(); } }); assertTrue(R.injected); assertTrue(sInjected.get()); } @Singleton static class R { static boolean injected = false; @Inject R() { injected = true; } } static class S {} } sisu-guice-sisu-guice-3.1.1/extensions/mini/src/0000755000175000017500000000000011704661106020334 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/mini/src/com/0000755000175000017500000000000011704661106021112 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/mini/src/com/google/0000755000175000017500000000000011704661106022366 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/mini/src/com/google/inject/0000755000175000017500000000000011704661106023642 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/mini/src/com/google/inject/mini/0000755000175000017500000000000011704661106024576 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/mini/src/com/google/inject/mini/MiniGuice.java0000644000175000017500000003223711704661106027321 0ustar tonytony/* * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.mini; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Queue; import java.util.Set; import javax.inject.Provider; /** * Proof of concept. A tiny injector suitable for tiny applications. * * @author jessewilson@google.com (Jesse Wilson) * @since 3.0 */ public final class MiniGuice { private static final Object UNINITIALIZED = new Object(); private MiniGuice() {} private final Map> bindings = new HashMap>(); private final Queue requiredKeys = new ArrayDeque(); private final Set singletons = new HashSet(); /** * Creates an injector defined by {@code modules} and immediately uses it to * create an instance of {@code type}. The modules can be of any type, and * must contain {@code @Provides} methods. * *

    The following injection features are supported: *

    * *

    Note that method injection is not supported. */ public static T inject(Class type, Object... modules) { Key key = new Key(type, null); MiniGuice miniGuice = new MiniGuice(); for (Object module : modules) { miniGuice.install(module); } miniGuice.requireKey(key, "root injection"); miniGuice.addJitBindings(); miniGuice.addProviderBindings(); miniGuice.eagerlyLoadSingletons(); Provider provider = miniGuice.bindings.get(key); return type.cast(provider.get()); } private void addProviderBindings() { Map> providerBindings = new HashMap>(); for (final Map.Entry> binding : bindings.entrySet()) { Key key = binding.getKey(); final Provider value = binding.getValue(); Provider> providerProvider = new Provider>() { public Provider get() { return value; } }; providerBindings.put(new Key(new ProviderType(javax.inject.Provider.class, key.type), key.annotation), providerProvider); } bindings.putAll(providerBindings); } private void requireKey(Key key, Object requiredBy) { if (key.type instanceof ParameterizedType && (((ParameterizedType) key.type).getRawType() == Provider.class || ((ParameterizedType) key.type).getRawType() == javax.inject.Provider.class)) { Type type = ((ParameterizedType) key.type).getActualTypeArguments()[0]; key = new Key(type, key.annotation); } requiredKeys.add(new RequiredKey(key, requiredBy)); } private void eagerlyLoadSingletons() { for (Key key : singletons) { Provider provider = bindings.get(key); final Object onlyInstance = provider.get(); bindings.put(key, new Provider() { public Object get() { return onlyInstance; } }); } } public void install(Object module) { boolean hasProvidesMethods = false; for (Class c = module.getClass(); c != Object.class; c = c.getSuperclass()) { for (Method method : c.getDeclaredMethods()) { if (method.getAnnotation(com.google.inject.Provides.class) != null) { Key key = key(method, method.getGenericReturnType(), method.getAnnotations()); addProviderMethodBinding(key, module, method); hasProvidesMethods = true; } } } if (!hasProvidesMethods) { throw new IllegalArgumentException("No @Provides methods on " + module); } } private void addProviderMethodBinding(Key key, final Object instance, final Method method) { final Key[] parameterKeys = parametersToKeys( method, method.getGenericParameterTypes(), method.getParameterAnnotations()); method.setAccessible(true); final Provider unscoped = new Provider() { public Object get() { Object[] parameters = keysToValues(parameterKeys); try { return method.invoke(instance, parameters); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e.getCause()); } } }; boolean singleton = method.getAnnotation(javax.inject.Singleton.class) != null; putBinding(key, unscoped, singleton); } private void addJitBindings() { RequiredKey requiredKey; while ((requiredKey = requiredKeys.poll()) != null) { Key key = requiredKey.key; if (bindings.containsKey(key)) { continue; } if (!(key.type instanceof Class) || key.annotation != null) { throw new IllegalArgumentException("No binding for " + key); } addJitBinding(key, requiredKey.requiredBy); } } private void addJitBinding(Key key, Object requiredBy) { Class type = (Class) key.type; /* * Lookup the injectable fields and their corresponding keys. */ final List injectedFields = new ArrayList(); List fieldKeysList = new ArrayList(); for (Class c = type; c != Object.class; c = c.getSuperclass()) { for (Field field : c.getDeclaredFields()) { if (field.getAnnotation(javax.inject.Inject.class) == null) { continue; } field.setAccessible(true); injectedFields.add(field); Key fieldKey = key(field, field.getGenericType(), field.getAnnotations()); fieldKeysList.add(fieldKey); requireKey(fieldKey, field); } } final Key[] fieldKeys = fieldKeysList.toArray(new Key[fieldKeysList.size()]); /* * Lookup @Inject-annotated constructors. If there's no @Inject-annotated * constructor, use a default constructor if the class has other injections. */ Constructor injectedConstructor = null; for (Constructor constructor : type.getDeclaredConstructors()) { if (constructor.getAnnotation(javax.inject.Inject.class) == null) { continue; } if (injectedConstructor != null) { throw new IllegalArgumentException("Too many injectable constructors on " + type); } constructor.setAccessible(true); injectedConstructor = constructor; } if (injectedConstructor == null) { if (fieldKeys.length == 0) { throw new IllegalArgumentException("No injectable constructor on " + type + " required by " + requiredBy); } try { injectedConstructor = type.getConstructor(); } catch (NoSuchMethodException e) { throw new IllegalArgumentException("No injectable constructor on " + type + " required by " + requiredBy); } } /* * Create a provider that invokes the constructor and sets its fields. */ final Constructor constructor = injectedConstructor; final Key[] parameterKeys = parametersToKeys( constructor, constructor.getGenericParameterTypes(), constructor.getParameterAnnotations()); final Provider unscoped = new Provider() { public Object get() { Object[] constructorParameters = keysToValues(parameterKeys); try { Object result = constructor.newInstance(constructorParameters); Object[] fieldValues = keysToValues(fieldKeys); for (int i = 0; i < fieldValues.length; i++) { injectedFields.get(i).set(result, fieldValues[i]); } return result; } catch (IllegalAccessException e) { throw new RuntimeException(e.getCause()); } catch (InvocationTargetException e) { throw new RuntimeException(e.getCause()); } catch (InstantiationException e) { throw new RuntimeException(e); } } }; boolean singleton = type.getAnnotation(javax.inject.Singleton.class) != null; putBinding(new Key(type, null), unscoped, singleton); } private void putBinding(Key key, Provider provider, boolean singleton) { if (singleton) { singletons.add(key); final Provider unscoped = provider; provider = new Provider() { private Object onlyInstance = UNINITIALIZED; public Object get() { if (onlyInstance == UNINITIALIZED) { onlyInstance = unscoped.get(); } return onlyInstance; } }; } if (bindings.put(key, provider) != null) { throw new IllegalArgumentException("Duplicate binding " + key); } } private Object[] keysToValues(Key[] parameterKeys) { Object[] parameters = new Object[parameterKeys.length]; for (int i = 0; i < parameterKeys.length; i++) { parameters[i] = bindings.get(parameterKeys[i]).get(); } return parameters; } private Key[] parametersToKeys(Member member, Type[] types, Annotation[][] annotations) { final Key[] parameterKeys = new Key[types.length]; for (int i = 0; i < parameterKeys.length; i++) { String name = member + " parameter " + i; parameterKeys[i] = key(name, types[i], annotations[i]); requireKey(parameterKeys[i], name); } return parameterKeys; } public Key key(Object subject, Type type, Annotation[] annotations) { Annotation bindingAnnotation = null; for (Annotation a : annotations) { if (a.annotationType().getAnnotation(javax.inject.Qualifier.class) == null) { continue; } if (bindingAnnotation != null) { throw new IllegalArgumentException("Too many binding annotations on " + subject); } bindingAnnotation = a; } return new Key(type, bindingAnnotation); } private static boolean equal(Object a, Object b) { return a == null ? b == null : a.equals(b); } private static final class Key { final Type type; final Annotation annotation; Key(Type type, Annotation annotation) { this.type = type; this.annotation = annotation; } @Override public boolean equals(Object o) { return o instanceof Key && ((Key) o).type.equals(type) && equal(annotation, ((Key) o).annotation); } @Override public int hashCode() { int result = type.hashCode(); if (annotation != null) { result += (37 * annotation.hashCode()); } return result; } @Override public String toString() { return "key[type=" + type + ",annotation=" + annotation + "]"; } } private class RequiredKey { private final Key key; private final Object requiredBy; private RequiredKey(Key key, Object requiredBy) { this.key = key; this.requiredBy = requiredBy; } } private static final class ProviderType implements ParameterizedType { private final Class rawType; private final Type typeArgument; public ProviderType(Class rawType, Type typeArgument) { this.rawType = rawType; this.typeArgument = typeArgument; } public Type getRawType() { return rawType; } public Type[] getActualTypeArguments() { return new Type[] { typeArgument }; } public Type getOwnerType() { return null; } @Override public boolean equals(Object o) { if (o instanceof ParameterizedType) { ParameterizedType that = (ParameterizedType) o; return Arrays.equals(getActualTypeArguments(), that.getActualTypeArguments()) && that.getRawType() == rawType; } return false; } @Override public int hashCode() { return Arrays.hashCode(getActualTypeArguments()) ^ rawType.hashCode(); } } } sisu-guice-sisu-guice-3.1.1/extensions/mini/pom.xml0000644000175000017500000000102311704661106021056 0ustar tonytony 4.0.0 org.sonatype.sisu.inject guice-extensions 3.0-SNAPSHOT guice-mini Sisu Guice - Extensions - Mini sisu-guice-sisu-guice-3.1.1/extensions/jndi/0000755000175000017500000000000011704661106017535 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jndi/test/0000755000175000017500000000000011704661106020514 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jndi/test/placeholder.txt0000644000175000017500000000000011704661106023525 0ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jndi/src/0000755000175000017500000000000011704661106020324 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jndi/src/com/0000755000175000017500000000000011704661106021102 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jndi/src/com/google/0000755000175000017500000000000011704661106022356 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jndi/src/com/google/inject/0000755000175000017500000000000011704661106023632 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jndi/src/com/google/inject/jndi/0000755000175000017500000000000011704661106024556 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jndi/src/com/google/inject/jndi/package-info.java0000644000175000017500000000130411704661106027743 0ustar tonytony/* * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * JNDI integration; this extension requires {@code guice-jndi-3.0.jar}. */ package com.google.inject.jndi;sisu-guice-sisu-guice-3.1.1/extensions/jndi/src/com/google/inject/jndi/JndiIntegration.java0000644000175000017500000000330411704661106030511 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.jndi; import com.google.inject.Inject; import com.google.inject.Provider; import javax.naming.Context; import javax.naming.NamingException; /** * Integrates Guice with JNDI. Requires a binding to * {@link javax.naming.Context}. * * @author crazybob@google.com (Bob Lee) */ public class JndiIntegration { private JndiIntegration() {} /** * Creates a provider which looks up objects in JNDI using the given name. * Example usage: * *
       * bind(DataSource.class).toProvider(fromJndi(DataSource.class, "java:..."));
       * 
    */ public static Provider fromJndi(Class type, String name) { return new JndiProvider(type, name); } static class JndiProvider implements Provider { @Inject Context context; final Class type; final String name; public JndiProvider(Class type, String name) { this.type = type; this.name = name; } public T get() { try { return type.cast(context.lookup(name)); } catch (NamingException e) { throw new RuntimeException(e); } } } } sisu-guice-sisu-guice-3.1.1/extensions/jndi/pom.xml0000644000175000017500000000101411704661106021046 0ustar tonytony 4.0.0 org.sonatype.sisu.inject guice-extensions 3.1.1 guice-jndi Sisu Guice - Extensions - JNDI sisu-guice-sisu-guice-3.1.1/extensions/jndi/jndi.iml0000644000175000017500000000076311704661106021172 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/jndi/build.xml0000644000175000017500000000124611704661106021361 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/jndi/build.properties0000644000175000017500000000013211704661106022746 0ustar tonytonylib.dir=../../lib src.dir=src test.dir=test build.dir=build module=com.google.inject.jndi sisu-guice-sisu-guice-3.1.1/extensions/jmx/0000755000175000017500000000000011704661106017407 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jmx/test/0000755000175000017500000000000011704661106020366 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jmx/test/com/0000755000175000017500000000000011704661106021144 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jmx/test/com/google/0000755000175000017500000000000011704661106022420 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jmx/test/com/google/inject/0000755000175000017500000000000011704661106023674 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jmx/test/com/google/inject/tools/0000755000175000017500000000000011704661106025034 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jmx/test/com/google/inject/tools/jmx/0000755000175000017500000000000011704661106025632 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jmx/test/com/google/inject/tools/jmx/JmxTest.java0000644000175000017500000000336111704661106030076 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.tools.jmx; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.AbstractModule; import com.google.inject.BindingAnnotation; import com.google.inject.Key; import com.google.inject.Singleton; import com.google.inject.name.Names; import java.lang.annotation.Retention; /** * @author crazybob@google.com (Bob Lee) */ public class JmxTest { interface Foo {} static class FooImpl implements Foo {} @Singleton static class TransactionalFoo implements Foo {} static class Bar {} @BindingAnnotation @Retention(RUNTIME) @interface Transactional {} public static void main(String[] args) throws Exception { Manager.main(new String[] { TestModule.class.getName() }); } public static class TestModule extends AbstractModule { protected void configure() { bind(Foo.class).to(FooImpl.class); bind(Bar.class); bind(Foo.class) .annotatedWith(Transactional.class) .to(FooImpl.class); bindConstant().annotatedWith(Names.named("port")).to(8080); bind(Key.get(Object.class)).to(Key.get(Bar.class)); // install(new ServletModule()); } } } sisu-guice-sisu-guice-3.1.1/extensions/jmx/src/0000755000175000017500000000000011704661106020176 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jmx/src/com/0000755000175000017500000000000011704661106020754 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jmx/src/com/google/0000755000175000017500000000000011704661106022230 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jmx/src/com/google/inject/0000755000175000017500000000000011704661106023504 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jmx/src/com/google/inject/tools/0000755000175000017500000000000011704661106024644 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jmx/src/com/google/inject/tools/jmx/0000755000175000017500000000000011704661106025442 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/jmx/src/com/google/inject/tools/jmx/package-info.java0000644000175000017500000000130711704661106030632 0ustar tonytony/* * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * JMX integration; this extension requires {@code guice-jmx-3.0.jar}. */ package com.google.inject.tools.jmx;sisu-guice-sisu-guice-3.1.1/extensions/jmx/src/com/google/inject/tools/jmx/Manager.java0000644000175000017500000000712411704661106027663 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.tools.jmx; import com.google.inject.Binding; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import java.lang.annotation.Annotation; import java.lang.management.ManagementFactory; import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; /** * Provides a JMX interface to Guice. * * @author crazybob@google.com (Bob Lee) */ public class Manager { /** * Registers all the bindings of an Injector with the platform MBean server. * Consider using the name of your root {@link Module} class as the domain. */ public static void manage( String domain, Injector injector) { manage(ManagementFactory.getPlatformMBeanServer(), domain, injector); } /** * Registers all the bindings of an Injector with the given MBean server. * Consider using the name of your root {@link Module} class as the domain. */ public static void manage(MBeanServer server, String domain, Injector injector) { // Register each binding independently. for (Binding binding : injector.getBindings().values()) { // Construct the name manually so we can ensure proper ordering of the // key/value pairs. StringBuilder name = new StringBuilder(); name.append(domain).append(":"); Key key = binding.getKey(); name.append("type=").append(quote(key.getTypeLiteral().toString())); Annotation annotation = key.getAnnotation(); if (annotation != null) { name.append(",annotation=").append(quote(annotation.toString())); } else { Class annotationType = key.getAnnotationType(); if (annotationType != null) { name.append(",annotation=") .append(quote("@" + annotationType.getName())); } } try { server.registerMBean(new ManagedBinding(binding), new ObjectName(name.toString())); } catch (MalformedObjectNameException e) { throw new RuntimeException("Bad object name: " + name.toString(), e); } catch (Exception e) { throw new RuntimeException(e); } } } static String quote(String value) { // JMX seems to have a comma bug. return ObjectName.quote(value).replace(',', ';'); } /** * Run with no arguments for usage instructions. */ public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("Usage: java -Dcom.sun.management.jmxremote " + Manager.class.getName() + " [module class name]"); System.err.println("Then run 'jconsole' to connect."); System.exit(1); } Module module = (Module) Class.forName(args[0]).newInstance(); Injector injector = Guice.createInjector(module); manage(args[0], injector); System.out.println("Press Ctrl+C to exit..."); // Sleep forever. Thread.sleep(Long.MAX_VALUE); } } sisu-guice-sisu-guice-3.1.1/extensions/jmx/src/com/google/inject/tools/jmx/ManagedBindingMBean.java0000644000175000017500000000172611704661106032045 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.tools.jmx; /** * JMX interface to bindings. * * @author crazybob@google.com (Bob Lee) */ public interface ManagedBindingMBean { /** * Gets the source of this binding. */ String getSource(); /** * Gets the provider to which this binding is bound. */ String getProvider(); /** * Gets the binding key. */ String getKey(); } sisu-guice-sisu-guice-3.1.1/extensions/jmx/src/com/google/inject/tools/jmx/ManagedBinding.java0000644000175000017500000000203511704661106031134 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.tools.jmx; import com.google.inject.Binding; class ManagedBinding implements ManagedBindingMBean { final Binding binding; ManagedBinding(Binding binding) { this.binding = binding; } public String getSource() { return binding.getSource().toString(); } public String getKey() { return binding.getKey().toString(); } public String getProvider() { return binding.getProvider().toString(); } } sisu-guice-sisu-guice-3.1.1/extensions/jmx/pom.xml0000644000175000017500000000101211704661106020716 0ustar tonytony 4.0.0 org.sonatype.sisu.inject guice-extensions 3.1.1 guice-jmx Sisu Guice - Extensions - JMX sisu-guice-sisu-guice-3.1.1/extensions/jmx/jmx.iml0000644000175000017500000000107511704661106020713 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/jmx/build.xml0000644000175000017500000000124511704661106021232 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/jmx/build.properties0000644000175000017500000000013711704661106022625 0ustar tonytonylib.dir=../../lib src.dir=src test.dir=test build.dir=build module=com.google.inject.tools.jmx sisu-guice-sisu-guice-3.1.1/extensions/grapher/0000755000175000017500000000000011704661106020241 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/grapher/test/0000755000175000017500000000000011704661106021220 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/0000755000175000017500000000000011704661106021776 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/0000755000175000017500000000000011704661106023252 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/0000755000175000017500000000000011704661106024526 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/0000755000175000017500000000000011704661106026156 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/0000755000175000017500000000000011704661106027102 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/Used.java0000644000175000017500000000174011704661106030647 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.BindingAnnotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; @Retention(RUNTIME) @Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @BindingAnnotation @interface Used {}sisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/Renewable.java0000644000175000017500000000174511704661106031660 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.BindingAnnotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; @Retention(RUNTIME) @Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @BindingAnnotation @interface Renewable {}././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/PrivateTestModule.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/PrivateTestModule0000644000175000017500000000201111704661106032437 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import com.google.inject.PrivateModule; /** * Module to test private modules and exposed bindings. * * @author bojand@google.com (Bojan Djordjevic) */ public class PrivateTestModule extends PrivateModule { interface Exposed {} static class Hidden implements Exposed {} @Override protected void configure() { bind(Exposed.class).to(Hidden.class); expose(Exposed.class); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/PlutoniumProvider.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/PlutoniumProvider0000644000175000017500000000161211704661106032534 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import com.google.inject.Inject; import com.google.inject.Provider; class PlutoniumProvider implements Provider { @Inject public PlutoniumProvider(@Inventor Person inventor, @Used PinballParts parts) {} public Plutonium get() { return null; } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/Plutonium.java0000644000175000017500000000125011704661106031737 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; class Plutonium implements EnergySource {}sisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/PinballParts.java0000644000175000017500000000162211704661106032341 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import com.google.inject.Inject; import com.google.inject.Provider; class PinballParts { // Shows up as an injection point on an instance. We use a Provider so that // it doesn't have to be satisfied when the Injector is created. @Inject Provider salvager; } sisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/Person.java0000644000175000017500000000122111704661106031207 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; interface Person {}sisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/Nuclear.java0000644000175000017500000000174311704661106031343 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.BindingAnnotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; @Retention(RUNTIME) @Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @BindingAnnotation @interface Nuclear {}././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/MultibinderModule.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/MultibinderModule0000644000175000017500000000221511704661106032451 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import com.google.inject.AbstractModule; import com.google.inject.multibindings.Multibinder; /** * Module to add {@link Multibinder}-based bindings to the injector. * * @author phopkins@gmail.com (Pete Hopkins) */ public class MultibinderModule extends AbstractModule { @Override protected void configure() { Multibinder charactersBinder = Multibinder.newSetBinder(binder(), Person.class); charactersBinder.addBinding().to(MartyMcFly.class); charactersBinder.addBinding().to(DocBrown.class); } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/MartyMcFly.java0000644000175000017500000000124311704661106031774 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; class MartyMcFly implements Person {}sisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/Lightning.java0000644000175000017500000000143611704661106031674 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import com.google.inject.Inject; import com.google.inject.name.Named; class Lightning implements EnergySource { @Inject @Named("year") String yearOfStrike; }sisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/Inventor.java0000644000175000017500000000174411704661106031557 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.BindingAnnotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; @Retention(RUNTIME) @Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @BindingAnnotation @interface Inventor {}././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/InjectorGrapherDemo.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/InjectorGrapherDe0000644000175000017500000000333311704661106032366 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Stage; import com.google.inject.grapher.graphviz.GraphvizGrapher; import com.google.inject.grapher.graphviz.GraphvizModule; import java.io.File; import java.io.PrintWriter; /** * Application that instantiates {@link BackToTheFutureModule} and graphs it, * writing the output to a DOT-formatted file (filename specified on the * command line). * * @author phopkins@gmail.com (Pete Hopkins) */ public class InjectorGrapherDemo { public static void main(String[] args) throws Exception { // TODO(phopkins): Switch to Stage.TOOL when issue 297 is fixed. Injector demoInjector = Guice.createInjector(Stage.DEVELOPMENT, new BackToTheFutureModule(), new MultibinderModule(), new PrivateTestModule()); PrintWriter out = new PrintWriter(new File(args[0]), "UTF-8"); Injector injector = Guice.createInjector(new GraphvizModule()); GraphvizGrapher grapher = injector.getInstance(GraphvizGrapher.class); grapher.setOut(out); grapher.setRankdir("TB"); grapher.graph(demoInjector); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/FluxCapacitor.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/FluxCapacitor.jav0000644000175000017500000000122411704661106032347 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; class FluxCapacitor {}././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/EnergySourceProvider.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/EnergySourceProvi0000644000175000017500000000205311704661106032457 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.name.Named; class EnergySourceProvider implements Provider { @Inject void setSources(@Nuclear EnergySource nuclear, @Renewable EnergySource renewable) {} // This will demonstrate a ConvertedConstantBinding. @Inject void setYear(@Named("year") int year) {} public EnergySource get() { return null; } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/EnergySource.java0000644000175000017500000000134511704661106032362 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import com.google.inject.ProvidedBy; @ProvidedBy(EnergySourceProvider.class) interface EnergySource {}sisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/Driver.java0000644000175000017500000000174211704661106031204 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.BindingAnnotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; @Retention(RUNTIME) @Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @BindingAnnotation @interface Driver {}sisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/DocBrown.java0000644000175000017500000000141511704661106031463 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import com.google.inject.Inject; class DocBrown implements Person { // handy because it introduces a cycle @Inject DeLorian stylishCar; } sisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/DeLorian.java0000644000175000017500000000204011704661106031436 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import com.google.inject.Inject; import com.google.inject.Provider; class DeLorian { // We @Inject a Provider to demonstrate that the graph doesn't differentiate // between a Provider and just @Injecting T. @Inject @Driver Provider driver; @Inject FluxCapacitor fluxCapacitor; @Inject PrivateTestModule.Exposed exposed; @Inject public void setEnergySource(EnergySource energySource) {} } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/DancePartyImpl.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/DancePartyImpl.ja0000644000175000017500000000153311704661106032274 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; class DancePartyImpl implements DanceParty { @Inject public DancePartyImpl(@Assisted String thatNewSound, MartyMcFly guitarist) {} } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/DancePartyFactory.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/DancePartyFactory0000644000175000017500000000147511704661106032416 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; /** * Interface to be used with {@link FactoryProvider}. * * @author phopkins@gmail.com (Pete Hopkins) */ interface DancePartyFactory { DanceParty newDanceParty(String thatNewSound); } sisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/DanceParty.java0000644000175000017500000000122611704661106032000 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; interface DanceParty {} ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/BackToTheFutureModule.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/BackToTheFutureMo0000644000175000017500000000342511704661106032324 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import com.google.inject.AbstractModule; import com.google.inject.Provides; import com.google.inject.Singleton; import com.google.inject.name.Names; /** * Module that adds a variety of different kinds of {@link Bindings} to be used * to generate a comprehensive sample graph. * * @see InjectorGrapherDemo * * @author phopkins@gmail.com (Pete Hopkins) */ public class BackToTheFutureModule extends AbstractModule { @Override protected void configure() { bind(DeLorian.class); bind(EnergySource.class).annotatedWith(Nuclear.class).to(Plutonium.class); bind(EnergySource.class).annotatedWith(Renewable.class).to(Lightning.class); bind(Plutonium.class).toProvider(PlutoniumProvider.class); bind(PinballParts.class).annotatedWith(Used.class).toInstance(new PinballParts()); bind(Person.class).annotatedWith(Driver.class).to(MartyMcFly.class).in(Singleton.class); bind(Person.class).annotatedWith(Inventor.class).to(DocBrown.class).in(Singleton.class); bindConstant().annotatedWith(Names.named("year")).to("1955"); } @Provides public FluxCapacitor provideFluxCapacitor(EnergySource energySource) { return null; } }././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/AssistedInjectModule.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/demo/AssistedInjectMod0000644000175000017500000000215611704661106032405 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.demo; import com.google.inject.AbstractModule; import com.google.inject.assistedinject.FactoryModuleBuilder; /** * Module to add {@link AssistedInject}-based elements to the demo * {@link Injector}. * * @author phopkins@gmail.com (Pete Hopkins) */ public class AssistedInjectModule extends AbstractModule { @Override protected void configure() { install(new FactoryModuleBuilder() .implement(DanceParty.class, DancePartyImpl.class) .build(DancePartyFactory.class)); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/TransitiveDependencyVisitorTest.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/TransitiveDependencyVi0000644000175000017500000001645211704661106032537 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.collect.ImmutableSet; import com.google.inject.AbstractModule; import com.google.inject.Binding; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provider; import com.google.inject.TypeLiteral; import com.google.inject.name.Names; import com.google.inject.spi.ConstructorBinding; import com.google.inject.spi.ConvertedConstantBinding; import com.google.inject.spi.Dependency; import com.google.inject.spi.HasDependencies; import com.google.inject.spi.InstanceBinding; import com.google.inject.spi.LinkedKeyBinding; import com.google.inject.spi.ProviderBinding; import com.google.inject.spi.ProviderInstanceBinding; import com.google.inject.spi.ProviderKeyBinding; import junit.framework.TestCase; import java.util.Collection; import java.util.Set; /** * Tests for {@link TransitiveDependencyVisitor}. * * @author phopkins@gmail.com (Pete Hopkins) */ public class TransitiveDependencyVisitorTest extends TestCase { private TransitiveDependencyVisitor visitor; @Override protected void setUp() throws Exception { super.setUp(); visitor = new TransitiveDependencyVisitor(); } public void testVisitConstructor() { Binding binding = getBinding(Key.get(ConstructedClass.class)); Collection> dependencies = visitor.visit((ConstructorBinding) binding); assertDependencies(dependencies, Key.get(A.class), Key.get(B.class), Key.get(C.class), Key.get(D.class)); } public void testVisitConvertedConstant() { Binding binding = getBinding(Key.get(Integer.class, Names.named("number")), new ConvertedConstantModule()); Collection> dependencies = visitor.visit( (ConvertedConstantBinding) binding); assertDependencies(dependencies, Key.get(String.class, Names.named("number"))); } public void testVisitInstance() { Binding binding = getBinding(Key.get(ConstructedClass.class), new InstanceModule()); Collection> dependencies = visitor.visit( (InstanceBinding) binding); // Dependencies will only be on the field- and method-injected classes. assertDependencies(dependencies, Key.get(A.class), Key.get(D.class)); } public void testVisitInstance_instanceHasDependencies() { Binding binding = getBinding(Key.get(Interface.class), new HasDependenciesModule()); Collection> dependencies = visitor.visit( (InstanceBinding) binding); // Dependencies should only be on the stated // HasDependencies#getDependencies() values assertDependencies(dependencies, Key.get(G.class)); } public void testVisitLinkedKey() { Binding binding = getBinding(Key.get(Interface.class), new LinkedKeyModule()); Collection> dependencies = visitor.visit((LinkedKeyBinding) binding); // Dependency should be to the class this interface is bound to. assertDependencies(dependencies, Key.get(ConstructedClass.class)); } public void testVisitProviderBinding() { Binding binding = getBinding(Key.get(new TypeLiteral>() {})); Collection> dependencies = visitor.visit((ProviderBinding) binding); assertDependencies(dependencies, Key.get(ConstructedClass.class)); } public void testVisitProviderInstance() { Binding binding = getBinding(Key.get(ConstructedClass.class), new ProviderInstanceModule()); Collection> dependencies = visitor.visit( (ProviderInstanceBinding) binding); // Dependencies will only be on the field- and method-injected classes. assertDependencies(dependencies, Key.get(E.class), Key.get(F.class)); } public void testVisitProviderKey() { Binding binding = getBinding(Key.get(ConstructedClass.class), new ProviderKeyModule()); Collection> dependencies = visitor.visit((ProviderKeyBinding) binding); // Dependency should be to the class that provides this one. assertDependencies(dependencies, Key.get(ConstructedClassProvider.class)); } private Binding getBinding(Key key, Module... modules) { return Guice.createInjector(modules).getBinding(key); } private void assertDependencies(Collection> dependencies, Key... keys) { assertNotNull("Dependencies should not be null", dependencies); assertEquals("There should be " + keys.length + " dependencies", keys.length, dependencies.size()); for (Key key : keys) { assertTrue("Dependencies should contain " + key, dependencies.contains(key)); } } private static class A {} private static class B {} private static class C {} private static class D {} private static class E {} private static class F {} private static class G {} private static interface Interface {} private static class ConstructedClass implements Interface { @Inject A a; ConstructedClass() {} @Inject ConstructedClass(B b, C c) {} @Inject void setD(D d) {} } private static class ConstructedClassProvider implements Provider { @Inject E e; ConstructedClassProvider() {} @Inject ConstructedClassProvider(A a, B b, C c) {} @Inject void setF(F f) {} public ConstructedClass get() { return null; } } private static class HasDependenciesClass implements Interface, HasDependencies { @Inject A a; @Inject B b; public Set> getDependencies() { return ImmutableSet.>of(Dependency.get(Key.get(G.class))); } } private static class ConvertedConstantModule extends AbstractModule { @Override protected void configure() { bindConstant().annotatedWith(Names.named("number")).to("2008"); } } private static class InstanceModule extends AbstractModule { @Override protected void configure() { bind(ConstructedClass.class).toInstance(new ConstructedClass()); } } private static class LinkedKeyModule extends AbstractModule { @Override protected void configure() { bind(Interface.class).to(ConstructedClass.class); } } private static class ProviderInstanceModule extends AbstractModule { @Override protected void configure() { bind(ConstructedClass.class).toProvider(new ConstructedClassProvider()); } } private static class HasDependenciesModule extends AbstractModule { @Override protected void configure() { bind(Interface.class).toInstance(new HasDependenciesClass()); } } private static class ProviderKeyModule extends AbstractModule { @Override protected void configure() { bind(ConstructedClass.class).toProvider(ConstructedClassProvider.class); } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/ShortNameFactoryTest.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/ShortNameFactoryTest.j0000644000175000017500000001444011704661106032424 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.AbstractModule; import com.google.inject.BindingAnnotation; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.Provides; import com.google.inject.TypeLiteral; import com.google.inject.internal.ProviderMethod; import com.google.inject.internal.util.StackTraceElements; import com.google.inject.name.Names; import com.google.inject.spi.DefaultBindingTargetVisitor; import com.google.inject.spi.ProviderInstanceBinding; import junit.framework.TestCase; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; import java.lang.reflect.Member; /** * Tests for {@link ShortNameFactory}. * * @author phopkins@gmail.com (Pete Hopkins) */ public class ShortNameFactoryTest extends TestCase { // Helper objects are up here because their line numbers are tested below. private static class Obj { @Annotated public String field; Obj() {} void method(String parameter) {} } private static class ToStringObj { @Override public String toString() { return "I'm a ToStringObj"; } } @Retention(RUNTIME) @Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @BindingAnnotation private @interface Annotated {} private NameFactory nameFactory; @Override protected void setUp() throws Exception { super.setUp(); nameFactory = new ShortNameFactory(); } public void testGetMemberName_field() throws Exception { Member field = Obj.class.getDeclaredField("field"); assertEquals("field", nameFactory.getMemberName(field)); } public void testGetMemberName_method() throws Exception { Member method = Obj.class.getDeclaredMethod("method", String.class); assertEquals("#method(...)", nameFactory.getMemberName(method)); } public void testGetMemberName_constructor() throws Exception { Member constructor = Obj.class.getDeclaredConstructor(); assertEquals("", nameFactory.getMemberName(constructor)); } public void testGetAnnotationName_annotationType() throws Exception { Key key = Key.get(String.class, Annotated.class); assertEquals("@Annotated", nameFactory.getAnnotationName(key)); } public void testGetAnnotationName_annotationInstance() throws Exception { Key key = Key.get(String.class, Obj.class.getDeclaredField("field").getDeclaredAnnotations()[0]); assertEquals("@Annotated", nameFactory.getAnnotationName(key)); } public void testGetAnnotationName_annotationInstanceWithParameters() throws Exception { Key key = Key.get(String.class, Names.named("name")); assertEquals("@Named(value=name)", nameFactory.getAnnotationName(key)); } public void testGetClassName_key() throws Exception { Key key = Key.get(Obj.class); assertEquals("Class name should not have the package", "ShortNameFactoryTest$Obj", nameFactory.getClassName(key)); } public void testGetClassName_keyWithTypeParameters() throws Exception { Key key = Key.get(new TypeLiteral>() {}); assertEquals("Class name and type values should not have packages", "Provider", nameFactory.getClassName(key)); } /** * Tests the case where a provider method is the source of the * @throws Exception */ public void testGetSourceName_method() throws Exception { Member method = Obj.class.getDeclaredMethod("method", String.class); assertEquals("Method should be identified by its file name and line number", "ShortNameFactoryTest.java:53", nameFactory.getSourceName(method)); } public void testGetSourceName_stackTraceElement() throws Exception { StackTraceElement element = (StackTraceElement) StackTraceElements.forMember(Obj.class.getField("field")); assertEquals("Stack trace element should be identified by its file name and line number", "ShortNameFactoryTest.java:52", nameFactory.getSourceName(element)); } public void testGetInstanceName_defaultToString() throws Exception { assertEquals("Should use class name instead of Object#toString()", "ShortNameFactoryTest$Obj", nameFactory.getInstanceName(new Obj())); } public void testGetInstanceName_customToString() throws Exception { assertEquals("Should use class's toString() method since it's defined", "I'm a ToStringObj", nameFactory.getInstanceName(new ToStringObj())); } public void testGetInstanceName_string() throws Exception { assertEquals("String should have quotes to evoke a string literal", "\"My String Instance\"", nameFactory.getInstanceName("My String Instance")); } public void testGetInstanceName_providerMethod() throws Exception { final ProviderMethod[] methodHolder = new ProviderMethod[1]; Injector injector = Guice.createInjector(new ProvidingModule()); injector.getBinding(Integer.class).acceptTargetVisitor( new DefaultBindingTargetVisitor() { @SuppressWarnings("unchecked") @Override public Void visit(ProviderInstanceBinding binding) { methodHolder[0] = (ProviderMethod) binding.getProviderInstance(); return null; } }); assertEquals("Method provider should pretty print as the method signature", "#provideInteger(String)", nameFactory.getInstanceName(methodHolder[0])); } private static class ProvidingModule extends AbstractModule { @Override protected void configure() {} @Provides public Integer provideInteger(String string) { return Integer.valueOf(string); } } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/AllTests.java0000644000175000017500000000202311704661106030551 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import junit.framework.Test; import junit.framework.TestSuite; /** * @author phopkins@gmail.com (Pete Hopkins) */ public class AllTests { public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(AbstractInjectorGrapherTest.class); suite.addTestSuite(ShortNameFactoryTest.class); suite.addTestSuite(TransitiveDependencyVisitorTest.class); return suite; } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/AbstractInjectorGrapherTest.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/test/com/google/inject/grapher/AbstractInjectorGraphe0000644000175000017500000001530111704661106032471 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.inject.AbstractModule; import com.google.inject.BindingAnnotation; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.spi.InjectionPoint; import junit.framework.TestCase; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.reflect.Member; import java.util.Set; /** * Test cases for {@link AbstractInjectorGrapher}. This indirectly tests most classes in this * package. * * @author bojand@google.com (Bojan Djordjevic) */ public class AbstractInjectorGrapherTest extends TestCase { private static final String TEST_STRING = "test"; private static class FakeGrapher extends AbstractInjectorGrapher { final Set nodes = Sets.newHashSet(); final Set edges = Sets.newHashSet(); @Override protected void reset() { nodes.clear(); edges.clear(); } @Override protected void newInterfaceNode(InterfaceNode node) { assertFalse(nodes.contains(node)); nodes.add(node); } @Override protected void newImplementationNode(ImplementationNode node) { assertFalse(nodes.contains(node)); nodes.add(node); } @Override protected void newInstanceNode(InstanceNode node) { assertFalse(nodes.contains(node)); nodes.add(node); } @Override protected void newDependencyEdge(DependencyEdge edge) { assertFalse(edges.contains(edge)); edges.add(edge); } @Override protected void newBindingEdge(BindingEdge edge) { assertFalse(edges.contains(edge)); edges.add(edge); } @Override protected void postProcess() {} } private static final class Wrapper { T value; } @BindingAnnotation @Retention(RetentionPolicy.RUNTIME) private static @interface Ann {} private static interface IA {} private static class A implements IA { @Inject public A(String str) {} } private static class A2 implements IA { @Inject public A2(Provider strProvider) {} } private Node aNode; private Node a2Node; private Node iaNode; private Node iaAnnNode; private Node stringNode; private Node stringInstanceNode; private FakeGrapher grapher; @Override protected void setUp() throws Exception { super.setUp(); grapher = new FakeGrapher(); Node.ignoreSourceInComparisons = true; aNode = new ImplementationNode(NodeId.newTypeId(Key.get(A.class)), null, ImmutableList.of(A.class.getConstructor(String.class))); a2Node = new ImplementationNode(NodeId.newTypeId(Key.get(A2.class)), null, ImmutableList.of(A2.class.getConstructor(Provider.class))); iaNode = new InterfaceNode(NodeId.newTypeId(Key.get(IA.class)), null); iaAnnNode = new InterfaceNode(NodeId.newTypeId(Key.get(IA.class, Ann.class)), null); stringNode = new InterfaceNode(NodeId.newTypeId(Key.get(String.class)), null); stringInstanceNode = new InstanceNode(NodeId.newInstanceId(Key.get(String.class)), null, TEST_STRING, ImmutableList.of()); } public void testLinkedAndInstanceBindings() throws Exception { grapher.graph(Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(IA.class).to(A.class); bind(IA.class).annotatedWith(Ann.class).to(A.class); bind(String.class).toInstance(TEST_STRING); } })); Set expectedNodes = ImmutableSet.of(iaNode, iaAnnNode, aNode, stringNode, stringInstanceNode); Set expectedEdges = ImmutableSet.of( new BindingEdge(iaNode.getId(), aNode.getId(), BindingEdge.Type.NORMAL), new BindingEdge(iaAnnNode.getId(), aNode.getId(), BindingEdge.Type.NORMAL), new BindingEdge(stringNode.getId(), stringInstanceNode.getId(), BindingEdge.Type.NORMAL), new DependencyEdge(aNode.getId(), stringNode.getId(), InjectionPoint.forConstructor(A.class.getConstructor(String.class)))); assertEquals(expectedNodes, grapher.nodes); assertEquals(expectedEdges, grapher.edges); } public void testProviderBindings() throws Exception { final Wrapper> wrapper = new Wrapper>(); grapher.graph(Guice.createInjector(new AbstractModule() { @Override protected void configure() { wrapper.value = getProvider(A2.class); bind(IA.class).toProvider(wrapper.value); bind(A2.class); bind(String.class).toInstance(TEST_STRING); } })); Node a2ProviderNode = new InstanceNode(NodeId.newInstanceId(Key.get(IA.class)), null, wrapper.value, ImmutableList.of()); Set expectedNodes = ImmutableSet.of(iaNode, stringNode, a2Node, stringInstanceNode, a2ProviderNode); Set expectedEdges = ImmutableSet.of( new BindingEdge(stringNode.getId(), stringInstanceNode.getId(), BindingEdge.Type.NORMAL), new BindingEdge(iaNode.getId(), a2ProviderNode.getId(), BindingEdge.Type.PROVIDER), new DependencyEdge(a2Node.getId(), stringNode.getId(), InjectionPoint.forConstructor(A2.class.getConstructor(Provider.class)))); assertEquals(expectedNodes, grapher.nodes); assertEquals(expectedEdges, grapher.edges); } public void testGraphWithGivenRoot() throws Exception { grapher.graph(Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(IA.class).to(A.class); bind(IA.class).annotatedWith(Ann.class).to(A.class); bind(String.class).toInstance(TEST_STRING); } }), ImmutableSet.>of(Key.get(String.class))); Set expectedNodes = ImmutableSet.of(stringNode, stringInstanceNode); Set expectedEdges = ImmutableSet.of( new BindingEdge(stringNode.getId(), stringInstanceNode.getId(), BindingEdge.Type.NORMAL)); assertEquals(expectedNodes, grapher.nodes); assertEquals(expectedEdges, grapher.edges); } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/0000755000175000017500000000000011704661106021030 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/0000755000175000017500000000000011704661106021606 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/0000755000175000017500000000000011704661106023062 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/0000755000175000017500000000000011704661106024336 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/0000755000175000017500000000000011704661106025766 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/0000755000175000017500000000000011704661106027620 5ustar tonytony././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/PortIdFactoryImpl.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/PortIdFactoryI0000644000175000017500000000171611704661106032412 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.graphviz; import java.lang.reflect.Member; /** * Implementation of {@link PortIdFactory}. Bound in {@link GraphvizModule}. * * @author phopkins@gmail.com (Pete Hopkins) */ public class PortIdFactoryImpl implements PortIdFactory { public String getPortId(Member member) { return "m_" + Integer.toHexString(member.hashCode()); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/PortIdFactory.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/PortIdFactory.0000644000175000017500000000167111704661106032357 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.graphviz; import java.lang.reflect.Member; /** * Interface for a service that returns Graphviz port IDs, used for naming the * rows in {@link ImplementationNode}-displaying {@link GraphvizNode}s. * * @author phopkins@gmail.com (Pete Hopkins) */ public interface PortIdFactory { String getPortId(Member member); } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/NodeStyle.java0000644000175000017500000000223511704661106032373 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.graphviz; /** * Styles for nodes. Similar to {@link EdgeStyle} but with a few more options. *

    * See: http://www.graphviz.org/doc/info/attrs.html#k:style * * @author phopkins@gmail.com (Pete Hopkins) */ public enum NodeStyle { BOLD("bold"), DASHED("dashed"), DIAGONALS("diagonals"), DOTTED("dotted"), INVISIBLE("invis"), FILLED("filled"), ROUNDED("rounded"), SOLID("solid"); private final String name; NodeStyle(String name) { this.name = name; } @Override public String toString() { return name; } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/NodeShape.java0000644000175000017500000000204611704661106032333 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.graphviz; /** * Enum for the shapes that are most interesting for Guice graphing. *

    * See: http://www.graphviz.org/doc/info/shapes.html * * @author phopkins@gmail.com (Pete Hopkins) */ public enum NodeShape { BOX("box"), ELLIPSE("ellipse"), NONE("none"); private final String shape; NodeShape(String shape) { this.shape = shape; } @Override public String toString() { return shape; } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/GraphvizNode.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/GraphvizNode.j0000644000175000017500000000557411704661106032406 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.graphviz; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.inject.grapher.NodeId; import java.util.List; import java.util.Map; /** * Data object to encapsulate the attributes of Graphviz nodes that we're * interested in drawing. * * @author phopkins@gmail.com (Pete Hopkins) */ public class GraphvizNode { private final NodeId nodeId; private NodeStyle style = NodeStyle.SOLID; private NodeShape shape = NodeShape.BOX; private String title = ""; private Map subtitles = Maps.newTreeMap(); private String headerTextColor = "#000000"; private String headerBackgroundColor = "#ffffff"; private String identifier; /** {@link Map} from port ID to field title */ private Map fields = Maps.newLinkedHashMap(); public GraphvizNode(NodeId nodeId) { this.nodeId = nodeId; } public NodeId getNodeId() { return nodeId; } public NodeShape getShape() { return shape; } public void setShape(NodeShape shape) { this.shape = shape; } public NodeStyle getStyle() { return style; } public void setStyle(NodeStyle style) { this.style = style; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public List getSubtitles() { return ImmutableList.copyOf(subtitles.values()); } public void addSubtitle(int position, String subtitle) { this.subtitles.put(position, subtitle); } public String getHeaderTextColor() { return headerTextColor; } public void setHeaderTextColor(String headerTextColor) { this.headerTextColor = headerTextColor; } public String getHeaderBackgroundColor() { return headerBackgroundColor; } public void setHeaderBackgroundColor(String headerBackgroundColor) { this.headerBackgroundColor = headerBackgroundColor; } public void addField(String portId, String title) { fields.put(portId, title); } public Map getFields() { return ImmutableMap.copyOf(fields); } public String getIdentifier() { return identifier; } public void setIdentifier(String identifier) { this.identifier = identifier; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/GraphvizModule.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/GraphvizModule0000644000175000017500000000227711704661106032513 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.graphviz; import com.google.inject.AbstractModule; import com.google.inject.grapher.NameFactory; import com.google.inject.grapher.ShortNameFactory; /** * Module that provides classes needed by {@link GraphvizGrapher}. * * @author phopkins@gmail.com (Pete Hopkins) */ public class GraphvizModule extends AbstractModule { @Override protected void configure() { bind(NameFactory.class) .annotatedWith(Graphviz.class) .to(ShortNameFactory.class); bind(PortIdFactory.class) .annotatedWith(Graphviz.class) .to(PortIdFactoryImpl.class); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/GraphvizGrapher.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/GraphvizGraphe0000644000175000017500000002443311704661106032472 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.graphviz; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.inject.Inject; import com.google.inject.Key; import com.google.inject.grapher.AbstractInjectorGrapher; import com.google.inject.grapher.BindingEdge; import com.google.inject.grapher.DependencyEdge; import com.google.inject.grapher.ImplementationNode; import com.google.inject.grapher.InstanceNode; import com.google.inject.grapher.InterfaceNode; import com.google.inject.grapher.NameFactory; import com.google.inject.grapher.NodeId; import com.google.inject.spi.InjectionPoint; import java.io.PrintWriter; import java.lang.reflect.Member; import java.util.List; import java.util.Map; import java.util.Map.Entry; /** * {@link InjectorGrapher} implementation that writes out a Graphviz DOT file of the graph. * Dependencies are bound in {@link GraphvizModule}. *

    * Specify the {@link PrintWriter} to output to with {@link #setOut(PrintWriter)}. * * @author phopkins@gmail.com (Pete Hopkins) */ public class GraphvizGrapher extends AbstractInjectorGrapher { private final Map nodes = Maps.newHashMap(); private final List edges = Lists.newArrayList(); private final NameFactory nameFactory; private final PortIdFactory portIdFactory; private PrintWriter out; private String rankdir = "TB"; @Inject GraphvizGrapher(@Graphviz NameFactory nameFactory, @Graphviz PortIdFactory portIdFactory) { this.nameFactory = nameFactory; this.portIdFactory = portIdFactory; } @Override protected void reset() { nodes.clear(); edges.clear(); } public void setOut(PrintWriter out) { this.out = out; } public void setRankdir(String rankdir) { this.rankdir = rankdir; } @Override protected void postProcess() { start(); for (GraphvizNode node : nodes.values()) { renderNode(node); } for (GraphvizEdge edge : edges) { renderEdge(edge); } finish(); out.flush(); } protected Map getGraphAttributes() { Map attrs = Maps.newHashMap(); attrs.put("rankdir", rankdir); return attrs; } protected void start() { out.println("digraph injector {"); Map attrs = getGraphAttributes(); out.println("graph " + getAttrString(attrs) + ";"); } protected void finish() { out.println("}"); } protected void renderNode(GraphvizNode node) { Map attrs = getNodeAttributes(node); out.println(node.getIdentifier() + " " + getAttrString(attrs)); } protected Map getNodeAttributes(GraphvizNode node) { Map attrs = Maps.newHashMap(); attrs.put("label", getNodeLabel(node)); // remove most of the margin because the table has internal padding attrs.put("margin", "0.02,0"); attrs.put("shape", node.getShape().toString()); attrs.put("style", node.getStyle().toString()); return attrs; } /** * Creates the "label" for a node. This is a string of HTML that defines a * table with a heading at the top and (in the case of * {@link ImplementationNode}s) rows for each of the member fields. */ protected String getNodeLabel(GraphvizNode node) { String cellborder = node.getStyle() == NodeStyle.INVISIBLE ? "1" : "0"; StringBuilder html = new StringBuilder(); html.append("<"); html.append(""); html.append("").append("").append(""); for (Map.Entry field : node.getFields().entrySet()) { html.append(""); html.append("").append(""); } html.append("
    "); String subtitle = Joiner.on("
    ").join(node.getSubtitles()); if (subtitle.length() != 0) { html.append(""); html.append(subtitle).append("
    ").append("
    "); } html.append(""); html.append(htmlEscape(node.getTitle())).append("
    "); html.append("
    ").append("
    "); html.append(htmlEscape(field.getValue())); html.append("
    "); html.append(">"); return html.toString(); } protected void renderEdge(GraphvizEdge edge) { Map attrs = getEdgeAttributes(edge); String tailId = getEdgeEndPoint(nodes.get(edge.getTailNodeId()).getIdentifier(), edge.getTailPortId(), edge.getTailCompassPoint()); String headId = getEdgeEndPoint(nodes.get(edge.getHeadNodeId()).getIdentifier(), edge.getHeadPortId(), edge.getHeadCompassPoint()); out.println(tailId + " -> " + headId + " " + getAttrString(attrs)); } protected Map getEdgeAttributes(GraphvizEdge edge) { Map attrs = Maps.newHashMap(); attrs.put("arrowhead", getArrowString(edge.getArrowHead())); attrs.put("arrowtail", getArrowString(edge.getArrowTail())); attrs.put("style", edge.getStyle().toString()); return attrs; } private String getAttrString(Map attrs) { List attrList = Lists.newArrayList(); for (Entry attr : attrs.entrySet()) { String value = attr.getValue(); if (value != null) { attrList.add(attr.getKey() + "=" + value); } } return "[" + Joiner.on(", ").join(attrList) + "]"; } /** * Turns a {@link List} of {@link ArrowType}s into a {@link String} that * represents combining them. With Graphviz, that just means concatenating * them. */ protected String getArrowString(List arrows) { return Joiner.on("").join(arrows); } protected String getEdgeEndPoint(String nodeId, String portId, CompassPoint compassPoint) { List portStrings = Lists.newArrayList(nodeId); if (portId != null) { portStrings.add(portId); } if (compassPoint != null) { portStrings.add(compassPoint.toString()); } return Joiner.on(":").join(portStrings); } protected String htmlEscape(String str) { return str.replace("&", "&").replace("<", "<").replace(">", ">"); } protected List htmlEscape(List elements) { List escaped = Lists.newArrayList(); for (String element : elements) { escaped.add(htmlEscape(element)); } return escaped; } @Override protected void newInterfaceNode(InterfaceNode node) { // TODO(phopkins): Show the Module on the graph, which comes from the // class name when source is a StackTraceElement. NodeId nodeId = node.getId(); GraphvizNode gnode = new GraphvizNode(nodeId); gnode.setStyle(NodeStyle.DASHED); Key key = nodeId.getKey(); gnode.setTitle(nameFactory.getClassName(key)); gnode.addSubtitle(0, nameFactory.getAnnotationName(key)); addNode(gnode); } @Override protected void newImplementationNode(ImplementationNode node) { NodeId nodeId = node.getId(); GraphvizNode gnode = new GraphvizNode(nodeId); gnode.setStyle(NodeStyle.INVISIBLE); gnode.setHeaderBackgroundColor("#000000"); gnode.setHeaderTextColor("#ffffff"); gnode.setTitle(nameFactory.getClassName(nodeId.getKey())); for (Member member : node.getMembers()) { gnode.addField(portIdFactory.getPortId(member), nameFactory.getMemberName(member)); } addNode(gnode); } @Override protected void newInstanceNode(InstanceNode node) { NodeId nodeId = node.getId(); GraphvizNode gnode = new GraphvizNode(nodeId); gnode.setStyle(NodeStyle.INVISIBLE); gnode.setHeaderBackgroundColor("#000000"); gnode.setHeaderTextColor("#ffffff"); gnode.setTitle(nameFactory.getClassName(nodeId.getKey())); gnode.addSubtitle(0, nameFactory.getSourceName(node.getSource())); gnode.setHeaderBackgroundColor("#aaaaaa"); gnode.setHeaderTextColor("#ffffff"); gnode.setTitle(nameFactory.getInstanceName(node.getInstance())); for (Member member : node.getMembers()) { gnode.addField(portIdFactory.getPortId(member), nameFactory.getMemberName(member)); } addNode(gnode); } @Override protected void newDependencyEdge(DependencyEdge edge) { GraphvizEdge gedge = new GraphvizEdge(edge.getFromId(), edge.getToId()); InjectionPoint fromPoint = edge.getInjectionPoint(); if (fromPoint == null) { gedge.setTailPortId("header"); } else { gedge.setTailPortId(portIdFactory.getPortId(fromPoint.getMember())); } gedge.setArrowHead(ImmutableList.of(ArrowType.NORMAL)); gedge.setTailCompassPoint(CompassPoint.EAST); edges.add(gedge); } @Override protected void newBindingEdge(BindingEdge edge) { GraphvizEdge gedge = new GraphvizEdge(edge.getFromId(), edge.getToId()); gedge.setStyle(EdgeStyle.DASHED); switch (edge.getType()) { case NORMAL: gedge.setArrowHead(ImmutableList.of(ArrowType.NORMAL_OPEN)); break; case PROVIDER: gedge.setArrowHead(ImmutableList.of(ArrowType.NORMAL_OPEN, ArrowType.NORMAL_OPEN)); break; case CONVERTED_CONSTANT: gedge.setArrowHead(ImmutableList.of(ArrowType.NORMAL_OPEN, ArrowType.DOT_OPEN)); break; } edges.add(gedge); } private void addNode(GraphvizNode node) { node.setIdentifier("x" + nodes.size()); nodes.put(node.getNodeId(), node); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/GraphvizEdge.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/GraphvizEdge.j0000644000175000017500000000536011704661106032356 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.graphviz; import com.google.common.collect.ImmutableList; import com.google.inject.grapher.NodeId; import java.util.List; /** * Data object to encapsulate the attributes of Graphviz edges that we're * interested in drawing. * * @author phopkins@gmail.com (Pete Hopkins) */ public class GraphvizEdge { private final NodeId headNodeId; private String headPortId; private CompassPoint headCompassPoint; private List arrowHead = ImmutableList.of(ArrowType.NORMAL); private final NodeId tailNodeId; private String tailPortId; private CompassPoint tailCompassPoint; private List arrowTail = ImmutableList.of(ArrowType.NONE); private EdgeStyle style = EdgeStyle.SOLID; public GraphvizEdge(NodeId tailNodeId, NodeId headNodeId) { this.tailNodeId = tailNodeId; this.headNodeId = headNodeId; } public NodeId getHeadNodeId() { return headNodeId; } public String getHeadPortId() { return headPortId; } public void setHeadPortId(String headPortId) { this.headPortId = headPortId; } public CompassPoint getHeadCompassPoint() { return headCompassPoint; } public void setHeadCompassPoint(CompassPoint headCompassPoint) { this.headCompassPoint = headCompassPoint; } public List getArrowHead() { return arrowHead; } public void setArrowHead(List arrowHead) { this.arrowHead = ImmutableList.copyOf(arrowHead); } public NodeId getTailNodeId() { return tailNodeId; } public String getTailPortId() { return tailPortId; } public void setTailPortId(String tailPortId) { this.tailPortId = tailPortId; } public CompassPoint getTailCompassPoint() { return tailCompassPoint; } public void setTailCompassPoint(CompassPoint tailCompassPoint) { this.tailCompassPoint = tailCompassPoint; } public List getArrowTail() { return arrowTail; } public void setArrowTail(List arrowTail) { this.arrowTail = ImmutableList.copyOf(arrowTail); } public EdgeStyle getStyle() { return style; } public void setStyle(EdgeStyle style) { this.style = style; } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/Graphviz.java0000644000175000017500000000170211704661106032255 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.graphviz; import com.google.inject.BindingAnnotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * Annotation for types used by the graphviz grapher. * * @author bojand@google.com (Bojan Djordjevic) */ @BindingAnnotation @Retention(RetentionPolicy.RUNTIME) @interface Graphviz {} sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/EdgeStyle.java0000644000175000017500000000203711704661106032352 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.graphviz; /** * Styles for edges. *

    * See: http://www.graphviz.org/doc/info/attrs.html#k:style * * @author phopkins@gmail.com (Pete Hopkins) */ public enum EdgeStyle { BOLD("bold"), DASHED("dashed"), DOTTED("dotted"), INVISIBLE("invis"), SOLID("solid"); private final String name; EdgeStyle(String name) { this.name = name; } @Override public String toString() { return name; } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/CompassPoint.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/CompassPoint.j0000644000175000017500000000240111704661106032407 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.graphviz; /** * Enum for the "compass point" values used to control where edge * end points appear on the graph. *

    * See: http://www.graphviz.org/doc/info/attrs.html#k:portPos * * @author phopkins@gmail.com (Pete Hopkins) */ public enum CompassPoint { NORTH("n"), NORTH_EAST("ne"), EAST("e"), SOUTH_EAST("se"), SOUTH("s"), SOUTH_WEST("sw"), WEST("w"), NORTH_WEST("nw"), CENTER("c"), EXTERIOR_SIDE("_"); /** Graphviz "compass_pt" value. */ private final String compassPt; CompassPoint(String compassPt) { this.compassPt = compassPt; } @Override public String toString() { return compassPt; } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/graphviz/ArrowType.java0000644000175000017500000000250511704661106032421 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher.graphviz; /** * Arrow symbols that are available from Graphviz. These can be composed by * concatenation to make double arrows and such. *

    * See: http://www.graphviz.org/doc/info/arrows.html * * @author phopkins@gmail.com (Pete Hopkins) */ public enum ArrowType { BOX("box"), BOX_OPEN("obox"), CROW("crow"), DIAMOND("diamond"), DIAMOND_OPEN("odiamond"), DOT("dot"), DOT_OPEN("odot"), INVERTED("inv"), INVERTED_OPEN("oinv"), NONE("none"), NORMAL("normal"), NORMAL_OPEN("onormal"), TEE("tee"), VEE("vee"); private final String arrowType; ArrowType(String arrowType) { this.arrowType = arrowType; } @Override public String toString() { return arrowType; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/TransitiveDependencyVisitor.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/TransitiveDependencyVis0000644000175000017500000000576511704661106032537 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.inject.Binding; import com.google.inject.Key; import com.google.inject.spi.ConstructorBinding; import com.google.inject.spi.ConvertedConstantBinding; import com.google.inject.spi.DefaultBindingTargetVisitor; import com.google.inject.spi.Dependency; import com.google.inject.spi.HasDependencies; import com.google.inject.spi.InstanceBinding; import com.google.inject.spi.LinkedKeyBinding; import com.google.inject.spi.ProviderBinding; import com.google.inject.spi.ProviderInstanceBinding; import com.google.inject.spi.ProviderKeyBinding; import java.util.Collection; import java.util.Set; /** * {@link BindingTargetVisitor} that returns a {@link Collection} of the * {@link Key}s of each {@link Binding}'s dependencies. Used by * {@link InjectorGrapher} to walk the dependency graph from a starting set of * {@link Binding}s. * * @author phopkins@gmail.com (Pete Hopkins) */ public class TransitiveDependencyVisitor extends DefaultBindingTargetVisitor>> { private Collection> visitHasDependencies(HasDependencies hasDependencies) { Set> dependencies = Sets.newHashSet(); for (Dependency dependency : hasDependencies.getDependencies()) { dependencies.add(dependency.getKey()); } return dependencies; } @Override public Collection> visit(ConstructorBinding binding) { return visitHasDependencies(binding); } @Override public Collection> visit(ConvertedConstantBinding binding) { return visitHasDependencies(binding); } @Override public Collection> visit(InstanceBinding binding) { return visitHasDependencies(binding); } @Override public Collection> visit(LinkedKeyBinding binding) { return ImmutableSet.>of(binding.getLinkedKey()); } @Override public Collection> visit(ProviderBinding binding) { return ImmutableSet.>of(binding.getProvidedKey()); } @Override public Collection> visit(ProviderInstanceBinding binding) { return visitHasDependencies(binding); } @Override public Collection> visit(ProviderKeyBinding binding) { return ImmutableSet.>of(binding.getProviderKey()); } @Override public Collection> visitOther(Binding binding) { return ImmutableSet.of(); } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/ShortNameFactory.java0000644000175000017500000001042011704661106032056 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.inject.Key; import com.google.inject.TypeLiteral; import com.google.inject.internal.ProviderMethod; import com.google.inject.internal.util.StackTraceElements; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.util.List; /** * Reasonable implementation for {@link NameFactory}. Mostly takes various * {@link Object#toString()}s and strips package names out of them so that * they'll fit on the graph. * * @author phopkins@gmail.com (Pete Hopkins) */ public class ShortNameFactory implements NameFactory { public String getMemberName(Member member) { if (member instanceof Constructor) { return ""; } else if (member instanceof Method) { return "#" + member.getName() + "(...)"; } else { return member.getName(); } } public String getAnnotationName(Key key) { Annotation annotation = key.getAnnotation(); Class annotationType = key.getAnnotationType(); if (annotation != null) { annotationType = annotation.annotationType(); String annotationString = annotation.toString(); String canonicalName = annotationType.getName(); String simpleName = annotationType.getSimpleName(); return annotationString.replace(canonicalName, simpleName).replace("()", ""); } else if (annotationType != null) { return "@" + annotationType.getSimpleName(); } else { return ""; } } public String getClassName(Key key) { TypeLiteral typeLiteral = key.getTypeLiteral(); return stripPackages(typeLiteral.toString()); } public String getInstanceName(Object instance) { if (instance instanceof ProviderMethod) { return getMethodString(((ProviderMethod) instance).getMethod()); } if (instance instanceof CharSequence) { return "\"" + instance + "\""; } try { if (instance.getClass().getMethod("toString").getDeclaringClass().equals(Object.class)) { return stripPackages(instance.getClass().getName()); } } catch (SecurityException e) { throw new AssertionError(e); } catch (NoSuchMethodException e) { throw new AssertionError(e); } return instance.toString(); } /** * Returns a name for a Guice "source" object. This will typically be either * a {@link StackTraceElement} for when the binding is made to the instance, * or a {@link Method} when a provider method is used. */ public String getSourceName(Object source) { if (source instanceof Method) { source = StackTraceElements.forMember((Method) source); } if (source instanceof StackTraceElement) { return getFileString((StackTraceElement) source); } return stripPackages(source.toString()); } protected String getFileString(StackTraceElement stackTraceElement) { return stackTraceElement.getFileName() + ":" + stackTraceElement.getLineNumber(); } protected String getMethodString(Method method) { List paramStrings = Lists.newArrayList(); for (Class paramType : method.getParameterTypes()) { paramStrings.add(paramType.getSimpleName()); } String paramString = Joiner.on(", ").join(paramStrings); return "#" + method.getName() + "(" + paramString + ")"; } /** * Eliminates runs of lowercase characters and numbers separated by periods. * Seems to remove packages from fully-qualified type names pretty well. */ private String stripPackages(String str) { return str.replaceAll("(^|[< .\\(])([a-z0-9]+\\.)*", "$1"); } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/RootKeySetCreator.java0000644000175000017500000000202011704661106032213 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.inject.Injector; import com.google.inject.Key; import java.util.Set; /** * Creator of the default starting set of keys to graph. These keys and their transitive * dependencies will be graphed. * * @author bojand@google.com (Bojan Djordjevic) */ public interface RootKeySetCreator { /** Returns the set of starting keys to graph. */ Set> getRootKeys(Injector injector); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/ProviderAliasCreator.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/ProviderAliasCreator.ja0000644000175000017500000000310011704661106032360 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.collect.Lists; import com.google.inject.Binding; import com.google.inject.spi.ProviderBinding; import java.util.List; /** * Alias creator that creates an alias for each {@link ProviderBinding}. These {@link Binding}s * arise from an {@link InjectionPoint} for the {@link Provider} interface. Since this isn't * very interesting information, we don't render this binding on the graph, and just alias the two * nodes. * * @author bojand@google.com (Bojan Djordjevic) */ final class ProviderAliasCreator implements AliasCreator { @Override public Iterable createAliases(Iterable> bindings) { List aliases = Lists.newArrayList(); for (Binding binding : bindings) { if (binding instanceof ProviderBinding) { aliases.add(new Alias(NodeId.newTypeId(binding.getKey()), NodeId.newTypeId(((ProviderBinding) binding).getProvidedKey()))); } } return aliases; } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/NodeId.java0000644000175000017500000000422311704661106027774 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.base.Objects; import com.google.inject.Key; /** * ID of a node in the graph. An ID is given by a {@link Key} and a node type, which is used to * distinguish instances and implementation classes for the same key. For example * {@code bind(Integer.class).toInstance(42)} produces two nodes: an * interface node with the key of {@code Key} and an instance node with the same * {@link Key} and value of 42. * * @author bojand@google.com (Bojan Djordjevic) */ public final class NodeId { /** Type of node. */ public enum NodeType { /** Type or class node. */ TYPE, /** Instance node, used when something is bound to an instance. */ INSTANCE } private final Key key; private final NodeType nodeType; private NodeId(Key key, NodeType nodeType) { this.key = key; this.nodeType = nodeType; } public static NodeId newTypeId(Key key) { return new NodeId(key, NodeType.TYPE); } public static NodeId newInstanceId(Key key) { return new NodeId(key, NodeType.INSTANCE); } public Key getKey() { return key; } @Override public int hashCode() { return Objects.hashCode(key, nodeType); } @Override public boolean equals(Object obj) { if (!(obj.getClass().equals(NodeId.class))) { return false; } NodeId other = (NodeId) obj; return Objects.equal(key, other.key) && Objects.equal(nodeType, other.nodeType); } @Override public String toString() { return "NodeId{nodeType=" + nodeType + " key=" + key + "}"; } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/NodeCreator.java0000644000175000017500000000160511704661106031040 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.inject.Binding; /** * Creator of graph nodes. * * @author bojand@google.com (Bojan Djordjevic) */ public interface NodeCreator { /** Returns nodes for the given dependency graph. */ Iterable getNodes(Iterable> bindings); } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/Node.java0000644000175000017500000000341511704661106027521 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.base.Objects; /** * Node in a guice dependency graph. * * @author bojand@google.com (Bojan Djordjevic) */ public abstract class Node { /** * When set to true, the source object is ignored in {@link #equals} and {@link #hashCode}. * Only used in tests. */ static boolean ignoreSourceInComparisons = false; private final NodeId id; private final Object source; protected Node(NodeId id, Object source) { this.id = id; this.source = source; } public NodeId getId() { return id; } public Object getSource() { return source; } @Override public boolean equals(Object obj) { if (!(obj instanceof Node)) { return false; } Node other = (Node) obj; return Objects.equal(id, other.id) && (ignoreSourceInComparisons || Objects.equal(source, other.source)); } @Override public int hashCode() { return ignoreSourceInComparisons ? id.hashCode() : Objects.hashCode(id, source); } /** * Returns a copy of the node with a new ID. * * @param id new ID of the node * @return copy of the node with a new ID */ public abstract Node copy(NodeId id); } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/NameFactory.java0000644000175000017500000000215111704661106031040 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.inject.Key; import java.lang.reflect.Member; /** * Interface for a service that provides nice {@link String}s that we can * display in the graph for the types that come up in {@link Binding}s. * * @author phopkins@gmail.com (Pete Hopkins) */ public interface NameFactory { String getMemberName(Member member); String getClassName(Key key); String getInstanceName(Object instance); String getAnnotationName(Key key); String getSourceName(Object source); } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/InterfaceNode.java0000644000175000017500000000234611704661106031344 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; /** * Node for an interface type that has been bound to an implementation class or instance. * * @see BindingEdge * * @author phopkins@gmail.com (Pete Hopkins) */ public class InterfaceNode extends Node { public InterfaceNode(NodeId id, Object source) { super(id, source); } @Override public Node copy(NodeId id) { return new InterfaceNode(id, getSource()); } @Override public boolean equals(Object obj) { return (obj instanceof InterfaceNode) && super.equals(obj); } @Override public String toString() { return "InterfaceNode{id=" + getId() + " source=" + getSource() + "}"; } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/InstanceNode.java0000644000175000017500000000364011704661106031206 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.base.Objects; import java.lang.reflect.Member; /** * Node for instances. Used when a type is bound to an instance. * * @author bojand@google.com (Bojan Djordjevic) */ public class InstanceNode extends Node { private final Object instance; private final Iterable members; public InstanceNode(NodeId id, Object source, Object instance, Iterable members) { super(id, source); this.instance = instance; this.members = members; } public Object getInstance() { return instance; } public Iterable getMembers() { return members; } @Override public boolean equals(Object obj) { if (!(obj instanceof InstanceNode)) { return false; } InstanceNode other = (InstanceNode) obj; return super.equals(other) && Objects.equal(instance, other.instance) && Objects.equal(members, other.members); } @Override public int hashCode() { return 31 * super.hashCode() + Objects.hashCode(instance, members); } @Override public String toString() { return "InstanceNode{id=" + getId() + " source=" + getSource() + " instance=" + instance + " members=" + members + "}"; } @Override public Node copy(NodeId id) { return new InstanceNode(id, getSource(), getInstance(), getMembers()); } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/InjectorGrapher.java0000644000175000017500000000255211704661106031723 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.inject.Injector; import com.google.inject.Key; import java.io.IOException; import java.util.Set; /** * Guice injector grapher. Renders the guice dependency graph for an injector. It can render the * whole dependency graph or just transitive dependencies of a given set of nodes. * * @author phopkins@gmail.com (Pete Hopkins) */ public interface InjectorGrapher { /** Graphs the guice dependency graph for the given injector using default starting keys. */ void graph(Injector injector) throws IOException; /** * Graphs the guice dependency graph for the given injector using the given starting keys and * their transitive dependencies. */ void graph(Injector injector, Set> root) throws IOException; } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/ImplementationNode.java0000644000175000017500000000361011704661106032424 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.base.Objects; import java.lang.reflect.Member; import java.util.Collection; /** * Node for types that have {@link Dependency}s and are bound to {@link InterfaceNode}s. These * nodes will often have fields for {@link Member}s that are {@link InjectionPoint}s. * * @see DependencyEdge * * @author phopkins@gmail.com (Pete Hopkins) */ public class ImplementationNode extends Node { private final Collection members; public ImplementationNode(NodeId id, Object source, Collection members) { super(id, source); this.members = members; } public Collection getMembers() { return members; } @Override public boolean equals(Object obj) { if (!(obj instanceof ImplementationNode)) { return false; } ImplementationNode other = (ImplementationNode) obj; return super.equals(other) && Objects.equal(members, other.members); } @Override public int hashCode() { return 31 * super.hashCode() + Objects.hashCode(members); } @Override public String toString() { return "ImplementationNode{id=" + getId() + " source=" + getSource() + " members=" + members + "}"; } @Override public Node copy(NodeId id) { return new ImplementationNode(id, getSource(), getMembers()); } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/EdgeCreator.java0000644000175000017500000000173411704661106031022 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.inject.Binding; /** * Creator of graph edges to render. All edges will be rendered on the graph after node aliasing is * performed. * * @author bojand@google.com (Bojan Djordjevic) */ public interface EdgeCreator { /** Returns edges for the given dependency graph. */ Iterable getEdges(Iterable> bindings); } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/Edge.java0000644000175000017500000000314511704661106027500 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.base.Objects; /** * Edge in a guice dependency graph. * * @author bojand@google.com (Bojan Djordjevic) */ public abstract class Edge { private final NodeId fromId; private final NodeId toId; protected Edge(NodeId fromId, NodeId toId) { this.fromId = fromId; this.toId = toId; } public NodeId getFromId() { return fromId; } public NodeId getToId() { return toId; } @Override public boolean equals(Object obj) { if (!(obj instanceof Edge)) { return false; } Edge other = (Edge) obj; return Objects.equal(fromId, other.fromId) && Objects.equal(toId, other.toId); } @Override public int hashCode() { return Objects.hashCode(fromId, toId); } /** * Returns a copy of the edge with new node IDs. * * @param fromId new ID of the 'from' node * @param toId new ID of the 'to' node * @return copy of the edge with the new node IDs */ public abstract Edge copy(NodeId fromId, NodeId toId); } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/DependencyEdge.java0000644000175000017500000000374111704661106031501 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.base.Objects; import com.google.inject.spi.InjectionPoint; /** * Edge from a class or {@link InjectionPoint} to the interface node that will satisfy the * dependency. * * @author phopkins@gmail.com (Pete Hopkins) */ public class DependencyEdge extends Edge { /** * Injection point to which this dependency belongs, or null if the dependency isn't attached to a * particular injection point. */ private final InjectionPoint injectionPoint; public DependencyEdge(NodeId fromId, NodeId toId, InjectionPoint injectionPoint) { super(fromId, toId); this.injectionPoint = injectionPoint; } public InjectionPoint getInjectionPoint() { return injectionPoint; } @Override public boolean equals(Object obj) { if (!(obj instanceof DependencyEdge)) { return false; } DependencyEdge other = (DependencyEdge) obj; return super.equals(other) && Objects.equal(injectionPoint, other.injectionPoint); } @Override public int hashCode() { return 31 * super.hashCode() + Objects.hashCode(injectionPoint); } @Override public String toString() { return "DependencyEdge{fromId=" + getFromId() + " toId=" + getToId() + " injectionPoint=" + injectionPoint + "}"; } @Override public Edge copy(NodeId fromId, NodeId toId) { return new DependencyEdge(fromId, toId, injectionPoint); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/DefaultRootKeySetCreator.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/DefaultRootKeySetCreato0000644000175000017500000000271611704661106032432 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.collect.Sets; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import java.util.Set; import java.util.logging.Logger; /** * Root key set creator that starts with all types that are not Guice internal types or the * {@link Logger} type. * * @author bojand@google.com (Bojan Djordjevic) */ public class DefaultRootKeySetCreator implements RootKeySetCreator { private static final Key loggerKey = Key.get(Logger.class); @Override public Set> getRootKeys(Injector injector) { Set> root = Sets.newHashSet(); for (Key key : injector.getBindings().keySet()) { if (key.getTypeLiteral().getRawType().getPackage() != Guice.class.getPackage() && !loggerKey.equals(key)) { root.add(key); } } return root; } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/DefaultNodeCreator.java0000644000175000017500000001133711704661106032350 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.inject.Binding; import com.google.inject.spi.ConstructorBinding; import com.google.inject.spi.DefaultBindingTargetVisitor; import com.google.inject.spi.Dependency; import com.google.inject.spi.HasDependencies; import com.google.inject.spi.InjectionPoint; import com.google.inject.spi.InstanceBinding; import com.google.inject.spi.ProviderInstanceBinding; import java.lang.reflect.Member; import java.util.Collection; import java.util.List; /** * Default node creator. * * @author bojand@google.com (Bojan Djordjevic) */ final class DefaultNodeCreator implements NodeCreator { @Override public Iterable getNodes(Iterable> bindings) { List nodes = Lists.newArrayList(); NodeVisitor visitor = new NodeVisitor(); for (Binding binding : bindings) { nodes.addAll(binding.acceptTargetVisitor(visitor)); } return nodes; } /** * {@link BindingTargetVisitor} that adds nodes to the graph based on the visited {@link Binding}. */ private static final class NodeVisitor extends DefaultBindingTargetVisitor> { /** Returns a new interface node for the given {@link Binding}. */ private InterfaceNode newInterfaceNode(Binding binding) { return new InterfaceNode(NodeId.newTypeId(binding.getKey()), binding.getSource()); } /** * Returns a new implementation node for the given binding. * * @param binding binding for the node to create * @param members members to add to the node * @return implementation node for the given binding */ private ImplementationNode newImplementationNode(Binding binding, Collection members) { return new ImplementationNode(NodeId.newTypeId(binding.getKey()), binding.getSource(), members); } /** * Returns a new instance node for the given {@link Binding}. * * @param binding binding for the node to create * @param instance value of the instance * @return instance node for the given binding */ private & HasDependencies> InstanceNode newInstanceNode(T binding, Object instance) { Collection members = Lists.newArrayList(); for (Dependency dependency : binding.getDependencies()) { InjectionPoint injectionPoint = dependency.getInjectionPoint(); if (injectionPoint != null) { members.add(injectionPoint.getMember()); } } return new InstanceNode(NodeId.newInstanceId(binding.getKey()), binding.getSource(), instance, members); } /** * Visitor for {@link ConstructorBinding}s. These are for classes that Guice will instantiate to * satisfy injection requests. */ @Override public Collection visit(ConstructorBinding binding) { Collection members = Lists.newArrayList(); members.add(binding.getConstructor().getMember()); for (InjectionPoint injectionPoint : binding.getInjectableMembers()) { members.add(injectionPoint.getMember()); } return ImmutableList.of(newImplementationNode(binding, members)); } /** * Visitor for {@link InstanceBinding}. We render two nodes in this case: an interface node for * the binding's {@link Key}, and then an implementation node for the instance {@link Object} * itself. */ @Override public Collection visit(InstanceBinding binding) { return ImmutableList.of(newInterfaceNode(binding), newInstanceNode(binding, binding.getInstance())); } /** * Same as {@link #visit(InstanceBinding)}, but the binding edge is * {@link BindingEdgeType#PROVIDER}. */ @Override public Collection visit(ProviderInstanceBinding binding) { return ImmutableList.of(newInterfaceNode(binding), newInstanceNode(binding, binding.getProviderInstance())); } @Override public Collection visitOther(Binding binding) { return ImmutableList.of(newInterfaceNode(binding)); } } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/DefaultEdgeCreator.java0000644000175000017500000001424711704661106032332 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.inject.Binding; import com.google.inject.spi.ConstructorBinding; import com.google.inject.spi.ConvertedConstantBinding; import com.google.inject.spi.DefaultBindingTargetVisitor; import com.google.inject.spi.Dependency; import com.google.inject.spi.HasDependencies; import com.google.inject.spi.InstanceBinding; import com.google.inject.spi.LinkedKeyBinding; import com.google.inject.spi.ProviderBinding; import com.google.inject.spi.ProviderInstanceBinding; import com.google.inject.spi.ProviderKeyBinding; import java.util.Collection; import java.util.List; /** * Default edge creator. * * @author bojand@google.com (Bojan Djordjevic) */ final class DefaultEdgeCreator implements EdgeCreator { @Override public Iterable getEdges(Iterable> bindings) { List edges = Lists.newArrayList(); EdgeVisitor visitor = new EdgeVisitor(); for (Binding binding : bindings) { edges.addAll(binding.acceptTargetVisitor(visitor)); } return edges; } /** * {@link BindingTargetVisitor} that adds edges to the graph based on the visited {@link Binding}. */ private static final class EdgeVisitor extends DefaultBindingTargetVisitor> { /** * Returns a dependency edge for each {@link Dependency} in the binding. These will be from the * given node ID to the {@link Dependency}'s {@link Key}. * * @param nodeId ID of the node that should be the tail of the dependency * edges * @param binding {@link Binding} for the dependencies */ private & HasDependencies> Collection newDependencyEdges( NodeId nodeId, T binding) { ImmutableList.Builder builder = ImmutableList.builder(); for (Dependency dependency : binding.getDependencies()) { NodeId to = NodeId.newTypeId(dependency.getKey()); builder.add(new DependencyEdge(nodeId, to, dependency.getInjectionPoint())); } return builder.build(); } /** * Visitor for {@link ConstructorBinding}s. These are for classes that Guice will instantiate to * satisfy injection requests. */ @Override public Collection visit(ConstructorBinding binding) { return newDependencyEdges(NodeId.newTypeId(binding.getKey()), binding); } /** * Visitor for {@link ConvertedConstantBinding}. The {@link Binding}'s {@link Key} will be of an * annotated primitive type, and the value of {@link ConvertedConstantBinding#getSourceKey()} * will be of a {@link String} with the same annotation. */ @Override public Collection visit(ConvertedConstantBinding binding) { return ImmutableList.of(new BindingEdge(NodeId.newTypeId(binding.getKey()), NodeId.newTypeId(binding.getSourceKey()), BindingEdge.Type.CONVERTED_CONSTANT)); } /** * Visitor for {@link InstanceBinding}. We then render any dependency edgess that the instance * may have, which come either from {@link InjectionPoint}s (method and field) on the instance, * or on {@link Dependency}s the instance declares through the {@link HasDependencies} * interface. */ @Override public Collection visit(InstanceBinding binding) { return new ImmutableList.Builder() .add(new BindingEdge(NodeId.newTypeId(binding.getKey()), NodeId.newInstanceId(binding.getKey()), BindingEdge.Type.NORMAL)) .addAll(newDependencyEdges(NodeId.newInstanceId(binding.getKey()), binding)) .build(); } /** * Visitor for {@link LinkedKeyBinding}. This is the standard {@link Binding} you get from * binding an interface class to an implementation class. We draw a {@link BindingEdge} from * the interface node to the node of the implementing class. */ @Override public Collection visit(LinkedKeyBinding binding) { return ImmutableList.of(new BindingEdge(NodeId.newTypeId(binding.getKey()), NodeId.newTypeId(binding.getLinkedKey()), BindingEdge.Type.NORMAL)); } /** * Visitor for {@link ProviderBinding}. These {@link Binding}s arise from an * {@link InjectionPoint} for the {@link Provider} interface. */ @Override public Collection visit(ProviderBinding binding) { return ImmutableList.of(new BindingEdge(NodeId.newTypeId(binding.getKey()), NodeId.newTypeId(binding.getProvidedKey()), BindingEdge.Type.PROVIDER)); } /** * Same as {@link #visit(InstanceBinding)}, but the binding edge is * {@link BindingEdge.Type#PROVIDER}. */ @Override public Collection visit(ProviderInstanceBinding binding) { return new ImmutableList.Builder() .add(new BindingEdge(NodeId.newTypeId(binding.getKey()), NodeId.newInstanceId(binding.getKey()), BindingEdge.Type.PROVIDER)) .addAll(newDependencyEdges(NodeId.newInstanceId(binding.getKey()), binding)) .build(); } /** * Same as {@link #visit(LinkedKeyBinding)}, but the binding edge is * {@link BindingEdge.Type#PROVIDER}. */ @Override public Collection visit(ProviderKeyBinding binding) { return ImmutableList.of(new BindingEdge(NodeId.newTypeId(binding.getKey()), NodeId.newTypeId(binding.getProviderKey()), BindingEdge.Type.PROVIDER)); } @Override public Collection visitOther(Binding binding) { return ImmutableList.of(); } } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/BindingEdge.java0000644000175000017500000000373611704661106031001 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.base.Objects; /** * Edge that connects an interface to the type or instance that is bound to implement it. * * @author phopkins@gmail.com (Pete Hopkins) */ public class BindingEdge extends Edge { /** * Classification for what kind of binding this edge represents. */ public enum Type { /** Binding is to an instance or class of the binding's same type. */ NORMAL, /** Binding is to an instance or class that provides the binding's type. */ PROVIDER, /** Binding is to the interface for a constant of a different type. */ CONVERTED_CONSTANT } private final Type type; public BindingEdge(NodeId fromId, NodeId toId, Type type) { super(fromId, toId); this.type = type; } public Type getType() { return type; } @Override public boolean equals(Object obj) { if (!(obj instanceof BindingEdge)) { return false; } BindingEdge other = (BindingEdge) obj; return super.equals(other) && Objects.equal(type, other.type); } @Override public int hashCode() { return 31 * super.hashCode() + Objects.hashCode(type); } @Override public String toString() { return "BindingEdge{fromId=" + getFromId() + " toId=" + getToId() + " type=" + type + "}"; } @Override public Edge copy(NodeId fromId, NodeId toId) { return new BindingEdge(fromId, toId, type); } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/AliasCreator.java0000644000175000017500000000253411704661106031206 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.inject.Binding; /** * Creator of node aliases. Used by dependency graphers to merge nodes in the internal Guice graph * into a single node on the rendered graph. * * @author bojand@google.com (Bojan Djordjevic) */ public interface AliasCreator { /** * Returns aliases for the given dependency graph. The aliases do not need to be transitively * resolved, i.e. it is valid to return an alias (X to Y) and an alias (Y to Z). It is the * responsibility of the caller to resolve this to (X to Z) and (Y to Z). * * @param bindings bindings that make up the dependency graph * @return aliases that should be applied on the graph */ Iterable createAliases(Iterable> bindings); } sisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/Alias.java0000644000175000017500000000222711704661106027665 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; /** * Alias between two nodes. Causes the 'from' node to be aliased with the 'to' node, which means * that the 'from' node is not rendered and all edges going to it instead go to the 'to' node. * * @author bojand@google.com (Bojan Djordjevic) */ public final class Alias { private final NodeId fromId; private final NodeId toId; public Alias(NodeId fromId, NodeId toId) { this.fromId = fromId; this.toId = toId; } public NodeId getFromId() { return fromId; } public NodeId getToId() { return toId; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/AbstractInjectorGrapher.javasisu-guice-sisu-guice-3.1.1/extensions/grapher/src/com/google/inject/grapher/AbstractInjectorGrapher0000644000175000017500000001665111704661106032474 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.grapher; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.inject.Binding; import com.google.inject.Injector; import com.google.inject.Key; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; /** * Abstract injector grapher that builds the dependency graph but doesn't render it. * * @author bojand@google.com (Bojan Djordjevic) */ public abstract class AbstractInjectorGrapher implements InjectorGrapher { private final RootKeySetCreator rootKeySetCreator; private final AliasCreator aliasCreator; private final NodeCreator nodeCreator; private final EdgeCreator edgeCreator; /** Parameters used to override default settings of the grapher. */ public static final class GrapherParameters { private RootKeySetCreator rootKeySetCreator = new DefaultRootKeySetCreator(); private AliasCreator aliasCreator = new ProviderAliasCreator(); private NodeCreator nodeCreator = new DefaultNodeCreator(); private EdgeCreator edgeCreator = new DefaultEdgeCreator(); public RootKeySetCreator getRootKeySetCreator() { return rootKeySetCreator; } public GrapherParameters setRootKeySetCreator(RootKeySetCreator rootKeySetCreator) { this.rootKeySetCreator = rootKeySetCreator; return this; } public AliasCreator getAliasCreator() { return aliasCreator; } public GrapherParameters setAliasCreator(AliasCreator aliasCreator) { this.aliasCreator = aliasCreator; return this; } public NodeCreator getNodeCreator() { return nodeCreator; } public GrapherParameters setNodeCreator(NodeCreator nodeCreator) { this.nodeCreator = nodeCreator; return this; } public EdgeCreator getEdgeCreator() { return edgeCreator; } public GrapherParameters setEdgeCreator(EdgeCreator edgeCreator) { this.edgeCreator = edgeCreator; return this; } } public AbstractInjectorGrapher() { this(new GrapherParameters()); } public AbstractInjectorGrapher(GrapherParameters options) { this.rootKeySetCreator = options.getRootKeySetCreator(); this.aliasCreator = options.getAliasCreator(); this.nodeCreator = options.getNodeCreator(); this.edgeCreator = options.getEdgeCreator(); } @Override public final void graph(Injector injector) throws IOException { graph(injector, rootKeySetCreator.getRootKeys(injector)); } @Override public final void graph(Injector injector, Set> root) throws IOException { reset(); Iterable> bindings = getBindings(injector, root); Map aliases = resolveAliases(aliasCreator.createAliases(bindings)); createNodes(nodeCreator.getNodes(bindings), aliases); createEdges(edgeCreator.getEdges(bindings), aliases); postProcess(); } /** Resets the state of the grapher before rendering a new graph. */ protected abstract void reset() throws IOException; /** Adds a new interface node to the graph. */ protected abstract void newInterfaceNode(InterfaceNode node) throws IOException; /** Adds a new implementation node to the graph. */ protected abstract void newImplementationNode(ImplementationNode node) throws IOException; /** Adds a new instance node to the graph. */ protected abstract void newInstanceNode(InstanceNode node) throws IOException; /** Adds a new dependency edge to the graph. */ protected abstract void newDependencyEdge(DependencyEdge edge) throws IOException; /** Adds a new binding edge to the graph. */ protected abstract void newBindingEdge(BindingEdge edge) throws IOException; /** Performs any post processing required after all nodes and edges have been added. */ protected abstract void postProcess() throws IOException; private void createNodes(Iterable nodes, Map aliases) throws IOException { for (Node node : nodes) { NodeId originalId = node.getId(); NodeId resolvedId = resolveAlias(aliases, originalId); node = node.copy(resolvedId); // Only render nodes that aren't aliased to some other node. if (resolvedId.equals(originalId)) { if (node instanceof InterfaceNode) { newInterfaceNode((InterfaceNode) node); } else if (node instanceof ImplementationNode) { newImplementationNode((ImplementationNode) node); } else { newInstanceNode((InstanceNode) node); } } } } private void createEdges(Iterable edges, Map aliases) throws IOException { for (Edge edge : edges) { edge = edge.copy(resolveAlias(aliases, edge.getFromId()), resolveAlias(aliases, edge.getToId())); if (!edge.getFromId().equals(edge.getToId())) { if (edge instanceof BindingEdge) { newBindingEdge((BindingEdge) edge); } else { newDependencyEdge((DependencyEdge) edge); } } } } private NodeId resolveAlias(Map aliases, NodeId nodeId) { return aliases.containsKey(nodeId) ? aliases.get(nodeId) : nodeId; } /** * Transitively resolves aliases. Given aliases (X to Y) and (Y to Z), it will return mappings * (X to Z) and (Y to Z). */ private Map resolveAliases(Iterable aliases) { Map resolved = Maps.newHashMap(); Map> inverse = Maps.newHashMap(); for (Alias alias : aliases) { NodeId from = alias.getFromId(); NodeId to = alias.getToId(); if (resolved.containsKey(to)) { to = resolved.get(to); } resolved.put(from, to); if (inverse.get(to) == null) { inverse.put(to, Sets.newHashSet()); } inverse.get(to).add(from); Set prev = inverse.get(from); if (prev != null) { for (NodeId id : prev) { resolved.remove(id); inverse.get(from).remove(id); resolved.put(id, to); inverse.get(to).add(id); } } } return resolved; } /** Returns the bindings for the root keys and their transitive dependencies. */ private Iterable> getBindings(Injector injector, Set> root) { Set> keys = Sets.newHashSet(root); Set> visitedKeys = Sets.newHashSet(); List> bindings = Lists.newArrayList(); TransitiveDependencyVisitor keyVisitor = new TransitiveDependencyVisitor(); while (!keys.isEmpty()) { Iterator> iterator = keys.iterator(); Key key = iterator.next(); iterator.remove(); if (!visitedKeys.contains(key)) { Binding binding = injector.getBinding(key); bindings.add(binding); visitedKeys.add(key); keys.addAll(binding.acceptTargetVisitor(keyVisitor)); } } return bindings; } } sisu-guice-sisu-guice-3.1.1/extensions/grapher/pom.xml0000644000175000017500000000210711704661106021556 0ustar tonytony 4.0.0 org.sonatype.sisu.inject guice-extensions 3.1.1 guice-grapher Sisu Guice - Extensions - Grapher org.sonatype.sisu.inject guice-assistedinject ${project.version} org.sonatype.sisu.inject guice-multibindings ${project.version} org.easymock easymock 3.0 test sisu-guice-sisu-guice-3.1.1/extensions/grapher/grapher.iml0000644000175000017500000000130411704661106022372 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/grapher/build.xml0000644000175000017500000000125111704661106022061 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/grapher/build.properties0000644000175000017500000000023111704661106023452 0ustar tonytonylib.dir=../../lib src.dir=src test.dir=test build.dir=build test.class=com.google.inject.grapher.AllTests module=com.google.inject.grapher fragment=true sisu-guice-sisu-guice-3.1.1/extensions/assistedinject/0000755000175000017500000000000011704661106021625 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/assistedinject/test/0000755000175000017500000000000011704661106022604 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/assistedinject/test/com/0000755000175000017500000000000011704661106023362 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/assistedinject/test/com/google/0000755000175000017500000000000011704661106024636 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/assistedinject/test/com/google/inject/0000755000175000017500000000000011704661106026112 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/assistedinject/test/com/google/inject/assistedinject/0000755000175000017500000000000011704661106031126 5ustar tonytony././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/test/com/google/inject/assistedinject/ManyConstructorsTest.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/test/com/google/inject/assistedinject/ManyCons0000644000175000017500000002055311704661106032605 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import com.google.inject.AbstractModule; import com.google.inject.Asserts; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Injector; import junit.framework.TestCase; /** * @author sameb@google.com (Sam Berlin) */ public class ManyConstructorsTest extends TestCase { public void testTwoConstructors() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder().build(Factory.class)); } }); Factory factory = injector.getInstance(Factory.class); Foo noIndex = factory.create("no index"); assertEquals("no index", noIndex.name); assertEquals(null, noIndex.index); Foo index = factory.create("index", 1); assertEquals("index", index.name); assertEquals(1, index.index.intValue()); } public void testDifferentOrderParameters() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder().build(OtherFactory.class)); } }); OtherFactory factory = injector.getInstance(OtherFactory.class); Foo noIndex = factory.create("no index"); assertEquals("no index", noIndex.name); assertEquals(null, noIndex.index); Foo index = factory.create(1, "index"); assertEquals("index", index.name); assertEquals(1, index.index.intValue()); Foo index2 = factory.create("index", 2); assertEquals("index", index2.name); assertEquals(2, index2.index.intValue()); } public void testInterfaceToImpl() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder() .implement(Bar.class, Foo.class) .build(BarFactory.class)); } }); BarFactory factory = injector.getInstance(BarFactory.class); Bar noIndex = factory.create("no index"); assertEquals("no index", noIndex.getName()); assertEquals(null, noIndex.getIndex()); Bar index = factory.create("index", 1); assertEquals("index", index.getName()); assertEquals(1, index.getIndex().intValue()); } public void testUsingOneConstructor() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder().build(SimpleFactory.class)); } }); SimpleFactory factory = injector.getInstance(SimpleFactory.class); Foo noIndex = factory.create("no index"); assertEquals("no index", noIndex.name); assertEquals(null, noIndex.index); injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder().build(SimpleFactory2.class)); } }); SimpleFactory2 factory2 = injector.getInstance(SimpleFactory2.class); Foo index = factory2.create("index", 1); assertEquals("index", index.name); assertEquals(1, index.index.intValue()); } public void testTooManyMatchingConstructors() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder() .implement(Foo.class, TooManyMatches.class) .build(SimpleFactory2.class)); } }); fail("should have failed"); } catch (CreationException expected) { Asserts.assertContains(expected.getMessage(), "1) " + TooManyMatches.class.getName() + " has more than one constructor annotated with @AssistedInject that " + "matches the parameters in method " + SimpleFactory2.class.getName()); } } public void testNoMatchingConstructorsBecauseTooManyParams() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder().build(ComplexFactory.class)); } }); fail("should have failed"); } catch (CreationException expected) { Asserts.assertContains(expected.getMessage(), "1) " + Foo.class.getName() + " has @AssistedInject constructors, but none of them match the parameters in method " + ComplexFactory.class.getName()); } } public void testNoMatchingConstrucotsBecauseTooLittleParams() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder().build(NullFactory.class)); } }); fail("should have failed"); } catch (CreationException expected) { Asserts.assertContains(expected.getMessage(), "1) " + Foo.class.getName() + " has @AssistedInject constructors, but none of them match the parameters in method " + NullFactory.class.getName()); } } public static interface ComplexFactory { Foo create(String name, int idx, float weight); } public static interface NullFactory { Foo create(); } public static interface OtherFactory { Foo create(String name, int idx); Foo create(int idx, String name); Foo create(String name); } public static interface Factory { Foo create(String name); Foo create(String name, int idx); } public static interface BarFactory { Bar create(String name); Bar create(String name, int idx); } public static interface SimpleFactory { Foo create(String name); } public static interface SimpleFactory2 { Foo create(String name, int idx); } public static class TooManyMatches extends Foo { @AssistedInject TooManyMatches(@Assisted String name, @Assisted int index) { } @AssistedInject TooManyMatches(@Assisted int index, @Assisted String name) { } } public static class Foo implements Bar { private String name; private Integer index; Foo() {} @AssistedInject Foo(@Assisted String name) { this.name = name; this.index = null; } @AssistedInject Foo(@Assisted String name, @Assisted int index) { this.name = name; this.index = index; } Foo(String a, String b, String c) { } public String getName() { return name; } public Integer getIndex() { return index; } } public static interface Bar { String getName(); Integer getIndex(); } public void testDependenciesAndOtherAnnotations() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder().build(FamilyFarmFactory.class)); } }); FamilyFarmFactory factory = injector.getInstance(FamilyFarmFactory.class); Farm pops = factory.popsFarm("Pop"); assertEquals("Pop", pops.pop); assertEquals(null, pops.mom); Farm moms = factory.momsFarm("Mom"); assertEquals(null, moms.pop); assertEquals("Mom", moms.mom); Farm momAndPop = factory.momAndPopsFarm("Mom", "Pop"); assertEquals("Pop", momAndPop.pop); assertEquals("Mom", momAndPop.mom); } public static interface FamilyFarmFactory { Farm popsFarm(String pop); Farm momsFarm(@Assisted("mom") String mom); Farm momAndPopsFarm(@Assisted("mom") String mom, @Assisted("pop") String pop); } public static class Farm { String pop; String mom; @AssistedInject Farm(@Assisted String pop, Dog dog) { this.pop = pop; } @AssistedInject Farm(@Assisted("mom") String mom, @Assisted("pop") String pop, Cow cow, Dog dog) { this.pop = pop; this.mom = mom; } @AssistedInject Farm(@Assisted("mom") String mom, Cow cow) { this.mom = mom; } } public static class Cow {} public static class Dog {} }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/test/com/google/inject/assistedinject/FactoryProviderTest.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/test/com/google/inject/assistedinject/FactoryP0000755000175000017500000006410611704661106032612 0ustar tonytony/** * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import static com.google.inject.Asserts.assertContains; import com.google.common.collect.ImmutableSet; import com.google.inject.AbstractModule; import com.google.inject.Binding; import com.google.inject.ConfigurationException; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.TypeLiteral; import com.google.inject.name.Named; import com.google.inject.name.Names; import com.google.inject.spi.Dependency; import com.google.inject.spi.HasDependencies; import junit.framework.TestCase; import java.util.Collection; import java.util.Collections; import java.util.Set; /** * @author jmourits@google.com (Jerome Mourits) * @author jessewilson@google.com (Jesse Wilson) */ public class FactoryProviderTest extends TestCase { private enum Color { BLUE, GREEN, RED, GRAY, BLACK, ORANGE, PINK } public void testAssistedFactory() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).toInstance(5.0d); bind(ColoredCarFactory.class) .toProvider(FactoryProvider.newFactory(ColoredCarFactory.class, Mustang.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); Mustang blueMustang = (Mustang) carFactory.create(Color.BLUE); assertEquals(Color.BLUE, blueMustang.color); assertEquals(5.0d, blueMustang.engineSize); Mustang redMustang = (Mustang) carFactory.create(Color.RED); assertEquals(Color.RED, redMustang.color); assertEquals(5.0d, redMustang.engineSize); } public void testFactoryBindingDependencies() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).toInstance(5.0d); bind(ColoredCarFactory.class) .toProvider(FactoryProvider.newFactory(ColoredCarFactory.class, Mustang.class)); } }); Binding binding = injector.getBinding(ColoredCarFactory.class); HasDependencies hasDependencies = (HasDependencies) binding; assertEquals(ImmutableSet.>of(Dependency.get(Key.get(double.class))), hasDependencies.getDependencies()); } public void testAssistedFactoryWithAnnotations() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(int.class).annotatedWith(Names.named("horsePower")).toInstance(250); bind(int.class).annotatedWith(Names.named("modelYear")).toInstance(1984); bind(ColoredCarFactory.class) .toProvider(FactoryProvider.newFactory(ColoredCarFactory.class, Camaro.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); Camaro blueCamaro = (Camaro) carFactory.create(Color.BLUE); assertEquals(Color.BLUE, blueCamaro.color); assertEquals(1984, blueCamaro.modelYear); assertEquals(250, blueCamaro.horsePower); Camaro redCamaro = (Camaro) carFactory.create(Color.RED); assertEquals(Color.RED, redCamaro.color); assertEquals(1984, redCamaro.modelYear); assertEquals(250, redCamaro.horsePower); } interface Car { } interface ColoredCarFactory { Car create(Color color); } public static class Mustang implements Car { private final double engineSize; private final Color color; @AssistedInject public Mustang(double engineSize, @Assisted Color color) { this.engineSize = engineSize; this.color = color; } } public static class Camaro implements Car { private final int horsePower; private final int modelYear; private final Color color; @AssistedInject public Camaro( @Named("horsePower")int horsePower, @Named("modelYear")int modelYear, @Assisted Color color) { this.horsePower = horsePower; this.modelYear = modelYear; this.color = color; } } interface SummerCarFactory { Car create(Color color, boolean convertable); Car createConvertible(Color color); } public void testFactoryWithMultipleMethods() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(float.class).toInstance(140f); bind(SummerCarFactory.class).toProvider( FactoryProvider.newFactory(SummerCarFactory.class, Corvette.class)); } }); SummerCarFactory carFactory = injector.getInstance(SummerCarFactory.class); Corvette blueCorvette = (Corvette) carFactory.createConvertible(Color.BLUE); assertEquals(Color.BLUE, blueCorvette.color); assertEquals(100f, blueCorvette.maxMph); assertTrue(blueCorvette.isConvertable); Corvette redCorvette = (Corvette) carFactory.create(Color.RED, false); assertEquals(Color.RED, redCorvette.color); assertEquals(140f, redCorvette.maxMph); assertFalse(redCorvette.isConvertable); } public static class Corvette implements Car { private boolean isConvertable; private Color color; private float maxMph; @AssistedInject public Corvette(@Assisted Color color) { this(color, 100f, true); } public Corvette(@Assisted Color color, @Assisted boolean isConvertable) { throw new IllegalStateException("Not an @AssistedInject constructor"); } @AssistedInject public Corvette(@Assisted Color color, Float maxMph, @Assisted boolean isConvertable) { this.isConvertable = isConvertable; this.color = color; this.maxMph = maxMph; } } public void testFactoryMethodsMismatch() { try { FactoryProvider.newFactory(SummerCarFactory.class, Beetle.class); fail(); } catch(ConfigurationException e) { assertContains(e.getMessage(), "Constructor mismatch"); } } public static class Beetle implements Car { @AssistedInject public Beetle(@Assisted Color color) { throw new IllegalStateException("Conflicting constructors"); } @AssistedInject public Beetle(@Assisted Color color, @Assisted boolean isConvertable) { throw new IllegalStateException("Conflicting constructors"); } @AssistedInject public Beetle(@Assisted Color color, @Assisted boolean isConvertable, float maxMph) { throw new IllegalStateException("Conflicting constructors"); } } public void testMethodsAndFieldsGetInjected() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(String.class).toInstance("turbo"); bind(int.class).toInstance(911); bind(double.class).toInstance(50000d); bind(ColoredCarFactory.class) .toProvider(FactoryProvider.newFactory(ColoredCarFactory.class, Porshe.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); Porshe grayPorshe = (Porshe) carFactory.create(Color.GRAY); assertEquals(Color.GRAY, grayPorshe.color); assertEquals(50000d, grayPorshe.price); assertEquals(911, grayPorshe.model); assertEquals("turbo", grayPorshe.name); } public static class Porshe implements Car { private final Color color; private final double price; private @Inject String name; private int model; @AssistedInject public Porshe(@Assisted Color color, double price) { this.color = color; this.price = price; } @Inject void setModel(int model) { this.model = model; } } public void testProviderInjection() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(String.class).toInstance("trans am"); bind(ColoredCarFactory.class) .toProvider(FactoryProvider.newFactory(ColoredCarFactory.class, Firebird.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); Firebird blackFirebird = (Firebird) carFactory.create(Color.BLACK); assertEquals(Color.BLACK, blackFirebird.color); assertEquals("trans am", blackFirebird.modifiersProvider.get()); } public static class Firebird implements Car { private final Provider modifiersProvider; private final Color color; @AssistedInject public Firebird(Provider modifiersProvider, @Assisted Color color) { this.modifiersProvider = modifiersProvider; this.color = color; } } public void testTypeTokenInjection() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(new TypeLiteral>() {}).toInstance(Collections.singleton("Flux Capacitor")); bind(new TypeLiteral>() {}).toInstance(Collections.singleton(88)); bind(ColoredCarFactory.class) .toProvider(FactoryProvider.newFactory(ColoredCarFactory.class, DeLorean.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); DeLorean deLorean = (DeLorean) carFactory.create(Color.GRAY); assertEquals(Color.GRAY, deLorean.color); assertEquals("Flux Capacitor", deLorean.features.iterator().next()); assertEquals(new Integer(88), deLorean.featureActivationSpeeds.iterator().next()); } public static class DeLorean implements Car { private final Set features; private final Set featureActivationSpeeds; private final Color color; @AssistedInject public DeLorean( Set extraFeatures, Set featureActivationSpeeds, @Assisted Color color) { this.features = extraFeatures; this.featureActivationSpeeds = featureActivationSpeeds; this.color = color; } } public void testTypeTokenProviderInjection() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(new TypeLiteral>() { }).toInstance(Collections.singleton("Datsun")); bind(ColoredCarFactory.class) .toProvider(FactoryProvider.newFactory(ColoredCarFactory.class, Z.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); Z orangeZ = (Z) carFactory.create(Color.ORANGE); assertEquals(Color.ORANGE, orangeZ.color); assertEquals("Datsun", orangeZ.manufacturersProvider.get().iterator().next()); } public static class Z implements Car { private final Provider> manufacturersProvider; private final Color color; @AssistedInject public Z(Provider> manufacturersProvider, @Assisted Color color) { this.manufacturersProvider = manufacturersProvider; this.color = color; } } public static class Prius implements Car { @SuppressWarnings("unused") private final Color color; @AssistedInject private Prius(@Assisted Color color) { this.color = color; } } public void testAssistInjectionInNonPublicConstructor() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(ColoredCarFactory.class) .toProvider(FactoryProvider.newFactory(ColoredCarFactory.class, Prius.class)); } }); Car car = injector.getInstance(ColoredCarFactory.class).create(Color.ORANGE); } public static class ExplodingCar implements Car { @AssistedInject public ExplodingCar(@Assisted Color color) { throw new IllegalStateException("kaboom!"); } } public void testExceptionDuringConstruction() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, ExplodingCar.class)); } }); try { injector.getInstance(ColoredCarFactory.class).create(Color.ORANGE); fail(); } catch (IllegalStateException e) { assertEquals("kaboom!", e.getMessage()); } } public static class DefectiveCar implements Car { @AssistedInject public DefectiveCar() throws ExplosionException, FireException { throw new ExplosionException(); } } public static class ExplosionException extends Exception { } public static class FireException extends Exception { } public interface DefectiveCarFactoryWithNoExceptions { Car createCar(); } public interface DefectiveCarFactory { Car createCar() throws FireException; } public void testFactoryMethodMustDeclareAllConstructorExceptions() { try { FactoryProvider.newFactory(DefectiveCarFactoryWithNoExceptions.class, DefectiveCar.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "no compatible exception is thrown"); } } public interface CorrectDefectiveCarFactory { Car createCar() throws FireException, ExplosionException; } public void testConstructorExceptionsAreThrownByFactory() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(CorrectDefectiveCarFactory.class).toProvider( FactoryProvider.newFactory( CorrectDefectiveCarFactory.class, DefectiveCar.class)); } }); try { injector.getInstance(CorrectDefectiveCarFactory.class).createCar(); fail(); } catch (FireException e) { fail(); } catch (ExplosionException expected) { } } public static class MultipleConstructorDefectiveCar implements Car { @AssistedInject public MultipleConstructorDefectiveCar() throws ExplosionException { throw new ExplosionException(); } @AssistedInject public MultipleConstructorDefectiveCar(@Assisted Color c) throws FireException { throw new FireException(); } } public interface MultipleConstructorDefectiveCarFactory { Car createCar() throws ExplosionException; Car createCar(Color r) throws FireException; } public void testMultipleConstructorExceptionMatching() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(MultipleConstructorDefectiveCarFactory.class).toProvider( FactoryProvider.newFactory( MultipleConstructorDefectiveCarFactory.class, MultipleConstructorDefectiveCar.class)); } }); MultipleConstructorDefectiveCarFactory factory = injector.getInstance(MultipleConstructorDefectiveCarFactory.class); try { factory.createCar(); fail(); } catch (ExplosionException expected) { } try { factory.createCar(Color.RED); fail(); } catch (FireException expected) { } } public static class WildcardCollection { public interface Factory { WildcardCollection create(Collection items); } @AssistedInject public WildcardCollection(@Assisted Collection items) { } } public void testWildcardGenerics() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(WildcardCollection.Factory.class).toProvider( FactoryProvider.newFactory( WildcardCollection.Factory.class, WildcardCollection.class)); } }); WildcardCollection.Factory factory = injector.getInstance(WildcardCollection.Factory.class); factory.create(Collections.emptyList()); } public static class SteeringWheel {} public static class Fiat implements Car { @SuppressWarnings("unused") private final SteeringWheel steeringWheel; @SuppressWarnings("unused") private final Color color; @AssistedInject public Fiat(SteeringWheel steeringWheel, @Assisted Color color) { this.steeringWheel = steeringWheel; this.color = color; } } public void testFactoryWithImplicitBindings() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory( ColoredCarFactory.class, Fiat.class)); } }); ColoredCarFactory coloredCarFactory = injector.getInstance(ColoredCarFactory.class); Fiat fiat = (Fiat) coloredCarFactory.create(Color.GREEN); assertEquals(Color.GREEN, fiat.color); assertNotNull(fiat.steeringWheel); } public void testFactoryFailsWithMissingBinding() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(ColoredCarFactory.class) .toProvider(FactoryProvider.newFactory(ColoredCarFactory.class, Mustang.class)); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Parameter of type 'double' is not injectable or annotated with @Assisted"); } } public void testMethodsDeclaredInObject() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).toInstance(5.0d); bind(ColoredCarFactory.class) .toProvider(FactoryProvider.newFactory(ColoredCarFactory.class, Mustang.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); carFactory.equals(carFactory); carFactory.hashCode(); carFactory.toString(); } public void testAssistedInjectConstructorAndAssistedFactoryParameterMustNotMix() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).toInstance(5.0d); bind(AssistedParamsFactory.class) .toProvider(FactoryProvider.newFactory(AssistedParamsFactory.class, Mustang.class)); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "Factory method " + AssistedParamsFactory.class.getName() + ".create() has an @Assisted parameter, which " + "is incompatible with the deprecated @AssistedInject annotation."); } } interface AssistedParamsFactory { Car create(@Assisted Color color); } interface GenericColoredCarFactory { T create(Color color); } public void testGenericAssistedFactory() { final TypeLiteral> mustangTypeLiteral = new TypeLiteral>() {}; final TypeLiteral> camaroTypeLiteral = new TypeLiteral>() {}; Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).toInstance(5.0d); bind(int.class).annotatedWith(Names.named("horsePower")).toInstance(250); bind(int.class).annotatedWith(Names.named("modelYear")).toInstance(1984); bind(mustangTypeLiteral).toProvider( FactoryProvider.newFactory(mustangTypeLiteral, TypeLiteral.get(Mustang.class))); bind(camaroTypeLiteral).toProvider( FactoryProvider.newFactory(camaroTypeLiteral, TypeLiteral.get(Camaro.class))); } }); GenericColoredCarFactory mustangFactory = injector.getInstance(Key.get(mustangTypeLiteral)); GenericColoredCarFactory camaroFactory = injector.getInstance(Key.get(camaroTypeLiteral)); Mustang blueMustang = mustangFactory.create(Color.BLUE); assertEquals(Color.BLUE, blueMustang.color); assertEquals(5.0d, blueMustang.engineSize); Camaro redCamaro = camaroFactory.create(Color.RED); assertEquals(Color.RED, redCamaro.color); assertEquals(1984, redCamaro.modelYear); assertEquals(250, redCamaro.horsePower); } public interface Insurance { } public static class MustangInsurance implements Insurance { private final double premium; private final double limit; private Mustang car; @AssistedInject public MustangInsurance(@Named("lowLimit") double limit, @Assisted Mustang car, @Assisted double premium) { this.premium = premium; this.limit = limit; this.car = car; } public void sell() {} } public static class CamaroInsurance implements Insurance { private final double premium; private final double limit; private Camaro car; @AssistedInject public CamaroInsurance(@Named("highLimit") double limit, @Assisted Camaro car, @Assisted double premium) { this.premium = premium; this.limit = limit; this.car = car; } public void sell() {} } public interface MustangInsuranceFactory { public Insurance create(Mustang car, double premium); } public interface CamaroInsuranceFactory { public Insurance create(Camaro car, double premium); } public void testAssistedFactoryForConcreteType() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).annotatedWith(Names.named("lowLimit")).toInstance(50000.0d); bind(Double.class).annotatedWith(Names.named("highLimit")).toInstance(100000.0d); bind(MustangInsuranceFactory.class).toProvider( FactoryProvider.newFactory(MustangInsuranceFactory.class, MustangInsurance.class)); bind(CamaroInsuranceFactory.class).toProvider( FactoryProvider.newFactory(CamaroInsuranceFactory.class, CamaroInsurance.class)); } }); MustangInsuranceFactory mustangInsuranceFactory = injector.getInstance(MustangInsuranceFactory.class); CamaroInsuranceFactory camaroInsuranceFactory = injector.getInstance(CamaroInsuranceFactory.class); Mustang mustang = new Mustang(5000d, Color.BLACK); MustangInsurance mustangPolicy = (MustangInsurance) mustangInsuranceFactory.create(mustang, 800.0d); assertEquals(800.0d, mustangPolicy.premium); assertEquals(50000.0d, mustangPolicy.limit); Camaro camaro = new Camaro(3000, 1967, Color.BLUE); CamaroInsurance camaroPolicy = (CamaroInsurance) camaroInsuranceFactory.create(camaro, 800.0d); assertEquals(800.0d, camaroPolicy.premium); assertEquals(100000.0d, camaroPolicy.limit); } public interface InsuranceFactory { public Insurance create(T car, double premium); } public void testAssistedFactoryForParameterizedType() { final TypeLiteral> mustangInsuranceFactoryType = new TypeLiteral>() {}; final TypeLiteral> camaroInsuranceFactoryType = new TypeLiteral>() {}; Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).annotatedWith(Names.named("lowLimit")).toInstance(50000.0d); bind(Double.class).annotatedWith(Names.named("highLimit")).toInstance(100000.0d); bind(mustangInsuranceFactoryType).toProvider(FactoryProvider.newFactory( mustangInsuranceFactoryType, TypeLiteral.get(MustangInsurance.class))); bind(camaroInsuranceFactoryType).toProvider(FactoryProvider.newFactory( camaroInsuranceFactoryType, TypeLiteral.get(CamaroInsurance.class))); } }); InsuranceFactory mustangInsuranceFactory = injector.getInstance(Key.get(mustangInsuranceFactoryType)); InsuranceFactory camaroInsuranceFactory = injector.getInstance(Key.get(camaroInsuranceFactoryType)); Mustang mustang = new Mustang(5000d, Color.BLACK); MustangInsurance mustangPolicy = (MustangInsurance) mustangInsuranceFactory.create(mustang, 800.0d); assertEquals(800.0d, mustangPolicy.premium); assertEquals(50000.0d, mustangPolicy.limit); Camaro camaro = new Camaro(3000, 1967, Color.BLUE); CamaroInsurance camaroPolicy = (CamaroInsurance) camaroInsuranceFactory.create(camaro, 800.0d); assertEquals(800.0d, camaroPolicy.premium); assertEquals(100000.0d, camaroPolicy.limit); } public static class AutoInsurance implements Insurance { private final double premium; private final double limit; private final T car; @AssistedInject public AutoInsurance(double limit, @Assisted T car, @Assisted double premium) { this.limit = limit; this.car = car; this.premium = premium; } public void sell() {} } public void testAssistedFactoryForTypeVariableParameters() { final TypeLiteral> camaroInsuranceFactoryType = new TypeLiteral>() {}; Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).toInstance(50000.0d); bind(camaroInsuranceFactoryType).toProvider(FactoryProvider.newFactory( camaroInsuranceFactoryType, new TypeLiteral>() {})); } }); InsuranceFactory camaroInsuranceFactory = injector.getInstance(Key.get(camaroInsuranceFactoryType)); Camaro camaro = new Camaro(3000, 1967, Color.BLUE); AutoInsurance camaroPolicy = (AutoInsurance) camaroInsuranceFactory.create(camaro, 800.0d); assertEquals(800.0d, camaroPolicy.premium); assertEquals(50000.0d, camaroPolicy.limit); assertEquals(camaro, camaroPolicy.car); } }././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/test/com/google/inject/assistedinject/FactoryProvider2Test.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/test/com/google/inject/assistedinject/FactoryP0000644000175000017500000011110711704661106032601 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import static com.google.inject.Asserts.assertContains; import static com.google.inject.Asserts.assertEqualsBothWays; import com.google.inject.AbstractModule; import com.google.inject.ConfigurationException; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.Stage; import com.google.inject.TypeLiteral; import com.google.inject.matcher.Matchers; import com.google.inject.name.Named; import com.google.inject.name.Names; import junit.framework.TestCase; import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; @SuppressWarnings("deprecation") public class FactoryProvider2Test extends TestCase { private enum Color { BLUE, GREEN, RED, GRAY, BLACK, ORANGE, PINK } public void testAssistedFactory() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).toInstance(5.0d); bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, Mustang.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); Mustang blueMustang = (Mustang) carFactory.create(Color.BLUE); assertEquals(Color.BLUE, blueMustang.color); assertEquals(5.0d, blueMustang.engineSize); Mustang redMustang = (Mustang) carFactory.create(Color.RED); assertEquals(Color.RED, redMustang.color); assertEquals(5.0d, redMustang.engineSize); } public void testAssistedFactoryWithAnnotations() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(int.class).annotatedWith(Names.named("horsePower")).toInstance(250); bind(int.class).annotatedWith(Names.named("modelYear")).toInstance(1984); bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, Camaro.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); Camaro blueCamaro = (Camaro) carFactory.create(Color.BLUE); assertEquals(Color.BLUE, blueCamaro.color); assertEquals(1984, blueCamaro.modelYear); assertEquals(250, blueCamaro.horsePower); Camaro redCamaro = (Camaro) carFactory.create(Color.RED); assertEquals(Color.RED, redCamaro.color); assertEquals(1984, redCamaro.modelYear); assertEquals(250, redCamaro.horsePower); } public interface Car {} interface ColoredCarFactory { Car create(Color color); } public static class Mustang implements Car { private final double engineSize; private final Color color; @Inject public Mustang(double engineSize, @Assisted Color color) { this.engineSize = engineSize; this.color = color; } public void drive() {} } public static class Camaro implements Car { private final int horsePower; private final int modelYear; private final Color color; @Inject public Camaro( @Named("horsePower") int horsePower, @Named("modelYear") int modelYear, @Assisted Color color) { this.horsePower = horsePower; this.modelYear = modelYear; this.color = color; } } interface SummerCarFactory { Car create(Color color, boolean convertable); } public void testFactoryUsesInjectedConstructor() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(float.class).toInstance(140f); bind(SummerCarFactory.class).toProvider( FactoryProvider.newFactory(SummerCarFactory.class, Corvette.class)); } }); SummerCarFactory carFactory = injector.getInstance(SummerCarFactory.class); Corvette redCorvette = (Corvette) carFactory.create(Color.RED, false); assertEquals(Color.RED, redCorvette.color); assertEquals(140f, redCorvette.maxMph); assertFalse(redCorvette.isConvertable); } public static class Corvette implements Car { private boolean isConvertable; private Color color; private float maxMph; public Corvette(Color color, boolean isConvertable) { throw new IllegalStateException("Not an @AssistedInject constructor"); } @Inject public Corvette(@Assisted Color color, Float maxMph, @Assisted boolean isConvertable) { this.isConvertable = isConvertable; this.color = color; this.maxMph = maxMph; } } public void testConstructorDoesntNeedAllFactoryMethodArguments() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(SummerCarFactory.class).toProvider( FactoryProvider.newFactory(SummerCarFactory.class, Beetle.class)); } }); SummerCarFactory factory = injector.getInstance(SummerCarFactory.class); Beetle beetle = (Beetle) factory.create(Color.RED, true); assertSame(Color.RED, beetle.color); } public static class Beetle implements Car { private final Color color; @Inject public Beetle(@Assisted Color color) { this.color = color; } } public void testMethodsAndFieldsGetInjected() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(String.class).toInstance("turbo"); bind(int.class).toInstance(911); bind(double.class).toInstance(50000d); bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, Porsche.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); Porsche grayPorsche = (Porsche) carFactory.create(Color.GRAY); assertEquals(Color.GRAY, grayPorsche.color); assertEquals(50000d, grayPorsche.price); assertEquals(911, grayPorsche.model); assertEquals("turbo", grayPorsche.name); } public static class Porsche implements Car { private final Color color; private final double price; private @Inject String name; private int model; @Inject public Porsche(@Assisted Color color, double price) { this.color = color; this.price = price; } @Inject void setModel(int model) { this.model = model; } } public void testProviderInjection() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(String.class).toInstance("trans am"); bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, Firebird.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); Firebird blackFirebird = (Firebird) carFactory.create(Color.BLACK); assertEquals(Color.BLACK, blackFirebird.color); assertEquals("trans am", blackFirebird.modifiersProvider.get()); } public static class Firebird implements Car { private final Provider modifiersProvider; private final Color color; @Inject public Firebird(Provider modifiersProvider, @Assisted Color color) { this.modifiersProvider = modifiersProvider; this.color = color; } } public void testAssistedProviderInjection() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(String.class).toInstance("trans am"); bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, Flamingbird.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); Flamingbird flamingbird = (Flamingbird) carFactory.create(Color.BLACK); assertEquals(Color.BLACK, flamingbird.colorProvider.get()); assertEquals("trans am", flamingbird.modifiersProvider.get()); Flamingbird flamingbird2 = (Flamingbird) carFactory.create(Color.RED); assertEquals(Color.RED, flamingbird2.colorProvider.get()); assertEquals("trans am", flamingbird2.modifiersProvider.get()); // Make sure the original flamingbird is black still. assertEquals(Color.BLACK, flamingbird.colorProvider.get()); } public static class Flamingbird implements Car { private final Provider modifiersProvider; private final Provider colorProvider; @Inject public Flamingbird(Provider modifiersProvider, @Assisted Provider colorProvider) { this.modifiersProvider = modifiersProvider; this.colorProvider = colorProvider; } } public void testTypeTokenInjection() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(new TypeLiteral>() {}).toInstance(Collections.singleton("Flux Capacitor")); bind(new TypeLiteral>() {}).toInstance(Collections.singleton(88)); bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, DeLorean.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); DeLorean deLorean = (DeLorean) carFactory.create(Color.GRAY); assertEquals(Color.GRAY, deLorean.color); assertEquals("Flux Capacitor", deLorean.features.iterator().next()); assertEquals(new Integer(88), deLorean.featureActivationSpeeds.iterator().next()); } public static class DeLorean implements Car { private final Set features; private final Set featureActivationSpeeds; private final Color color; @Inject public DeLorean( Set extraFeatures, Set featureActivationSpeeds, @Assisted Color color) { this.features = extraFeatures; this.featureActivationSpeeds = featureActivationSpeeds; this.color = color; } } public void testTypeTokenProviderInjection() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(new TypeLiteral>() { }).toInstance(Collections.singleton("Datsun")); bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, Z.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); Z orangeZ = (Z) carFactory.create(Color.ORANGE); assertEquals(Color.ORANGE, orangeZ.color); assertEquals("Datsun", orangeZ.manufacturersProvider.get().iterator().next()); } public static class Z implements Car { private final Provider> manufacturersProvider; private final Color color; @Inject public Z(Provider> manufacturersProvider, @Assisted Color color) { this.manufacturersProvider = manufacturersProvider; this.color = color; } } public static class Prius implements Car { final Color color; @Inject private Prius(@Assisted Color color) { this.color = color; } } public void testAssistInjectionInNonPublicConstructor() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, Prius.class)); } }); Prius prius = (Prius) injector.getInstance(ColoredCarFactory.class).create(Color.ORANGE); assertEquals(prius.color, Color.ORANGE); } public static class ExplodingCar implements Car { @Inject public ExplodingCar(@Assisted Color color) { throw new IllegalStateException("kaboom!"); } } public void testExceptionDuringConstruction() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, ExplodingCar.class)); } }); try { injector.getInstance(ColoredCarFactory.class).create(Color.ORANGE); fail(); } catch (IllegalStateException e) { assertEquals("kaboom!", e.getMessage()); } } public static class DefectiveCar implements Car { @Inject public DefectiveCar() throws ExplosionException, FireException { throw new ExplosionException(); } } public static class ExplosionException extends Exception { } public static class FireException extends Exception { } public interface DefectiveCarFactoryWithNoExceptions { Car createCar(); } public interface DefectiveCarFactory { Car createCar() throws FireException; } public interface CorrectDefectiveCarFactory { Car createCar() throws FireException, ExplosionException; } public void testConstructorExceptionsAreThrownByFactory() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(CorrectDefectiveCarFactory.class).toProvider( FactoryProvider.newFactory(CorrectDefectiveCarFactory.class, DefectiveCar.class)); } }); try { injector.getInstance(CorrectDefectiveCarFactory.class).createCar(); fail(); } catch (FireException e) { fail(); } catch (ExplosionException expected) { } } public static class WildcardCollection { public interface Factory { WildcardCollection create(Collection items); } @Inject public WildcardCollection(@Assisted Collection items) { } } public void testWildcardGenerics() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(WildcardCollection.Factory.class).toProvider( FactoryProvider.newFactory(WildcardCollection.Factory.class, WildcardCollection.class)); } }); WildcardCollection.Factory factory = injector.getInstance(WildcardCollection.Factory.class); factory.create(Collections.emptyList()); } public static class SteeringWheel {} public static class Fiat implements Car { private final SteeringWheel steeringWheel; private final Color color; @Inject public Fiat(SteeringWheel steeringWheel, @Assisted Color color) { this.steeringWheel = steeringWheel; this.color = color; } } public void testFactoryWithImplicitBindings() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, Fiat.class)); } }); ColoredCarFactory coloredCarFactory = injector.getInstance(ColoredCarFactory.class); Fiat fiat = (Fiat) coloredCarFactory.create(Color.GREEN); assertEquals(Color.GREEN, fiat.color); assertNotNull(fiat.steeringWheel); } public void testFactoryFailsWithMissingBinding() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, Mustang.class)); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "Could not find a suitable constructor in java.lang.Double.", "at " + ColoredCarFactory.class.getName() + ".create(FactoryProvider2Test.java"); } } public void testFactoryFailsWithMissingBindingInToolStage() { try { Guice.createInjector(Stage.TOOL, new AbstractModule() { @Override protected void configure() { bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, Mustang.class)); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "Could not find a suitable constructor in java.lang.Double.", "at " + ColoredCarFactory.class.getName() + ".create(FactoryProvider2Test.java"); } } public void testMethodsDeclaredInObject() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).toInstance(5.0d); bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, Mustang.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); assertEqualsBothWays(carFactory, carFactory); } static class Subaru implements Car { @Inject @Assisted Provider colorProvider; } public void testInjectingProviderOfParameter() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, Subaru.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); Subaru subaru = (Subaru) carFactory.create(Color.RED); assertSame(Color.RED, subaru.colorProvider.get()); assertSame(Color.RED, subaru.colorProvider.get()); Subaru sedan = (Subaru) carFactory.create(Color.BLUE); assertSame(Color.BLUE, sedan.colorProvider.get()); assertSame(Color.BLUE, sedan.colorProvider.get()); // and make sure the subaru is still red assertSame(Color.RED, subaru.colorProvider.get()); } public void testInjectingNullParameter() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, Subaru.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); Subaru subaru = (Subaru) carFactory.create(null); assertNull(subaru.colorProvider.get()); assertNull(subaru.colorProvider.get()); } interface ProviderBasedColoredCarFactory { Car createCar(Provider colorProvider, Provider stringProvider); Mustang createMustang(@Assisted("color") Provider colorProvider); } public void testAssistedProviderIsDisallowed() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(ProviderBasedColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ProviderBasedColoredCarFactory.class, Subaru.class)); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) A Provider may not be a type in a factory method of an AssistedInject." + "\n Offending instance is parameter [1] with key" + " [com.google.inject.Provider<" + Color.class.getName() + ">] on method [" + ProviderBasedColoredCarFactory.class.getName() + ".createCar()]", "2) A Provider may not be a type in a factory method of an AssistedInject." + "\n Offending instance is parameter [2] with key" + " [com.google.inject.Provider] on method [" + ProviderBasedColoredCarFactory.class.getName() + ".createCar()]", "3) A Provider may not be a type in a factory method of an AssistedInject." + "\n Offending instance is parameter [1] with key" + " [com.google.inject.Provider<" + Color.class.getName() + ">" + " annotated with @com.google.inject.assistedinject.Assisted(value=color)]" + " on method [" + ProviderBasedColoredCarFactory.class.getName() + ".createMustang()]" ); } } interface JavaxProviderBasedColoredCarFactory { Car createCar(javax.inject.Provider colorProvider, javax.inject.Provider stringProvider); Mustang createMustang(@Assisted("color") javax.inject.Provider colorProvider); } public void testAssistedJavaxProviderIsDisallowed() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(JavaxProviderBasedColoredCarFactory.class).toProvider( FactoryProvider.newFactory(JavaxProviderBasedColoredCarFactory.class, Subaru.class)); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) A Provider may not be a type in a factory method of an AssistedInject." + "\n Offending instance is parameter [1] with key" + " [com.google.inject.Provider<" + Color.class.getName() + ">] on method [" + JavaxProviderBasedColoredCarFactory.class.getName() + ".createCar()]", "2) A Provider may not be a type in a factory method of an AssistedInject." + "\n Offending instance is parameter [2] with key" + " [com.google.inject.Provider] on method [" + JavaxProviderBasedColoredCarFactory.class.getName() + ".createCar()]", "3) A Provider may not be a type in a factory method of an AssistedInject." + "\n Offending instance is parameter [1] with key" + " [com.google.inject.Provider<" + Color.class.getName() + ">" + " annotated with @com.google.inject.assistedinject.Assisted(value=color)]" + " on method [" + JavaxProviderBasedColoredCarFactory.class.getName() + ".createMustang()]" ); } } public void testFactoryUseBeforeInitialization() { ColoredCarFactory carFactory = FactoryProvider.newFactory(ColoredCarFactory.class, Subaru.class) .get(); try { carFactory.create(Color.RED); fail(); } catch (IllegalStateException expected) { assertContains(expected.getMessage(), "Factories.create() factories cannot be used until they're initialized by Guice."); } } interface MustangFactory { Mustang create(Color color); } public void testFactoryBuildingConcreteTypes() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(double.class).toInstance(5.0d); // note there is no 'thatMakes()' call here: bind(MustangFactory.class).toProvider( FactoryProvider.newFactory(MustangFactory.class, Mustang.class)); } }); MustangFactory factory = injector.getInstance(MustangFactory.class); Mustang mustang = factory.create(Color.RED); assertSame(Color.RED, mustang.color); assertEquals(5.0d, mustang.engineSize); } static class Fleet { @Inject Mustang mustang; @Inject Camaro camaro; } interface FleetFactory { Fleet createFleet(Color color); } public void testInjectDeepIntoConstructedObjects() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(double.class).toInstance(5.0d); bind(int.class).annotatedWith(Names.named("horsePower")).toInstance(250); bind(int.class).annotatedWith(Names.named("modelYear")).toInstance(1984); bind(FleetFactory.class).toProvider(FactoryProvider.newFactory(FleetFactory.class, Fleet.class)); } }); FleetFactory fleetFactory = injector.getInstance(FleetFactory.class); Fleet fleet = fleetFactory.createFleet(Color.RED); assertSame(Color.RED, fleet.mustang.color); assertEquals(5.0d, fleet.mustang.engineSize); assertSame(Color.RED, fleet.camaro.color); assertEquals(250, fleet.camaro.horsePower); assertEquals(1984, fleet.camaro.modelYear); } interface TwoToneCarFactory { Car create(@Assisted("paint") Color paint, @Assisted("fabric") Color fabric); } static class Maxima implements Car { @Inject @Assisted("paint") Color paint; @Inject @Assisted("fabric") Color fabric; } public void testDistinctKeys() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(TwoToneCarFactory.class).toProvider( FactoryProvider.newFactory(TwoToneCarFactory.class, Maxima.class)); } }); TwoToneCarFactory factory = injector.getInstance(TwoToneCarFactory.class); Maxima maxima = (Maxima) factory.create(Color.BLACK, Color.GRAY); assertSame(Color.BLACK, maxima.paint); assertSame(Color.GRAY, maxima.fabric); } interface DoubleToneCarFactory { Car create(@Assisted("paint") Color paint, @Assisted("paint") Color morePaint); } public void testDuplicateKeys() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(DoubleToneCarFactory.class).toProvider( FactoryProvider.newFactory(DoubleToneCarFactory.class, Maxima.class)); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "A binding to " + Color.class.getName() + " annotated with @" + Assisted.class.getName() + "(value=paint) was already configured at"); } } /*if[AOP]*/ public void testMethodInterceptorsOnAssistedTypes() { final AtomicInteger invocationCount = new AtomicInteger(); final org.aopalliance.intercept.MethodInterceptor interceptor = new org.aopalliance.intercept.MethodInterceptor() { public Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation) throws Throwable { invocationCount.incrementAndGet(); return methodInvocation.proceed(); } }; Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindInterceptor(Matchers.any(), Matchers.any(), interceptor); bind(Double.class).toInstance(5.0d); bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, Mustang.class)); } }); ColoredCarFactory factory = injector.getInstance(ColoredCarFactory.class); Mustang mustang = (Mustang) factory.create(Color.GREEN); assertEquals(0, invocationCount.get()); mustang.drive(); assertEquals(1, invocationCount.get()); } /*end[AOP]*/ /** * Our factories aren't reusable across injectors. Although this behaviour isn't something we * like, I have a test case to make sure the error message is pretty. */ public void testFactoryReuseErrorMessageIsPretty() { final Provider factoryProvider = FactoryProvider.newFactory(ColoredCarFactory.class, Mustang.class); Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).toInstance(5.0d); bind(ColoredCarFactory.class).toProvider(factoryProvider); } }); try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).toInstance(5.0d); bind(ColoredCarFactory.class).toProvider(factoryProvider); } }); fail(); } catch(CreationException expected) { assertContains(expected.getMessage(), "Factories.create() factories may only be used in one Injector!"); } } public void testNonAssistedFactoryMethodParameter() { try { FactoryProvider.newFactory(NamedParameterFactory.class, Mustang.class); fail(); } catch(ConfigurationException expected) { assertContains(expected.getMessage(), "Only @Assisted is allowed for factory parameters, but found @" + Named.class.getName()); } } interface NamedParameterFactory { Car create(@Named("seats") int seats, double engineSize); } public void testDefaultAssistedAnnotation() throws NoSuchFieldException { Assisted plainAssisted = Subaru.class.getDeclaredField("colorProvider").getAnnotation(Assisted.class); assertEqualsBothWays(FactoryProvider2.DEFAULT_ANNOTATION, plainAssisted); assertEquals(FactoryProvider2.DEFAULT_ANNOTATION.toString(), plainAssisted.toString()); } interface GenericColoredCarFactory { T create(Color color); } public void testGenericAssistedFactory() { final TypeLiteral> mustangTypeLiteral = new TypeLiteral>() {}; final TypeLiteral> camaroTypeLiteral = new TypeLiteral>() {}; Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).toInstance(5.0d); bind(int.class).annotatedWith(Names.named("horsePower")).toInstance(250); bind(int.class).annotatedWith(Names.named("modelYear")).toInstance(1984); bind(mustangTypeLiteral) .toProvider(FactoryProvider.newFactory(mustangTypeLiteral, TypeLiteral.get(Mustang.class))); bind(camaroTypeLiteral) .toProvider(FactoryProvider.newFactory(camaroTypeLiteral, TypeLiteral.get(Camaro.class))); } }); GenericColoredCarFactory mustangFactory = injector.getInstance(Key.get(mustangTypeLiteral)); GenericColoredCarFactory camaroFactory = injector.getInstance(Key.get(camaroTypeLiteral)); Mustang blueMustang = mustangFactory.create(Color.BLUE); assertEquals(Color.BLUE, blueMustang.color); assertEquals(5.0d, blueMustang.engineSize); Camaro redCamaro = camaroFactory.create(Color.RED); assertEquals(Color.RED, redCamaro.color); assertEquals(1984, redCamaro.modelYear); assertEquals(250, redCamaro.horsePower); } public interface Insurance { } public static class MustangInsurance implements Insurance { private final double premium; private final double limit; private Mustang car; @Inject public MustangInsurance(@Named("lowLimit") double limit, @Assisted Mustang car, @Assisted double premium) { this.premium = premium; this.limit = limit; this.car = car; } public void sell() {} } public static class CamaroInsurance implements Insurance { private final double premium; private final double limit; private Camaro car; @Inject public CamaroInsurance(@Named("highLimit") double limit, @Assisted Camaro car, @Assisted double premium) { this.premium = premium; this.limit = limit; this.car = car; } public void sell() {} } public interface MustangInsuranceFactory { public Insurance create(Mustang car, double premium); } public interface CamaroInsuranceFactory { public Insurance create(Camaro car, double premium); } public void testAssistedFactoryForConcreteType() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).annotatedWith(Names.named("lowLimit")).toInstance(50000.0d); bind(Double.class).annotatedWith(Names.named("highLimit")).toInstance(100000.0d); bind(MustangInsuranceFactory.class).toProvider( FactoryProvider.newFactory(MustangInsuranceFactory.class, MustangInsurance.class)); bind(CamaroInsuranceFactory.class).toProvider( FactoryProvider.newFactory(CamaroInsuranceFactory.class, CamaroInsurance.class)); } }); MustangInsuranceFactory mustangInsuranceFactory = injector.getInstance(MustangInsuranceFactory.class); CamaroInsuranceFactory camaroInsuranceFactory = injector.getInstance(CamaroInsuranceFactory.class); Mustang mustang = new Mustang(5000d, Color.BLACK); MustangInsurance mustangPolicy = (MustangInsurance) mustangInsuranceFactory.create(mustang, 800.0d); assertEquals(800.0d, mustangPolicy.premium); assertEquals(50000.0d, mustangPolicy.limit); Camaro camaro = new Camaro(3000, 1967, Color.BLUE); CamaroInsurance camaroPolicy = (CamaroInsurance) camaroInsuranceFactory.create(camaro, 800.0d); assertEquals(800.0d, camaroPolicy.premium); assertEquals(100000.0d, camaroPolicy.limit); } public interface InsuranceFactory { public Insurance create(T car, double premium); } public void testAssistedFactoryForParameterizedType() { final TypeLiteral> mustangInsuranceFactoryType = new TypeLiteral>() {}; final TypeLiteral> camaroInsuranceFactoryType = new TypeLiteral>() {}; Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).annotatedWith(Names.named("lowLimit")).toInstance(50000.0d); bind(Double.class).annotatedWith(Names.named("highLimit")).toInstance(100000.0d); bind(mustangInsuranceFactoryType).toProvider(FactoryProvider.newFactory( mustangInsuranceFactoryType, TypeLiteral.get(MustangInsurance.class))); bind(camaroInsuranceFactoryType).toProvider(FactoryProvider.newFactory( camaroInsuranceFactoryType, TypeLiteral.get(CamaroInsurance.class))); } }); InsuranceFactory mustangInsuranceFactory = injector.getInstance(Key.get(mustangInsuranceFactoryType)); InsuranceFactory camaroInsuranceFactory = injector.getInstance(Key.get(camaroInsuranceFactoryType)); Mustang mustang = new Mustang(5000d, Color.BLACK); MustangInsurance mustangPolicy = (MustangInsurance) mustangInsuranceFactory.create(mustang, 800.0d); assertEquals(800.0d, mustangPolicy.premium); assertEquals(50000.0d, mustangPolicy.limit); Camaro camaro = new Camaro(3000, 1967, Color.BLUE); CamaroInsurance camaroPolicy = (CamaroInsurance) camaroInsuranceFactory.create(camaro, 800.0d); assertEquals(800.0d, camaroPolicy.premium); assertEquals(100000.0d, camaroPolicy.limit); } public static class AutoInsurance implements Insurance { private final double premium; private final double limit; private final T car; @Inject public AutoInsurance(double limit, @Assisted T car, @Assisted double premium) { this.limit = limit; this.car = car; this.premium = premium; } public void sell() {} } public void testAssistedFactoryForTypeVariableParameters() { final TypeLiteral> camaroInsuranceFactoryType = new TypeLiteral>() {}; Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).toInstance(50000.0d); bind(camaroInsuranceFactoryType).toProvider(FactoryProvider.newFactory( camaroInsuranceFactoryType, new TypeLiteral>() {})); } }); InsuranceFactory camaroInsuranceFactory = injector.getInstance(Key.get(camaroInsuranceFactoryType)); Camaro camaro = new Camaro(3000, 1967, Color.BLUE); AutoInsurance camaroPolicy = (AutoInsurance) camaroInsuranceFactory.create(camaro, 800.0d); assertEquals(800.0d, camaroPolicy.premium); assertEquals(50000.0d, camaroPolicy.limit); assertEquals(camaro, camaroPolicy.car); } public void testInjectingAndUsingInjector() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(ColoredCarFactory.class).toProvider( FactoryProvider.newFactory(ColoredCarFactory.class, Segway.class)); } }); ColoredCarFactory carFactory = injector.getInstance(ColoredCarFactory.class); Segway green = (Segway)carFactory.create(Color.GREEN); assertSame(Color.GREEN, green.getColor()); assertSame(Color.GREEN, green.getColor()); Segway pink = (Segway)carFactory.create(Color.PINK); assertSame(Color.PINK, pink.getColor()); assertSame(Color.PINK, pink.getColor()); assertSame(Color.GREEN, green.getColor()); } static class Segway implements Car { @Inject Injector injector; Color getColor() { return injector.getInstance(Key.get(Color.class, FactoryProvider2.DEFAULT_ANNOTATION)); } } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/test/com/google/inject/assistedinject/FactoryModuleBuilderTest.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/test/com/google/inject/assistedinject/FactoryM0000644000175000017500000004200511704661106032576 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import static com.google.inject.Asserts.assertContains; import static com.google.inject.name.Names.named; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.inject.AbstractModule; import com.google.inject.Binding; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provides; import com.google.inject.Singleton; import com.google.inject.Stage; import com.google.inject.TypeLiteral; import com.google.inject.name.Named; import com.google.inject.name.Names; import com.google.inject.spi.Dependency; import com.google.inject.spi.Element; import com.google.inject.spi.Elements; import com.google.inject.spi.HasDependencies; import com.google.inject.spi.Message; import junit.framework.TestCase; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; public class FactoryModuleBuilderTest extends TestCase { private enum Color { BLUE, GREEN, RED, GRAY, BLACK } public void testImplicitForwardingAssistedBindingFailsWithInterface() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Car.class).to(Golf.class); install(new FactoryModuleBuilder().build(ColoredCarFactory.class)); } }); fail(); } catch (CreationException ce) { assertContains( ce.getMessage(), "1) " + Car.class.getName() + " is an interface, not a concrete class.", "Unable to create AssistedInject factory.", "while locating " + Car.class.getName(), "at " + ColoredCarFactory.class.getName() + ".create("); assertEquals(1, ce.getErrorMessages().size()); } } public void testImplicitForwardingAssistedBindingFailsWithAbstractClass() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(AbstractCar.class).to(ArtCar.class); install(new FactoryModuleBuilder().build(ColoredAbstractCarFactory.class)); } }); fail(); } catch (CreationException ce) { assertContains( ce.getMessage(), "1) " + AbstractCar.class.getName() + " is abstract, not a concrete class.", "Unable to create AssistedInject factory.", "while locating " + AbstractCar.class.getName(), "at " + ColoredAbstractCarFactory.class.getName() + ".create("); assertEquals(1, ce.getErrorMessages().size()); } } public void testImplicitForwardingAssistedBindingCreatesNewObjects() { final Mustang providedMustang = new Mustang(Color.BLUE); Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder().build(MustangFactory.class)); } @Provides Mustang provide() { return providedMustang; } }); assertSame(providedMustang, injector.getInstance(Mustang.class)); MustangFactory factory = injector.getInstance(MustangFactory.class); Mustang created = factory.create(Color.GREEN); assertNotSame(providedMustang, created); assertEquals(Color.BLUE, providedMustang.color); assertEquals(Color.GREEN, created.color); } public void testExplicitForwardingAssistedBindingFailsWithInterface() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Volkswagen.class).to(Golf.class); install(new FactoryModuleBuilder() .implement(Car.class, Volkswagen.class) .build(ColoredCarFactory.class)); } }); fail(); } catch (CreationException ce) { assertContains( ce.getMessage(), "1) " + Volkswagen.class.getName() + " is an interface, not a concrete class.", "Unable to create AssistedInject factory.", "while locating " + Volkswagen.class.getName(), "while locating " + Car.class.getName(), "at " + ColoredCarFactory.class.getName() + ".create("); assertEquals(1, ce.getErrorMessages().size()); } } public void testExplicitForwardingAssistedBindingFailsWithAbstractClass() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(AbstractCar.class).to(ArtCar.class); install(new FactoryModuleBuilder() .implement(Car.class, AbstractCar.class) .build(ColoredCarFactory.class)); } }); fail(); } catch (CreationException ce) { assertContains( ce.getMessage(), "1) " + AbstractCar.class.getName() + " is abstract, not a concrete class.", "Unable to create AssistedInject factory.", "while locating " + AbstractCar.class.getName(), "while locating " + Car.class.getName(), "at " + ColoredCarFactory.class.getName() + ".create("); assertEquals(1, ce.getErrorMessages().size()); } } public void testExplicitForwardingAssistedBindingCreatesNewObjects() { final Mustang providedMustang = new Mustang(Color.BLUE); Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder().implement(Car.class, Mustang.class).build( ColoredCarFactory.class)); } @Provides Mustang provide() { return providedMustang; } }); assertSame(providedMustang, injector.getInstance(Mustang.class)); ColoredCarFactory factory = injector.getInstance(ColoredCarFactory.class); Mustang created = (Mustang)factory.create(Color.GREEN); assertNotSame(providedMustang, created); assertEquals(Color.BLUE, providedMustang.color); assertEquals(Color.GREEN, created.color); } public void testAnnotatedAndParentBoundReturnValue() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Car.class).to(Golf.class); bind(Integer.class).toInstance(911); bind(Double.class).toInstance(5.0d); install(new FactoryModuleBuilder() .implement(Car.class, Names.named("german"), Beetle.class) .implement(Car.class, Names.named("american"), Mustang.class) .build(AnnotatedVersatileCarFactory.class)); } }); AnnotatedVersatileCarFactory factory = injector.getInstance(AnnotatedVersatileCarFactory.class); assertTrue(factory.getGermanCar(Color.BLACK) instanceof Beetle); assertTrue(injector.getInstance(Car.class) instanceof Golf); } public void testParentBoundReturnValue() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Car.class).to(Golf.class); bind(Double.class).toInstance(5.0d); install(new FactoryModuleBuilder() .implement(Car.class, Mustang.class) .build(ColoredCarFactory.class)); } }); ColoredCarFactory factory = injector.getInstance(ColoredCarFactory.class); assertTrue(factory.create(Color.RED) instanceof Mustang); assertTrue(injector.getInstance(Car.class) instanceof Golf); } public void testConfigureAnnotatedReturnValue() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder() .implement(Car.class, Names.named("german"), Beetle.class) .implement(Car.class, Names.named("american"), Mustang.class) .build(AnnotatedVersatileCarFactory.class)); } }); AnnotatedVersatileCarFactory factory = injector.getInstance(AnnotatedVersatileCarFactory.class); assertTrue(factory.getGermanCar(Color.GRAY) instanceof Beetle); assertTrue(factory.getAmericanCar(Color.BLACK) instanceof Mustang); } public void testNoBindingAssistedInject() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder().build(MustangFactory.class)); } }); MustangFactory factory = injector.getInstance(MustangFactory.class); Mustang mustang = factory.create(Color.BLUE); assertEquals(Color.BLUE, mustang.color); } public void testBindingAssistedInject() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder() .implement(Car.class, Mustang.class) .build(ColoredCarFactory.class)); } }); ColoredCarFactory factory = injector.getInstance(ColoredCarFactory.class); Mustang mustang = (Mustang) factory.create(Color.BLUE); assertEquals(Color.BLUE, mustang.color); } public void testMultipleReturnTypes() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Double.class).toInstance(5.0d); install(new FactoryModuleBuilder().build(VersatileCarFactory.class)); } }); VersatileCarFactory factory = injector.getInstance(VersatileCarFactory.class); Mustang mustang = factory.getMustang(Color.RED); assertEquals(Color.RED, mustang.color); Beetle beetle = factory.getBeetle(Color.GREEN); assertEquals(Color.GREEN, beetle.color); } public void testParameterizedClassesWithNoImplements() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder().build(new TypeLiteral>() {})); } }); Foo.Factory factory = injector.getInstance(Key.get(new TypeLiteral>() {})); @SuppressWarnings("unused") Foo foo = factory.create(new Bar()); } public void testGenericErrorMessageMakesSense() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder().build(Key.get(Foo.Factory.class))); } }); fail(); } catch(CreationException ce ) { // Assert not only that it's the correct message, but also that it's the *only* message. Collection messages = ce.getErrorMessages(); assertEquals( Foo.Factory.class.getName() + " cannot be used as a key; It is not fully specified.", Iterables.getOnlyElement(messages).getMessage()); } } interface Car {} interface Volkswagen extends Car {} interface ColoredCarFactory { Car create(Color color); } interface MustangFactory { Mustang create(Color color); } interface VersatileCarFactory { Mustang getMustang(Color color); Beetle getBeetle(Color color); } interface AnnotatedVersatileCarFactory { @Named("german") Car getGermanCar(Color color); @Named("american") Car getAmericanCar(Color color); } public static class Golf implements Volkswagen {} public static class Mustang implements Car { private final Color color; @Inject public Mustang(@Assisted Color color) { this.color = color; } } public static class Beetle implements Car { private final Color color; @Inject public Beetle(@Assisted Color color) { this.color = color; } } public static class Foo { static interface Factory { Foo create(Bar bar); } @Inject Foo(@Assisted Bar bar, Baz baz) {} } public static class Bar {} public static class Baz {} abstract static class AbstractCar implements Car {} interface ColoredAbstractCarFactory { AbstractCar create(Color color); } public static class ArtCar extends AbstractCar {} public void testFactoryBindingDependencies() { // validate dependencies work in all stages & as a raw element, // and that dependencies work for methods, fields, constructors, // and for @AssistedInject constructors too. Module module = new AbstractModule() { @Override protected void configure() { bind(Integer.class).toInstance(42); bind(Double.class).toInstance(4.2d); bind(Float.class).toInstance(4.2f); bind(String.class).annotatedWith(named("dog")).toInstance("dog"); bind(String.class).annotatedWith(named("cat1")).toInstance("cat1"); bind(String.class).annotatedWith(named("cat2")).toInstance("cat2"); bind(String.class).annotatedWith(named("cat3")).toInstance("cat3"); bind(String.class).annotatedWith(named("arbitrary")).toInstance("fail!"); install(new FactoryModuleBuilder() .implement(Animal.class, Dog.class) .build(AnimalHouse.class)); } }; Set> expectedKeys = ImmutableSet.>of( Key.get(Integer.class), Key.get(Double.class), Key.get(Float.class), Key.get(String.class, named("dog")), Key.get(String.class, named("cat1")), Key.get(String.class, named("cat2")), Key.get(String.class, named("cat3")) ); Injector injector = Guice.createInjector(module); validateDependencies(expectedKeys, injector.getBinding(AnimalHouse.class)); injector = Guice.createInjector(Stage.TOOL, module); validateDependencies(expectedKeys, injector.getBinding(AnimalHouse.class)); List elements = Elements.getElements(module); boolean found = false; for(Element element : elements) { if(element instanceof Binding) { Binding binding = (Binding)element; if(binding.getKey().equals(Key.get(AnimalHouse.class))) { found = true; validateDependencies(expectedKeys, binding); break; } } } assertTrue(found); } private void validateDependencies(Set> expectedKeys, Binding binding) { Set> dependencies = ((HasDependencies)binding).getDependencies(); Set> actualKeys = new HashSet>(); for(Dependency dependency : dependencies) { actualKeys.add(dependency.getKey()); } assertEquals(expectedKeys, actualKeys); } interface AnimalHouse { Animal createAnimal(String name); Cat createCat(String name); Cat createCat(int age); } interface Animal {} private static class Dog implements Animal { @Inject int a; @Inject Dog(@Assisted String a, double b) {} @Inject void register(@Named("dog") String a) {} } private static class Cat implements Animal { @Inject float a; @AssistedInject Cat(@Assisted String a, @Named("cat1") String b) {} @AssistedInject Cat(@Assisted int a, @Named("cat2") String b) {} @AssistedInject Cat(@Assisted byte a, @Named("catfail") String b) {} // not a dependency! @Inject void register(@Named("cat3") String a) {} } public void testFactoryPublicAndReturnTypeNotPublic() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder() .implement(Hidden.class, HiddenImpl.class) .build(NotHidden.class)); } }); } catch(CreationException ce) { assertEquals(NotHidden.class.getName() + " is public, but has a method that returns a non-public type: " + Hidden.class.getName() + ". Due to limitations with java.lang.reflect.Proxy, this is not allowed. " + "Please either make the factory non-public or the return type public.", Iterables.getOnlyElement(ce.getErrorMessages()).getMessage()); } } interface Hidden {} public static class HiddenImpl implements Hidden {} public interface NotHidden { Hidden create(); } public void testSingletonScopeOnAssistedClassIsIgnored() { // production stage is important, because it will trigger eager singleton creation Injector injector = Guice.createInjector(Stage.PRODUCTION, new AbstractModule() { @Override protected void configure() { install(new FactoryModuleBuilder().build(SingletonFactory.class)); } }); SingletonFactory factory = injector.getInstance(SingletonFactory.class); assertNotSame(factory.create("foo"), factory.create("bar")); } interface SingletonFactory { AssistedSingleton create(String string); } @Singleton static class AssistedSingleton { @Inject public AssistedSingleton(@Assisted String string) { } } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/test/com/google/inject/assistedinject/ExtensionSpiTest.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/test/com/google/inject/assistedinject/Extensio0000644000175000017500000002103711704661106032652 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import static com.google.inject.name.Names.named; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.inject.AbstractModule; import com.google.inject.Binding; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Stage; import com.google.inject.name.Named; import com.google.inject.spi.DefaultBindingTargetVisitor; import com.google.inject.spi.Dependency; import com.google.inject.spi.Element; import com.google.inject.spi.Elements; import junit.framework.AssertionFailedError; import junit.framework.TestCase; import java.util.List; import java.util.Set; import java.util.logging.Logger; /** * Tests for AssistedInject Spi. * * @author ramakrishna@google.com (Ramakrishna Rajanna) */ public class ExtensionSpiTest extends TestCase { public final void testSpiOnElements() throws Exception { AssistedInjectSpiVisitor visitor = new AssistedInjectSpiVisitor(); Integer count = 0; for(Element element : Elements.getElements(new Module())) { if(element instanceof Binding) { assertEquals(count++, ((Binding)element).acceptTargetVisitor(visitor)); } } validateVisitor(visitor); } public void testSpiOnVisitor() throws Exception { AssistedInjectSpiVisitor visitor = new AssistedInjectSpiVisitor(); Integer count = 0; Injector injector = Guice.createInjector(new Module()); for(Binding binding : injector.getBindings().values()) { assertEquals(count++, binding.acceptTargetVisitor(visitor)); } validateVisitor(visitor); } private void validateVisitor(AssistedInjectSpiVisitor visitor) throws Exception { assertEquals(1, visitor.assistedBindingCount); List assistedMethods = Lists.newArrayList(Iterables.getOnlyElement( visitor.assistedInjectBindings).getAssistedMethods()); assertEquals(7, assistedMethods.size()); assertEquals(1, visitor.assistedBindingCount); assertEquals(1, visitor.assistedInjectBindings.size()); // Validate for each of the methods in AnimalFactory validateCreateAStrangeCatAsAnimal(assistedMethods.get(0)); validatecreateStrangeCatWithConstructorForOwner(assistedMethods.get(1)); validatecreateStrangeCatWithConstructorForAge(assistedMethods.get(2)); validateCreateCatWithANonAssistedDependency(assistedMethods.get(3)); validateCreateCat(assistedMethods.get(4)); validateCreateASimpleCatAsAnimal(assistedMethods.get(5)); validateCreateCatWithNonAssistedDependencies(assistedMethods.get(6)); } private void validateCreateAStrangeCatAsAnimal(AssistedMethod assistedMethod) { validateAssistedMethod(assistedMethod, "createAStrangeCatAsAnimal", StrangeCat.class, ImmutableList.>of()); } private void validatecreateStrangeCatWithConstructorForOwner(AssistedMethod assistedMethod) { validateAssistedMethod(assistedMethod, "createStrangeCatWithConstructorForOwner", StrangeCat.class, ImmutableList.>of()); } private void validatecreateStrangeCatWithConstructorForAge(AssistedMethod assistedMethod) { validateAssistedMethod(assistedMethod, "createStrangeCatWithConstructorForAge", StrangeCat.class, ImmutableList.>of()); } private void validateCreateCatWithANonAssistedDependency(AssistedMethod assistedMethod) throws Exception { validateAssistedMethod(assistedMethod, "createCatWithANonAssistedDependency", CatWithAName.class, ImmutableList.>of(Key.get(String.class, named("catName2")))); } private void validateCreateCat(AssistedMethod assistedMethod) throws Exception { validateAssistedMethod(assistedMethod, "createCat", Cat.class, ImmutableList.>of()); } private void validateCreateASimpleCatAsAnimal(AssistedMethod assistedMethod) { validateAssistedMethod(assistedMethod, "createASimpleCatAsAnimal", SimpleCat.class, ImmutableList.>of()); } private void validateCreateCatWithNonAssistedDependencies(AssistedMethod assistedMethod) { List> dependencyKeys = ImmutableList.>of( Key.get(String.class, named("catName1")), Key.get(String.class, named("petName")), Key.get(Integer.class, named("age"))); validateAssistedMethod(assistedMethod, "createCatWithNonAssistedDependencies", ExplodingCat.class, dependencyKeys); } private void validateAssistedMethod(AssistedMethod assistedMethod, String factoryMethodName, Class clazz, List> dependencyKeys){ assertEquals(factoryMethodName, assistedMethod.getFactoryMethod().getName()); assertEquals(clazz, assistedMethod.getImplementationConstructor().getDeclaringClass()); assertEquals(dependencyKeys.size(), assistedMethod.getDependencies().size()); for (Dependency dependency : assistedMethod.getDependencies()) { assertTrue(dependencyKeys.contains(dependency.getKey())); } assertEquals(clazz, assistedMethod.getImplementationType().getType()); } interface AnimalFactory { Cat createCat(String owner); CatWithAName createCatWithANonAssistedDependency(String owner); @Named("SimpleCat") Animal createASimpleCatAsAnimal(String owner); Animal createAStrangeCatAsAnimal(String owner); StrangeCat createStrangeCatWithConstructorForOwner(String owner); StrangeCat createStrangeCatWithConstructorForAge(Integer age); ExplodingCat createCatWithNonAssistedDependencies(String owner); } interface Animal {} private static class Cat implements Animal { @Inject Cat(@Assisted String owner) {} } private static class SimpleCat implements Animal { @Inject SimpleCat(@Assisted String owner) { } } private static class StrangeCat implements Animal { @AssistedInject StrangeCat(@Assisted String owner) {} @AssistedInject StrangeCat(@Assisted Integer age) {} } private static class ExplodingCat implements Animal { @Inject public ExplodingCat(@Named("catName1") String name, @Assisted String owner, @Named("age") Integer age, @Named("petName") String petName) {} } private static class CatWithAName extends Cat { @Inject CatWithAName(@Assisted String owner, @Named("catName2") String name) { super(owner); } } public class Module extends AbstractModule{ @Override protected void configure() { bind(String.class).annotatedWith(named("catName1")).toInstance("kitty1"); bind(String.class).annotatedWith(named("catName2")).toInstance("kitty2"); bind(String.class).annotatedWith(named("petName")).toInstance("pussy"); bind(Integer.class).annotatedWith(named("age")).toInstance(12); install(new FactoryModuleBuilder() .implement(Animal.class, StrangeCat.class) .implement(Animal.class, named("SimpleCat"), SimpleCat.class) .build(AnimalFactory.class)); } } public class AssistedInjectSpiVisitor extends DefaultBindingTargetVisitor implements AssistedInjectTargetVisitor { private final Set allowedClasses = ImmutableSet. of( Injector.class, Stage.class, Logger.class, String.class, Integer.class); private int assistedBindingCount = 0; private int currentCount = 0; private List> assistedInjectBindings = Lists.newArrayList(); public Integer visit(AssistedInjectBinding assistedInjectBinding) { assistedInjectBindings.add(assistedInjectBinding); assistedBindingCount++; return currentCount++; } @Override protected Integer visitOther(Binding binding) { if(!allowedClasses.contains(binding.getKey().getTypeLiteral().getRawType())) { throw new AssertionFailedError("invalid other binding: " + binding); } return currentCount++; } } } sisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/0000755000175000017500000000000011704661106022414 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/0000755000175000017500000000000011704661106023172 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/0000755000175000017500000000000011704661106024446 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/0000755000175000017500000000000011704661106025722 5ustar tonytonysisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/0000755000175000017500000000000011704661106030736 5ustar tonytony././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/package-info.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/package-i0000644000175000017500000000140411704661106032501 0ustar tonytony/* * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Extension for combining factory interfaces with injection; this extension requires {@code * guice-assistedinject-3.0.jar}. */ package com.google.inject.assistedinject;././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/ParameterListKey.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/Parameter0000755000175000017500000000326111704661106032606 0ustar tonytony/** * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import com.google.inject.TypeLiteral; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * A list of {@link TypeLiteral}s to match an injectable Constructor's assited * parameter types to the corresponding factory method. * * @author jmourits@google.com (Jerome Mourits) * @author jessewilson@google.com (Jesse Wilson) */ class ParameterListKey { private final List paramList; public ParameterListKey(List paramList) { this.paramList = new ArrayList(paramList); } public ParameterListKey(Type[] types) { this(Arrays.asList(types)); } @Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof ParameterListKey)) { return false; } ParameterListKey other = (ParameterListKey) o; return paramList.equals(other.paramList); } @Override public int hashCode() { return paramList.hashCode(); } @Override public String toString() { return paramList.toString(); } }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/Parameter.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/Parameter0000755000175000017500000001157711704661106032617 0ustar tonytony/** * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import static com.google.common.base.Preconditions.checkArgument; import com.google.inject.ConfigurationException; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.internal.Annotations; import java.lang.annotation.Annotation; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; /** * Models a method or constructor parameter. * * @author jmourits@google.com (Jerome Mourits) * @author jessewilson@google.com (Jesse Wilson) */ class Parameter { private final Type type; private final boolean isAssisted; private final Annotation bindingAnnotation; private final boolean isProvider; private volatile Provider provider; public Parameter(Type type, Annotation[] annotations) { this.type = type; this.bindingAnnotation = getBindingAnnotation(annotations); this.isAssisted = hasAssistedAnnotation(annotations); this.isProvider = isProvider(type); } public boolean isProvidedByFactory() { return isAssisted; } public Type getType() { return type; } @Override public String toString() { StringBuilder result = new StringBuilder(); if (isAssisted) { result.append("@Assisted"); result.append(" "); } if (bindingAnnotation != null) { result.append(bindingAnnotation.toString()); result.append(" "); } result.append(type.toString()); return result.toString(); } private boolean hasAssistedAnnotation(Annotation[] annotations) { for (Annotation annotation : annotations) { if (annotation.annotationType().equals(Assisted.class)) { return true; } } return false; } /** * Returns the Guice {@link Key} for this parameter. */ public Object getValue(Injector injector) { if (null == provider) { synchronized (this) { if (null == provider) { provider = isProvider ? injector.getProvider(getBindingForType(getProvidedType(type))) : injector.getProvider(getPrimaryBindingKey()); } } } return isProvider ? provider : provider.get(); } public boolean isBound(Injector injector) { return isBound(injector, getPrimaryBindingKey()) || isBound(injector, fixAnnotations(getPrimaryBindingKey())); } private boolean isBound(Injector injector, Key key) { // This method is particularly lame - we really need an API that can test // for any binding, implicit or explicit try { return injector.getBinding(key) != null; } catch (ConfigurationException e) { return false; } } /** * Replace annotation instances with annotation types, this is only * appropriate for testing if a key is bound and not for injecting. * * See Guice bug 125, * http://code.google.com/p/google-guice/issues/detail?id=125 */ public Key fixAnnotations(Key key) { return key.getAnnotation() == null ? key : Key.get(key.getTypeLiteral(), key.getAnnotation().annotationType()); } Key getPrimaryBindingKey() { return isProvider ? getBindingForType(getProvidedType(type)) : getBindingForType(type); } private Type getProvidedType(Type type) { return ((ParameterizedType) type).getActualTypeArguments()[0]; } private boolean isProvider(Type type) { return type instanceof ParameterizedType && ((ParameterizedType) type).getRawType() == Provider.class; } private Key getBindingForType(Type type) { return bindingAnnotation != null ? Key.get(type, bindingAnnotation) : Key.get(type); } /** * Returns the unique binding annotation from the specified list, or * {@code null} if there are none. * * @throws IllegalStateException if multiple binding annotations exist. */ private Annotation getBindingAnnotation(Annotation[] annotations) { Annotation bindingAnnotation = null; for (Annotation annotation : annotations) { if (Annotations.isBindingAnnotation(annotation.annotationType())) { checkArgument(bindingAnnotation == null, "Parameter has multiple binding annotations: %s and %s", bindingAnnotation, annotation); bindingAnnotation = annotation; } } return bindingAnnotation; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryProvider2.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryPr0000644000175000017500000006460611704661106032606 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.Iterables.getOnlyElement; import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.inject.AbstractModule; import com.google.inject.Binder; import com.google.inject.Binding; import com.google.inject.ConfigurationException; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provider; import com.google.inject.ProvisionException; import com.google.inject.Scopes; import com.google.inject.TypeLiteral; import com.google.inject.internal.Annotations; import com.google.inject.internal.BytecodeGen; import com.google.inject.internal.Errors; import com.google.inject.internal.ErrorsException; import com.google.inject.internal.util.Classes; import com.google.inject.spi.BindingTargetVisitor; import com.google.inject.spi.Dependency; import com.google.inject.spi.HasDependencies; import com.google.inject.spi.InjectionPoint; import com.google.inject.spi.Message; import com.google.inject.spi.ProviderInstanceBinding; import com.google.inject.spi.ProviderWithExtensionVisitor; import com.google.inject.spi.Toolable; import com.google.inject.util.Providers; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.Proxy; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; /** * The newer implementation of factory provider. This implementation uses a child injector to * create values. * * @author jessewilson@google.com (Jesse Wilson) * @author dtm@google.com (Daniel Martin) * @author schmitt@google.com (Peter Schmitt) * @author sameb@google.com (Sam Berlin) */ final class FactoryProvider2 implements InvocationHandler, ProviderWithExtensionVisitor, HasDependencies, AssistedInjectBinding { /** if a factory method parameter isn't annotated, it gets this annotation. */ static final Assisted DEFAULT_ANNOTATION = new Assisted() { public String value() { return ""; } public Class annotationType() { return Assisted.class; } @Override public boolean equals(Object o) { return o instanceof Assisted && ((Assisted) o).value().equals(""); } @Override public int hashCode() { return 127 * "value".hashCode() ^ "".hashCode(); } @Override public String toString() { return "@" + Assisted.class.getName() + "(value=)"; } }; /** All the data necessary to perform an assisted inject. */ private static class AssistData implements AssistedMethod { /** the constructor the implementation is constructed with. */ final Constructor constructor; /** the return type in the factory method that the constructor is bound to. */ final Key returnType; /** the parameters in the factory method associated with this data. */ final ImmutableList> paramTypes; /** the type of the implementation constructed */ final TypeLiteral implementationType; /** All non-assisted dependencies required by this method. */ final Set> dependencies; /** The factory method associated with this data*/ final Method factoryMethod; /** true if {@link #validForOptimizedAssistedInject} returned true. */ final boolean optimized; /** the list of optimized providers, empty if not optimized. */ final List providers; /** used to perform optimized factory creations. */ volatile Binding cachedBinding; // TODO: volatile necessary? AssistData(Constructor constructor, Key returnType, ImmutableList> paramTypes, TypeLiteral implementationType, Method factoryMethod, Set> dependencies, boolean optimized, List providers) { this.constructor = constructor; this.returnType = returnType; this.paramTypes = paramTypes; this.implementationType = implementationType; this.factoryMethod = factoryMethod; this.dependencies = dependencies; this.optimized = optimized; this.providers = providers; } @Override public String toString() { return Objects.toStringHelper(getClass()) .add("ctor", constructor) .add("return type", returnType) .add("param type", paramTypes) .add("implementation type", implementationType) .add("dependencies", dependencies) .add("factory method", factoryMethod) .add("optimized", optimized) .add("providers", providers) .add("cached binding", cachedBinding) .toString(); } public Set> getDependencies() { return dependencies; } public Method getFactoryMethod() { return factoryMethod; } public Constructor getImplementationConstructor() { return constructor; } public TypeLiteral getImplementationType() { return implementationType; } } /** Mapping from method to the data about how the method will be assisted. */ private final ImmutableMap assistDataByMethod; /** the hosting injector, or null if we haven't been initialized yet */ private Injector injector; /** the factory interface, implemented and provided */ private final F factory; /** The key that this is bound to. */ private final Key factoryKey; /** * @param factoryType a Java interface that defines one or more create methods. * @param collector binding configuration that maps method return types to * implementation types. */ FactoryProvider2(Key factoryKey, BindingCollector collector) { this.factoryKey = factoryKey; TypeLiteral factoryType = factoryKey.getTypeLiteral(); Errors errors = new Errors(); @SuppressWarnings("unchecked") // we imprecisely treat the class literal of T as a Class Class factoryRawType = (Class) factoryType.getRawType(); try { if(!factoryRawType.isInterface()) { throw errors.addMessage("%s must be an interface.", factoryRawType).toException(); } ImmutableMap.Builder assistDataBuilder = ImmutableMap.builder(); // TODO: also grab methods from superinterfaces for (Method method : factoryRawType.getMethods()) { TypeLiteral returnTypeLiteral = factoryType.getReturnType(method); Key returnType; try { returnType = Annotations.getKey(returnTypeLiteral, method, method.getAnnotations(), errors); } catch(ConfigurationException ce) { // If this was an error due to returnTypeLiteral not being specified, rephrase // it as our factory not being specified, so it makes more sense to users. if(isTypeNotSpecified(returnTypeLiteral, ce)) { throw errors.keyNotFullySpecified(TypeLiteral.get(factoryRawType)).toException(); } else { throw ce; } } validateFactoryReturnType(errors, returnType.getTypeLiteral().getRawType(), factoryRawType); List> params = factoryType.getParameterTypes(method); Annotation[][] paramAnnotations = method.getParameterAnnotations(); int p = 0; List> keys = Lists.newArrayList(); for (TypeLiteral param : params) { Key paramKey = Annotations.getKey(param, method, paramAnnotations[p++], errors); Class underlylingType = paramKey.getTypeLiteral().getRawType(); if (underlylingType.equals(Provider.class) || underlylingType.equals(javax.inject.Provider.class)) { errors.addMessage("A Provider may not be a type in a factory method of an AssistedInject." + "\n Offending instance is parameter [%s] with key [%s] on method [%s]", p, paramKey, method); } keys.add(assistKey(method, paramKey, errors)); } ImmutableList> immutableParamList = ImmutableList.copyOf(keys); // try to match up the method to the constructor TypeLiteral implementation = collector.getBindings().get(returnType); if(implementation == null) { implementation = returnType.getTypeLiteral(); } InjectionPoint ctorInjectionPoint; try { ctorInjectionPoint = findMatchingConstructorInjectionPoint(method, returnType, implementation, immutableParamList); } catch(ErrorsException ee) { errors.merge(ee.getErrors()); continue; } Constructor constructor = (Constructor)ctorInjectionPoint.getMember(); List providers = Collections.emptyList(); Set> deps = getDependencies(ctorInjectionPoint, implementation); boolean optimized = false; // Now go through all dependencies of the implementation and see if it is OK to // use an optimized form of assistedinject2. The optimized form requires that // all injections directly inject the object itself (and not a Provider of the object, // or an Injector), because it caches a single child injector and mutates the Provider // of the arguments in a ThreadLocal. if(isValidForOptimizedAssistedInject(deps)) { ImmutableList.Builder providerListBuilder = ImmutableList.builder(); for(int i = 0; i < params.size(); i++) { providerListBuilder.add(new ThreadLocalProvider()); } providers = providerListBuilder.build(); optimized = true; } assistDataBuilder.put(method, new AssistData(constructor, returnType, immutableParamList, implementation, method, removeAssistedDeps(deps), optimized, providers)); } // If we generated any errors (from finding matching constructors, for instance), throw an exception. if(errors.hasErrors()) { throw errors.toException(); } assistDataByMethod = assistDataBuilder.build(); } catch (ErrorsException e) { throw new ConfigurationException(e.getErrors().getMessages()); } factory = factoryRawType.cast(Proxy.newProxyInstance(BytecodeGen.getClassLoader(factoryRawType), new Class[] { factoryRawType }, this)); } public F get() { return factory; } public Set> getDependencies() { Set> combinedDeps = new HashSet>(); for(AssistData data : assistDataByMethod.values()) { combinedDeps.addAll(data.dependencies); } return ImmutableSet.copyOf(combinedDeps); } public Key getKey() { return factoryKey; } // safe cast because values are typed to AssistedData, which is an AssistedMethod @SuppressWarnings("unchecked") public Collection getAssistedMethods() { return (Collection)assistDataByMethod.values(); } @SuppressWarnings("unchecked") public V acceptExtensionVisitor(BindingTargetVisitor visitor, ProviderInstanceBinding binding) { if (visitor instanceof AssistedInjectTargetVisitor) { return ((AssistedInjectTargetVisitor)visitor).visit((AssistedInjectBinding)this); } return visitor.visit(binding); } private void validateFactoryReturnType(Errors errors, Class returnType, Class factoryType) { if (Modifier.isPublic(factoryType.getModifiers()) && !Modifier.isPublic(returnType.getModifiers())) { errors.addMessage("%s is public, but has a method that returns a non-public type: %s. " + "Due to limitations with java.lang.reflect.Proxy, this is not allowed. " + "Please either make the factory non-public or the return type public.", factoryType, returnType); } } /** * Returns true if the ConfigurationException is due to an error of TypeLiteral not being fully * specified. */ private boolean isTypeNotSpecified(TypeLiteral typeLiteral, ConfigurationException ce) { Collection messages = ce.getErrorMessages(); if (messages.size() == 1) { Message msg = Iterables.getOnlyElement( new Errors().keyNotFullySpecified(typeLiteral).getMessages()); return msg.getMessage().equals(Iterables.getOnlyElement(messages).getMessage()); } else { return false; } } /** * Finds a constructor suitable for the method. If the implementation contained any constructors * marked with {@link AssistedInject}, this requires all {@link Assisted} parameters to exactly * match the parameters (in any order) listed in the method. Otherwise, if no * {@link AssistedInject} constructors exist, this will default to looking for an * {@literal @}{@link Inject} constructor. */ private InjectionPoint findMatchingConstructorInjectionPoint( Method method, Key returnType, TypeLiteral implementation, List> paramList) throws ErrorsException { Errors errors = new Errors(method); if(returnType.getTypeLiteral().equals(implementation)) { errors = errors.withSource(implementation); } else { errors = errors.withSource(returnType).withSource(implementation); } Class rawType = implementation.getRawType(); if (Modifier.isInterface(rawType.getModifiers())) { errors.addMessage( "%s is an interface, not a concrete class. Unable to create AssistedInject factory.", implementation); throw errors.toException(); } else if (Modifier.isAbstract(rawType.getModifiers())) { errors.addMessage( "%s is abstract, not a concrete class. Unable to create AssistedInject factory.", implementation); throw errors.toException(); } else if (Classes.isInnerClass(rawType)) { errors.cannotInjectInnerClass(rawType); throw errors.toException(); } Constructor matchingConstructor = null; boolean anyAssistedInjectConstructors = false; // Look for AssistedInject constructors... for (Constructor constructor : rawType.getDeclaredConstructors()) { if (constructor.isAnnotationPresent(AssistedInject.class)) { anyAssistedInjectConstructors = true; if (constructorHasMatchingParams(implementation, constructor, paramList, errors)) { if (matchingConstructor != null) { errors .addMessage( "%s has more than one constructor annotated with @AssistedInject" + " that matches the parameters in method %s. Unable to create AssistedInject factory.", implementation, method); throw errors.toException(); } else { matchingConstructor = constructor; } } } } if(!anyAssistedInjectConstructors) { // If none existed, use @Inject. try { return InjectionPoint.forConstructorOf(implementation); } catch(ConfigurationException e) { errors.merge(e.getErrorMessages()); throw errors.toException(); } } else { // Otherwise, use it or fail with a good error message. if(matchingConstructor != null) { // safe because we got the constructor from this implementation. @SuppressWarnings("unchecked") InjectionPoint ip = InjectionPoint.forConstructor( (Constructor)matchingConstructor, implementation); return ip; } else { errors.addMessage( "%s has @AssistedInject constructors, but none of them match the" + " parameters in method %s. Unable to create AssistedInject factory.", implementation, method); throw errors.toException(); } } } /** * Matching logic for constructors annotated with AssistedInject. * This returns true if and only if all @Assisted parameters in the * constructor exactly match (in any order) all @Assisted parameters * the method's parameter. */ private boolean constructorHasMatchingParams(TypeLiteral type, Constructor constructor, List> paramList, Errors errors) throws ErrorsException { List> params = type.getParameterTypes(constructor); Annotation[][] paramAnnotations = constructor.getParameterAnnotations(); int p = 0; List> constructorKeys = Lists.newArrayList(); for (TypeLiteral param : params) { Key paramKey = Annotations.getKey(param, constructor, paramAnnotations[p++], errors); constructorKeys.add(paramKey); } // Require that every key exist in the constructor to match up exactly. for (Key key : paramList) { // If it didn't exist in the constructor set, we can't use it. if (!constructorKeys.remove(key)) { return false; } } // If any keys remain and their annotation is Assisted, we can't use it. for (Key key : constructorKeys) { if (key.getAnnotationType() == Assisted.class) { return false; } } // All @Assisted params match up to the method's parameters. return true; } /** Calculates all dependencies required by the implementation and constructor. */ private Set> getDependencies(InjectionPoint ctorPoint, TypeLiteral implementation) { ImmutableSet.Builder> builder = ImmutableSet.builder(); builder.addAll(ctorPoint.getDependencies()); if (!implementation.getRawType().isInterface()) { for (InjectionPoint ip : InjectionPoint.forInstanceMethodsAndFields(implementation)) { builder.addAll(ip.getDependencies()); } } return builder.build(); } /** Return all non-assisted dependencies. */ private Set> removeAssistedDeps(Set> deps) { ImmutableSet.Builder> builder = ImmutableSet.builder(); for(Dependency dep : deps) { Class annotationType = dep.getKey().getAnnotationType(); if (annotationType == null || !annotationType.equals(Assisted.class)) { builder.add(dep); } } return builder.build(); } /** * Returns true if all dependencies are suitable for the optimized version of AssistedInject. The * optimized version caches the binding & uses a ThreadLocal Provider, so can only be applied if * the assisted bindings are immediately provided. This looks for hints that the values may be * lazily retrieved, by looking for injections of Injector or a Provider for the assisted values. */ private boolean isValidForOptimizedAssistedInject(Set> dependencies) { for (Dependency dep : dependencies) { if (isInjectorOrAssistedProvider(dep)) { return false; } } return true; } /** * Returns true if the dependency is for {@link Injector} or if the dependency * is a {@link Provider} for a parameter that is {@literal @}{@link Assisted}. */ private boolean isInjectorOrAssistedProvider(Dependency dependency) { Class annotationType = dependency.getKey().getAnnotationType(); if (annotationType != null && annotationType.equals(Assisted.class)) { // If it's assisted.. if (dependency.getKey().getTypeLiteral().getRawType().equals(Provider.class)) { // And a Provider... return true; } } else if (dependency.getKey().getTypeLiteral().getRawType().equals(Injector.class)) { // If it's the Injector... return true; } return false; } /** * Returns a key similar to {@code key}, but with an {@literal @}Assisted binding annotation. * This fails if another binding annotation is clobbered in the process. If the key already has * the {@literal @}Assisted annotation, it is returned as-is to preserve any String value. */ private Key assistKey(Method method, Key key, Errors errors) throws ErrorsException { if (key.getAnnotationType() == null) { return Key.get(key.getTypeLiteral(), DEFAULT_ANNOTATION); } else if (key.getAnnotationType() == Assisted.class) { return key; } else { errors.withSource(method).addMessage( "Only @Assisted is allowed for factory parameters, but found @%s", key.getAnnotationType()); throw errors.toException(); } } /** * At injector-creation time, we initialize the invocation handler. At this time we make sure * all factory methods will be able to build the target types. */ @Inject @Toolable void initialize(Injector injector) { if (this.injector != null) { throw new ConfigurationException(ImmutableList.of(new Message(FactoryProvider2.class, "Factories.create() factories may only be used in one Injector!"))); } this.injector = injector; for (Map.Entry entry : assistDataByMethod.entrySet()) { Method method = entry.getKey(); AssistData data = entry.getValue(); Object[] args; if(!data.optimized) { args = new Object[method.getParameterTypes().length]; Arrays.fill(args, "dummy object for validating Factories"); } else { args = null; // won't be used -- instead will bind to data.providers. } getBindingFromNewInjector(method, args, data); // throws if the binding isn't properly configured } } /** * Creates a child injector that binds the args, and returns the binding for the method's result. */ public Binding getBindingFromNewInjector(final Method method, final Object[] args, final AssistData data) { checkState(injector != null, "Factories.create() factories cannot be used until they're initialized by Guice."); final Key returnType = data.returnType; // We ignore any pre-existing binding annotation. final Key assistedReturnType = Key.get(returnType.getTypeLiteral(), Assisted.class); Module assistedModule = new AbstractModule() { @Override @SuppressWarnings("unchecked") // raw keys are necessary for the args array and return value protected void configure() { Binder binder = binder().withSource(method); int p = 0; if(!data.optimized) { for (Key paramKey : data.paramTypes) { // Wrap in a Provider to cover null, and to prevent Guice from injecting the parameter binder.bind((Key) paramKey).toProvider(Providers.of(args[p++])); } } else { for (Key paramKey : data.paramTypes) { // Bind to our ThreadLocalProviders. binder.bind((Key) paramKey).toProvider(data.providers.get(p++)); } } Constructor constructor = data.constructor; // Constructor *should* always be non-null here, // but if it isn't, we'll end up throwing a fairly good error // message for the user. if(constructor != null) { binder.bind(assistedReturnType) .toConstructor(constructor, (TypeLiteral)data.implementationType) .in(Scopes.NO_SCOPE); // make sure we erase any scope on the implementation type } } }; Injector forCreate = injector.createChildInjector(assistedModule); Binding binding = forCreate.getBinding(assistedReturnType); // If we have providers cached in data, cache the binding for future optimizations. if(data.optimized) { data.cachedBinding = binding; } return binding; } /** * When a factory method is invoked, we create a child injector that binds all parameters, then * use that to get an instance of the return type. */ public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable { if (method.getDeclaringClass() == Object.class) { return method.invoke(this, args); } AssistData data = assistDataByMethod.get(method); Provider provider; if(data.cachedBinding != null) { // Try to get optimized form... provider = data.cachedBinding.getProvider(); } else { provider = getBindingFromNewInjector(method, args, data).getProvider(); } try { int p = 0; for(ThreadLocalProvider tlp : data.providers) { tlp.set(args[p++]); } return provider.get(); } catch (ProvisionException e) { // if this is an exception declared by the factory method, throw it as-is if (e.getErrorMessages().size() == 1) { Message onlyError = getOnlyElement(e.getErrorMessages()); Throwable cause = onlyError.getCause(); if (cause != null && canRethrow(method, cause)) { throw cause; } } throw e; } finally { for(ThreadLocalProvider tlp : data.providers) { tlp.remove(); } } } @Override public String toString() { return factory.getClass().getInterfaces()[0].getName(); } @Override public boolean equals(Object o) { return o == this || o == factory; } /** Returns true if {@code thrown} can be thrown by {@code invoked} without wrapping. */ static boolean canRethrow(Method invoked, Throwable thrown) { if (thrown instanceof Error || thrown instanceof RuntimeException) { return true; } for (Class declared : invoked.getExceptionTypes()) { if (declared.isInstance(thrown)) { return true; } } return false; } // not because we'll never know and this is easier than suppressing warnings. private static class ThreadLocalProvider extends ThreadLocal implements Provider { @Override protected Object initialValue() { throw new IllegalStateException( "Cannot use optimized @Assisted provider outside the scope of the constructor." + " (This should never happen. If it does, please report it.)"); } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryProvider.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryPr0000755000175000017500000003711611704661106032605 0ustar tonytony/** * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import static com.google.inject.internal.Annotations.getKey; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.inject.ConfigurationException; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.TypeLiteral; import com.google.inject.internal.BytecodeGen; import com.google.inject.internal.Errors; import com.google.inject.internal.ErrorsException; import com.google.inject.spi.Dependency; import com.google.inject.spi.HasDependencies; import com.google.inject.spi.Message; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.lang.reflect.Type; import java.util.List; import java.util.Map; import java.util.Set; /** * Obsolete. Prefer {@link FactoryModuleBuilder} for its more concise API and * additional capability. * *

    Provides a factory that combines the caller's arguments with injector-supplied values to * construct objects. * *

    Defining a factory

    * Create an interface whose methods return the constructed type, or any of its supertypes. The * method's parameters are the arguments required to build the constructed type. *
    public interface PaymentFactory {
     *   Payment create(Date startDate, Money amount);
     * }
    * You can name your factory methods whatever you like, such as create, createPayment * or newPayment. * *

    Creating a type that accepts factory parameters

    * {@code constructedType} is a concrete class with an {@literal @}{@link Inject}-annotated * constructor. In addition to injector-supplied parameters, the constructor should have * parameters that match each of the factory method's parameters. Each factory-supplied parameter * requires an {@literal @}{@link Assisted} annotation. This serves to document that the parameter * is not bound by your application's modules. *
    public class RealPayment implements Payment {
     *   {@literal @}Inject
     *   public RealPayment(
     *      CreditService creditService,
     *      AuthService authService,
     *      {@literal @}Assisted Date startDate,
     *      {@literal @}Assisted Money amount) {
     *     ...
     *   }
     * }
    * Any parameter that permits a null value should also be annotated {@code @Nullable}. * *

    Configuring factories

    * In your {@link com.google.inject.Module module}, bind the factory interface to the returned * factory: *
    bind(PaymentFactory.class).toProvider(
     *     FactoryProvider.newFactory(PaymentFactory.class, RealPayment.class));
    * As a side-effect of this binding, Guice will inject the factory to initialize it for use. The * factory cannot be used until the injector has been initialized. * *

    Using the factory

    * Inject your factory into your application classes. When you use the factory, your arguments * will be combined with values from the injector to construct an instance. *
    public class PaymentAction {
     *   {@literal @}Inject private PaymentFactory paymentFactory;
     *
     *   public void doPayment(Money amount) {
     *     Payment payment = paymentFactory.create(new Date(), amount);
     *     payment.apply();
     *   }
     * }
    * *

    Making parameter types distinct

    * The types of the factory method's parameters must be distinct. To use multiple parameters of * the same type, use a named {@literal @}{@link Assisted} annotation to disambiguate the * parameters. The names must be applied to the factory method's parameters: * *
    public interface PaymentFactory {
     *   Payment create(
     *       {@literal @}Assisted("startDate") Date startDate,
     *       {@literal @}Assisted("dueDate") Date dueDate,
     *       Money amount);
     * } 
    * ...and to the concrete type's constructor parameters: *
    public class RealPayment implements Payment {
     *   {@literal @}Inject
     *   public RealPayment(
     *      CreditService creditService,
     *      AuthService authService,
     *      {@literal @}Assisted("startDate") Date startDate,
     *      {@literal @}Assisted("dueDate") Date dueDate,
     *      {@literal @}Assisted Money amount) {
     *     ...
     *   }
     * }
    * *

    Values are created by Guice

    * Returned factories use child injectors to create values. The values are eligible for method * interception. In addition, {@literal @}{@literal Inject} members will be injected before they are * returned. * *

    Backwards compatibility using {@literal @}AssistedInject

    * Instead of the {@literal @}Inject annotation, you may annotate the constructed classes with * {@literal @}{@link AssistedInject}. This triggers a limited backwards-compatability mode. * *

    Instead of matching factory method arguments to constructor parameters using their names, the * parameters are matched by their order. The first factory method argument is * used for the first {@literal @}Assisted constructor parameter, etc.. Annotation names have no * effect. * *

    Returned values are not created by Guice. These types are not eligible for * method interception. They do receive post-construction member injection. * * @param The factory interface * * @author jmourits@google.com (Jerome Mourits) * @author jessewilson@google.com (Jesse Wilson) * @author dtm@google.com (Daniel Martin) * * @deprecated use {@link FactoryModuleBuilder} instead. */ @Deprecated public class FactoryProvider implements Provider, HasDependencies { /* * This class implements the old @AssistedInject implementation that manually matches constructors * to factory methods. The new child injector implementation lives in FactoryProvider2. */ private Injector injector; private final TypeLiteral factoryType; private final Map> factoryMethodToConstructor; public static Provider newFactory(Class factoryType, Class implementationType){ return newFactory(TypeLiteral.get(factoryType), TypeLiteral.get(implementationType)); } public static Provider newFactory( TypeLiteral factoryType, TypeLiteral implementationType) { Map> factoryMethodToConstructor = createMethodMapping(factoryType, implementationType); if (!factoryMethodToConstructor.isEmpty()) { return new FactoryProvider(factoryType, factoryMethodToConstructor); } else { BindingCollector collector = new BindingCollector(); // Preserving backwards-compatibility: Map all return types in a factory // interface to the passed implementation type. Errors errors = new Errors(); Key implementationKey = Key.get(implementationType); if (implementationType != null) { try { for (Method method : factoryType.getRawType().getMethods()) { Key returnType = getKey(factoryType.getReturnType(method), method, method.getAnnotations(), errors); if (!implementationKey.equals(returnType)) { collector.addBinding(returnType, implementationType); } } } catch (ErrorsException e) { throw new ConfigurationException(e.getErrors().getMessages()); } } return new FactoryProvider2(Key.get(factoryType), collector); } } private FactoryProvider(TypeLiteral factoryType, Map> factoryMethodToConstructor) { this.factoryType = factoryType; this.factoryMethodToConstructor = factoryMethodToConstructor; checkDeclaredExceptionsMatch(); } @Inject void setInjectorAndCheckUnboundParametersAreInjectable(Injector injector) { this.injector = injector; for (AssistedConstructor c : factoryMethodToConstructor.values()) { for (Parameter p : c.getAllParameters()) { if(!p.isProvidedByFactory() && !paramCanBeInjected(p, injector)) { // this is lame - we're not using the proper mechanism to add an // error to the injector. Throughout this class we throw exceptions // to add errors, which isn't really the best way in Guice throw newConfigurationException("Parameter of type '%s' is not injectable or annotated " + "with @Assisted for Constructor '%s'", p, c); } } } } private void checkDeclaredExceptionsMatch() { for (Map.Entry> entry : factoryMethodToConstructor.entrySet()) { for (Class constructorException : entry.getValue().getDeclaredExceptions()) { if (!isConstructorExceptionCompatibleWithFactoryExeception( constructorException, entry.getKey().getExceptionTypes())) { throw newConfigurationException("Constructor %s declares an exception, but no compatible " + "exception is thrown by the factory method %s", entry.getValue(), entry.getKey()); } } } } private boolean isConstructorExceptionCompatibleWithFactoryExeception( Class constructorException, Class[] factoryExceptions) { for (Class factoryException : factoryExceptions) { if (factoryException.isAssignableFrom(constructorException)) { return true; } } return false; } private boolean paramCanBeInjected(Parameter parameter, Injector injector) { return parameter.isBound(injector); } private static Map> createMethodMapping( TypeLiteral factoryType, TypeLiteral implementationType) { List> constructors = Lists.newArrayList(); for (Constructor constructor : implementationType.getRawType().getDeclaredConstructors()) { if (constructor.getAnnotation(AssistedInject.class) != null) { @SuppressWarnings("unchecked") // the constructor type and implementation type agree AssistedConstructor assistedConstructor = new AssistedConstructor( constructor, implementationType.getParameterTypes(constructor)); constructors.add(assistedConstructor); } } if (constructors.isEmpty()) { return ImmutableMap.of(); } Method[] factoryMethods = factoryType.getRawType().getMethods(); if (constructors.size() != factoryMethods.length) { throw newConfigurationException("Constructor mismatch: %s has %s @AssistedInject " + "constructors, factory %s has %s creation methods", implementationType, constructors.size(), factoryType, factoryMethods.length); } Map paramsToConstructor = Maps.newHashMap(); for (AssistedConstructor c : constructors) { if (paramsToConstructor.containsKey(c.getAssistedParameters())) { throw new RuntimeException("Duplicate constructor, " + c); } paramsToConstructor.put(c.getAssistedParameters(), c); } Map> result = Maps.newHashMap(); for (Method method : factoryMethods) { if (!method.getReturnType().isAssignableFrom(implementationType.getRawType())) { throw newConfigurationException("Return type of method %s is not assignable from %s", method, implementationType); } List parameterTypes = Lists.newArrayList(); for (TypeLiteral parameterType : factoryType.getParameterTypes(method)) { parameterTypes.add(parameterType.getType()); } ParameterListKey methodParams = new ParameterListKey(parameterTypes); if (!paramsToConstructor.containsKey(methodParams)) { throw newConfigurationException("%s has no @AssistInject constructor that takes the " + "@Assisted parameters %s in that order. @AssistInject constructors are %s", implementationType, methodParams, paramsToConstructor.values()); } method.getParameterAnnotations(); for (Annotation[] parameterAnnotations : method.getParameterAnnotations()) { for (Annotation parameterAnnotation : parameterAnnotations) { if (parameterAnnotation.annotationType() == Assisted.class) { throw newConfigurationException("Factory method %s has an @Assisted parameter, which " + "is incompatible with the deprecated @AssistedInject annotation. Please replace " + "@AssistedInject with @Inject on the %s constructor.", method, implementationType); } } } AssistedConstructor matchingConstructor = paramsToConstructor.remove(methodParams); result.put(method, matchingConstructor); } return result; } public Set> getDependencies() { List> dependencies = Lists.newArrayList(); for (AssistedConstructor constructor : factoryMethodToConstructor.values()) { for (Parameter parameter : constructor.getAllParameters()) { if (!parameter.isProvidedByFactory()) { dependencies.add(Dependency.get(parameter.getPrimaryBindingKey())); } } } return ImmutableSet.copyOf(dependencies); } public F get() { InvocationHandler invocationHandler = new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] creationArgs) throws Throwable { // pass methods from Object.class to the proxy if (method.getDeclaringClass().equals(Object.class)) { return method.invoke(this, creationArgs); } AssistedConstructor constructor = factoryMethodToConstructor.get(method); Object[] constructorArgs = gatherArgsForConstructor(constructor, creationArgs); Object objectToReturn = constructor.newInstance(constructorArgs); injector.injectMembers(objectToReturn); return objectToReturn; } public Object[] gatherArgsForConstructor( AssistedConstructor constructor, Object[] factoryArgs) { int numParams = constructor.getAllParameters().size(); int argPosition = 0; Object[] result = new Object[numParams]; for (int i = 0; i < numParams; i++) { Parameter parameter = constructor.getAllParameters().get(i); if (parameter.isProvidedByFactory()) { result[i] = factoryArgs[argPosition]; argPosition++; } else { result[i] = parameter.getValue(injector); } } return result; } }; @SuppressWarnings("unchecked") // we imprecisely treat the class literal of T as a Class Class factoryRawType = (Class) factoryType.getRawType(); return factoryRawType.cast(Proxy.newProxyInstance(BytecodeGen.getClassLoader(factoryRawType), new Class[] { factoryRawType }, invocationHandler)); } private static ConfigurationException newConfigurationException(String format, Object... args) { return new ConfigurationException(ImmutableSet.of(new Message(Errors.format(format, args)))); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryModuleBuilder.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryMo0000644000175000017500000003011411704661106032563 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import com.google.inject.AbstractModule; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provider; import com.google.inject.TypeLiteral; import java.lang.annotation.Annotation; /** * Provides a factory that combines the caller's arguments with injector-supplied values to * construct objects. * *

    Defining a factory

    * Create an interface whose methods return the constructed type, or any of its supertypes. The * method's parameters are the arguments required to build the constructed type. * *
    public interface PaymentFactory {
     *   Payment create(Date startDate, Money amount);
     * }
    * * You can name your factory methods whatever you like, such as create, createPayment * or newPayment. * *

    Creating a type that accepts factory parameters

    * {@code constructedType} is a concrete class with an {@literal @}{@link com.google.inject.Inject * Inject}-annotated constructor. In addition to injector-supplied parameters, the constructor * should have parameters that match each of the factory method's parameters. Each factory-supplied * parameter requires an {@literal @}{@link Assisted} annotation. This serves to document that the * parameter is not bound by your application's modules. * *
    public class RealPayment implements Payment {
     *   {@literal @}Inject
     *   public RealPayment(
     *      CreditService creditService,
     *      AuthService authService,
     *      {@literal @}Assisted Date startDate,
     *      {@literal @}Assisted Money amount) {
     *     ...
     *   }
     * }
    * *

    Multiple factory methods for the same type

    * If the factory contains many methods that return the same type, you can create multiple * constructors in your concrete class, each constructor marked with with * {@literal @}{@link AssistedInject}, in order to match the different parameters types of the * factory methods. * *
    public interface PaymentFactory {
     *    Payment create(Date startDate, Money amount);
     *    Payment createWithoutDate(Money amount);
     * }
     * 
     * public class RealPayment implements Payment {
     *  {@literal @}AssistedInject
     *   public RealPayment(
     *      CreditService creditService,
     *      AuthService authService,
     *     {@literal @}Assisted Date startDate,
     *     {@literal @}Assisted Money amount) {
     *     ...
     *   }
     *   
     *  {@literal @}AssistedInject
     *   public RealPayment(
     *      CreditService creditService,
     *      AuthService authService,
     *     {@literal @}Assisted Money amount) {
     *     ...
     *   }   
     * }
    * *

    Configuring simple factories

    * In your {@link Module module}, install a {@code FactoryModuleBuilder} that creates the * factory: * *
    install(new FactoryModuleBuilder()
     *     .implement(Payment.class, RealPayment.class)
     *     .build(PaymentFactory.class);
    * * As a side-effect of this binding, Guice will inject the factory to initialize it for use. The * factory cannot be used until the injector has been initialized. * *

    Configuring complex factories

    * Factories can create an arbitrary number of objects, one per each method. Each factory * method can be configured using .implement. * *
    public interface OrderFactory {
     *    Payment create(Date startDate, Money amount);
     *    Shipment create(Customer customer, Item item);
     *    Receipt create(Payment payment, Shipment shipment);
     * }
     * 
     * [...]
     * 
     * install(new FactoryModuleBuilder()
     *     .implement(Payment.class, RealPayment.class)
     *     // excluding .implement for Shipment means the implementation class
     *     // will be 'Shipment' itself, which is legal if it's not an interface.
     *     .implement(Receipt.class, RealReceipt.class)
     *     .build(OrderFactory.class);
    * * *

    Using the factory

    * Inject your factory into your application classes. When you use the factory, your arguments * will be combined with values from the injector to construct an instance. * *
    public class PaymentAction {
     *   {@literal @}Inject private PaymentFactory paymentFactory;
     *
     *   public void doPayment(Money amount) {
     *     Payment payment = paymentFactory.create(new Date(), amount);
     *     payment.apply();
     *   }
     * }
    * *

    Making parameter types distinct

    * The types of the factory method's parameters must be distinct. To use multiple parameters of * the same type, use a named {@literal @}{@link Assisted} annotation to disambiguate the * parameters. The names must be applied to the factory method's parameters: * *
    public interface PaymentFactory {
     *   Payment create(
     *       {@literal @}Assisted("startDate") Date startDate,
     *       {@literal @}Assisted("dueDate") Date dueDate,
     *       Money amount);
     * } 
    * * ...and to the concrete type's constructor parameters: * *
    public class RealPayment implements Payment {
     *   {@literal @}Inject
     *   public RealPayment(
     *      CreditService creditService,
     *      AuthService authService,
     *      {@literal @}Assisted("startDate") Date startDate,
     *      {@literal @}Assisted("dueDate") Date dueDate,
     *      {@literal @}Assisted Money amount) {
     *     ...
     *   }
     * }
    * *

    Values are created by Guice

    * Returned factories use child injectors to create values. The values are eligible for method * interception. In addition, {@literal @}{@literal Inject} members will be injected before they are * returned. * *

    More configuration options

    * In addition to simply specifying an implementation class for any returned type, factories' return * values can be automatic or can be configured to use annotations: *

    * If you just want to return the types specified in the factory, do not configure any * implementations: * *

    public interface FruitFactory {
     *   Apple getApple(Color color);
     * }
     * ...
     * protected void configure() {
     *   install(new FactoryModuleBuilder().build(FruitFactory.class));
     * }
    * * Note that any type returned by the factory in this manner needs to be an implementation class. *

    * To return two different implementations for the same interface from your factory, use binding * annotations on your return types: * *

    interface CarFactory {
     *   {@literal @}Named("fast") Car getFastCar(Color color);
     *   {@literal @}Named("clean") Car getCleanCar(Color color);
     * }
     * ...
     * protected void configure() {
     *   install(new FactoryModuleBuilder()
     *       .implement(Car.class, Names.named("fast"), Porsche.class)
     *       .implement(Car.class, Names.named("clean"), Prius.class)
     *       .build(CarFactory.class));
     * }
    * *

    Implementation limitations

    * As a limitation of the implementation, it is prohibited to declare a factory method that * accepts a {@code Provider} as one of its arguments. * * @since 3.0 * @author schmitt@google.com (Peter Schmitt) */ public final class FactoryModuleBuilder { private final BindingCollector bindings = new BindingCollector(); /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public FactoryModuleBuilder implement(Class source, Class target) { return implement(source, TypeLiteral.get(target)); } /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public FactoryModuleBuilder implement(Class source, TypeLiteral target) { return implement(TypeLiteral.get(source), target); } /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public FactoryModuleBuilder implement(TypeLiteral source, Class target) { return implement(source, TypeLiteral.get(target)); } /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public FactoryModuleBuilder implement(TypeLiteral source, TypeLiteral target) { return implement(Key.get(source), target); } /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public FactoryModuleBuilder implement(Class source, Annotation annotation, Class target) { return implement(source, annotation, TypeLiteral.get(target)); } /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public FactoryModuleBuilder implement(Class source, Annotation annotation, TypeLiteral target) { return implement(TypeLiteral.get(source), annotation, target); } /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public FactoryModuleBuilder implement(TypeLiteral source, Annotation annotation, Class target) { return implement(source, annotation, TypeLiteral.get(target)); } /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public FactoryModuleBuilder implement(TypeLiteral source, Annotation annotation, TypeLiteral target) { return implement(Key.get(source, annotation), target); } /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public FactoryModuleBuilder implement(Class source, Class annotationType, Class target) { return implement(source, annotationType, TypeLiteral.get(target)); } /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public FactoryModuleBuilder implement(Class source, Class annotationType, TypeLiteral target) { return implement(TypeLiteral.get(source), annotationType, target); } /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public FactoryModuleBuilder implement(TypeLiteral source, Class annotationType, Class target) { return implement(source, annotationType, TypeLiteral.get(target)); } /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public FactoryModuleBuilder implement(TypeLiteral source, Class annotationType, TypeLiteral target) { return implement(Key.get(source, annotationType), target); } /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public FactoryModuleBuilder implement(Key source, Class target) { return implement(source, TypeLiteral.get(target)); } /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public FactoryModuleBuilder implement(Key source, TypeLiteral target) { bindings.addBinding(source, target); return this; } /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public Module build(Class factoryInterface) { return build(TypeLiteral.get(factoryInterface)); } /** * See the factory configuration examples at {@link FactoryModuleBuilder}. */ public Module build(TypeLiteral factoryInterface) { return build(Key.get(factoryInterface)); } public Module build(final Key factoryInterface) { return new AbstractModule() { @Override protected void configure() { Provider provider = new FactoryProvider2(factoryInterface, bindings); bind(factoryInterface).toProvider(provider); } }; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/BindingCollector.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/BindingCo0000644000175000017500000000310611704661106032515 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import com.google.inject.ConfigurationException; import com.google.inject.Key; import com.google.inject.TypeLiteral; import com.google.inject.spi.Message; import java.util.Collections; import java.util.Map; /** * Utility class for collecting factory bindings. Used for configuring {@link FactoryProvider2}. * * @author schmitt@google.com (Peter Schmitt) */ class BindingCollector { private final Map, TypeLiteral> bindings = Maps.newHashMap(); public BindingCollector addBinding(Key key, TypeLiteral target) { if (bindings.containsKey(key)) { throw new ConfigurationException(ImmutableSet.of( new Message("Only one implementation can be specified for " + key))); } bindings.put(key, target); return this; } public Map, TypeLiteral> getBindings() { return Collections.unmodifiableMap(bindings); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/AssistedMethod.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/AssistedM0000644000175000017500000000304411704661106032556 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import com.google.inject.TypeLiteral; import com.google.inject.spi.Dependency; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.Set; /** * Details about how a method in an assisted inject factory will be assisted. * * @since 3.0 * @author ramakrishna@google.com (Ramakrishna Rajanna) */ public interface AssistedMethod { /** * Returns the factory method that is being assisted. */ Method getFactoryMethod(); /** * Returns the implementation type that will be created when the method is * used. */ TypeLiteral getImplementationType(); /** * Returns the constructor that will be used to construct instances of the * implementation. */ Constructor getImplementationConstructor(); /** * Returns all non-assisted dependencies required to construct and inject * the implementation. */ Set> getDependencies(); } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/AssistedInjectTargetVisitor.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/AssistedI0000644000175000017500000000235111704661106032552 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import com.google.inject.spi.BindingTargetVisitor; /** * A visitor for the AssistedInject extension. *

    * If your {@link BindingTargetVisitor} implements this interface, bindings created by using * {@link FactoryModuleBuilder} will be visited through this interface. * * @since 3.0 * @author ramakrishna@google.com (Ramakrishna Rajanna) */ public interface AssistedInjectTargetVisitor extends BindingTargetVisitor { /** * Visits an {@link AssistedInjectBinding} created through {@link FactoryModuleBuilder}. */ V visit(AssistedInjectBinding assistedInjectBinding); } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/AssistedInjectBinding.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/AssistedI0000644000175000017500000000220411704661106032547 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import com.google.inject.Key; import java.util.Collection; /** * A binding for a factory created by FactoryModuleBuilder. * * @param The fully qualified type of the factory. * * @since 3.0 * @author ramakrishna@google.com (Ramakrishna Rajanna) */ public interface AssistedInjectBinding { /** Returns the {@link Key} for the factory binding. */ Key getKey(); /** Returns an {@link AssistedMethod} for each method in the factory. */ Collection getAssistedMethods(); } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/AssistedInject.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/AssistedI0000755000175000017500000000443211704661106032557 0ustar tonytony/** * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import static java.lang.annotation.ElementType.CONSTRUCTOR; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.Inject; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** *

    * When used in tandem with {@link FactoryModuleBuilder}, constructors annotated with * {@code @AssistedInject} indicate that multiple constructors can be injected, each with different * parameters. AssistedInject annotations should not be mixed with {@literal @}{@link Inject} * annotations. The assisted parameters must exactly match one corresponding factory method within * the factory interface, but the parameters do not need to be in the same order. Constructors * annotated with AssistedInject are created by Guice and receive all the benefits * (such as AOP). * *

    * Obsolete Usage: When used in tandem with {@link FactoryProvider}, constructors * annotated with {@code @AssistedInject} trigger a "backwards compatibility mode". The assisted * parameters must exactly match one corresponding factory method within the factory interface and * all must be in the same order as listed in the factory. In this backwards compatable mode, * constructors annotated with AssistedInject are not created by Guice and thus receive * none of the benefits. * *

    * Constructor parameters must be either supplied by the factory interface and marked with * @Assisted, or they must be injectable. * * @author jmourits@google.com (Jerome Mourits) * @author jessewilson@google.com (Jesse Wilson) */ @Target( { CONSTRUCTOR }) @Retention(RUNTIME) public @interface AssistedInject { } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/AssistedConstructor.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/AssistedC0000755000175000017500000000617411704661106032556 0ustar tonytony/** * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import com.google.common.collect.Lists; import com.google.inject.Inject; import com.google.inject.TypeLiteral; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; /** * Internal respresentation of a constructor annotated with * {@link AssistedInject} * * @author jmourits@google.com (Jerome Mourits) * @author jessewilson@google.com (Jesse Wilson) */ class AssistedConstructor { private final Constructor constructor; private final ParameterListKey assistedParameters; private final List allParameters; @SuppressWarnings("unchecked") public AssistedConstructor(Constructor constructor, List> parameterTypes) { this.constructor = constructor; Annotation[][] annotations = constructor.getParameterAnnotations(); List typeList = Lists.newArrayList(); allParameters = new ArrayList(); // categorize params as @Assisted or @Injected for (int i = 0; i < parameterTypes.size(); i++) { Parameter parameter = new Parameter(parameterTypes.get(i).getType(), annotations[i]); allParameters.add(parameter); if (parameter.isProvidedByFactory()) { typeList.add(parameter.getType()); } } this.assistedParameters = new ParameterListKey(typeList); } /** * Returns the {@link ParameterListKey} for this constructor. The * {@link ParameterListKey} is created from the ordered list of {@link Assisted} * constructor parameters. */ public ParameterListKey getAssistedParameters() { return assistedParameters; } /** * Returns an ordered list of all constructor parameters (both * {@link Assisted} and {@link Inject}ed). */ public List getAllParameters() { return allParameters; } public Set> getDeclaredExceptions() { return new HashSet>(Arrays.asList(constructor.getExceptionTypes())); } /** * Returns an instance of T, constructed using this constructor, with the * supplied arguments. */ public T newInstance(Object[] args) throws Throwable { constructor.setAccessible(true); try { return constructor.newInstance(args); } catch (InvocationTargetException e) { throw e.getCause(); } } @Override public String toString() { return constructor.toString(); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootsisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/Assisted.javasisu-guice-sisu-guice-3.1.1/extensions/assistedinject/src/com/google/inject/assistedinject/Assisted.0000755000175000017500000000300711704661106032521 0ustar tonytony/** * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.assistedinject; import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.PARAMETER; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.BindingAnnotation; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * Annotates an injected parameter or field whose value comes from an argument to a factory method. * * @author jmourits@google.com (Jerome Mourits) * @author jessewilson@google.com (Jesse Wilson) */ @BindingAnnotation @Target({ FIELD, PARAMETER, METHOD }) @Retention(RUNTIME) public @interface Assisted { /** * The unique name for this parameter. This is matched to the {@literal @Assisted} constructor * parameter with the same value. Names are not necessary when the parameter types are distinct. */ String value() default ""; }sisu-guice-sisu-guice-3.1.1/extensions/assistedinject/pom.xml0000644000175000017500000000104011704661106023135 0ustar tonytony 4.0.0 org.sonatype.sisu.inject guice-extensions 3.1.1 guice-assistedinject Sisu Guice - Extensions - AssistedInject sisu-guice-sisu-guice-3.1.1/extensions/assistedinject/build.xml0000644000175000017500000000126011704661106023445 0ustar tonytony sisu-guice-sisu-guice-3.1.1/extensions/assistedinject/build.properties0000644000175000017500000000026211704661106025042 0ustar tonytonylib.dir=../../lib src.dir=src test.dir=test build.dir=build test.class=com.google.inject.assistedinject.FactoryProviderTest module=com.google.inject.assistedinject fragment=true sisu-guice-sisu-guice-3.1.1/extensions/assistedinject/assistedinject.iml0000644000175000017500000000147011704661106025346 0ustar tonytony sisu-guice-sisu-guice-3.1.1/examples/0000755000175000017500000000000011704661106016230 5ustar tonytonysisu-guice-sisu-guice-3.1.1/examples/src/0000755000175000017500000000000011704661106017017 5ustar tonytonysisu-guice-sisu-guice-3.1.1/examples/src/example/0000755000175000017500000000000011704661106020452 5ustar tonytonysisu-guice-sisu-guice-3.1.1/examples/src/example/xml/0000755000175000017500000000000011704661106021252 5ustar tonytonysisu-guice-sisu-guice-3.1.1/examples/src/example/xml/phone.xml0000644000175000017500000000013411704661106023103 0ustar tonytony sisu-guice-sisu-guice-3.1.1/examples/src/example/xml/XmlBeanModule.java0000644000175000017500000001275411704661106024622 0ustar tonytonypackage example.xml; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provider; import com.google.inject.Binder; import java.io.InputStreamReader; import java.io.Reader; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.net.URL; import java.util.ArrayList; import java.util.List; import org.xml.sax.Attributes; import org.xml.sax.Locator; import safesax.Element; import safesax.ElementListener; import safesax.Parsers; import safesax.RootElement; import safesax.StartElementListener; public class XmlBeanModule implements Module { final URL xmlUrl; Locator locator; Binder originalBinder; BeanBuilder beanBuilder; public XmlBeanModule(URL xmlUrl) { this.xmlUrl = xmlUrl; } public void configure(Binder binder) { this.originalBinder = binder; try { RootElement beans = new RootElement("beans"); locator = beans.getLocator(); Element bean = beans.getChild("bean"); bean.setElementListener(new BeanListener()); Element property = bean.getChild("property"); property.setStartElementListener(new PropertyListener()); Reader in = new InputStreamReader(xmlUrl.openStream()); Parsers.parse(in, beans.getContentHandler()); } catch (Exception e) { originalBinder.addError(e); } } /** Handles "binding" elements. */ class BeanListener implements ElementListener { public void start(final Attributes attributes) { Binder sourced = originalBinder.withSource(xmlSource()); String typeString = attributes.getValue("type"); // Make sure 'type' is present. if (typeString == null) { sourced.addError("Missing 'type' attribute."); return; } // Resolve 'type'. Class type; try { type = Class.forName(typeString); } catch (ClassNotFoundException e) { sourced.addError(e); return; } // Look for a no-arg constructor. try { type.getConstructor(); } catch (NoSuchMethodException e) { sourced.addError("%s doesn't have a no-arg constructor."); return; } // Create a bean builder for the given type. beanBuilder = new BeanBuilder(type); } public void end() { if (beanBuilder != null) { beanBuilder.build(); beanBuilder = null; } } } /** Handles "property" elements. */ class PropertyListener implements StartElementListener { public void start(final Attributes attributes) { Binder sourced = originalBinder.withSource(xmlSource()); if (beanBuilder == null) { // We must have already run into an error. return; } // Check for 'name'. String name = attributes.getValue("name"); if (name == null) { sourced.addError("Missing attribute name."); return; } Class type = beanBuilder.type; // Find setter method for the given property name. String setterName = "set" + capitalize(name); Method setter = null; for (Method method : type.getMethods()) { if (method.getName().equals(setterName)) { setter = method; break; } } if (setter == null) { sourced.addError("%s.%s() not found.", type.getName(), setterName); return; } // Validate number of parameters. Type[] parameterTypes = setter.getGenericParameterTypes(); if (parameterTypes.length != 1) { sourced.addError("%s.%s() must take one argument.", setterName, type.getName()); return; } // Add property descriptor to builder. Provider provider = sourced.getProvider(Key.get(parameterTypes[0])); beanBuilder.properties.add( new Property(setter, provider)); } } static String capitalize(String s) { return Character.toUpperCase(s.charAt(0)) + s.substring(1); } static class Property { final Method setter; final Provider provider; Property(Method setter, Provider provider) { this.setter = setter; this.provider = provider; } void setOn(Object o) { try { setter.invoke(o, provider.get()); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } } } class BeanBuilder { final List properties = new ArrayList(); final Class type; BeanBuilder(Class type) { this.type = type; } void build() { addBinding(type); } void addBinding(Class type) { originalBinder.withSource(xmlSource()) .bind(type).toProvider(new BeanProvider(type, properties)); } } static class BeanProvider implements Provider { final Class type; final List properties; BeanProvider(Class type, List properties) { this.type = type; this.properties = properties; } public T get() { try { T t = type.newInstance(); for (Property property : properties) { property.setOn(t); } return t; } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } } Object xmlSource() { return xmlUrl + ":" + locator.getLineNumber(); } } sisu-guice-sisu-guice-3.1.1/examples/src/example/xml/SimCard.java0000644000175000017500000000027711704661106023445 0ustar tonytonypackage example.xml; import java.util.Collections; public class SimCard implements Contacts { public Iterable findByName(String name) { return Collections.emptyList(); } }sisu-guice-sisu-guice-3.1.1/examples/src/example/xml/Phone.java0000644000175000017500000000032111704661106023162 0ustar tonytonypackage example.xml; public class Phone { Contacts contacts; public void setContacts(Contacts contacts) { this.contacts = contacts; } public Contacts getContacts() { return contacts; } } sisu-guice-sisu-guice-3.1.1/examples/src/example/xml/Main.java0000644000175000017500000000241411704661106023002 0ustar tonytony/** * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package example.xml; import com.google.inject.Guice; import com.google.inject.AbstractModule; import com.google.inject.Injector; import java.net.URL; /** * * */ public class Main { public static void main(String[] args) { final URL xmlUrl = Main.class.getResource("phone.xml"); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Contacts.class).to(SimCard.class); install(new XmlBeanModule(xmlUrl)); } }); Phone phone = injector.getInstance(Phone.class); if (phone.getContacts() == null) { throw new AssertionError(); } else { System.out.println("It worked!"); } } } sisu-guice-sisu-guice-3.1.1/examples/src/example/xml/FromSim.java0000644000175000017500000000024511704661106023472 0ustar tonytonypackage example.xml; import java.lang.annotation.Retention; import static java.lang.annotation.RetentionPolicy.*; @Retention(RUNTIME) public @interface FromSim {} sisu-guice-sisu-guice-3.1.1/examples/src/example/xml/FromFlash.java0000644000175000017500000000024611704661106024000 0ustar tonytonypackage example.xml; import java.lang.annotation.Retention; import static java.lang.annotation.RetentionPolicy.*; @Retention(RUNTIME) public @interface FromFlash {}sisu-guice-sisu-guice-3.1.1/examples/src/example/xml/FlashMemory.java0000644000175000017500000000030411704661106024340 0ustar tonytonypackage example.xml; import java.util.Collections; public class FlashMemory implements Contacts { public Iterable findByName(String name) { return Collections.emptyList(); } } sisu-guice-sisu-guice-3.1.1/examples/src/example/xml/Contacts.java0000644000175000017500000000014111704661106023667 0ustar tonytonypackage example.xml; public interface Contacts { Iterable findByName(String name); } sisu-guice-sisu-guice-3.1.1/examples/src/example/xml/Contact.java0000644000175000017500000000006011704661106023504 0ustar tonytonypackage example.xml; public class Contact { } sisu-guice-sisu-guice-3.1.1/examples/examples.iml0000644000175000017500000000134111704661106020550 0ustar tonytony sisu-guice-sisu-guice-3.1.1/core/0000755000175000017500000000000011704661106015342 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/test/0000755000175000017500000000000011704661106016321 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/test/com/0000755000175000017500000000000011704661106017077 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/test/com/googlecode/0000755000175000017500000000000011704661106021206 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/test/com/googlecode/guice/0000755000175000017500000000000011704661106022302 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/test/com/googlecode/guice/bundle/0000755000175000017500000000000011704661106023553 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/test/com/googlecode/guice/bundle/OSGiTestActivator.java0000644000175000017500000002313011704661106027733 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.guice.bundle; import static com.google.inject.name.Names.named; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.matcher.AbstractMatcher; import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.Random; /** * Test Guice from inside an OSGi bundle activator. * * @author mcculls@gmail.com (Stuart McCulloch) */ @SuppressWarnings("unused") public class OSGiTestActivator implements BundleActivator { // varying visibilities to test our code-generation support public static class _ {} public interface A {} protected interface B {} interface C {} private interface D {} public static class AA implements A { public AA() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } protected static class AB implements A { public AB() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } static class AC implements A { public AC() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } private static class AD implements A { public AD() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } public static class BA implements B { protected BA() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } protected static class BB implements B { protected BB() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } static class BC implements B { protected BC() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } private static class BD implements B { protected BD() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } public static class CA implements C { CA() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } protected static class CB implements C { CB() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } static class CC implements C { CC() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } private static class CD implements C { CD() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } public static class DA implements D { @Inject private DA() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } protected static class DB implements D { @Inject private DB() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } static class DC implements D { @Inject private DC() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } private static class DD implements D { private DD() {} @Inject public void setA(_ _) {} @Inject protected void setB(_ _) {} @Inject void setC(_ _) {} @Inject private void setD(_ _) {} @Inject public _ a; @Inject protected _ b; @Inject _ c; @Inject private _ d; } enum Visibility { PUBLIC, PROTECTED, PACKAGE_PRIVATE, PRIVATE } static final Class[] TEST_CLAZZES = {A.class, B.class, C.class, D.class}; // registers all the class combinations static class TestModule extends AbstractModule { final Bundle bundle; TestModule(Bundle bundle) { this.bundle = bundle; } @Override @SuppressWarnings("unchecked") protected void configure() { for (Class api : TEST_CLAZZES) { for (Visibility visibility : Visibility.values()) { try { // this registers: A + PUBLIC -> AA, A + PROTECTED -> AB, etc... String suffix = TEST_CLAZZES[visibility.ordinal()].getSimpleName(); Class imp = bundle.loadClass(api.getName() + suffix); bind(api).annotatedWith(named(visibility.name())).to(imp); } catch (ClassNotFoundException e) { throw new RuntimeException("Unable to load test class", e); } } } } } /*if[AOP]*/ // applies method-interception to classes with enough visibility static class InterceptorModule extends AbstractModule { @Override protected void configure() { bindInterceptor(new AbstractMatcher>() { public boolean matches(Class clazz) { try { // the class and constructor must be visible int clazzModifiers = clazz.getModifiers(); int ctorModifiers = clazz.getConstructor().getModifiers(); return (clazzModifiers & (Modifier.PUBLIC | Modifier.PROTECTED)) != 0 && (ctorModifiers & (Modifier.PUBLIC | Modifier.PROTECTED)) != 0; } catch (NoSuchMethodException e) { return false; } } }, new AbstractMatcher() { public boolean matches(Method method) { // the intercepted method must also be visible int methodModifiers = method.getModifiers(); return (methodModifiers & (Modifier.PUBLIC | Modifier.PROTECTED)) != 0; } }, new org.aopalliance.intercept.MethodInterceptor() { public Object invoke(org.aopalliance.intercept.MethodInvocation mi) throws Throwable { return mi.proceed(); } }); } } /*end[AOP]*/ // called from OSGi when bundle starts public void start(BundleContext context) throws BundleException { final Bundle bundle = context.getBundle(); Injector injector = Guice.createInjector(new TestModule(bundle)); /*if[AOP]*/ Injector aopInjector = Guice.createInjector(new TestModule(bundle), new InterceptorModule()); /*end[AOP]*/ // test code-generation support for (Class api : TEST_CLAZZES) { for (Visibility vis : Visibility.values()) { injector.getInstance(Key.get(api, named(vis.name()))); /*if[AOP]*/ aopInjector.getInstance(Key.get(api, named(vis.name()))); /*end[AOP]*/ } } // test injection of system class (issue 343) injector.getInstance(Random.class); /*if[AOP]*/ aopInjector.getInstance(Random.class); /*end[AOP]*/ } // called from OSGi when bundle stops public void stop(BundleContext context) {} } sisu-guice-sisu-guice-3.1.1/core/test/com/googlecode/guice/PackageVisibilityTestModule.java0000644000175000017500000000116111704661106030555 0ustar tonytonypackage com.googlecode.guice; import com.google.inject.AbstractModule; import com.google.inject.Inject; public class PackageVisibilityTestModule extends AbstractModule { @Override protected void configure() { bind(PackagePrivateInterface.class).to(PackagePrivateImpl.class); } public static class PublicUserOfPackagePrivate { @Inject public PublicUserOfPackagePrivate(PackagePrivateInterface ppi) {} @Inject public void acceptPackagePrivateParameter(PackagePrivateInterface ppi) {} } interface PackagePrivateInterface {} static class PackagePrivateImpl implements PackagePrivateInterface {} } sisu-guice-sisu-guice-3.1.1/core/test/com/googlecode/guice/OSGiContainerTest.java0000644000175000017500000001311411704661106026451 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.guice; import aQute.bnd.main.bnd; import com.googlecode.guice.bundle.OSGiTestActivator; import junit.framework.TestCase; import org.osgi.framework.BundleContext; import org.osgi.framework.launch.Framework; import org.osgi.framework.launch.FrameworkFactory; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.Iterator; import java.util.Map; import java.util.Properties; import javax.imageio.spi.ServiceRegistry; /** * Run various tests inside one or more OSGi containers. * * @author mcculls@gmail.com (Stuart McCulloch) */ public class OSGiContainerTest extends TestCase { // build properties passed from Ant static final String VERSION = System.getProperty("version", "snapshot"); static final String BUILD_DIR = System.getProperty("build.dir", "build"); static final String BUILD_DIST_DIR = BUILD_DIR + "/dist"; static final String BUILD_TEST_DIR = BUILD_DIR + "/test"; static final String GUICE_JAR = BUILD_DIST_DIR + "/guice-" + VERSION + ".jar"; /*if[AOP]*/ static final String AOPALLIANCE_JAR = System.getProperty("aopalliance.jar", "lib/aopalliance.jar"); /*end[AOP]*/ static final String JAVAX_INJECT_JAR = System.getProperty("javax.inject.jar", "lib/javax.inject.jar"); // dynamically build test bundles @Override protected void setUp() throws Exception { // verify properties assertTrue(failMsg(), new File(BUILD_DIR).isDirectory()); assertTrue(failMsg(), new File(GUICE_JAR).isFile()); /*if[AOP]*/ assertTrue(failMsg(), new File(AOPALLIANCE_JAR).isFile()); /*end[AOP]*/ assertTrue(failMsg(), new File(JAVAX_INJECT_JAR).isFile()); Properties instructions = new Properties(); /*if[AOP]*/ // aopalliance is an API bundle --> export the full API instructions.setProperty("Export-Package", "org.aopalliance.*"); buildBundle("aopalliance", instructions, AOPALLIANCE_JAR); instructions.clear(); /*end[AOP]*/ // javax.inject is an API bundle --> export the full API instructions.setProperty("Export-Package", "javax.inject.*"); buildBundle("javax.inject", instructions, JAVAX_INJECT_JAR); instructions.clear(); // strict imports to make sure test bundle only has access to these packages instructions.setProperty("Import-Package", "org.osgi.framework," /*if[AOP]*/ + "org.aopalliance.intercept," /*end[AOP]*/ + "com.google.inject(|.binder|.matcher|.name)"); // test bundle should only contain the local test classes, nothing else instructions.setProperty("Bundle-Activator", OSGiTestActivator.class.getName()); instructions.setProperty("Private-Package", OSGiTestActivator.class.getPackage().getName()); buildBundle("osgitests", instructions, BUILD_TEST_DIR); instructions.clear(); } // build an OSGi bundle at runtime private static void buildBundle(String name, Properties instructions, String classpath) throws IOException { // write BND instructions to temporary test directory String bndFileName = BUILD_TEST_DIR + '/' + name + ".bnd"; OutputStream os = new BufferedOutputStream(new FileOutputStream(bndFileName)); instructions.store(os, "BND instructions"); os.close(); // assemble bundle, use -failok switch to avoid early exit bnd.main(new String[]{"-failok", "build", "-classpath", classpath, bndFileName}); } private String failMsg() { return "This test may fail if it is not run from ant, or if it is not run after ant has " + "compiled & built jars. This is because the test is validating that the Guice jar " + "is properly setup to load in an OSGi container"; } //This test may fail if it is not run from ant, or if it is not run after ant has //compiled & built jars. This is because the test is validating that the Guice jar //is properly setup to load in an OSGi container public void testGuiceWorksInOSGiContainer() throws Throwable { // ask framework to clear cache on startup Properties properties = new Properties(); properties.setProperty("org.osgi.framework.storage", BUILD_TEST_DIR + "/bundle.cache"); properties.setProperty("org.osgi.framework.storage.clean", "onFirstInit"); // test each available OSGi framework in turn Iterator f = ServiceRegistry.lookupProviders(FrameworkFactory.class); while (f.hasNext()) { Framework framework = f.next().newFramework((Map)properties); framework.start(); BundleContext systemContext = framework.getBundleContext(); // load all the necessary bundles and start the OSGi test bundle /*if[AOP]*/ systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/aopalliance.jar"); /*end[AOP]*/ systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/javax.inject.jar"); systemContext.installBundle("reference:file:" + GUICE_JAR); systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/osgitests.jar").start(); framework.stop(); } } } sisu-guice-sisu-guice-3.1.1/core/test/com/googlecode/guice/Jsr330Test.java0000644000175000017500000003146011704661106024775 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.guice; import static com.google.inject.Asserts.assertContains; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.AbstractModule; import com.google.inject.Binding; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Scope; import com.google.inject.Scopes; import com.google.inject.Stage; import com.google.inject.TypeLiteral; import com.google.inject.name.Names; import com.google.inject.spi.Dependency; import com.google.inject.spi.HasDependencies; import com.google.inject.util.Providers; import junit.framework.TestCase; import java.lang.annotation.Annotation; import java.lang.annotation.Retention; import java.util.Set; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Provider; import javax.inject.Qualifier; import javax.inject.Singleton; public class Jsr330Test extends TestCase { private final B b = new B(); private final C c = new C(); private final D d = new D(); private final E e = new E(); @Override protected void setUp() throws Exception { J.nextInstanceId = 0; K.nextInstanceId = 0; } public void testInject() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(B.class).toInstance(b); bind(C.class).toInstance(c); bind(D.class).toInstance(d); bind(E.class).toInstance(e); bind(A.class); } }); A a = injector.getInstance(A.class); assertSame(b, a.b); assertSame(c, a.c); assertSame(d, a.d); assertSame(e, a.e); } public void testQualifiedInject() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(B.class).annotatedWith(Names.named("jodie")).toInstance(b); bind(C.class).annotatedWith(Red.class).toInstance(c); bind(D.class).annotatedWith(RED).toInstance(d); bind(E.class).annotatedWith(Names.named("jesse")).toInstance(e); bind(F.class); } }); F f = injector.getInstance(F.class); assertSame(b, f.b); assertSame(c, f.c); assertSame(d, f.d); assertSame(e, f.e); } public void testProviderInject() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(B.class).annotatedWith(Names.named("jodie")).toInstance(b); bind(C.class).toInstance(c); bind(D.class).annotatedWith(RED).toInstance(d); bind(E.class).toInstance(e); bind(G.class); } }); G g = injector.getInstance(G.class); assertSame(b, g.bProvider.get()); assertSame(c, g.cProvider.get()); assertSame(d, g.dProvider.get()); assertSame(e, g.eProvider.get()); } public void testScopeAnnotation() { final TestScope scope = new TestScope(); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(B.class).in(scope); bind(C.class).in(TestScoped.class); bindScope(TestScoped.class, scope); } }); B b = injector.getInstance(B.class); assertSame(b, injector.getInstance(B.class)); assertSame(b, injector.getInstance(B.class)); C c = injector.getInstance(C.class); assertSame(c, injector.getInstance(C.class)); assertSame(c, injector.getInstance(C.class)); H h = injector.getInstance(H.class); assertSame(h, injector.getInstance(H.class)); assertSame(h, injector.getInstance(H.class)); scope.reset(); assertNotSame(b, injector.getInstance(B.class)); assertNotSame(c, injector.getInstance(C.class)); assertNotSame(h, injector.getInstance(H.class)); } public void testSingleton() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(B.class).in(Singleton.class); } }); B b = injector.getInstance(B.class); assertSame(b, injector.getInstance(B.class)); assertSame(b, injector.getInstance(B.class)); J j = injector.getInstance(J.class); assertSame(j, injector.getInstance(J.class)); assertSame(j, injector.getInstance(J.class)); } public void testEagerSingleton() { Guice.createInjector(Stage.PRODUCTION, new AbstractModule() { protected void configure() { bind(J.class); bind(K.class).in(Singleton.class); } }); assertEquals(1, J.nextInstanceId); assertEquals(1, K.nextInstanceId); } public void testScopesIsSingleton() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(J.class); bind(K.class).in(Singleton.class); } }); assertTrue(Scopes.isSingleton(injector.getBinding(J.class))); assertTrue(Scopes.isSingleton(injector.getBinding(K.class))); } public void testInjectingFinalFieldsIsForbidden() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(L.class); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Injected field " + L.class.getName() + ".b cannot be final."); } } public void testInjectingAbstractMethodsIsForbidden() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(M.class); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Injected method " + AbstractM.class.getName() + ".setB() cannot be abstract."); } } public void testInjectingMethodsWithTypeParametersIsForbidden() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(N.class); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Injected method " + N.class.getName() + ".setB() cannot declare type parameters of its own."); } } public void testInjectingMethodsWithNonVoidReturnTypes() { Guice.createInjector(new AbstractModule() { protected void configure() { bind(P.class); } }); } /** * This test verifies that we can compile bindings to provider instances * whose compile-time type implements javax.inject.Provider but not * com.google.inject.Provider. For binary compatibility, we don't (and won't) * support binding to instances of javax.inject.Provider. */ public void testBindProviderClass() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(B.class).toProvider(BProvider.class); bind(B.class).annotatedWith(Names.named("1")).toProvider(BProvider.class); bind(B.class).annotatedWith(Names.named("2")).toProvider(Key.get(BProvider.class)); bind(B.class).annotatedWith(Names.named("3")).toProvider(TypeLiteral.get(BProvider.class)); } }); injector.getInstance(Key.get(B.class)); injector.getInstance(Key.get(B.class, Names.named("1"))); injector.getInstance(Key.get(B.class, Names.named("2"))); injector.getInstance(Key.get(B.class, Names.named("3"))); } public void testGuicify330Provider() { Provider jsr330Provider = new Provider() { public String get() { return "A"; } @Override public String toString() { return "jsr330Provider"; } }; com.google.inject.Provider guicified = Providers.guicify(jsr330Provider); assertEquals("guicified(jsr330Provider)", guicified.toString()); assertEquals("A", guicified.get()); // when you guicify the Guice-friendly, it's a no-op assertSame(guicified, Providers.guicify(guicified)); assertFalse(guicified instanceof HasDependencies); } public void testGuicifyWithDependencies() { Provider jsr330Provider = new Provider() { @Inject double d; int i; @Inject void injectMe(int i) { this.i = i; } public String get() { return d + "-" + i; } }; final com.google.inject.Provider guicified = Providers.guicify(jsr330Provider); assertTrue(guicified instanceof HasDependencies); Set> actual = ((HasDependencies)guicified).getDependencies(); validateDependencies(actual, jsr330Provider.getClass()); Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(String.class).toProvider(guicified); bind(int.class).toInstance(1); bind(double.class).toInstance(2.0d); } }); Binding binding = injector.getBinding(String.class); assertEquals("2.0-1", binding.getProvider().get()); validateDependencies(actual, jsr330Provider.getClass()); } private void validateDependencies(Set> actual, Class owner) { assertEquals(actual.toString(), 2, actual.size()); Dependency dDep = null; Dependency iDep = null; for(Dependency dep : actual) { if(dep.getKey().equals(Key.get(Double.class))) { dDep = dep; } else if(dep.getKey().equals(Key.get(Integer.class))) { iDep = dep; } } assertNotNull(dDep); assertNotNull(iDep); assertEquals(TypeLiteral.get(owner), dDep.getInjectionPoint().getDeclaringType()); assertEquals("d", dDep.getInjectionPoint().getMember().getName()); assertEquals(-1, dDep.getParameterIndex()); assertEquals(TypeLiteral.get(owner), iDep.getInjectionPoint().getDeclaringType()); assertEquals("injectMe", iDep.getInjectionPoint().getMember().getName()); assertEquals(0, iDep.getParameterIndex()); } static class A { final B b; @Inject C c; D d; E e; @Inject A(B b) { this.b = b; } @Inject void injectD(D d, E e) { this.d = d; this.e = e; } } static class B {} static class C {} static class D {} static class E {} static class F { final B b; @Inject @Red C c; D d; E e; @Inject F(@Named("jodie") B b) { this.b = b; } @Inject void injectD(@Red D d, @Named("jesse") E e) { this.d = d; this.e = e; } } @Qualifier @Retention(RUNTIME) @interface Red {} public static final Red RED = new Red() { public Class annotationType() { return Red.class; } @Override public boolean equals(Object obj) { return obj instanceof Red; } @Override public int hashCode() { return 0; } }; static class G { final Provider bProvider; @Inject Provider cProvider; Provider dProvider; Provider eProvider; @Inject G(@Named("jodie") Provider bProvider) { this.bProvider = bProvider; } @Inject void injectD(@Red Provider dProvider, Provider eProvider) { this.dProvider = dProvider; this.eProvider = eProvider; } } @javax.inject.Scope @Retention(RUNTIME) @interface TestScoped {} static class TestScope implements Scope { private int now = 0; public com.google.inject.Provider scope(Key key, final com.google.inject.Provider unscoped) { return new com.google.inject.Provider() { private T value; private int snapshotTime = -1; public T get() { if (snapshotTime != now) { value = unscoped.get(); snapshotTime = now; } return value; } }; } public void reset() { now++; } } @TestScoped static class H {} @Singleton static class J { static int nextInstanceId = 0; int instanceId = nextInstanceId++; } static class K { static int nextInstanceId = 0; int instanceId = nextInstanceId++; } static class L { @Inject final B b = null; } static abstract class AbstractM { @Inject abstract void setB(B b); } static class M extends AbstractM { void setB(B b) {} } static class N { @Inject void setB(B b) {} } static class P { @Inject B setB(B b) { return b; } } static class BProvider implements Provider { public B get() { return new B(); } } } sisu-guice-sisu-guice-3.1.1/core/test/com/googlecode/guice/GuiceTck.java0000644000175000017500000000365711704661106024656 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.guice; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Provides; import junit.framework.Test; import junit.framework.TestCase; import org.atinject.tck.Tck; import org.atinject.tck.auto.Car; import org.atinject.tck.auto.Convertible; import org.atinject.tck.auto.Drivers; import org.atinject.tck.auto.DriversSeat; import org.atinject.tck.auto.Engine; import org.atinject.tck.auto.FuelTank; import org.atinject.tck.auto.Seat; import org.atinject.tck.auto.Tire; import org.atinject.tck.auto.V8Engine; import org.atinject.tck.auto.accessories.Cupholder; import org.atinject.tck.auto.accessories.SpareTire; import javax.inject.Named; public class GuiceTck extends TestCase { public static Test suite() { return Tck.testsFor(Guice.createInjector(new AbstractModule() { protected void configure() { bind(Car.class).to(Convertible.class); bind(Seat.class).annotatedWith(Drivers.class).to(DriversSeat.class); bind(Engine.class).to(V8Engine.class); bind(Cupholder.class); bind(Tire.class); bind(FuelTank.class); requestStaticInjection(Convertible.class, SpareTire.class); } @Provides @Named("spare") Tire provideSpareTire(SpareTire spare) { return spare; } }).getInstance(Car.class), true, true); } } sisu-guice-sisu-guice-3.1.1/core/test/com/googlecode/guice/BytecodeGenTest.java0000644000175000017500000002450011704661106026176 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.guice; import static com.google.inject.matcher.Matchers.any; import com.google.inject.AbstractModule; import com.google.inject.Binder; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Module; import com.googlecode.guice.PackageVisibilityTestModule.PublicUserOfPackagePrivate; import junit.framework.TestCase; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import java.io.File; import java.lang.ref.Reference; import java.lang.ref.WeakReference; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; /** * This test is in a separate package so we can test package-level visibility * with confidence. * * @author mcculls@gmail.com (Stuart McCulloch) */ public class BytecodeGenTest extends TestCase { private final ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); private final Module interceptorModule = new AbstractModule() { protected void configure() { bindInterceptor(any(), any(), new MethodInterceptor() { public Object invoke(MethodInvocation chain) throws Throwable { return chain.proceed() + " WORLD"; } }); } }; private final Module noopInterceptorModule = new AbstractModule() { protected void configure() { bindInterceptor(any(), any(), new MethodInterceptor() { public Object invoke(MethodInvocation chain) throws Throwable { return chain.proceed(); } }); } }; public void testPackageVisibility() { Injector injector = Guice.createInjector(new PackageVisibilityTestModule()); injector.getInstance(PublicUserOfPackagePrivate.class); // This must pass. } public void testInterceptedPackageVisibility() { Injector injector = Guice.createInjector(interceptorModule, new PackageVisibilityTestModule()); injector.getInstance(PublicUserOfPackagePrivate.class); // This must pass. } public void testEnhancerNaming() { Injector injector = Guice.createInjector(interceptorModule, new PackageVisibilityTestModule()); PublicUserOfPackagePrivate pupp = injector.getInstance(PublicUserOfPackagePrivate.class); assertTrue(pupp.getClass().getName().startsWith( PublicUserOfPackagePrivate.class.getName() + "$$EnhancerByGuice$$")); } // TODO(sameb): Figure out how to test FastClass naming tests. /** * Custom URL classloader with basic visibility rules */ static class TestVisibilityClassLoader extends URLClassLoader { boolean hideInternals; public TestVisibilityClassLoader(boolean hideInternals) { super(new URL[0]); this.hideInternals = hideInternals; final String[] classpath = System.getProperty("java.class.path").split(File.pathSeparator); for (final String element : classpath) { try { // is it a remote/local URL? addURL(new URL(element)); } catch (final MalformedURLException e1) { try { // nope - perhaps it's a filename? addURL(new File(element).toURI().toURL()); } catch (final MalformedURLException e2) { throw new RuntimeException(e1); } } } } /** * Classic parent-delegating classloaders are meant to override findClass. * However, non-delegating classloaders (as used in OSGi) instead override * loadClass to provide support for "class-space" separation. */ @Override protected Class loadClass(final String name, final boolean resolve) throws ClassNotFoundException { synchronized (this) { // check our local cache to avoid duplicates final Class clazz = findLoadedClass(name); if (clazz != null) { return clazz; } } if (name.startsWith("java.")) { // standard bootdelegation of java.* return super.loadClass(name, resolve); } else if (!name.contains(".internal.") && !name.contains(".cglib.")) { /* * load public and test classes directly from the classpath - we don't * delegate to our parent because then the loaded classes would also be * able to see private internal Guice classes, as they are also loaded * by the parent classloader. */ final Class clazz = findClass(name); if (resolve) { resolveClass(clazz); } return clazz; } // hide internal non-test classes if (hideInternals) { throw new ClassNotFoundException(); } return super.loadClass(name, resolve); } } /** as loaded by another class loader */ private Class proxyTestClass; private Class realClass; private Module testModule; @SuppressWarnings("unchecked") protected void setUp() throws Exception { super.setUp(); ClassLoader testClassLoader = new TestVisibilityClassLoader(true); proxyTestClass = (Class) testClassLoader.loadClass(ProxyTest.class.getName()); realClass = (Class) testClassLoader.loadClass(ProxyTestImpl.class.getName()); testModule = new AbstractModule() { public void configure() { bind(proxyTestClass).to(realClass); } }; } interface ProxyTest { String sayHello(); } /** * Note: this class must be marked as public or protected so that the Guice * custom classloader will intercept it. Private and implementation classes * are not intercepted by the custom classloader. * * @see com.google.inject.internal.BytecodeGen.Visibility */ public static class ProxyTestImpl implements ProxyTest { static { //System.out.println(ProxyTestImpl.class.getClassLoader()); } public String sayHello() { return "HELLO"; } } public void testProxyClassLoading() throws Exception { Object testObject = Guice.createInjector(interceptorModule, testModule) .getInstance(proxyTestClass); // verify method interception still works Method m = realClass.getMethod("sayHello"); assertEquals("HELLO WORLD", m.invoke(testObject)); } public void testSystemClassLoaderIsUsedIfProxiedClassUsesIt() { ProxyTest testProxy = Guice.createInjector(interceptorModule, new Module() { public void configure(Binder binder) { binder.bind(ProxyTest.class).to(ProxyTestImpl.class); } }).getInstance(ProxyTest.class); if (ProxyTest.class.getClassLoader() == systemClassLoader) { assertSame(testProxy.getClass().getClassLoader(), systemClassLoader); } else { assertNotSame(testProxy.getClass().getClassLoader(), systemClassLoader); } } public void testProxyClassUnloading() { Object testObject = Guice.createInjector(interceptorModule, testModule) .getInstance(proxyTestClass); assertNotNull(testObject.getClass().getClassLoader()); assertNotSame(testObject.getClass().getClassLoader(), systemClassLoader); // take a weak reference to the generated proxy class Reference> clazzRef = new WeakReference>(testObject.getClass()); assertNotNull(clazzRef.get()); // null the proxy testObject = null; /* * this should be enough to queue the weak reference * unless something is holding onto it accidentally. */ String[] buf; System.gc(); buf = new String[8 * 1024 * 1024]; buf = null; System.gc(); buf = new String[8 * 1024 * 1024]; buf = null; System.gc(); buf = new String[8 * 1024 * 1024]; buf = null; System.gc(); buf = new String[8 * 1024 * 1024]; buf = null; System.gc(); // This test could be somewhat flaky when the GC isn't working. // If it fails, run the test again to make sure it's failing reliably. assertNull(clazzRef.get()); } public void testProxyingPackagePrivateMethods() { Injector injector = Guice.createInjector(interceptorModule); assertEquals("HI WORLD", injector.getInstance(PackageClassPackageMethod.class).sayHi()); assertEquals("HI WORLD", injector.getInstance(PublicClassPackageMethod.class).sayHi()); assertEquals("HI WORLD", injector.getInstance(ProtectedClassProtectedMethod.class).sayHi()); } static class PackageClassPackageMethod { String sayHi() { return "HI"; } } public static class PublicClassPackageMethod { String sayHi() { return "HI"; } } protected static class ProtectedClassProtectedMethod { protected String sayHi() { return "HI"; } } static class Hidden { } public static class HiddenMethodReturn { public Hidden method() { return new Hidden(); } } public static class HiddenMethodParameter { public void method(Hidden h) { } } public void testClassLoaderBridging() throws Exception { ClassLoader testClassLoader = new TestVisibilityClassLoader(false); Class hiddenMethodReturnClass = testClassLoader.loadClass(HiddenMethodReturn.class.getName()); Class hiddenMethodParameterClass = testClassLoader.loadClass(HiddenMethodParameter.class.getName()); Injector injector = Guice.createInjector(noopInterceptorModule); Class hiddenClass = testClassLoader.loadClass(Hidden.class.getName()); Constructor ctor = hiddenClass.getDeclaredConstructor(); ctor.setAccessible(true); // don't use bridging for proxies with private parameters Object o1 = injector.getInstance(hiddenMethodParameterClass); o1.getClass().getDeclaredMethod("method", hiddenClass).invoke(o1, ctor.newInstance()); // don't use bridging for proxies with private return types Object o2 = injector.getInstance(hiddenMethodReturnClass); o2.getClass().getDeclaredMethod("method").invoke(o2); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/0000755000175000017500000000000011704661106020353 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/0000755000175000017500000000000011704661106021627 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/util/0000755000175000017500000000000011704661106022604 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/util/TypesTest.java0000644000175000017500000002042711704661106025420 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.util; import static com.google.inject.Asserts.assertContains; import static com.google.inject.Asserts.assertEqualWhenReserialized; import static com.google.inject.Asserts.assertEqualsBothWays; import static com.google.inject.util.Types.subtypeOf; import static com.google.inject.util.Types.supertypeOf; import com.google.inject.TypeLiteral; import com.google.inject.internal.MoreTypes; import junit.framework.Assert; import junit.framework.TestCase; import java.io.IOException; import java.lang.reflect.GenericArrayType; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.lang.reflect.WildcardType; import java.util.List; import java.util.Map; import java.util.Set; /** * @author jessewilson@google.com (Jesse Wilson) */ public class TypesTest extends TestCase { // generic types for comparison Map a; Inner b; List[][]> c; List d; Set e; Outer.Inner f; private ParameterizedType mapStringInteger; private ParameterizedType innerFloatDouble; private ParameterizedType listSetStringArray; private ParameterizedType listString; private ParameterizedType setString; private ParameterizedType outerInner; private GenericArrayType setStringArray; @Override protected void setUp() throws Exception { super.setUp(); mapStringInteger = (ParameterizedType) getClass().getDeclaredField("a").getGenericType(); innerFloatDouble = (ParameterizedType) getClass().getDeclaredField("b").getGenericType(); listSetStringArray = (ParameterizedType) getClass().getDeclaredField("c").getGenericType(); listString = (ParameterizedType) getClass().getDeclaredField("d").getGenericType(); setString = (ParameterizedType) getClass().getDeclaredField("e").getGenericType(); outerInner = (ParameterizedType) getClass().getDeclaredField("f").getGenericType(); setStringArray = (GenericArrayType) listSetStringArray.getActualTypeArguments()[0]; } public void testListSetMap() { assertEqualsBothWays(mapStringInteger, Types.mapOf(String.class, Integer.class)); assertEqualsBothWays(listString, Types.listOf(String.class)); assertEqualsBothWays(setString, Types.setOf(String.class)); } public void testDefensiveCopies() { Type[] arguments = new Type[] { String.class, Integer.class }; ParameterizedType parameterizedType = Types.newParameterizedType(Map.class, arguments); arguments[0] = null; assertEquals(String.class, parameterizedType.getActualTypeArguments()[0]); parameterizedType.getActualTypeArguments()[1] = null; assertEquals(Integer.class, parameterizedType.getActualTypeArguments()[1]); } public void testTypeWithOwnerType() { ParameterizedType actual = Types.newParameterizedTypeWithOwner( TypesTest.class, Inner.class, Float.class, Double.class); assertEquals(TypesTest.class, actual.getOwnerType()); assertEqualsBothWays(innerFloatDouble, actual); // The JDK prints this out as: // com.google.inject.util.TypesTest.com.google.inject.util.TypesTest$Inner // and we think that's wrong, so the assertEquals comparison is worthless. :-( // assertEquals(innerFloatDouble.toString(), actual.toString()); // We think the correct comparison is: assertEquals("com.google.inject.util.TypesTest$Inner", actual.toString()); } public void testTypeParametersMustNotBePrimitives() { try { Types.newParameterizedType(Map.class, String.class, int.class); fail(); } catch (IllegalArgumentException expected) { assertContains(expected.getMessage(), "Primitive types are not allowed in type parameters: int"); } } public List wildcardExtends; public List wildcardSuper; public List wildcardObject; public void testWildcardTypes() throws NoSuchFieldException, IOException { assertEqualsBothWays(getWildcard("wildcardSuper"), supertypeOf(CharSequence.class)); assertEqualsBothWays(getWildcard("wildcardExtends"), subtypeOf(CharSequence.class)); assertEqualsBothWays(getWildcard("wildcardObject"), subtypeOf(Object.class)); assertEquals("? super java.lang.CharSequence", supertypeOf(CharSequence.class).toString()); assertEquals("? extends java.lang.CharSequence", subtypeOf(CharSequence.class).toString()); assertEquals("?", subtypeOf(Object.class).toString()); assertEqualWhenReserialized(supertypeOf(CharSequence.class)); assertEqualWhenReserialized(subtypeOf(CharSequence.class)); } public void testWildcardBoundsMustNotBePrimitives() { try { supertypeOf(int.class); fail(); } catch (IllegalArgumentException expected) { assertContains(expected.getMessage(), "Primitive types are not allowed in wildcard bounds: int"); } try { subtypeOf(int.class); fail(); } catch (IllegalArgumentException expected) { assertContains(expected.getMessage(), "Primitive types are not allowed in wildcard bounds: int"); } } private WildcardType getWildcard(String fieldName) throws NoSuchFieldException { ParameterizedType type = (ParameterizedType) getClass().getField(fieldName).getGenericType(); return (WildcardType) type.getActualTypeArguments()[0]; } public void testEqualsAndHashcode() { ParameterizedType parameterizedType = Types.newParameterizedType(Map.class, String.class, Integer.class); assertEqualsBothWays(mapStringInteger, parameterizedType); assertEquals(mapStringInteger.toString(), parameterizedType.toString()); GenericArrayType genericArrayType = Types.arrayOf(Types.arrayOf( Types.newParameterizedType(Set.class, String.class))); assertEqualsBothWays(setStringArray, genericArrayType); assertEquals(setStringArray.toString(), genericArrayType.toString()); } public void testToString() { Assert.assertEquals("java.lang.String", MoreTypes.typeToString(String.class)); assertEquals("java.util.Set[][]", MoreTypes.typeToString(setStringArray)); assertEquals("java.util.Map", MoreTypes.typeToString(mapStringInteger)); assertEquals("java.util.List[][]>", MoreTypes.typeToString(listSetStringArray)); assertEquals(innerFloatDouble.toString(), MoreTypes.typeToString(innerFloatDouble)); } static class Owning {} /** * Ensure that owning types are required when necessary, and forbidden * otherwise. */ public void testCanonicalizeRequiresOwnerTypes() { try { Types.newParameterizedType(Owning.class, String.class); fail(); } catch (IllegalArgumentException expected) { assertContains(expected.getMessage(), "No owner type for enclosed " + Owning.class); } try { Types.newParameterizedTypeWithOwner(Object.class, Set.class, String.class); } catch (IllegalArgumentException expected) { assertContains(expected.getMessage(), "Owner type for unenclosed " + Set.class); } } @SuppressWarnings("UnusedDeclaration") class Inner {} public void testInnerParameterizedEvenWithZeroArgs() { TypeLiteral.Inner> type = new TypeLiteral.Inner>() {}; assertEqualsBothWays(outerInner, type.getType()); ParameterizedType parameterizedType = (ParameterizedType) type.getType(); assertEquals(0, parameterizedType.getActualTypeArguments().length); assertEquals(new TypeLiteral>() {}.getType(), parameterizedType.getOwnerType()); assertEquals(Outer.Inner.class, parameterizedType.getRawType()); } static class Outer { class Inner {} } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/util/ProvidersTest.java0000644000175000017500000000213311704661106026263 0ustar tonytony/* * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.util; import com.google.inject.Provider; import junit.framework.TestCase; /** * Unit tests for {@link Providers}. * * @author Kevin Bourrillion (kevinb9n@gmail.com) */ public class ProvidersTest extends TestCase { public void testOfInstance() { String foo = "foo"; Provider p = Providers.of(foo); assertSame(foo, p.get()); assertSame(foo, p.get()); } public void testOfNull() { Provider p = Providers.of(null); assertNull(p.get()); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/util/NoopOverrideTest.java0000644000175000017500000000205311704661106026722 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.util; import com.google.inject.Module; import com.google.inject.spi.ElementVisitor; import com.google.inject.spi.ElementsTest; /** * @author jessewilson@google.com (Jesse Wilson) */ public class NoopOverrideTest extends ElementsTest { protected void checkModule(Module module, ElementVisitor... visitors) { Module overridden = Modules.override(module).with(Modules.EMPTY_MODULE); super.checkModule(overridden, visitors); } }sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/spi/0000755000175000017500000000000011704661106022422 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/spi/ToolStageInjectorTest.java0000644000175000017500000001153411704661106027530 0ustar tonytonypackage com.google.inject.spi; import com.google.inject.AbstractModule; import com.google.inject.Asserts; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.Stage; import com.google.inject.spi.Toolable; import junit.framework.TestCase; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; public class ToolStageInjectorTest extends TestCase { @Override protected void setUp() throws Exception { Foo.s = null; Foo.sm = null; } public void testToolStageInjectorRestrictions() { Injector injector = Guice.createInjector(Stage.TOOL); try { injector.injectMembers(new Object()); fail("Non-SPI Injector methods must throw an exception in the TOOL stage."); } catch (UnsupportedOperationException expected) { } try { injector.getInstance(Injector.class); fail("Non-SPI Injector methods must throw an exception in the TOOL stage."); } catch (UnsupportedOperationException expected) { } try { injector.getInstance(Key.get(Injector.class)); fail("Non-SPI Injector methods must throw an exception in the TOOL stage."); } catch (UnsupportedOperationException expected) { } try { injector.getProvider(Injector.class); fail("Non-SPI Injector methods must throw an exception in the TOOL stage."); } catch (UnsupportedOperationException expected) { } try { injector.getProvider(Key.get(Injector.class)); fail("Non-SPI Injector methods must throw an exception in the TOOL stage."); } catch (UnsupportedOperationException expected) { } } public void testToolStageDoesntInjectInstances() { final Foo foo = new Foo(); Guice.createInjector(Stage.TOOL, new AbstractModule() { @Override protected void configure() { requestStaticInjection(Foo.class); requestInjection(foo); } }); assertNull(Foo.s); assertNull(Foo.sm); assertNull(foo.f); assertNull(foo.m); } public void testToolStageDoesntInjectProviders() { final Foo foo = new Foo(); Guice.createInjector(Stage.TOOL, new AbstractModule() { @Override protected void configure() { requestStaticInjection(Foo.class); bind(Object.class).toProvider(foo); } }); assertNull(Foo.s); assertNull(Foo.sm); assertNull(foo.f); assertNull(foo.m); } public void testToolStageWarnsOfMissingObjectGraph() { final Bar bar = new Bar(); try { Guice.createInjector(Stage.TOOL, new AbstractModule() { @Override protected void configure() { requestStaticInjection(Bar.class); requestInjection(bar); } }); fail("expected exception"); } catch(CreationException expected) { Asserts.assertContains(expected.toString(), "No implementation for java.util.Collection was bound.", "No implementation for java.util.Map was bound.", "No implementation for java.util.List was bound.", "No implementation for java.util.Set was bound."); } } public void testToolStageInjectsTooledMethods() { final Tooled tooled = new Tooled(); Guice.createInjector(Stage.TOOL, new AbstractModule() { @Override protected void configure() { requestStaticInjection(Tooled.class); bind(Object.class).toProvider(tooled); } }); assertNull(Tooled.s); assertNotNull(Tooled.sm); assertNull(tooled.f); assertNotNull(tooled.m); } @SuppressWarnings("unchecked") private static class Bar { @SuppressWarnings("unused") @Inject private static List list; @SuppressWarnings("unused") @Inject private Set set; @SuppressWarnings("unused") @Inject void method(Collection c) {} @SuppressWarnings("unused") @Inject static void staticMethod(Map map) {} } private static class Foo implements Provider { @Inject private static S s; @Inject private F f; private M m; @SuppressWarnings("unused") @Inject void method(M m) { this.m = m; } private static SM sm; @SuppressWarnings("unused") @Inject static void staticMethod(SM sm) { Tooled.sm = sm; } public Object get() { return null; } } private static class Tooled implements Provider { @Inject private static S s; @Inject private F f; private M m; @Toolable @SuppressWarnings("unused") @Inject void method(M m) { this.m = m; } private static SM sm; @Toolable @SuppressWarnings("unused") @Inject static void staticMethod(SM sm) { Tooled.sm = sm; } public Object get() { return null; } } private static class S {} private static class F {} private static class M {} private static class SM {} } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/spi/SpiBindingsTest.java0000644000175000017500000003772511704661106026354 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.inject.Asserts.assertContains; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.inject.AbstractModule; import com.google.inject.Binding; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provider; import com.google.inject.Scope; import com.google.inject.Scopes; import com.google.inject.Singleton; import com.google.inject.Stage; import com.google.inject.name.Names; import junit.framework.AssertionFailedError; import junit.framework.TestCase; import java.lang.reflect.Constructor; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Logger; /** * @author jessewilson@google.com (Jesse Wilson) */ public class SpiBindingsTest extends TestCase { public void testBindConstant() { checkInjector( new AbstractModule() { protected void configure() { bindConstant().annotatedWith(Names.named("one")).to(1); } }, new FailingElementVisitor() { @Override public Void visit(Binding binding) { assertTrue(binding instanceof InstanceBinding); assertEquals(Key.get(Integer.class, Names.named("one")), binding.getKey()); return null; } } ); } public void testToInstanceBinding() { checkInjector( new AbstractModule() { protected void configure() { bind(String.class).toInstance("A"); } }, new FailingElementVisitor() { @Override public Void visit(Binding binding) { assertTrue(binding instanceof InstanceBinding); assertContains(binding.getSource().toString(), "SpiBindingsTest.java"); assertEquals(Key.get(String.class), binding.getKey()); binding.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit(InstanceBinding binding) { assertEquals("A", binding.getInstance()); return null; } }); binding.acceptScopingVisitor(new FailingBindingScopingVisitor() { public Void visitEagerSingleton() { return null; } }); return null; } } ); } public void testToProviderBinding() { final Provider stringProvider = new StringProvider(); checkInjector( new AbstractModule() { protected void configure() { bind(String.class).toProvider(stringProvider); } }, new FailingElementVisitor() { @Override public Void visit(Binding binding) { assertTrue(binding instanceof ProviderInstanceBinding); assertContains(binding.getSource().toString(), "SpiBindingsTest.java"); assertEquals(Key.get(String.class), binding.getKey()); binding.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit( ProviderInstanceBinding binding) { assertSame(stringProvider, binding.getProviderInstance()); return null; } }); return null; } } ); } public void testToProviderKeyBinding() { checkInjector( new AbstractModule() { protected void configure() { bind(String.class).toProvider(StringProvider.class); } }, new FailingElementVisitor() { @Override public Void visit(Binding binding) { assertTrue(binding instanceof ProviderKeyBinding); assertContains(binding.getSource().toString(), "SpiBindingsTest.java"); assertEquals(Key.get(String.class), binding.getKey()); binding.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit(ProviderKeyBinding binding) { assertEquals(Key.get(StringProvider.class), binding.getProviderKey()); return null; } }); return null; } } ); } public void testToKeyBinding() { final Key aKey = Key.get(String.class, Names.named("a")); final Key bKey = Key.get(String.class, Names.named("b")); checkInjector( new AbstractModule() { protected void configure() { bind(aKey).to(bKey); bind(bKey).toInstance("B"); } }, new FailingElementVisitor() { @Override public Void visit(Binding binding) { assertTrue(binding instanceof LinkedKeyBinding); assertContains(binding.getSource().toString(), "SpiBindingsTest.java"); assertEquals(aKey, binding.getKey()); binding.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit(LinkedKeyBinding binding) { assertEquals(bKey, binding.getLinkedKey()); return null; } }); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding binding) { assertEquals(bKey, binding.getKey()); return null; } } ); } public void testToConstructorBinding() { checkInjector( new AbstractModule() { protected void configure() { bind(D.class); } }, new FailingElementVisitor() { @Override public Void visit(Binding binding) { assertTrue(binding instanceof ConstructorBinding); assertContains(binding.getSource().toString(), "SpiBindingsTest.java"); assertEquals(Key.get(D.class), binding.getKey()); binding.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit(ConstructorBinding binding) { Constructor expected = D.class.getDeclaredConstructors()[0]; assertEquals(expected, binding.getConstructor().getMember()); assertEquals(ImmutableSet.of(), binding.getInjectableMembers()); return null; } }); return null; } } ); } public void testConstantBinding() { checkInjector( new AbstractModule() { protected void configure() { bindConstant().annotatedWith(Names.named("one")).to(1); } }, new FailingElementVisitor() { @Override public Void visit(Binding binding) { assertTrue(binding instanceof InstanceBinding); assertContains(binding.getSource().toString(), "SpiBindingsTest.java"); assertEquals(Key.get(Integer.class, Names.named("one")), binding.getKey()); binding.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit(InstanceBinding binding) { assertEquals(1, binding.getInstance()); return null; } }); return null; } } ); } public void testConvertedConstantBinding() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindConstant().annotatedWith(Names.named("one")).to("1"); } }); Binding binding = injector.getBinding(Key.get(Integer.class, Names.named("one"))); assertEquals(Key.get(Integer.class, Names.named("one")), binding.getKey()); assertContains(binding.getSource().toString(), "SpiBindingsTest.java"); assertTrue(binding instanceof ConvertedConstantBinding); binding.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit( ConvertedConstantBinding binding) { assertEquals((Integer) 1, binding.getValue()); assertEquals(Key.get(String.class, Names.named("one")), binding.getSourceKey()); return null; } }); } public void testProviderBinding() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(String.class).toInstance("A"); } }); Key> providerOfStringKey = new Key>() {}; Binding> binding = injector.getBinding(providerOfStringKey); assertEquals(providerOfStringKey, binding.getKey()); assertContains(binding.getSource().toString(), "SpiBindingsTest.java"); assertTrue(binding instanceof ProviderBinding); binding.acceptTargetVisitor(new FailingTargetVisitor>() { @Override public Void visit( ProviderBinding> binding) { assertEquals(Key.get(String.class), binding.getProvidedKey()); return null; } }); } public void testScopes() { checkInjector( new AbstractModule() { protected void configure() { bind(String.class).annotatedWith(Names.named("a")) .toProvider(StringProvider.class).in(Singleton.class); bind(String.class).annotatedWith(Names.named("b")) .toProvider(StringProvider.class).in(Scopes.SINGLETON); bind(String.class).annotatedWith(Names.named("c")) .toProvider(StringProvider.class).asEagerSingleton(); bind(String.class).annotatedWith(Names.named("d")) .toProvider(StringProvider.class); } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertEquals(Key.get(String.class, Names.named("a")), command.getKey()); command.acceptScopingVisitor(new FailingBindingScopingVisitor() { @Override public Void visitScope(Scope scope) { // even though we bound with an annotation, the injector always uses instances assertSame(Scopes.SINGLETON, scope); return null; } }); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertEquals(Key.get(String.class, Names.named("b")), command.getKey()); command.acceptScopingVisitor(new FailingBindingScopingVisitor() { @Override public Void visitScope(Scope scope) { assertSame(Scopes.SINGLETON, scope); return null; } }); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertEquals(Key.get(String.class, Names.named("c")), command.getKey()); command.acceptScopingVisitor(new FailingBindingScopingVisitor() { @Override public Void visitEagerSingleton() { return null; } }); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertEquals(Key.get(String.class, Names.named("d")), command.getKey()); command.acceptScopingVisitor(new FailingBindingScopingVisitor() { @Override public Void visitNoScoping() { return null; } }); return null; } } ); } public void testExtensionSpi() { final AtomicBoolean visiting = new AtomicBoolean(false); final Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(String.class).toProvider(new ProviderWithExtensionVisitor() { public V acceptExtensionVisitor(BindingTargetVisitor visitor, ProviderInstanceBinding binding) { assertSame(this, binding.getProviderInstance()); // We can't always check for FailingSpiTargetVisitor, // because constructing the injector visits here, and we need // to process the binding as normal if(visiting.get()) { assertTrue("visitor: " + visitor, visitor instanceof FailingSpiTargetVisitor); return (V)"visited"; } else { return visitor.visit(binding); } } public String get() { return "FooBar"; } }); } }); visiting.set(true); // Check for Provider binding -- that is still a ProviderBinding. Key> providerOfStringKey = new Key>() {}; Binding> providerBinding = injector.getBinding(providerOfStringKey); assertEquals(providerOfStringKey, providerBinding.getKey()); assertContains(providerBinding.getSource().toString(), "SpiBindingsTest.java"); assertTrue("binding: " + providerBinding, providerBinding instanceof ProviderBinding); providerBinding.acceptTargetVisitor(new FailingTargetVisitor>() { @Override public Void visit(ProviderBinding> binding) { assertEquals(Key.get(String.class), binding.getProvidedKey()); return null; } }); // Check for String binding -- that one is ProviderInstanceBinding, and gets hooked Binding binding = injector.getBinding(String.class); assertEquals(Key.get(String.class), binding.getKey()); assertContains(binding.getSource().toString(), "SpiBindingsTest.java"); assertTrue(binding instanceof ProviderInstanceBinding); assertEquals("visited", binding.acceptTargetVisitor(new FailingSpiTargetVisitor())); } private static class FailingSpiTargetVisitor extends DefaultBindingTargetVisitor { @Override protected String visitOther(Binding binding) { throw new AssertionFailedError(); } } public void checkInjector(Module module, ElementVisitor... visitors) { Injector injector = Guice.createInjector(module); List> bindings = Lists.newArrayList(injector.getBindings().values()); for (Iterator> i = bindings.iterator(); i.hasNext(); ) { if (BUILT_IN_BINDINGS.contains(i.next().getKey())) { i.remove(); } } Collections.sort(bindings, orderByKey); assertEquals(bindings.size(), visitors.length); for (int i = 0; i < visitors.length; i++) { ElementVisitor visitor = visitors[i]; Binding binding = bindings.get(i); binding.acceptVisitor(visitor); } } private final ImmutableSet> BUILT_IN_BINDINGS = ImmutableSet.of( Key.get(Injector.class), Key.get(Stage.class), Key.get(Logger.class)); private final Comparator> orderByKey = new Comparator>() { public int compare(Binding a, Binding b) { return a.getKey().toString().compareTo(b.getKey().toString()); } }; private static class StringProvider implements Provider { public String get() { return "A"; } } private static class C { } private static class D extends C { @Inject public D(Injector unused) { } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/spi/ProviderMethodsTest.java0000644000175000017500000002747211704661106027257 0ustar tonytony/** * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.inject.Asserts.assertContains; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.inject.AbstractModule; import com.google.inject.Binder; import com.google.inject.BindingAnnotation; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provider; import com.google.inject.Provides; import com.google.inject.Singleton; import com.google.inject.internal.ProviderMethod; import com.google.inject.internal.ProviderMethodsModule; import com.google.inject.name.Named; import com.google.inject.name.Names; import com.google.inject.util.Types; import junit.framework.TestCase; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import java.util.logging.Logger; /** * @author crazybob@google.com (Bob Lee) */ public class ProviderMethodsTest extends TestCase implements Module { @SuppressWarnings("unchecked") public void testProviderMethods() { Injector injector = Guice.createInjector(this); Bob bob = injector.getInstance(Bob.class); assertEquals("A Bob", bob.getName()); Bob clone = injector.getInstance(Bob.class); assertEquals("A Bob", clone.getName()); assertNotSame(bob, clone); assertSame(bob.getDaughter(), clone.getDaughter()); Key soleBobKey = Key.get(Bob.class, Sole.class); assertSame( injector.getInstance(soleBobKey), injector.getInstance(soleBobKey) ); } public void configure(Binder binder) {} interface Bob { String getName(); Dagny getDaughter(); } interface Dagny { int getAge(); } @Provides Bob provideBob(final Dagny dagny) { return new Bob() { public String getName() { return "A Bob"; } public Dagny getDaughter() { return dagny; } }; } @Provides @Singleton @Sole Bob provideSoleBob(final Dagny dagny) { return new Bob() { public String getName() { return "Only Bob"; } public Dagny getDaughter() { return dagny; } }; } @Provides @Singleton Dagny provideDagny() { return new Dagny() { public int getAge() { return 1; } }; } @Retention(RUNTIME) @Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @BindingAnnotation @interface Sole {} // We'll have to make getProvider() support circular dependencies before this // will work. // // public void testCircularDependency() { // Injector injector = Guice.createInjector(new Module() { // public void configure(Binder binder) { // binder.install(ProviderMethods.from(ProviderMethodsTest.this)); // } // }); // // Foo foo = injector.getInstance(Foo.class); // assertEquals(5, foo.getI()); // assertEquals(10, foo.getBar().getI()); // assertEquals(5, foo.getBar().getFoo().getI()); // } // // interface Foo { // Bar getBar(); // int getI(); // } // // interface Bar { // Foo getFoo(); // int getI(); // } // // @Provides Foo newFoo(final Bar bar) { // return new Foo() { // // public Bar getBar() { // return bar; // } // // public int getI() { // return 5; // } // }; // } // // @Provides Bar newBar(final Foo foo) { // return new Bar() { // // public Foo getFoo() { // return foo; // } // // public int getI() { // return 10; // } // }; // } public void testMultipleBindingAnnotations() { try { Guice.createInjector(new AbstractModule() { protected void configure() {} @Provides @Named("A") @Blue public String provideString() { return "a"; } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "more than one annotation annotated with @BindingAnnotation:", "Named", "Blue", "at " + getClass().getName(), ".provideString(ProviderMethodsTest.java:"); } } @Retention(RUNTIME) @BindingAnnotation @interface Blue {} public void testGenericProviderMethods() { Injector injector = Guice.createInjector( new ProvideTs("A", "B") {}, new ProvideTs(1, 2) {}); assertEquals("A", injector.getInstance(Key.get(String.class, Names.named("First")))); assertEquals("B", injector.getInstance(Key.get(String.class, Names.named("Second")))); assertEquals(ImmutableSet.of("A", "B"), injector.getInstance(Key.get(Types.setOf(String.class)))); assertEquals(1, injector.getInstance(Key.get(Integer.class, Names.named("First"))).intValue()); assertEquals(2, injector.getInstance(Key.get(Integer.class, Names.named("Second"))).intValue()); assertEquals(ImmutableSet.of(1, 2), injector.getInstance(Key.get(Types.setOf(Integer.class)))); } abstract class ProvideTs extends AbstractModule { final T first; final T second; protected ProvideTs(T first, T second) { this.first = first; this.second = second; } protected void configure() {} @Named("First") @Provides T provideFirst() { return first; } @Named("Second") @Provides T provideSecond() { return second; } @Provides Set provideBoth(@Named("First") T first, @Named("Second") T second) { return ImmutableSet.of(first, second); } } public void testAutomaticProviderMethods() { Injector injector = Guice.createInjector((Module) new AbstractModule() { protected void configure() { } private int next = 1; @Provides @Named("count") public Integer provideCount() { return next++; } }); assertEquals(1, injector.getInstance(Key.get(Integer.class, Names.named("count"))).intValue()); assertEquals(2, injector.getInstance(Key.get(Integer.class, Names.named("count"))).intValue()); assertEquals(3, injector.getInstance(Key.get(Integer.class, Names.named("count"))).intValue()); } /** * If the user installs provider methods for the module manually, that shouldn't cause a double * binding of the provider methods' types. */ public void testAutomaticProviderMethodsDoNotCauseDoubleBinding() { Module installsSelf = new AbstractModule() { protected void configure() { install(this); bind(Integer.class).toInstance(5); } @Provides public String provideString(Integer count) { return "A" + count; } }; Injector injector = Guice.createInjector(installsSelf); assertEquals("A5", injector.getInstance(String.class)); } public void testWildcardProviderMethods() { final List strings = ImmutableList.of("A", "B", "C"); final List numbers = ImmutableList.of(1, 2, 3); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { @SuppressWarnings("unchecked") Key> listOfSupertypesOfInteger = (Key>) Key.get(Types.listOf(Types.supertypeOf(Integer.class))); bind(listOfSupertypesOfInteger).toInstance(numbers); } @Provides public List provideCharSequences() { return strings; } @Provides public Class provideType() { return Float.class; } }); assertSame(strings, injector.getInstance(HasWildcardInjection.class).charSequences); assertSame(numbers, injector.getInstance(HasWildcardInjection.class).numbers); assertSame(Float.class, injector.getInstance(HasWildcardInjection.class).type); } static class HasWildcardInjection { @Inject List charSequences; @Inject List numbers; @Inject Class type; } public void testProviderMethodDependenciesAreExposed() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Integer.class).toInstance(50); bindConstant().annotatedWith(Names.named("units")).to("Kg"); } @Provides @Named("weight") String provideWeight(Integer count, @Named("units") String units) { return count + units; } }); ProviderInstanceBinding binding = (ProviderInstanceBinding) injector.getBinding( Key.get(String.class, Names.named("weight"))); assertEquals(ImmutableSet.>of(Dependency.get(Key.get(Integer.class)), Dependency.get(Key.get(String.class, Names.named("units")))), binding.getDependencies()); } public void testNonModuleProviderMethods() { final Object methodsObject = new Object() { @Provides @Named("foo") String provideFoo() { return "foo-value"; } }; Module module = new AbstractModule() { @Override protected void configure() { install(ProviderMethodsModule.forObject(methodsObject)); } }; Injector injector = Guice.createInjector(module); Key key = Key.get(String.class, Names.named("foo")); assertEquals("foo-value", injector.getInstance(key)); // Test the provider method object itself. This makes sure getInstance works, since GIN uses it List elements = Elements.getElements(module); assertEquals(1, elements.size()); Element element = elements.get(0); assertTrue(element + " instanceof ProviderInstanceBinding", element instanceof ProviderInstanceBinding); ProviderInstanceBinding binding = (ProviderInstanceBinding) element; Provider provider = binding.getProviderInstance(); assertEquals(ProviderMethod.class, provider.getClass()); assertEquals(methodsObject, ((ProviderMethod) provider).getInstance()); } public void testVoidProviderMethods() { try { Guice.createInjector(new AbstractModule() { protected void configure() {} @Provides void provideFoo() {} }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Provider methods must return a value. Do not return void.", getClass().getName(), ".provideFoo(ProviderMethodsTest.java:"); } } public void testInjectsJustOneLogger() { AtomicReference loggerRef = new AtomicReference(); Injector injector = Guice.createInjector(new FooModule(loggerRef)); assertNull(loggerRef.get()); injector.getInstance(Integer.class); Logger lastLogger = loggerRef.getAndSet(null); assertNotNull(lastLogger); injector.getInstance(Integer.class); assertSame(lastLogger, loggerRef.get()); assertEquals(FooModule.class.getName() + ".foo", lastLogger.getName()); } private static class FooModule extends AbstractModule { private final AtomicReference loggerRef; public FooModule(AtomicReference loggerRef) { this.loggerRef = loggerRef; } @Override protected void configure() {} @SuppressWarnings("unused") @Provides Integer foo(Logger logger) { loggerRef.set(logger); return 42; } } }sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/spi/ModuleRewriterTest.java0000644000175000017500000000714311704661106027103 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.common.collect.Lists; import com.google.inject.AbstractModule; import com.google.inject.Binding; import com.google.inject.ConfigurationException; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provider; import com.google.inject.name.Names; import junit.framework.TestCase; import java.util.List; /** * @author jessewilson@google.com (Jesse Wilson) */ public class ModuleRewriterTest extends TestCase { public void testRewriteBindings() { // create a module the binds String.class and CharSequence.class Module module = new AbstractModule() { protected void configure() { bind(String.class).toInstance("Pizza"); bind(CharSequence.class).toInstance("Wine"); } }; // record the elements from that module List elements = Elements.getElements(module); // create a rewriter that rewrites the binding to 'Wine' with a binding to 'Beer' List rewritten = Lists.newArrayList(); for (Element element : elements) { element = element.acceptVisitor(new DefaultElementVisitor() { @Override public Element visit(Binding binding) { T target = binding.acceptTargetVisitor(Elements.getInstanceVisitor()); if ("Wine".equals(target)) { return null; } else { return binding; } } }); if (element != null) { rewritten.add(element); } } // create a module from the original list of elements and the rewriter Module rewrittenModule = Elements.getModule(rewritten); // the wine binding is dropped Injector injector = Guice.createInjector(rewrittenModule); try { injector.getInstance(CharSequence.class); fail(); } catch (ConfigurationException expected) { } } public void testGetProviderAvailableAtInjectMembersTime() { Module module = new AbstractModule() { public void configure() { final Provider stringProvider = getProvider(String.class); bind(String.class).annotatedWith(Names.named("2")).toProvider(new Provider() { private String value; @Inject void initialize() { value = stringProvider.get(); } public String get() { return value; } }); bind(String.class).toInstance("A"); } }; // the module works fine normally Injector injector = Guice.createInjector(module); assertEquals("A", injector.getInstance(Key.get(String.class, Names.named("2")))); // and it should also work fine if we rewrite it List elements = Elements.getElements(module); Module replayed = Elements.getModule(elements); Injector replayedInjector = Guice.createInjector(replayed); assertEquals("A", replayedInjector.getInstance(Key.get(String.class, Names.named("2")))); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/spi/InjectorSpiTest.java0000644000175000017500000000572311704661106026365 0ustar tonytonypackage com.google.inject.spi; import com.google.inject.AbstractModule; import com.google.inject.Binding; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.TypeLiteral; import junit.framework.TestCase; import java.util.Map; /** * @author sberlin@gmail.com (Sam Berlin) */ public class InjectorSpiTest extends TestCase { public void testExistingBinding() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Foo.class); bind(Baz.class); } }); // Sanity check -- ensure we return the proper binding for all existing bindings. for(Map.Entry, Binding> entry : injector.getAllBindings().entrySet()) { assertSame(entry.getValue(), injector.getExistingBinding(entry.getKey())); } // Now run through specifics... Binding binding; // 1) non-Provider Foo.class binding = injector.getExistingBinding(Key.get(Foo.class)); assertNotNull(binding); assertEquals(Foo.class, binding.getKey().getTypeLiteral().getRawType()); // 2) Provider class (should already exist, because Baz @Injects it). // the assertTrue is a bit stricter than necessary, but makes sure this works for pre-existing Provider bindings assertTrue(injector.getAllBindings().containsKey(Key.get(new TypeLiteral>() {}))); binding = injector.getExistingBinding(Key.get(new TypeLiteral>() {})); assertNotNull(binding); assertEquals(Provider.class, binding.getKey().getTypeLiteral().getRawType()); assertEquals(Foo.class, ((Provider)binding.getProvider().get()).get().getClass()); // 3) non-Provider Baz.class binding = injector.getExistingBinding(Key.get(Baz.class)); assertNotNull(binding); assertEquals(Baz.class, binding.getKey().getTypeLiteral().getRawType()); // 4) Provider class (should not already exist, because nothing used it yet). // the assertFalse is a bit stricter than necessary, but makes sure this works for non-pre-existing Provider bindings assertFalse(injector.getAllBindings().containsKey(Key.get(new TypeLiteral>() {}))); binding = injector.getExistingBinding(Key.get(new TypeLiteral>() {})); assertNotNull(binding); assertEquals(Provider.class, binding.getKey().getTypeLiteral().getRawType()); assertEquals(Baz.class, ((Provider)binding.getProvider().get()).get().getClass()); // 5) non-Provider Bar, doesn't exist. assertNull(injector.getExistingBinding(Key.get(Bar.class))); // 6) Provider Bar, doesn't exist. assertNull(injector.getExistingBinding(Key.get(new TypeLiteral>() {}))); } private static class Foo {} private static class Bar {} private static class Baz { @SuppressWarnings("unused") @Inject Provider fooP; } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/spi/InjectionPointTest.java0000644000175000017500000003266411704661106027074 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.inject.Asserts.assertContains; import static com.google.inject.Asserts.assertEqualsBothWays; import static com.google.inject.Asserts.assertNotSerializable; import static com.google.inject.name.Names.named; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.inject.ConfigurationException; import com.google.inject.Inject; import com.google.inject.Key; import com.google.inject.TypeLiteral; import com.google.inject.internal.ErrorsException; import com.google.inject.name.Named; import com.google.inject.spi.InjectionPoint.Signature; import junit.framework.Assert; import junit.framework.TestCase; import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; /** * @author jessewilson@google.com (Jesse Wilson) */ public class InjectionPointTest extends TestCase { public @Inject @Named("a") String foo; public @Inject void bar(@Named("b") String param) {} public static class Constructable { @Inject public Constructable(@Named("c") String param) {} } public void testFieldInjectionPoint() throws NoSuchFieldException, IOException, ErrorsException { TypeLiteral typeLiteral = TypeLiteral.get(getClass()); Field fooField = getClass().getField("foo"); InjectionPoint injectionPoint = new InjectionPoint(typeLiteral, fooField, false); assertSame(fooField, injectionPoint.getMember()); assertFalse(injectionPoint.isOptional()); assertEquals(getClass().getName() + ".foo", injectionPoint.toString()); assertEqualsBothWays(injectionPoint, new InjectionPoint(typeLiteral, fooField, false)); assertNotSerializable(injectionPoint); Dependency dependency = getOnlyElement(injectionPoint.getDependencies()); assertEquals("Key[type=java.lang.String, annotation=@com.google.inject.name.Named(value=a)]@" + getClass().getName() + ".foo", dependency.toString()); assertEquals(fooField, dependency.getInjectionPoint().getMember()); assertEquals(-1, dependency.getParameterIndex()); Assert.assertEquals(Key.get(String.class, named("a")), dependency.getKey()); assertEquals(false, dependency.isNullable()); assertNotSerializable(dependency); assertEqualsBothWays(dependency, getOnlyElement(new InjectionPoint(typeLiteral, fooField, false).getDependencies())); } public void testMethodInjectionPoint() throws Exception { TypeLiteral typeLiteral = TypeLiteral.get(getClass()); Method barMethod = getClass().getMethod("bar", String.class); InjectionPoint injectionPoint = new InjectionPoint(typeLiteral, barMethod, false); assertSame(barMethod, injectionPoint.getMember()); assertFalse(injectionPoint.isOptional()); assertEquals(getClass().getName() + ".bar()", injectionPoint.toString()); assertEqualsBothWays(injectionPoint, new InjectionPoint(typeLiteral, barMethod, false)); assertNotSerializable(injectionPoint); Dependency dependency = getOnlyElement(injectionPoint.getDependencies()); assertEquals("Key[type=java.lang.String, annotation=@com.google.inject.name.Named(value=b)]@" + getClass().getName() + ".bar()[0]", dependency.toString()); assertEquals(barMethod, dependency.getInjectionPoint().getMember()); assertEquals(0, dependency.getParameterIndex()); assertEquals(Key.get(String.class, named("b")), dependency.getKey()); assertEquals(false, dependency.isNullable()); assertNotSerializable(dependency); assertEqualsBothWays(dependency, getOnlyElement(new InjectionPoint(typeLiteral, barMethod, false).getDependencies())); } public void testConstructorInjectionPoint() throws NoSuchMethodException, IOException, ErrorsException { TypeLiteral typeLiteral = TypeLiteral.get(Constructable.class); Constructor constructor = Constructable.class.getConstructor(String.class); InjectionPoint injectionPoint = new InjectionPoint(typeLiteral, constructor); assertSame(constructor, injectionPoint.getMember()); assertFalse(injectionPoint.isOptional()); assertEquals(Constructable.class.getName() + ".()", injectionPoint.toString()); assertEqualsBothWays(injectionPoint, new InjectionPoint(typeLiteral, constructor)); assertNotSerializable(injectionPoint); Dependency dependency = getOnlyElement(injectionPoint.getDependencies()); assertEquals("Key[type=java.lang.String, annotation=@com.google.inject.name.Named(value=c)]@" + Constructable.class.getName() + ".()[0]", dependency.toString()); assertEquals(constructor, dependency.getInjectionPoint().getMember()); assertEquals(0, dependency.getParameterIndex()); assertEquals(Key.get(String.class, named("c")), dependency.getKey()); assertEquals(false, dependency.isNullable()); assertNotSerializable(dependency); assertEqualsBothWays(dependency, getOnlyElement(new InjectionPoint(typeLiteral, constructor).getDependencies())); } public void testUnattachedDependency() throws IOException { Dependency dependency = Dependency.get(Key.get(String.class, named("d"))); assertEquals("Key[type=java.lang.String, annotation=@com.google.inject.name.Named(value=d)]", dependency.toString()); assertNull(dependency.getInjectionPoint()); assertEquals(-1, dependency.getParameterIndex()); assertEquals(Key.get(String.class, named("d")), dependency.getKey()); assertEquals(true, dependency.isNullable()); assertNotSerializable(dependency); assertEqualsBothWays(dependency, Dependency.get(Key.get(String.class, named("d")))); } public void testForConstructor() throws NoSuchMethodException { Constructor constructor = HashSet.class.getConstructor(); TypeLiteral> hashSet = new TypeLiteral>() {}; InjectionPoint injectionPoint = InjectionPoint.forConstructor(constructor, hashSet); assertSame(constructor, injectionPoint.getMember()); assertEquals(ImmutableList.of(), injectionPoint.getDependencies()); assertFalse(injectionPoint.isOptional()); try { InjectionPoint.forConstructor(constructor, new TypeLiteral>() {}); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "java.util.LinkedHashSet", " does not define java.util.HashSet.()", " while locating java.util.LinkedHashSet"); } try { InjectionPoint.forConstructor((Constructor) constructor, new TypeLiteral>() {}); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "java.util.Set", " does not define java.util.HashSet.()", " while locating java.util.Set"); } } public void testForConstructorOf() { InjectionPoint injectionPoint = InjectionPoint.forConstructorOf(Constructable.class); assertEquals(Constructable.class.getName() + ".()", injectionPoint.toString()); } public void testAddForInstanceMethodsAndFields() throws Exception { Method instanceMethod = HasInjections.class.getMethod("instanceMethod", String.class); Field instanceField = HasInjections.class.getField("instanceField"); TypeLiteral type = TypeLiteral.get(HasInjections.class); assertEquals(ImmutableSet.of( new InjectionPoint(type, instanceMethod, false), new InjectionPoint(type, instanceField, false)), InjectionPoint.forInstanceMethodsAndFields(HasInjections.class)); } public void testAddForStaticMethodsAndFields() throws Exception { Method staticMethod = HasInjections.class.getMethod("staticMethod", String.class); Field staticField = HasInjections.class.getField("staticField"); Set injectionPoints = InjectionPoint.forStaticMethodsAndFields( HasInjections.class); assertEquals(ImmutableSet.of( new InjectionPoint(TypeLiteral.get(HasInjections.class), staticMethod, false), new InjectionPoint(TypeLiteral.get(HasInjections.class), staticField, false)), injectionPoints); } static class HasInjections { @Inject public static void staticMethod(@Named("a") String a) {} @Inject @Named("c") public static String staticField; @Inject public void instanceMethod(@Named("d") String d) {} @Inject @Named("f") public String instanceField; } public void testAddForParameterizedInjections() { TypeLiteral type = new TypeLiteral>() {}; InjectionPoint constructor = InjectionPoint.forConstructorOf(type); assertEquals(new Key>() {}, getOnlyElement(constructor.getDependencies()).getKey()); InjectionPoint field = getOnlyElement(InjectionPoint.forInstanceMethodsAndFields(type)); assertEquals(new Key>() {}, getOnlyElement(field.getDependencies()).getKey()); } static class ParameterizedInjections { @Inject Set setOfTees; @Inject public ParameterizedInjections(Map map) {} } public void testSignature() throws Exception { Signature fooA = new Signature(Foo.class.getDeclaredMethod( "a", String.class, int.class)); Signature fooB = new Signature(Foo.class.getDeclaredMethod("b")); Signature barA = new Signature(Bar.class.getDeclaredMethod( "a", String.class, int.class)); Signature barB = new Signature(Bar.class.getDeclaredMethod("b")); assertEquals(fooA.hashCode(), barA.hashCode()); assertEquals(fooB.hashCode(), barB.hashCode()); assertEquals(fooA, barA); assertEquals(fooB, barB); } static class Foo { void a(String s, int i) {} int b() { return 0; } } static class Bar { public void a(String s, int i) {} void b() {} } public void testOverrideBehavior() { Set points; points = InjectionPoint.forInstanceMethodsAndFields(Super.class); assertEquals(points.toString(), 6, points.size()); assertPoints(points, Super.class, "atInject", "gInject", "privateAtAndPublicG", "privateGAndPublicAt", "atFirstThenG", "gFirstThenAt"); points = InjectionPoint.forInstanceMethodsAndFields(Sub.class); assertEquals(points.toString(), 7, points.size()); // Superclass will always have is private members injected, // and 'gInject' was last @Injected in Super, so that remains the owner assertPoints(points, Super.class, "privateAtAndPublicG", "privateGAndPublicAt", "gInject"); // Subclass also has the "private" methods, but they do not override // the superclass' methods, and it now owns the inject2 methods. assertPoints(points, Sub.class, "privateAtAndPublicG", "privateGAndPublicAt", "atFirstThenG", "gFirstThenAt"); points = InjectionPoint.forInstanceMethodsAndFields(SubSub.class); assertEquals(points.toString(), 6, points.size()); // Superclass still has all the injection points it did before.. assertPoints(points, Super.class, "privateAtAndPublicG", "privateGAndPublicAt", "gInject"); // Subclass is missing the privateGAndPublicAt because it first became public with // javax.inject.Inject and was overrode without an annotation, which means it // disappears. (It was guice @Inject in Super, but it was private there, so it doesn't // effect the annotations of the subclasses.) assertPoints(points, Sub.class, "privateAtAndPublicG", "atFirstThenG", "gFirstThenAt"); } private void assertPoints(Iterable points, Class clazz, String... methodNames) { Set methods = new HashSet(); for(InjectionPoint point : points) { if(point.getDeclaringType().getRawType() == clazz) { methods.add(point.getMember().getName()); } } assertEquals(points.toString(), ImmutableSet.copyOf(methodNames), methods); } static class Super { @javax.inject.Inject public void atInject() {} @com.google.inject.Inject public void gInject() {} @javax.inject.Inject private void privateAtAndPublicG() {} @com.google.inject.Inject private void privateGAndPublicAt() {} @javax.inject.Inject public void atFirstThenG() {} @com.google.inject.Inject public void gFirstThenAt() {} } static class Sub extends Super { public void atInject() {} public void gInject() {} @com.google.inject.Inject public void privateAtAndPublicG() {} @javax.inject.Inject public void privateGAndPublicAt() {} @com.google.inject.Inject public void atFirstThenG() {} @javax.inject.Inject public void gFirstThenAt() {} } static class SubSub extends Sub { public void privateAtAndPublicG() {} public void privateGAndPublicAt() {} public void atFirstThenG() {} public void gFirstThenAt() {} } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/spi/HasDependenciesTest.java0000644000175000017500000000635311704661106027156 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Provider; import junit.framework.TestCase; import java.util.Set; /** * @author jessewilson@google.com (Jesse Wilson) */ public class HasDependenciesTest extends TestCase { /** * When an instance implements HasDependencies, the injected dependencies aren't used. */ public void testInstanceWithDependencies() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(A.class).toInstance(new AWithDependencies()); } }); InstanceBinding binding = (InstanceBinding) injector.getBinding(A.class); assertEquals(ImmutableSet.>of(Dependency.get(Key.get(Integer.class))), binding.getDependencies()); } public void testInstanceWithoutDependencies() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(A.class).toInstance(new A()); } }); InstanceBinding binding = (InstanceBinding) injector.getBinding(A.class); Dependency onlyDependency = Iterables.getOnlyElement(binding.getDependencies()); assertEquals(Key.get(String.class), onlyDependency.getKey()); } public void testProvider() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(A.class).toProvider(new ProviderOfA()); } }); ProviderInstanceBinding binding = (ProviderInstanceBinding) injector.getBinding(A.class); Dependency onlyDependency = Iterables.getOnlyElement(binding.getDependencies()); assertEquals(Key.get(String.class), onlyDependency.getKey()); } static class A { @Inject void injectUnusedDependencies(String unused) {} } static class ProviderOfA implements Provider { @Inject void injectUnusedDependencies(String unused) {} public A get() { throw new UnsupportedOperationException(); } } static class AWithDependencies extends A implements HasDependencies { public Set> getDependencies() { return ImmutableSet.>of(Dependency.get(Key.get(Integer.class))); } } static class ProviderOfAWithDependencies extends ProviderOfA implements ProviderWithDependencies { public Set> getDependencies() { return ImmutableSet.>of(Dependency.get(Key.get(Integer.class))); } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/spi/FailingTargetVisitor.java0000644000175000017500000000161411704661106027367 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binding; import junit.framework.AssertionFailedError; public class FailingTargetVisitor extends DefaultBindingTargetVisitor { @Override protected Void visitOther(Binding binding) { throw new AssertionFailedError(); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/spi/FailingElementVisitor.java0000644000175000017500000000151211704661106027527 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import junit.framework.AssertionFailedError; class FailingElementVisitor extends DefaultElementVisitor { @Override protected Void visitOther(Element element) { throw new AssertionFailedError(); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/spi/FailingBindingScopingVisitor.java0000644000175000017500000000225611704661106031041 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Scope; import junit.framework.AssertionFailedError; import java.lang.annotation.Annotation; public class FailingBindingScopingVisitor implements BindingScopingVisitor { public Void visitEagerSingleton() { throw new AssertionFailedError(); } public Void visitScope(Scope scope) { throw new AssertionFailedError(); } public Void visitScopeAnnotation(Class scopeAnnotation) { throw new AssertionFailedError(); } public Void visitNoScoping() { throw new AssertionFailedError(); } }sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/spi/ElementsTest.java0000644000175000017500000012554111704661106025711 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.inject.Asserts.assertContains; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.inject.AbstractModule; import com.google.inject.Binding; import com.google.inject.BindingAnnotation; import com.google.inject.Inject; import com.google.inject.Key; import com.google.inject.MembersInjector; import com.google.inject.Module; import com.google.inject.PrivateBinder; import com.google.inject.Provider; import com.google.inject.Scope; import com.google.inject.Scopes; import com.google.inject.Singleton; import com.google.inject.Stage; import com.google.inject.TypeLiteral; import com.google.inject.binder.AnnotatedBindingBuilder; import com.google.inject.binder.AnnotatedConstantBindingBuilder; import com.google.inject.binder.ConstantBindingBuilder; import com.google.inject.binder.ScopedBindingBuilder; import com.google.inject.matcher.Matcher; import com.google.inject.matcher.Matchers; import com.google.inject.name.Named; import com.google.inject.name.Names; import com.google.inject.util.Providers; import junit.framework.TestCase; import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; /** * @author jessewilson@google.com (Jesse Wilson) */ public class ElementsTest extends TestCase { // Binder fidelity tests public void testAddMessageErrorCommand() { checkModule( new AbstractModule() { protected void configure() { addError("Message %s %d %s", "A", 5, "C"); } }, new FailingElementVisitor() { @Override public Void visit(Message command) { assertEquals("Message A 5 C", command.getMessage()); assertNull(command.getCause()); assertContains(command.getSources().toString(), ElementsTest.class.getName(), ".configure(ElementsTest.java:"); assertContains(command.getSource(), "ElementsTest.java"); return null; } } ); } public void testAddThrowableErrorCommand() { checkModule( new AbstractModule() { protected void configure() { addError(new Exception("A")); } }, new FailingElementVisitor() { @Override public Void visit(Message command) { assertEquals("A", command.getCause().getMessage()); assertEquals(command.getMessage(), "An exception was caught and reported. Message: A"); assertContains(command.getSource(), "ElementsTest.java"); return null; } } ); } public void testErrorsAddedWhenExceptionsAreThrown() { checkModule( new AbstractModule() { protected void configure() { install(new AbstractModule() { protected void configure() { throw new RuntimeException("Throwing RuntimeException in AbstractModule.configure()."); } }); addError("Code after the exception still gets executed"); } }, new FailingElementVisitor() { @Override public Void visit(Message command) { assertEquals("Throwing RuntimeException in AbstractModule.configure().", command.getCause().getMessage()); return null; } }, new FailingElementVisitor() { @Override public Void visit(Message command) { assertEquals("Code after the exception still gets executed", command.getMessage()); return null; } } ); } private T getInstance(Binding binding) { return binding.acceptTargetVisitor(Elements.getInstanceVisitor()); } public void testBindConstantAnnotations() { checkModule( new AbstractModule() { protected void configure() { bindConstant().annotatedWith(SampleAnnotation.class).to("A"); bindConstant().annotatedWith(Names.named("Bee")).to("B"); } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof InstanceBinding); assertEquals(Key.get(String.class, SampleAnnotation.class), command.getKey()); assertEquals("A", getInstance(command)); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof InstanceBinding); assertEquals(Key.get(String.class, Names.named("Bee")), command.getKey()); assertEquals("B", getInstance(command)); return null; } } ); } public void testBindConstantTypes() { checkModule( new AbstractModule() { protected void configure() { bindConstant().annotatedWith(Names.named("String")).to("A"); bindConstant().annotatedWith(Names.named("int")).to(2); bindConstant().annotatedWith(Names.named("long")).to(3L); bindConstant().annotatedWith(Names.named("boolean")).to(false); bindConstant().annotatedWith(Names.named("double")).to(5.0d); bindConstant().annotatedWith(Names.named("float")).to(6.0f); bindConstant().annotatedWith(Names.named("short")).to((short) 7); bindConstant().annotatedWith(Names.named("char")).to('h'); bindConstant().annotatedWith(Names.named("byte")).to((byte) 8); bindConstant().annotatedWith(Names.named("Class")).to(Iterator.class); bindConstant().annotatedWith(Names.named("Enum")).to(CoinSide.TAILS); } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof InstanceBinding); assertEquals(Key.get(String.class, Names.named("String")), command.getKey()); assertEquals("A", getInstance(command)); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof InstanceBinding); assertEquals(Key.get(Integer.class, Names.named("int")), command.getKey()); assertEquals(2, getInstance(command)); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof InstanceBinding); assertEquals(Key.get(Long.class, Names.named("long")), command.getKey()); assertEquals(3L, getInstance(command)); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof InstanceBinding); assertEquals(Key.get(Boolean.class, Names.named("boolean")), command.getKey()); assertEquals(false, getInstance(command)); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof InstanceBinding); assertEquals(Key.get(Double.class, Names.named("double")), command.getKey()); assertEquals(5.0d, getInstance(command)); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof InstanceBinding); assertEquals(Key.get(Float.class, Names.named("float")), command.getKey()); assertEquals(6.0f, getInstance(command)); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof InstanceBinding); assertEquals(Key.get(Short.class, Names.named("short")), command.getKey()); assertEquals((short) 7, getInstance(command)); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof InstanceBinding); assertEquals(Key.get(Character.class, Names.named("char")), command.getKey()); assertEquals('h', getInstance(command)); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof InstanceBinding); assertEquals(Key.get(Byte.class, Names.named("byte")), command.getKey()); assertEquals((byte) 8, getInstance(command)); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof InstanceBinding); assertEquals(Key.get(Class.class, Names.named("Class")), command.getKey()); assertEquals(Iterator.class, getInstance(command)); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof InstanceBinding); assertEquals(Key.get(CoinSide.class, Names.named("Enum")), command.getKey()); assertEquals(CoinSide.TAILS, getInstance(command)); return null; } } ); } public void testBindKeysNoAnnotations() { FailingElementVisitor keyChecker = new FailingElementVisitor() { @Override public Void visit(Binding command) { assertEquals(Key.get(String.class), command.getKey()); return null; } }; checkModule( new AbstractModule() { protected void configure() { bind(String.class).toInstance("A"); bind(new TypeLiteral() {}).toInstance("B"); bind(Key.get(String.class)).toInstance("C"); } }, keyChecker, keyChecker, keyChecker ); } public void testBindKeysWithAnnotationType() { FailingElementVisitor annotationChecker = new FailingElementVisitor() { @Override public Void visit(Binding command) { assertEquals(Key.get(String.class, SampleAnnotation.class), command.getKey()); return null; } }; checkModule( new AbstractModule() { protected void configure() { bind(String.class).annotatedWith(SampleAnnotation.class).toInstance("A"); bind(new TypeLiteral() {}).annotatedWith(SampleAnnotation.class).toInstance("B"); } }, annotationChecker, annotationChecker ); } public void testBindKeysWithAnnotationInstance() { FailingElementVisitor annotationChecker = new FailingElementVisitor() { @Override public Void visit(Binding command) { assertEquals(Key.get(String.class, Names.named("a")), command.getKey()); return null; } }; checkModule( new AbstractModule() { protected void configure() { bind(String.class).annotatedWith(Names.named("a")).toInstance("B"); bind(new TypeLiteral() {}).annotatedWith(Names.named("a")).toInstance("C"); } }, annotationChecker, annotationChecker ); } public void testBindToProvider() { final Provider aProvider = new Provider() { public String get() { return "A"; } }; checkModule( new AbstractModule() { protected void configure() { bind(String.class).toProvider(aProvider); bind(List.class).toProvider(ListProvider.class); bind(Collection.class).toProvider(Key.get(ListProvider.class)); bind(Iterable.class).toProvider(new TypeLiteral>() {}); } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof ProviderInstanceBinding); assertEquals(Key.get(String.class), command.getKey()); command.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit( ProviderInstanceBinding binding) { assertSame(aProvider, binding.getProviderInstance()); return null; } }); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof ProviderKeyBinding); assertEquals(Key.get(List.class), command.getKey()); command.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit(ProviderKeyBinding binding) { assertEquals(Key.get(ListProvider.class), binding.getProviderKey()); return null; } }); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof ProviderKeyBinding); assertEquals(Key.get(Collection.class), command.getKey()); command.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit(ProviderKeyBinding binding) { assertEquals(Key.get(ListProvider.class), binding.getProviderKey()); return null; } }); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof ProviderKeyBinding); assertEquals(Key.get(Iterable.class), command.getKey()); command.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit(ProviderKeyBinding binding) { assertEquals(new Key>() {}, binding.getProviderKey()); return null; } }); return null; } } ); } public void testBindToLinkedBinding() { checkModule( new AbstractModule() { protected void configure() { bind(List.class).to(ArrayList.class); bind(Map.class).to(new TypeLiteral>() {}); bind(Set.class).to(Key.get(TreeSet.class, SampleAnnotation.class)); } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof LinkedKeyBinding); assertEquals(Key.get(List.class), command.getKey()); command.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit(LinkedKeyBinding binding) { assertEquals(Key.get(ArrayList.class), binding.getLinkedKey()); return null; } }); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof LinkedKeyBinding); assertEquals(Key.get(Map.class), command.getKey()); command.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit(LinkedKeyBinding binding) { assertEquals(Key.get(new TypeLiteral>() {}), binding.getLinkedKey()); return null; } }); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof LinkedKeyBinding); assertEquals(Key.get(Set.class), command.getKey()); command.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit(LinkedKeyBinding binding) { assertEquals(Key.get(TreeSet.class, SampleAnnotation.class), binding.getLinkedKey()); return null; } }); return null; } } ); } public void testBindToInstance() { checkModule( new AbstractModule() { protected void configure() { bind(String.class).toInstance("A"); } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertTrue(command instanceof InstanceBinding); assertEquals(Key.get(String.class), command.getKey()); assertEquals("A", getInstance(command)); return null; } } ); } public void testBindInScopes() { checkModule( new AbstractModule() { protected void configure() { bind(String.class); bind(List.class).to(ArrayList.class).in(Scopes.SINGLETON); bind(Map.class).to(HashMap.class).in(Singleton.class); bind(Set.class).to(TreeSet.class).asEagerSingleton(); } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertEquals(Key.get(String.class), command.getKey()); command.acceptScopingVisitor(new FailingBindingScopingVisitor() { @Override public Void visitNoScoping() { return null; } }); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertEquals(Key.get(List.class), command.getKey()); command.acceptScopingVisitor(new FailingBindingScopingVisitor() { @Override public Void visitScope(Scope scope) { assertEquals(Scopes.SINGLETON, scope); return null; } }); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertEquals(Key.get(Map.class), command.getKey()); command.acceptScopingVisitor(new FailingBindingScopingVisitor() { @Override public Void visitScopeAnnotation(Class annotation) { assertEquals(Singleton.class, annotation); return null; } }); return null; } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { assertEquals(Key.get(Set.class), command.getKey()); command.acceptScopingVisitor(new FailingBindingScopingVisitor() { public Void visitEagerSingleton() { return null; } }); return null; } } ); } public void testBindToInstanceInScope() { checkModule( new AbstractModule() { protected void configure() { AnnotatedBindingBuilder b = bind(String.class); b.toInstance("A"); b.in(Singleton.class); } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { return null; } }, new FailingElementVisitor() { @Override public Void visit(Message command) { assertEquals("Setting the scope is not permitted when binding to a single instance.", command.getMessage()); assertNull(command.getCause()); assertContains(command.getSource(), "ElementsTest.java"); return null; } } ); } public void testBindToInstanceScope() { checkModule( new AbstractModule() { protected void configure() { bind(String.class).toInstance("A"); } }, new FailingElementVisitor() { @Override public Void visit(Binding binding) { assertEquals(Key.get(String.class), binding.getKey()); binding.acceptScopingVisitor(new FailingBindingScopingVisitor() { public Void visitEagerSingleton() { return null; } }); return null; } } ); } /*if[AOP]*/ public void testBindIntercepor() { final Matcher classMatcher = Matchers.subclassesOf(List.class); final Matcher methodMatcher = Matchers.any(); final org.aopalliance.intercept.MethodInterceptor methodInterceptor = new org.aopalliance.intercept.MethodInterceptor() { public Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation) { return null; } }; checkModule( new AbstractModule() { protected void configure() { bindInterceptor(classMatcher, methodMatcher, methodInterceptor); } }, new FailingElementVisitor() { @Override public Void visit(InterceptorBinding command) { assertSame(classMatcher, command.getClassMatcher()); assertSame(methodMatcher, command.getMethodMatcher()); assertEquals(Arrays.asList(methodInterceptor), command.getInterceptors()); return null; } } ); } /*end[AOP]*/ public void testBindScope() { checkModule( new AbstractModule() { protected void configure() { bindScope(SampleAnnotation.class, Scopes.NO_SCOPE); } }, new FailingElementVisitor() { @Override public Void visit(ScopeBinding command) { assertSame(SampleAnnotation.class, command.getAnnotationType()); assertSame(Scopes.NO_SCOPE, command.getScope()); return null; } } ); } public void testBindListener() { final Matcher typeMatcher = Matchers.only(TypeLiteral.get(String.class)); final TypeListener listener = new TypeListener() { public void hear(TypeLiteral type, TypeEncounter encounter) { throw new UnsupportedOperationException(); } }; checkModule( new AbstractModule() { protected void configure() { bindListener(typeMatcher, listener); } }, new FailingElementVisitor() { @Override public Void visit(TypeListenerBinding binding) { assertSame(typeMatcher, binding.getTypeMatcher()); assertSame(listener, binding.getListener()); return null; } } ); } public void testConvertToTypes() { final TypeConverter typeConverter = new TypeConverter() { public Object convert(String value, TypeLiteral toType) { return value; } }; checkModule( new AbstractModule() { protected void configure() { convertToTypes(Matchers.any(), typeConverter); } }, new FailingElementVisitor() { @Override public Void visit(TypeConverterBinding command) { assertSame(typeConverter, command.getTypeConverter()); assertSame(Matchers.any(), command.getTypeMatcher()); return null; } } ); } public void testGetProvider() { checkModule( new AbstractModule() { protected void configure() { Provider keyGetProvider = getProvider(Key.get(String.class, SampleAnnotation.class)); try { keyGetProvider.get(); } catch (IllegalStateException e) { assertEquals("This Provider cannot be used until the Injector has been created.", e.getMessage()); } Provider typeGetProvider = getProvider(String.class); try { typeGetProvider.get(); } catch (IllegalStateException e) { assertEquals("This Provider cannot be used until the Injector has been created.", e.getMessage()); } } }, new FailingElementVisitor() { @Override public Void visit(ProviderLookup command) { assertEquals(Key.get(String.class, SampleAnnotation.class), command.getKey()); assertNull(command.getDelegate()); return null; } }, new FailingElementVisitor() { @Override public Void visit(ProviderLookup command) { assertEquals(Key.get(String.class), command.getKey()); assertNull(command.getDelegate()); return null; } } ); } public void testElementInitialization() { final AtomicReference> providerFromBinder = new AtomicReference>(); final AtomicReference> membersInjectorFromBinder = new AtomicReference>(); final AtomicReference lastInjected = new AtomicReference(); final MembersInjector stringInjector = new MembersInjector() { public void injectMembers(String instance) { lastInjected.set(instance); } }; checkModule( new AbstractModule() { protected void configure() { providerFromBinder.set(getProvider(String.class)); membersInjectorFromBinder.set(getMembersInjector(String.class)); } }, new FailingElementVisitor() { public Void visit(ProviderLookup providerLookup) { @SuppressWarnings("unchecked") // we know that T is a String here ProviderLookup stringLookup = (ProviderLookup) providerLookup; stringLookup.initializeDelegate(Providers.of("out")); assertEquals("out", providerFromBinder.get().get()); return null; } }, new FailingElementVisitor() { @Override public Void visit(MembersInjectorLookup lookup) { @SuppressWarnings("unchecked") // we know that T is a String here MembersInjectorLookup stringLookup = (MembersInjectorLookup) lookup; stringLookup.initializeDelegate(stringInjector); membersInjectorFromBinder.get().injectMembers("in"); assertEquals("in", lastInjected.get()); return null; } }); } public void testGetMembersInjector() { checkModule( new AbstractModule() { protected void configure() { MembersInjector> typeMembersInjector = getMembersInjector(new TypeLiteral>() {}); try { typeMembersInjector.injectMembers(new A()); } catch (IllegalStateException e) { assertEquals( "This MembersInjector cannot be used until the Injector has been created.", e.getMessage()); } MembersInjector classMembersInjector = getMembersInjector(String.class); try { classMembersInjector.injectMembers("hello"); } catch (IllegalStateException e) { assertEquals( "This MembersInjector cannot be used until the Injector has been created.", e.getMessage()); } } }, new FailingElementVisitor() { @Override public Void visit(MembersInjectorLookup command) { assertEquals(new TypeLiteral>() {}, command.getType()); assertNull(command.getDelegate()); return null; } }, new FailingElementVisitor() { @Override public Void visit(MembersInjectorLookup command) { assertEquals(TypeLiteral.get(String.class), command.getType()); assertNull(command.getDelegate()); return null; } } ); } public void testRequestInjection() { final Object firstObject = new Object(); final Object secondObject = new Object(); checkModule( new AbstractModule() { protected void configure() { requestInjection(firstObject); requestInjection(secondObject); } }, new FailingElementVisitor() { @Override public Void visit(InjectionRequest command) { assertEquals(firstObject, command.getInstance()); return null; } }, new FailingElementVisitor() { @Override public Void visit(InjectionRequest command) { assertEquals(secondObject, command.getInstance()); return null; } } ); } public void testRequestStaticInjection() { checkModule( new AbstractModule() { protected void configure() { requestStaticInjection(ArrayList.class); } }, new FailingElementVisitor() { @Override public Void visit(StaticInjectionRequest command) { assertEquals(ArrayList.class, command.getType()); return null; } } ); } public void testNewPrivateBinder() { final Key collection = Key.get(Collection.class, SampleAnnotation.class); final Key arrayList = Key.get(ArrayList.class); final ImmutableSet> collections = ImmutableSet.>of(arrayList, collection); final Key a = Key.get(String.class, Names.named("a")); final Key b = Key.get(String.class, Names.named("b")); final ImmutableSet> ab = ImmutableSet.of(a, b); checkModule( new AbstractModule() { protected void configure() { PrivateBinder one = binder().newPrivateBinder(); one.expose(ArrayList.class); one.expose(Collection.class).annotatedWith(SampleAnnotation.class); one.bind(List.class).to(ArrayList.class); PrivateBinder two = binder().withSource("1 ElementsTest.java") .newPrivateBinder().withSource("2 ElementsTest.java"); two.expose(String.class).annotatedWith(Names.named("a")); two.expose(b); two.bind(List.class).to(ArrayList.class); } }, new FailingElementVisitor() { @Override public Void visit(PrivateElements one) { assertEquals(collections, one.getExposedKeys()); checkElements(one.getElements(), new FailingElementVisitor() { @Override public Void visit(Binding binding) { assertEquals(Key.get(List.class), binding.getKey()); return null; } } ); return null; } }, new FailingElementVisitor() { @Override public Void visit(PrivateElements two) { assertEquals(ab, two.getExposedKeys()); assertEquals("1 ElementsTest.java", two.getSource()); checkElements(two.getElements(), new FailingElementVisitor() { @Override public Void visit(Binding binding) { assertEquals("2 ElementsTest.java", binding.getSource()); assertEquals(Key.get(List.class), binding.getKey()); return null; } } ); return null; } } ); } public void testBindWithMultipleAnnotationsAddsError() { checkModule( new AbstractModule() { protected void configure() { AnnotatedBindingBuilder abb = bind(String.class); abb.annotatedWith(SampleAnnotation.class); abb.annotatedWith(Names.named("A")); } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { return null; } }, new FailingElementVisitor() { @Override public Void visit(Message command) { assertEquals("More than one annotation is specified for this binding.", command.getMessage()); assertNull(command.getCause()); assertContains(command.getSource(), "ElementsTest.java"); return null; } } ); } public void testBindWithMultipleTargetsAddsError() { checkModule( new AbstractModule() { protected void configure() { AnnotatedBindingBuilder abb = bind(String.class); abb.toInstance("A"); abb.toInstance("B"); } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { return null; } }, new FailingElementVisitor() { @Override public Void visit(Message command) { assertEquals("Implementation is set more than once.", command.getMessage()); assertNull(command.getCause()); assertContains(command.getSource(), "ElementsTest.java"); return null; } } ); } public void testBindWithMultipleScopesAddsError() { checkModule( new AbstractModule() { protected void configure() { ScopedBindingBuilder sbb = bind(List.class).to(ArrayList.class); sbb.in(Scopes.NO_SCOPE); sbb.asEagerSingleton(); } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { return null; } }, new FailingElementVisitor() { @Override public Void visit(Message command) { assertEquals("Scope is set more than once.", command.getMessage()); assertNull(command.getCause()); assertContains(command.getSource(), "ElementsTest.java"); return null; } } ); } public void testBindConstantWithMultipleAnnotationsAddsError() { checkModule( new AbstractModule() { protected void configure() { AnnotatedConstantBindingBuilder cbb = bindConstant(); cbb.annotatedWith(SampleAnnotation.class).to("A"); cbb.annotatedWith(Names.named("A")); } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { return null; } }, new FailingElementVisitor() { @Override public Void visit(Message command) { assertEquals("More than one annotation is specified for this binding.", command.getMessage()); assertNull(command.getCause()); assertContains(command.getSource(), "ElementsTest.java"); return null; } } ); } public void testBindConstantWithMultipleTargetsAddsError() { checkModule( new AbstractModule() { protected void configure() { ConstantBindingBuilder cbb = bindConstant().annotatedWith(SampleAnnotation.class); cbb.to("A"); cbb.to("B"); } }, new FailingElementVisitor() { @Override public Void visit(Binding command) { return null; } }, new FailingElementVisitor() { @Override public Void visit(Message message) { assertEquals("Constant value is set more than once.", message.getMessage()); assertNull(message.getCause()); assertContains(message.getSource(), "ElementsTest.java"); return null; } } ); } public void testBindToConstructor() throws NoSuchMethodException, NoSuchFieldException { final Constructor aConstructor = A.class.getDeclaredConstructor(); final Constructor bConstructor = B.class.getDeclaredConstructor(Object.class); final Field field = B.class.getDeclaredField("stage"); checkModule( new AbstractModule() { protected void configure() { bind(A.class).toConstructor(aConstructor); bind(B.class).toConstructor(bConstructor, new TypeLiteral>() {}) .in(Singleton.class); } }, new FailingElementVisitor() { @Override public Void visit(Binding binding) { assertEquals(new Key() {}, binding.getKey()); return binding.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit(ConstructorBinding constructorBinding) { InjectionPoint injectionPoint = constructorBinding.getConstructor(); assertEquals(aConstructor, injectionPoint.getMember()); assertEquals(new TypeLiteral() {}, injectionPoint.getDeclaringType()); return null; } }); } }, new FailingElementVisitor() { @Override public Void visit(Binding binding) { assertEquals(new Key() {}, binding.getKey()); binding.acceptScopingVisitor(new FailingBindingScopingVisitor() { @Override public Void visitScopeAnnotation(Class annotation) { assertEquals(Singleton.class, annotation); return null; } }); binding.acceptTargetVisitor(new FailingTargetVisitor() { @Override public Void visit(ConstructorBinding constructorBinding) { assertEquals(bConstructor, constructorBinding.getConstructor().getMember()); assertEquals(Key.get(Integer.class), getOnlyElement(constructorBinding.getConstructor().getDependencies()).getKey()); assertEquals(field, getOnlyElement(constructorBinding.getInjectableMembers()).getMember()); assertEquals(2, constructorBinding.getDependencies().size()); /*if[AOP]*/ assertEquals(ImmutableMap.of(), constructorBinding.getMethodInterceptors()); /*end[AOP]*/ return null; } }); return null; } } ); } public void testBindToMalformedConstructor() throws NoSuchMethodException, NoSuchFieldException { final Constructor constructor = C.class.getDeclaredConstructor(Integer.class); checkModule( new AbstractModule() { protected void configure() { bind(C.class).toConstructor(constructor); } }, new FailingElementVisitor() { @Override public Void visit(Binding binding) { assertEquals(Key.get(C.class), binding.getKey()); assertTrue(binding instanceof UntargettedBinding); return null; } }, new ExternalFailureVisitor() { @Override public Void visit(Message message) { assertContains(message.getMessage(), C.class.getName() + ".a has more than one annotation ", Named.class.getName(), SampleAnnotation.class.getName()); return null; } }, new ExternalFailureVisitor() { @Override public Void visit(Message message) { assertContains(message.getMessage(), C.class.getName() + ".() has more than one annotation ", Named.class.getName(), SampleAnnotation.class.getName()); return null; } } ); } // Business logic tests public void testModulesAreInstalledAtMostOnce() { final AtomicInteger aConfigureCount = new AtomicInteger(0); final Module a = new AbstractModule() { public void configure() { aConfigureCount.incrementAndGet(); } }; Elements.getElements(a, a); assertEquals(1, aConfigureCount.get()); aConfigureCount.set(0); Module b = new AbstractModule() { protected void configure() { install(a); install(a); } }; Elements.getElements(b); assertEquals(1, aConfigureCount.get()); } /** * Ensures the module performs the commands consistent with {@code visitors}. */ protected void checkModule(Module module, ElementVisitor... visitors) { List elements = Elements.getElements(module); assertEquals(elements.size(), visitors.length); checkElements(elements, visitors); } protected void checkElements(List elements, ElementVisitor... visitors) { for (int i = 0; i < visitors.length; i++) { ElementVisitor visitor = visitors[i]; Element element = elements.get(i); if (!(visitor instanceof ExternalFailureVisitor)) { assertContains(element.getSource().toString(), "ElementsTest.java"); } element.acceptVisitor(visitor); } } private static class ListProvider implements Provider { public List get() { return new ArrayList(); } } private static class TProvider implements Provider { public T get() { return null; } } /** * By extending this interface rather than FailingElementVisitor, the source of the error doesn't * need to contain the string {@code ElementsTest.java}. */ abstract class ExternalFailureVisitor extends FailingElementVisitor {} @Retention(RUNTIME) @Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @BindingAnnotation public @interface SampleAnnotation { } public enum CoinSide { HEADS, TAILS } static class A { @Inject Stage stage; } static class B { @Inject Stage stage; B(T t) {} } static class C { @Inject @Named("foo") @SampleAnnotation String a; C(@Named("bar") @SampleAnnotation Integer b) {} } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/spi/ElementApplyToTest.java0000644000175000017500000000173511704661106027035 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Module; /** * @author jessewilson@google.com (Jesse Wilson) */ public class ElementApplyToTest extends ElementsTest { protected void checkModule(Module module, ElementVisitor... visitors) { // convert from module to elements and back super.checkModule(Elements.getModule(Elements.getElements(module)), visitors); } }sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/spi/BindingTargetVisitorTest.java0000644000175000017500000000233211704661106030226 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binding; import com.google.inject.Guice; import com.google.inject.Injector; import junit.framework.TestCase; /** * Simple little test that should compile. Ensures that wildcards on the * generics are correct. * * @author phopkins@gmail.com */ public class BindingTargetVisitorTest extends TestCase { public void testBindingTargetVisitorTypeTest() throws Exception { Injector injector = Guice.createInjector(); for (Binding binding : injector.getBindings().values()) { binding.acceptTargetVisitor(new DefaultBindingTargetVisitor() {}); } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/name/0000755000175000017500000000000011704661106022547 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/name/NamesTest.java0000644000175000017500000000722411704661106025322 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.name; import static com.google.inject.Asserts.assertEqualWhenReserialized; import static com.google.inject.Asserts.assertEqualsBothWays; import com.google.common.collect.ImmutableMap; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import junit.framework.TestCase; import java.io.IOException; import java.util.Map; import java.util.Properties; /** * @author jessewilson@google.com (Jesse Wilson) */ public class NamesTest extends TestCase { @Named("foo") private String foo; private Named namedFoo; protected void setUp() throws Exception { super.setUp(); namedFoo = getClass().getDeclaredField("foo").getAnnotation(Named.class); } public void testConsistentEqualsAndHashcode() { Named actual = Names.named("foo"); assertEqualsBothWays(namedFoo, actual); assertEquals(namedFoo.toString(), actual.toString()); } public void testNamedIsSerializable() throws IOException { assertEqualWhenReserialized(Names.named("foo")); } public void testBindPropertiesUsingProperties() { final Properties teams = new Properties(); teams.setProperty("SanJose", "Sharks"); teams.setProperty("Edmonton", "Oilers"); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { Names.bindProperties(binder(), teams); } }); assertEquals("Sharks", injector.getInstance(Key.get(String.class, Names.named("SanJose")))); assertEquals("Oilers", injector.getInstance(Key.get(String.class, Names.named("Edmonton")))); } public void testBindPropertiesUsingMap() { final Map properties = ImmutableMap.of( "SanJose", "Sharks", "Edmonton", "Oilers"); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { Names.bindProperties(binder(), properties); } }); assertEquals("Sharks", injector.getInstance(Key.get(String.class, Names.named("SanJose")))); assertEquals("Oilers", injector.getInstance(Key.get(String.class, Names.named("Edmonton")))); } public void testBindPropertiesIncludesInheritedProperties() { Properties defaults = new Properties(); defaults.setProperty("Edmonton", "Eskimos"); defaults.setProperty("Regina", "Pats"); final Properties teams = new Properties(defaults); teams.setProperty("SanJose", "Sharks"); teams.setProperty("Edmonton", "Oilers"); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { Names.bindProperties(binder(), teams); } }); assertEquals("Pats", injector.getInstance(Key.get(String.class, Names.named("Regina")))); assertEquals("Oilers", injector.getInstance(Key.get(String.class, Names.named("Edmonton")))); assertEquals("Sharks", injector.getInstance(Key.get(String.class, Names.named("SanJose")))); try { injector.getInstance(Key.get(String.class, Names.named("Calgary"))); fail(); } catch (RuntimeException expected) { } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/name/NamedEquivalanceTest.java0000644000175000017500000002071111704661106027455 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.name; import static com.google.inject.Asserts.assertContains; import com.google.inject.AbstractModule; import com.google.inject.ConfigurationException; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provides; import junit.framework.TestCase; import java.io.Serializable; import java.lang.annotation.Annotation; import java.util.Properties; /** * Tests that {@code javax.inject.Named} and {@code com.google.inject.name.Named} are completely * interchangeable: bindings for one can be used to inject the other. * * @author cgdecker@gmail.com (Colin Decker) */ public class NamedEquivalanceTest extends TestCase { private static final Module GUICE_BINDING_MODULE = moduleWithAnnotation(Names.named("foo")); private static final Module JSR330_BINDING_MODULE = moduleWithAnnotation(new JsrNamed("foo")); private static final Module GUICE_PROVIDER_METHOD_MODULE = getGuiceBindingProviderMethodModule(); private static final Module JSR330_PROVIDER_METHOD_MODULE = getJsr330BindingProviderMethodModule(); public void testKeysCreatedWithDifferentTypesAreEqual() { assertEquals(keyForAnnotation(new GuiceNamed("foo")), keyForAnnotation(new JsrNamed("foo"))); assertEquals(keyForAnnotation(Names.named("foo")), keyForAnnotation(new GuiceNamed("foo"))); assertEquals(keyForAnnotation(Names.named("foo")), keyForAnnotation(new JsrNamed("foo"))); assertEquals(keyForAnnotationType(com.google.inject.name.Named.class), keyForAnnotationType(javax.inject.Named.class)); } private static Key keyForAnnotation(Annotation annotation) { return Key.get(String.class, annotation); } private static Key keyForAnnotationType(Class annotationType) { return Key.get(String.class, annotationType); } public void testBindingWithNamesCanInjectBothTypes() { assertInjectionsSucceed(GUICE_BINDING_MODULE); } public void testBindingWithJsr330AnnotationCanInjectBothTypes() { assertInjectionsSucceed(JSR330_BINDING_MODULE); } public void testBindingWithGuiceNamedAnnotatedProviderMethodCanInjectBothTypes() { assertInjectionsSucceed(GUICE_PROVIDER_METHOD_MODULE); } public void testBindingWithJsr330NamedAnnotatedProviderMethodCanInjectBothTypes() { assertInjectionsSucceed(JSR330_PROVIDER_METHOD_MODULE); } public void testBindingDifferentTypesWithSameValueIsIgnored() { assertDuplicateBinding(GUICE_BINDING_MODULE, JSR330_BINDING_MODULE, false); assertDuplicateBinding(JSR330_BINDING_MODULE, GUICE_BINDING_MODULE, false); } public void testBindingDifferentTypesWithSameValueIsAnErrorWithProviderMethods() { assertDuplicateBinding(GUICE_PROVIDER_METHOD_MODULE, JSR330_PROVIDER_METHOD_MODULE, true); assertDuplicateBinding(JSR330_PROVIDER_METHOD_MODULE, GUICE_PROVIDER_METHOD_MODULE, true); } public void testBindingDifferentTypesWithSameValueIsAnErrorMixed() { assertDuplicateBinding(GUICE_BINDING_MODULE, JSR330_PROVIDER_METHOD_MODULE, true); assertDuplicateBinding(JSR330_BINDING_MODULE, GUICE_PROVIDER_METHOD_MODULE, true); } public void testMissingBindingForGuiceNamedUsesSameTypeInErrorMessage() { assertMissingBindingErrorMessageUsesType(GuiceNamedClient.class); } public void testMissingBindingForJsr330NamedUsesSameTypeInErrorMessage() { assertMissingBindingErrorMessageUsesType(Jsr330NamedClient.class); } public void testBindPropertiesWorksWithJsr330() { assertInjectionsSucceed(new AbstractModule() { @Override protected void configure() { Properties properties = new Properties(); properties.put("foo", "bar"); Names.bindProperties(binder(), properties); } }); } private static void assertMissingBindingErrorMessageUsesType(Class clientType) { try { Guice.createInjector().getInstance(clientType); fail("should have thrown ConfigurationException"); } catch (ConfigurationException e) { assertContains(e.getMessage(), "No implementation for java.lang.String annotated with @com.google.inject.name.Named(value=foo) was bound."); } } private static void assertDuplicateBinding(Module a, Module b, boolean fails) { try { Guice.createInjector(a, b); if(fails) { fail("should have thrown CreationException"); } } catch (CreationException e) { if(fails) { assertContains(e.getMessage(), "A binding to java.lang.String annotated with @com.google.inject.name.Named(value=foo) was already configured"); } else { throw e; } } } private static Module moduleWithAnnotation(final Annotation annotation) { return new AbstractModule() { @Override protected void configure() { bindConstant().annotatedWith(annotation).to("bar"); } }; } private static void assertInjectionsSucceed(Module module) { Injector injector = Guice.createInjector(module); assertInjected(injector.getInstance(GuiceNamedClient.class), injector .getInstance(Jsr330NamedClient.class)); } private static void assertInjected(GuiceNamedClient guiceClient, Jsr330NamedClient jsr330Client) { assertEquals("bar", guiceClient.foo); assertEquals("bar", jsr330Client.foo); } private static Module getJsr330BindingProviderMethodModule() { return new AbstractModule() { @Override protected void configure() {} @SuppressWarnings("unused") @Provides @javax.inject.Named("foo") String provideFoo() { return "bar"; } }; } private static Module getGuiceBindingProviderMethodModule() { return new AbstractModule() { @Override protected void configure() {} @SuppressWarnings("unused") @Provides @Named("foo") String provideFoo() { return "bar"; } }; } private static class GuiceNamedClient { @Inject @Named("foo") String foo; } private static class Jsr330NamedClient { @Inject @javax.inject.Named("foo") String foo; } private static class JsrNamed implements javax.inject.Named, Serializable { private final String value; public JsrNamed(String value) { this.value = value; } public String value() { return this.value; } public int hashCode() { // This is specified in java.lang.Annotation. return (127 * "value".hashCode()) ^ value.hashCode(); } public boolean equals(Object o) { if (!(o instanceof javax.inject.Named)) { return false; } javax.inject.Named other = (javax.inject.Named) o; return value.equals(other.value()); } public String toString() { return "@" + javax.inject.Named.class.getName() + "(value=" + value + ")"; } public Class annotationType() { return javax.inject.Named.class; } private static final long serialVersionUID = 0; } private static class GuiceNamed implements com.google.inject.name.Named, Serializable { private final String value; public GuiceNamed(String value) { this.value = value; } public String value() { return this.value; } public int hashCode() { // This is specified in java.lang.Annotation. return (127 * "value".hashCode()) ^ value.hashCode(); } public boolean equals(Object o) { if (!(o instanceof com.google.inject.name.Named)) { return false; } com.google.inject.name.Named other = (com.google.inject.name.Named) o; return value.equals(other.value()); } public String toString() { return "@" + com.google.inject.name.Named.class.getName() + "(value=" + value + ")"; } public Class annotationType() { return com.google.inject.name.Named.class; } private static final long serialVersionUID = 0; } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/matcher/0000755000175000017500000000000011704661106023252 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/matcher/MatcherTest.java0000644000175000017500000001567411704661106026355 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.matcher; import static com.google.inject.Asserts.assertEqualWhenReserialized; import static com.google.inject.Asserts.assertEqualsBothWays; import static com.google.inject.matcher.Matchers.annotatedWith; import static com.google.inject.matcher.Matchers.any; import static com.google.inject.matcher.Matchers.identicalTo; import static com.google.inject.matcher.Matchers.inPackage; import static com.google.inject.matcher.Matchers.inSubpackage; import static com.google.inject.matcher.Matchers.not; import static com.google.inject.matcher.Matchers.only; import static com.google.inject.matcher.Matchers.returns; import static com.google.inject.matcher.Matchers.subclassesOf; import com.google.inject.name.Named; import com.google.inject.name.Names; import junit.framework.TestCase; import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.reflect.Method; import java.util.AbstractList; /** * @author crazybob@google.com (Bob Lee) */ public class MatcherTest extends TestCase { public void testAny() { assertTrue(any().matches(null)); assertEquals("any()", any().toString()); assertEqualsBothWays(any(), any()); assertFalse(any().equals(not(any()))); } public void testNot() { assertFalse(not(any()).matches(null)); assertEquals("not(any())", not(any()).toString()); assertEqualsBothWays(not(any()), not(any())); assertFalse(not(any()).equals(any())); } public void testAnd() { assertTrue(any().and(any()).matches(null)); assertFalse(any().and(not(any())).matches(null)); assertEquals("and(any(), any())", any().and(any()).toString()); assertEqualsBothWays(any().and(any()), any().and(any())); assertFalse(any().and(any()).equals(not(any()))); } public void testOr() { assertTrue(any().or(not(any())).matches(null)); assertFalse(not(any()).or(not(any())).matches(null)); assertEquals("or(any(), any())", any().or(any()).toString()); assertEqualsBothWays(any().or(any()), any().or(any())); assertFalse(any().or(any()).equals(not(any()))); } public void testAnnotatedWith() { assertTrue(annotatedWith(Foo.class).matches(Bar.class)); assertFalse(annotatedWith(Foo.class).matches( MatcherTest.class.getMethods()[0])); assertEquals("annotatedWith(Foo.class)", annotatedWith(Foo.class).toString()); assertEqualsBothWays(annotatedWith(Foo.class), annotatedWith(Foo.class)); assertFalse(annotatedWith(Foo.class).equals(annotatedWith(Named.class))); try { annotatedWith(Baz.class); fail(); } catch (IllegalArgumentException expected) { } } public void testSubclassesOf() { assertTrue(subclassesOf(Runnable.class).matches(Runnable.class)); assertTrue(subclassesOf(Runnable.class).matches(MyRunnable.class)); assertFalse(subclassesOf(Runnable.class).matches(Object.class)); assertEquals("subclassesOf(Runnable.class)", subclassesOf(Runnable.class).toString()); assertEqualsBothWays(subclassesOf(Runnable.class), subclassesOf(Runnable.class)); assertFalse(subclassesOf(Runnable.class).equals(subclassesOf(Object.class))); } public void testOnly() { assertTrue(only(1000).matches(1000)); assertFalse(only(1).matches(1000)); assertEquals("only(1)", only(1).toString()); assertEqualsBothWays(only(1), only(1)); assertFalse(only(1).equals(only(2))); } @SuppressWarnings("UnnecessaryBoxing") public void testIdenticalTo() { Object o = new Object(); assertEquals("identicalTo(1)", identicalTo(1).toString()); assertTrue(identicalTo(o).matches(o)); assertFalse(identicalTo(o).matches(new Object())); assertEqualsBothWays(identicalTo(o), identicalTo(o)); assertFalse(identicalTo(1).equals(identicalTo(new Integer(1)))); } public void testInPackage() { Package matchersPackage = Matchers.class.getPackage(); assertEquals("inPackage(com.google.inject.matcher)", inPackage(matchersPackage).toString()); assertTrue(inPackage(matchersPackage).matches(MatcherTest.class)); assertFalse(inPackage(matchersPackage).matches(Object.class)); assertEqualsBothWays(inPackage(matchersPackage), inPackage(matchersPackage)); assertFalse(inPackage(matchersPackage).equals(inPackage(Object.class.getPackage()))); } public void testInSubpackage() { String stringPackageName = String.class.getPackage().getName(); assertEquals("inSubpackage(java.lang)", inSubpackage(stringPackageName).toString()); assertTrue(inSubpackage(stringPackageName).matches(Object.class)); assertTrue(inSubpackage(stringPackageName).matches(Method.class)); assertFalse(inSubpackage(stringPackageName).matches(Matchers.class)); assertFalse(inSubpackage("jav").matches(Object.class)); assertEqualsBothWays(inSubpackage(stringPackageName), inSubpackage(stringPackageName)); assertFalse(inSubpackage(stringPackageName).equals(inSubpackage(Matchers.class.getPackage().getName()))); } public void testReturns() throws NoSuchMethodException { Matcher predicate = returns(only(String.class)); assertTrue(predicate.matches( Object.class.getMethod("toString"))); assertFalse(predicate.matches( Object.class.getMethod("hashCode"))); assertEquals("returns(only(class java.lang.String))", returns(only(String.class)).toString()); assertEqualsBothWays(predicate, returns(only(String.class))); assertFalse(predicate.equals(returns(only(Integer.class)))); } public void testSerialization() throws IOException { assertEqualWhenReserialized(any()); assertEqualWhenReserialized(not(any())); assertEqualWhenReserialized(annotatedWith(Named.class)); assertEqualWhenReserialized(annotatedWith(Names.named("foo"))); assertEqualWhenReserialized(only("foo")); assertEqualWhenReserialized(identicalTo(Object.class)); assertEqualWhenReserialized(inPackage(String.class.getPackage())); assertEqualWhenReserialized(inSubpackage(String.class.getPackage().getName())); assertEqualWhenReserialized(returns(any())); assertEqualWhenReserialized(subclassesOf(AbstractList.class)); assertEqualWhenReserialized(only("a").or(only("b"))); assertEqualWhenReserialized(only("a").and(only("b"))); } static abstract class MyRunnable implements Runnable {} @Retention(RetentionPolicy.RUNTIME) @interface Foo {} @Foo static class Bar {} @interface Baz {} @Baz static class Car {} } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/internal/0000755000175000017500000000000011704661106023443 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/internal/util/0000755000175000017500000000000011704661106024420 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/internal/util/LineNumbersTest.java0000644000175000017500000001137011704661106030350 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal.util; import static com.google.inject.Asserts.assertContains; import com.google.inject.AbstractModule; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.matcher.Matchers; import junit.framework.TestCase; import java.lang.reflect.Modifier; /** * @author jessewilson@google.com (Jesse Wilson) */ public class LineNumbersTest extends TestCase { public void testLineNumbers() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(A.class); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) No implementation for " + B.class.getName() + " was bound.", "for parameter 0 at " + A.class.getName() + ".(LineNumbersTest.java:", "at " + LineNumbersTest.class.getName(), ".configure(LineNumbersTest.java:"); } } static class A { @Inject A(B b) {} } public interface B {} /*if[AOP]*/ public void testCanHandleLineNumbersForGuiceGeneratedClasses() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bindInterceptor(Matchers.only(A.class), Matchers.any(), new org.aopalliance.intercept.MethodInterceptor() { public Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation) { return null; } }); bind(A.class); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) No implementation for " + B.class.getName() + " was bound.", "for parameter 0 at " + A.class.getName() + ".(LineNumbersTest.java:", "at " + LineNumbersTest.class.getName(), ".configure(LineNumbersTest.java:"); } } static class GeneratingClassLoader extends ClassLoader { static String name = "__generated"; GeneratingClassLoader() { super(B.class.getClassLoader()); } Class generate() { org.objectweb.asm.ClassWriter cw = new org.objectweb.asm.ClassWriter(org.objectweb.asm.ClassWriter.COMPUTE_MAXS); cw.visit(org.objectweb.asm.Opcodes.V1_5, Modifier.PUBLIC, name, null, org.objectweb.asm.Type.getInternalName(Object.class), null); String sig = "("+org.objectweb.asm.Type.getDescriptor(B.class)+")V"; org.objectweb.asm.MethodVisitor mv = cw.visitMethod(Modifier.PUBLIC, "", sig, null, null); mv.visitAnnotation(org.objectweb.asm.Type.getDescriptor(Inject.class), true); mv.visitCode(); mv.visitVarInsn(org.objectweb.asm.Opcodes.ALOAD, 0); mv.visitMethodInsn(org.objectweb.asm.Opcodes.INVOKESPECIAL, org.objectweb.asm.Type.getInternalName(Object.class), "", "()V" ); mv.visitInsn(org.objectweb.asm.Opcodes.RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); cw.visitEnd(); byte[] buf = cw.toByteArray(); return defineClass(name.replace('/', '.'), buf, 0, buf.length); } } public void testUnavailableByteCodeShowsUnknownSource() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(new GeneratingClassLoader().generate()); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) No implementation for " + B.class.getName() + " was bound.", "for parameter 0 at " + GeneratingClassLoader.name + ".(Unknown Source)", "at " + LineNumbersTest.class.getName(), ".configure(LineNumbersTest.java:"); } } public void testGeneratedClassesCanSucceed() { final Class generated = new GeneratingClassLoader().generate(); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(generated); bind(B.class).toInstance(new B() {}); } }); Object instance = injector.getInstance(generated); assertEquals(instance.getClass(), generated); } /*end[AOP]*/ } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/internal/UniqueAnnotationsTest.java0000644000175000017500000000227311704661106030636 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import junit.framework.TestCase; import java.lang.annotation.Annotation; /** * @author jessewilson@google.com (Jesse Wilson) */ public class UniqueAnnotationsTest extends TestCase { @UniqueAnnotations.Internal(31) public Void unused; public void testEqualsHashCodeToString() { Annotation actual = UniqueAnnotations.create(31); Annotation expected = getClass().getFields()[0].getAnnotations()[0]; assertEquals(expected.toString(), actual.toString()); assertEquals(expected.hashCode(), actual.hashCode()); assertEquals(expected, actual); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/internal/ProxyFactoryTest.java0000644000175000017500000001365711704661106027633 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.inject.matcher.Matchers.annotatedWith; import static com.google.inject.matcher.Matchers.any; import static com.google.inject.matcher.Matchers.not; import static com.google.inject.matcher.Matchers.only; import com.google.common.collect.Lists; import com.google.inject.Inject; import com.google.inject.spi.InjectionPoint; import junit.framework.TestCase; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.reflect.InvocationTargetException; import java.util.List; /** * @author crazybob@google.com (Bob Lee) */ public class ProxyFactoryTest extends TestCase { List aspects = Lists.newArrayList(); public void testSimpleCase() throws NoSuchMethodException, InvocationTargetException, ErrorsException { SimpleInterceptor interceptor = new SimpleInterceptor(); InjectionPoint injectionPoint = InjectionPoint.forConstructorOf(Simple.class); aspects.add(new MethodAspect(any(), any(), interceptor)); ProxyFactory factory = new ProxyFactory(injectionPoint, aspects); ConstructionProxy constructionProxy = factory.create(); Simple simple = constructionProxy.newInstance(); simple.invoke(); assertTrue(simple.invoked); assertTrue(interceptor.invoked); } static class Simple { boolean invoked = false; public void invoke() { invoked = true; } } static class SimpleInterceptor implements MethodInterceptor { boolean invoked = false; public Object invoke(MethodInvocation methodInvocation) throws Throwable { invoked = true; return methodInvocation.proceed(); } } public void testInterceptOneMethod() throws NoSuchMethodException, InvocationTargetException, ErrorsException { SimpleInterceptor interceptor = new SimpleInterceptor(); aspects.add(new MethodAspect(only(Bar.class), annotatedWith(Intercept.class), interceptor)); ConstructionProxy fooFactory = new ProxyFactory(InjectionPoint.forConstructorOf(Foo.class), aspects).create(); ConstructionProxy barFactory = new ProxyFactory(InjectionPoint.forConstructorOf(Bar.class), aspects).create(); Foo foo = fooFactory.newInstance(); Bar bar = barFactory.newInstance(); foo.foo(); assertTrue(foo.fooCalled); assertFalse(interceptor.invoked); bar.bar(); assertTrue(bar.barCalled); assertFalse(interceptor.invoked); bar.intercepted(); assertTrue(bar.interceptedCalled); assertTrue(interceptor.invoked); } static class Foo { boolean fooCalled; @Intercept void foo() { fooCalled = true; } } static class Bar { boolean barCalled; void bar() { barCalled = true; } boolean interceptedCalled; @Intercept void intercepted() { interceptedCalled = true; } } @Retention(RetentionPolicy.RUNTIME) @interface Intercept {} public void testWithConstructorArguments() throws InvocationTargetException, NoSuchMethodException, ErrorsException { SimpleInterceptor interceptor = new SimpleInterceptor(); aspects.add(new MethodAspect(any(), any(), interceptor)); ProxyFactory factory = new ProxyFactory(InjectionPoint.forConstructorOf(A.class), aspects); ConstructionProxy constructor = factory.create(); A a = constructor.newInstance(5); a.a(); assertEquals(5, a.i); } public void testNotProxied() throws NoSuchMethodException, InvocationTargetException, ErrorsException { SimpleInterceptor interceptor = new SimpleInterceptor(); aspects.add(new MethodAspect(not(any()), not(any()), interceptor)); ProxyFactory factory = new ProxyFactory(InjectionPoint.forConstructorOf(A.class), aspects); ConstructionProxy constructor = factory.create(); A a = constructor.newInstance(5); assertEquals(A.class, a.getClass()); } static class A { final int i; @Inject public A(int i) { this.i = i; } public void a() {} } public void testMultipleInterceptors() throws NoSuchMethodException, InvocationTargetException, ErrorsException { DoubleInterceptor doubleInterceptor = new DoubleInterceptor(); CountingInterceptor countingInterceptor = new CountingInterceptor(); aspects.add(new MethodAspect(any(), any(), doubleInterceptor, countingInterceptor)); ProxyFactory factory = new ProxyFactory(InjectionPoint.forConstructorOf(Counter.class), aspects); ConstructionProxy constructor = factory.create(); Counter counter = constructor.newInstance(); counter.inc(); assertEquals(2, counter.count); assertEquals(2, countingInterceptor.count); } static class CountingInterceptor implements MethodInterceptor { int count; public Object invoke(MethodInvocation methodInvocation) throws Throwable { count++; return methodInvocation.proceed(); } } static class DoubleInterceptor implements MethodInterceptor { public Object invoke(MethodInvocation methodInvocation) throws Throwable { methodInvocation.proceed(); return methodInvocation.proceed(); } } static class Counter { int count; void inc() { count++; } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/internal/MoreTypesTest.java0000644000175000017500000000345511704661106027104 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.TypeLiteral; import junit.framework.TestCase; import java.util.Map; import java.util.Set; /** * @author schmitt@google.com (Peter Schmitt) */ public class MoreTypesTest extends TestCase { public void testParameterizedTypeToString() { TypeLiteral> innerString = new TypeLiteral>(){}; assertEquals("com.google.inject.internal.MoreTypesTest$Inner", MoreTypes.typeToString(innerString.getType())); TypeLiteral>> mapInnerInteger = new TypeLiteral>>() {}; assertEquals("java.util.Set>", MoreTypes.typeToString(mapInnerInteger.getType())); TypeLiteral, Set>>> mapInnerLongToSetInnerLong = new TypeLiteral, Set>>>() {}; assertEquals("java.util.Map, " + "java.util.Set>>", MoreTypes.typeToString(mapInnerLongToSetInnerLong.getType())); } public static class Inner {} } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/example/0000755000175000017500000000000011704661106023262 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/example/JndiProviderClient.java0000644000175000017500000000253011704661106027663 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.example; import static com.google.inject.example.JndiProvider.fromJndi; import com.google.inject.AbstractModule; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Injector; import javax.naming.Context; import javax.naming.InitialContext; import javax.sql.DataSource; class JndiProviderClient { public static void main(String[] args) throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { // Bind Context to the default InitialContext. bind(Context.class).to(InitialContext.class); // Bind to DataSource from JNDI. bind(DataSource.class) .toProvider(fromJndi(DataSource.class, "...")); } }); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/example/JndiProvider.java0000644000175000017500000000247411704661106026533 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.example; import com.google.inject.Inject; import com.google.inject.Provider; import javax.naming.Context; import javax.naming.NamingException; class JndiProvider implements Provider { @Inject Context context; final String name; final Class type; JndiProvider(Class type, String name) { this.name = name; this.type = type; } public T get() { try { return type.cast(context.lookup(name)); } catch (NamingException e) { throw new RuntimeException(e); } } /** * Creates a JNDI provider for the given * type and name. */ static Provider fromJndi( Class type, String name) { return new JndiProvider(type, name); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/example/ClientServiceWithGuiceDefaults.java0000644000175000017500000000365211704661106032173 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.example; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.ImplementedBy; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Singleton; import junit.framework.Assert; /** * @author crazybob@google.com (Bob Lee) */ public class ClientServiceWithGuiceDefaults { // 44 lines @ImplementedBy(ServiceImpl.class) public interface Service { void go(); } @Singleton public static class ServiceImpl implements ClientServiceWithGuiceDefaults.Service { public void go() { // ... } } public static class Client { private final Service service; @Inject public Client(Service service) { this.service = service; } public void go() { service.go(); } } public void testClient() { MockService mock = new MockService(); Client client = new Client(mock); client.go(); Assert.assertTrue(mock.isGone()); } public static class MockService implements Service { private boolean gone = false; public void go() { gone = true; } public boolean isGone() { return gone; } } public static void main(String[] args) throws CreationException { new ClientServiceWithGuiceDefaults().testClient(); Injector injector = Guice.createInjector(); Client client = injector.getProvider(Client.class).get(); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/example/ClientServiceWithGuice.java0000644000175000017500000000377711704661106030513 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.example; import static junit.framework.Assert.assertTrue; import com.google.inject.AbstractModule; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Scopes; /** * @author crazybob@google.com (Bob Lee) */ public class ClientServiceWithGuice { // 48 lines public interface Service { void go(); } public static class ServiceImpl implements Service { public void go() { // ... } } public static class MyModule extends AbstractModule { protected void configure() { bind(Service.class).to(ServiceImpl.class).in(Scopes.SINGLETON); } } public static class Client { private final Service service; @Inject public Client(Service service) { this.service = service; } public void go() { service.go(); } } public void testClient() { MockService mock = new MockService(); Client client = new Client(mock); client.go(); assertTrue(mock.isGone()); } public static class MockService implements Service { private boolean gone = false; public void go() { gone = true; } public boolean isGone() { return gone; } } public static void main(String[] args) throws CreationException { new ClientServiceWithGuice().testClient(); Injector injector = Guice.createInjector(new MyModule()); Client client = injector.getInstance(Client.class); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/example/ClientServiceWithFactories.java0000644000175000017500000000360611704661106031365 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.example; import static junit.framework.Assert.assertTrue; /** * @author crazybob@google.com (Bob Lee) */ public class ClientServiceWithFactories { // 58 lines public interface Service { void go(); } public static class ServiceImpl implements Service { public void go() { // ... } } public static class ServiceFactory { private ServiceFactory() {} private static Service instance = new ServiceImpl(); public static Service getInstance() { return instance; } public static void setInstance(Service service) { instance = service; } } public static class Client { public void go() { Service service = ServiceFactory.getInstance(); service.go(); } } public void testClient() { Service previous = ServiceFactory.getInstance(); try { final MockService mock = new MockService(); ServiceFactory.setInstance(mock); Client client = new Client(); client.go(); assertTrue(mock.isGone()); } finally { ServiceFactory.setInstance(previous); } } public static class MockService implements Service { private boolean gone = false; public void go() { gone = true; } public boolean isGone() { return gone; } } public static void main(String[] args) { new ClientServiceWithFactories().testClient(); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootsisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/example/ClientServiceWithDependencyInjection.javasisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/example/ClientServiceWithDependencyInjection0000644000175000017500000000370011704661106032442 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.example; import static junit.framework.Assert.assertTrue; /** * @author crazybob@google.com (Bob Lee) */ public class ClientServiceWithDependencyInjection { // 62 lines public interface Service { void go(); } public static class ServiceImpl implements ClientServiceWithDependencyInjection.Service { public void go() { // ... } } public static class ServiceFactory { private ServiceFactory() {} private static final Service service = new ServiceImpl(); public static Service getInstance() { return service; } } public static class Client { private final Service service; public Client(Service service) { this.service = service; } public void go() { service.go(); } } public static class ClientFactory { private ClientFactory() {} public static Client getInstance() { Service service = ServiceFactory.getInstance(); return new Client(service); } } public void testClient() { MockService mock = new MockService(); Client client = new Client(mock); client.go(); assertTrue(mock.isGone()); } public static class MockService implements Service { private boolean gone = false; public void go() { gone = true; } public boolean isGone() { return gone; } } public static void main(String[] args) { new ClientServiceWithDependencyInjection().testClient(); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/TypeLiteralTypeResolutionTest.java0000644000175000017500000003231611704661106030523 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertEqualsBothWays; import static com.google.inject.Asserts.assertNotSerializable; import static com.google.inject.util.Types.arrayOf; import static com.google.inject.util.Types.listOf; import static com.google.inject.util.Types.newParameterizedType; import static com.google.inject.util.Types.newParameterizedTypeWithOwner; import static com.google.inject.util.Types.setOf; import com.google.common.collect.ImmutableList; import com.google.inject.util.Types; import junit.framework.TestCase; import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.util.AbstractCollection; import java.util.AbstractList; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; /** * This test checks that TypeLiteral can perform type resolution on its members. * * @author jessewilson@google.com (Jesse Wilson) */ public class TypeLiteralTypeResolutionTest extends TestCase { Type arrayListOfString = newParameterizedType(ArrayList.class, String.class); Type hasGenericFieldsOfShort = newParameterizedTypeWithOwner( getClass(), HasGenericFields.class, Short.class); Type hasGenericConstructorOfShort = newParameterizedTypeWithOwner( getClass(), GenericConstructor.class, Short.class); Type throwerOfNpe = newParameterizedTypeWithOwner( getClass(), Thrower.class, NullPointerException.class); Type hasArrayOfShort = newParameterizedTypeWithOwner(getClass(), HasArray.class, Short.class); Type hasRelatedOfString = newParameterizedTypeWithOwner( getClass(), HasRelated.class, String.class, String.class); Type mapK = Map.class.getTypeParameters()[0]; Type hashMapK = HashMap.class.getTypeParameters()[0]; Type setEntryKV; Type entryStringInteger = setOf(newParameterizedTypeWithOwner( Map.class, Map.Entry.class, String.class, Integer.class)); Field list; Field instance; Constructor newHasGenericConstructor; Constructor newThrower; Constructor newString; Method stringIndexOf; Method comparableCompareTo; Method getArray; Method getSetOfArray; Method echo; Method throwS; @Override protected void setUp() throws Exception { super.setUp(); list = HasGenericFields.class.getField("list"); instance = HasGenericFields.class.getField("instance"); newHasGenericConstructor = GenericConstructor.class.getConstructor(Object.class, Object.class); newThrower = Thrower.class.getConstructor(); stringIndexOf = String.class.getMethod("indexOf", String.class); newString = String.class.getConstructor(String.class); comparableCompareTo = Comparable.class.getMethod("compareTo", Object.class); getArray = HasArray.class.getMethod("getArray"); getSetOfArray = HasArray.class.getMethod("getSetOfArray"); echo = HasRelated.class.getMethod("echo", Object.class); throwS = Thrower.class.getMethod("throwS"); setEntryKV = HashMap.class.getMethod("entrySet").getGenericReturnType(); } public void testDirectInheritance() throws NoSuchMethodException { TypeLiteral resolver = TypeLiteral.get(arrayListOfString); assertEquals(listOf(String.class), resolver.getReturnType(List.class.getMethod("subList", int.class, int.class)).getType()); assertEquals(ImmutableList.>of(TypeLiteral.get(String.class)), resolver.getParameterTypes(Collection.class.getMethod("add", Object.class))); } public void testGenericSupertype() { TypeLiteral resolver = TypeLiteral.get(arrayListOfString); assertEquals(newParameterizedType(Collection.class, String.class), resolver.getSupertype(Collection.class).getType()); assertEquals(newParameterizedType(Iterable.class, String.class), resolver.getSupertype(Iterable.class).getType()); assertEquals(newParameterizedType(AbstractList.class, String.class), resolver.getSupertype(AbstractList.class).getType()); assertEquals(Object.class, resolver.getSupertype(Object.class).getType()); } public void testRecursiveTypeVariable() { TypeLiteral resolver = TypeLiteral.get(MyInteger.class); assertEquals(MyInteger.class, resolver.getParameterTypes(comparableCompareTo).get(0).getType()); } interface MyComparable> extends Comparable {} static class MyInteger implements MyComparable { int value; public int compareTo(MyInteger o) { return value - o.value; } } public void testFields() { TypeLiteral resolver = TypeLiteral.get(hasGenericFieldsOfShort); assertEquals(listOf(Short.class), resolver.getFieldType(list).getType()); assertEquals(Short.class, resolver.getFieldType(instance).getType()); } static class HasGenericFields { public List list; public T instance; } public void testGenericConstructor() throws NoSuchMethodException { TypeLiteral resolver = TypeLiteral.get(hasGenericConstructorOfShort); assertEquals(Short.class, resolver.getParameterTypes(newHasGenericConstructor).get(0).getType()); } static class GenericConstructor { @SuppressWarnings("UnusedDeclaration") public GenericConstructor(S s, T t) {} } public void testThrowsExceptions() { TypeLiteral type = TypeLiteral.get(throwerOfNpe); assertEquals(NullPointerException.class, type.getExceptionTypes(newThrower).get(0).getType()); assertEquals(NullPointerException.class, type.getExceptionTypes(throwS).get(0).getType()); } static class Thrower { public Thrower() throws S {} public void throwS() throws S {} } public void testArrays() { TypeLiteral resolver = TypeLiteral.get(hasArrayOfShort); assertEquals(arrayOf(Short.class), resolver.getReturnType(getArray).getType()); assertEquals(setOf(arrayOf(Short.class)), resolver.getReturnType(getSetOfArray).getType()); } static interface HasArray { T[] getArray(); Set getSetOfArray(); } public void testRelatedTypeVariables() { TypeLiteral resolver = TypeLiteral.get(hasRelatedOfString); assertEquals(String.class, resolver.getParameterTypes(echo).get(0).getType()); assertEquals(String.class, resolver.getReturnType(echo).getType()); } interface HasRelated { T echo(R r); } /** Ensure the cache doesn't cache too much */ public void testCachingAndReindexing() throws NoSuchMethodException { TypeLiteral resolver = TypeLiteral.get( newParameterizedTypeWithOwner(getClass(), HasLists.class, String.class, Short.class)); assertEquals(listOf(String.class), resolver.getReturnType(HasLists.class.getMethod("listS")).getType()); assertEquals(listOf(Short.class), resolver.getReturnType(HasLists.class.getMethod("listT")).getType()); } interface HasLists { List listS(); List listT(); List> listEntries(); } public void testUnsupportedQueries() throws NoSuchMethodException { TypeLiteral resolver = TypeLiteral.get(arrayListOfString); try { resolver.getExceptionTypes(stringIndexOf); fail(); } catch (IllegalArgumentException e) { assertEquals("public int java.lang.String.indexOf(java.lang.String) is not defined by a " + "supertype of java.util.ArrayList", e.getMessage()); } try { resolver.getParameterTypes(stringIndexOf); fail(); } catch (Exception e) { assertEquals("public int java.lang.String.indexOf(java.lang.String) is not defined by a " + "supertype of java.util.ArrayList", e.getMessage()); } try { resolver.getReturnType(stringIndexOf); fail(); } catch (Exception e) { assertEquals("public int java.lang.String.indexOf(java.lang.String) is not defined by a " + "supertype of java.util.ArrayList", e.getMessage()); } try { resolver.getSupertype(String.class); fail(); } catch (Exception e) { assertEquals("class java.lang.String is not a supertype of " + "java.util.ArrayList", e.getMessage()); } try { resolver.getExceptionTypes(newString); fail(); } catch (Exception e) { assertEquals("public java.lang.String(java.lang.String) does not construct " + "a supertype of java.util.ArrayList", e.getMessage()); } try { resolver.getParameterTypes(newString); fail(); } catch (Exception e) { assertEquals("public java.lang.String(java.lang.String) does not construct " + "a supertype of java.util.ArrayList", e.getMessage()); } } public void testResolve() { TypeLiteral typeResolver = TypeLiteral.get(StringIntegerMap.class); assertEquals(String.class, typeResolver.resolveType(mapK)); typeResolver = new TypeLiteral>() {}; assertEquals(String.class, typeResolver.resolveType(mapK)); assertEquals(Types.mapOf(String.class, Integer.class), typeResolver.getSupertype(Map.class).getType()); typeResolver = new TypeLiteral>() {}; assertEquals(String.class, typeResolver.resolveType(mapK)); typeResolver = new TypeLiteral>() {}; assertEquals(String.class, typeResolver.resolveType(mapK)); typeResolver = TypeLiteral.get(StringIntegerHashMap.class); assertEquals(String.class, typeResolver.resolveType(mapK)); assertEquals(String.class, typeResolver.resolveType(hashMapK)); assertEquals(entryStringInteger, typeResolver.resolveType(setEntryKV)); assertEquals(Object.class, typeResolver.getSupertype(Object.class).getType()); } public void testOnObject() { TypeLiteral typeResolver = TypeLiteral.get(Object.class); assertEquals(Object.class, typeResolver.getSupertype(Object.class).getType()); assertEquals(Object.class, typeResolver.getRawType()); // interfaces also resolve Object typeResolver = TypeLiteral.get(Types.setOf(Integer.class)); assertEquals(Object.class, typeResolver.getSupertype(Object.class).getType()); } interface StringIntegerMap extends Map {} interface BetterMap extends Map {} interface BestMap extends BetterMap {} static class StringIntegerHashMap extends HashMap {} public void testGetSupertype() { TypeLiteral> listOfString = new TypeLiteral>() {}; assertEquals(Types.newParameterizedType(AbstractCollection.class, String.class), listOfString.getSupertype(AbstractCollection.class).getType()); TypeLiteral arrayListOfE = TypeLiteral.get(newParameterizedType( ArrayList.class, ArrayList.class.getTypeParameters())); assertEquals( newParameterizedType(AbstractCollection.class, ArrayList.class.getTypeParameters()), arrayListOfE.getSupertype(AbstractCollection.class).getType()); } public void testGetSupertypeForArraysAsList() { Class arraysAsListClass = Arrays.asList().getClass(); Type anotherE = arraysAsListClass.getTypeParameters()[0]; TypeLiteral type = TypeLiteral.get(newParameterizedType(AbstractList.class, anotherE)); assertEquals(newParameterizedType(AbstractCollection.class, anotherE), type.getSupertype(AbstractCollection.class).getType()); } public void testWildcards() throws NoSuchFieldException { TypeLiteral> ofString = new TypeLiteral>() {}; assertEquals(new TypeLiteral>() {}.getType(), ofString.getFieldType(Parameterized.class.getField("t")).getType()); assertEquals(new TypeLiteral>() {}.getType(), ofString.getFieldType(Parameterized.class.getField("extendsT")).getType()); assertEquals(new TypeLiteral>() {}.getType(), ofString.getFieldType(Parameterized.class.getField("superT")).getType()); } static class Parameterized { public List t; public List extendsT; public List superT; } // TODO(jessewilson): tests for tricky bounded types like public void testEqualsAndHashCode() throws IOException { TypeLiteral a1 = TypeLiteral.get(arrayListOfString); TypeLiteral a2 = TypeLiteral.get(arrayListOfString); TypeLiteral b = TypeLiteral.get(listOf(String.class)); assertEqualsBothWays(a1, a2); assertNotSerializable(a1); assertFalse(a1.equals(b)); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/TypeLiteralTest.java0000644000175000017500000001711111704661106025571 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertEqualsBothWays; import static com.google.inject.Asserts.assertNotSerializable; import com.google.common.collect.ImmutableList; import com.google.inject.util.Types; import junit.framework.TestCase; import java.io.IOException; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import java.util.List; /** * @author crazybob@google.com (Bob Lee) */ public class TypeLiteralTest extends TestCase { public void testWithParameterizedType() { TypeLiteral> a = new TypeLiteral>() {}; TypeLiteral> b = new TypeLiteral>( Types.listOf(String.class)) {}; assertEqualsBothWays(a, b); } public void testEquality() { TypeLiteral> t1 = new TypeLiteral>() {}; TypeLiteral> t2 = new TypeLiteral>() {}; TypeLiteral> t3 = new TypeLiteral>() {}; TypeLiteral t4 = new TypeLiteral() {}; assertEqualsBothWays(t1, t2); assertFalse(t2.equals(t3)); assertFalse(t3.equals(t2)); assertFalse(t2.equals(t4)); assertFalse(t4.equals(t2)); TypeLiteral t5 = TypeLiteral.get(String.class); assertEqualsBothWays(t4, t5); } public List wildcardExtends; public void testWithWildcardType() throws NoSuchFieldException, IOException { TypeLiteral a = TypeLiteral.get(getClass().getField("wildcardExtends").getGenericType()); TypeLiteral b = TypeLiteral.get(Types.listOf(Types.subtypeOf(CharSequence.class))); TypeLiteral c = new TypeLiteral>() {}; assertEqualsBothWays(a, b); assertEqualsBothWays(b, c); assertEquals("java.util.List", a.toString()); assertEquals("java.util.List", b.toString()); assertEquals("java.util.List", c.toString()); assertNotSerializable(a); assertNotSerializable(b); assertNotSerializable(c); } public void testMissingTypeParameter() { try { new TypeLiteral() {}; fail(); } catch (RuntimeException e) { /* expected */ } } public void testTypesInvolvingArraysForEquality() { TypeLiteral stringArray = new TypeLiteral() {}; assertEquals(stringArray, new TypeLiteral() {}); TypeLiteral> listOfStringArray = new TypeLiteral>() {}; assertEquals(listOfStringArray, new TypeLiteral>() {}); } public void testEqualityOfGenericArrayAndClassArray() { TypeLiteral arrayAsClass = TypeLiteral.get(String[].class); TypeLiteral arrayAsType = new TypeLiteral() {}; assertEquals(arrayAsClass, arrayAsType); } public void testEqualityOfMultidimensionalGenericArrayAndClassArray() { TypeLiteral arrayAsClass = TypeLiteral.get(String[][][].class); TypeLiteral arrayAsType = new TypeLiteral() {}; assertEquals(arrayAsClass, arrayAsType); } public void testTypeLiteralsMustHaveRawTypes() { try { TypeLiteral.get(Types.subtypeOf(Runnable.class)); fail(); } catch (IllegalArgumentException expected) { Asserts.assertContains(expected.getMessage(), "Expected a Class, ParameterizedType, or " + "GenericArrayType, but is of type " + "com.google.inject.internal.MoreTypes$WildcardTypeImpl"); } } /** * Unlike Key, TypeLiteral retains full type information and differentiates * between {@code int.class} and {@code Integer.class}. */ public void testDifferentiationBetweenWrappersAndPrimitives() { Class[] primitives = new Class[] { boolean.class, byte.class, short.class, int.class, long.class, float.class, double.class, char.class, void.class }; Class[] wrappers = new Class[] { Boolean.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class, Character.class, Void.class }; for (int t = 0; t < primitives.length; t++) { @SuppressWarnings("unchecked") TypeLiteral primitiveTl = TypeLiteral.get(primitives[t]); @SuppressWarnings("unchecked") TypeLiteral wrapperTl = TypeLiteral.get(wrappers[t]); assertFalse(primitiveTl.equals(wrapperTl)); assertEquals(primitives[t], primitiveTl.getType()); assertEquals(wrappers[t], wrapperTl.getType()); assertEquals(primitives[t], primitiveTl.getRawType()); assertEquals(wrappers[t], wrapperTl.getRawType()); } } public void testSerialization() throws IOException { assertNotSerializable(new TypeLiteral>() {}); } public void testTypeVariableWithNoBound() { TypeVariable>[] typeVariables = HasTypeParameters.class.getTypeParameters(); TypeLiteral aTl = TypeLiteral.get(typeVariables[0]); assertEquals(Object.class, aTl.getRawType()); assertEquals("A", aTl.toString()); TypeVariable aTv = (TypeVariable) aTl.getType(); assertEquals(HasTypeParameters.class, aTv.getGenericDeclaration()); assertEquals("A", aTv.getName()); assertEquals(ImmutableList.of(Object.class), ImmutableList.copyOf(aTv.getBounds())); assertEquals("A", aTv.toString()); assertEqualsBothWays(aTl, TypeLiteral.get(HasTypeParameters.class.getTypeParameters()[0])); } public void testTypeVariablesWithSingleBound() { TypeVariable>[] typeVariables = HasTypeParameters.class.getTypeParameters(); TypeLiteral cTl = TypeLiteral.get(typeVariables[2]); assertEquals(Object.class, cTl.getRawType()); assertEquals("C", cTl.toString()); TypeVariable cTv = (TypeVariable) cTl.getType(); assertEquals(HasTypeParameters.class, cTv.getGenericDeclaration()); assertEquals("C", cTv.getName()); assertEquals(ImmutableList.of(Runnable.class), ImmutableList.copyOf(cTv.getBounds())); assertEquals("C", cTv.toString()); assertEqualsBothWays(cTl, TypeLiteral.get(HasTypeParameters.class.getTypeParameters()[2])); } public void testTypeVariableWithMultipleBounds() { TypeVariable>[] typeVariables = HasTypeParameters.class.getTypeParameters(); TypeLiteral bTl = TypeLiteral.get(typeVariables[1]); assertEquals(Object.class, bTl.getRawType()); assertEquals("B", bTl.toString()); TypeVariable bTv = (TypeVariable) bTl.getType(); assertEquals(HasTypeParameters.class, bTv.getGenericDeclaration()); assertEquals("B", bTv.getName()); assertEquals(ImmutableList.of(Types.listOf(typeVariables[0]), Runnable.class), ImmutableList.copyOf(bTv.getBounds())); assertEquals("B", bTv.toString()); assertEqualsBothWays(bTl, TypeLiteral.get(HasTypeParameters.class.getTypeParameters()[1])); } class HasTypeParameters & Runnable, C extends Runnable> { A a; B b; C c; } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/TypeLiteralInjectionTest.java0000644000175000017500000000664711704661106027450 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static com.google.inject.util.Types.listOf; import com.google.inject.util.Types; import junit.framework.TestCase; import java.util.List; /** * Demonstrates type reification. * * @author jessewilson@google.com (Jesse Wilson) */ public class TypeLiteralInjectionTest extends TestCase { public void testBindingToRawTypeLiteralIsNotAllowed() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(TypeLiteral.class).toInstance(TypeLiteral.get(String.class)); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "Binding to core guice framework type is not allowed: TypeLiteral"); } } public void testBindingToParameterizedTypeLiteralIsNotAllowed() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(new TypeLiteral>() {}) .toInstance(TypeLiteral.get(String.class)); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "Binding to core guice framework type is not allowed: TypeLiteral"); } } public void testInjectTypeLiteralWithRawTypes() { C c = Guice.createInjector().getInstance(C.class); assertEquals(TypeLiteral.get(String.class), c.string); assertEquals(TypeLiteral.get(A.class), c.a); try { Guice.createInjector().getInstance(B.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), TypeLiteral.class.getName() + "> " + "cannot be used as a key; It is not fully specified."); } } public void testInjectTypeLiteralWithClassTypes() { B b = Guice.createInjector().getInstance(new Key>() {}); assertEquals(TypeLiteral.get(String.class), b.string); assertEquals(TypeLiteral.get(Integer.class), b.t); assertEquals(TypeLiteral.get(listOf(Integer.class)), b.listOfT); assertEquals(TypeLiteral.get(listOf(Types.subtypeOf(Integer.class))), b.listOfWildcardT); } public void testInjectRawTypeLiteral() { try { Guice.createInjector().getInstance(TypeLiteral.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "Cannot inject a TypeLiteral that has no type parameter"); } } static class A { @Inject TypeLiteral string; @Inject TypeLiteral> listOfT; @Inject TypeLiteral> listOfWildcardT; } static class B extends A { @Inject TypeLiteral t; } static class C { @Inject TypeLiteral string; @Inject TypeLiteral a; T t; } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/TypeListenerTest.java0000644000175000017500000005231411704661106025766 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static com.google.inject.matcher.Matchers.any; import static com.google.inject.matcher.Matchers.only; import static com.google.inject.name.Names.named; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.inject.matcher.Matcher; import com.google.inject.matcher.Matchers; import com.google.inject.spi.InjectionListener; import com.google.inject.spi.Message; import com.google.inject.spi.TypeEncounter; import com.google.inject.spi.TypeListener; import junit.framework.TestCase; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; /** * @author jessewilson@google.com (Jesse Wilson) */ public class TypeListenerTest extends TestCase { private final Matcher onlyAbcd = Matchers.only(new TypeLiteral() {}) .or(only(new TypeLiteral() {})) .or(only(new TypeLiteral() {})) .or(only(new TypeLiteral() {})); final TypeListener failingTypeListener = new TypeListener() { int failures = 0; public void hear(TypeLiteral type, TypeEncounter encounter) { throw new ClassCastException("whoops, failure #" + (++failures)); } @Override public String toString() { return "clumsy"; } }; final InjectionListener failingInjectionListener = new InjectionListener() { int failures = 0; public void afterInjection(Object injectee) { throw new ClassCastException("whoops, failure #" + (++failures)); } @Override public String toString() { return "goofy"; } }; final MembersInjector failingMembersInjector = new MembersInjector() { int failures = 0; public void injectMembers(Object instance) { throw new ClassCastException("whoops, failure #" + (++failures)); } @Override public String toString() { return "awkward"; } }; public void testTypeListenersAreFired() throws NoSuchMethodException { final AtomicInteger firedCount = new AtomicInteger(); final TypeListener typeListener = new TypeListener() { public void hear(TypeLiteral type, TypeEncounter encounter) { assertEquals(new TypeLiteral() {}, type); firedCount.incrementAndGet(); } }; Guice.createInjector(new AbstractModule() { protected void configure() { bindListener(onlyAbcd, typeListener); bind(A.class); } }); assertEquals(1, firedCount.get()); } public void testInstallingInjectionListener() { final List injectees = Lists.newArrayList(); final InjectionListener injectionListener = new InjectionListener() { public void afterInjection(Object injectee) { injectees.add(injectee); } }; Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindListener(onlyAbcd, new TypeListener() { public void hear(TypeLiteral type, TypeEncounter encounter) { encounter.register(injectionListener); } }); bind(A.class); } }); assertEquals(ImmutableList.of(), injectees); Object a1 = injector.getInstance(A.class); assertEquals(ImmutableList.of(a1), injectees); Object a2 = injector.getInstance(A.class); assertEquals(ImmutableList.of(a1, a2), injectees); Object b1 = injector.getInstance(B.class); assertEquals(ImmutableList.of(a1, a2, b1), injectees); Provider aProvider = injector.getProvider(A.class); assertEquals(ImmutableList.of(a1, a2, b1), injectees); A a3 = aProvider.get(); A a4 = aProvider.get(); assertEquals(ImmutableList.of(a1, a2, b1, a3, a4), injectees); } /*if[AOP]*/ private static org.aopalliance.intercept.MethodInterceptor prefixInterceptor( final String prefix) { return new org.aopalliance.intercept.MethodInterceptor() { public Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation) throws Throwable { return prefix + methodInvocation.proceed(); } }; } public void testAddingInterceptors() throws NoSuchMethodException { final Matcher buzz = only(C.class.getMethod("buzz")); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindInterceptor(any(), buzz, prefixInterceptor("ka")); bindInterceptor(any(), any(), prefixInterceptor("fe")); bindListener(onlyAbcd, new TypeListener() { public void hear(TypeLiteral type, TypeEncounter encounter) { encounter.bindInterceptor(any(), prefixInterceptor("li")); encounter.bindInterceptor(buzz, prefixInterceptor("no")); } }); } }); // interceptors must be invoked in the order they're bound. C c = injector.getInstance(C.class); assertEquals("kafelinobuzz", c.buzz()); assertEquals("felibeep", c.beep()); } /*end[AOP]*/ public void testTypeListenerThrows() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bindListener(onlyAbcd, failingTypeListener); bind(B.class); bind(C.class); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Error notifying TypeListener clumsy (bound at " + getClass().getName(), ".configure(TypeListenerTest.java:", "of " + B.class.getName(), "Reason: java.lang.ClassCastException: whoops, failure #1", "2) Error notifying TypeListener clumsy (bound at " + getClass().getName(), ".configure(TypeListenerTest.java:", "of " + C.class.getName(), "Reason: java.lang.ClassCastException: whoops, failure #2"); } Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindListener(onlyAbcd, failingTypeListener); } }); try { injector.getProvider(B.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "1) Error notifying TypeListener clumsy (bound at " + getClass().getName(), ".configure(TypeListenerTest.java:", "of " + B.class.getName(), "Reason: java.lang.ClassCastException: whoops, failure #3"); } // getting it again should yield the same exception #3 try { injector.getInstance(B.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "1) Error notifying TypeListener clumsy (bound at " + getClass().getName(), ".configure(TypeListenerTest.java:", "of " + B.class.getName(), "Reason: java.lang.ClassCastException: whoops, failure #3"); } // non-injected types do not participate assertSame(Stage.DEVELOPMENT, injector.getInstance(Stage.class)); } public void testInjectionListenerThrows() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindListener(onlyAbcd, new TypeListener() { public void hear(TypeLiteral type, TypeEncounter encounter) { encounter.register(failingInjectionListener); } }); bind(B.class); } }); try { injector.getInstance(A.class); fail(); } catch (ProvisionException e) { assertContains(e.getMessage(), "1) Error notifying InjectionListener goofy of " + A.class.getName(), " Reason: java.lang.ClassCastException: whoops, failure #1"); } // second time through should be a new cause (#2) try { injector.getInstance(A.class); fail(); } catch (ProvisionException e) { assertContains(e.getMessage(), "1) Error notifying InjectionListener goofy of " + A.class.getName(), " Reason: java.lang.ClassCastException: whoops, failure #2"); } // we should get errors for all types, but only on getInstance() Provider bProvider = injector.getProvider(B.class); try { bProvider.get(); fail(); } catch (ProvisionException e) { assertContains(e.getMessage(), "1) Error notifying InjectionListener goofy of " + B.class.getName(), " Reason: java.lang.ClassCastException: whoops, failure #3"); } // non-injected types do not participate assertSame(Stage.DEVELOPMENT, injector.getInstance(Stage.class)); } public void testInjectMembersTypeListenerFails() { try { Guice.createInjector(new AbstractModule() { protected void configure() { getMembersInjector(A.class); bindListener(onlyAbcd, failingTypeListener); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Error notifying TypeListener clumsy (bound at ", TypeListenerTest.class.getName(), ".configure(TypeListenerTest.java:", "of " + A.class.getName(), " Reason: java.lang.ClassCastException: whoops, failure #1"); } } public void testConstructedTypeListenerIsTheSameAsMembersInjectorListener() { final AtomicInteger typeEncounters = new AtomicInteger(); final AtomicInteger injections = new AtomicInteger(); final InjectionListener listener = new InjectionListener() { public void afterInjection(A injectee) { injections.incrementAndGet(); assertNotNull(injectee.injector); } }; Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindListener(onlyAbcd, new TypeListener() { public void hear(TypeLiteral type, TypeEncounter encounter) { typeEncounters.incrementAndGet(); encounter.register((InjectionListener) listener); } }); bind(A.class); getMembersInjector(A.class); } }); // creating the injector shouldn't trigger injections assertEquals(0, injections.getAndSet(0)); // constructing an A should trigger an injection injector.getInstance(A.class); assertEquals(1, injections.getAndSet(0)); // injecting an A should trigger an injection injector.injectMembers(new A()); assertEquals(1, injections.getAndSet(0)); // getting a provider shouldn't Provider aProvider = injector.getProvider(A.class); MembersInjector aMembersInjector = injector.getMembersInjector(A.class); assertEquals(0, injections.getAndSet(0)); // exercise the provider aProvider.get(); aProvider.get(); assertEquals(2, injections.getAndSet(0)); // exercise the members injector aMembersInjector.injectMembers(new A()); aMembersInjector.injectMembers(new A()); assertEquals(2, injections.getAndSet(0)); // we should only have encountered one type assertEquals(1, typeEncounters.getAndSet(0)); } public void testLookupsAtInjectorCreateTime() { final AtomicReference> bProviderReference = new AtomicReference>(); final AtomicReference> aMembersInjectorReference = new AtomicReference>(); final InjectionListener lookupsTester = new InjectionListener() { public void afterInjection(Object injectee) { assertNotNull(bProviderReference.get().get()); A a = new A(); aMembersInjectorReference.get().injectMembers(a); assertNotNull(a.injector); } }; Guice.createInjector(new AbstractModule() { protected void configure() { bindListener(only(TypeLiteral.get(C.class)), new TypeListener() { public void hear(TypeLiteral type, TypeEncounter encounter) { Provider bProvider = encounter.getProvider(B.class); try { bProvider.get(); fail(); } catch (IllegalStateException expected) { assertEquals("This Provider cannot be used until the Injector has been created.", expected.getMessage()); } bProviderReference.set(bProvider); MembersInjector aMembersInjector = encounter.getMembersInjector(A.class); try { aMembersInjector.injectMembers(new A()); fail(); } catch (IllegalStateException expected) { assertEquals( "This MembersInjector cannot be used until the Injector has been created.", expected.getMessage()); } aMembersInjectorReference.set(aMembersInjector); encounter.register(lookupsTester); } }); // this ensures the type listener fires, and also the afterInjection() listener bind(C.class).asEagerSingleton(); } }); lookupsTester.afterInjection(null); } public void testLookupsPostCreate() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindListener(only(TypeLiteral.get(C.class)), new TypeListener() { public void hear(TypeLiteral type, TypeEncounter encounter) { assertNotNull(encounter.getProvider(B.class).get()); A a = new A(); encounter.getMembersInjector(A.class).injectMembers(a); assertNotNull(a.injector); } }); } }); injector.getInstance(C.class); } public void testMembersInjector() { final MembersInjector membersInjector = new MembersInjector() { public void injectMembers(D instance) { instance.userInjected++; assertEquals(instance.guiceInjected, instance.userInjected); } }; final InjectionListener injectionListener = new InjectionListener() { public void afterInjection(D injectee) { assertTrue(injectee.userInjected > 0); injectee.listenersNotified++; assertEquals(injectee.guiceInjected, injectee.listenersNotified); } }; Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindListener(onlyAbcd, new TypeListener() { public void hear(TypeLiteral type, TypeEncounter encounter) { encounter.register((MembersInjector) membersInjector); encounter.register((InjectionListener) injectionListener); } }); D boundThreeTimes = new D(); bind(D.class).annotatedWith(named("i")).toInstance(boundThreeTimes); bind(D.class).annotatedWith(named("ii")).toInstance(boundThreeTimes); bind(D.class).annotatedWith(named("iii")).toInstance(boundThreeTimes); } }); D boundThreeTimes = injector.getInstance(Key.get(D.class, named("iii"))); boundThreeTimes.assertAllCounts(1); D getInstance = injector.getInstance(D.class); getInstance.assertAllCounts(1); D memberInjection = new D(); injector.injectMembers(memberInjection); memberInjection.assertAllCounts(1); injector.injectMembers(memberInjection); injector.injectMembers(memberInjection); memberInjection.assertAllCounts(3); injector.getMembersInjector(D.class).injectMembers(memberInjection); memberInjection.assertAllCounts(4); } public void testMembersInjectorThrows() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindListener(onlyAbcd, new TypeListener() { public void hear(TypeLiteral type, TypeEncounter encounter) { encounter.register(failingMembersInjector); } }); bind(B.class); } }); try { injector.getInstance(A.class); fail(); } catch (ProvisionException e) { assertContains(e.getMessage(), "1) Error injecting " + A.class.getName() + " using awkward.", "Reason: java.lang.ClassCastException: whoops, failure #1"); } // second time through should be a new cause (#2) try { injector.getInstance(A.class); fail(); } catch (ProvisionException e) { assertContains(e.getMessage(), "1) Error injecting " + A.class.getName() + " using awkward.", "Reason: java.lang.ClassCastException: whoops, failure #2"); } // we should get errors for all types, but only on getInstance() Provider bProvider = injector.getProvider(B.class); try { bProvider.get(); fail(); } catch (ProvisionException e) { assertContains(e.getMessage(), "1) Error injecting " + B.class.getName() + " using awkward.", "Reason: java.lang.ClassCastException: whoops, failure #3"); } // non-injected types do not participate assertSame(Stage.DEVELOPMENT, injector.getInstance(Stage.class)); } /** * We had a bug where we weren't notifying of types encountered for member injection when those * types had no members to be injected. Constructed types are always injected because they always * have at least one injection point: the class constructor. */ public void testTypesWithNoInjectableMembersAreNotified() { final AtomicInteger notificationCount = new AtomicInteger(); Guice.createInjector(new AbstractModule() { protected void configure() { bindListener(onlyAbcd, new TypeListener() { public void hear(TypeLiteral type, TypeEncounter encounter) { notificationCount.incrementAndGet(); } }); bind(C.class).toInstance(new C()); } }); assertEquals(1, notificationCount.get()); } public void testEncounterCannotBeUsedAfterHearReturns() { final AtomicReference> encounterReference = new AtomicReference>(); Guice.createInjector(new AbstractModule() { protected void configure() { bindListener(any(), new TypeListener() { public void hear(TypeLiteral type, TypeEncounter encounter) { encounterReference.set(encounter); } }); bind(C.class); } }); TypeEncounter encounter = encounterReference.get(); try { encounter.register(new InjectionListener() { public void afterInjection(Object injectee) {} }); fail(); } catch (IllegalStateException expected) { } /*if[AOP]*/ try { encounter.bindInterceptor(any(), new org.aopalliance.intercept.MethodInterceptor() { public Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation) throws Throwable { return methodInvocation.proceed(); } }); fail(); } catch (IllegalStateException expected) { } /*end[AOP]*/ try { encounter.addError(new Exception()); fail(); } catch (IllegalStateException expected) { } try { encounter.getMembersInjector(A.class); fail(); } catch (IllegalStateException expected) { } try { encounter.getProvider(B.class); fail(); } catch (IllegalStateException expected) { } } public void testAddErrors() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bindListener(Matchers.only(new TypeLiteral() {}), new TypeListener() { public void hear(TypeLiteral type, TypeEncounter encounter) { encounter.addError("There was an error on %s", type); encounter.addError(new IllegalArgumentException("whoops!")); encounter.addError(new Message("And another problem")); encounter.addError(new IllegalStateException()); } }); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) There was an error on com.google.inject.Stage", "2) An exception was caught and reported. Message: whoops!", "3) And another problem", "4) An exception was caught and reported. Message: null", "4 errors"); } } // TODO: recursively accessing a lookup should fail static class A { @Inject Injector injector; @Inject Stage stage; } static class B {} public static class C { public String buzz() { return "buzz"; } public String beep() { return "beep"; } } static class D { int guiceInjected = 0; int userInjected = 0; int listenersNotified = 0; @Inject void guiceInjected() { guiceInjected++; } void assertAllCounts(int expected) { assertEquals(expected, guiceInjected); assertEquals(expected, userInjected); assertEquals(expected, listenersNotified); } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/TypeConversionTest.java0000644000175000017500000003377611704661106026341 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.common.collect.Iterables; import com.google.inject.matcher.Matchers; import com.google.inject.spi.ConvertedConstantBinding; import com.google.inject.spi.TypeConverter; import com.google.inject.spi.TypeConverterBinding; import junit.framework.AssertionFailedError; import junit.framework.TestCase; import java.lang.annotation.Retention; import java.util.Date; /** * @author crazybob@google.com (Bob Lee) */ public class TypeConversionTest extends TestCase { @Retention(RUNTIME) @BindingAnnotation @interface NumericValue {} @Retention(RUNTIME) @BindingAnnotation @interface BooleanValue {} @Retention(RUNTIME) @BindingAnnotation @interface EnumValue {} @Retention(RUNTIME) @BindingAnnotation @interface ClassName {} public static class Foo { @Inject @BooleanValue Boolean booleanField; @Inject @BooleanValue boolean primitiveBooleanField; @Inject @NumericValue Byte byteField; @Inject @NumericValue byte primitiveByteField; @Inject @NumericValue Short shortField; @Inject @NumericValue short primitiveShortField; @Inject @NumericValue Integer integerField; @Inject @NumericValue int primitiveIntField; @Inject @NumericValue Long longField; @Inject @NumericValue long primitiveLongField; @Inject @NumericValue Float floatField; @Inject @NumericValue float primitiveFloatField; @Inject @NumericValue Double doubleField; @Inject @NumericValue double primitiveDoubleField; @Inject @EnumValue Bar enumField; @Inject @ClassName Class classField; } public enum Bar { TEE, BAZ, BOB } public void testOneConstantInjection() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindConstant().annotatedWith(NumericValue.class).to("5"); bind(Simple.class); } }); Simple simple = injector.getInstance(Simple.class); assertEquals(5, simple.i); } static class Simple { @Inject @NumericValue int i; } public void testConstantInjection() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindConstant().annotatedWith(NumericValue.class).to("5"); bindConstant().annotatedWith(BooleanValue.class).to("true"); bindConstant().annotatedWith(EnumValue.class).to("TEE"); bindConstant().annotatedWith(ClassName.class).to(Foo.class.getName()); } }); Foo foo = injector.getInstance(Foo.class); checkNumbers( foo.integerField, foo.primitiveIntField, foo.longField, foo.primitiveLongField, foo.byteField, foo.primitiveByteField, foo.shortField, foo.primitiveShortField, foo.floatField, foo.primitiveFloatField, foo.doubleField, foo.primitiveDoubleField ); assertEquals(Bar.TEE, foo.enumField); assertEquals(Foo.class, foo.classField); } public void testConstantInjectionWithExplicitBindingsRequired() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { binder().requireExplicitBindings(); bind(Foo.class); bindConstant().annotatedWith(NumericValue.class).to("5"); bindConstant().annotatedWith(BooleanValue.class).to("true"); bindConstant().annotatedWith(EnumValue.class).to("TEE"); bindConstant().annotatedWith(ClassName.class).to(Foo.class.getName()); } }); Foo foo = injector.getInstance(Foo.class); checkNumbers( foo.integerField, foo.primitiveIntField, foo.longField, foo.primitiveLongField, foo.byteField, foo.primitiveByteField, foo.shortField, foo.primitiveShortField, foo.floatField, foo.primitiveFloatField, foo.doubleField, foo.primitiveDoubleField ); assertEquals(Bar.TEE, foo.enumField); assertEquals(Foo.class, foo.classField); } void checkNumbers(Number... ns) { for (Number n : ns) { assertEquals(5, n.intValue()); } } public void testInvalidInteger() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindConstant().annotatedWith(NumericValue.class).to("invalid"); } }); try { injector.getInstance(InvalidInteger.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "Error converting 'invalid'"); assertContains(expected.getMessage(), "bound at " + getClass().getName()); assertContains(expected.getMessage(), "to java.lang.Integer"); } } public static class InvalidInteger { @Inject @NumericValue Integer integerField; } public void testInvalidCharacter() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindConstant().annotatedWith(NumericValue.class).to("invalid"); } }); try { injector.getInstance(InvalidCharacter.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "Error converting 'invalid'"); assertContains(expected.getMessage(), "bound at " + getClass().getName()); assertContains(expected.getMessage(), "to java.lang.Character"); } } public static class InvalidCharacter { @Inject @NumericValue char foo; } public void testInvalidEnum() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindConstant().annotatedWith(NumericValue.class).to("invalid"); } }); try { injector.getInstance(InvalidEnum.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "Error converting 'invalid'"); assertContains(expected.getMessage(), "bound at " + getClass().getName()); assertContains(expected.getMessage(), "to " + Bar.class.getName()); } } public static class InvalidEnum { @Inject @NumericValue Bar foo; } public void testToInstanceIsTreatedLikeConstant() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(String.class).toInstance("5"); bind(LongHolder.class); } }); assertEquals(5L, (long) injector.getInstance(LongHolder.class).foo); } static class LongHolder { @Inject Long foo; } public void testCustomTypeConversion() throws CreationException { final Date result = new Date(); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { convertToTypes(Matchers.only(TypeLiteral.get(Date.class)) , mockTypeConverter(result)); bindConstant().annotatedWith(NumericValue.class).to("Today"); bind(DateHolder.class); } }); assertSame(result, injector.getInstance(DateHolder.class).date); Binding binding = injector.getBinding(Key.get(Date.class, NumericValue.class)); assertTrue(binding instanceof ConvertedConstantBinding); TypeConverterBinding converterBinding = ((ConvertedConstantBinding)binding).getTypeConverterBinding(); assertEquals("CustomConverter", converterBinding.getTypeConverter().toString()); assertTrue(injector.getTypeConverterBindings().contains(converterBinding)); } public void testInvalidCustomValue() throws CreationException { Module module = new AbstractModule() { protected void configure() { convertToTypes(Matchers.only(TypeLiteral.get(Date.class)), failingTypeConverter()); bindConstant().annotatedWith(NumericValue.class).to("invalid"); bind(DateHolder.class); } }; try { Guice.createInjector(module); fail(); } catch (CreationException expected) { Throwable cause = Iterables.getOnlyElement(expected.getErrorMessages()).getCause(); assertTrue(cause instanceof UnsupportedOperationException); assertContains(expected.getMessage(), "1) Error converting 'invalid' (bound at ", getClass().getName(), ".configure(TypeConversionTest.java:", "to java.util.Date", "using BrokenConverter which matches only(java.util.Date) ", "(bound at " + getClass().getName(), ".configure(TypeConversionTest.java:", "Reason: java.lang.UnsupportedOperationException: Cannot convert", "at " + DateHolder.class.getName() + ".date(TypeConversionTest.java:"); } } public void testNullCustomValue() { Module module = new AbstractModule() { protected void configure() { convertToTypes(Matchers.only(TypeLiteral.get(Date.class)), mockTypeConverter(null)); bindConstant().annotatedWith(NumericValue.class).to("foo"); bind(DateHolder.class); } }; try { Guice.createInjector(module); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Received null converting 'foo' (bound at ", getClass().getName(), ".configure(TypeConversionTest.java:", "to java.util.Date", "using CustomConverter which matches only(java.util.Date) ", "(bound at " + getClass().getName(), ".configure(TypeConversionTest.java:", "at " + DateHolder.class.getName() + ".date(TypeConversionTest.java:"); } } public void testCustomValueTypeMismatch() { Module module = new AbstractModule() { protected void configure() { convertToTypes(Matchers.only(TypeLiteral.get(Date.class)), mockTypeConverter(-1)); bindConstant().annotatedWith(NumericValue.class).to("foo"); bind(DateHolder.class); } }; try { Guice.createInjector(module); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Type mismatch converting 'foo' (bound at ", getClass().getName(), ".configure(TypeConversionTest.java:", "to java.util.Date", "using CustomConverter which matches only(java.util.Date) ", "(bound at " + getClass().getName(), ".configure(TypeConversionTest.java:", "Converter returned -1.", "at " + DateHolder.class.getName() + ".date(TypeConversionTest.java:"); } } public void testStringIsConvertedOnlyOnce() { final TypeConverter converter = new TypeConverter() { boolean converted = false; public Object convert(String value, TypeLiteral toType) { if (converted) { throw new AssertionFailedError("converted multiple times!"); } converted = true; return new Date(); } }; Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { convertToTypes(Matchers.only(TypeLiteral.get(Date.class)), converter); bindConstant().annotatedWith(NumericValue.class).to("unused"); } }); Date first = injector.getInstance(Key.get(Date.class, NumericValue.class)); Date second = injector.getInstance(Key.get(Date.class, NumericValue.class)); assertSame(first, second); } public void testAmbiguousTypeConversion() { Module module = new AbstractModule() { protected void configure() { convertToTypes(Matchers.only(TypeLiteral.get(Date.class)), mockTypeConverter(new Date())); convertToTypes(Matchers.only(TypeLiteral.get(Date.class)), mockTypeConverter(new Date())); bindConstant().annotatedWith(NumericValue.class).to("foo"); bind(DateHolder.class); } }; try { Guice.createInjector(module); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Multiple converters can convert 'foo' (bound at ", getClass().getName(), ".configure(TypeConversionTest.java:", "to java.util.Date:", "CustomConverter which matches only(java.util.Date)", "and", "CustomConverter which matches only(java.util.Date)", "Please adjust your type converter configuration to avoid overlapping matches.", "at " + DateHolder.class.getName() + ".date(TypeConversionTest.java:"); } } TypeConverter mockTypeConverter(final Object result) { return new TypeConverter() { public Object convert(String value, TypeLiteral toType) { return result; } @Override public String toString() { return "CustomConverter"; } }; } private TypeConverter failingTypeConverter() { return new TypeConverter() { public Object convert(String value, TypeLiteral toType) { throw new UnsupportedOperationException("Cannot convert"); } @Override public String toString() { return "BrokenConverter"; } }; } static class DateHolder { @Inject @NumericValue Date date; } public void ignoreTestCannotConvertUnannotatedBindings() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(String.class).toInstance("55"); } }); try { injector.getInstance(Integer.class); fail("Converted an unannotated String to an Integer"); } catch (ConfigurationException expected) { Asserts.assertContains(expected.getMessage(), "Could not find a suitable constructor in java.lang.Integer."); } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/SuperclassTest.java0000644000175000017500000000263411704661106025463 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import junit.framework.TestCase; /** * @author crazybob@google.com (Bob Lee) */ public class SuperclassTest extends TestCase { public void testSuperclassInjection() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Foo.class); } }); Provider creator = injector.getProvider(Sub.class); Sub sub = creator.get(); sub = creator.get(); sub = creator.get(); sub = creator.get(); sub = creator.get(); assertNotNull(sub.field); assertNotNull(sub.fromMethod); } static abstract class Super { @Inject Foo field; Foo fromMethod; @Inject void setC(Foo foo) { fromMethod = foo; } } static class Sub extends Super { } static class Foo {} } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/SuiteUtils.java0000644000175000017500000000247111704661106024610 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import junit.framework.Test; import junit.framework.TestSuite; import java.util.Enumeration; import java.util.Set; public class SuiteUtils { public static TestSuite removeSuppressedTests(TestSuite suite, Set suppressedTestNames) { TestSuite result = new TestSuite(suite.getName()); for(Enumeration e = suite.tests(); e.hasMoreElements(); ) { Test test = (Test) e.nextElement(); if (suppressedTestNames.contains(test.toString())) { continue; } if (test instanceof TestSuite) { result.addTest(removeSuppressedTests((TestSuite) test, suppressedTestNames)); } else { result.addTest(test); } } return result; } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/SerializationTest.java0000644000175000017500000000326411704661106026154 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertSimilarWhenReserialized; import junit.framework.AssertionFailedError; import junit.framework.TestCase; import java.io.IOException; import java.io.Serializable; import java.util.List; /** * @author jessewilson@google.com (Jesse Wilson) */ public class SerializationTest extends TestCase { public void testAbstractModuleIsSerializable() throws IOException { Asserts.reserialize(new MyAbstractModule()); } static class MyAbstractModule extends AbstractModule implements Serializable { protected void configure() {} } public void testCreationExceptionIsSerializable() throws IOException { assertSimilarWhenReserialized(createCreationException()); } private CreationException createCreationException() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(List.class); } }); throw new AssertionFailedError(); } catch (CreationException e) { return e; } } static class A { @Inject B b; } static class B {} } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/ScopesTest.java0000644000175000017500000006200411704661106024570 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static com.google.inject.name.Names.named; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.inject.name.Named; import com.google.inject.spi.Element; import com.google.inject.spi.Elements; import com.google.inject.spi.PrivateElements; import com.google.inject.util.Providers; import junit.framework.TestCase; import java.io.IOException; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Map; /** * @author crazybob@google.com (Bob Lee) */ public class ScopesTest extends TestCase { private final AbstractModule singletonsModule = new AbstractModule() { protected void configure() { bind(BoundAsSingleton.class).in(Scopes.SINGLETON); bind(AnnotatedSingleton.class); bind(EagerSingleton.class).asEagerSingleton(); bind(LinkedSingleton.class).to(RealLinkedSingleton.class); bind(DependsOnJustInTimeSingleton.class); bind(NotASingleton.class); bind(ImplementedBySingleton.class).in(Scopes.SINGLETON); bind(ProvidedBySingleton.class).in(Scopes.SINGLETON); } }; @Override protected void setUp() throws Exception { AnnotatedSingleton.nextInstanceId = 0; BoundAsSingleton.nextInstanceId = 0; EagerSingleton.nextInstanceId = 0; RealLinkedSingleton.nextInstanceId = 0; JustInTimeSingleton.nextInstanceId = 0; NotASingleton.nextInstanceId = 0; Implementation.nextInstanceId = 0; ProvidedBySingleton.nextInstanceId = 0; ThrowingSingleton.nextInstanceId = 0; } public void testSingletons() { Injector injector = Guice.createInjector(singletonsModule); assertSame( injector.getInstance(BoundAsSingleton.class), injector.getInstance(BoundAsSingleton.class)); assertSame( injector.getInstance(AnnotatedSingleton.class), injector.getInstance(AnnotatedSingleton.class)); assertSame( injector.getInstance(EagerSingleton.class), injector.getInstance(EagerSingleton.class)); assertSame( injector.getInstance(LinkedSingleton.class), injector.getInstance(LinkedSingleton.class)); assertSame( injector.getInstance(JustInTimeSingleton.class), injector.getInstance(JustInTimeSingleton.class)); assertNotSame( injector.getInstance(NotASingleton.class), injector.getInstance(NotASingleton.class)); assertSame( injector.getInstance(ImplementedBySingleton.class), injector.getInstance(ImplementedBySingleton.class)); assertSame( injector.getInstance(ProvidedBySingleton.class), injector.getInstance(ProvidedBySingleton.class)); } public void testJustInTimeAnnotatedSingleton() { Injector injector = Guice.createInjector(); assertSame( injector.getInstance(AnnotatedSingleton.class), injector.getInstance(AnnotatedSingleton.class)); } public void testSingletonIsPerInjector() { assertNotSame( Guice.createInjector().getInstance(AnnotatedSingleton.class), Guice.createInjector().getInstance(AnnotatedSingleton.class)); } public void testOverriddingAnnotation() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(AnnotatedSingleton.class).in(Scopes.NO_SCOPE); } }); assertNotSame( injector.getInstance(AnnotatedSingleton.class), injector.getInstance(AnnotatedSingleton.class)); } public void testScopingAnnotationsOnAbstractTypeViaBind() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(A.class).to(AImpl.class); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), A.class.getName() + " is annotated with " + Singleton.class.getName(), "but scope annotations are not supported for abstract types.", "at " + A.class.getName() + ".class(ScopesTest.java:"); } } @Singleton interface A {} static class AImpl implements A {} public void testScopingAnnotationsOnAbstractTypeViaImplementedBy() { try { Guice.createInjector().getInstance(D.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), D.class.getName() + " is annotated with " + Singleton.class.getName(), "but scope annotations are not supported for abstract types.", "at " + D.class.getName() + ".class(ScopesTest.java:"); } } @Singleton @ImplementedBy(DImpl.class) interface D {} static class DImpl implements D {} public void testScopingAnnotationsOnAbstractTypeViaProvidedBy() { try { Guice.createInjector().getInstance(E.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), E.class.getName() + " is annotated with " + Singleton.class.getName(), "but scope annotations are not supported for abstract types.", "at " + E.class.getName() + ".class(ScopesTest.java:"); } } @Singleton @ProvidedBy(EProvider.class) interface E {} static class EProvider implements Provider { public E get() { return null; } } public void testScopeUsedButNotBound() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(B.class).in(CustomScoped.class); bind(C.class); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) No scope is bound to " + CustomScoped.class.getName(), "at " + getClass().getName(), ".configure(ScopesTest.java:", "2) No scope is bound to " + CustomScoped.class.getName(), "at " + C.class.getName() + ".class"); } } static class B {} @CustomScoped static class C {} public void testSingletonsInProductionStage() { Guice.createInjector(Stage.PRODUCTION, singletonsModule); assertEquals(1, AnnotatedSingleton.nextInstanceId); assertEquals(1, BoundAsSingleton.nextInstanceId); assertEquals(1, EagerSingleton.nextInstanceId); assertEquals(1, RealLinkedSingleton.nextInstanceId); assertEquals(1, JustInTimeSingleton.nextInstanceId); assertEquals(0, NotASingleton.nextInstanceId); } public void testSingletonsInDevelopmentStage() { Guice.createInjector(Stage.DEVELOPMENT, singletonsModule); assertEquals(0, AnnotatedSingleton.nextInstanceId); assertEquals(0, BoundAsSingleton.nextInstanceId); assertEquals(1, EagerSingleton.nextInstanceId); assertEquals(0, RealLinkedSingleton.nextInstanceId); assertEquals(0, JustInTimeSingleton.nextInstanceId); assertEquals(0, NotASingleton.nextInstanceId); } public void testSingletonScopeIsNotSerializable() throws IOException { Asserts.assertNotSerializable(Scopes.SINGLETON); } public void testNoScopeIsNotSerializable() throws IOException { Asserts.assertNotSerializable(Scopes.NO_SCOPE); } public void ignoreTestUnscopedProviderWorksOutsideOfRequestedScope() { final RememberProviderScope scope = new RememberProviderScope(); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindScope(CustomScoped.class, scope); bind(List.class).to(ArrayList.class).in(CustomScoped.class); } }); injector.getInstance(List.class); Provider listProvider = scope.providers.get(Key.get(List.class)); // this line fails with a NullPointerException because the Providers // passed to Scope.scope() don't work outside of the scope() method. assertTrue(listProvider.get() instanceof ArrayList); } public void testScopeAnnotationWithoutRuntimeRetention() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bindScope(NotRuntimeRetainedScoped.class, Scopes.NO_SCOPE); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Please annotate with @Retention(RUNTIME).", "at " + NotRuntimeRetainedScoped.class.getName() + ".class(ScopesTest.java:"); } } public void testBindScopeToAnnotationWithoutScopeAnnotation() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bindScope(Deprecated.class, Scopes.NO_SCOPE); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Please annotate with @ScopeAnnotation.", "at " + Deprecated.class.getName() + ".class("); } } public void testBindScopeTooManyTimes() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bindScope(CustomScoped.class, Scopes.NO_SCOPE); bindScope(CustomScoped.class, Scopes.SINGLETON); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Scope Scopes.NO_SCOPE is already bound to " + CustomScoped.class.getName(), "Cannot bind Scopes.SINGLETON.", "at " + ScopesTest.class.getName(), ".configure(ScopesTest.java:"); } } public void testDuplicateScopeAnnotations() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindScope(CustomScoped.class, Scopes.NO_SCOPE); } }); try { injector.getInstance(SingletonAndCustomScoped.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "1) More than one scope annotation was found: ", "while locating " + SingletonAndCustomScoped.class.getName()); } } public void testNullScopedAsASingleton() { Provider unscoped = new Provider() { final Iterator values = Arrays.asList(null, "A").iterator(); public String get() { return values.next(); } }; Provider scoped = Scopes.SINGLETON.scope(Key.get(String.class), unscoped); assertNull(scoped.get()); assertNull(scoped.get()); assertNull(scoped.get()); } class RememberProviderScope implements Scope { final Map, Provider> providers = Maps.newHashMap(); public Provider scope(Key key, Provider unscoped) { providers.put(key, unscoped); return unscoped; } } public void testSingletonAnnotationOnParameterizedType() { Injector injector = Guice.createInjector(); assertSame(injector.getInstance(new Key>() {}), injector.getInstance(new Key>() {})); assertSame(injector.getInstance(new Key>() {}), injector.getInstance(new Key>() {})); } @ImplementedBy(Injected.class) public interface In {} @Singleton public static class Injected implements In {} @Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RUNTIME) @ScopeAnnotation public @interface CustomScoped {} static final Scope CUSTOM_SCOPE = new Scope() { public Provider scope(Key key, Provider unscoped) { return Scopes.SINGLETON.scope(key, unscoped); } }; @Target({ ElementType.TYPE, ElementType.METHOD }) @ScopeAnnotation public @interface NotRuntimeRetainedScoped {} @CustomScoped static class AnnotatedCustomScoped {} @Singleton static class AnnotatedSingleton { static int nextInstanceId; final int instanceId = nextInstanceId++; } static class BoundAsSingleton { static int nextInstanceId; final int instanceId = nextInstanceId++; } static class EagerSingleton { static int nextInstanceId; final int instanceId = nextInstanceId++; } interface LinkedSingleton {} @Singleton static class RealLinkedSingleton implements LinkedSingleton { static int nextInstanceId; final int instanceId = nextInstanceId++; } static class DependsOnJustInTimeSingleton { @Inject JustInTimeSingleton justInTimeSingleton; } @Singleton static class JustInTimeSingleton { static int nextInstanceId; final int instanceId = nextInstanceId++; } static class NotASingleton { static int nextInstanceId; final int instanceId = nextInstanceId++; } @Singleton @CustomScoped static class SingletonAndCustomScoped {} @ImplementedBy(Implementation.class) static interface ImplementedBySingleton {} @ProvidedBy(ImplementationProvider.class) static class ProvidedBySingleton { static int nextInstanceId; final int instanceId = nextInstanceId++; } static class Implementation implements ImplementedBySingleton { static int nextInstanceId; final int instanceId = nextInstanceId++; } static class ImplementationProvider implements Provider { public ProvidedBySingleton get() { return new ProvidedBySingleton(); } } public void testScopeThatGetsAnUnrelatedObject() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(B.class); bind(C.class); ProviderGetScope providerGetScope = new ProviderGetScope(); requestInjection(providerGetScope); bindScope(CustomScoped.class, providerGetScope); } }); injector.getInstance(C.class); } class ProviderGetScope implements Scope { @Inject Provider bProvider; public Provider scope(Key key, final Provider unscoped) { return new Provider() { public T get() { bProvider.get(); return unscoped.get(); } }; } } public void testIsSingletonPositive() { final Key a = Key.get(String.class, named("A")); final Key b = Key.get(String.class, named("B")); final Key c = Key.get(String.class, named("C")); final Key d = Key.get(String.class, named("D")); final Key e = Key.get(String.class, named("E")); final Key f = Key.get(String.class, named("F")); final Key g = Key.get(String.class, named("G")); final Key h = Key.get(Object.class, named("H")); final Key i = Key.get(String.class, named("I")); Module singletonBindings = new AbstractModule() { protected void configure() { bind(a).to(b); bind(b).to(c); bind(c).toProvider(Providers.of("c")).in(Scopes.SINGLETON); bind(d).toInstance("d"); bind(e).toProvider(Providers.of("e")).asEagerSingleton(); bind(f).toProvider(Providers.of("f")).in(Singleton.class); bind(h).to(AnnotatedSingleton.class); install(new PrivateModule() { @Override protected void configure() { bind(i).toProvider(Providers.of("i")).in(Singleton.class); expose(i); } }); } @Provides @Named("G") @Singleton String provideG() { return "g"; } }; @SuppressWarnings("unchecked") // we know the module contains only bindings List moduleBindings = Elements.getElements(singletonBindings); ImmutableMap, Binding> map = indexBindings(moduleBindings); assertFalse(Scopes.isSingleton(map.get(a))); // linked bindings are not followed by modules assertFalse(Scopes.isSingleton(map.get(b))); assertTrue(Scopes.isSingleton(map.get(c))); assertTrue(Scopes.isSingleton(map.get(d))); assertTrue(Scopes.isSingleton(map.get(e))); assertTrue(Scopes.isSingleton(map.get(f))); assertTrue(Scopes.isSingleton(map.get(g))); assertFalse(Scopes.isSingleton(map.get(h))); // annotated classes are not followed by modules assertTrue(Scopes.isSingleton(map.get(i))); Injector injector = Guice.createInjector(singletonBindings); assertTrue(Scopes.isSingleton(injector.getBinding(a))); assertTrue(Scopes.isSingleton(injector.getBinding(b))); assertTrue(Scopes.isSingleton(injector.getBinding(c))); assertTrue(Scopes.isSingleton(injector.getBinding(d))); assertTrue(Scopes.isSingleton(injector.getBinding(e))); assertTrue(Scopes.isSingleton(injector.getBinding(f))); assertTrue(Scopes.isSingleton(injector.getBinding(g))); assertTrue(Scopes.isSingleton(injector.getBinding(h))); assertTrue(Scopes.isSingleton(injector.getBinding(i))); } public void testIsSingletonNegative() { final Key a = Key.get(String.class, named("A")); final Key b = Key.get(String.class, named("B")); final Key c = Key.get(String.class, named("C")); final Key d = Key.get(String.class, named("D")); final Key e = Key.get(String.class, named("E")); final Key f = Key.get(String.class, named("F")); Module singletonBindings = new AbstractModule() { protected void configure() { bind(a).to(b); bind(b).to(c); bind(c).toProvider(Providers.of("c")).in(Scopes.NO_SCOPE); bind(d).toProvider(Providers.of("d")).in(CustomScoped.class); bindScope(CustomScoped.class, Scopes.NO_SCOPE); install(new PrivateModule() { @Override protected void configure() { bind(f).toProvider(Providers.of("f")).in(CustomScoped.class); expose(f); } }); } @Provides @Named("E") @CustomScoped String provideE() { return "e"; } }; @SuppressWarnings("unchecked") // we know the module contains only bindings List moduleBindings = Elements.getElements(singletonBindings); ImmutableMap, Binding> map = indexBindings(moduleBindings); assertFalse(Scopes.isSingleton(map.get(a))); assertFalse(Scopes.isSingleton(map.get(b))); assertFalse(Scopes.isSingleton(map.get(c))); assertFalse(Scopes.isSingleton(map.get(d))); assertFalse(Scopes.isSingleton(map.get(e))); assertFalse(Scopes.isSingleton(map.get(f))); Injector injector = Guice.createInjector(singletonBindings); assertFalse(Scopes.isSingleton(injector.getBinding(a))); assertFalse(Scopes.isSingleton(injector.getBinding(b))); assertFalse(Scopes.isSingleton(injector.getBinding(c))); assertFalse(Scopes.isSingleton(injector.getBinding(d))); assertFalse(Scopes.isSingleton(injector.getBinding(e))); assertFalse(Scopes.isSingleton(injector.getBinding(f))); } public void testIsScopedPositive() { final Key a = Key.get(String.class, named("A")); final Key b = Key.get(String.class, named("B")); final Key c = Key.get(String.class, named("C")); final Key d = Key.get(String.class, named("D")); final Key e = Key.get(String.class, named("E")); final Key f = Key.get(Object.class, named("F")); final Key g = Key.get(String.class, named("G")); Module customBindings = new AbstractModule() { protected void configure() { bindScope(CustomScoped.class, CUSTOM_SCOPE); bind(a).to(b); bind(b).to(c); bind(c).toProvider(Providers.of("c")).in(CUSTOM_SCOPE); bind(d).toProvider(Providers.of("d")).in(CustomScoped.class); bind(f).to(AnnotatedCustomScoped.class); install(new PrivateModule() { @Override protected void configure() { bind(g).toProvider(Providers.of("g")).in(CustomScoped.class); expose(g); } }); } @Provides @Named("E") @CustomScoped String provideE() { return "e"; } }; @SuppressWarnings("unchecked") // we know the module contains only bindings List moduleBindings = Elements.getElements(customBindings); ImmutableMap, Binding> map = indexBindings(moduleBindings); assertFalse(isCustomScoped(map.get(a))); // linked bindings are not followed by modules assertFalse(isCustomScoped(map.get(b))); assertTrue(isCustomScoped(map.get(c))); assertTrue(isCustomScoped(map.get(d))); assertTrue(isCustomScoped(map.get(e))); assertFalse(isCustomScoped(map.get(f))); // annotated classes are not followed by modules assertTrue(isCustomScoped(map.get(g))); Injector injector = Guice.createInjector(customBindings); assertTrue(isCustomScoped(injector.getBinding(a))); assertTrue(isCustomScoped(injector.getBinding(b))); assertTrue(isCustomScoped(injector.getBinding(c))); assertTrue(isCustomScoped(injector.getBinding(d))); assertTrue(isCustomScoped(injector.getBinding(e))); assertTrue(isCustomScoped(injector.getBinding(f))); assertTrue(isCustomScoped(injector.getBinding(g))); } public void testIsScopedNegative() { final Key a = Key.get(String.class, named("A")); final Key b = Key.get(String.class, named("B")); final Key c = Key.get(String.class, named("C")); final Key d = Key.get(String.class, named("D")); final Key e = Key.get(String.class, named("E")); final Key f = Key.get(String.class, named("F")); final Key g = Key.get(String.class, named("G")); final Key h = Key.get(String.class, named("H")); Module customBindings = new AbstractModule() { protected void configure() { bind(a).to(b); bind(b).to(c); bind(c).toProvider(Providers.of("c")).in(Scopes.NO_SCOPE); bind(d).toProvider(Providers.of("d")).in(Singleton.class); install(new PrivateModule() { @Override protected void configure() { bind(f).toProvider(Providers.of("f")).in(Singleton.class); expose(f); } }); bind(g).toInstance("g"); bind(h).toProvider(Providers.of("h")).asEagerSingleton(); } @Provides @Named("E") @Singleton String provideE() { return "e"; } }; @SuppressWarnings("unchecked") // we know the module contains only bindings List moduleBindings = Elements.getElements(customBindings); ImmutableMap, Binding> map = indexBindings(moduleBindings); assertFalse(isCustomScoped(map.get(a))); assertFalse(isCustomScoped(map.get(b))); assertFalse(isCustomScoped(map.get(c))); assertFalse(isCustomScoped(map.get(d))); assertFalse(isCustomScoped(map.get(e))); assertFalse(isCustomScoped(map.get(f))); assertFalse(isCustomScoped(map.get(g))); assertFalse(isCustomScoped(map.get(h))); Injector injector = Guice.createInjector(customBindings); assertFalse(isCustomScoped(injector.getBinding(a))); assertFalse(isCustomScoped(injector.getBinding(b))); assertFalse(isCustomScoped(injector.getBinding(c))); assertFalse(isCustomScoped(injector.getBinding(d))); assertFalse(isCustomScoped(injector.getBinding(e))); assertFalse(isCustomScoped(injector.getBinding(f))); assertFalse(isCustomScoped(injector.getBinding(g))); assertFalse(isCustomScoped(injector.getBinding(h))); } private boolean isCustomScoped(Binding binding) { return Scopes.isScoped(binding, CUSTOM_SCOPE, CustomScoped.class); } ImmutableMap, Binding> indexBindings(Iterable elements) { ImmutableMap.Builder, Binding> builder = ImmutableMap.builder(); for (Element element : elements) { if (element instanceof Binding) { Binding binding = (Binding) element; builder.put(binding.getKey(), binding); } else if (element instanceof PrivateElements) { PrivateElements privateElements = (PrivateElements)element; Map, Binding> privateBindings = indexBindings(privateElements.getElements()); for(Key exposed : privateElements.getExposedKeys()) { builder.put(exposed, privateBindings.get(exposed)); } } } return builder.build(); } @Singleton static class ThrowingSingleton { static int nextInstanceId; final int instanceId = nextInstanceId++; ThrowingSingleton() { if (instanceId == 0) { throw new RuntimeException(); } } } public void testSingletonConstructorThrows() { Injector injector = Guice.createInjector(); try { injector.getInstance(ThrowingSingleton.class); fail(); } catch (ProvisionException expected) { } // this behaviour is unspecified. If we change Guice to re-throw the exception, this test // should be changed injector.getInstance(ThrowingSingleton.class); assertEquals(2, ThrowingSingleton.nextInstanceId); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/RequestInjectionTest.java0000644000175000017500000001701111704661106026625 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.matcher.Matchers; import com.google.inject.spi.TypeEncounter; import com.google.inject.spi.TypeListener; import junit.framework.TestCase; import java.lang.annotation.Retention; /** * @author crazybob@google.com (Bob Lee) */ public class RequestInjectionTest extends TestCase { @Retention(RUNTIME) @BindingAnnotation @interface ForField {} @Retention(RUNTIME) @BindingAnnotation @interface ForMethod {} @Override protected void setUp() throws Exception { super.setUp(); HasInjections.staticField = 0; HasInjections.staticMethod = null; } public void testInjectMembers() { final HasInjections hi = new HasInjections(); Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindConstant().annotatedWith(ForMethod.class).to("test"); bindConstant().annotatedWith(ForField.class).to(5); requestInjection(hi); } }); assertEquals("test", hi.instanceMethod); assertEquals(5, hi.instanceField); assertNull(HasInjections.staticMethod); assertEquals(0, HasInjections.staticField); } public void testInjectStatics() throws CreationException { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindConstant().annotatedWith(ForMethod.class).to("test"); bindConstant().annotatedWith(ForField.class).to(5); requestStaticInjection(HasInjections.class); } }); assertEquals("test", HasInjections.staticMethod); assertEquals(5, HasInjections.staticField); } public void testInjectMembersAndStatics() { final HasInjections hi = new HasInjections(); Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindConstant().annotatedWith(ForMethod.class).to("test"); bindConstant().annotatedWith(ForField.class).to(5); requestStaticInjection(HasInjections.class); requestInjection(hi); } }); assertEquals("test", hi.instanceMethod); assertEquals(5, hi.instanceField); assertEquals("test", HasInjections.staticMethod); assertEquals(5, HasInjections.staticField); } public void testValidationErrorOnInjectedMembers() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { requestInjection(new NeedsRunnable()); } }); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) No implementation for java.lang.Runnable was bound", "at " + NeedsRunnable.class.getName(), ".runnable(RequestInjectionTest.java:"); } } public void testInjectionErrorOnInjectedMembers() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Runnable.class).toProvider(new Provider() { public Runnable get() { throw new UnsupportedOperationException(); } }); requestInjection(new NeedsRunnable()); } }); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Error in custom provider, java.lang.UnsupportedOperationException", "for field at " + NeedsRunnable.class.getName() + ".runnable(RequestInjectionTest.java:", "at " + getClass().getName(), ".configure(RequestInjectionTest.java:"); } } public void testUserExceptionWhileInjectingInstance() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { requestInjection(new BlowsUpOnInject()); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Error injecting method, java.lang.UnsupportedOperationException: Pop", "at " + BlowsUpOnInject.class.getName() + ".injectInstance(RequestInjectionTest.java:"); } } public void testUserExceptionWhileInjectingStatically() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { requestStaticInjection(BlowsUpOnInject.class); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Error injecting method, java.lang.UnsupportedOperationException: Snap", "at " + BlowsUpOnInject.class.getName() + ".injectStatically(RequestInjectionTest.java:"); } } static class NeedsRunnable { @Inject Runnable runnable; } static class HasInjections { @Inject @ForField static int staticField; @Inject @ForField int instanceField; static String staticMethod; String instanceMethod; @Inject static void setStaticMethod(@ForMethod String staticMethod) { HasInjections.staticMethod = staticMethod; } @Inject void setInstanceS(@ForMethod String instanceS) { this.instanceMethod = instanceS; } } static class BlowsUpOnInject { @Inject void injectInstance() { throw new UnsupportedOperationException("Pop"); } @Inject static void injectStatically() { throw new UnsupportedOperationException("Snap"); } } /* * Tests that initializables of the same instance don't clobber * membersInjectors in InitializableReference, so that they ultimately * can be requested in any order. */ public void testEarlyInjectableReferencesWithSameIdentity() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { // Add a listener to trigger all toInstance bindings to get an Initializable. bindListener(Matchers.any(), new TypeListener() { @Override public void hear(TypeLiteral type, TypeEncounter encounter) { } }); // Bind two different Keys to the IDENTITICAL object // ORDER MATTERS! We want the String binding to push out the Object one String fail = new String("better not fail!"); bind(Object.class).toInstance(fail); bind(String.class).toInstance(fail); // Then try to inject those objects in a requestInjection, // letting us get into InjectableReference.get before it has // finished running through all its injections. // Each of these technically has its own InjectableReference internally. // ORDER MATTERS!.. because Object is injected first, that InjectableReference // attempts to process its members injector, but it wasn't initialized, // because String pushed it out of the queue! requestInjection(new Object() { @SuppressWarnings("unused") @Inject Object obj; @SuppressWarnings("unused") @Inject String str; }); } }); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/ReflectionTest.java0000644000175000017500000000462211704661106025430 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static java.lang.annotation.RetentionPolicy.RUNTIME; import junit.framework.TestCase; import java.lang.annotation.Retention; /** * @author crazybob@google.com (Bob Lee) */ public class ReflectionTest extends TestCase { @Retention(RUNTIME) @BindingAnnotation @interface I {} public void testNormalBinding() throws CreationException { final Foo foo = new Foo(); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Foo.class).toInstance(foo); } }); Binding fooBinding = injector.getBinding(Key.get(Foo.class)); assertSame(foo, fooBinding.getProvider().get()); assertNotNull(fooBinding.getSource()); assertEquals(Key.get(Foo.class), fooBinding.getKey()); } public void testConstantBinding() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindConstant().annotatedWith(I.class).to(5); } }); Binding i = injector.getBinding(Key.get(int.class, I.class)); assertEquals(5, i.getProvider().get()); assertNotNull(i.getSource()); assertEquals(Key.get(int.class, I.class), i.getKey()); } public void testLinkedBinding() throws CreationException { final Bar bar = new Bar(); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Bar.class).toInstance(bar); bind(Key.get(Foo.class)).to(Key.get(Bar.class)); } }); Binding fooBinding = injector.getBinding(Key.get(Foo.class)); assertSame(bar, fooBinding.getProvider().get()); assertNotNull(fooBinding.getSource()); assertEquals(Key.get(Foo.class), fooBinding.getKey()); } static class Foo {} static class Bar extends Foo {} } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/ProvisionListenerTest.java0000644000175000017500000004513011704661106027033 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.common.collect.ImmutableList.of; import static com.google.inject.Asserts.assertContains; import static com.google.inject.name.Names.named; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.inject.matcher.Matcher; import com.google.inject.matcher.Matchers; import com.google.inject.name.Named; import com.google.inject.spi.DependencyAndSource; import com.google.inject.spi.ProvisionListener; import junit.framework.TestCase; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; /** * Tests for {@link Binder#bindListener(Matcher, ProvisionListener...)} * * @author sameb@google.com (Sam Berlin) */ public class ProvisionListenerTest extends TestCase { public void testExceptionInListenerBeforeProvisioning() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindListener(Matchers.any(), new FailBeforeProvision()); } }); try { injector.getInstance(Foo.class); fail(); } catch(ProvisionException pe) { assertEquals(1, pe.getErrorMessages().size()); assertContains(pe.getMessage(), "1) Error notifying ProvisionListener " + FailBeforeProvision.class.getName() + " of " + Foo.class.getName(), "Reason: java.lang.RuntimeException: boo", "while locating " + Foo.class.getName()); assertEquals("boo", pe.getCause().getMessage()); } } public void testExceptionInListenerAfterProvisioning() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindListener(Matchers.any(), new FailAfterProvision()); } }); try { injector.getInstance(Foo.class); fail(); } catch(ProvisionException pe) { assertEquals(1, pe.getErrorMessages().size()); assertContains(pe.getMessage(), "1) Error notifying ProvisionListener " + FailAfterProvision.class.getName() + " of " + Foo.class.getName(), "Reason: java.lang.RuntimeException: boo", "while locating " + Foo.class.getName()); assertEquals("boo", pe.getCause().getMessage()); } } public void testExceptionInProvisionExplicitlyCalled() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindListener(Matchers.any(), new JustProvision()); } }); try { injector.getInstance(FooBomb.class); fail(); } catch(ProvisionException pe) { assertEquals(1, pe.getErrorMessages().size()); assertContains(pe.getMessage(), "1) Error injecting constructor, java.lang.RuntimeException: Retry, Abort, Fail", " at " + FooBomb.class.getName(), " while locating " + FooBomb.class.getName()); assertEquals("Retry, Abort, Fail", pe.getCause().getMessage()); } } public void testExceptionInProvisionAutomaticallyCalled() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindListener(Matchers.any(), new NoProvision()); } }); try { injector.getInstance(FooBomb.class); fail(); } catch(ProvisionException pe) { assertEquals(1, pe.getErrorMessages().size()); assertContains(pe.getMessage(), "1) Error injecting constructor, java.lang.RuntimeException: Retry, Abort, Fail", " at " + FooBomb.class.getName(), " while locating " + FooBomb.class.getName()); assertEquals("Retry, Abort, Fail", pe.getCause().getMessage()); } } public void testListenerCallsProvisionTwice() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindListener(Matchers.any(), new ProvisionTwice()); } }); try { injector.getInstance(Foo.class); fail(); } catch(ProvisionException pe) { assertEquals(1, pe.getErrorMessages().size()); assertContains(pe.getMessage(), "1) Error notifying ProvisionListener " + ProvisionTwice.class.getName() + " of " + Foo.class.getName(), "Reason: java.lang.IllegalStateException: Already provisioned in this listener.", "while locating " + Foo.class.getName()); assertEquals("Already provisioned in this listener.", pe.getCause().getMessage()); } } public void testCachedInScopePreventsProvisionNotify() { final Counter count1 = new Counter(); Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindListener(Matchers.any(), count1); bind(Foo.class).in(Scopes.SINGLETON); } }); Foo foo = injector.getInstance(Foo.class); assertNotNull(foo); assertEquals(1, count1.count); // not notified the second time because nothing is provisioned // (it's cached in the scope) count1.count = 0; assertSame(foo, injector.getInstance(Foo.class)); assertEquals(0, count1.count); } public void testCombineAllBindListenerCalls() { final Counter count1 = new Counter(); final Counter count2 = new Counter(); Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindListener(Matchers.any(), count1); bindListener(Matchers.any(), count2); } }); assertNotNull(injector.getInstance(Foo.class)); assertEquals(1, count1.count); assertEquals(1, count2.count); } public void testNotifyEarlyListenersIfFailBeforeProvision() { final Counter count1 = new Counter(); final Counter count2 = new Counter(); Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindListener(Matchers.any(), count1, new FailBeforeProvision(), count2); } }); try { injector.getInstance(Foo.class); fail(); } catch(ProvisionException pe) { assertEquals(1, pe.getErrorMessages().size()); assertContains(pe.getMessage(), "1) Error notifying ProvisionListener " + FailBeforeProvision.class.getName() + " of " + Foo.class.getName(), "Reason: java.lang.RuntimeException: boo", "while locating " + Foo.class.getName()); assertEquals("boo", pe.getCause().getMessage()); assertEquals(1, count1.count); assertEquals(0, count2.count); } } public void testNotifyLaterListenersIfFailAfterProvision() { final Counter count1 = new Counter(); final Counter count2 = new Counter(); Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindListener(Matchers.any(), count1, new FailAfterProvision(), count2); } }); try { injector.getInstance(Foo.class); fail(); } catch(ProvisionException pe) { assertEquals(1, pe.getErrorMessages().size()); assertContains(pe.getMessage(), "1) Error notifying ProvisionListener " + FailAfterProvision.class.getName() + " of " + Foo.class.getName(), "Reason: java.lang.RuntimeException: boo", "while locating " + Foo.class.getName()); assertEquals("boo", pe.getCause().getMessage()); assertEquals(1, count1.count); assertEquals(1, count2.count); } } public void testNotifiedKeysOfAllBindTypes() { final Capturer capturer = new Capturer(); Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindListener(Matchers.any(), capturer); bind(Foo.class).annotatedWith(named("pk")).toProvider(FooP.class); try { bind(Foo.class).annotatedWith(named("cxtr")).toConstructor(Foo.class.getDeclaredConstructor()); } catch (Exception ex) { throw new RuntimeException(ex); } bind(LinkedFoo.class).to(Foo.class); } @Provides @Named("pi") Foo provideFooBar() { return new Foo(); } }); // simple binding assertNotNull(injector.getInstance(Foo.class)); assertEquals(of(Key.get(Foo.class)), capturer.getAndClear()); // provider key binding -- notifies about provider & the object, always assertNotNull(injector.getInstance(Key.get(Foo.class, named("pk")))); assertEquals(of(Key.get(FooP.class), Key.get(Foo.class, named("pk"))), capturer.getAndClear()); assertNotNull(injector.getInstance(Key.get(Foo.class, named("pk")))); assertEquals(of(Key.get(FooP.class), Key.get(Foo.class, named("pk"))), capturer.getAndClear()); // JIT provider key binding -- notifies about provider & the object, always assertNotNull(injector.getInstance(JitFoo2.class)); assertEquals(of(Key.get(JitFoo2P.class), Key.get(JitFoo2.class)), capturer.getAndClear()); assertNotNull(injector.getInstance(JitFoo2.class)); assertEquals(of(Key.get(JitFoo2P.class), Key.get(JitFoo2.class)), capturer.getAndClear()); // provider instance binding -- just the object (not the provider) assertNotNull(injector.getInstance(Key.get(Foo.class, named("pi")))); assertEquals(of(Key.get(Foo.class, named("pi"))), capturer.getAndClear()); // toConstructor binding assertNotNull(injector.getInstance(Key.get(Foo.class, named("cxtr")))); assertEquals(of(Key.get(Foo.class, named("cxtr"))), capturer.getAndClear()); // linked binding -- notifies about the target (that's what's provisioned), not the link assertNotNull(injector.getInstance(LinkedFoo.class)); assertEquals(of(Key.get(Foo.class)), capturer.getAndClear()); // JIT linked binding -- notifies about the target (that's what's provisioned), not the link assertNotNull(injector.getInstance(JitFoo.class)); assertEquals(of(Key.get(Foo.class)), capturer.getAndClear()); } @ImplementedBy(Foo.class) static interface JitFoo {} @ProvidedBy(JitFoo2P.class) static class JitFoo2 {} static interface LinkedFoo {} static class Foo implements JitFoo, LinkedFoo {} static class FooP implements Provider { public Foo get() { return new Foo(); } } static class JitFoo2P implements Provider { public JitFoo2 get() { return new JitFoo2(); } } static class FooBomb { FooBomb() { throw new RuntimeException("Retry, Abort, Fail"); } } private static class Counter implements ProvisionListener { int count = 0; public void onProvision(ProvisionInvocation provision) { count++; } } private static class Capturer implements ProvisionListener { List keys = Lists.newArrayList(); public void onProvision(ProvisionInvocation provision) { keys.add(provision.getKey()); T provisioned = provision.provision(); assertEquals(provision.getKey().getRawType(), provisioned.getClass()); } List getAndClear() { List copy = ImmutableList.copyOf(keys); keys.clear(); return copy; } } private static class FailBeforeProvision implements ProvisionListener { public void onProvision(ProvisionInvocation provision) { throw new RuntimeException("boo"); } } private static class FailAfterProvision implements ProvisionListener { public void onProvision(ProvisionInvocation provision) { provision.provision(); throw new RuntimeException("boo"); } } private static class JustProvision implements ProvisionListener { public void onProvision(ProvisionInvocation provision) { provision.provision(); } } private static class NoProvision implements ProvisionListener { public void onProvision(ProvisionInvocation provision) { } } private static class ProvisionTwice implements ProvisionListener { public void onProvision(ProvisionInvocation provision) { provision.provision(); provision.provision(); } } private static class ChainAsserter implements ProvisionListener { private final List> provisionList; private final List> expected; public ChainAsserter(List> provisionList, Iterable> expected) { this.provisionList = provisionList; this.expected = ImmutableList.copyOf(expected); } public void onProvision(ProvisionInvocation provision) { List> actual = Lists.newArrayList(); for (DependencyAndSource dep : provision.getDependencyChain()) { actual.add(dep.getDependency().getKey().getRawType()); } assertEquals(expected, actual); provisionList.add(provision.getKey().getRawType()); } } private static Matcher keyMatcher(Class clazz) { return Matchers.only(Key.get(clazz)); } @SuppressWarnings("unchecked") public void testDependencyChain() { final List> pList = Lists.newArrayList(); final List> totalList = Lists.newArrayList(); Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Instance.class).toInstance(new Instance()); bind(B.class).to(BImpl.class); bind(D.class).toProvider(DP.class); bindListener(Matchers.any(), new ProvisionListener() { public void onProvision(ProvisionInvocation provision) { totalList.add(provision.getKey().getRawType()); } }); // Build up a list of asserters for our dependency chains. ImmutableList.Builder> chain = ImmutableList.builder(); chain.add(Instance.class).add(A.class); bindListener(keyMatcher(A.class), new ChainAsserter(pList, chain.build())); chain.add(B.class).add(BImpl.class); bindListener(keyMatcher(BImpl.class), new ChainAsserter(pList, chain.build())); chain.add(C.class); bindListener(keyMatcher(C.class), new ChainAsserter(pList, chain.build())); // the chain has D before DP even though DP is provisioned & notified first // because we do DP because of D, and need DP to provision D. chain.add(D.class).add(DP.class); bindListener(keyMatcher(D.class), new ChainAsserter(pList, chain.build())); bindListener(keyMatcher(DP.class), new ChainAsserter(pList, chain.build())); chain.add(E.class); bindListener(keyMatcher(E.class), new ChainAsserter(pList, chain.build())); chain.add(F.class); bindListener(keyMatcher(F.class), new ChainAsserter(pList, chain.build())); } @Provides C c(D d) { return new C() {}; } }); Instance instance = injector.getInstance(Instance.class); // make sure we're checking all of the chain asserters.. assertEquals(of(A.class, BImpl.class, C.class, DP.class, D.class, E.class, F.class), pList); // and make sure that nothing else was notified that we didn't expect. assertEquals(totalList, pList); } public void testModuleRequestInjection() { final AtomicBoolean notified = new AtomicBoolean(); Guice.createInjector(new AbstractModule() { @Override protected void configure() { requestInjection(new Object() { @Inject Foo foo; }); bindListener(Matchers.any(), new SpecialChecker(Foo.class, getClass().getName() + ".configure(", notified)); } }); assertTrue(notified.get()); } public void testToProviderInstance() { final AtomicBoolean notified = new AtomicBoolean(); Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Object.class).toProvider(new Provider() { @Inject Foo foo; public Object get() { return null; } }); bindListener(Matchers.any(), new SpecialChecker(Foo.class, getClass().getName() + ".configure(", notified)); } }); assertTrue(notified.get()); } public void testInjectorInjectMembers() { final Object object = new Object() { @Inject Foo foo; }; final AtomicBoolean notified = new AtomicBoolean(); Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindListener(Matchers.any(), new SpecialChecker(Foo.class, object.getClass().getName(), notified)); } }).injectMembers(object); assertTrue(notified.get()); } private static class SpecialChecker implements ProvisionListener { private final Class notifyType; private final String firstSource; private final AtomicBoolean notified; public SpecialChecker(Class notifyType, String firstSource, AtomicBoolean notified) { this.notifyType = notifyType; this.firstSource = firstSource; this.notified = notified; } public void onProvision(ProvisionInvocation provision) { notified.set(true); assertEquals(notifyType, provision.getKey().getRawType()); assertEquals(2, provision.getDependencyChain().size()); assertEquals(null, provision.getDependencyChain().get(0).getDependency()); assertContains(provision.getDependencyChain().get(0).getBindingSource(), firstSource); assertEquals(notifyType, provision.getDependencyChain().get(1).getDependency().getKey().getRawType()); assertContains(provision.getDependencyChain().get(1).getBindingSource(), notifyType.getName() + ".class("); } } private static class Instance { @Inject A a; } private static class A { @Inject A(B b) {} } private interface B {} private static class BImpl implements B { @Inject void inject(C c) {} } private interface C {} private interface D {} private static class DP implements Provider { @Inject Provider ep; public D get() { ep.get(); return new D() {}; } } private static class E { @SuppressWarnings("unused") @Inject F f; } private static class F {} } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/ProvisionExceptionsTest.java0000644000175000017500000001431211704661106027365 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import com.google.inject.internal.Errors; import com.google.inject.name.Named; import com.google.inject.name.Names; import junit.framework.TestCase; import java.io.IOException; /** * Tests that ProvisionExceptions are readable and clearly indicate to the user what went wrong with * their code. * * @author sameb@google.com (Sam Berlin) */ public class ProvisionExceptionsTest extends TestCase { public void testConstructorRuntimeException() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindConstant().annotatedWith(Names.named("runtime")).to(true); bind(Exploder.class).to(Explosion.class); bind(Tracer.class).to(TracerImpl.class); } }); try { injector.getInstance(Tracer.class); fail(); } catch(ProvisionException pe) { // Make sure our initial error message gives the user exception. Asserts.assertContains(pe.getMessage(), "1) Error injecting constructor", "java.lang.IllegalStateException: boom!"); assertEquals(1, pe.getErrorMessages().size()); assertEquals(IllegalStateException.class, pe.getCause().getClass()); assertEquals(IllegalStateException.class, Errors.getOnlyCause(pe.getErrorMessages()).getClass()); } } public void testConstructorCheckedException() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindConstant().annotatedWith(Names.named("runtime")).to(false); bind(Exploder.class).to(Explosion.class); bind(Tracer.class).to(TracerImpl.class); } }); try { injector.getInstance(Tracer.class); fail(); } catch(ProvisionException pe) { // Make sure our initial error message gives the user exception. Asserts.assertContains(pe.getMessage(), "1) Error injecting constructor", "java.io.IOException: boom!"); assertEquals(1, pe.getErrorMessages().size()); assertEquals(IOException.class, pe.getCause().getClass()); assertEquals(IOException.class, Errors.getOnlyCause(pe.getErrorMessages()).getClass()); } } public void testCustomProvidersRuntimeException() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Exploder.class).toProvider(new Provider() { public Exploder get() { return Explosion.createRuntime(); } }); bind(Tracer.class).to(TracerImpl.class); } }); try { injector.getInstance(Tracer.class); fail(); } catch(ProvisionException pe) { // Make sure our initial error message gives the user exception. Asserts.assertContains(pe.getMessage(), "1) Error in custom provider", "java.lang.IllegalStateException: boom!"); assertEquals(1, pe.getErrorMessages().size()); assertEquals(IllegalStateException.class, pe.getCause().getClass()); assertEquals(IllegalStateException.class, Errors.getOnlyCause(pe.getErrorMessages()).getClass()); } } public void testProviderMethodRuntimeException() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Tracer.class).to(TracerImpl.class); } @Provides Exploder exploder() { return Explosion.createRuntime(); } }); try { injector.getInstance(Tracer.class); fail(); } catch(ProvisionException pe) { // Make sure our initial error message gives the user exception. Asserts.assertContains(pe.getMessage(), "1) Error in custom provider", "java.lang.IllegalStateException: boom!"); assertEquals(1, pe.getErrorMessages().size()); assertEquals(IllegalStateException.class, pe.getCause().getClass()); assertEquals(IllegalStateException.class, Errors.getOnlyCause(pe.getErrorMessages()).getClass()); } } public void testProviderMethodCheckedException() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Tracer.class).to(TracerImpl.class); } @Provides Exploder exploder() throws IOException { return Explosion.createChecked(); } }); try { injector.getInstance(Tracer.class); fail(); } catch(ProvisionException pe) { pe.printStackTrace(); // Make sure our initial error message gives the user exception. Asserts.assertContains(pe.getMessage(), "1) Error in custom provider", "java.io.IOException: boom!"); assertEquals(1, pe.getErrorMessages().size()); assertEquals(IOException.class, pe.getCause().getClass()); assertEquals(IOException.class, Errors.getOnlyCause(pe.getErrorMessages()).getClass()); } } private static interface Exploder {} public static class Explosion implements Exploder { @Inject public Explosion(@Named("runtime") boolean runtime) throws IOException { if(runtime) { throw new IllegalStateException("boom!"); } else { throw new IOException("boom!"); } } public static Explosion createRuntime() { try { return new Explosion(true); } catch(IOException iox) { throw new RuntimeException(); } } public static Explosion createChecked() throws IOException { return new Explosion(false); } } private static interface Tracer {} private static class TracerImpl implements Tracer { @Inject TracerImpl(Exploder explosion) { } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/ProvisionExceptionTest.java0000644000175000017500000002714311704661106027210 0ustar tonytony/** * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static com.google.inject.Asserts.reserialize; import static java.lang.annotation.ElementType.CONSTRUCTOR; import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.PARAMETER; import static java.lang.annotation.RetentionPolicy.RUNTIME; import junit.framework.TestCase; import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * @author jessewilson@google.com (Jesse Wilson) */ @SuppressWarnings("UnusedDeclaration") public class ProvisionExceptionTest extends TestCase { public void testExceptionsCollapsed() { try { Guice.createInjector().getInstance(A.class); fail(); } catch (ProvisionException e) { assertTrue(e.getCause() instanceof UnsupportedOperationException); assertContains(e.getMessage(), "Error injecting constructor", "for parameter 0 at com.google.inject.ProvisionExceptionTest$C.setD", "for field at com.google.inject.ProvisionExceptionTest$B.c", "for parameter 0 at com.google.inject.ProvisionExceptionTest$A"); } } /** * There's a pass-through of user code in the scope. We want exceptions thrown by Guice to be * limited to a single exception, even if it passes through user code. */ public void testExceptionsCollapsedWithScopes() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(B.class).in(Scopes.SINGLETON); } }).getInstance(A.class); fail(); } catch (ProvisionException e) { assertTrue(e.getCause() instanceof UnsupportedOperationException); assertFalse(e.getMessage().contains("custom provider")); assertContains(e.getMessage(), "Error injecting constructor", "for parameter 0 at com.google.inject.ProvisionExceptionTest$C.setD", "for field at com.google.inject.ProvisionExceptionTest$B.c", "for parameter 0 at com.google.inject.ProvisionExceptionTest$A"); } } public void testMethodInjectionExceptions() { try { Guice.createInjector().getInstance(E.class); fail(); } catch (ProvisionException e) { assertTrue(e.getCause() instanceof UnsupportedOperationException); assertContains(e.getMessage(), "Error injecting method", "at " + E.class.getName() + ".setObject(ProvisionExceptionTest.java:"); } } public void testBindToProviderInstanceExceptions() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(D.class).toProvider(new DProvider()); } }).getInstance(D.class); fail(); } catch (ProvisionException e) { assertTrue(e.getCause() instanceof UnsupportedOperationException); assertContains(e.getMessage(), "1) Error in custom provider, java.lang.UnsupportedOperationException", "at " + ProvisionExceptionTest.class.getName(), ".configure(ProvisionExceptionTest.java"); } } /** * This test demonstrates that if the user throws a ProvisionException, we wrap it to add context. */ public void testProvisionExceptionsAreWrappedForBindToType() { try { Guice.createInjector().getInstance(F.class); fail(); } catch (ProvisionException e) { assertContains(e.getMessage(), "1) User Exception", "at " + F.class.getName() + ".(ProvisionExceptionTest.java:"); } } public void testProvisionExceptionsAreWrappedForBindToProviderType() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(F.class).toProvider(FProvider.class); } }).getInstance(F.class); fail(); } catch (ProvisionException e) { assertContains(e.getMessage(), "1) User Exception", "while locating ", FProvider.class.getName(), "while locating ", F.class.getName()); } } public void testProvisionExceptionsAreWrappedForBindToProviderInstance() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(F.class).toProvider(new FProvider()); } }).getInstance(F.class); fail(); } catch (ProvisionException e) { assertContains(e.getMessage(), "1) User Exception", "at " + ProvisionExceptionTest.class.getName(), ".configure(ProvisionExceptionTest.java"); } } public void testProvisionExceptionIsSerializable() throws IOException { try { Guice.createInjector().getInstance(A.class); fail(); } catch (ProvisionException expected) { ProvisionException reserialized = reserialize(expected); assertContains(reserialized.getMessage(), "1) Error injecting constructor, java.lang.UnsupportedOperationException", "at com.google.inject.ProvisionExceptionTest$RealD.()", "at Key[type=com.google.inject.ProvisionExceptionTest$RealD, annotation=[none]]", "@com.google.inject.ProvisionExceptionTest$C.setD()[0]", "at Key[type=com.google.inject.ProvisionExceptionTest$C, annotation=[none]]", "@com.google.inject.ProvisionExceptionTest$B.c", "at Key[type=com.google.inject.ProvisionExceptionTest$B, annotation=[none]]", "@com.google.inject.ProvisionExceptionTest$A.()[0]", "at Key[type=com.google.inject.ProvisionExceptionTest$A, annotation=[none]]"); } } public void testMultipleCauses() { try { Guice.createInjector().getInstance(G.class); fail(); } catch (ProvisionException e) { assertContains(e.getMessage(), "1) Error injecting method, java.lang.IllegalArgumentException", "Caused by: java.lang.IllegalArgumentException: java.lang.UnsupportedOperationException", "Caused by: java.lang.UnsupportedOperationException: Unsupported", "2) Error injecting method, java.lang.NullPointerException: can't inject second either", "Caused by: java.lang.NullPointerException: can't inject second either", "2 errors"); } } public void testInjectInnerClass() throws Exception { Injector injector = Guice.createInjector(); try { injector.getInstance(InnerClass.class); fail(); } catch (Exception expected) { assertContains(expected.getMessage(), "Injecting into inner classes is not supported.", "while locating " + InnerClass.class.getName()); } } public void testInjectLocalClass() throws Exception { class LocalClass {} Injector injector = Guice.createInjector(); try { injector.getInstance(LocalClass.class); fail(); } catch (Exception expected) { assertContains(expected.getMessage(), "Injecting into inner classes is not supported.", "while locating " + LocalClass.class.getName()); } } public void testBindingAnnotationsOnMethodsAndConstructors() { try { Injector injector = Guice.createInjector(); injector.getInstance(MethodWithBindingAnnotation.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), MethodWithBindingAnnotation.class.getName() + ".injectMe() is annotated with @", Green.class.getName() + "(), ", "but binding annotations should be applied to its parameters instead.", "while locating " + MethodWithBindingAnnotation.class.getName()); } try { Guice.createInjector().getInstance(ConstructorWithBindingAnnotation.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), ConstructorWithBindingAnnotation.class.getName() + ".() is annotated with @", Green.class.getName() + "(), ", "but binding annotations should be applied to its parameters instead.", "at " + ConstructorWithBindingAnnotation.class.getName() + ".class", "while locating " + ConstructorWithBindingAnnotation.class.getName()); } } public void testBindingAnnotationWarningForScala() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(String.class).annotatedWith(Green.class).toInstance("lime!"); } }); injector.getInstance(LikeScala.class); } public void testLinkedBindings() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(D.class).to(RealD.class); } }); try { injector.getInstance(D.class); fail(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "at " + RealD.class.getName() + ".(ProvisionExceptionTest.java:", "while locating " + RealD.class.getName(), "while locating " + D.class.getName()); } } public void testProviderKeyBindings() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(D.class).toProvider(DProvider.class); } }); try { injector.getInstance(D.class); fail(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "while locating " + DProvider.class.getName(), "while locating " + D.class.getName()); } } private class InnerClass {} static class A { @Inject A(B b) { } } static class B { @Inject C c; } static class C { @Inject void setD(RealD d) { } } static class E { @Inject void setObject(Object o) { throw new UnsupportedOperationException(); } } static class MethodWithBindingAnnotation { @Inject @Green void injectMe(String greenString) {} } static class ConstructorWithBindingAnnotation { @Inject @Green ConstructorWithBindingAnnotation(String greenString) {} } /** * In Scala, fields automatically get accessor methods with the same name. So we don't do * misplaced-binding annotation detection if the offending method has a matching field. */ static class LikeScala { @Inject @Green String green; @Inject @Green String green() { return green; } } @Retention(RUNTIME) @Target({ FIELD, PARAMETER, CONSTRUCTOR, METHOD }) @BindingAnnotation @interface Green {} interface D {} static class RealD implements D { @Inject RealD() { throw new UnsupportedOperationException(); } } static class DProvider implements Provider { public D get() { throw new UnsupportedOperationException(); } } static class F { @Inject public F() { throw new ProvisionException("User Exception", new RuntimeException()); } } static class FProvider implements Provider { public F get() { return new F(); } } static class G { @Inject void injectFirst() { throw new IllegalArgumentException(new UnsupportedOperationException("Unsupported")); } @Inject void injectSecond() { throw new NullPointerException("can't inject second either"); } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/ProviderInjectionTest.java0000644000175000017500000001301711704661106026771 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.name.Names.named; import com.google.inject.name.Named; import junit.framework.TestCase; import java.util.Arrays; import java.util.List; /** * @author crazybob@google.com (Bob Lee) */ public class ProviderInjectionTest extends TestCase { public void testProviderInjection() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Bar.class); bind(SampleSingleton.class).in(Scopes.SINGLETON); } }); Foo foo = injector.getInstance(Foo.class); Bar bar = foo.barProvider.get(); assertNotNull(bar); assertNotSame(bar, foo.barProvider.get()); SampleSingleton singleton = foo.singletonProvider.get(); assertNotNull(singleton); assertSame(singleton, foo.singletonProvider.get()); } /** Test for bug 155. */ public void testProvidersAreInjectedWhenBound() { Module m = new AbstractModule() { @Override protected void configure() { bind(Bar.class).toProvider(new Provider() { @SuppressWarnings("unused") @Inject void cantBeCalled(Baz baz) { fail("Can't have called this method since Baz is not bound."); } public Bar get() { return new Bar() {}; } }); } }; try { Guice.createInjector(m); fail("Should have thrown a CreationException"); } catch (CreationException expected) { } } /** * When custom providers are used at injector creation time, they should be * injected before use. In this testcase, we verify that a provider for * List.class is injected before it is used. */ public void testProvidersAreInjectedBeforeTheyAreUsed() { Injector injector = Guice.createInjector(new AbstractModule() { public void configure() { // should bind String to "[true]" bind(String.class).toProvider(new Provider() { private String value; @Inject void initialize(List list) { value = list.toString(); } public String get() { return value; } }); // should bind List to [true] bind(List.class).toProvider(new Provider() { @Inject Boolean injectedYet = Boolean.FALSE; public List get() { return Arrays.asList(injectedYet); } }); // should bind Boolean to true bind(Boolean.class).toInstance(Boolean.TRUE); } }); assertEquals("Providers not injected before use", "[true]", injector.getInstance(String.class)); } /** * This test ensures that regardless of binding order, instances are injected * before they are used. It injects mutable Count objects and records their * value at the time that they're injected. */ public void testCreationTimeInjectionOrdering() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { // instance injection bind(Count.class).annotatedWith(named("a")).toInstance(new Count(0) { @Inject void initialize(@Named("b") Count bCount) { value = bCount.value + 1; } }); // provider injection bind(Count.class).annotatedWith(named("b")).toProvider(new Provider() { Count count; @Inject void initialize(@Named("c") Count cCount) { count = new Count(cCount.value + 2); } public Count get() { return count; } }); // field and method injection, fields first bind(Count.class).annotatedWith(named("c")).toInstance(new Count(0) { @Inject @Named("d") Count dCount; @Inject void initialize(@Named("e") Count eCount) { value = dCount.value + eCount.value + 4; } }); // static injection requestStaticInjection(StaticallyInjectable.class); bind(Count.class).annotatedWith(named("d")).toInstance(new Count(8)); bind(Count.class).annotatedWith(named("e")).toInstance(new Count(16)); } }); assertEquals(28, injector.getInstance(Key.get(Count.class, named("c"))).value); assertEquals(30, injector.getInstance(Key.get(Count.class, named("b"))).value); assertEquals(31, injector.getInstance(Key.get(Count.class, named("a"))).value); assertEquals(28, StaticallyInjectable.cCountAtInjectionTime); } static class Count { int value; Count(int value) { this.value = value; } } static class StaticallyInjectable { static int cCountAtInjectionTime; @Inject static void initialize(@Named("c") Count cCount) { cCountAtInjectionTime = cCount.value; } } static class Foo { @Inject Provider barProvider; @Inject Provider singletonProvider; } static class Bar {} static class SampleSingleton {} interface Baz { } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/PrivateModuleTest.java0000644000175000017500000004565711704661106026133 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static com.google.inject.name.Names.named; import com.google.common.collect.ImmutableSet; import com.google.inject.name.Named; import com.google.inject.name.Names; import com.google.inject.spi.Dependency; import com.google.inject.spi.ExposedBinding; import com.google.inject.spi.PrivateElements; import com.google.inject.util.Types; import junit.framework.TestCase; import java.util.ArrayList; import java.util.Collection; import java.util.List; /** * @author jessewilson@google.com (Jesse Wilson) */ public class PrivateModuleTest extends TestCase { public void testBasicUsage() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(String.class).annotatedWith(named("a")).toInstance("public"); install(new PrivateModule() { public void configure() { bind(String.class).annotatedWith(named("b")).toInstance("i"); bind(AB.class).annotatedWith(named("one")).to(AB.class); expose(AB.class).annotatedWith(named("one")); } }); install(new PrivateModule() { public void configure() { bind(String.class).annotatedWith(named("b")).toInstance("ii"); bind(AB.class).annotatedWith(named("two")).to(AB.class); expose(AB.class).annotatedWith(named("two")); } }); } }); AB ab1 = injector.getInstance(Key.get(AB.class, named("one"))); assertEquals("public", ab1.a); assertEquals("i", ab1.b); AB ab2 = injector.getInstance(Key.get(AB.class, named("two"))); assertEquals("public", ab2.a); assertEquals("ii", ab2.b); } public void testWithoutPrivateModules() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { PrivateBinder bindA = binder().newPrivateBinder(); bindA.bind(String.class).annotatedWith(named("a")).toInstance("i"); bindA.expose(String.class).annotatedWith(named("a")); bindA.bind(String.class).annotatedWith(named("c")).toInstance("private to A"); PrivateBinder bindB = binder().newPrivateBinder(); bindB.bind(String.class).annotatedWith(named("b")).toInstance("ii"); bindB.expose(String.class).annotatedWith(named("b")); bindB.bind(String.class).annotatedWith(named("c")).toInstance("private to B"); } }); assertEquals("i", injector.getInstance(Key.get(String.class, named("a")))); assertEquals("ii", injector.getInstance(Key.get(String.class, named("b")))); } public void testMisplacedExposedAnnotation() { try { Guice.createInjector(new AbstractModule() { protected void configure() {} @Provides @Exposed String provideString() { return "i"; } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "Cannot expose java.lang.String on a standard binder. ", "Exposed bindings are only applicable to private binders.", " at " + PrivateModuleTest.class.getName(), "provideString(PrivateModuleTest.java:"); } } public void testMisplacedExposeStatement() { try { Guice.createInjector(new AbstractModule() { protected void configure() { ((PrivateBinder) binder()).expose(String.class).annotatedWith(named("a")); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "Cannot expose java.lang.String on a standard binder. ", "Exposed bindings are only applicable to private binders.", " at " + PrivateModuleTest.class.getName(), "configure(PrivateModuleTest.java:"); } } public void testPrivateModulesAndProvidesMethods() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { install(new PrivateModule() { public void configure() { expose(String.class).annotatedWith(named("a")); } @Provides @Named("a") String providePublicA() { return "i"; } @Provides @Named("b") String providePrivateB() { return "private"; } }); install(new PrivateModule() { public void configure() {} @Provides @Named("c") String providePrivateC() { return "private"; } @Provides @Exposed @Named("d") String providePublicD() { return "ii"; } }); } }); assertEquals("i", injector.getInstance(Key.get(String.class, named("a")))); try { injector.getInstance(Key.get(String.class, named("b"))); fail(); } catch(ConfigurationException expected) { } try { injector.getInstance(Key.get(String.class, named("c"))); fail(); } catch(ConfigurationException expected) { } assertEquals("ii", injector.getInstance(Key.get(String.class, named("d")))); } public void testCannotBindAKeyExportedByASibling() { try { Guice.createInjector(new AbstractModule() { protected void configure() { install(new PrivateModule() { public void configure() { bind(String.class).toInstance("public"); expose(String.class); } }); install(new PrivateModule() { public void configure() { bind(String.class).toInstance("private"); } }); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "A binding to java.lang.String was already configured at ", getClass().getName(), ".configure(PrivateModuleTest.java:", " at " + getClass().getName(), ".configure(PrivateModuleTest.java:"); } } public void testExposeButNoBind() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(String.class).annotatedWith(named("a")).toInstance("a"); bind(String.class).annotatedWith(named("b")).toInstance("b"); install(new PrivateModule() { public void configure() { expose(AB.class); } }); } }); fail("AB was exposed but not bound"); } catch (CreationException expected) { assertContains(expected.getMessage(), "Could not expose() " + AB.class.getName() + ", it must be explicitly bound", ".configure(PrivateModuleTest.java:"); } } /** * Ensure that when we've got errors in different private modules, Guice presents all errors * in a unified message. */ public void testMessagesFromPrivateModulesAreNicelyIntegrated() { try { Guice.createInjector( new PrivateModule() { public void configure() { bind(C.class); } }, new PrivateModule() { public void configure() { bind(AB.class); } } ); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) No implementation for " + C.class.getName() + " was bound.", "at " + getClass().getName(), ".configure(PrivateModuleTest.java:", "2) No implementation for " + String.class.getName(), "Named(value=a) was bound.", "for field at " + AB.class.getName() + ".a(PrivateModuleTest.java:", "3) No implementation for " + String.class.getName(), "Named(value=b) was bound.", "for field at " + AB.class.getName() + ".b(PrivateModuleTest.java:", "3 errors"); } } public void testNestedPrivateInjectors() { Injector injector = Guice.createInjector(new PrivateModule() { public void configure() { expose(String.class); install(new PrivateModule() { public void configure() { bind(String.class).toInstance("nested"); expose(String.class); } }); } }); assertEquals("nested", injector.getInstance(String.class)); } public void testInstallingRegularModulesFromPrivateModules() { Injector injector = Guice.createInjector(new PrivateModule() { public void configure() { expose(String.class); install(new AbstractModule() { protected void configure() { bind(String.class).toInstance("nested"); } }); } }); assertEquals("nested", injector.getInstance(String.class)); } public void testNestedPrivateModulesWithSomeKeysUnexposed() { Injector injector = Guice.createInjector(new PrivateModule() { public void configure() { bind(String.class).annotatedWith(named("bound outer, exposed outer")).toInstance("boeo"); expose(String.class).annotatedWith(named("bound outer, exposed outer")); bind(String.class).annotatedWith(named("bound outer, exposed none")).toInstance("boen"); expose(String.class).annotatedWith(named("bound inner, exposed both")); install(new PrivateModule() { public void configure() { bind(String.class).annotatedWith(named("bound inner, exposed both")).toInstance("bieb"); expose(String.class).annotatedWith(named("bound inner, exposed both")); bind(String.class).annotatedWith(named("bound inner, exposed none")).toInstance("bien"); } }); } }); assertEquals("boeo", injector.getInstance(Key.get(String.class, named("bound outer, exposed outer")))); assertEquals("bieb", injector.getInstance(Key.get(String.class, named("bound inner, exposed both")))); try { injector.getInstance(Key.get(String.class, named("bound outer, exposed none"))); fail(); } catch (ConfigurationException expected) { } try { injector.getInstance(Key.get(String.class, named("bound inner, exposed none"))); fail(); } catch (ConfigurationException expected) { } } public void testDependenciesBetweenPrivateAndPublic() { Injector injector = Guice.createInjector( new PrivateModule() { protected void configure() {} @Provides @Exposed @Named("a") String provideA() { return "A"; } @Provides @Exposed @Named("abc") String provideAbc(@Named("ab") String ab) { return ab + "C"; } }, new AbstractModule() { protected void configure() {} @Provides @Named("ab") String provideAb(@Named("a") String a) { return a + "B"; } @Provides @Named("abcd") String provideAbcd(@Named("abc") String abc) { return abc + "D"; } } ); assertEquals("ABCD", injector.getInstance(Key.get(String.class, named("abcd")))); } public void testDependenciesBetweenPrivateAndPublicWithPublicEagerSingleton() { Injector injector = Guice.createInjector( new PrivateModule() { protected void configure() {} @Provides @Exposed @Named("a") String provideA() { return "A"; } @Provides @Exposed @Named("abc") String provideAbc(@Named("ab") String ab) { return ab + "C"; } }, new AbstractModule() { protected void configure() { bind(String.class).annotatedWith(named("abcde")).toProvider(new Provider() { @Inject @Named("abcd") String abcd; public String get() { return abcd + "E"; } }).asEagerSingleton(); } @Provides @Named("ab") String provideAb(@Named("a") String a) { return a + "B"; } @Provides @Named("abcd") String provideAbcd(@Named("abc") String abc) { return abc + "D"; } } ); assertEquals("ABCDE", injector.getInstance(Key.get(String.class, named("abcde")))); } public void testDependenciesBetweenPrivateAndPublicWithPrivateEagerSingleton() { Injector injector = Guice.createInjector( new AbstractModule() { protected void configure() {} @Provides @Named("ab") String provideAb(@Named("a") String a) { return a + "B"; } @Provides @Named("abcd") String provideAbcd(@Named("abc") String abc) { return abc + "D"; } }, new PrivateModule() { protected void configure() { bind(String.class).annotatedWith(named("abcde")).toProvider(new Provider() { @Inject @Named("abcd") String abcd; public String get() { return abcd + "E"; } }).asEagerSingleton(); expose(String.class).annotatedWith(named("abcde")); } @Provides @Exposed @Named("a") String provideA() { return "A"; } @Provides @Exposed @Named("abc") String provideAbc(@Named("ab") String ab) { return ab + "C"; } } ); assertEquals("ABCDE", injector.getInstance(Key.get(String.class, named("abcde")))); } static class AB { @Inject @Named("a") String a; @Inject @Named("b") String b; } interface C {} public void testSpiAccess() { Injector injector = Guice.createInjector(new PrivateModule() { public void configure() { bind(String.class).annotatedWith(named("a")).toInstance("private"); bind(String.class).annotatedWith(named("b")).toInstance("exposed"); expose(String.class).annotatedWith(named("b")); } }); ExposedBinding binding = (ExposedBinding) injector.getBinding(Key.get(String.class, Names.named("b"))); assertEquals(ImmutableSet.>of(Dependency.get(Key.get(Injector.class))), binding.getDependencies()); PrivateElements privateElements = binding.getPrivateElements(); assertEquals(ImmutableSet.>of(Key.get(String.class, named("b"))), privateElements.getExposedKeys()); assertContains(privateElements.getExposedSource(Key.get(String.class, named("b"))).toString(), PrivateModuleTest.class.getName(), ".configure(PrivateModuleTest.java:"); Injector privateInjector = privateElements.getInjector(); assertEquals("private", privateInjector.getInstance(Key.get(String.class, Names.named("a")))); } public void testParentBindsSomethingInPrivate() { try { Guice.createInjector(new FailingModule()); fail(); } catch(CreationException expected) { assertEquals(1, expected.getErrorMessages().size()); assertContains(expected.toString(), "Unable to create binding for java.util.List.", "It was already configured on one or more child injectors or private modules", "bound at " + FailingPrivateModule.class.getName() + ".configure(", "bound at " + SecondFailingPrivateModule.class.getName() + ".configure(", "If it was in a PrivateModule, did you forget to expose the binding?", "at " + FailingModule.class.getName() + ".configure("); } } public void testParentBindingToPrivateLinkedJitBinding() { Injector injector = Guice.createInjector(new ManyPrivateModules()); try { injector.getBinding(Key.get(Types.providerOf(List.class))); fail(); } catch(ConfigurationException expected) { assertEquals(1, expected.getErrorMessages().size()); assertContains(expected.toString(), "Unable to create binding for com.google.inject.Provider.", "It was already configured on one or more child injectors or private modules", "bound at " + FailingPrivateModule.class.getName() + ".configure(", "bound at " + SecondFailingPrivateModule.class.getName() + ".configure(", "If it was in a PrivateModule, did you forget to expose the binding?", "while locating com.google.inject.Provider"); } } public void testParentBindingToPrivateJitBinding() { Injector injector = Guice.createInjector(new ManyPrivateModules()); try { injector.getBinding(PrivateFoo.class); fail(); } catch(ConfigurationException expected) { assertEquals(1, expected.getErrorMessages().size()); assertContains(expected.toString(), "Unable to create binding for " + PrivateFoo.class.getName(), "It was already configured on one or more child injectors or private modules", "(bound by a just-in-time binding)", "If it was in a PrivateModule, did you forget to expose the binding?", "while locating " + PrivateFoo.class.getName()); } } private static class FailingModule extends AbstractModule { @Override protected void configure() { bind(Collection.class).to(List.class); install(new ManyPrivateModules()); } } private static class ManyPrivateModules extends AbstractModule { @Override protected void configure() { // make sure duplicate sources are collapsed install(new FailingPrivateModule()); install(new FailingPrivateModule()); // but additional sources are listed install(new SecondFailingPrivateModule()); } } private static class FailingPrivateModule extends PrivateModule { @Override protected void configure() { bind(List.class).toInstance(new ArrayList()); // Add the Provider binding, created just-in-time, // to make sure our linked JIT bindings have the correct source. getProvider(Key.get(Types.providerOf(List.class))); // Request a JIT binding for PrivateFoo, which can only // be created in the private module because it depends // on List. getProvider(PrivateFoo.class); } } /** A second class, so we can see another name in the source list. */ private static class SecondFailingPrivateModule extends PrivateModule { @Override protected void configure() { bind(List.class).toInstance(new ArrayList()); // Add the Provider binding, created just-in-time, // to make sure our linked JIT bindings have the correct source. getProvider(Key.get(Types.providerOf(List.class))); // Request a JIT binding for PrivateFoo, which can only // be created in the private module because it depends // on List. getProvider(PrivateFoo.class); } } private static class PrivateFoo { @Inject List list; } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/PerformanceComparison.java0000644000175000017500000001720611704661106026774 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static java.lang.annotation.RetentionPolicy.RUNTIME; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertSame; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.config.ConstructorArgumentValues; import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import java.lang.annotation.Retention; import java.text.DecimalFormat; import java.util.concurrent.Callable; /** * A semi-useless microbenchmark. Spring and Guice constuct the same object * graph a bunch of times, and we see who can construct the most per second. * As of this writing Guice is more than 50X faster. Also useful for comparing * pure Java configuration options. * * @author crazybob@google.com (Bob Lee) */ public class PerformanceComparison { public static void main(String[] args) throws Exception { // Once warm up. Takes lazy loading out of the equation and ensures we // created the graphs properly. validate(springFactory); validate(juiceFactory); validate(byHandFactory); for (int i2 = 0; i2 < 10; i2++) { iterate(springFactory, "Spring: "); iterate(juiceFactory, "Guice: "); iterate(byHandFactory, "By Hand: "); System.err.println(); } System.err.println("Concurrent:"); for (int i2 = 0; i2 < 10; i2++) { concurrentlyIterate(springFactory, "Spring: "); concurrentlyIterate(juiceFactory, "Guice: "); concurrentlyIterate(byHandFactory, "By Hand: "); System.err.println(); } } static final Callable springFactory = new Callable() { final DefaultListableBeanFactory beanFactory; { beanFactory = new DefaultListableBeanFactory(); RootBeanDefinition tee = new RootBeanDefinition(TeeImpl.class, true); tee.setLazyInit(true); ConstructorArgumentValues teeValues = new ConstructorArgumentValues(); teeValues.addGenericArgumentValue("test"); tee.setConstructorArgumentValues(teeValues); RootBeanDefinition bar = new RootBeanDefinition(BarImpl.class, false); ConstructorArgumentValues barValues = new ConstructorArgumentValues(); barValues.addGenericArgumentValue(new RuntimeBeanReference("tee")); barValues.addGenericArgumentValue(5); bar.setConstructorArgumentValues(barValues); RootBeanDefinition foo = new RootBeanDefinition(Foo.class, false); MutablePropertyValues fooValues = new MutablePropertyValues(); fooValues.addPropertyValue("i", 5); fooValues.addPropertyValue("bar", new RuntimeBeanReference("bar")); fooValues.addPropertyValue("copy", new RuntimeBeanReference("bar")); fooValues.addPropertyValue("s", "test"); foo.setPropertyValues(fooValues); beanFactory.registerBeanDefinition("foo", foo); beanFactory.registerBeanDefinition("bar", bar); beanFactory.registerBeanDefinition("tee", tee); } public Foo call() throws Exception { return (Foo) beanFactory.getBean("foo"); } }; static final Callable juiceFactory = new Callable() { final Provider fooProvider; { Injector injector; try { injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Tee.class).to(TeeImpl.class); bind(Bar.class).to(BarImpl.class); bind(Foo.class); bindConstant().annotatedWith(I.class).to(5); bindConstant().annotatedWith(S.class).to("test"); } }); } catch (CreationException e) { throw new RuntimeException(e); } fooProvider = injector.getProvider(Foo.class); } public Foo call() throws Exception { return fooProvider.get(); } }; static final Callable byHandFactory = new Callable() { final Tee tee = new TeeImpl("test"); public Foo call() throws Exception { Foo foo = new Foo(); foo.setI(5); foo.setS("test"); Bar bar = new BarImpl(tee, 5); Bar copy = new BarImpl(tee, 5); foo.setBar(bar); foo.setCopy(copy); return foo; } }; static void validate(Callable t) throws Exception { Foo foo = t.call(); assertEquals(5, foo.i); assertEquals("test", foo.s); assertSame(foo.bar.getTee(), foo.copy.getTee()); assertEquals(5, foo.bar.getI()); assertEquals("test", foo.bar.getTee().getS()); } static final DecimalFormat format = new DecimalFormat(); static void iterate(Callable callable, String label) { int count = 100000; long time = System.currentTimeMillis(); for (int i = 0; i < count; i++) { try { callable.call(); } catch (Exception e) { throw new RuntimeException(e); } } time = System.currentTimeMillis() - time; System.err.println(label + format.format(count * 1000 / time) + " creations/s"); } static void concurrentlyIterate(final Callable callable, String label) { int threadCount = 10; final int count = 10000; Thread[] threads = new Thread[threadCount]; for (int i = 0; i < threadCount; i++) { threads[i] = new Thread() { public void run() { for (int i = 0; i < count; i++) { try { validate(callable); } catch (Exception e) { throw new RuntimeException(e); } } } }; } long time = System.currentTimeMillis(); for (int i = 0; i < threadCount; i++) { threads[i].start(); } for (int i = 0; i < threadCount; i++) { try { threads[i].join(); } catch (InterruptedException e) { throw new RuntimeException(e); } } time = System.currentTimeMillis() - time; System.err.println(label + format.format(count * 1000 / time) + " creations/s"); } public static class Foo { Bar bar; Bar copy; String s; int i; @Inject public void setI(@I int i) { this.i = i; } @Inject public void setBar(Bar bar) { this.bar = bar; } @Inject public void setCopy(Bar copy) { this.copy = copy; } @Inject public void setS(@S String s) { this.s = s; } } interface Bar { Tee getTee(); int getI(); } public static class BarImpl implements Bar { final int i; final Tee tee; @Inject public BarImpl(Tee tee, @I int i) { this.tee = tee; this.i = i; } public Tee getTee() { return tee; } public int getI() { return i; } } interface Tee { String getS(); } @Singleton public static class TeeImpl implements Tee { final String s; @Inject public TeeImpl(@S String s) { this.s = s; } public String getS() { return s; } } @Retention(RUNTIME) @BindingAnnotation @interface I {} @Retention(RUNTIME) @BindingAnnotation @interface S {} } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/ParentInjectorTest.java0000644000175000017500000002451311704661106026266 0ustar tonytony/* Copyright (C) 2007 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.inject.matcher.Matchers; import com.google.inject.name.Names; import com.google.inject.spi.TypeConverter; import junit.framework.TestCase; import java.lang.annotation.Retention; import java.lang.annotation.Target; import java.util.List; /** * @author jessewilson@google.com (Jesse Wilson) */ public class ParentInjectorTest extends TestCase { public void testParentAndChildCannotShareExplicitBindings() { Injector parent = Guice.createInjector(bindsA); try { parent.createChildInjector(bindsA); fail("Created the same explicit binding on both parent and child"); } catch (CreationException e) { assertContains(e.getMessage(), "A binding to ", A.class.getName(), " was already configured", " at ", getClass().getName(), ".configure(ParentInjectorTest.java:", " at ", getClass().getName(), ".configure(ParentInjectorTest.java:"); } } public void testParentJitBindingWontClobberChildBinding() { Injector parent = Guice.createInjector(); parent.createChildInjector(bindsA); try { parent.getInstance(A.class); fail("Created a just-in-time binding on the parent that's the same as a child's binding"); } catch (ConfigurationException e) { assertContains(e.getMessage(), "Unable to create binding for " + A.class.getName(), "It was already configured on one or more child injectors or private modules", "bound at " + bindsA.getClass().getName() + ".configure(", "If it was in a PrivateModule, did you forget to expose the binding?", "while locating " + A.class.getName()); } } public void testChildCannotBindToAParentJitBinding() { Injector parent = Guice.createInjector(); parent.getInstance(A.class); try { parent.createChildInjector(bindsA); fail(); } catch(CreationException ce) { assertContains(Iterables.getOnlyElement(ce.getErrorMessages()).getMessage(), "A just-in-time binding to " + A.class.getName() + " was already configured on a parent injector."); } } public void testJustInTimeBindingsAreSharedWithParentIfPossible() { Injector parent = Guice.createInjector(); Injector child = parent.createChildInjector(); assertSame(child.getInstance(A.class), parent.getInstance(A.class)); Injector anotherChild = parent.createChildInjector(); assertSame(anotherChild.getInstance(A.class), parent.getInstance(A.class)); Injector grandchild = child.createChildInjector(); assertSame(grandchild.getInstance(A.class), parent.getInstance(A.class)); } public void testBindingsInherited() { Injector parent = Guice.createInjector(bindsB); Injector child = parent.createChildInjector(); assertSame(RealB.class, child.getInstance(B.class).getClass()); } public void testGetParent() { Injector top = Guice.createInjector(bindsA); Injector middle = top.createChildInjector(bindsB); Injector bottom = middle.createChildInjector(); assertSame(middle, bottom.getParent()); assertSame(top, middle.getParent()); assertNull(top.getParent()); } public void testChildBindingsNotVisibleToParent() { Injector parent = Guice.createInjector(); parent.createChildInjector(bindsB); try { parent.getBinding(B.class); fail(); } catch (ConfigurationException expected) { } } public void testScopesInherited() { Injector parent = Guice.createInjector(new AbstractModule() { protected void configure() { bindScope(MyScope.class, Scopes.SINGLETON); } }); Injector child = parent.createChildInjector(new AbstractModule() { @Override protected void configure() { bind(A.class).in(MyScope.class); } }); assertSame(child.getInstance(A.class), child.getInstance(A.class)); } /*if[AOP]*/ private final org.aopalliance.intercept.MethodInterceptor returnNullInterceptor = new org.aopalliance.intercept.MethodInterceptor() { public Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation) { return null; } }; public void testInterceptorsInherited() { Injector parent = Guice.createInjector(new AbstractModule() { protected void configure() { super.bindInterceptor(Matchers.any(), Matchers.returns(Matchers.identicalTo(A.class)), returnNullInterceptor); } }); Injector child = parent.createChildInjector(new AbstractModule() { protected void configure() { bind(C.class); } }); assertNull(child.getInstance(C.class).interceptedMethod()); } /*end[AOP]*/ public void testTypeConvertersInherited() { Injector parent = Guice.createInjector(bindListConverterModule); Injector child = parent.createChildInjector(bindStringNamedB); assertEquals(ImmutableList.of(), child.getInstance(Key.get(List.class, Names.named("B")))); } public void testTypeConvertersConflicting() { Injector parent = Guice.createInjector(bindListConverterModule); Injector child = parent.createChildInjector(bindListConverterModule, bindStringNamedB); try { child.getInstance(Key.get(List.class, Names.named("B"))); fail(); } catch (ConfigurationException expected) { Asserts.assertContains(expected.getMessage(), "Multiple converters can convert"); } } public void testInjectorInjectionSpanningInjectors() { Injector parent = Guice.createInjector(); Injector child = parent.createChildInjector(new AbstractModule() { protected void configure() { bind(D.class); } }); D d = child.getInstance(D.class); assertSame(d.injector, child); E e = child.getInstance(E.class); assertSame(e.injector, parent); } public void testSeveralLayersOfHierarchy() { Injector top = Guice.createInjector(bindsA); Injector left = top.createChildInjector(); Injector leftLeft = left.createChildInjector(bindsD); Injector right = top.createChildInjector(bindsD); assertSame(leftLeft, leftLeft.getInstance(D.class).injector); assertSame(right, right.getInstance(D.class).injector); assertSame(top, leftLeft.getInstance(E.class).injector); assertSame(top.getInstance(A.class), leftLeft.getInstance(A.class)); Injector leftRight = left.createChildInjector(bindsD); assertSame(leftRight, leftRight.getInstance(D.class).injector); try { top.getInstance(D.class); fail(); } catch (ConfigurationException expected) { } try { left.getInstance(D.class); fail(); } catch (ConfigurationException expected) { } } public void testScopeBoundInChildInjectorOnly() { Injector parent = Guice.createInjector(); Injector child = parent.createChildInjector(new AbstractModule() { protected void configure() { bindScope(MyScope.class, Scopes.SINGLETON); } }); try { parent.getProvider(F.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "No scope is bound to com.google.inject.ParentInjectorTest$MyScope.", "at " + F.class.getName() + ".class(ParentInjectorTest.java", " while locating " + F.class.getName()); } assertNotNull(child.getProvider(F.class).get()); } public void testErrorInParentButOkayInChild() { Injector parent = Guice.createInjector(); Injector childInjector = parent.createChildInjector(new AbstractModule() { protected void configure() { bindScope(MyScope.class, Scopes.SINGLETON); bind(Object.class).to(F.class); } }); Object one = childInjector.getInstance(Object.class); Object two = childInjector.getInstance(Object.class); assertSame(one, two); } public void testErrorInParentAndChild() { Injector parent = Guice.createInjector(); Injector childInjector = parent.createChildInjector(); try { childInjector.getInstance(G.class); fail(); } catch(ConfigurationException expected) { assertContains(expected.getMessage(), "No scope is bound to " + MyScope.class.getName(), "at " + F.class.getName() + ".class(ParentInjectorTest.java:", " while locating " + G.class.getName()); } } @Singleton static class A {} private final Module bindsA = new AbstractModule() { protected void configure() { bind(A.class).toInstance(new A()); } }; interface B {} static class RealB implements B {} private final Module bindsB = new AbstractModule() { protected void configure() { bind(B.class).to(RealB.class); } }; @Target(TYPE) @Retention(RUNTIME) @ScopeAnnotation public @interface MyScope {} private final TypeConverter listConverter = new TypeConverter() { public Object convert(String value, TypeLiteral toType) { return ImmutableList.of(); } }; private final Module bindListConverterModule = new AbstractModule() { protected void configure() { convertToTypes(Matchers.any(), listConverter); } }; private final Module bindStringNamedB = new AbstractModule() { protected void configure() { bind(String.class).annotatedWith(Names.named("B")).toInstance("buzz"); } }; public static class C { public A interceptedMethod() { return new A(); } } static class D { @Inject Injector injector; } static class E { @Inject Injector injector; } private final Module bindsD = new AbstractModule() { protected void configure() { bind(D.class); } }; @MyScope static class F implements G {} @ImplementedBy(F.class) interface G {} } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/OverrideModuleTest.java0000644000175000017500000004704011704661106026264 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static com.google.inject.Guice.createInjector; import static com.google.inject.name.Names.named; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.common.base.Objects; import com.google.inject.name.Named; import com.google.inject.util.Modules; import junit.framework.TestCase; import java.lang.annotation.Retention; import java.lang.annotation.Target; import java.util.Date; import java.util.concurrent.atomic.AtomicReference; /** * @author sberlin@gmail.com (Sam Berlin) */ public class OverrideModuleTest extends TestCase { private static final Key key2 = Key.get(String.class, named("2")); private static final Key key3 = Key.get(String.class, named("3")); private static final Module EMPTY_MODULE = new Module() { public void configure(Binder binder) {} }; public void testOverride() { Injector injector = createInjector(Modules.override(newModule("A")).with(newModule("B"))); assertEquals("B", injector.getInstance(String.class)); } public void testOverrideMultiple() { Module module = Modules.override(newModule("A"), newModule(1), newModule(0.5f)) .with(newModule("B"), newModule(2), newModule(1.5d)); Injector injector = createInjector(module); assertEquals("B", injector.getInstance(String.class)); assertEquals(2, injector.getInstance(Integer.class).intValue()); assertEquals(0.5f, injector.getInstance(Float.class)); assertEquals(1.5d, injector.getInstance(Double.class)); } public void testOverrideUnmatchedTolerated() { Injector injector = createInjector(Modules.override(EMPTY_MODULE).with(newModule("B"))); assertEquals("B", injector.getInstance(String.class)); } public void testOverrideConstant() { Module original = new AbstractModule() { @Override protected void configure() { bindConstant().annotatedWith(named("Test")).to("A"); } }; Module replacements = new AbstractModule() { @Override protected void configure() { bindConstant().annotatedWith(named("Test")).to("B"); } }; Injector injector = createInjector(Modules.override(original).with(replacements)); assertEquals("B", injector.getInstance(Key.get(String.class, named("Test")))); } public void testGetProviderInModule() { Module original = new AbstractModule() { @Override protected void configure() { bind(String.class).toInstance("A"); bind(key2).toProvider(getProvider(String.class)); } }; Injector injector = createInjector(Modules.override(original).with(EMPTY_MODULE)); assertEquals("A", injector.getInstance(String.class)); assertEquals("A", injector.getInstance(key2)); } public void testOverrideWhatGetProviderProvided() { Module original = new AbstractModule() { @Override protected void configure() { bind(String.class).toInstance("A"); bind(key2).toProvider(getProvider(String.class)); } }; Module replacements = newModule("B"); Injector injector = createInjector(Modules.override(original).with(replacements)); assertEquals("B", injector.getInstance(String.class)); assertEquals("B", injector.getInstance(key2)); } public void testOverrideUsingOriginalsGetProvider() { Module original = new AbstractModule() { @Override protected void configure() { bind(String.class).toInstance("A"); bind(key2).toInstance("B"); } }; Module replacements = new AbstractModule() { @Override protected void configure() { bind(String.class).toProvider(getProvider(key2)); } }; Injector injector = createInjector(Modules.override(original).with(replacements)); assertEquals("B", injector.getInstance(String.class)); assertEquals("B", injector.getInstance(key2)); } public void testOverrideOfOverride() { Module original = new AbstractModule() { @Override protected void configure() { bind(String.class).toInstance("A1"); bind(key2).toInstance("A2"); bind(key3).toInstance("A3"); } }; Module replacements1 = new AbstractModule() { @Override protected void configure() { bind(String.class).toInstance("B1"); bind(key2).toInstance("B2"); } }; Module overrides = Modules.override(original).with(replacements1); Module replacements2 = new AbstractModule() { @Override protected void configure() { bind(String.class).toInstance("C1"); bind(key3).toInstance("C3"); } }; Injector injector = createInjector(Modules.override(overrides).with(replacements2)); assertEquals("C1", injector.getInstance(String.class)); assertEquals("B2", injector.getInstance(key2)); assertEquals("C3", injector.getInstance(key3)); } public void testOverridesTwiceFails() { Module original = newModule("A"); Module replacements = new AbstractModule() { @Override protected void configure() { bind(String.class).toInstance("B"); bind(String.class).toInstance("C"); } }; Module module = Modules.override(original).with(replacements); try { createInjector(module); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "A binding to java.lang.String " + "was already configured at " + replacements.getClass().getName(), "at " + replacements.getClass().getName()); } } public void testOverridesDoesntFixTwiceBoundInOriginal() { Module original = new AbstractModule() { @Override protected void configure() { bind(String.class).toInstance("A"); bind(String.class).toInstance("B"); } }; Module replacements = new AbstractModule() { @Override protected void configure() { bind(String.class).toInstance("C"); } }; Module module = Modules.override(original).with(replacements); try { createInjector(module); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) A binding to java.lang.String " + "was already configured at " + replacements.getClass().getName(), "at " + original.getClass().getName()); } } public void testStandardScopeAnnotation() { final SingleUseScope scope = new SingleUseScope(); Module module = new AbstractModule() { protected void configure() { bindScope(TestScopeAnnotation.class, scope); bind(String.class).in(TestScopeAnnotation.class); } }; assertFalse(scope.used); Guice.createInjector(module); assertTrue(scope.used); } public void testOverrideUntargettedBinding() { Module original = new AbstractModule() { @Override protected void configure() { bind(Date.class); } }; Module replacements = new AbstractModule() { @Override protected void configure() { bind(Date.class).toInstance(new Date(0)); } }; Injector injector = createInjector(Modules.override(original).with(replacements)); assertEquals(0, injector.getInstance(Date.class).getTime()); } public void testOverrideScopeAnnotation() { final Scope scope = new Scope() { public Provider scope(Key key, Provider unscoped) { throw new AssertionError("Should not be called"); } }; final SingleUseScope replacementScope = new SingleUseScope(); Module original = new AbstractModule() { @Override protected void configure() { bindScope(TestScopeAnnotation.class, scope); bind(Date.class).in(TestScopeAnnotation.class); } }; Module replacements = new AbstractModule() { @Override protected void configure() { bindScope(TestScopeAnnotation.class, replacementScope); } }; Injector injector = createInjector(Modules.override(original).with(replacements)); injector.getInstance(Date.class); assertTrue(replacementScope.used); } public void testFailsIfOverridenScopeInstanceHasBeenUsed() { final Scope scope = new Scope() { public Provider scope(Key key, Provider unscoped) { return unscoped; } @Override public String toString() { return "ORIGINAL SCOPE"; } }; Module original = new AbstractModule() { @Override protected void configure() { bindScope(TestScopeAnnotation.class, scope); bind(Date.class).in(scope); } }; Module replacements = new AbstractModule() { @Override protected void configure() { bindScope(TestScopeAnnotation.class, new SingleUseScope()); } }; try { createInjector(Modules.override(original).with(replacements)); fail("Exception expected"); } catch (CreationException e) { assertContains(e.getMessage(), "1) The scope for @TestScopeAnnotation is bound directly and cannot be overridden.", "at ", getClass().getName(), ".configure("); } } public void testOverrideIsLazy() { final AtomicReference value = new AtomicReference("A"); Module overridden = Modules.override(new AbstractModule() { protected void configure() { bind(String.class).annotatedWith(named("original")).toInstance(value.get()); } }).with(new AbstractModule() { protected void configure() { bind(String.class).annotatedWith(named("override")).toInstance(value.get()); } }); // the value.get() call should be deferred until Guice.createInjector value.set("B"); Injector injector = Guice.createInjector(overridden); assertEquals("B", injector.getInstance(Key.get(String.class, named("original")))); assertEquals("B", injector.getInstance(Key.get(String.class, named("override")))); } public void testOverridePrivateModuleOverPrivateModule() { Module exposes5and6 = new AbstractModule() { protected void configure() { install(new PrivateModule() { protected void configure() { bind(Integer.class).toInstance(5); expose(Integer.class); bind(Character.class).toInstance('E'); } }); install(new PrivateModule() { protected void configure() { bind(Long.class).toInstance(6L); expose(Long.class); bind(Character.class).toInstance('F'); } }); } }; AbstractModule exposes15 = new AbstractModule() { protected void configure() { install(new PrivateModule() { protected void configure() { bind(Integer.class).toInstance(15); expose(Integer.class); bind(Character.class).toInstance('G'); } }); install(new PrivateModule() { protected void configure() { bind(Character.class).toInstance('H'); } }); } }; // override forwards Injector injector = Guice.createInjector(Modules.override(exposes5and6).with(exposes15)); assertEquals(15, injector.getInstance(Integer.class).intValue()); assertEquals(6L, injector.getInstance(Long.class).longValue()); // and in reverse order Injector reverse = Guice.createInjector(Modules.override(exposes15).with(exposes5and6)); assertEquals(5, reverse.getInstance(Integer.class).intValue()); assertEquals(6L, reverse.getInstance(Long.class).longValue()); } public void testOverrideModuleAndPrivateModule() { Module exposes5 = new PrivateModule() { protected void configure() { bind(Integer.class).toInstance(5); expose(Integer.class); } }; Module binds15 = new AbstractModule() { protected void configure() { bind(Integer.class).toInstance(15); } }; Injector injector = Guice.createInjector(Modules.override(exposes5).with(binds15)); assertEquals(15, injector.getInstance(Integer.class).intValue()); Injector reverse = Guice.createInjector(Modules.override(binds15).with(exposes5)); assertEquals(5, reverse.getInstance(Integer.class).intValue()); } public void testOverrideDeepExpose() { final AtomicReference> charAProvider = new AtomicReference>(); Module exposes5 = new PrivateModule() { protected void configure() { install(new PrivateModule() { protected void configure() { bind(Integer.class).toInstance(5); expose(Integer.class); charAProvider.set(getProvider(Character.class)); bind(Character.class).toInstance('A'); } }); expose(Integer.class); } }; Injector injector = Guice.createInjector(Modules.override(exposes5).with(EMPTY_MODULE)); assertEquals(5, injector.getInstance(Integer.class).intValue()); assertEquals('A', charAProvider.getAndSet(null).get().charValue()); injector = Guice.createInjector(Modules.override(EMPTY_MODULE).with(exposes5)); assertEquals(5, injector.getInstance(Integer.class).intValue()); assertEquals('A', charAProvider.getAndSet(null).get().charValue()); final AtomicReference> charBProvider = new AtomicReference>(); Module binds15 = new AbstractModule() { protected void configure() { bind(Integer.class).toInstance(15); install(new PrivateModule() { protected void configure() { charBProvider.set(getProvider(Character.class)); bind(Character.class).toInstance('B'); } }); } }; injector = Guice.createInjector(Modules.override(binds15).with(exposes5)); assertEquals(5, injector.getInstance(Integer.class).intValue()); assertEquals('A', charAProvider.getAndSet(null).get().charValue()); assertEquals('B', charBProvider.getAndSet(null).get().charValue()); injector = Guice.createInjector(Modules.override(exposes5).with(binds15)); assertEquals(15, injector.getInstance(Integer.class).intValue()); assertEquals('A', charAProvider.getAndSet(null).get().charValue()); assertEquals('B', charBProvider.getAndSet(null).get().charValue()); } @Retention(RUNTIME) @Target(TYPE) @ScopeAnnotation private static @interface TestScopeAnnotation {} private static class SingleUseScope implements Scope { boolean used = false; public Provider scope(Key key, Provider unscoped) { assertFalse(used); used = true; return unscoped; } } private static Module newModule(final T bound) { return new AbstractModule() { @Override protected void configure() { @SuppressWarnings("unchecked") Class type = (Class) bound.getClass(); bind(type).toInstance(bound); } }; } private static final String RESULT = "RESULT"; private static final String PRIVATE_INPUT = "PRIVATE_INPUT"; private static final String OVERRIDDEN_INPUT = "FOO"; private static final String OVERRIDDEN_RESULT = "Size: 3"; private static final Key RESULT_KEY = Key.get(String.class, named(RESULT)); private static final Key INPUT_KEY = Key.get(String.class, named(PRIVATE_INPUT)); public void testExposedBindingOverride() throws Exception { Injector inj = Guice.createInjector( Modules.override(new ExampleModule()).with( new AbstractModule() { @Override protected void configure() { bind(RESULT_KEY).toInstance(OVERRIDDEN_RESULT); } })); assertEquals(inj.getInstance(RESULT_KEY), OVERRIDDEN_RESULT); } public void testPrivateBindingOverride() throws Exception { Injector inj = Guice.createInjector( Modules.override(new ExampleModule()).with( new AbstractModule() { @Override protected void configure() { bind(INPUT_KEY).toInstance(OVERRIDDEN_INPUT); } })); assertEquals(inj.getInstance(RESULT_KEY), OVERRIDDEN_RESULT); } public static class ExampleModule extends PrivateModule { @Provides @Exposed @Named(RESULT) public String provideResult(@Named(PRIVATE_INPUT) String input) { return "Size: " + input.length(); } @Provides @Named(PRIVATE_INPUT) public String provideInput() { return "Hello World"; } @Override protected void configure() { } } public void testEqualsNotCalledByDefaultOnInstance() { final HashEqualsTester a = new HashEqualsTester(); a.throwOnEquals = true; Guice.createInjector(Modules.override(new AbstractModule() { @Override protected void configure() { bind(String.class); bind(HashEqualsTester.class).toInstance(a); } }).with()); } public void testEqualsNotCalledByDefaultOnProvider() { final HashEqualsTester a = new HashEqualsTester(); a.throwOnEquals = true; Guice.createInjector(Modules.override(new AbstractModule() { @Override protected void configure() { bind(String.class); bind(Object.class).toProvider(a); } }).with()); } public void testHashcodeNeverCalledOnInstance() { final HashEqualsTester a = new HashEqualsTester(); a.throwOnHashcode = true; a.equality = "test"; final HashEqualsTester b = new HashEqualsTester(); b.throwOnHashcode = true; b.equality = "test"; Guice.createInjector(Modules.override(new AbstractModule() { @Override protected void configure() { bind(String.class); bind(HashEqualsTester.class).toInstance(a); bind(HashEqualsTester.class).toInstance(b); } }).with()); } public void testHashcodeNeverCalledOnProviderInstance() { final HashEqualsTester a = new HashEqualsTester(); a.throwOnHashcode = true; a.equality = "test"; final HashEqualsTester b = new HashEqualsTester(); b.throwOnHashcode = true; b.equality = "test"; Guice.createInjector(Modules.override(new AbstractModule() { @Override protected void configure() { bind(String.class); bind(Object.class).toProvider(a); bind(Object.class).toProvider(b); } }).with()); } private static class HashEqualsTester implements Provider { private String equality; private boolean throwOnEquals; private boolean throwOnHashcode; @Override public boolean equals(Object obj) { if (throwOnEquals) { throw new RuntimeException(); } else if (obj instanceof HashEqualsTester) { HashEqualsTester o = (HashEqualsTester)obj; if(o.throwOnEquals) { throw new RuntimeException(); } if(equality == null && o.equality == null) { return this == o; } else { return Objects.equal(equality, o.equality); } } else { return false; } } @Override public int hashCode() { if(throwOnHashcode) { throw new RuntimeException(); } else { return super.hashCode(); } } public Object get() { return new Object(); } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/OptionalBindingTest.java0000644000175000017500000002172511704661106026421 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import com.google.inject.name.Named; import com.google.inject.name.Names; import junit.framework.TestCase; /** * This test verifies the ways things are injected (ie. getInstance(), * injectMembers(), bind to instance, and bind to provider instance) for all * states of optional bindings (fields, methods, multiple-argument methods, * provider fields, provider methods, constructors). * * @author jessewilson@google.com (Jesse Wilson) */ public class OptionalBindingTest extends TestCase { private static final A injectA = new A() {}; private static final B injectB = new B() {}; private static final C injectC = new C() {}; private static final D injectD = new D() {}; private static final E injectE = new E() {}; private static final F injectF = new F() {}; private static final G injectG = new G() {}; private Module everythingModule = new AbstractModule() { protected void configure() { bind(A.class).toInstance(injectA); bind(B.class).toInstance(injectB); bind(C.class).toInstance(injectC); bind(D.class).toInstance(injectD); bind(E.class).annotatedWith(Names.named("e")).toInstance(injectE); bind(F.class).toInstance(injectF); bind(G.class).toInstance(injectG); } }; private Module partialModule = new AbstractModule() { protected void configure() { bind(C.class).toInstance(new C() {}); } }; private Module toInstanceModule = new AbstractModule() { protected void configure() { bind(HasOptionalInjections.class) .toInstance(new HasOptionalInjections()); } }; private Module toProviderInstanceModule = new AbstractModule() { protected void configure() { bind(HasOptionalInjections.class) .toProvider(new HasOptionalInjectionsProvider()); } }; private Module toProviderModule = new AbstractModule() { protected void configure() { bind(HasOptionalInjections.class) .toProvider(HasOptionalInjectionsProvider.class); } }; public void testEverythingInjectorGetInstance() { Guice.createInjector(everythingModule) .getInstance(HasOptionalInjections.class) .assertEverythingInjected(); } public void testPartialInjectorGetInstance() { Guice.createInjector(partialModule) .getInstance(HasOptionalInjections.class) .assertNothingInjected(); } public void testNothingInjectorGetInstance() { Guice.createInjector() .getInstance(HasOptionalInjections.class) .assertNothingInjected(); } public void testEverythingInjectorInjectMembers() { HasOptionalInjections instance = new HasOptionalInjections(); Guice.createInjector(everythingModule).injectMembers(instance); instance.assertEverythingInjected(); } public void testPartialInjectorInjectMembers() { HasOptionalInjections instance = new HasOptionalInjections(); Guice.createInjector(partialModule).injectMembers(instance); instance.assertNothingInjected(); } public void testNothingInjectorInjectMembers() { HasOptionalInjections instance = new HasOptionalInjections(); Guice.createInjector().injectMembers(instance); instance.assertNothingInjected(); } public void testEverythingInjectorToInstance() { Guice.createInjector(everythingModule, toInstanceModule) .getInstance(HasOptionalInjections.class) .assertEverythingInjected(); } public void testPartialInjectorToInstance() { Guice.createInjector(partialModule, toInstanceModule) .getInstance(HasOptionalInjections.class) .assertNothingInjected(); } public void testNothingInjectorToInstance() { Guice.createInjector(toInstanceModule) .getInstance(HasOptionalInjections.class) .assertNothingInjected(); } public void testEverythingInjectorToProviderInstance() { Guice.createInjector(everythingModule, toProviderInstanceModule) .getInstance(HasOptionalInjections.class) .assertEverythingInjected(); } public void testPartialInjectorToProviderInstance() { Guice.createInjector(partialModule, toProviderInstanceModule) .getInstance(HasOptionalInjections.class) .assertNothingInjected(); } public void testNothingInjectorToProviderInstance() { Guice.createInjector(toProviderInstanceModule) .getInstance(HasOptionalInjections.class) .assertNothingInjected(); } public void testEverythingInjectorToProvider() { Guice.createInjector(everythingModule, toProviderModule) .getInstance(HasOptionalInjections.class) .assertEverythingInjected(); } public void testPartialInjectorToProvider() { Guice.createInjector(partialModule, toProviderModule) .getInstance(HasOptionalInjections.class) .assertNothingInjected(); } public void testNothingInjectorToProvider() { Guice.createInjector(toProviderModule) .getInstance(HasOptionalInjections.class) .assertNothingInjected(); } static class HasOptionalInjections { A originalA = new A() {}; @Inject(optional=true) A a = originalA; // field injection B b; // method injection with one argument C c; // method injection with two arguments D d; // method injection with two arguments E e; // annotated injection @Inject(optional=true) Provider fProvider; // provider Provider gProvider; // method injection of provider boolean invoked0, invoked1, invoked2, invokedAnnotated, invokeProvider; @Inject(optional=true) void methodInjectZeroArguments() { invoked0 = true; } @Inject(optional=true) void methodInjectOneArgument(B b) { this.b = b; invoked1 = true; } @Inject(optional=true) void methodInjectTwoArguments(C c, D d) { this.c = c; this.d = d; invoked2 = true; } @Inject(optional=true) void methodInjectAnnotated(@Named("e") E e) { this.e = e; invokedAnnotated = true; } @Inject(optional=true) void methodInjectProvider(Provider gProvider) { this.gProvider = gProvider; invokeProvider = true; } void assertNothingInjected() { assertSame(originalA, a); assertNull(b); assertNull(c); assertNull(d); assertNull(e); assertNull(fProvider); assertNull(gProvider); assertTrue(invoked0); assertFalse(invoked1); assertFalse(invoked2); assertFalse(invokedAnnotated); } public void assertEverythingInjected() { assertNotSame(injectA, originalA); assertSame(injectA, a); assertSame(injectB, b); assertSame(injectC, c); assertSame(injectD, d); assertSame(injectE, e); assertSame(injectF, fProvider.get()); assertSame(injectG, gProvider.get()); assertTrue(invoked0); assertTrue(invoked1); assertTrue(invoked2); assertTrue(invokedAnnotated); } } static class HasOptionalInjectionsProvider extends HasOptionalInjections implements Provider { public HasOptionalInjections get() { return this; } } public void testOptionalConstructorBlowsUp() { try { Guice.createInjector().getInstance(HasOptionalConstructor.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "OptionalBindingTest$HasOptionalConstructor.() " + "is annotated @Inject(optional=true), but constructors cannot be optional."); } } static class HasOptionalConstructor { @Inject(optional=true) HasOptionalConstructor() {} } @Inject(optional=true) static A staticInjectA; public void testStaticInjection() { staticInjectA = injectA; Guice.createInjector(new AbstractModule() { protected void configure() { requestStaticInjection(OptionalBindingTest.class); } }); assertSame(staticInjectA, injectA); } /** * Test for bug 107, where we weren't doing optional injection properly for * indirect injections. */ public void testIndirectOptionalInjection() { Indirect indirect = Guice.createInjector().getInstance(Indirect.class); assertNotNull(indirect.hasOptionalInjections); indirect.hasOptionalInjections.assertNothingInjected(); } static class Indirect { @Inject HasOptionalInjections hasOptionalInjections; } interface A {} interface B {} interface C {} interface D {} interface E {} interface F {} interface G {} } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/NullableInjectionPointTest.java0000644000175000017500000001577611704661106027765 0ustar tonytonypackage com.google.inject; import static com.google.inject.Asserts.assertContains; import junit.framework.TestCase; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * @author jessewilson@google.com (Jesse Wilson) */ public class NullableInjectionPointTest extends TestCase { public void testInjectNullIntoNotNullableConstructor() { try { createInjector().getInstance(FooConstructor.class); fail("Injecting null should fail with an error"); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "null returned by binding at " + getClass().getName(), "parameter 0 of " + FooConstructor.class.getName() + ".() is not @Nullable"); } } public void testInjectNullIntoNotNullableMethod() { try { createInjector().getInstance(FooMethod.class); fail("Injecting null should fail with an error"); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "null returned by binding at " + getClass().getName(), "parameter 0 of " + FooMethod.class.getName() + ".setFoo() is not @Nullable"); } } public void testInjectNullIntoNotNullableField() { try { createInjector().getInstance(FooField.class); fail("Injecting null should fail with an error"); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "null returned by binding at " + getClass().getName(), " but " + FooField.class.getName() + ".foo is not @Nullable"); } } /** * Provider.getInstance() is allowed to return null via direct calls to * getInstance(). */ public void testGetInstanceOfNull() { assertNull(createInjector().getInstance(Foo.class)); } public void testInjectNullIntoNullableConstructor() { NullableFooConstructor nfc = createInjector().getInstance(NullableFooConstructor.class); assertNull(nfc.foo); } public void testInjectNullIntoNullableMethod() { NullableFooMethod nfm = createInjector().getInstance(NullableFooMethod.class); assertNull(nfm.foo); } public void testInjectNullIntoNullableField() { NullableFooField nff = createInjector().getInstance(NullableFooField.class); assertNull(nff.foo); } public void testInjectNullIntoCustomNullableConstructor() { CustomNullableFooConstructor nfc = createInjector().getInstance(CustomNullableFooConstructor.class); assertNull(nfc.foo); } public void testInjectNullIntoCustomNullableMethod() { CustomNullableFooMethod nfm = createInjector().getInstance(CustomNullableFooMethod.class); assertNull(nfm.foo); } public void testInjectNullIntoCustomNullableField() { CustomNullableFooField nff = createInjector().getInstance(CustomNullableFooField.class); assertNull(nff.foo); } private Injector createInjector() { return Guice.createInjector( new AbstractModule() { protected void configure() { bind(Foo.class).toProvider(new Provider() { public Foo get() { return null; } }); } }); } /** * We haven't decided on what the desired behaviour of this test should be... */ public void testBindNullToInstance() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(Foo.class).toInstance(null); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "Binding to null instances is not allowed.", "at " + getClass().getName(), ".configure(NullableInjectionPointTest.java:"); } } public void testBindNullToProvider() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Foo.class).toProvider(new Provider() { public Foo get() { return null; } }); } }); assertNull(injector.getInstance(NullableFooField.class).foo); assertNull(injector.getInstance(CustomNullableFooField.class).foo); try { injector.getInstance(FooField.class); } catch(ProvisionException expected) { assertContains(expected.getMessage(), "null returned by binding at"); } } public void testBindScopedNull() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Foo.class).toProvider(new Provider() { public Foo get() { return null; } }).in(Scopes.SINGLETON); } }); assertNull(injector.getInstance(NullableFooField.class).foo); assertNull(injector.getInstance(CustomNullableFooField.class).foo); try { injector.getInstance(FooField.class); } catch(ProvisionException expected) { assertContains(expected.getMessage(), "null returned by binding at"); } } public void testBindNullAsEagerSingleton() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Foo.class).toProvider(new Provider() { public Foo get() { return null; } }).asEagerSingleton(); } }); assertNull(injector.getInstance(NullableFooField.class).foo); assertNull(injector.getInstance(CustomNullableFooField.class).foo); try { injector.getInstance(FooField.class); fail(); } catch(ProvisionException expected) { assertContains(expected.getMessage(), "null returned by binding " + "at com.google.inject.NullableInjectionPointTest"); } } static class Foo { } static class FooConstructor { @Inject FooConstructor(Foo foo) { } } static class FooField { @Inject Foo foo; } static class FooMethod { @Inject void setFoo(Foo foo) { } } static class NullableFooConstructor { Foo foo; @Inject NullableFooConstructor(@Nullable Foo foo) { this.foo = foo; } } static class NullableFooField { @Inject @Nullable Foo foo; } static class NullableFooMethod { Foo foo; @Inject void setFoo(@Nullable Foo foo) { this.foo = foo; } } static class CustomNullableFooConstructor { Foo foo; @Inject CustomNullableFooConstructor(@Namespace.Nullable Foo foo) { this.foo = foo; } } static class CustomNullableFooField { @Inject @Namespace.Nullable Foo foo; } static class CustomNullableFooMethod { Foo foo; @Inject void setFoo(@Namespace.Nullable Foo foo) { this.foo = foo; } } @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.PARAMETER, ElementType.FIELD}) @interface Nullable { } static interface Namespace { @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.PARAMETER, ElementType.FIELD}) @interface Nullable { } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/ModulesTest.java0000644000175000017500000000477211704661106024754 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import com.google.inject.util.Modules; import junit.framework.TestCase; import java.util.Arrays; /** * @author jessewilson@google.com (Jesse Wilson) */ public class ModulesTest extends TestCase { public void testCombineVarargs() { Module combined = Modules.combine(newModule(1), newModule(2L), newModule((short) 3)); Injector injector = Guice.createInjector(combined); assertEquals(1, injector.getInstance(Integer.class).intValue()); assertEquals(2L, injector.getInstance(Long.class).longValue()); assertEquals(3, injector.getInstance(Short.class).shortValue()); } public void testCombineIterable() { Iterable modules = Arrays.asList(newModule(1), newModule(2L), newModule((short) 3)); Injector injector = Guice.createInjector(Modules.combine(modules)); assertEquals(1, injector.getInstance(Integer.class).intValue()); assertEquals(2, injector.getInstance(Long.class).longValue()); assertEquals(3, injector.getInstance(Short.class).shortValue()); } /** * The module returned by Modules.combine shouldn't show up in binder sources. */ public void testCombineSources() { Module skipSourcesModule = new AbstractModule() { @Override protected void configure() { install(Modules.combine(newModule(1), newModule(2L))); } }; Injector injector = Guice.createInjector(Modules.combine(skipSourcesModule)); StackTraceElement source = (StackTraceElement) injector.getBinding(Integer.class).getSource(); assertEquals(skipSourcesModule.getClass().getName(), source.getClassName()); } private Module newModule(final T toBind) { return new AbstractModule() { protected void configure() { @SuppressWarnings("unchecked") // getClass always needs a cast Class tClass = (Class) toBind.getClass(); binder().skipSources(getClass()).bind(tClass).toInstance(toBind); } }; } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/ModuleTest.java0000644000175000017500000000225711704661106024565 0ustar tonytony// Copyright 2007 Google Inc. All Rights Reserved. package com.google.inject; import junit.framework.TestCase; /** * Tests relating to modules. * * @author kevinb */ public class ModuleTest extends TestCase { static class A implements Module { public void configure(Binder binder) { binder.bind(X.class); binder.install(new B()); binder.install(new C()); } } static class B implements Module { public void configure(Binder binder) { binder.bind(Y.class); binder.install(new D()); } } static class C implements Module { public void configure(Binder binder) { binder.bind(Z.class); binder.install(new D()); } } static class D implements Module { public void configure(Binder binder) { binder.bind(W.class); } @Override public boolean equals(Object obj) { return obj.getClass() == D.class; // we're all equal in the eyes of guice } @Override public int hashCode() { return D.class.hashCode(); } } static class X {} static class Y {} static class Z {} static class W {} public void testDiamond() throws Exception { Guice.createInjector(new A()); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/MethodInterceptionTest.java0000644000175000017500000002510011704661106027134 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.matcher.Matchers.only; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.inject.matcher.AbstractMatcher; import com.google.inject.matcher.Matchers; import com.google.inject.spi.ConstructorBinding; import junit.framework.TestCase; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; /** * @author jessewilson@google.com (Jesse Wilson) */ public class MethodInterceptionTest extends TestCase { private AtomicInteger count = new AtomicInteger(); private final class CountingInterceptor implements MethodInterceptor { public Object invoke(MethodInvocation methodInvocation) throws Throwable { count.incrementAndGet(); return methodInvocation.proceed(); } } private final class ReturnNullInterceptor implements MethodInterceptor { public Object invoke(MethodInvocation methodInvocation) throws Throwable { return null; } } private final class NoOpInterceptor implements MethodInterceptor { public Object invoke(MethodInvocation methodInvocation) throws Throwable { return methodInvocation.proceed(); } } public void testSharedProxyClasses() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindInterceptor(Matchers.any(), Matchers.returns(only(Foo.class)), new ReturnNullInterceptor()); } }); Injector childOne = injector.createChildInjector(new AbstractModule() { protected void configure() { bind(Interceptable.class); } }); Interceptable nullFoosOne = childOne.getInstance(Interceptable.class); assertNotNull(nullFoosOne.bar()); assertNull(nullFoosOne.foo()); Injector childTwo = injector.createChildInjector(new AbstractModule() { protected void configure() { bind(Interceptable.class); } }); Interceptable nullFoosTwo = childTwo.getInstance(Interceptable.class); assertNull(nullFoosTwo.foo()); assertSame("Child injectors should share proxy classes, otherwise memory leaks!", nullFoosOne.getClass(), nullFoosTwo.getClass()); } public void testGetThis() { final AtomicReference lastTarget = new AtomicReference(); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindInterceptor(Matchers.any(), Matchers.any(), new MethodInterceptor() { public Object invoke(MethodInvocation methodInvocation) throws Throwable { lastTarget.set(methodInvocation.getThis()); return methodInvocation.proceed(); } }); } }); Interceptable interceptable = injector.getInstance(Interceptable.class); interceptable.foo(); assertSame(interceptable, lastTarget.get()); } public void testInterceptingFinalClass() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindInterceptor(Matchers.any(), Matchers.any(), new MethodInterceptor() { public Object invoke(MethodInvocation methodInvocation) throws Throwable { return methodInvocation.proceed(); } }); } }); try { injector.getInstance(NotInterceptable.class); fail(); } catch(ConfigurationException ce) { assertEquals("Unable to method intercept: " + NotInterceptable.class.getName(), Iterables.getOnlyElement(ce.getErrorMessages()).getMessage().toString()); assertEquals("Cannot subclass final class class " + NotInterceptable.class.getName(), ce.getCause().getMessage()); } } public void testSpiAccessToInterceptors() throws NoSuchMethodException { final MethodInterceptor countingInterceptor = new CountingInterceptor(); final MethodInterceptor returnNullInterceptor = new ReturnNullInterceptor(); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindInterceptor(Matchers.any(),Matchers.returns(only(Foo.class)), countingInterceptor); bindInterceptor(Matchers.any(), Matchers.returns(only(Foo.class).or(only(Bar.class))), returnNullInterceptor); } }); ConstructorBinding interceptedBinding = (ConstructorBinding) injector.getBinding(Interceptable.class); Method barMethod = Interceptable.class.getMethod("bar"); Method fooMethod = Interceptable.class.getMethod("foo"); assertEquals(ImmutableMap.>of( fooMethod, ImmutableList.of(countingInterceptor, returnNullInterceptor), barMethod, ImmutableList.of(returnNullInterceptor)), interceptedBinding.getMethodInterceptors()); ConstructorBinding nonInterceptedBinding = (ConstructorBinding) injector.getBinding(Foo.class); assertEquals(ImmutableMap.>of(), nonInterceptedBinding.getMethodInterceptors()); injector.getInstance(Interceptable.class).foo(); assertEquals("expected counting interceptor to be invoked first", 1, count.get()); } public void testInterceptedMethodThrows() throws Exception { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindInterceptor(Matchers.any(), Matchers.any(), new CountingInterceptor()); bindInterceptor(Matchers.any(), Matchers.any(), new CountingInterceptor()); } }); Interceptable interceptable = injector.getInstance(Interceptable.class); try { interceptable.explode(); fail(); } catch (Exception e) { // validate all causes. for (Throwable t = e; t != null; t = t.getCause()) { StackTraceElement[] stackTraceElement = t.getStackTrace(); assertEquals("explode", stackTraceElement[0].getMethodName()); assertEquals("invoke", stackTraceElement[1].getMethodName()); assertEquals("invoke", stackTraceElement[2].getMethodName()); assertEquals("testInterceptedMethodThrows", stackTraceElement[3].getMethodName()); } } } public void testNotInterceptedMethodsInInterceptedClassDontAddFrames() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindInterceptor(Matchers.any(), Matchers.returns(only(Foo.class)), new NoOpInterceptor()); } }); Interceptable interceptable = injector.getInstance(Interceptable.class); assertNull(interceptable.lastElements); interceptable.foo(); boolean cglibFound = false; for (int i = 0; i < interceptable.lastElements.length; i++) { if (interceptable.lastElements[i].toString().contains("cglib")) { cglibFound = true; break; } } assertTrue(Arrays.asList(interceptable.lastElements).toString(), cglibFound); cglibFound = false; interceptable.bar(); for (int i = 0; i < interceptable.lastElements.length; i++) { if (interceptable.lastElements[i].toString().contains("cglib")) { cglibFound = true; break; } } assertFalse(Arrays.asList(interceptable.lastElements).toString(), cglibFound); } static class Foo {} static class Bar {} public static class Interceptable { StackTraceElement[] lastElements; public Foo foo() { lastElements = Thread.currentThread().getStackTrace(); return new Foo() {}; } public Bar bar() { lastElements = Thread.currentThread().getStackTrace(); return new Bar() {}; } public String explode() throws Exception { lastElements = Thread.currentThread().getStackTrace(); throw new Exception("kaboom!", new RuntimeException("boom!")); } } public static final class NotInterceptable {} public void testInterceptingNonBridgeWorks() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Interface.class).to(Impl.class); bindInterceptor(Matchers.any(), new AbstractMatcher() { public boolean matches(Method t) { return !t.isBridge() && t.getDeclaringClass() != Object.class; } }, new CountingInterceptor()); } }); Interface intf = injector.getInstance(Interface.class); assertEquals(0, count.get()); intf.aMethod(null); assertEquals(1, count.get()); } static class ErasedType {} static class RetType extends ErasedType {} static abstract class Superclass { public T aMethod(T t) { return null; } } public interface Interface { RetType aMethod(RetType obj); } public static class Impl extends Superclass implements Interface { } public void testInterceptionOrder() { final List callList = Lists.newArrayList(); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindInterceptor(Matchers.any(), Matchers.any(), new NamedInterceptor("a", callList), new NamedInterceptor("b", callList), new NamedInterceptor("c", callList)); } }); Interceptable interceptable = injector.getInstance(Interceptable.class); assertEquals(0, callList.size()); interceptable.foo(); assertEquals(Arrays.asList("a", "b", "c"), callList); } private final class NamedInterceptor implements MethodInterceptor { private final String name; final List called; NamedInterceptor(String name, List callList) { this.name = name; this.called = callList; } public Object invoke(MethodInvocation methodInvocation) throws Throwable { called.add(name); return methodInvocation.proceed(); } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/MembersInjectorTest.java0000644000175000017500000002246611704661106026434 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import com.google.inject.name.Names; import com.google.inject.util.Providers; import junit.framework.AssertionFailedError; import junit.framework.TestCase; import java.util.concurrent.atomic.AtomicReference; /** * @author jessewilson@google.com (Jesse Wilson) */ public class MembersInjectorTest extends TestCase { private static final A uninjectableA = new A() { @Override void doNothing() { throw new AssertionFailedError(); } }; private static final B uninjectableB = new B() { @Override void doNothing() { throw new AssertionFailedError(); } }; private static final C myFavouriteC = new C(); public void testMembersInjectorFromBinder() { final AtomicReference>> aMembersInjectorReference = new AtomicReference>>(); final AtomicReference> bMembersInjectorReference = new AtomicReference>(); Guice.createInjector(new AbstractModule() { @Override protected void configure() { MembersInjector> aMembersInjector = getMembersInjector(new TypeLiteral>() {}); try { aMembersInjector.injectMembers(uninjectableA); fail(); } catch (IllegalStateException expected) { assertContains(expected.getMessage(), "This MembersInjector cannot be used until the Injector has been created."); } MembersInjector bMembersInjector = getMembersInjector(B.class); try { bMembersInjector.injectMembers(uninjectableB); fail(); } catch (IllegalStateException expected) { assertContains(expected.getMessage(), "This MembersInjector cannot be used until the Injector has been created."); } aMembersInjectorReference.set(aMembersInjector); bMembersInjectorReference.set(bMembersInjector); assertEquals("MembersInjector", getMembersInjector(String.class).toString()); bind(C.class).toInstance(myFavouriteC); } }); A injectableA = new A(); aMembersInjectorReference.get().injectMembers(injectableA); assertSame(myFavouriteC, injectableA.t); assertSame(myFavouriteC, injectableA.b.c); B injectableB = new B(); bMembersInjectorReference.get().injectMembers(injectableB); assertSame(myFavouriteC, injectableB.c); B anotherInjectableB = new B(); bMembersInjectorReference.get().injectMembers(anotherInjectableB); assertSame(myFavouriteC, anotherInjectableB.c); } public void testMembersInjectorFromInjector() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(C.class).toInstance(myFavouriteC); } }); MembersInjector> aMembersInjector = injector.getMembersInjector(new TypeLiteral>() {}); MembersInjector bMembersInjector = injector.getMembersInjector(B.class); A injectableA = new A(); aMembersInjector.injectMembers(injectableA); assertSame(myFavouriteC, injectableA.t); assertSame(myFavouriteC, injectableA.b.c); B injectableB = new B(); bMembersInjector.injectMembers(injectableB); assertSame(myFavouriteC, injectableB.c); B anotherInjectableB = new B(); bMembersInjector.injectMembers(anotherInjectableB); assertSame(myFavouriteC, anotherInjectableB.c); assertEquals("MembersInjector", injector.getMembersInjector(String.class).toString()); } public void testMembersInjectorWithNonInjectedTypes() { Injector injector = Guice.createInjector(); MembersInjector membersInjector = injector.getMembersInjector(NoInjectedMembers.class); membersInjector.injectMembers(new NoInjectedMembers()); membersInjector.injectMembers(new NoInjectedMembers()); } public void testInjectionFailure() { Injector injector = Guice.createInjector(); MembersInjector membersInjector = injector.getMembersInjector(InjectionFailure.class); try { membersInjector.injectMembers(new InjectionFailure()); fail(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "1) Error injecting method, java.lang.ClassCastException: whoops, failure #1"); } } public void testInjectionAppliesToSpecifiedType() { Injector injector = Guice.createInjector(); MembersInjector membersInjector = injector.getMembersInjector(Object.class); membersInjector.injectMembers(new InjectionFailure()); } public void testInjectingMembersInjector() { InjectsMembersInjector injectsMembersInjector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(C.class).toInstance(myFavouriteC); } }).getInstance(InjectsMembersInjector.class); A a = new A(); injectsMembersInjector.aMembersInjector.injectMembers(a); assertSame(myFavouriteC, a.t); assertSame(myFavouriteC, a.b.c); } public void testCannotBindMembersInjector() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(MembersInjector.class).toProvider(Providers.of(null)); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Binding to core guice framework type is not allowed: MembersInjector."); } try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(new TypeLiteral>>() {}) .toProvider(Providers.>>of(null)); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Binding to core guice framework type is not allowed: MembersInjector."); } } public void testInjectingMembersInjectorWithErrorsInDependencies() { try { Guice.createInjector().getInstance(InjectsBrokenMembersInjector.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "1) No implementation for " + Unimplemented.class.getName() + " was bound.", "while locating " + Unimplemented.class.getName(), "for field at " + A.class.getName() + ".t(MembersInjectorTest.java:", "while locating com.google.inject.MembersInjector<", "for field at " + InjectsBrokenMembersInjector.class.getName() + ".aMembersInjector(", "while locating " + InjectsBrokenMembersInjector.class.getName()); } } public void testLookupMembersInjectorBinding() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(C.class).toInstance(myFavouriteC); } }); MembersInjector> membersInjector = injector.getInstance(new Key>>() {}); A a = new A(); membersInjector.injectMembers(a); assertSame(myFavouriteC, a.t); assertSame(myFavouriteC, a.b.c); assertEquals("MembersInjector", injector.getInstance(new Key>() {}).toString()); } public void testGettingRawMembersInjector() { Injector injector = Guice.createInjector(); try { injector.getInstance(MembersInjector.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "Cannot inject a MembersInjector that has no type parameter"); } } public void testGettingAnnotatedMembersInjector() { Injector injector = Guice.createInjector(); try { injector.getInstance(new Key>(Names.named("foo")) {}); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "1) No implementation for com.google.inject.MembersInjector " + "annotated with @com.google.inject.name.Named(value=foo) was bound."); } } static class A { @Inject B b; @Inject T t; @Inject void doNothing() {} } static class B { @Inject C c; @Inject void doNothing() {} } static class C {} static class NoInjectedMembers {} static class InjectionFailure { int failures = 0; @Inject void fail() { throw new ClassCastException("whoops, failure #" + (++failures)); } } static class InjectsMembersInjector { @Inject MembersInjector> aMembersInjector; @Inject A ab; } static class InjectsBrokenMembersInjector { @Inject MembersInjector> aMembersInjector; } static interface Unimplemented {} } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/LoggerInjectionTest.java0000644000175000017500000000413311704661106026415 0ustar tonytonypackage com.google.inject; import static com.google.inject.Asserts.assertContains; import com.google.inject.name.Names; import junit.framework.TestCase; import java.util.logging.Logger; /** * Test built-in injection of loggers. * * @author jessewilson */ public class LoggerInjectionTest extends TestCase { @Inject Logger logger; public void testLoggerWithMember() { Injector injector = Guice.createInjector(); injector.injectMembers(this); assertEquals("com.google.inject.LoggerInjectionTest", logger.getName()); } public void testLoggerInConstructor() { Injector injector = Guice.createInjector(); Foo foo = injector.getInstance(Foo.class); assertEquals("com.google.inject.LoggerInjectionTest$Foo", foo.logger.getName()); } private static class Foo { Logger logger; @SuppressWarnings("unused") @Inject Foo(Logger logger) { this.logger = logger; } } public void testLoggerWithoutMember() { Injector injector = Guice.createInjector(); assertNull(injector.getInstance(Logger.class).getName()); assertNull(injector.getProvider(Logger.class).get().getName()); assertNull(injector.getBinding(Logger.class).getProvider().get().getName()); assertEquals("Provider", injector.getProvider(Logger.class).toString()); } public void testCanBindAnnotatedLogger() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Logger.class) .annotatedWith(Names.named("anonymous")) .toInstance(Logger.getAnonymousLogger()); } }); assertNull(injector.getInstance(Key.get(Logger.class, Names.named("anonymous"))).getName()); } public void testCannotBindLogger() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(Logger.class).toInstance(Logger.getAnonymousLogger()); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "A binding to java.util.logging.Logger was already configured"); } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/KeyTest.java0000644000175000017500000001733011704661106024066 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static com.google.inject.Asserts.assertEqualsBothWays; import static com.google.inject.Asserts.assertNotSerializable; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.name.Named; import com.google.inject.name.Names; import com.google.inject.util.Types; import junit.framework.TestCase; import java.io.IOException; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import java.util.List; import java.util.Map; /** * @author crazybob@google.com (Bob Lee) */ public class KeyTest extends TestCase { public void foo(List a, List b) {} public void bar(Provider> a) {} @Foo String baz; List wildcardExtends; public void testOfType() { Key k = Key.get(Object.class, Foo.class); Key ki = k.ofType(Integer.class); assertEquals(Integer.class, ki.getRawType()); assertEquals(Foo.class, ki.getAnnotationType()); } public void testKeyEquality() { Key> a = new Key>(Foo.class) {}; Key> b = Key.get(new TypeLiteral>() {}, Foo.class); assertEqualsBothWays(a, b); } public void testProviderKey() throws NoSuchMethodException { Key actual = Key.get(getClass().getMethod("foo", List.class, List.class) .getGenericParameterTypes()[0]).providerKey(); Key expected = Key.get(getClass().getMethod("bar", Provider.class) .getGenericParameterTypes()[0]); assertEqualsBothWays(expected, actual); assertEquals(expected.toString(), actual.toString()); } public void testTypeEquality() throws Exception { Method m = getClass().getMethod("foo", List.class, List.class); Type[] types = m.getGenericParameterTypes(); assertEquals(types[0], types[1]); Key> k = new Key>() {}; assertEquals(types[0], k.getTypeLiteral().getType()); assertFalse(types[0].equals( new Key>() {}.getTypeLiteral().getType())); } /** * Key canonicalizes {@link int.class} to {@code Integer.class}, and * won't expose wrapper types. */ public void testPrimitivesAndWrappersAreEqual() { Class[] primitives = new Class[] { boolean.class, byte.class, short.class, int.class, long.class, float.class, double.class, char.class, void.class }; Class[] wrappers = new Class[] { Boolean.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class, Character.class, Void.class }; for (int t = 0; t < primitives.length; t++) { @SuppressWarnings("unchecked") Key primitiveKey = Key.get(primitives[t]); @SuppressWarnings("unchecked") Key wrapperKey = Key.get(wrappers[t]); assertEquals(primitiveKey, wrapperKey); assertEquals(wrappers[t], primitiveKey.getRawType()); assertEquals(wrappers[t], wrapperKey.getRawType()); assertEquals(wrappers[t], primitiveKey.getTypeLiteral().getType()); assertEquals(wrappers[t], wrapperKey.getTypeLiteral().getType()); } Key integerKey = Key.get(Integer.class); Key integerKey2 = Key.get(Integer.class, Named.class); Key integerKey3 = Key.get(Integer.class, Names.named("int")); Class intClassLiteral = int.class; assertEquals(integerKey, Key.get(intClassLiteral)); assertEquals(integerKey2, Key.get(intClassLiteral, Named.class)); assertEquals(integerKey3, Key.get(intClassLiteral, Names.named("int"))); Type intType = int.class; assertEquals(integerKey, Key.get(intType)); assertEquals(integerKey2, Key.get(intType, Named.class)); assertEquals(integerKey3, Key.get(intType, Names.named("int"))); TypeLiteral intTypeLiteral = TypeLiteral.get(int.class); assertEquals(integerKey, Key.get(intTypeLiteral)); assertEquals(integerKey2, Key.get(intTypeLiteral, Named.class)); assertEquals(integerKey3, Key.get(intTypeLiteral, Names.named("int"))); } public void testSerialization() throws IOException, NoSuchFieldException { assertNotSerializable(Key.get(B.class)); assertNotSerializable(Key.get(B.class, Names.named("bee"))); assertNotSerializable(Key.get(B.class, Named.class)); assertNotSerializable(Key.get(B[].class)); assertNotSerializable(Key.get(new TypeLiteral, B>>() {})); assertNotSerializable(Key.get(new TypeLiteral>() {})); assertNotSerializable(Key.get(Types.listOf(Types.subtypeOf(CharSequence.class)))); } public void testEqualityOfAnnotationTypesAndInstances() throws NoSuchFieldException { Foo instance = getClass().getDeclaredField("baz").getAnnotation(Foo.class); Key keyWithInstance = Key.get(String.class, instance); Key keyWithLiteral = Key.get(String.class, Foo.class); assertEqualsBothWays(keyWithInstance, keyWithLiteral); } public void testNonBindingAnnotationOnKey() { try { Key.get(String.class, Deprecated.class); fail(); } catch (IllegalArgumentException expected) { assertContains(expected.getMessage(), "java.lang.Deprecated is not a binding annotation. ", "Please annotate it with @BindingAnnotation."); } } public void testBindingAnnotationWithoutRuntimeRetention() { try { Key.get(String.class, Bar.class); fail(); } catch (IllegalArgumentException expected) { assertContains(expected.getMessage(), Bar.class.getName() + " is not retained at runtime.", "Please annotate it with @Retention(RUNTIME)."); } } void parameterizedWithVariable(List typeWithVariables) {} /** Test for issue 186 */ public void testCannotCreateKeysWithTypeVariables() throws NoSuchMethodException { ParameterizedType listOfTType = (ParameterizedType) getClass().getDeclaredMethod( "parameterizedWithVariable", List.class).getGenericParameterTypes()[0]; TypeLiteral listOfT = TypeLiteral.get(listOfTType); try { Key.get(listOfT); fail("Guice should not allow keys for java.util.List"); } catch (ConfigurationException e) { assertContains(e.getMessage(), "java.util.List cannot be used as a key; It is not fully specified."); } TypeVariable tType = (TypeVariable) listOfTType.getActualTypeArguments()[0]; TypeLiteral t = TypeLiteral.get(tType); try { Key.get(t); fail("Guice should not allow keys for T"); } catch (ConfigurationException e) { assertContains(e.getMessage(), "T cannot be used as a key; It is not fully specified."); } } interface B {} @Retention(RUNTIME) @Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @BindingAnnotation @interface Foo {} @Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @BindingAnnotation @interface Bar {} class HasTypeParameters & Runnable, C extends Runnable> { A a; B b; C c; } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/JitBindingsTest.java0000644000175000017500000005464611704661106025555 0ustar tonytony/* * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.common.collect.ImmutableSet.of; import static com.google.inject.Asserts.assertContains; import static com.google.inject.JitBindingsTest.GetBindingCheck.ALLOW_BINDING; import static com.google.inject.JitBindingsTest.GetBindingCheck.ALLOW_BINDING_PROVIDER; import static com.google.inject.JitBindingsTest.GetBindingCheck.FAIL_ALL; import junit.framework.TestCase; import java.util.Set; /** * Some tests for {@link Binder#requireExplicitBindings()} * * @author sberlin@gmail.com (Sam Berlin) */ public class JitBindingsTest extends TestCase { private String jitFailed(Class clazz) { return jitFailed(TypeLiteral.get(clazz)); } private String jitFailed(TypeLiteral clazz) { return "Explicit bindings are required and " + clazz + " is not explicitly bound."; } private String inChildMessage(Class clazz) { return "Unable to create binding for " + clazz.getName() + ". It was already configured on one or more child injectors or private modules"; } public void testLinkedBindingWorks() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(Foo.class).to(FooImpl.class); } }); // Foo was explicitly bound ensureWorks(injector, Foo.class); // FooImpl was implicitly bound, it is an error to call getInstance or getProvider, // It is OK to call getBinding for introspection, but an error to get the provider // of the binding ensureFails(injector, ALLOW_BINDING, FooImpl.class); } public void testMoreBasicsWork() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(Foo.class).to(FooImpl.class); bind(Bar.class); bind(FooBar.class); } }); // Foo, Bar & FooBar was explicitly bound ensureWorks(injector, FooBar.class, Bar.class, Foo.class); // FooImpl was implicitly bound, it is an error to call getInstance or getProvider, // It is OK to call getBinding for introspection, but an error to get the provider // of the binding ensureFails(injector, ALLOW_BINDING, FooImpl.class); } public void testLinkedEagerSingleton() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(Foo.class).to(FooImpl.class).asEagerSingleton(); } }); // Foo was explicitly bound ensureWorks(injector, Foo.class); // FooImpl was implicitly bound, it is an error to call getInstance or getProvider, // It is OK to call getBinding for introspection, but an error to get the provider // of the binding ensureFails(injector, ALLOW_BINDING, FooImpl.class); } public void testBasicsWithEagerSingleton() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(Foo.class).to(FooImpl.class).asEagerSingleton(); bind(Bar.class); bind(FooBar.class); } }); // Foo, Bar & FooBar was explicitly bound ensureWorks(injector, FooBar.class, Bar.class, Foo.class); // FooImpl was implicitly bound, it is an error to call getInstance or getProvider, // It is OK to call getBinding for introspection, but an error to get the provider // of the binding ensureFails(injector, ALLOW_BINDING, FooImpl.class); } public void testLinkedToScoped() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder.requireExplicitBindings(); bind(Foo.class).to(ScopedFooImpl.class); } }); // Foo was explicitly bound ensureWorks(injector, Foo.class); // FooSingletonImpl was implicitly bound, it is an error to call getInstance or getProvider, // It is OK to call getBinding for introspection, but an error to get the provider // of the binding ensureFails(injector, ALLOW_BINDING, ScopedFooImpl.class); } public void testBasicsWithScoped() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(Foo.class).to(ScopedFooImpl.class); bind(Bar.class); bind(FooBar.class); } }); // Foo, Bar & FooBar was explicitly bound ensureWorks(injector, FooBar.class, Bar.class, Foo.class); // FooSingletonImpl was implicitly bound, it is an error to call getInstance or getProvider, // It is OK to call getBinding for introspection, but an error to get the provider // of the binding ensureFails(injector, ALLOW_BINDING, ScopedFooImpl.class); } public void testFailsIfInjectingScopedDirectlyWhenItIsntBound() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(Foo.class).to(ScopedFooImpl.class); bind(WantsScopedFooImpl.class); } }); fail(); } catch(CreationException expected) { assertContains(expected.getMessage(), "1) " + jitFailed(ScopedFooImpl.class)); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } } public void testLinkedProviderBindingWorks() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(Foo.class).toProvider(FooProvider.class); } }); // Foo was explicitly bound ensureWorks(injector, Foo.class); // FooImpl was not bound at all (even implicitly), it is an error // to call getInstance, getProvider, or getBinding. ensureFails(injector, FAIL_ALL, FooImpl.class); } public void testJitGetFails() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); } }).getInstance(Bar.class); fail("should have failed"); } catch(ConfigurationException expected) { assertContains(expected.getMessage(), "1) " + jitFailed(Bar.class)); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } } public void testJitInjectionFails() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(Foo.class).to(FooImpl.class); bind(FooBar.class); } }); fail("should have failed"); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) " + jitFailed(Bar.class)); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } } public void testJitProviderGetFails() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); } }).getProvider(Bar.class); fail("should have failed"); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "1) " + jitFailed(Bar.class)); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } } public void testJitProviderInjectionFails() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(Foo.class).to(FooImpl.class); bind(ProviderFooBar.class); } }); fail("should have failed"); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) " + jitFailed(Bar.class)); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } } public void testImplementedBy() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(ImplBy.class); } }); ensureWorks(injector, ImplBy.class); ensureFails(injector, ALLOW_BINDING, ImplByImpl.class); } public void testImplementedBySomethingThatIsAnnotated() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(ImplByScoped.class); } }); ensureWorks(injector, ImplByScoped.class); ensureFails(injector, ALLOW_BINDING, ImplByScopedImpl.class); } public void testProvidedBy() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(ProvBy.class); } }); ensureWorks(injector, ProvBy.class); ensureFails(injector, ALLOW_BINDING, ProvByProvider.class); } public void testProviderMethods() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); } @SuppressWarnings("unused") @Provides Foo foo() { return new FooImpl(); } }); ensureWorks(injector, Foo.class); } public void testChildInjectorInheritsOption() { Injector parent = Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(Bar.class); } }); ensureWorks(parent, Bar.class); ensureFails(parent, FAIL_ALL, FooImpl.class, FooBar.class, Foo.class); try { parent.createChildInjector(new AbstractModule() { @Override protected void configure() { bind(FooBar.class); } }); fail("should have failed"); } catch(CreationException expected) { assertContains(expected.getMessage(), "1) " + jitFailed(Foo.class)); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } Injector child = parent.createChildInjector(new AbstractModule() { @Override protected void configure() { bind(Foo.class).to(FooImpl.class); } }); ensureWorks(child, Foo.class, Bar.class); ensureFails(child, ALLOW_BINDING, FooImpl.class); ensureInChild(parent, FooImpl.class, FooBar.class, Foo.class); Injector grandchild = child.createChildInjector(new AbstractModule() { @Override protected void configure() { bind(FooBar.class); } }); ensureWorks(grandchild, FooBar.class, Foo.class, Bar.class); ensureFails(grandchild, ALLOW_BINDING, FooImpl.class); ensureFails(child, ALLOW_BINDING, FooImpl.class); ensureInChild(parent, FooImpl.class, FooBar.class, Foo.class); } public void testChildInjectorAddsOption() { Injector parent = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Bar.class); } }); int totalParentBindings = parent.getAllBindings().size(); try { parent.createChildInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(FooBar.class); } }); fail("should have failed"); } catch(CreationException expected) { assertContains(expected.getMessage(), "1) " + jitFailed(Foo.class)); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } assertEquals(totalParentBindings, parent.getAllBindings().size()); Injector child = parent.createChildInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(Foo.class).to(FooImpl.class); } }); totalParentBindings++; // creating this child added FooImpl to the parent. assertEquals(totalParentBindings, parent.getAllBindings().size()); ensureWorks(child, Foo.class, Bar.class); ensureFails(child, ALLOW_BINDING_PROVIDER, FooImpl.class); // Make extra certain that if something tries to inject a FooImpl from child // that it fails, even if calling getBinding().getProvider works.. because // the binding is built with the parent injector. try { child.injectMembers(new Object() { @SuppressWarnings("unused") @Inject void inject(FooImpl fooImpl) {} }); fail(); } catch(ConfigurationException expected) { assertContains(expected.getMessage(), "1) " + jitFailed(FooImpl.class)); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } Injector grandchild = child.createChildInjector(new AbstractModule() { @Override protected void configure() { bind(FooBar.class); } }); assertEquals(totalParentBindings, parent.getAllBindings().size()); ensureWorks(grandchild, FooBar.class, Foo.class, Bar.class); ensureFails(grandchild, ALLOW_BINDING_PROVIDER, FooImpl.class); ensureFails(child, ALLOW_BINDING_PROVIDER, FooImpl.class); // Make sure siblings of children don't inherit each others settings... // a new child should be able to get FooImpl. child = parent.createChildInjector(); ensureWorks(child, FooImpl.class); } public void testPrivateModulesInheritOptions() { try { Guice.createInjector(new AbstractModule() { protected void configure() { binder().requireExplicitBindings(); bind(Foo.class).to(FooImpl.class); install(new PrivateModule() { public void configure() { bind(FooBar.class); expose(FooBar.class); } }); } }); fail("should have failed"); } catch(CreationException expected) { assertContains(expected.getMessage(), "1) " + jitFailed(Bar.class)); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { binder().requireExplicitBindings(); install(new PrivateModule() { public void configure() { bind(Foo.class).to(FooImpl.class); expose(Foo.class); } }); } }); ensureInChild(injector, FooImpl.class); } public void testPrivateModuleAddsOption() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(Foo.class).to(FooImpl.class); // Fails because FooBar is in the private module, // and it wants Bar, but Bar would be JIT. install(new PrivateModule() { public void configure() { binder().requireExplicitBindings(); bind(FooBar.class); expose(FooBar.class); } }); } }); fail("should have failed"); } catch(CreationException expected) { assertContains(expected.getMessage(), "1) " + jitFailed(Bar.class)); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } } public void testPrivateModuleSiblingsDontShareOption() { Guice.createInjector(new AbstractModule() { protected void configure() { bind(Foo.class).to(FooImpl.class); install(new PrivateModule() { public void configure() { binder().requireExplicitBindings(); } }); // This works, even though Bar is JIT, // because the requireExplicitBindings isn't shared // between sibling private modules. install(new PrivateModule() { public void configure() { bind(FooBar.class); expose(FooBar.class); } }); } }); } public void testTypeLiteralsCanBeInjected() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); bind(new TypeLiteral>() {}); bind(new TypeLiteral>() {}).toInstance(of("bar")); } }); WantsTypeLiterals foo = injector.getInstance(new Key>() {}); assertEquals(foo.literal.getRawType(), String.class); assertEquals(of("bar"), foo.set); } public void testMembersInjectorsCanBeInjected() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); } @Provides String data(MembersInjector mi) { String data = "foo"; mi.injectMembers(data); return data; } }); String data = injector.getInstance(String.class); assertEquals("foo", data); } private void ensureWorks(Injector injector, Class... classes) { for(int i = 0; i < classes.length; i++) { injector.getInstance(classes[i]); injector.getProvider(classes[i]).get(); injector.getBinding(classes[i]).getProvider().get(); } } enum GetBindingCheck { FAIL_ALL, ALLOW_BINDING, ALLOW_BINDING_PROVIDER } private void ensureFails(Injector injector, GetBindingCheck getBinding, Class... classes) { for(int i = 0; i < classes.length; i++) { try { injector.getInstance(classes[i]); fail("should have failed tring to retrieve class: " + classes[i]); } catch(ConfigurationException expected) { assertContains(expected.getMessage(), "1) " + jitFailed(classes[i])); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } try { injector.getProvider(classes[i]); fail("should have failed tring to retrieve class: " + classes[i]); } catch(ConfigurationException expected) { assertContains(expected.getMessage(), "1) " + jitFailed(classes[i])); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } if (getBinding == GetBindingCheck.ALLOW_BINDING || getBinding == GetBindingCheck.ALLOW_BINDING_PROVIDER) { Binding binding = injector.getBinding(classes[i]); try { binding.getProvider(); if (getBinding != GetBindingCheck.ALLOW_BINDING_PROVIDER) { fail("should have failed trying to retrieve class: " + classes[i]); } } catch(ConfigurationException expected) { if (getBinding == GetBindingCheck.ALLOW_BINDING_PROVIDER) { throw expected; } assertContains(expected.getMessage(), "1) " + jitFailed(classes[i])); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } } else { try { injector.getBinding(classes[i]); fail("should have failed tring to retrieve class: " + classes[i]); } catch(ConfigurationException expected) { assertContains(expected.getMessage(), "1) " + jitFailed(classes[i])); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } } } } private void ensureInChild(Injector injector, Class... classes) { for(int i = 0; i < classes.length; i++) { try { injector.getInstance(classes[i]); fail("should have failed tring to retrieve class: " + classes[i]); } catch(ConfigurationException expected) { assertContains(expected.getMessage(), "1) " + inChildMessage(classes[i])); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } try { injector.getProvider(classes[i]); fail("should have failed tring to retrieve class: " + classes[i]); } catch(ConfigurationException expected) { assertContains(expected.getMessage(), "1) " + inChildMessage(classes[i])); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } try { injector.getBinding(classes[i]); fail("should have failed tring to retrieve class: " + classes[i]); } catch(ConfigurationException expected) { assertContains(expected.getMessage(), "1) " + inChildMessage(classes[i])); assertTrue(expected.getMessage(), !expected.getMessage().contains("2) ")); } } } private static interface Foo {} private static class FooImpl implements Foo {} @Singleton private static class ScopedFooImpl implements Foo {} private static class WantsScopedFooImpl { @SuppressWarnings("unused") @Inject ScopedFooImpl scopedFoo; } private static class Bar {} private static class FooBar { @SuppressWarnings("unused") @Inject Foo foo; @SuppressWarnings("unused") @Inject Bar bar; } private static class ProviderFooBar { @SuppressWarnings("unused") @Inject Provider foo; @SuppressWarnings("unused") @Inject Provider bar; } private static class FooProvider implements Provider { public Foo get() { return new FooImpl(); } } @ImplementedBy(ImplByImpl.class) private static interface ImplBy {} private static class ImplByImpl implements ImplBy {} @ImplementedBy(ImplByScopedImpl.class) private static interface ImplByScoped {} @Singleton private static class ImplByScopedImpl implements ImplByScoped {} @ProvidedBy(ProvByProvider.class) private static interface ProvBy {} private static class ProvByProvider implements Provider { public ProvBy get() { return new ProvBy() {}; } } private static class WantsTypeLiterals { TypeLiteral literal; Set set; @Inject WantsTypeLiterals(TypeLiteral literal, Set set) { this.literal = literal; this.set = set; } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/IntegrationTest.java0000644000175000017500000000344711704661106025625 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.matcher.Matchers.any; import junit.framework.TestCase; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; /** * @author crazybob@google.com (Bob Lee) */ public class IntegrationTest extends TestCase { public void testIntegration() throws CreationException { final CountingInterceptor counter = new CountingInterceptor(); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Foo.class); bindInterceptor(any(), any(), counter); } }); Foo foo = injector.getInstance(Key.get(Foo.class)); foo.foo(); assertTrue(foo.invoked); assertEquals(1, counter.count); foo = injector.getInstance(Foo.class); foo.foo(); assertTrue(foo.invoked); assertEquals(2, counter.count); } static class Foo { boolean invoked; public void foo() { invoked = true; } } static class CountingInterceptor implements MethodInterceptor { int count; public Object invoke(MethodInvocation methodInvocation) throws Throwable { count++; return methodInvocation.proceed(); } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/InjectorTest.java0000644000175000017500000002505211704661106025113 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static com.google.inject.Asserts.assertNotSerializable; import static java.lang.annotation.RetentionPolicy.RUNTIME; import junit.framework.TestCase; import java.io.IOException; import java.lang.annotation.Retention; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicReference; /** * @author crazybob@google.com (Bob Lee) */ public class InjectorTest extends TestCase { @Retention(RUNTIME) @BindingAnnotation @interface Other {} @Retention(RUNTIME) @BindingAnnotation @interface S {} @Retention(RUNTIME) @BindingAnnotation @interface I {} public void testToStringDoesNotInfinitelyRecurse() { Injector injector = Guice.createInjector(Stage.TOOL); injector.toString(); injector.getBinding(Injector.class).toString(); } public void testProviderMethods() throws CreationException { final SampleSingleton singleton = new SampleSingleton(); final SampleSingleton other = new SampleSingleton(); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(SampleSingleton.class).toInstance(singleton); bind(SampleSingleton.class) .annotatedWith(Other.class) .toInstance(other); } }); assertSame(singleton, injector.getInstance(Key.get(SampleSingleton.class))); assertSame(singleton, injector.getInstance(SampleSingleton.class)); assertSame(other, injector.getInstance(Key.get(SampleSingleton.class, Other.class))); } static class SampleSingleton {} public void testInjection() throws CreationException { Injector injector = createFooInjector(); Foo foo = injector.getInstance(Foo.class); assertEquals("test", foo.s); assertEquals("test", foo.bar.getTee().getS()); assertSame(foo.bar, foo.copy); assertEquals(5, foo.i); assertEquals(5, foo.bar.getI()); // Test circular dependency. assertSame(foo.bar, foo.bar.getTee().getBar()); } private Injector createFooInjector() throws CreationException { return Guice.createInjector(new AbstractModule() { protected void configure() { bind(Bar.class).to(BarImpl.class); bind(Tee.class).to(TeeImpl.class); bindConstant().annotatedWith(S.class).to("test"); bindConstant().annotatedWith(I.class).to(5); } }); } public void testGetInstance() throws CreationException { Injector injector = createFooInjector(); Bar bar = injector.getInstance(Key.get(Bar.class)); assertEquals("test", bar.getTee().getS()); assertEquals(5, bar.getI()); } public void testIntAndIntegerAreInterchangeable() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bindConstant().annotatedWith(I.class).to(5); } }); IntegerWrapper iw = injector.getInstance(IntegerWrapper.class); assertEquals(5, (int) iw.i); } public void testInjectorApiIsNotSerializable() throws IOException { Injector injector = Guice.createInjector(); assertNotSerializable(injector); assertNotSerializable(injector.getProvider(String.class)); assertNotSerializable(injector.getBinding(String.class)); for (Binding binding : injector.getBindings().values()) { assertNotSerializable(binding); } } static class IntegerWrapper { @Inject @I Integer i; } static class Foo { @Inject Bar bar; @Inject Bar copy; @Inject @S String s; int i; @Inject void setI(@I int i) { this.i = i; } } interface Bar { Tee getTee(); int getI(); } @Singleton static class BarImpl implements Bar { @Inject @I int i; Tee tee; @Inject void initialize(Tee tee) { this.tee = tee; } public Tee getTee() { return tee; } public int getI() { return i; } } interface Tee { String getS(); Bar getBar(); } static class TeeImpl implements Tee { final String s; @Inject Bar bar; @Inject TeeImpl(@S String s) { this.s = s; } public String getS() { return s; } public Bar getBar() { return bar; } } public void testInjectStatics() throws CreationException { Guice.createInjector(new AbstractModule() { protected void configure() { bindConstant().annotatedWith(S.class).to("test"); bindConstant().annotatedWith(I.class).to(5); requestStaticInjection(Static.class); } }); assertEquals("test", Static.s); assertEquals(5, Static.i); } public void testInjectStaticInterface() { try { Guice.createInjector(new AbstractModule() { protected void configure() { requestStaticInjection(Interface.class); } }); fail(); } catch(CreationException ce) { assertEquals(1, ce.getErrorMessages().size()); Asserts.assertContains( ce.getMessage(), "1) " + Interface.class.getName() + " is an interface, but interfaces have no static injection points.", "at " + InjectorTest.class.getName(), "configure"); } } private static interface Interface {} static class Static { @Inject @I static int i; static String s; @Inject static void setS(@S String s) { Static.s = s; } } public void testPrivateInjection() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(String.class).toInstance("foo"); bind(int.class).toInstance(5); } }); Private p = injector.getInstance(Private.class); assertEquals("foo", p.fromConstructor); assertEquals(5, p.fromMethod); } static class Private { String fromConstructor; int fromMethod; @Inject private Private(String fromConstructor) { this.fromConstructor = fromConstructor; } @Inject private void setInt(int i) { this.fromMethod = i; } } public void testProtectedInjection() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(String.class).toInstance("foo"); bind(int.class).toInstance(5); } }); Protected p = injector.getInstance(Protected.class); assertEquals("foo", p.fromConstructor); assertEquals(5, p.fromMethod); } static class Protected { String fromConstructor; int fromMethod; @Inject protected Protected(String fromConstructor) { this.fromConstructor = fromConstructor; } @Inject protected void setInt(int i) { this.fromMethod = i; } } public void testInstanceInjectionHappensAfterFactoriesAreSetUp() { Guice.createInjector(new AbstractModule() { protected void configure() { bind(Object.class).toInstance(new Object() { @Inject Runnable r; }); bind(Runnable.class).to(MyRunnable.class); } }); } public void testSubtypeNotProvided() { try { Guice.createInjector().getInstance(Money.class); fail(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), Tree.class.getName() + " doesn't provide instances of " + Money.class.getName(), "while locating ", Tree.class.getName(), "while locating ", Money.class.getName()); } } public void testNotASubtype() { try { Guice.createInjector().getInstance(PineTree.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), Tree.class.getName() + " doesn't extend " + PineTree.class.getName(), "while locating ", PineTree.class.getName()); } } public void testRecursiveImplementationType() { try { Guice.createInjector().getInstance(SeaHorse.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "@ImplementedBy points to the same class it annotates.", "while locating ", SeaHorse.class.getName()); } } public void testRecursiveProviderType() { try { Guice.createInjector().getInstance(Chicken.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "@ProvidedBy points to the same class it annotates", "while locating ", Chicken.class.getName()); } } static class MyRunnable implements Runnable { public void run() {} } @ProvidedBy(Tree.class) static class Money {} static class Tree implements Provider { public Object get() { return "Money doesn't grow on trees"; } } @ImplementedBy(Tree.class) static class PineTree extends Tree {} @ImplementedBy(SeaHorse.class) static class SeaHorse {} @ProvidedBy(Chicken.class) static class Chicken implements Provider { public Chicken get() { return this; } } public void testJitBindingFromAnotherThreadDuringInjection() { final ExecutorService executorService = Executors.newSingleThreadExecutor(); final AtomicReference got = new AtomicReference(); Guice.createInjector(new AbstractModule() { protected void configure() { requestInjection(new Object() { @Inject void initialize(final Injector injector) throws ExecutionException, InterruptedException { Future future = executorService.submit(new Callable() { public JustInTime call() throws Exception { return injector.getInstance(JustInTime.class); } }); got.set(future.get()); } }); } }); assertNotNull(got.get()); } static class JustInTime {} } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/ImplicitBindingTest.java0000644000175000017500000002656211704661106026412 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import com.google.common.collect.Iterables; import com.google.inject.name.Named; import com.google.inject.name.Names; import com.google.inject.spi.Message; import junit.framework.TestCase; import java.util.List; /** * @author crazybob@google.com (Bob Lee) */ public class ImplicitBindingTest extends TestCase { public void testCircularDependency() throws CreationException { Injector injector = Guice.createInjector(); Foo foo = injector.getInstance(Foo.class); assertSame(foo, foo.bar.foo); } static class Foo { @Inject Bar bar; } static class Bar { final Foo foo; @Inject public Bar(Foo foo) { this.foo = foo; } } public void testDefaultImplementation() { Injector injector = Guice.createInjector(); I i = injector.getInstance(I.class); i.go(); } @ImplementedBy(IImpl.class) interface I { void go(); } static class IImpl implements I { public void go() {} } static class AlternateImpl implements I { public void go() {} } public void testDefaultProvider() { Injector injector = Guice.createInjector(); Provided provided = injector.getInstance(Provided.class); provided.go(); } public void testBindingOverridesImplementedBy() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(I.class).to(AlternateImpl.class); } }); assertEquals(AlternateImpl.class, injector.getInstance(I.class).getClass()); } @ProvidedBy(ProvidedProvider.class) interface Provided { void go(); } public void testNoImplicitBindingIsCreatedForAnnotatedKeys() { try { Guice.createInjector().getInstance(Key.get(I.class, Names.named("i"))); fail(); } catch (ConfigurationException expected) { Asserts.assertContains(expected.getMessage(), "1) No implementation for " + I.class.getName(), "annotated with @" + Named.class.getName() + "(value=i) was bound.", "while locating " + I.class.getName(), " annotated with @" + Named.class.getName() + "(value=i)"); } } static class ProvidedProvider implements Provider { public Provided get() { return new Provided() { public void go() {} }; } } /** * When we're building the binding for A, we temporarily insert that binding to support circular * dependencies. And so we can successfully create a binding for B. But later, when the binding * for A ultimately fails, we need to clean up the dependent binding for B. * * The test loops through linked bindings & bindings with constructor & member injections, * to make sure that all are cleaned up and traversed. It also makes sure we don't touch * explicit bindings. */ public void testCircularJitBindingsLeaveNoResidue() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Valid.class); bind(Valid2.class); } }); // Capture good bindings. Binding v1 = injector.getBinding(Valid.class); Binding v2 = injector.getBinding(Valid2.class); Binding jv1 = injector.getBinding(JitValid.class); Binding jv2 = injector.getBinding(JitValid2.class); // Then validate that a whole series of invalid bindings are erased. assertFailure(injector, Invalid.class); assertFailure(injector, InvalidLinked.class); assertFailure(injector, InvalidLinkedImpl.class); assertFailure(injector, InvalidLinked2.class); assertFailure(injector, InvalidLinked2Impl.class); assertFailure(injector, InvalidProvidedBy.class); assertFailure(injector, InvalidProvidedByProvider.class); assertFailure(injector, InvalidProvidedBy2.class); assertFailure(injector, InvalidProvidedBy2Provider.class); assertFailure(injector, Invalid2.class); // Validate we didn't do anything to the valid explicit bindings. assertSame(v1, injector.getBinding(Valid.class)); assertSame(v2, injector.getBinding(Valid2.class)); // Validate that we didn't erase the valid JIT bindings assertSame(jv1, injector.getBinding(JitValid.class)); assertSame(jv2, injector.getBinding(JitValid2.class)); } @SuppressWarnings("unchecked") private void assertFailure(Injector injector, Class clazz) { try { injector.getBinding(clazz); fail("Shouldn't have been able to get binding of: " + clazz); } catch(ConfigurationException expected) { Message msg = Iterables.getOnlyElement(expected.getErrorMessages()); assertEquals("No implementation for " + InvalidInterface.class.getName() + " was bound.", msg.getMessage()); List sources = msg.getSources(); // Assert that the first item in the sources if the key for the class we're looking up, // ensuring that each lookup is "new". assertEquals(Key.get(clazz).toString(), sources.get(0).toString()); // Assert that the last item in each lookup contains the InvalidInterface class Asserts.assertContains(sources.get(sources.size()-1).toString(), Key.get(InvalidInterface.class).toString()); } } static class Invalid { @Inject Valid a; @Inject JitValid b; @Inject InvalidProvidedBy c; @Inject Invalid(InvalidLinked a) {} @Inject void foo(InvalidInterface a) {} } @ImplementedBy(InvalidLinkedImpl.class) static interface InvalidLinked {} static class InvalidLinkedImpl implements InvalidLinked { @Inject InvalidLinked2 a; } @ImplementedBy(InvalidLinked2Impl.class) static interface InvalidLinked2 {} static class InvalidLinked2Impl implements InvalidLinked2 { @Inject InvalidLinked2Impl(Invalid2 a) {} } @ProvidedBy(InvalidProvidedByProvider.class) static interface InvalidProvidedBy {} static class InvalidProvidedByProvider implements Provider { @Inject InvalidProvidedBy2 a; public InvalidProvidedBy get() { return null; } } @ProvidedBy(InvalidProvidedBy2Provider.class) static interface InvalidProvidedBy2 {} static class InvalidProvidedBy2Provider implements Provider { @Inject Invalid2 a; public InvalidProvidedBy2 get() { return null; } } static class Invalid2 { @Inject Invalid a; } interface InvalidInterface {} static class Valid { @Inject Valid2 a; } static class Valid2 {} static class JitValid { @Inject JitValid2 a; } static class JitValid2 {} /** * Regression test for http://code.google.com/p/google-guice/issues/detail?id=319 * * The bug is that a class that asks for a provider for itself during injection time, * where any one of the other types required to fulfill the object creation was bound * in a child constructor, explodes when the injected Provider is called. * * It works just fine when the other types are bound in a main injector. */ public void testInstancesRequestingProvidersForThemselvesWithChildInjectors() { final Module testModule = new AbstractModule() { @Override protected void configure() { bind(String.class) .toProvider(TestStringProvider.class); } }; // Verify it works when the type is setup in the parent. Injector parentSetupRootInjector = Guice.createInjector(testModule); Injector parentSetupChildInjector = parentSetupRootInjector.createChildInjector(); assertEquals(TestStringProvider.TEST_VALUE, parentSetupChildInjector.getInstance( RequiresProviderForSelfWithOtherType.class).getValue()); // Verify it works when the type is setup in the child, not the parent. // If it still occurs, the bug will explode here. Injector childSetupRootInjector = Guice.createInjector(); Injector childSetupChildInjector = childSetupRootInjector.createChildInjector(testModule); assertEquals(TestStringProvider.TEST_VALUE, childSetupChildInjector.getInstance( RequiresProviderForSelfWithOtherType.class).getValue()); } static class TestStringProvider implements Provider { static final String TEST_VALUE = "This is to verify it all works"; public String get() { return TEST_VALUE; } } static class RequiresProviderForSelfWithOtherType { private final Provider selfProvider; private final String providedStringValue; @Inject RequiresProviderForSelfWithOtherType( String providedStringValue, Provider selfProvider ) { this.providedStringValue = providedStringValue; this.selfProvider = selfProvider; } public String getValue() { // Attempt to get another instance of ourself. This pattern // is possible for recursive processing. selfProvider.get(); return providedStringValue; } } /** * Ensure that when we cleanup failed JIT bindings, we don't break. * The test here requires a sequence of JIT bindings: * A-> B * B -> C, A * C -> A, D * D not JITable * The problem was that C cleaned up A's binding and then handed control back to B, * which tried to continue processing A.. but A was removed from the jitBindings Map, * so it attempts to create a new JIT binding for A, but we haven't yet finished * constructing the first JIT binding for A, so we get a recursive * computation exception from ComputingConcurrentHashMap. * * We also throw in a valid JIT binding, E, to guarantee that if * something fails in this flow, it can be recreated later if it's * not from a failed sequence. */ public void testRecursiveJitBindingsCleanupCorrectly() throws Exception { Injector injector = Guice.createInjector(); try { injector.getInstance(A.class); fail("Expected failure"); } catch(ConfigurationException expected) { Message msg = Iterables.getOnlyElement(expected.getErrorMessages()); Asserts.assertContains(msg.getMessage(), "Could not find a suitable constructor in " + D.class.getName()); } // Assert that we've removed all the bindings. assertNull(injector.getExistingBinding(Key.get(A.class))); assertNull(injector.getExistingBinding(Key.get(B.class))); assertNull(injector.getExistingBinding(Key.get(C.class))); assertNull(injector.getExistingBinding(Key.get(D.class))); // Confirm that we didn't prevent 'E' from working. assertNotNull(injector.getBinding(Key.get(E.class))); } static class A { @Inject public A(B b) {} } static class B { @Inject public B(C c, A a) {} } static class C { @Inject public C(A a, D d, E e) {} } static class D { public D(int i) {} } // Valid JITable binding static class E { } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/GenericInjectionTest.java0000644000175000017500000001356611704661106026564 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.inject.util.Modules; import junit.framework.TestCase; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; /** * @author crazybob@google.com (Bob Lee) */ public class GenericInjectionTest extends TestCase { public void testGenericInjection() throws CreationException { final List names = Arrays.asList("foo", "bar", "bob"); Injector injector = Guice.createInjector((Module) new AbstractModule() { protected void configure() { bind(new TypeLiteral>() {}).toInstance(names); } }); Foo foo = injector.getInstance(Foo.class); assertEquals(names, foo.names); } static class Foo { @Inject List names; } /** * Although we may not have intended to support this behaviour, this test * passes under Guice 1.0. The workaround is to add an explicit binding for * the parameterized type. See {@link #testExplicitBindingOfGenericType()}. */ public void testImplicitBindingOfGenericType() { Parameterized parameterized = Guice.createInjector().getInstance(Key.get(new TypeLiteral>() {})); assertNotNull(parameterized); } public void testExplicitBindingOfGenericType() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Key.get(new TypeLiteral>() {})) .to((Class) Parameterized.class); } }); Parameterized parameterized = injector.getInstance(Key.get(new TypeLiteral>() { })); assertNotNull(parameterized); } static class Parameterized { @Inject Parameterized() { } } public void testInjectingParameterizedDependenciesForImplicitBinding() { assertParameterizedDepsInjected(new Key>() {}, Modules.EMPTY_MODULE); } public void testInjectingParameterizedDependenciesForBindingTarget() { final TypeLiteral> type = new TypeLiteral>() {}; assertParameterizedDepsInjected(Key.get(Object.class), new AbstractModule() { protected void configure() { bind(Object.class).to(type); } }); } public void testInjectingParameterizedDependenciesForBindingSource() { final TypeLiteral> type = new TypeLiteral>() {}; assertParameterizedDepsInjected(Key.get(type), new AbstractModule() { protected void configure() { bind(type); } }); } public void testBindingToSubtype() { final TypeLiteral> type = new TypeLiteral>() {}; assertParameterizedDepsInjected(Key.get(type), new AbstractModule() { protected void configure() { bind(type).to(new TypeLiteral>() {}); } }); } public void testBindingSubtype() { final TypeLiteral> type = new TypeLiteral>() {}; assertParameterizedDepsInjected(Key.get(type), new AbstractModule() { protected void configure() { bind(type); } }); } @SuppressWarnings("unchecked") public void assertParameterizedDepsInjected(Key key, Module bindingModule) { Module bindDataModule = new AbstractModule() { protected void configure() {} @Provides Map provideMap() { return ImmutableMap.of("one", 1, "two", 2); } @Provides Set provideSet(Map map) { return map.keySet(); } @Provides Collection provideCollection(Map map) { return map.values(); } }; Injector injector = Guice.createInjector(bindDataModule, bindingModule); ParameterizedDeps parameterizedDeps = (ParameterizedDeps) injector.getInstance(key); assertEquals(ImmutableMap.of("one", 1, "two", 2), parameterizedDeps.map); assertEquals(ImmutableSet.of("one", "two"), parameterizedDeps.keys); assertEquals(ImmutableSet.of(1, 2), ImmutableSet.copyOf(parameterizedDeps.values)); } static class SubParameterizedDeps extends ParameterizedDeps { @Inject SubParameterizedDeps(Set keys) { super(keys); } } static class ParameterizedDeps { @Inject private Map map; private Set keys; private Collection values; @Inject ParameterizedDeps(Set keys) { this.keys = keys; } @Inject void method(Collection values) { this.values = values; } } public void testImmediateTypeVariablesAreInjected() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(String.class).toInstance("tee"); } }); InjectsT injectsT = injector.getInstance(new Key>() {}); assertEquals("tee", injectsT.t); } static class InjectsT { @Inject T t; } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/ErrorHandlingTest.java0000644000175000017500000000667311704661106026104 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.name.Named; import com.google.inject.name.Names; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; import java.util.List; /** * @author crazybob@google.com (Bob Lee) */ public class ErrorHandlingTest { public static void main(String[] args) throws CreationException { try { Guice.createInjector(new MyModule()); } catch (CreationException e) { e.printStackTrace(); System.err.println("--"); } Injector bad = Guice.createInjector(new AbstractModule() { protected void configure() { bind(String.class).toProvider(new Provider() { public String get() { return null; } }); } }); try { bad.getInstance(String.class); } catch (Exception e) { e.printStackTrace(); System.err.println("--"); } try { bad.getInstance(NeedsString.class); } catch (Exception e) { e.printStackTrace(); System.err.println("--"); } } static class NeedsString { @Inject String mofo; } @Inject @Named("missing") static List missing = null; static class Foo { @Inject public Foo(Runnable r) {} @Inject void setNames(List names) {} } static class Bar { // Invalid constructor. Bar(String s) {} @Inject void setNumbers(@Named("numbers") List numbers) {} @Inject void bar(@Named("foo") String s) {} } static class Tee { @Inject String s; @Inject void tee(String s, int i) {} @Inject Invalid invalid; } static class Invalid { Invalid(String s) {} } @Singleton @GoodScope static class TooManyScopes { } @Target(ElementType.TYPE) @Retention(RUNTIME) @ScopeAnnotation @interface GoodScope {} @interface BadScope {} @ImplementedBy(String.class) interface I {} static class MyModule extends AbstractModule { protected void configure() { bind(Runnable.class); bind(Foo.class); bind(Bar.class); bind(Tee.class); bind(new TypeLiteral>() {}); bind(String.class).annotatedWith(Names.named("foo")).in(Named.class); bind(Key.get(Runnable.class)).to(Key.get(Runnable.class)); bind(TooManyScopes.class); bindScope(BadScope.class, Scopes.SINGLETON); bind(Object.class).toInstance(new Object() { @Inject void foo() { throw new RuntimeException(); } }); requestStaticInjection(ErrorHandlingTest.class); addError("I don't like %s", "you"); Object o = "2"; try { Integer i = (Integer) o; } catch (Exception e) { addError(e); } bind(Module.class).toInstance(this); bind(I.class); } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/EagerSingletonTest.java0000644000175000017500000000466411704661106026252 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import junit.framework.TestCase; /** * @author jessewilson@google.com (Jesse Wilson) */ public class EagerSingletonTest extends TestCase { @Override public void setUp() { A.instanceCount = 0; B.instanceCount = 0; C.instanceCount = 0; } public void testJustInTimeEagerSingletons() { Guice.createInjector(Stage.PRODUCTION, new AbstractModule() { protected void configure() { // create a just-in-time binding for A getProvider(A.class); // create a just-in-time binding for C requestInjection(new Object() { @Inject void inject(Injector injector) { injector.getInstance(C.class); } }); } }); assertEquals(1, A.instanceCount); assertEquals("Singletons discovered when creating singletons should not be built eagerly", 0, B.instanceCount); assertEquals(1, C.instanceCount); } public void testJustInTimeSingletonsAreNotEager() { Injector injector = Guice.createInjector(Stage.PRODUCTION); injector.getProvider(B.class); assertEquals(0, B.instanceCount); } public void testChildEagerSingletons() { Injector parent = Guice.createInjector(Stage.PRODUCTION); parent.createChildInjector(new AbstractModule() { @Override protected void configure() { bind(D.class).to(C.class); } }); assertEquals(1, C.instanceCount); } @Singleton static class A { static int instanceCount = 0; int instanceId = instanceCount++; @Inject A(Injector injector) { injector.getProvider(B.class); } } @Singleton static class B { static int instanceCount = 0; int instanceId = instanceCount++; } @Singleton static class C implements D { static int instanceCount = 0; int instanceId = instanceCount++; } private static interface D {} } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/DuplicateBindingsTest.java0000644000175000017500000004702111704661106026726 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static com.google.inject.name.Names.named; import com.google.common.base.Objects; import com.google.common.collect.Lists; import com.google.inject.name.Named; import com.google.inject.spi.Element; import com.google.inject.spi.Elements; import com.google.inject.util.Providers; import junit.framework.TestCase; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashSet; import java.util.List; import java.util.logging.Logger; /** * A suite of tests for duplicate bindings. * * @author sameb@google.com (Sam Berlin) */ public class DuplicateBindingsTest extends TestCase { private FooImpl foo = new FooImpl(); private Provider pFoo = Providers.of(new FooImpl()); private Class> pclFoo = FooProvider.class; private Class clFoo = FooImpl.class; private Constructor cFoo = FooImpl.cxtor(); public void testDuplicateBindingsAreIgnored() { Injector injector = Guice.createInjector( new SimpleModule(foo, pFoo, pclFoo, clFoo, cFoo), new SimpleModule(foo, pFoo, pclFoo, clFoo, cFoo) ); List> bindings = Lists.newArrayList(injector.getAllBindings().keySet()); removeBasicBindings(bindings); // Ensure only one binding existed for each type. assertTrue(bindings.remove(Key.get(Foo.class, named("instance")))); assertTrue(bindings.remove(Key.get(Foo.class, named("pInstance")))); assertTrue(bindings.remove(Key.get(Foo.class, named("pKey")))); assertTrue(bindings.remove(Key.get(Foo.class, named("linkedKey")))); assertTrue(bindings.remove(Key.get(FooImpl.class))); assertTrue(bindings.remove(Key.get(Foo.class, named("constructor")))); assertTrue(bindings.remove(Key.get(FooProvider.class))); // JIT binding assertTrue(bindings.remove(Key.get(Foo.class, named("providerMethod")))); assertEquals(bindings.toString(), 0, bindings.size()); } public void testElementsDeduplicate() { List elements = Elements.getElements( new SimpleModule(foo, pFoo, pclFoo, clFoo, cFoo), new SimpleModule(foo, pFoo, pclFoo, clFoo, cFoo) ); assertEquals(14, elements.size()); assertEquals(7, new LinkedHashSet(elements).size()); } public void testProviderMethodsFailIfInstancesDiffer() { try { Guice.createInjector(new FailingProviderModule(), new FailingProviderModule()); fail("should have failed"); } catch(CreationException ce) { assertContains(ce.getMessage(), "A binding to " + Foo.class.getName() + " was already configured at " + FailingProviderModule.class.getName(), "at " + FailingProviderModule.class.getName() ); } } public void testSameScopeInstanceIgnored() { Guice.createInjector( new ScopedModule(Scopes.SINGLETON, foo, pFoo, pclFoo, clFoo, cFoo), new ScopedModule(Scopes.SINGLETON, foo, pFoo, pclFoo, clFoo, cFoo) ); Guice.createInjector( new ScopedModule(Scopes.NO_SCOPE, foo, pFoo, pclFoo, clFoo, cFoo), new ScopedModule(Scopes.NO_SCOPE, foo, pFoo, pclFoo, clFoo, cFoo) ); } public void testSameScopeAnnotationIgnored() { Guice.createInjector( new AnnotatedScopeModule(Singleton.class, foo, pFoo, pclFoo, clFoo, cFoo), new AnnotatedScopeModule(Singleton.class, foo, pFoo, pclFoo, clFoo, cFoo) ); } public void testMixedAnnotationAndScopeForSingletonIgnored() { Guice.createInjector( new ScopedModule(Scopes.SINGLETON, foo, pFoo, pclFoo, clFoo, cFoo), new AnnotatedScopeModule(Singleton.class, foo, pFoo, pclFoo, clFoo, cFoo) ); } public void testMixedScopeAndUnscopedIgnored() { Guice.createInjector( new SimpleModule(foo, pFoo, pclFoo, clFoo, cFoo), new ScopedModule(Scopes.NO_SCOPE, foo, pFoo, pclFoo, clFoo, cFoo) ); } public void testMixedScopeFails() { try { Guice.createInjector( new SimpleModule(foo, pFoo, pclFoo, clFoo, cFoo), new ScopedModule(Scopes.SINGLETON, foo, pFoo, pclFoo, clFoo, cFoo) ); fail("expected exception"); } catch(CreationException ce) { assertContains(ce.getMessage(), "A binding to " + Foo.class.getName() + " annotated with " + named("pInstance") + " was already configured at " + SimpleModule.class.getName(), "at " + ScopedModule.class.getName(), "A binding to " + Foo.class.getName() + " annotated with " + named("pKey") + " was already configured at " + SimpleModule.class.getName(), "at " + ScopedModule.class.getName(), "A binding to " + Foo.class.getName() + " annotated with " + named("linkedKey") + " was already configured at " + SimpleModule.class.getName(), "at " + ScopedModule.class.getName(), "A binding to " + FooImpl.class.getName() + " was already configured at " + SimpleModule.class.getName(), "at " + ScopedModule.class.getName(), "A binding to " + Foo.class.getName() + " annotated with " + named("constructor") + " was already configured at " + SimpleModule.class.getName(), "at " + ScopedModule.class.getName()); } } @SuppressWarnings("unchecked") public void testMixedTargetsFails() { try { Guice.createInjector( new SimpleModule(foo, pFoo, pclFoo, clFoo, cFoo), new SimpleModule(new FooImpl(), Providers.of(new FooImpl()), (Class)BarProvider.class, (Class)Bar.class, (Constructor)Bar.cxtor()) ); fail("expected exception"); } catch(CreationException ce) { assertContains(ce.getMessage(), "A binding to " + Foo.class.getName() + " annotated with " + named("pInstance") + " was already configured at " + SimpleModule.class.getName(), "at " + SimpleModule.class.getName(), "A binding to " + Foo.class.getName() + " annotated with " + named("pKey") + " was already configured at " + SimpleModule.class.getName(), "at " + SimpleModule.class.getName(), "A binding to " + Foo.class.getName() + " annotated with " + named("linkedKey") + " was already configured at " + SimpleModule.class.getName(), "at " + SimpleModule.class.getName(), "A binding to " + Foo.class.getName() + " annotated with " + named("constructor") + " was already configured at " + SimpleModule.class.getName(), "at " + SimpleModule.class.getName()); } } public void testExceptionInEqualsThrowsCreationException() { try { Guice.createInjector(new ThrowingModule(), new ThrowingModule()); fail("expected exception"); } catch(CreationException ce) { assertContains(ce.getMessage(), "A binding to " + Foo.class.getName() + " was already configured at " + ThrowingModule.class.getName(), "and an error was thrown while checking duplicate bindings. Error: java.lang.RuntimeException: Boo!", "at " + ThrowingModule.class.getName()); } } public void testChildInjectorDuplicateParentFail() { Injector injector = Guice.createInjector( new SimpleModule(foo, pFoo, pclFoo, clFoo, cFoo) ); try { injector.createChildInjector( new SimpleModule(foo, pFoo, pclFoo, clFoo, cFoo) ); fail("expected exception"); } catch(CreationException ce) { assertContains(ce.getMessage(), "A binding to " + Foo.class.getName() + " annotated with " + named("pInstance") + " was already configured at " + SimpleModule.class.getName(), "at " + SimpleModule.class.getName(), "A binding to " + Foo.class.getName() + " annotated with " + named("pKey") + " was already configured at " + SimpleModule.class.getName(), "at " + SimpleModule.class.getName(), "A binding to " + Foo.class.getName() + " annotated with " + named("linkedKey") + " was already configured at " + SimpleModule.class.getName(), "at " + SimpleModule.class.getName(), "A binding to " + Foo.class.getName() + " annotated with " + named("constructor") + " was already configured at " + SimpleModule.class.getName(), "at " + SimpleModule.class.getName(), "A binding to " + Foo.class.getName() + " annotated with " + named("providerMethod") + " was already configured at " + SimpleProviderModule.class.getName(), "at " + SimpleProviderModule.class.getName() ); } } public void testDuplicatesSolelyInChildIgnored() { Injector injector = Guice.createInjector(); injector.createChildInjector( new SimpleModule(foo, pFoo, pclFoo, clFoo, cFoo), new SimpleModule(foo, pFoo, pclFoo, clFoo, cFoo) ); } public void testDifferentBindingTypesFail() { List elements = Elements.getElements( new FailedModule(foo, pFoo, pclFoo, clFoo, cFoo) ); // Make sure every combination of the elements with another element fails. // This ensures that duplication checks the kind of binding also. for(Element e1 : elements) { for(Element e2: elements) { // if they're the same, this shouldn't fail. try { Guice.createInjector(Elements.getModule(Arrays.asList(e1, e2))); if(e1 != e2) { fail("must fail!"); } } catch(CreationException expected) { if(e1 != e2) { assertContains(expected.getMessage(), "A binding to " + Foo.class.getName() + " was already configured at " + FailedModule.class.getName(), "at " + FailedModule.class.getName()); } else { throw expected; } } } } } public void testJitBindingsAreCheckedAfterConversions() { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(A.class); bind(A.class).to(RealA.class); } }); } public void testEqualsNotCalledByDefaultOnInstance() { final HashEqualsTester a = new HashEqualsTester(); a.throwOnEquals = true; Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(String.class); bind(HashEqualsTester.class).toInstance(a); } }); } public void testEqualsNotCalledByDefaultOnProvider() { final HashEqualsTester a = new HashEqualsTester(); a.throwOnEquals = true; Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(String.class); bind(Object.class).toProvider(a); } }); } public void testHashcodeNeverCalledOnInstance() { final HashEqualsTester a = new HashEqualsTester(); a.throwOnHashcode = true; a.equality = "test"; final HashEqualsTester b = new HashEqualsTester(); b.throwOnHashcode = true; b.equality = "test"; Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(String.class); bind(HashEqualsTester.class).toInstance(a); bind(HashEqualsTester.class).toInstance(b); } }); } public void testHashcodeNeverCalledOnProviderInstance() { final HashEqualsTester a = new HashEqualsTester(); a.throwOnHashcode = true; a.equality = "test"; final HashEqualsTester b = new HashEqualsTester(); b.throwOnHashcode = true; b.equality = "test"; Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(String.class); bind(Object.class).toProvider(a); bind(Object.class).toProvider(b); } }); } private static class RealA extends A {} @ImplementedBy(RealA.class) private static class A {} private void removeBasicBindings(Collection> bindings) { bindings.remove(Key.get(Injector.class)); bindings.remove(Key.get(Logger.class)); bindings.remove(Key.get(Stage.class)); } private static class ThrowingModule extends AbstractModule { @Override protected void configure() { bind(Foo.class).toInstance(new Foo() { @Override public boolean equals(Object obj) { throw new RuntimeException("Boo!"); } }); } } private static abstract class FooModule extends AbstractModule { protected final FooImpl foo; protected final Provider pFoo; protected final Class> pclFoo; protected final Class clFoo; protected final Constructor cFoo; FooModule(FooImpl foo, Provider pFoo, Class> pclFoo, Class clFoo, Constructor cFoo) { this.foo = foo; this.pFoo = pFoo; this.pclFoo = pclFoo; this.clFoo = clFoo; this.cFoo = cFoo; } } private static class FailedModule extends FooModule { FailedModule(FooImpl foo, Provider pFoo, Class> pclFoo, Class clFoo, Constructor cFoo) { super(foo, pFoo, pclFoo, clFoo, cFoo); } protected void configure() { // InstanceBinding bind(Foo.class).toInstance(foo); // ProviderInstanceBinding bind(Foo.class).toProvider(pFoo); // ProviderKeyBinding bind(Foo.class).toProvider(pclFoo); // LinkedKeyBinding bind(Foo.class).to(clFoo); // ConstructorBinding bind(Foo.class).toConstructor(cFoo); } @Provides Foo foo() { return null; } } private static class FailingProviderModule extends AbstractModule { @Override protected void configure() {} @Provides Foo foo() { return null; } } private static class SimpleProviderModule extends AbstractModule { @Override protected void configure() {} @Provides @Named("providerMethod") Foo foo() { return null; } @Override public boolean equals(Object obj) { return obj.getClass() == getClass(); } } private static class SimpleModule extends FooModule { SimpleModule(FooImpl foo, Provider pFoo, Class> pclFoo, Class clFoo, Constructor cFoo) { super(foo, pFoo, pclFoo, clFoo, cFoo); } protected void configure() { // InstanceBinding bind(Foo.class).annotatedWith(named("instance")).toInstance(foo); // ProviderInstanceBinding bind(Foo.class).annotatedWith(named("pInstance")).toProvider(pFoo); // ProviderKeyBinding bind(Foo.class).annotatedWith(named("pKey")).toProvider(pclFoo); // LinkedKeyBinding bind(Foo.class).annotatedWith(named("linkedKey")).to(clFoo); // UntargettedBinding / ConstructorBinding bind(FooImpl.class); // ConstructorBinding bind(Foo.class).annotatedWith(named("constructor")).toConstructor(cFoo); // ProviderMethod // (reconstructed from an Element to ensure it doesn't get filtered out // by deduplicating Modules) install(Elements.getModule(Elements.getElements(new SimpleProviderModule()))); } } private static class ScopedModule extends FooModule { private final Scope scope; ScopedModule(Scope scope, FooImpl foo, Provider pFoo, Class> pclFoo, Class clFoo, Constructor cFoo) { super(foo, pFoo, pclFoo, clFoo, cFoo); this.scope = scope; } protected void configure() { // ProviderInstanceBinding bind(Foo.class).annotatedWith(named("pInstance")).toProvider(pFoo).in(scope); // ProviderKeyBinding bind(Foo.class).annotatedWith(named("pKey")).toProvider(pclFoo).in(scope); // LinkedKeyBinding bind(Foo.class).annotatedWith(named("linkedKey")).to(clFoo).in(scope); // UntargettedBinding / ConstructorBinding bind(FooImpl.class).in(scope); // ConstructorBinding bind(Foo.class).annotatedWith(named("constructor")).toConstructor(cFoo).in(scope); } } private static class AnnotatedScopeModule extends FooModule { private final Class scope; AnnotatedScopeModule(Class scope, FooImpl foo, Provider pFoo, Class> pclFoo, Class clFoo, Constructor cFoo) { super(foo, pFoo, pclFoo, clFoo, cFoo); this.scope = scope; } protected void configure() { // ProviderInstanceBinding bind(Foo.class).annotatedWith(named("pInstance")).toProvider(pFoo).in(scope); // ProviderKeyBinding bind(Foo.class).annotatedWith(named("pKey")).toProvider(pclFoo).in(scope); // LinkedKeyBinding bind(Foo.class).annotatedWith(named("linkedKey")).to(clFoo).in(scope); // UntargettedBinding / ConstructorBinding bind(FooImpl.class).in(scope); // ConstructorBinding bind(Foo.class).annotatedWith(named("constructor")).toConstructor(cFoo).in(scope); } } private static interface Foo {} private static class FooImpl implements Foo { @Inject public FooImpl() {} private static Constructor cxtor() { try { return FooImpl.class.getConstructor(); } catch (SecurityException e) { throw new RuntimeException(e); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } } } private static class FooProvider implements Provider { public Foo get() { return new FooImpl(); } } private static class Bar implements Foo { @Inject public Bar() {} private static Constructor cxtor() { try { return Bar.class.getConstructor(); } catch (SecurityException e) { throw new RuntimeException(e); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } } } private static class BarProvider implements Provider { public Foo get() { return new Bar(); } } private static class HashEqualsTester implements Provider { private String equality; private boolean throwOnEquals; private boolean throwOnHashcode; @Override public boolean equals(Object obj) { if (throwOnEquals) { throw new RuntimeException(); } else if (obj instanceof HashEqualsTester) { HashEqualsTester o = (HashEqualsTester)obj; if(o.throwOnEquals) { throw new RuntimeException(); } if(equality == null && o.equality == null) { return this == o; } else { return Objects.equal(equality, o.equality); } } else { return false; } } @Override public int hashCode() { if(throwOnHashcode) { throw new RuntimeException(); } else { return super.hashCode(); } } public Object get() { return new Object(); } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/CircularDependencyTest.java0000644000175000017500000004123611704661106027103 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import junit.framework.TestCase; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * @author crazybob@google.com (Bob Lee) * @author sameb@google.com (Sam Berlin) */ public class CircularDependencyTest extends TestCase { @Override protected void setUp() throws Exception { AImpl.nextId = 0; BImpl.nextId = 0; } public void testCircularlyDependentConstructors() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(A.class).to(AImpl.class); bind(B.class).to(BImpl.class); } }); assertCircularDependencies(injector); } public void testCircularlyDependentConstructorsWithProviderMethods() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() {} @Provides @Singleton A a(B b) { return new AImpl(b); } @Provides B b(A a) { return new BImpl(a); } }); assertCircularDependencies(injector); } public void testCircularlyDependentConstructorsWithProviderInstances() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(A.class).toProvider(new Provider() { @Inject Provider bp; public A get() { return new AImpl(bp.get()); } }).in(Singleton.class); bind(B.class).toProvider(new Provider() { @Inject Provider ap; public B get() { return new BImpl(ap.get()); } }); } }); assertCircularDependencies(injector); } public void testCircularlyDependentConstructorsWithProviderKeys() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(A.class).toProvider(AP.class).in(Singleton.class); bind(B.class).toProvider(BP.class); } }); assertCircularDependencies(injector); } public void testCircularlyDependentConstructorsWithProvidedBy() throws CreationException { Injector injector = Guice.createInjector(); assertCircularDependencies(injector); } private void assertCircularDependencies(Injector injector) { A a = injector.getInstance(A.class); assertNotNull(a.getB().getA()); assertEquals(0, a.id()); assertEquals(a.id(), a.getB().getA().id()); assertEquals(0, a.getB().id()); assertEquals(1, AImpl.nextId); assertEquals(1, BImpl.nextId); assertSame(a, injector.getInstance(A.class)); } @ProvidedBy(AutoAP.class) public interface A { B getB(); int id(); } @Singleton static class AImpl implements A { static int nextId; int id = nextId++; final B b; @Inject public AImpl(B b) { this.b = b; } public int id() { return id; } public B getB() { return b; } } static class AP implements Provider { @Inject Provider bp; public A get() { return new AImpl(bp.get()); } } @Singleton static class AutoAP implements Provider { @Inject Provider bp; A a; public A get() { if (a == null) { a = new AImpl(bp.get()); } return a; } } @ProvidedBy(BP.class) public interface B { A getA(); int id(); } static class BImpl implements B { static int nextId; int id = nextId++; final A a; @Inject public BImpl(A a) { this.a = a; } public int id() { return id; } public A getA() { return a; } } static class BP implements Provider { Provider ap; @Inject BP(Provider ap) { this.ap = ap; } public B get() { return new BImpl(ap.get()); } } public void testUnresolvableCircularDependency() { try { Guice.createInjector().getInstance(C.class); fail(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "Tried proxying " + C.class.getName() + " to support a circular dependency, ", "but it is not an interface."); } } public void testUnresolvableCircularDependenciesWithProviderInstances() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() {} @Provides C c(D d) { return null; } @Provides D d(C c) { return null; } }).getInstance(C.class); fail(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "Tried proxying " + C.class.getName() + " to support a circular dependency, ", "but it is not an interface."); } } public void testUnresolvableCircularDependenciesWithProviderKeys() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(C2.class).toProvider(C2P.class); bind(D2.class).toProvider(D2P.class); } }).getInstance(C2.class); fail(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "Tried proxying " + C2.class.getName() + " to support a circular dependency, ", "but it is not an interface."); } } public void testUnresolvableCircularDependenciesWithProvidedBy() { try { Guice.createInjector().getInstance(C2.class); fail(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "Tried proxying " + C2.class.getName() + " to support a circular dependency, ", "but it is not an interface."); } } static class C { @Inject C(D d) {} } static class D { @Inject D(C c) {} } static class C2P implements Provider { @Inject Provider dp; public C2 get() { dp.get(); return null; } } static class D2P implements Provider { @Inject Provider cp; public D2 get() { cp.get(); return null; } } @ProvidedBy(C2P.class) static class C2 { @Inject C2(D2 d) {} } @ProvidedBy(D2P.class) static class D2 { @Inject D2(C2 c) {} } public void testDisabledCircularDependency() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().disableCircularProxies(); } }).getInstance(C.class); fail(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "Tried proxying " + C.class.getName() + " to support a circular dependency, ", "but circular proxies are disabled."); } } public void testDisabledCircularDependenciesWithProviderInstances() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().disableCircularProxies(); } @Provides C c(D d) { return null; } @Provides D d(C c) { return null; } }).getInstance(C.class); fail(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "Tried proxying " + C.class.getName() + " to support a circular dependency, ", "but circular proxies are disabled."); } } public void testDisabledCircularDependenciesWithProviderKeys() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().disableCircularProxies(); bind(C2.class).toProvider(C2P.class); bind(D2.class).toProvider(D2P.class); } }).getInstance(C2.class); fail(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "Tried proxying " + C2.class.getName() + " to support a circular dependency, ", "but circular proxies are disabled."); } } public void testDisabledCircularDependenciesWithProvidedBy() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().disableCircularProxies(); } }).getInstance(C2.class); fail(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "Tried proxying " + C2.class.getName() + " to support a circular dependency, ", "but circular proxies are disabled."); } } /** * As reported by issue 349, we give a lousy trace when a class is circularly * dependent on itself in multiple ways. */ public void testCircularlyDependentMultipleWays() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { binder.bind(A.class).to(E.class); binder.bind(B.class).to(E.class); } }); injector.getInstance(A.class); } public void testDisablingCircularProxies() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { binder().disableCircularProxies(); binder.bind(A.class).to(E.class); binder.bind(B.class).to(E.class); } }); try { injector.getInstance(A.class); fail("expected exception"); } catch(ProvisionException expected) { assertContains(expected.getMessage(), "Tried proxying " + A.class.getName() + " to support a circular dependency, but circular proxies are disabled", "Tried proxying " + B.class.getName() + " to support a circular dependency, but circular proxies are disabled"); } } @Singleton static class E implements A, B { @Inject public E(A a, B b) {} public B getB() { return this; } public A getA() { return this; } public int id() { return 0; } } public void testCircularDependencyProxyDelegateNeverInitialized() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(F.class).to(RealF.class); bind(G.class).to(RealG.class); } }); F f = injector.getInstance(F.class); assertEquals("F", f.g().f().toString()); assertEquals("G", f.g().f().g().toString()); } public interface F { G g(); } @Singleton public static class RealF implements F { private final G g; @Inject RealF(G g) { this.g = g; } public G g() { return g; } @Override public String toString() { return "F"; } } public interface G { F f(); } @Singleton public static class RealG implements G { private final F f; @Inject RealG(F f) { this.f = f; } public F f() { return f; } @Override public String toString() { return "G"; } } /** * Tests that ProviderInternalFactory can detect circular dependencies * before it gets to Scopes.SINGLETON. This is especially important * because the failure in Scopes.SINGLETON doesn't have enough context to * provide a decent error message. */ public void testCircularDependenciesDetectedEarlyWhenDependenciesHaveDifferentTypes() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(Number.class).to(Integer.class); } @Provides @Singleton Integer provideInteger(List list) { return new Integer(2); } @Provides List provideList(Integer integer) { return new ArrayList(); } }); try { injector.getInstance(Number.class); fail(); } catch(ProvisionException expected) { assertContains(expected.getMessage(), "Tried proxying " + Integer.class.getName() + " to support a circular dependency, ", "but it is not an interface."); } } public void testPrivateModulesDontTriggerCircularErrorsInProviders() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { install(new PrivateModule() { @Override protected void configure() { bind(Foo.class); expose(Foo.class); } @Provides String provideString(Bar bar) { return new String("private 1, " + bar.string); } }); install(new PrivateModule() { @Override protected void configure() { bind(Bar.class); expose(Bar.class); } @Provides String provideString() { return new String("private 2"); } }); } }); Foo foo = injector.getInstance(Foo.class); assertEquals("private 1, private 2", foo.string); } static class Foo { @Inject String string; } static class Bar { @Inject String string; } /** * When Scope Providers call their unscoped Provider's get() methods are * called, it's possible that the result is a circular proxy designed for one * specific parameter (not for all possible parameters). But custom scopes * typically cache the results without checking to see if the result is a * proxy. This leads to caching a result that is unsuitable for reuse for * other parameters. * * This means that custom proxies have to do an * {@code if(Scopes.isCircularProxy(..))} * in order to avoid exceptions. */ public void testCustomScopeCircularProxies() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindScope(SimpleSingleton.class, new BasicSingleton()); bind(H.class).to(HImpl.class); bind(I.class).to(IImpl.class); bind(J.class).to(JImpl.class); } }); // The reason this happens is because the Scope gets these requests, in order: // entry: Key (1 - from getInstance call) // entry: Key // entry: Key (2 - circular dependency from HImpl) // result of 2nd Key - a com.google.inject.$Proxy, because it's a circular proxy // result of Key - an HImpl // entry: Key // entry: Key (3 - another circular dependency, this time from JImpl) // At this point, if the first Key result was cached, our cache would have // Key caching to an instanceof of I, but not an an instanceof of IImpl. // If returned this, it would result in cglib giving a ClassCastException or // java reflection giving an IllegalArgumentException when filling in parameters // for the constructor, because JImpl wants an IImpl, not an I. try { injector.getInstance(IImpl.class); fail(); } catch(ProvisionException pe) { assertContains(Iterables.getOnlyElement(pe.getErrorMessages()).getMessage(), "Tried proxying " + IImpl.class.getName() + " to support a circular dependency, but it is not an interface."); } } interface H {} interface I {} interface J {} @SimpleSingleton static class HImpl implements H { @Inject HImpl(I i) {} } @SimpleSingleton static class IImpl implements I { @Inject IImpl(HImpl i, J j) {} } @SimpleSingleton static class JImpl implements J { @Inject JImpl(IImpl i) {} } @Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RUNTIME) @ScopeAnnotation public @interface SimpleSingleton {} public static class BasicSingleton implements Scope { private static Map cache = Maps.newHashMap(); public Provider scope(final Key key, final Provider unscoped) { return new Provider() { @SuppressWarnings("unchecked") public T get() { if (!cache.containsKey(key)) { T t = unscoped.get(); if (Scopes.isCircularProxy(t)) { return t; } cache.put(key, t); } return (T)cache.get(key); } }; } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/BoundProviderTest.java0000644000175000017500000000452211704661106026117 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import junit.framework.TestCase; /** * @author crazybob@google.com (Bob Lee) */ public class BoundProviderTest extends TestCase { public void testFooProvider() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Foo.class).toProvider(FooProvider.class); } }); Foo a = injector.getInstance(Foo.class); Foo b = injector.getInstance(Foo.class); assertEquals(0, a.i); assertEquals(0, b.i); assertNotNull(a.bar); assertNotNull(b.bar); assertNotSame(a.bar, b.bar); } public void testSingletonFooProvider() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Foo.class).toProvider(SingletonFooProvider.class); } }); Foo a = injector.getInstance(Foo.class); Foo b = injector.getInstance(Foo.class); assertEquals(0, a.i); assertEquals(1, b.i); assertNotNull(a.bar); assertNotNull(b.bar); assertSame(a.bar, b.bar); } static class Bar {} static class Foo { final Bar bar; final int i; Foo(Bar bar, int i) { this.bar = bar; this.i = i; } } static class FooProvider implements Provider { final Bar bar; int count = 0; @Inject public FooProvider(Bar bar) { this.bar = bar; } public Foo get() { return new Foo(this.bar, count++); } } @Singleton static class SingletonFooProvider implements Provider { final Bar bar; int count = 0; @Inject public SingletonFooProvider(Bar bar) { this.bar = bar; } public Foo get() { return new Foo(this.bar, count++); } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/BoundInstanceInjectionTest.java0000644000175000017500000000675611704661106027747 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.PARAMETER; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.name.Named; import junit.framework.TestCase; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * @author crazybob@google.com (Bob Lee) */ public class BoundInstanceInjectionTest extends TestCase { public void testInstancesAreInjected() throws CreationException { final O o = new O(); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(O.class).toInstance(o); bind(int.class).toInstance(5); } }); assertEquals(5, o.fromMethod); } static class O { int fromMethod; @Inject void setInt(int i) { this.fromMethod = i; } } public void testProvidersAreInjected() throws CreationException { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(O.class).toProvider(new Provider() { @Inject int i; public O get() { O o = new O(); o.setInt(i); return o; } }); bind(int.class).toInstance(5); } }); assertEquals(5, injector.getInstance(O.class).fromMethod); } public void testMalformedInstance() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(Object.class).toInstance(new MalformedInjectable()); } }); fail(); } catch (CreationException expected) { Asserts.assertContains(expected.getMessage(), MalformedInjectable.class.getName(), ".doublyAnnotated() has more than one ", "annotation annotated with @BindingAnnotation: ", Named.class.getName() + " and " + Another.class.getName()); } } public void testMalformedProvider() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(String.class).toProvider(new MalformedProvider()); } }); fail(); } catch (CreationException expected) { Asserts.assertContains(expected.getMessage(), MalformedProvider.class.getName(), ".doublyAnnotated() has more than one ", "annotation annotated with @BindingAnnotation: ", Named.class.getName() + " and " + Another.class.getName()); } } static class MalformedInjectable { @Inject void doublyAnnotated(@Named("a") @Another String unused) {} } static class MalformedProvider implements Provider { @Inject void doublyAnnotated(@Named("a") @Another String s) {} public String get() { return "a"; } } @BindingAnnotation @Target({ FIELD, PARAMETER, METHOD }) @Retention(RUNTIME) public @interface Another {} } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/BindingTest.java0000644000175000017500000003734611704661106024721 0ustar tonytony/* * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static com.google.inject.name.Names.named; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.inject.matcher.Matchers; import com.google.inject.spi.InjectionPoint; import com.google.inject.spi.TypeEncounter; import com.google.inject.spi.TypeListener; import junit.framework.TestCase; /*if[AOP]*/ import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; /*end[AOP]*/ import java.lang.reflect.Constructor; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Logger; /** * @author crazybob@google.com (Bob Lee) */ public class BindingTest extends TestCase { static class Dependent { @Inject A a; @Inject Dependent(A a, B b) {} @Inject void injectBob(Bob bob) {} } public void testExplicitCyclicDependency() { Guice.createInjector(new AbstractModule() { protected void configure() { bind(A.class); bind(B.class); } }).getInstance(A.class); } static class A { @Inject B b; } static class B { @Inject A a; } static class Bob {} static class MyModule extends AbstractModule { protected void configure() { // Linked. bind(Object.class).to(Runnable.class).in(Scopes.SINGLETON); // Instance. bind(Runnable.class).toInstance(new Runnable() { public void run() {} }); // Provider instance. bind(Foo.class).toProvider(new Provider() { public Foo get() { return new Foo(); } }).in(Scopes.SINGLETON); // Provider. bind(Foo.class) .annotatedWith(named("provider")) .toProvider(FooProvider.class); // Class. bind(Bar.class).in(Scopes.SINGLETON); // Constant. bindConstant().annotatedWith(named("name")).to("Bob"); } } static class Foo {} public static class FooProvider implements Provider { public Foo get() { throw new UnsupportedOperationException(); } } public static class Bar {} public void testBindToUnboundLinkedBinding() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(Collection.class).to(List.class); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "No implementation for java.util.List was bound."); } } /** * This test ensures that the asEagerSingleton() scoping applies to the key, * not to what the key is linked to. */ public void testScopeIsAppliedToKeyNotTarget() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Integer.class).toProvider(Counter.class).asEagerSingleton(); bind(Number.class).toProvider(Counter.class).asEagerSingleton(); } }); assertNotSame(injector.getInstance(Integer.class), injector.getInstance(Number.class)); } static class Counter implements Provider { static AtomicInteger next = new AtomicInteger(1); public Integer get() { return next.getAndIncrement(); } } public void testAnnotatedNoArgConstructor() { assertBindingSucceeds(PublicNoArgAnnotated.class); assertBindingSucceeds(ProtectedNoArgAnnotated.class); assertBindingSucceeds(PackagePrivateNoArgAnnotated.class); assertBindingSucceeds(PrivateNoArgAnnotated.class); } static class PublicNoArgAnnotated { @Inject public PublicNoArgAnnotated() { } } static class ProtectedNoArgAnnotated { @Inject protected ProtectedNoArgAnnotated() { } } static class PackagePrivateNoArgAnnotated { @Inject PackagePrivateNoArgAnnotated() { } } static class PrivateNoArgAnnotated { @Inject private PrivateNoArgAnnotated() { } } public void testUnannotatedNoArgConstructor() throws Exception{ assertBindingSucceeds(PublicNoArg.class); assertBindingSucceeds(ProtectedNoArg.class); assertBindingSucceeds(PackagePrivateNoArg.class); assertBindingSucceeds(PrivateNoArgInPrivateClass.class); assertBindingFails(PrivateNoArg.class); } static class PublicNoArg { public PublicNoArg() { } } static class ProtectedNoArg { protected ProtectedNoArg() { } } static class PackagePrivateNoArg { PackagePrivateNoArg() { } } private static class PrivateNoArgInPrivateClass { PrivateNoArgInPrivateClass() { } } static class PrivateNoArg { private PrivateNoArg() { } } private void assertBindingSucceeds(final Class clazz) { assertNotNull(Guice.createInjector().getInstance(clazz)); } private void assertBindingFails(final Class clazz) throws NoSuchMethodException { try { Guice.createInjector().getInstance(clazz); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "Could not find a suitable constructor in " + PrivateNoArg.class.getName(), "at " + PrivateNoArg.class.getName() + ".class(BindingTest.java:"); } } public void testTooManyConstructors() { try { Guice.createInjector().getInstance(TooManyConstructors.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), TooManyConstructors.class.getName() + " has more than one constructor annotated with " + "@Inject. Classes must have either one (and only one) constructor", "at " + TooManyConstructors.class.getName() + ".class(BindingTest.java:"); } } static class TooManyConstructors { @Inject TooManyConstructors(Injector i) {} @Inject TooManyConstructors() {} } public void testToConstructorBinding() throws NoSuchMethodException { final Constructor constructor = D.class.getConstructor(Stage.class); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Object.class).toConstructor(constructor); } }); D d = (D) injector.getInstance(Object.class); assertEquals(Stage.DEVELOPMENT, d.stage); } public void testToConstructorBindingsOnParameterizedTypes() throws NoSuchMethodException { final Constructor constructor = C.class.getConstructor(Stage.class, Object.class); final Key s = new Key(named("s")) {}; final Key i = new Key(named("i")) {}; Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(s).toConstructor(constructor, new TypeLiteral>() {}); bind(i).toConstructor(constructor, new TypeLiteral>() {}); } }); C one = (C) injector.getInstance(s); assertEquals(Stage.DEVELOPMENT, one.stage); assertEquals(Stage.DEVELOPMENT, one.t); assertEquals(Stage.DEVELOPMENT, one.anotherT); C two = (C) injector.getInstance(i); assertEquals(Stage.DEVELOPMENT, two.stage); assertEquals(injector, two.t); assertEquals(injector, two.anotherT); } public void testToConstructorBindingsFailsOnRawTypes() throws NoSuchMethodException { final Constructor constructor = C.class.getConstructor(Stage.class, Object.class); try { Guice.createInjector(new AbstractModule() { protected void configure() { bind(Object.class).toConstructor(constructor); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) T cannot be used as a key; It is not fully specified.", "at " + C.class.getName() + ".(BindingTest.java:", "2) T cannot be used as a key; It is not fully specified.", "at " + C.class.getName() + ".anotherT(BindingTest.java:"); } } /*if[AOP]*/ public void testToConstructorAndMethodInterceptors() throws NoSuchMethodException { final Constructor constructor = D.class.getConstructor(Stage.class); final AtomicInteger count = new AtomicInteger(); final MethodInterceptor countingInterceptor = new MethodInterceptor() { public Object invoke(MethodInvocation methodInvocation) throws Throwable { count.incrementAndGet(); return methodInvocation.proceed(); } }; Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(Object.class).toConstructor(constructor); bindInterceptor(Matchers.any(), Matchers.any(), countingInterceptor); } }); D d = (D) injector.getInstance(Object.class); d.hashCode(); d.hashCode(); assertEquals(2, count.get()); } /*end[AOP]*/ public void testInaccessibleConstructor() throws NoSuchMethodException { final Constructor constructor = E.class.getDeclaredConstructor(Stage.class); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(E.class).toConstructor(constructor); } }); E e = injector.getInstance(E.class); assertEquals(Stage.DEVELOPMENT, e.stage); } public void testToConstructorAndScopes() throws NoSuchMethodException { final Constructor constructor = F.class.getConstructor(Stage.class); final Key d = Key.get(Object.class, named("D")); // default scoping final Key s = Key.get(Object.class, named("S")); // singleton final Key n = Key.get(Object.class, named("N")); // "N" instances final Key r = Key.get(Object.class, named("R")); // a regular binding Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(d).toConstructor(constructor); bind(s).toConstructor(constructor).in(Singleton.class); bind(n).toConstructor(constructor).in(Scopes.NO_SCOPE); bind(r).to(F.class); } }); assertDistinct(injector, 1, d, d, d, d); assertDistinct(injector, 1, s, s, s, s); assertDistinct(injector, 4, n, n, n, n); assertDistinct(injector, 1, r, r, r, r); assertDistinct(injector, 4, d, d, r, r, s, s, n); } public void assertDistinct(Injector injector, int expectedCount, Key... keys) { ImmutableSet.Builder builder = ImmutableSet.builder(); for (Key k : keys) { builder.add(injector.getInstance(k)); } assertEquals(expectedCount, builder.build().size()); } public void testToConstructorSpiData() throws NoSuchMethodException { final Set> heardTypes = Sets.newHashSet(); final Constructor constructor = D.class.getConstructor(Stage.class); final TypeListener listener = new TypeListener() { public void hear(TypeLiteral type, TypeEncounter encounter) { if (!heardTypes.add(type)) { fail("Heard " + type + " multiple times!"); } } }; Guice.createInjector(new AbstractModule() { protected void configure() { bind(Object.class).toConstructor(constructor); bind(D.class).toConstructor(constructor); bindListener(Matchers.any(), listener); } }); assertEquals(ImmutableSet.of(TypeLiteral.get(Stage.class), TypeLiteral.get(D.class)), heardTypes); } public void testInterfaceToImplementationConstructor() throws NoSuchMethodException { final Constructor constructor = CFoo.class.getDeclaredConstructor(); Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(IFoo.class).toConstructor(constructor); } }); injector.getInstance(IFoo.class); } public static interface IFoo {} public static class CFoo implements IFoo {} public void testGetAllBindings() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(D.class).toInstance(new D(Stage.PRODUCTION)); bind(Object.class).to(D.class); getProvider(new Key>() {}); } }); Map,Binding> bindings = injector.getAllBindings(); assertEquals(ImmutableSet.of(Key.get(Injector.class), Key.get(Stage.class), Key.get(D.class), Key.get(Logger.class), Key.get(Object.class), new Key>() {}), bindings.keySet()); // add a JIT binding injector.getInstance(F.class); Map,Binding> bindings2 = injector.getAllBindings(); assertEquals(ImmutableSet.of(Key.get(Injector.class), Key.get(Stage.class), Key.get(D.class), Key.get(Logger.class), Key.get(Object.class), new Key>() {}, Key.get(F.class)), bindings2.keySet()); // the original map shouldn't have changed assertEquals(ImmutableSet.of(Key.get(Injector.class), Key.get(Stage.class), Key.get(D.class), Key.get(Logger.class), Key.get(Object.class), new Key>() {}), bindings.keySet()); // check the bindings' values assertEquals(injector, bindings.get(Key.get(Injector.class)).getProvider().get()); } public void testGetAllServletBindings() throws Exception { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(F.class); // an explicit binding that uses a JIT binding for a constructor } }); injector.getAllBindings(); } public static class C { private Stage stage; private T t; @Inject T anotherT; public C(Stage stage, T t) { this.stage = stage; this.t = t; } @Inject C() {} } public static class D { Stage stage; public D(Stage stage) { this.stage = stage; } } private static class E { Stage stage; private E(Stage stage) { this.stage = stage; } } @Singleton public static class F { Stage stage; @Inject public F(Stage stage) { this.stage = stage; } } public void testTurkeyBaconProblemUsingToConstuctor() { Injector injector = Guice.createInjector(new AbstractModule() { @SuppressWarnings("unchecked") @Override public void configure() { bind(Bacon.class).to(UncookedBacon.class); bind(Bacon.class).annotatedWith(named("Turkey")).to(TurkeyBacon.class); bind(Bacon.class).annotatedWith(named("Cooked")).toConstructor( (Constructor)InjectionPoint.forConstructorOf(Bacon.class).getMember()); } }); Bacon bacon = injector.getInstance(Bacon.class); assertEquals(Food.PORK, bacon.getMaterial()); assertFalse(bacon.isCooked()); Bacon turkeyBacon = injector.getInstance(Key.get(Bacon.class, named("Turkey"))); assertEquals(Food.TURKEY, turkeyBacon.getMaterial()); assertTrue(turkeyBacon.isCooked()); Bacon cookedBacon = injector.getInstance(Key.get(Bacon.class, named("Cooked"))); assertEquals(Food.PORK, cookedBacon.getMaterial()); assertTrue(cookedBacon.isCooked()); } enum Food { TURKEY, PORK } private static class Bacon { public Food getMaterial() { return Food.PORK; } public boolean isCooked() { return true; } } private static class TurkeyBacon extends Bacon { public Food getMaterial() { return Food.TURKEY; } } private static class UncookedBacon extends Bacon { public boolean isCooked() { return false; } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/BindingOrderTest.java0000644000175000017500000000525211704661106025704 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import junit.framework.TestCase; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicReference; /** * @author jessewilson@google.com (Jesse Wilson) */ public class BindingOrderTest extends TestCase { public void testBindingOutOfOrder() { Guice.createInjector(new AbstractModule() { protected void configure() { bind(BoundFirst.class); bind(BoundSecond.class).to(BoundSecondImpl.class); } }); } public static class BoundFirst { @Inject public BoundFirst(BoundSecond boundSecond) { } } interface BoundSecond { } static class BoundSecondImpl implements BoundSecond { } public void testBindingOrderAndScopes() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(A.class); bind(B.class).asEagerSingleton(); } }); assertSame(injector.getInstance(A.class).b, injector.getInstance(A.class).b); } public void testBindingWithExtraThreads() throws InterruptedException { final CountDownLatch ready = new CountDownLatch(1); final CountDownLatch done = new CountDownLatch(1); final AtomicReference ref = new AtomicReference(); final Object createsAThread = new Object() { @Inject void createAnotherThread(final Injector injector) { new Thread() { public void run() { ready.countDown(); A a = injector.getInstance(A.class); ref.set(a.b); done.countDown(); } }.start(); // to encourage collisions, we make sure the other thread is running before returning try { ready.await(); } catch (InterruptedException e) { throw new RuntimeException(e); } } }; Guice.createInjector(new AbstractModule() { protected void configure() { requestInjection(createsAThread); bind(A.class).toInstance(new A()); } }); done.await(); assertNotNull(ref.get()); } static class A { @Inject B b; } static class B { } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/BindingAnnotationTest.java0000644000175000017500000000503011704661106026735 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static java.lang.annotation.RetentionPolicy.RUNTIME; import junit.framework.TestCase; import java.lang.annotation.Annotation; import java.lang.annotation.Retention; /** * @author crazybob@google.com (Bob Lee) */ public class BindingAnnotationTest extends TestCase { public void testAnnotationWithValueMatchesKeyWithTypeOnly() throws CreationException { Injector c = Guice.createInjector(new AbstractModule() { protected void configure() { bindConstant().annotatedWith(Blue.class).to("foo"); bind(Foo.class); } }); Foo foo = c.getInstance(Foo.class); assertEquals("foo", foo.s); } public void testAnnotationWithValueThatDoesntMatch() { try { Guice.createInjector(new AbstractModule() { protected void configure() { bindConstant().annotatedWith(createBlue(6)).to("six"); bind(String.class).toInstance("bar"); bind(Foo.class); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "No implementation for java.lang.String annotated with", "BindingAnnotationTest$Blue(value=5) was bound", "at " + BindingAnnotationTest.class.getName(), ".configure(BindingAnnotationTest.java:"); } } static class Foo { @Inject @Blue(5) String s; } @Retention(RUNTIME) @BindingAnnotation @interface Blue { int value(); } public Blue createBlue(final int value) { return new Blue() { public int value() { return value; } public Class annotationType() { return Blue.class; } @Override public boolean equals(Object o) { return o instanceof Blue && ((Blue) o).value() == value; } @Override public int hashCode() { return 127 * "value".hashCode() ^ value; } }; } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/BinderTestSuite.java0000644000175000017500000005705011704661106025556 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static com.google.inject.name.Names.named; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.inject.binder.AnnotatedBindingBuilder; import com.google.inject.binder.ScopedBindingBuilder; import com.google.inject.name.Named; import com.google.inject.util.Providers; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import java.lang.annotation.Retention; import java.lang.annotation.Target; import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; /** * @author jessewilson@google.com (Jesse Wilson) */ public class BinderTestSuite extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(); new Builder() .name("bind A") .module(new AbstractModule() { protected void configure() { bind(A.class); } }) .creationException("No implementation for %s was bound", A.class.getName()) .addToSuite(suite); new Builder() .name("bind PlainA named apple") .module(new AbstractModule() { protected void configure() { bind(PlainA.class).annotatedWith(named("apple")); } }) .creationException("No implementation for %s annotated with %s was bound", PlainA.class.getName(), named("apple")) .addToSuite(suite); new Builder() .name("bind A to new PlainA(1)") .module(new AbstractModule() { protected void configure() { bind(A.class).toInstance(new PlainA(1)); } }) .creationTime(CreationTime.NONE) .expectedValues(new PlainA(1), new PlainA(1), new PlainA(1)) .addToSuite(suite); new Builder() .name("no binding, AWithProvidedBy") .key(Key.get(AWithProvidedBy.class), InjectsAWithProvidedBy.class) .addToSuite(suite); new Builder() .name("no binding, AWithImplementedBy") .key(Key.get(AWithImplementedBy.class), InjectsAWithImplementedBy.class) .addToSuite(suite); new Builder() .name("no binding, ScopedA") .key(Key.get(ScopedA.class), InjectsScopedA.class) .expectedValues(new PlainA(201), new PlainA(201), new PlainA(202), new PlainA(202)) .addToSuite(suite); new Builder() .name("no binding, AWithProvidedBy named apple") .key(Key.get(AWithProvidedBy.class, named("apple")), InjectsAWithProvidedByNamedApple.class) .configurationException("No implementation for %s annotated with %s was bound", AWithProvidedBy.class.getName(), named("apple")) .addToSuite(suite); new Builder() .name("no binding, AWithImplementedBy named apple") .key(Key.get(AWithImplementedBy.class, named("apple")), InjectsAWithImplementedByNamedApple.class) .configurationException("No implementation for %s annotated with %s was bound", AWithImplementedBy.class.getName(), named("apple")) .addToSuite(suite); new Builder() .name("no binding, ScopedA named apple") .key(Key.get(ScopedA.class, named("apple")), InjectsScopedANamedApple.class) .configurationException("No implementation for %s annotated with %s was bound", ScopedA.class.getName(), named("apple")) .addToSuite(suite); for (final Scoper scoper : Scoper.values()) { new Builder() .name("bind PlainA") .key(Key.get(PlainA.class), InjectsPlainA.class) .module(new AbstractModule() { protected void configure() { AnnotatedBindingBuilder abb = bind(PlainA.class); scoper.configure(abb); } }) .scoper(scoper) .addToSuite(suite); new Builder() .name("bind A to PlainA") .module(new AbstractModule() { protected void configure() { ScopedBindingBuilder sbb = bind(A.class).to(PlainA.class); scoper.configure(sbb); } }) .scoper(scoper) .addToSuite(suite); new Builder() .name("bind A to PlainAProvider.class") .module(new AbstractModule() { protected void configure() { ScopedBindingBuilder sbb = bind(A.class).toProvider(PlainAProvider.class); scoper.configure(sbb); } }) .scoper(scoper) .addToSuite(suite); new Builder() .name("bind A to new PlainAProvider()") .module(new AbstractModule() { protected void configure() { ScopedBindingBuilder sbb = bind(A.class).toProvider(new PlainAProvider()); scoper.configure(sbb); } }) .scoper(scoper) .addToSuite(suite); new Builder() .name("bind AWithProvidedBy") .key(Key.get(AWithProvidedBy.class), InjectsAWithProvidedBy.class) .module(new AbstractModule() { protected void configure() { ScopedBindingBuilder sbb = bind(AWithProvidedBy.class); scoper.configure(sbb); } }) .scoper(scoper) .addToSuite(suite); new Builder() .name("bind AWithImplementedBy") .key(Key.get(AWithImplementedBy.class), InjectsAWithImplementedBy.class) .module(new AbstractModule() { protected void configure() { ScopedBindingBuilder sbb = bind(AWithImplementedBy.class); scoper.configure(sbb); } }) .scoper(scoper) .addToSuite(suite); new Builder() .name("bind ScopedA") .key(Key.get(ScopedA.class), InjectsScopedA.class) .module(new AbstractModule() { protected void configure() { ScopedBindingBuilder sbb = bind(ScopedA.class); scoper.configure(sbb); } }) .expectedValues(new PlainA(201), new PlainA(201), new PlainA(202), new PlainA(202)) .scoper(scoper) .addToSuite(suite); new Builder() .name("bind AWithProvidedBy named apple") .module(new AbstractModule() { protected void configure() { scoper.configure(bind(AWithProvidedBy.class).annotatedWith(named("apple"))); } }) .creationException("No implementation for %s annotated with %s was bound", AWithProvidedBy.class.getName(), named("apple")) .addToSuite(suite); new Builder() .name("bind AWithImplementedBy named apple") .module(new AbstractModule() { protected void configure() { scoper.configure(bind(AWithImplementedBy.class).annotatedWith(named("apple"))); } }) .creationException("No implementation for %s annotated with %s was bound", AWithImplementedBy.class.getName(), named("apple")) .addToSuite(suite); new Builder() .name("bind ScopedA named apple") .module(new AbstractModule() { protected void configure() { scoper.configure(bind(ScopedA.class).annotatedWith(named("apple"))); } }) .creationException("No implementation for %s annotated with %s was bound", ScopedA.class.getName(), named("apple")) .addToSuite(suite); } return suite; } enum Scoper { UNSCOPED { void configure(ScopedBindingBuilder sbb) {} void apply(Builder builder) {} }, EAGER_SINGLETON { void configure(ScopedBindingBuilder sbb) { sbb.asEagerSingleton(); } void apply(Builder builder) { builder.expectedValues(new PlainA(101), new PlainA(101), new PlainA(101)); builder.creationTime(CreationTime.EAGER); } }, SCOPES_SINGLETON { void configure(ScopedBindingBuilder sbb) { sbb.in(Scopes.SINGLETON); } void apply(Builder builder) { builder.expectedValues(new PlainA(201), new PlainA(201), new PlainA(201)); } }, SINGLETON_DOT_CLASS { void configure(ScopedBindingBuilder sbb) { sbb.in(Singleton.class); } void apply(Builder builder) { builder.expectedValues(new PlainA(201), new PlainA(201), new PlainA(201)); } }, TWO_AT_A_TIME_SCOPED_DOT_CLASS { void configure(ScopedBindingBuilder sbb) { sbb.in(TwoAtATimeScoped.class); } void apply(Builder builder) { builder.expectedValues(new PlainA(201), new PlainA(201), new PlainA(202), new PlainA(202)); } }, TWO_AT_A_TIME_SCOPE { void configure(ScopedBindingBuilder sbb) { sbb.in(new TwoAtATimeScope()); } void apply(Builder builder) { builder.expectedValues(new PlainA(201), new PlainA(201), new PlainA(202), new PlainA(202)); } }; abstract void configure(ScopedBindingBuilder sbb); abstract void apply(Builder builder); } /** When Guice creates a value, directly or via a provider */ enum CreationTime { NONE, EAGER, LAZY } public static class Builder { private String name = "test"; private Key key = Key.get(A.class); private Class injectsKey = InjectsA.class; private List modules = Lists.newArrayList(new AbstractModule() { protected void configure() { bindScope(TwoAtATimeScoped.class, new TwoAtATimeScope()); } }); private List expectedValues = Lists.newArrayList( new PlainA(201), new PlainA(202), new PlainA(203)); private CreationTime creationTime = CreationTime.LAZY; private String creationException; private String configurationException; public Builder module(Module module) { this.modules.add(module); return this; } public Builder creationTime(CreationTime creationTime) { this.creationTime = creationTime; return this; } public Builder name(String name) { this.name = name; return this; } public Builder key(Key key, Class injectsKey) { this.key = key; this.injectsKey = injectsKey; return this; } private Builder creationException(String message, Object... args) { this.creationException = String.format(message, args); return this; } private Builder configurationException(String message, Object... args) { configurationException = String.format(message, args); return this; } private Builder scoper(Scoper scoper) { name(name + " in " + scoper.toString()); scoper.apply(this); return this; } private Builder expectedValues(T... values) { this.expectedValues.clear(); this.expectedValues.addAll(Arrays.asList(values)); return this; } public void addToSuite(TestSuite suite) { if (creationException != null) { suite.addTest(new CreationExceptionTest(this)); } else if (configurationException != null) { suite.addTest(new ConfigurationExceptionTest(this)); } else { suite.addTest(new SuccessTest(this)); if (creationTime != CreationTime.NONE) { suite.addTest(new UserExceptionsTest(this)); } } } } public static class SuccessTest extends TestCase { final String name; final Key key; final Class injectsKey; final ImmutableList modules; final ImmutableList expectedValues; public SuccessTest(Builder builder) { super("test"); name = builder.name; key = builder.key; injectsKey = builder.injectsKey; modules = ImmutableList.copyOf(builder.modules); expectedValues = ImmutableList.copyOf(builder.expectedValues); } public String getName() { return name; } Injector newInjector() { nextId.set(101); return Guice.createInjector(modules); } public void test() throws IllegalAccessException, InstantiationException { Injector injector = newInjector(); nextId.set(201); for (Object value : expectedValues) { assertEquals(value, injector.getInstance(key)); } Provider provider = newInjector().getProvider(key); nextId.set(201); for (Object value : expectedValues) { assertEquals(value, provider.get()); } Provider bindingProvider = newInjector().getBinding(key).getProvider(); nextId.set(201); for (Object value : expectedValues) { assertEquals(value, bindingProvider.get()); } injector = newInjector(); nextId.set(201); for (Object value : expectedValues) { Injectable instance = injector.getInstance(injectsKey); assertEquals(value, instance.value); } injector = newInjector(); nextId.set(201); for (Object value : expectedValues) { Injectable injectable = injectsKey.newInstance(); injector.injectMembers(injectable); assertEquals(value, injectable.value); } Injector injector1 = newInjector(); nextId.set(201); Injectable hasProvider = injector1.getInstance(injectsKey); hasProvider.provider.get(); nextId.set(201); for (Object value : expectedValues) { assertEquals(value, hasProvider.provider.get()); } } } public static class CreationExceptionTest extends TestCase { final String name; final Key key; final ImmutableList modules; final String creationException; public CreationExceptionTest(Builder builder) { super("test"); name = builder.name; key = builder.key; modules = ImmutableList.copyOf(builder.modules); creationException = builder.creationException; } public String getName() { return "creation errors:" + name; } public void test() { try { Guice.createInjector(modules); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), creationException); } } } public static class ConfigurationExceptionTest extends TestCase { final String name; final Key key; final Class injectsKey; final ImmutableList modules; final String configurationException; public ConfigurationExceptionTest(Builder builder) { super("test"); name = builder.name; key = builder.key; injectsKey = builder.injectsKey; modules = ImmutableList.copyOf(builder.modules); configurationException = builder.configurationException; } public String getName() { return "provision errors:" + name; } Injector newInjector() { return Guice.createInjector(modules); } public void test() throws IllegalAccessException, InstantiationException { try { newInjector().getProvider(key); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), configurationException); } try { newInjector().getBinding(key).getProvider(); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), configurationException); } try { newInjector().getInstance(key); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), configurationException); } try { newInjector().getInstance(injectsKey); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), configurationException, injectsKey.getName() + ".inject", configurationException, injectsKey.getName() + ".inject", "2 errors"); } try { Injectable injectable = injectsKey.newInstance(); newInjector().injectMembers(injectable); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), configurationException, injectsKey.getName() + ".inject", configurationException, injectsKey.getName() + ".inject", "2 errors"); } } } public static class UserExceptionsTest extends TestCase { final String name; final Key key; final Class injectsKey; final ImmutableList modules; final ImmutableList expectedValues; final CreationTime creationTime; public UserExceptionsTest(Builder builder) { super("test"); name = builder.name; key = builder.key; injectsKey = builder.injectsKey; modules = ImmutableList.copyOf(builder.modules); expectedValues = ImmutableList.copyOf(builder.expectedValues); creationTime = builder.creationTime; } public String getName() { return "provision errors:" + name; } Injector newInjector() { return Guice.createInjector(modules); } public void test() throws IllegalAccessException, InstantiationException { nextId.set(-1); try { newInjector(); assertEquals(CreationTime.LAZY, creationTime); } catch (CreationException expected) { assertEquals(CreationTime.EAGER, creationTime); assertContains(expected.getMessage(), "Illegal value: -1"); return; } Provider provider = newInjector().getProvider(key); Provider bindingProvider = newInjector().getBinding(key).getProvider(); nextId.set(-1); try { newInjector().getInstance(key); fail(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "Illegal value: -1"); } nextId.set(-1); try { provider.get(); fail(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "Illegal value: -1"); } nextId.set(-1); try { bindingProvider.get(); fail(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "Illegal value: -1"); } try { nextId.set(-1); newInjector().getInstance(injectsKey); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "Illegal value: -1", "for parameter 0 at " + injectsKey.getName() + ".inject"); } nextId.set(201); Injectable injectable = injectsKey.newInstance(); try { nextId.set(-1); newInjector().injectMembers(injectable); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "Illegal value: -1", "for parameter 0 at " + injectsKey.getName() + ".inject"); } nextId.set(201); Injectable hasProvider = newInjector().getInstance(injectsKey); hasProvider.provider.get(); try { nextId.set(-1); hasProvider.provider.get(); } catch (ProvisionException expected) { assertContains(expected.getMessage(), "Illegal value: -1"); } } } /** negative to throw, 101... for eager singletons, 201... for everything else */ static final AtomicInteger nextId = new AtomicInteger(); @ProvidedBy(PlainAProvider.class) interface AWithProvidedBy {} static class InjectsAWithProvidedBy extends Injectable { @Inject public void inject(AWithProvidedBy aWithProvidedBy, Provider aWithProvidedByProvider) { this.value = aWithProvidedBy; this.provider = aWithProvidedByProvider; } } static class InjectsAWithProvidedByNamedApple extends Injectable { @Inject public void inject(@Named("apple") AWithProvidedBy aWithProvidedBy, @Named("apple") Provider aWithProvidedByProvider) { this.value = aWithProvidedBy; this.provider = aWithProvidedByProvider; } } @ImplementedBy(PlainA.class) interface AWithImplementedBy {} static class InjectsAWithImplementedBy extends Injectable { @Inject public void inject(AWithImplementedBy aWithImplementedBy, Provider aWithImplementedByProvider) { this.value = aWithImplementedBy; this.provider = aWithImplementedByProvider; } } static class InjectsAWithImplementedByNamedApple extends Injectable { @Inject public void inject(@Named("apple") AWithImplementedBy aWithImplementedBy, @Named("apple") Provider aWithImplementedByProvider) { this.value = aWithImplementedBy; this.provider = aWithImplementedByProvider; } } interface A extends AWithProvidedBy, AWithImplementedBy {} static class InjectsA extends Injectable { @Inject public void inject(A a, Provider aProvider) { this.value = a; this.provider = aProvider; } } static class PlainA implements A { final int value; PlainA() { value = nextId.getAndIncrement(); if (value < 0) { throw new RuntimeException("Illegal value: " + value); } } PlainA(int value) { this.value = value; } public boolean equals(Object obj) { return obj instanceof PlainA && value == ((PlainA) obj).value; } public int hashCode() { return value; } public String toString() { return "PlainA#" + value; } } static class PlainAProvider implements Provider { public A get() { return new PlainA(); } } static class InjectsPlainA extends Injectable { @Inject public void inject(PlainA plainA, Provider plainAProvider) { this.value = plainA; this.provider = plainAProvider; } } /** This scope hands out each value exactly twice */ static class TwoAtATimeScope implements Scope { public Provider scope(Key key, final Provider unscoped) { return new Provider() { T instance; public T get() { if (instance == null) { instance = unscoped.get(); return instance; } else { T result = instance; instance = null; return result; } } }; } } @Target({ TYPE, METHOD }) @Retention(RUNTIME) @ScopeAnnotation public @interface TwoAtATimeScoped {} @TwoAtATimeScoped static class ScopedA extends PlainA {} static class InjectsScopedA extends Injectable { @Inject public void inject(ScopedA scopedA, Provider scopedAProvider) { this.value = scopedA; this.provider = scopedAProvider; } } static class InjectsScopedANamedApple extends Injectable { @Inject public void inject(@Named("apple") ScopedA scopedA, @Named("apple") Provider scopedAProvider) { this.value = scopedA; this.provider = scopedAProvider; } } static class Injectable { Object value = new Object(); Provider provider = Providers.of(new Object()); } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/BinderTest.java0000644000175000017500000004643511704661106024551 0ustar tonytony/** * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.inject.Asserts.assertContains; import static com.google.inject.Asserts.assertNotSerializable; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.inject.name.Named; import com.google.inject.name.Names; import com.google.inject.spi.Message; import com.google.inject.util.Providers; import junit.framework.TestCase; import java.io.IOException; import java.util.Comparator; import java.util.Date; import java.util.List; import java.util.concurrent.Callable; import java.util.logging.Handler; import java.util.logging.LogRecord; import java.util.logging.Logger; /** * @author crazybob@google.com (Bob Lee) */ public class BinderTest extends TestCase { private final Logger loggerToWatch = Logger.getLogger(Guice.class.getName()); private final List logRecords = Lists.newArrayList(); private final Handler fakeHandler = new Handler() { @Override public void publish(LogRecord logRecord) { logRecords.add(logRecord); } @Override public void flush() {} @Override public void close() throws SecurityException {} }; Provider fooProvider; @Override protected void setUp() throws Exception { super.setUp(); loggerToWatch.addHandler(fakeHandler); } @Override protected void tearDown() throws Exception { loggerToWatch.removeHandler(fakeHandler); super.tearDown(); } public void testProviderFromBinder() { Guice.createInjector(new Module() { public void configure(Binder binder) { fooProvider = binder.getProvider(Foo.class); try { fooProvider.get(); } catch (IllegalStateException e) { /* expected */ } } }); assertNotNull(fooProvider.get()); } static class Foo {} public void testMissingBindings() { try { Guice.createInjector(new AbstractModule() { @Override public void configure() { getProvider(Runnable.class); bind(Comparator.class); requireBinding(Key.get(new TypeLiteral>() {})); bind(Date.class).annotatedWith(Names.named("date")); } }); } catch (CreationException e) { assertEquals(4, e.getErrorMessages().size()); assertContains(e.getMessage(), "1) No implementation for java.lang.Runnable was bound.", "at " + getClass().getName(), "2) No implementation for " + Comparator.class.getName() + " was bound.", "at " + getClass().getName(), "3) No implementation for java.util.concurrent.Callable was bound.", "at " + getClass().getName(), "4) No implementation for java.util.Date annotated with @" + Named.class.getName() + "(value=date) was bound.", "at " + getClass().getName()); } } public void testMissingDependency() { try { Guice.createInjector(new AbstractModule() { @Override public void configure() { bind(NeedsRunnable.class); } }); } catch (CreationException e) { assertEquals(1, e.getErrorMessages().size()); assertContains(e.getMessage(), "No implementation for java.lang.Runnable was bound.", "for field at " + NeedsRunnable.class.getName(), ".runnable(BinderTest.java:", "at " + getClass().getName(), ".configure(BinderTest.java:"); } } static class NeedsRunnable { @Inject Runnable runnable; } public void testDanglingConstantBinding() { try { Guice.createInjector(new AbstractModule() { @Override public void configure() { bindConstant(); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Missing constant value. Please call to(...).", "at " + getClass().getName()); } } public void testRecursiveBinding() { try { Guice.createInjector(new AbstractModule() { @Override public void configure() { bind(Runnable.class).to(Runnable.class); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Binding points to itself.", "at " + getClass().getName(), ".configure(BinderTest.java:"); } } public void testBindingNullConstant() { try { Guice.createInjector(new AbstractModule() { @Override public void configure() { String none = null; bindConstant().annotatedWith(Names.named("nullOne")).to(none); bind(String.class).annotatedWith(Names.named("nullTwo")).toInstance(none); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Binding to null instances is not allowed. Use toProvider(Providers.of(null))", "2) Binding to null instances is not allowed. Use toProvider(Providers.of(null))"); } } public void testToStringOnBinderApi() { try { Guice.createInjector(new AbstractModule() { @Override public void configure() { assertEquals("Binder", binder().toString()); assertEquals("Provider", getProvider(Integer.class).toString()); assertEquals("Provider>", getProvider(Key.get(new TypeLiteral>() {})).toString()); assertEquals("BindingBuilder", bind(Integer.class).toString()); assertEquals("BindingBuilder", bind(Integer.class).annotatedWith(Names.named("a")).toString()); assertEquals("ConstantBindingBuilder", bindConstant().toString()); assertEquals("ConstantBindingBuilder", bindConstant().annotatedWith(Names.named("b")).toString()); assertEquals("AnnotatedElementBuilder", binder().newPrivateBinder().expose(Integer.class).toString()); } }); fail(); } catch (CreationException ignored) { } } public void testNothingIsSerializableInBinderApi() { try { Guice.createInjector(new AbstractModule() { @Override public void configure() { try { assertNotSerializable(binder()); assertNotSerializable(getProvider(Integer.class)); assertNotSerializable(getProvider(Key.get(new TypeLiteral>() {}))); assertNotSerializable(bind(Integer.class)); assertNotSerializable(bind(Integer.class).annotatedWith(Names.named("a"))); assertNotSerializable(bindConstant()); assertNotSerializable(bindConstant().annotatedWith(Names.named("b"))); } catch (IOException e) { fail(e.getMessage()); } } }); fail(); } catch (CreationException ignored) { } } /** * Although {@code String[].class} isn't equal to {@code new * GenericArrayTypeImpl(String.class)}, Guice should treat these two types * interchangeably. */ public void testArrayTypeCanonicalization() { final String[] strings = new String[] { "A" }; final Integer[] integers = new Integer[] { 1 }; Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(String[].class).toInstance(strings); bind(new TypeLiteral() {}).toInstance(integers); } }); assertSame(integers, injector.getInstance(Key.get(new TypeLiteral() {}))); assertSame(integers, injector.getInstance(new Key() {})); assertSame(integers, injector.getInstance(Integer[].class)); assertSame(strings, injector.getInstance(Key.get(new TypeLiteral() {}))); assertSame(strings, injector.getInstance(new Key() {})); assertSame(strings, injector.getInstance(String[].class)); try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(String[].class).toInstance(new String[] { "A" }); bind(new TypeLiteral() {}).toInstance(new String[] { "B" }); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) A binding to java.lang.String[] was already configured at " + getClass().getName(), "at " + getClass().getName(), ".configure(BinderTest.java:"); assertContains(expected.getMessage(), "1 error"); } // passes because duplicates are ignored injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(String[].class).toInstance(strings); bind(new TypeLiteral() {}).toInstance(strings); } }); assertSame(strings, injector.getInstance(Key.get(new TypeLiteral() {}))); assertSame(strings, injector.getInstance(new Key() {})); assertSame(strings, injector.getInstance(String[].class)); } /** * Binding something to two different things should give an error. */ public void testSettingBindingTwice() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(String.class).toInstance("foo"); bind(String.class).toInstance("bar"); } }); fail(); } catch(CreationException expected) { assertContains(expected.getMessage(), "1) A binding to java.lang.String was already configured at " + getClass().getName(), "at " + getClass().getName(), ".configure(BinderTest.java:"); assertContains(expected.getMessage(), "1 error"); } } /** * Binding an @ImplementedBy thing to something else should also fail. */ public void testSettingAtImplementedByTwice() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(HasImplementedBy1.class); bind(HasImplementedBy1.class).toInstance(new HasImplementedBy1() {}); } }); fail(); } catch(CreationException expected) { expected.printStackTrace(); assertContains(expected.getMessage(), "1) A binding to " + HasImplementedBy1.class.getName() + " was already configured at " + getClass().getName(), "at " + getClass().getName(), ".configure(BinderTest.java:"); assertContains(expected.getMessage(), "1 error"); } } /** * See issue 614, Problem One * http://code.google.com/p/google-guice/issues/detail?id=614 */ public void testJitDependencyDoesntBlockOtherExplicitBindings() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(HasImplementedByThatNeedsAnotherImplementedBy.class); bind(HasImplementedBy1.class).toInstance(new HasImplementedBy1() {}); } }); injector.getAllBindings(); // just validate it doesn't throw. // Also validate that we're using the explicit (and not @ImplementedBy) implementation assertFalse(injector.getInstance(HasImplementedBy1.class) instanceof ImplementsHasImplementedBy1); } /** * See issue 614, Problem Two * http://code.google.com/p/google-guice/issues/detail?id=614 */ public void testJitDependencyCanUseExplicitDependencies() { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(HasImplementedByThatWantsExplicit.class); bind(JustAnInterface.class).toInstance(new JustAnInterface() {}); } }); } /** * Untargetted bindings should follow @ImplementedBy and @ProvidedBy * annotations if they exist. Otherwise the class should be constructed * directly. */ public void testUntargettedBinding() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(HasProvidedBy1.class); bind(HasImplementedBy1.class); bind(HasProvidedBy2.class); bind(HasImplementedBy2.class); bind(JustAClass.class); } }); assertNotNull(injector.getInstance(HasProvidedBy1.class)); assertNotNull(injector.getInstance(HasImplementedBy1.class)); assertNotSame(HasProvidedBy2.class, injector.getInstance(HasProvidedBy2.class).getClass()); assertSame(ExtendsHasImplementedBy2.class, injector.getInstance(HasImplementedBy2.class).getClass()); assertSame(JustAClass.class, injector.getInstance(JustAClass.class).getClass()); } public void testPartialInjectorGetInstance() { Injector injector = Guice.createInjector(); try { injector.getInstance(MissingParameter.class); fail(); } catch (ConfigurationException expected) { assertContains(expected.getMessage(), "1) Could not find a suitable constructor in " + NoInjectConstructor.class.getName(), "at " + MissingParameter.class.getName() + ".(BinderTest.java:"); } } public void testUserReportedError() { final Message message = new Message(getClass(), "Whoops!"); try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { addError(message); } }); fail(); } catch (CreationException expected) { assertSame(message, Iterables.getOnlyElement(expected.getErrorMessages())); } } public void testUserReportedErrorsAreAlsoLogged() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { addError(new Message(ImmutableList.of(), "Whoops!", new IllegalArgumentException())); } }); fail(); } catch (CreationException expected) { } LogRecord logRecord = Iterables.getOnlyElement(this.logRecords); assertContains(logRecord.getMessage(), "An exception was caught and reported. Message: java.lang.IllegalArgumentException"); } public void testBindingToProvider() { try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(new TypeLiteral>() {}).toInstance(Providers.of("A")); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "1) Binding to Provider is not allowed.", "at " + BinderTest.class.getName(), "configure(BinderTest.java:"); } } public void testCannotBindToGuiceTypes() { final Named red = Names.named("red"); try { Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(AbstractModule.class).annotatedWith(red) .toProvider(Providers.of(null)); bind(Binder.class).annotatedWith(red).toProvider(Providers.of(null)); bind(Binding.class).annotatedWith(red).toProvider(Providers.of(null)); bind(Injector.class).annotatedWith(red).toProvider(Providers.of(null)); bind(Key.class).annotatedWith(red).toProvider(Providers.of(null)); bind(Module.class).annotatedWith(red).toProvider(Providers.of(null)); bind(Provider.class).annotatedWith(red).toProvider(Providers.of(null)); bind(Scope.class).annotatedWith(red).toProvider(Providers.of(null)); bind(TypeLiteral.class).annotatedWith(red).toProvider(Providers.of(null)); bind(new TypeLiteral>() {}).toProvider(Providers.>of(null)); } }); fail(); } catch (CreationException expected) { assertContains(expected.getMessage(), "Binding to core guice framework type is not allowed: AbstractModule.", "Binding to core guice framework type is not allowed: Binder.", "Binding to core guice framework type is not allowed: Binding.", "Binding to core guice framework type is not allowed: Injector.", "Binding to core guice framework type is not allowed: Key.", "Binding to core guice framework type is not allowed: Module.", "Binding to Provider is not allowed.", "Binding to core guice framework type is not allowed: Scope.", "Binding to core guice framework type is not allowed: TypeLiteral.", "Binding to core guice framework type is not allowed: Key."); } } static class MissingParameter { @Inject MissingParameter(NoInjectConstructor noInjectConstructor) {} } static class NoInjectConstructor { private NoInjectConstructor() {} } @ProvidedBy(HasProvidedBy1Provider.class) interface HasProvidedBy1 {} static class HasProvidedBy1Provider implements Provider { public HasProvidedBy1 get() { return new HasProvidedBy1() {}; } } @ImplementedBy(ImplementsHasImplementedBy1.class) interface HasImplementedBy1 {} static class ImplementsHasImplementedBy1 implements HasImplementedBy1 {} @ProvidedBy(HasProvidedBy2Provider.class) static class HasProvidedBy2 {} static class HasProvidedBy2Provider implements Provider { public HasProvidedBy2 get() { return new HasProvidedBy2() {}; } } @ImplementedBy(ExtendsHasImplementedBy2.class) static class HasImplementedBy2 {} static class ExtendsHasImplementedBy2 extends HasImplementedBy2 {} static class JustAClass {} @ImplementedBy(ImplementsHasImplementedByThatNeedsAnotherImplementedBy.class) static interface HasImplementedByThatNeedsAnotherImplementedBy { } static class ImplementsHasImplementedByThatNeedsAnotherImplementedBy implements HasImplementedByThatNeedsAnotherImplementedBy { @Inject ImplementsHasImplementedByThatNeedsAnotherImplementedBy( HasImplementedBy1 h1n1) {} } @ImplementedBy(ImplementsHasImplementedByThatWantsExplicit.class) static interface HasImplementedByThatWantsExplicit { } static class ImplementsHasImplementedByThatWantsExplicit implements HasImplementedByThatWantsExplicit { @Inject ImplementsHasImplementedByThatWantsExplicit(JustAnInterface jai) {} } static interface JustAnInterface {} // public void testBindInterfaceWithoutImplementation() { // Guice.createInjector(new AbstractModule() { // protected void configure() { // bind(Runnable.class); // } // }).getInstance(Runnable.class); // } enum Roshambo { ROCK, SCISSORS, PAPER } public void testInjectRawProvider() { try { Guice.createInjector().getInstance(Provider.class); fail(); } catch (ConfigurationException expected) { Asserts.assertContains(expected.getMessage(), "1) Cannot inject a Provider that has no type parameter", "while locating " + Provider.class.getName()); } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/Asserts.java0000644000175000017500000000752211704661106024124 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; import junit.framework.Assert; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.NotSerializableException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; /** * @author jessewilson@google.com (Jesse Wilson) */ public class Asserts { private Asserts() {} /** * Fails unless {@code expected.equals(actual)}, {@code * actual.equals(expected)} and their hash codes are equal. This is useful * for testing the equals method itself. */ public static void assertEqualsBothWays(Object expected, Object actual) { assertNotNull(expected); assertNotNull(actual); assertTrue("expected.equals(actual)", expected.equals(actual)); assertTrue("actual.equals(expected)", actual.equals(expected)); assertEquals("hashCode", expected.hashCode(), actual.hashCode()); } /** * Fails unless {@code text} includes all {@code substrings}, in order. */ public static void assertContains(String text, String... substrings) { /*if[NO_AOP] // when we strip out bytecode manipulation, we lose the ability to generate some source lines. if (text.contains("(Unknown Source)")) { return; } end[NO_AOP]*/ int startingFrom = 0; for (String substring : substrings) { int index = text.indexOf(substring, startingFrom); assertTrue(String.format("Expected \"%s\" to contain substring \"%s\"", text, substring), index >= startingFrom); startingFrom = index + substring.length(); } String lastSubstring = substrings[substrings.length - 1]; assertTrue(String.format("Expected \"%s\" to contain substring \"%s\" only once),", text, lastSubstring), text.indexOf(lastSubstring, startingFrom) == -1); } /** * Fails unless {@code object} doesn't equal itself when reserialized. */ public static void assertEqualWhenReserialized(Object object) throws IOException { Object reserialized = reserialize(object); assertEquals(object, reserialized); assertEquals(object.hashCode(), reserialized.hashCode()); } /** * Fails unless {@code object} has the same toString value when reserialized. */ public static void assertSimilarWhenReserialized(Object object) throws IOException { Object reserialized = reserialize(object); assertEquals(object.toString(), reserialized.toString()); } public static E reserialize(E original) throws IOException { try { ByteArrayOutputStream out = new ByteArrayOutputStream(); new ObjectOutputStream(out).writeObject(original); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); @SuppressWarnings("unchecked") // the reserialized type is assignable E reserialized = (E) new ObjectInputStream(in).readObject(); return reserialized; } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } public static void assertNotSerializable(Object object) throws IOException { try { reserialize(object); Assert.fail(); } catch (NotSerializableException expected) { } } } sisu-guice-sisu-guice-3.1.1/core/test/com/google/inject/AllTests.java0000644000175000017500000001317211704661106024231 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import com.google.common.collect.ImmutableSet; import com.google.inject.internal.MoreTypesTest; import com.google.inject.internal.UniqueAnnotationsTest; import com.google.inject.internal.util.LineNumbersTest; import com.google.inject.matcher.MatcherTest; import com.google.inject.name.NamedEquivalanceTest; import com.google.inject.name.NamesTest; import com.google.inject.spi.BindingTargetVisitorTest; import com.google.inject.spi.ElementApplyToTest; import com.google.inject.spi.ElementsTest; import com.google.inject.spi.HasDependenciesTest; import com.google.inject.spi.InjectionPointTest; import com.google.inject.spi.InjectorSpiTest; import com.google.inject.spi.ModuleRewriterTest; import com.google.inject.spi.ProviderMethodsTest; import com.google.inject.spi.SpiBindingsTest; import com.google.inject.spi.ToolStageInjectorTest; import com.google.inject.util.NoopOverrideTest; import com.google.inject.util.ProvidersTest; import com.google.inject.util.TypesTest; import com.googlecode.guice.GuiceTck; import com.googlecode.guice.Jsr330Test; import junit.framework.Test; import junit.framework.TestSuite; import java.util.Set; /** * @author crazybob@google.com (Bob Lee) */ public class AllTests { private static final Set SUPPRESSED_TEST_NAMES = ImmutableSet.of( "testUnscopedProviderWorksOutsideOfRequestedScope(" + ScopesTest.class.getName() + ")", "testCannotConvertUnannotatedBindings(" + TypeConversionTest.class.getName() + ")" ); public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest(GuiceTck.suite()); suite.addTestSuite(BinderTest.class); suite.addTest(BinderTestSuite.suite()); suite.addTestSuite(BindingAnnotationTest.class); suite.addTestSuite(BindingOrderTest.class); suite.addTestSuite(BindingTest.class); suite.addTestSuite(BoundInstanceInjectionTest.class); suite.addTestSuite(BoundProviderTest.class); suite.addTestSuite(CircularDependencyTest.class); suite.addTestSuite(DuplicateBindingsTest.class); // ErrorHandlingTest.class is not a testcase suite.addTestSuite(EagerSingletonTest.class); suite.addTestSuite(GenericInjectionTest.class); suite.addTestSuite(ImplicitBindingTest.class); suite.addTestSuite(TypeListenerTest.class); suite.addTestSuite(InjectorTest.class); suite.addTestSuite(JitBindingsTest.class); // IntegrationTest is AOP-only suite.addTestSuite(KeyTest.class); suite.addTestSuite(LoggerInjectionTest.class); // MethodInterceptionTest is AOP-only suite.addTestSuite(MembersInjectorTest.class); suite.addTestSuite(ModulesTest.class); suite.addTestSuite(ModuleTest.class); suite.addTestSuite(NullableInjectionPointTest.class); suite.addTestSuite(OptionalBindingTest.class); suite.addTestSuite(OverrideModuleTest.class); suite.addTestSuite(ParentInjectorTest.class); suite.addTestSuite(PrivateModuleTest.class); suite.addTestSuite(ProviderInjectionTest.class); suite.addTestSuite(ProvisionExceptionTest.class); suite.addTestSuite(ProvisionListenerTest.class); // ProxyFactoryTest is AOP-only suite.addTestSuite(ReflectionTest.class); suite.addTestSuite(RequestInjectionTest.class); suite.addTestSuite(ScopesTest.class); suite.addTestSuite(SerializationTest.class); suite.addTestSuite(SuperclassTest.class); suite.addTestSuite(TypeConversionTest.class); suite.addTestSuite(TypeLiteralInjectionTest.class); suite.addTestSuite(TypeLiteralTest.class); suite.addTestSuite(TypeLiteralTypeResolutionTest.class); // internal suite.addTestSuite(LineNumbersTest.class); suite.addTestSuite(MoreTypesTest.class); suite.addTestSuite(UniqueAnnotationsTest.class); // matcher suite.addTestSuite(MatcherTest.class); // names suite.addTestSuite(NamesTest.class); suite.addTestSuite(NamedEquivalanceTest.class); // spi suite.addTestSuite(BindingTargetVisitorTest.class); suite.addTestSuite(ElementsTest.class); suite.addTestSuite(ElementApplyToTest.class); suite.addTestSuite(HasDependenciesTest.class); suite.addTestSuite(InjectionPointTest.class); suite.addTestSuite(InjectorSpiTest.class); suite.addTestSuite(ModuleRewriterTest.class); suite.addTestSuite(ProviderMethodsTest.class); suite.addTestSuite(SpiBindingsTest.class); suite.addTestSuite(ToolStageInjectorTest.class); // tools // suite.addTestSuite(JmxTest.class); not a testcase // util suite.addTestSuite(NoopOverrideTest.class); suite.addTestSuite(ProvidersTest.class); suite.addTestSuite(TypesTest.class); /*if[AOP]*/ suite.addTestSuite(com.google.inject.internal.ProxyFactoryTest.class); suite.addTestSuite(IntegrationTest.class); suite.addTestSuite(MethodInterceptionTest.class); suite.addTestSuite(com.googlecode.guice.BytecodeGenTest.class); /*end[AOP]*/ // googlecode.guice suite.addTestSuite(com.googlecode.guice.OSGiContainerTest.class); suite.addTestSuite(Jsr330Test.class); return SuiteUtils.removeSuppressedTests(suite, SUPPRESSED_TEST_NAMES); } } sisu-guice-sisu-guice-3.1.1/core/src/0000755000175000017500000000000011704661106016131 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/src/com/0000755000175000017500000000000011704661106016707 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/src/com/google/0000755000175000017500000000000011704661106020163 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/0000755000175000017500000000000011704661106021437 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/util/0000755000175000017500000000000011704661106022414 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/util/package-info.java0000644000175000017500000000124511704661106025605 0ustar tonytony/* * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Helper methods for working with Guice. */ package com.google.inject.util;sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/util/Types.java0000644000175000017500000001103111704661106024357 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.util; import com.google.inject.Provider; import com.google.inject.internal.MoreTypes; import com.google.inject.internal.MoreTypes.GenericArrayTypeImpl; import com.google.inject.internal.MoreTypes.ParameterizedTypeImpl; import com.google.inject.internal.MoreTypes.WildcardTypeImpl; import java.lang.reflect.GenericArrayType; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.lang.reflect.WildcardType; import java.util.List; import java.util.Map; import java.util.Set; /** * Static methods for working with types. * * @author crazybob@google.com (Bob Lee) * @since 2.0 */ public final class Types { private Types() {} /** * Returns a new parameterized type, applying {@code typeArguments} to * {@code rawType}. The returned type does not have an owner type. * * @return a {@link java.io.Serializable serializable} parameterized type. */ public static ParameterizedType newParameterizedType(Type rawType, Type... typeArguments) { return newParameterizedTypeWithOwner(null, rawType, typeArguments); } /** * Returns a new parameterized type, applying {@code typeArguments} to * {@code rawType} and enclosed by {@code ownerType}. * * @return a {@link java.io.Serializable serializable} parameterized type. */ public static ParameterizedType newParameterizedTypeWithOwner( Type ownerType, Type rawType, Type... typeArguments) { return new ParameterizedTypeImpl(ownerType, rawType, typeArguments); } /** * Returns an array type whose elements are all instances of * {@code componentType}. * * @return a {@link java.io.Serializable serializable} generic array type. */ public static GenericArrayType arrayOf(Type componentType) { return new GenericArrayTypeImpl(componentType); } /** * Returns a type that represents an unknown type that extends {@code bound}. * For example, if {@code bound} is {@code CharSequence.class}, this returns * {@code ? extends CharSequence}. If {@code bound} is {@code Object.class}, * this returns {@code ?}, which is shorthand for {@code ? extends Object}. */ public static WildcardType subtypeOf(Type bound) { return new WildcardTypeImpl(new Type[] { bound }, MoreTypes.EMPTY_TYPE_ARRAY); } /** * Returns a type that represents an unknown supertype of {@code bound}. For * example, if {@code bound} is {@code String.class}, this returns {@code ? * super String}. */ public static WildcardType supertypeOf(Type bound) { return new WildcardTypeImpl(new Type[] { Object.class }, new Type[] { bound }); } /** * Returns a type modelling a {@link List} whose elements are of type * {@code elementType}. * * @return a {@link java.io.Serializable serializable} parameterized type. */ public static ParameterizedType listOf(Type elementType) { return newParameterizedType(List.class, elementType); } /** * Returns a type modelling a {@link Set} whose elements are of type * {@code elementType}. * * @return a {@link java.io.Serializable serializable} parameterized type. */ public static ParameterizedType setOf(Type elementType) { return newParameterizedType(Set.class, elementType); } /** * Returns a type modelling a {@link Map} whose keys are of type * {@code keyType} and whose values are of type {@code valueType}. * * @return a {@link java.io.Serializable serializable} parameterized type. */ public static ParameterizedType mapOf(Type keyType, Type valueType) { return newParameterizedType(Map.class, keyType, valueType); } // for other custom collections types, use newParameterizedType() /** * Returns a type modelling a {@link Provider} that provides elements of type * {@code elementType}. * * @return a {@link java.io.Serializable serializable} parameterized type. */ public static ParameterizedType providerOf(Type providedType) { return newParameterizedType(Provider.class, providedType); } }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/util/Providers.java0000644000175000017500000000711711704661106025242 0ustar tonytony/* * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.util; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Provider; import com.google.inject.spi.Dependency; import com.google.inject.spi.InjectionPoint; import com.google.inject.spi.ProviderWithDependencies; import java.util.Set; /** * Static utility methods for creating and working with instances of * {@link Provider}. * * @author Kevin Bourrillion (kevinb9n@gmail.com) * @since 2.0 */ public final class Providers { private Providers() {} /** * Returns a provider which always provides {@code instance}. This should not * be necessary to use in your application, but is helpful for several types * of unit tests. * * @param instance the instance that should always be provided. This is also * permitted to be null, to enable aggressive testing, although in real * life a Guice-supplied Provider will never return null. */ public static Provider of(final T instance) { return new Provider() { public T get() { return instance; } @Override public String toString() { return "of(" + instance + ")"; } }; } /** * Returns a Guice-friendly {@code com.google.inject.Provider} for the given * JSR-330 {@code javax.inject.Provider}. The converse method is unnecessary, * since Guice providers directly implement the JSR-330 interface. * * @since 3.0 */ public static Provider guicify(javax.inject.Provider provider) { if (provider instanceof Provider) { return (Provider) provider; } final javax.inject.Provider delegate = checkNotNull(provider, "provider"); // Ensure that we inject all injection points from the delegate provider. Set injectionPoints = InjectionPoint.forInstanceMethodsAndFields(provider.getClass()); if(injectionPoints.isEmpty()) { return new Provider() { public T get() { return delegate.get(); } @Override public String toString() { return "guicified(" + delegate + ")"; } }; } else { Set> mutableDeps = Sets.newHashSet(); for(InjectionPoint ip : injectionPoints) { mutableDeps.addAll(ip.getDependencies()); } final Set> dependencies = ImmutableSet.copyOf(mutableDeps); return new ProviderWithDependencies() { @SuppressWarnings("unused") @Inject void initialize(Injector injector) { injector.injectMembers(delegate); } public Set> getDependencies() { return dependencies; } public T get() { return delegate.get(); } @Override public String toString() { return "guicified(" + delegate + ")"; } }; } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/util/Modules.java0000644000175000017500000002657711704661106024710 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.util; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.inject.AbstractModule; import com.google.inject.Binder; import com.google.inject.Binding; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.PrivateBinder; import com.google.inject.PrivateModule; import com.google.inject.Scope; import com.google.inject.spi.DefaultBindingScopingVisitor; import com.google.inject.spi.DefaultElementVisitor; import com.google.inject.spi.Element; import com.google.inject.spi.Elements; import com.google.inject.spi.PrivateElements; import com.google.inject.spi.ScopeBinding; import java.lang.annotation.Annotation; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; /** * Static utility methods for creating and working with instances of {@link Module}. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public final class Modules { private Modules() {} public static final Module EMPTY_MODULE = new Module() { public void configure(Binder binder) {} }; /** * Returns a builder that creates a module that overlays override modules over the given * modules. If a key is bound in both sets of modules, only the binding from the override modules * is kept. If a single {@link PrivateModule} is supplied or all elements are from * a single {@link PrivateBinder}, then this will overwrite the private bindings. * Otherwise, private bindings will not be overwritten unless they are exposed. * This can be used to replace the bindings of a production module with test bindings: *
       * Module functionalTestModule
       *     = Modules.override(new ProductionModule()).with(new TestModule());
       * 
    * *

    Prefer to write smaller modules that can be reused and tested without overrides. * * @param modules the modules whose bindings are open to be overridden */ public static OverriddenModuleBuilder override(Module... modules) { return new RealOverriddenModuleBuilder(Arrays.asList(modules)); } /** * Returns a builder that creates a module that overlays override modules over the given * modules. If a key is bound in both sets of modules, only the binding from the override modules * is kept. If a single {@link PrivateModule} is supplied or all elements are from * a single {@link PrivateBinder}, then this will overwrite the private bindings. * Otherwise, private bindings will not be overwritten unless they are exposed. * This can be used to replace the bindings of a production module with test bindings: *

       * Module functionalTestModule
       *     = Modules.override(getProductionModules()).with(getTestModules());
       * 
    * *

    Prefer to write smaller modules that can be reused and tested without overrides. * * @param modules the modules whose bindings are open to be overridden */ public static OverriddenModuleBuilder override(Iterable modules) { return new RealOverriddenModuleBuilder(modules); } /** * Returns a new module that installs all of {@code modules}. */ public static Module combine(Module... modules) { return combine(ImmutableSet.copyOf(modules)); } /** * Returns a new module that installs all of {@code modules}. */ public static Module combine(Iterable modules) { final Set modulesSet = ImmutableSet.copyOf(modules); return new Module() { public void configure(Binder binder) { binder = binder.skipSources(getClass()); for (Module module : modulesSet) { binder.install(module); } } }; } /** * See the EDSL example at {@link Modules#override(Module[]) override()}. */ public interface OverriddenModuleBuilder { /** * See the EDSL example at {@link Modules#override(Module[]) override()}. */ Module with(Module... overrides); /** * See the EDSL example at {@link Modules#override(Module[]) override()}. */ Module with(Iterable overrides); } private static final class RealOverriddenModuleBuilder implements OverriddenModuleBuilder { private final ImmutableSet baseModules; private RealOverriddenModuleBuilder(Iterable baseModules) { this.baseModules = ImmutableSet.copyOf(baseModules); } public Module with(Module... overrides) { return with(Arrays.asList(overrides)); } public Module with(final Iterable overrides) { return new AbstractModule() { @Override public void configure() { Binder baseBinder = binder(); List baseElements = Elements.getElements(baseModules); // If the sole element was a PrivateElements, we want to override // the private elements within that -- so refocus our elements // and binder. if(baseElements.size() == 1) { Element element = Iterables.getOnlyElement(baseElements); if(element instanceof PrivateElements) { PrivateElements privateElements = (PrivateElements)element; PrivateBinder privateBinder = baseBinder.newPrivateBinder().withSource(privateElements.getSource()); for(Key exposed : privateElements.getExposedKeys()) { privateBinder.withSource(privateElements.getExposedSource(exposed)).expose(exposed); } baseBinder = privateBinder; baseElements = privateElements.getElements(); } } final Binder binder = baseBinder; final LinkedHashSet elements = new LinkedHashSet(baseElements); final List overrideElements = Elements.getElements(overrides); final Set> overriddenKeys = Sets.newHashSet(); final Set> overridesScopeAnnotations = Sets.newHashSet(); // execute the overrides module, keeping track of which keys and scopes are bound new ModuleWriter(binder) { @Override public Void visit(Binding binding) { overriddenKeys.add(binding.getKey()); return super.visit(binding); } @Override public Void visit(ScopeBinding scopeBinding) { overridesScopeAnnotations.add(scopeBinding.getAnnotationType()); return super.visit(scopeBinding); } @Override public Void visit(PrivateElements privateElements) { overriddenKeys.addAll(privateElements.getExposedKeys()); return super.visit(privateElements); } }.writeAll(overrideElements); // execute the original module, skipping all scopes and overridden keys. We only skip each // overridden binding once so things still blow up if the module binds the same thing // multiple times. final Map scopeInstancesInUse = Maps.newHashMap(); final List scopeBindings = Lists.newArrayList(); new ModuleWriter(binder) { @Override public Void visit(Binding binding) { if (!overriddenKeys.remove(binding.getKey())) { super.visit(binding); // Record when a scope instance is used in a binding Scope scope = getScopeInstanceOrNull(binding); if (scope != null) { scopeInstancesInUse.put(scope, binding.getSource()); } } return null; } void rewrite(Binder binder, PrivateElements privateElements, Set> keysToSkip) { PrivateBinder privateBinder = binder.withSource(privateElements.getSource()) .newPrivateBinder(); Set> skippedExposes = Sets.newHashSet(); for (Key key : privateElements.getExposedKeys()) { if (keysToSkip.remove(key)) { skippedExposes.add(key); } else { privateBinder.withSource(privateElements.getExposedSource(key)).expose(key); } } for (Element element : privateElements.getElements()) { if (element instanceof Binding && skippedExposes.remove(((Binding) element).getKey())) { continue; } if (element instanceof PrivateElements) { rewrite(privateBinder, (PrivateElements) element, skippedExposes); continue; } element.applyTo(privateBinder); } } @Override public Void visit(PrivateElements privateElements) { rewrite(binder, privateElements, overriddenKeys); return null; } @Override public Void visit(ScopeBinding scopeBinding) { scopeBindings.add(scopeBinding); return null; } }.writeAll(elements); // execute the scope bindings, skipping scopes that have been overridden. Any scope that // is overridden and in active use will prompt an error new ModuleWriter(binder) { @Override public Void visit(ScopeBinding scopeBinding) { if (!overridesScopeAnnotations.remove(scopeBinding.getAnnotationType())) { super.visit(scopeBinding); } else { Object source = scopeInstancesInUse.get(scopeBinding.getScope()); if (source != null) { binder.withSource(source).addError( "The scope for @%s is bound directly and cannot be overridden.", scopeBinding.getAnnotationType().getSimpleName()); } } return null; } }.writeAll(scopeBindings); // TODO: bind the overridden keys using multibinder } private Scope getScopeInstanceOrNull(Binding binding) { return binding.acceptScopingVisitor(new DefaultBindingScopingVisitor() { public Scope visitScope(Scope scope) { return scope; } }); } }; } } private static class ModuleWriter extends DefaultElementVisitor { protected final Binder binder; ModuleWriter(Binder binder) { this.binder = binder; } @Override protected Void visitOther(Element element) { element.applyTo(binder); return null; } void writeAll(Iterable elements) { for (Element element : elements) { element.acceptVisitor(this); } } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/0000755000175000017500000000000011704661106022232 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/package-info.java0000644000175000017500000000123711704661106025424 0ustar tonytony/* * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Guice service provider interface */ package com.google.inject.spi;sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/UntargettedBinding.java0000644000175000017500000000165011704661106026660 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binding; /** * An untargetted binding. This binding indicates that the injector should use its implicit binding * strategies to resolve injections. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public interface UntargettedBinding extends Binding {} sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/TypeListenerBinding.java0000644000175000017500000000404411704661106027021 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binder; import com.google.inject.TypeLiteral; import com.google.inject.matcher.Matcher; /** * Binds types (picked using a Matcher) to an type listener. Registrations are created explicitly in * a module using {@link com.google.inject.Binder#bindListener(Matcher, TypeListener)} statements: * *

     *     register(only(new TypeLiteral<PaymentService<CreditCard>>() {}), listener);
    * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public final class TypeListenerBinding implements Element { private final Object source; private final Matcher> typeMatcher; private final TypeListener listener; TypeListenerBinding(Object source, TypeListener listener, Matcher> typeMatcher) { this.source = source; this.listener = listener; this.typeMatcher = typeMatcher; } /** Returns the registered listener. */ public TypeListener getListener() { return listener; } /** Returns the type matcher which chooses which types the listener should be notified of. */ public Matcher> getTypeMatcher() { return typeMatcher; } public Object getSource() { return source; } public T acceptVisitor(ElementVisitor visitor) { return visitor.visit(this); } public void applyTo(Binder binder) { binder.withSource(getSource()).bindListener(typeMatcher, listener); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/TypeListener.java0000644000175000017500000000336711704661106025535 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.TypeLiteral; /** * Listens for Guice to encounter injectable types. If a given type has its constructor injected in * one situation but only its methods and fields injected in another, Guice will notify this * listener once. * *

    Useful for extra type checking, {@linkplain TypeEncounter#register(InjectionListener) * registering injection listeners}, and {@linkplain TypeEncounter#bindInterceptor( * com.google.inject.matcher.Matcher, org.aopalliance.intercept.MethodInterceptor[]) * binding method interceptors}. * * @since 2.0 */ public interface TypeListener { /** * Invoked when Guice encounters a new type eligible for constructor or members injection. * Called during injector creation (or afterwords if Guice encounters a type at run time and * creates a JIT binding). * * @param type encountered by Guice * @param encounter context of this encounter, enables reporting errors, registering injection * listeners and binding method interceptors for {@code type}. * * @param the injectable type */ void hear(TypeLiteral type, TypeEncounter encounter); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/TypeEncounter.java0000644000175000017500000001135011704661106025701 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Key; import com.google.inject.MembersInjector; import com.google.inject.Provider; import com.google.inject.TypeLiteral; import com.google.inject.matcher.Matcher; import java.lang.reflect.Method; /** * Context of an injectable type encounter. Enables reporting errors, registering injection * listeners and binding method interceptors for injectable type {@code I}. It is an error to use * an encounter after the {@link TypeListener#hear(TypeLiteral, TypeEncounter) hear()} method has * returned. * * @param the injectable type encountered * @since 2.0 */ public interface TypeEncounter { /** * Records an error message for type {@code I} which will be presented to the user at a later * time. Unlike throwing an exception, this enable us to continue configuring the Injector and * discover more errors. Uses {@link String#format(String, Object[])} to insert the arguments * into the message. */ void addError(String message, Object... arguments); /** * Records an exception for type {@code I}, the full details of which will be logged, and the * message of which will be presented to the user at a later time. If your type listener calls * something that you worry may fail, you should catch the exception and pass it to this method. */ void addError(Throwable t); /** * Records an error message to be presented to the user at a later time. */ void addError(Message message); /** * Returns the provider used to obtain instances for the given injection key. The returned * provider will not be valid until the injector has been created. The provider will throw an * {@code IllegalStateException} if you try to use it beforehand. */ Provider getProvider(Key key); /** * Returns the provider used to obtain instances for the given injection type. The returned * provider will not be valid until the injetor has been created. The provider will throw an * {@code IllegalStateException} if you try to use it beforehand. */ Provider getProvider(Class type); /** * Returns the members injector used to inject dependencies into methods and fields on instances * of the given type {@code T}. The returned members injector will not be valid until the main * injector has been created. The members injector will throw an {@code IllegalStateException} * if you try to use it beforehand. * * @param typeLiteral type to get members injector for */ MembersInjector getMembersInjector(TypeLiteral typeLiteral); /** * Returns the members injector used to inject dependencies into methods and fields on instances * of the given type {@code T}. The returned members injector will not be valid until the main * injector has been created. The members injector will throw an {@code IllegalStateException} * if you try to use it beforehand. * * @param type type to get members injector for */ MembersInjector getMembersInjector(Class type); /** * Registers a members injector for type {@code I}. Guice will use the members injector after its * performed its own injections on an instance of {@code I}. */ void register(MembersInjector membersInjector); /** * Registers an injection listener for type {@code I}. Guice will notify the listener after all * injections have been performed on an instance of {@code I}. */ void register(InjectionListener listener); /*if[AOP]*/ /** * Binds method interceptor[s] to methods matched in type {@code I} and its supertypes. A * method is eligible for interception if: * *

      *
    • Guice created the instance the method is on
    • *
    • Neither the enclosing type nor the method is final
    • *
    • And the method is package-private or more accessible
    • *
    * * @param methodMatcher matches methods the interceptor should apply to. For * example: {@code annotatedWith(Transactional.class)}. * @param interceptors to bind */ void bindInterceptor(Matcher methodMatcher, org.aopalliance.intercept.MethodInterceptor... interceptors); /*end[AOP]*/ } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/TypeConverterBinding.java0000644000175000017500000000443311704661106027205 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Binder; import com.google.inject.TypeLiteral; import com.google.inject.matcher.Matcher; /** * Registration of type converters for matching target types. Instances are created * explicitly in a module using {@link com.google.inject.Binder#convertToTypes(Matcher, * TypeConverter) convertToTypes()} statements: *
     *     convertToTypes(Matchers.only(TypeLiteral.get(DateTime.class)), new DateTimeConverter());
    * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public final class TypeConverterBinding implements Element { private final Object source; private final Matcher> typeMatcher; private final TypeConverter typeConverter; /** @since 3.0 */ public TypeConverterBinding(Object source, Matcher> typeMatcher, TypeConverter typeConverter) { this.source = checkNotNull(source, "source"); this.typeMatcher = checkNotNull(typeMatcher, "typeMatcher"); this.typeConverter = checkNotNull(typeConverter, "typeConverter"); } public Object getSource() { return source; } public Matcher> getTypeMatcher() { return typeMatcher; } public TypeConverter getTypeConverter() { return typeConverter; } public T acceptVisitor(ElementVisitor visitor) { return visitor.visit(this); } public void applyTo(Binder binder) { binder.withSource(getSource()).convertToTypes(typeMatcher, typeConverter); } @Override public String toString() { return typeConverter + " which matches " + typeMatcher + " (bound at " + source + ")"; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/TypeConverter.java0000644000175000017500000000171411704661106025711 0ustar tonytony/* * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.TypeLiteral; /** * Converts constant string values to a different type. * * @author crazybob@google.com (Bob Lee) * @since 2.0 */ public interface TypeConverter { /** * Converts a string value. Throws an exception if a conversion error occurs. */ Object convert(String value, TypeLiteral toType); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/Toolable.java0000644000175000017500000000204011704661106024632 0ustar tonytonypackage com.google.inject.spi; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.Injector; import com.google.inject.Stage; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * Instructs an {@link Injector} running in {@link Stage#TOOL} that a method should be injected. * This is typically useful for for extensions to Guice that perform additional validation in an * injected method or field. This only applies to objects that are already constructed when * bindings are created (ie., something bound using {@link * com.google.inject.binder.LinkedBindingBuilder#toProvider toProvider}, {@link * com.google.inject.binder.LinkedBindingBuilder#toInstance toInstance}, or {@link * com.google.inject.Binder#requestInjection requestInjection}. * * @author sberlin@gmail.com (Sam Berlin) * @since 3.0 */ @Target({ METHOD }) @Retention(RUNTIME) @Documented public @interface Toolable { } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/StaticInjectionRequest.java0000644000175000017500000000513211704661106027541 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Binder; import com.google.inject.ConfigurationException; import java.util.Set; /** * A request to inject the static fields and methods of a type. Requests are created * explicitly in a module using {@link com.google.inject.Binder#requestStaticInjection(Class[]) * requestStaticInjection()} statements: *
     *     requestStaticInjection(MyLegacyService.class);
    * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public final class StaticInjectionRequest implements Element { private final Object source; private final Class type; StaticInjectionRequest(Object source, Class type) { this.source = checkNotNull(source, "source"); this.type = checkNotNull(type, "type"); } public Object getSource() { return source; } public Class getType() { return type; } /** * Returns the static methods and fields of {@code type} that will be injected to fulfill this * request. * * @return a possibly empty set of injection points. The set has a specified iteration order. All * fields are returned and then all methods. Within the fields, supertype fields are returned * before subtype fields. Similarly, supertype methods are returned before subtype methods. * @throws ConfigurationException if there is a malformed injection point on {@code type}, such as * a field with multiple binding annotations. The exception's {@link * ConfigurationException#getPartialValue() partial value} is a {@code Set} * of the valid injection points. */ public Set getInjectionPoints() throws ConfigurationException { return InjectionPoint.forStaticMethodsAndFields(type); } public void applyTo(Binder binder) { binder.withSource(getSource()).requestStaticInjection(type); } public T acceptVisitor(ElementVisitor visitor) { return visitor.visit(this); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/ScopeBinding.java0000644000175000017500000000400111704661106025434 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Binder; import com.google.inject.Scope; import java.lang.annotation.Annotation; /** * Registration of a scope annotation with the scope that implements it. Instances are created * explicitly in a module using {@link com.google.inject.Binder#bindScope(Class, Scope) bindScope()} * statements: *
     *     Scope recordScope = new RecordScope();
     *     bindScope(RecordScoped.class, new RecordScope());
    * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public final class ScopeBinding implements Element { private final Object source; private final Class annotationType; private final Scope scope; ScopeBinding(Object source, Class annotationType, Scope scope) { this.source = checkNotNull(source, "source"); this.annotationType = checkNotNull(annotationType, "annotationType"); this.scope = checkNotNull(scope, "scope"); } public Object getSource() { return source; } public Class getAnnotationType() { return annotationType; } public Scope getScope() { return scope; } public T acceptVisitor(ElementVisitor visitor) { return visitor.visit(this); } public void applyTo(Binder binder) { binder.withSource(getSource()).bindScope(annotationType, scope); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/RequireExplicitBindingsOption.java0000644000175000017500000000242411704661106031064 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Binder; /** * A request to require explicit bindings. * * @author sameb@google.com (Sam Berlin) * @since 3.0 */ public final class RequireExplicitBindingsOption implements Element { private final Object source; RequireExplicitBindingsOption(Object source) { this.source = checkNotNull(source, "source"); } public Object getSource() { return source; } public void applyTo(Binder binder) { binder.withSource(getSource()).requireExplicitBindings(); } public T acceptVisitor(ElementVisitor visitor) { return visitor.visit(this); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/ProvisionListenerBinding.java0000644000175000017500000000411011704661106030062 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.common.collect.ImmutableList; import com.google.inject.Binder; import com.google.inject.Key; import com.google.inject.matcher.Matcher; import java.util.List; /** * Binds keys (picked using a Matcher) to a provision listener. Listeners are created explicitly in * a module using {@link Binder#bindListener(Matcher, ProvisionListener)} statements: * * @author sameb@google.com (Sam Berlin) * @since 4.0 */ public final class ProvisionListenerBinding implements Element { private final Object source; private final Matcher> keyMatcher; private final List listeners; ProvisionListenerBinding(Object source, Matcher> typeMatcher, ProvisionListener[] listeners) { this.source = source; this.keyMatcher = typeMatcher; this.listeners = ImmutableList.copyOf(listeners); } /** Returns the registered listeners. */ public List getListeners() { return listeners; } /** Returns the key matcher which chooses which keys the listener should be notified of. */ public Matcher> getKeyMatcher() { return keyMatcher; } public Object getSource() { return source; } public R acceptVisitor(ElementVisitor visitor) { return visitor.visit(this); } public void applyTo(Binder binder) { binder.withSource(getSource()).bindListener(keyMatcher, listeners.toArray(new ProvisionListener[listeners.size()])); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/ProvisionListener.java0000644000175000017500000000453611704661106026603 0ustar tonytony/* * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.google.inject.spi; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.Scope; import java.util.List; /** * Listens for provisioning of objects. Useful for gathering timing information * about provisioning, post-provision initialization, and more. * * @author sameb@google.com (Sam Berlin) * @since 4.0 */ public interface ProvisionListener { /** * Invoked by Guice when an object requires provisioning. Provisioning occurs * when Guice locates and injects the dependencies for a binding. For types * bound to a Provider, provisioning encapsulates the {@link Provider#get} * method. For other types, provisioning encapsulates the construction of the * object. If a type is bound within a {@link Scope}, provisioning depends on * the scope. Types bound in Singleton scope will only be provisioned once. * Types bound in no scope will be provisioned every time they are injected. * Other scopes define their own behavior for provisioning. *

    * To perform the provision, call {@link ProvisionInvocation#provision()}. * If you do not explicitly call provision, it will be automatically done after * this method returns. It is an error to call provision more than once. */ void onProvision(ProvisionInvocation provision); /** Encapsulates a single act of provisioning.*/ public abstract static class ProvisionInvocation { /** Returns the Key which will be provisioned. */ public abstract Key getKey(); /** Performs the provision, returning the object provisioned. */ public abstract T provision(); /** Returns the dependency chain that led to this object being provisioned. */ public abstract List getDependencyChain(); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/ProviderWithExtensionVisitor.java0000644000175000017500000000465111704661106031006 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binding; import com.google.inject.Provider; /** * A Provider that is part of an extension which supports a custom * BindingTargetVisitor. *

    * When an extension binds a provider instance, the provider can implement this * interface to allow users using the * {@link Binding#acceptTargetVisitor(BindingTargetVisitor)} method to visit a * custom visitor designed for that extension. A typical implementation within * the extension would look like *

     
     * <V, B> V acceptExtensionVisitor(BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding) {
     *   if(visitor instanceof MyCustomExtensionVisitor) {
     *     return ((MyCustomExtensionVisitor<B, V>)visitor).visitCustomExtension(customProperties, binding);
     *   } else {
     *     return visitor.visit(binding);
     *   }
     * }
    * 'MyCustomExtensionVisitor' in the example above would be an interface the * extension provides that users can implement in order to be notified of custom * extension information. These visitor interfaces must extend from * BindingTargetVisitor. * * @since 3.0 * @author sameb@google.com (Sam Berlin) */ public interface ProviderWithExtensionVisitor extends Provider { /** * Instructs the extension determine if the visitor is an instance of a custom * extension visitor, and if so, visit it using that method. If the visitor is * not an instance of the custom extension visitor, this method MUST * call visitor.visit(binding). *

    * Due to issues with generics, the type parameters of this method do not * relate to the type of the provider. In practice, the 'B' type will always * be a supertype of 'T'. */ V acceptExtensionVisitor(BindingTargetVisitor visitor, ProviderInstanceBinding binding); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/ProviderWithDependencies.java0000644000175000017500000000171111704661106030032 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Provider; /** * A provider with dependencies on other injected types. If a {@link Provider} has dependencies that * aren't specified in injections, this interface should be used to expose all dependencies. * * @since 2.0 */ public interface ProviderWithDependencies extends Provider, HasDependencies {} sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/ProviderLookup.java0000644000175000017500000000575311704661106026073 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import com.google.inject.Binder; import com.google.inject.Key; import com.google.inject.Provider; /** * A lookup of the provider for a type. Lookups are created explicitly in a module using * {@link com.google.inject.Binder#getProvider(Class) getProvider()} statements: *

     *     Provider<PaymentService> paymentServiceProvider
     *         = getProvider(PaymentService.class);
    * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public final class ProviderLookup implements Element { private final Object source; private final Key key; private Provider delegate; public ProviderLookup(Object source, Key key) { this.source = checkNotNull(source, "source"); this.key = checkNotNull(key, "key"); } public Object getSource() { return source; } public Key getKey() { return key; } public T acceptVisitor(ElementVisitor visitor) { return visitor.visit(this); } /** * Sets the actual provider. * * @throws IllegalStateException if the delegate is already set */ public void initializeDelegate(Provider delegate) { checkState(this.delegate == null, "delegate already initialized"); this.delegate = checkNotNull(delegate, "delegate"); } public void applyTo(Binder binder) { initializeDelegate(binder.withSource(getSource()).getProvider(key)); } /** * Returns the delegate provider, or {@code null} if it has not yet been initialized. The delegate * will be initialized when this element is processed, or otherwise used to create an injector. */ public Provider getDelegate() { return delegate; } /** * Returns the looked up provider. The result is not valid until this lookup has been initialized, * which usually happens when the injector is created. The provider will throw an {@code * IllegalStateException} if you try to use it beforehand. */ public Provider getProvider() { return new Provider() { public T get() { checkState(delegate != null, "This Provider cannot be used until the Injector has been created."); return delegate.get(); } @Override public String toString() { return "Provider<" + key.getTypeLiteral() + ">"; } }; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/ProviderKeyBinding.java0000644000175000017500000000236311704661106026637 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binding; import com.google.inject.Key; /** * A binding to a provider key. To resolve injections, the provider key is first resolved, then that * provider's {@code get} method is invoked. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public interface ProviderKeyBinding extends Binding { /** * Returns the key used to resolve the provider's binding. That binding can be retrieved from an * injector using {@link com.google.inject.Injector#getBinding(Key) * Injector.getBinding(providerKey)} */ Key> getProviderKey(); }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/ProviderInstanceBinding.java0000644000175000017500000000243511704661106027653 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binding; import com.google.inject.Provider; import java.util.Set; /** * A binding to a provider instance. The provider's {@code get} method is invoked to resolve * injections. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public interface ProviderInstanceBinding extends Binding, HasDependencies { /** * Returns the user-supplied, unscoped provider. */ Provider getProviderInstance(); /** * Returns the field and method injection points of the provider, injected at injector-creation * time only. * * @return a possibly empty set */ Set getInjectionPoints(); }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/ProviderBinding.java0000644000175000017500000000251311704661106026163 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binding; import com.google.inject.Key; import com.google.inject.Provider; /** * A binding to a {@link Provider} that delegates to the binding for the provided type. This binding * is used whenever a {@code Provider} is injected (as opposed to injecting {@code T} directly). * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public interface ProviderBinding> extends Binding { /** * Returns the key whose binding is used to {@link Provider#get provide instances}. That binding * can be retrieved from an injector using {@link com.google.inject.Injector#getBinding(Key) * Injector.getBinding(providedKey)} */ Key getProvidedKey(); }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/PrivateElements.java0000644000175000017500000000362511704661106026212 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Injector; import com.google.inject.Key; import java.util.List; import java.util.Set; /** * A private collection of elements that are hidden from the enclosing injector or module by * default. See {@link com.google.inject.PrivateModule PrivateModule} for details. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public interface PrivateElements extends Element { /** * Returns the configuration information in this private environment. */ List getElements(); /** * Returns the child injector that hosts these private elements, or null if the elements haven't * been used to create an injector. */ Injector getInjector(); /** * Returns the unique exposed keys for these private elements. */ Set> getExposedKeys(); /** * Returns an arbitrary object containing information about the "place" where this key was * exposed. Used by Guice in the production of descriptive error messages. * *

    Tools might specially handle types they know about; {@code StackTraceElement} is a good * example. Tools should simply call {@code toString()} on the source object if the type is * unfamiliar. * * @param key one of the keys exposed by this module. */ Object getExposedSource(Key key); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/Message.java0000644000175000017500000000731511704661106024467 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; import com.google.inject.Binder; import com.google.inject.internal.Errors; import com.google.inject.internal.util.SourceProvider; import java.io.ObjectStreamException; import java.io.Serializable; import java.util.List; /** * An error message and the context in which it occured. Messages are usually created internally by * Guice and its extensions. Messages can be created explicitly in a module using {@link * com.google.inject.Binder#addError(Throwable) addError()} statements: *

     *     try {
     *       bindPropertiesFromFile();
     *     } catch (IOException e) {
     *       addError(e);
     *     }
    * * @author crazybob@google.com (Bob Lee) */ public final class Message implements Serializable, Element { private final String message; private final Throwable cause; private final List sources; /** * @since 2.0 */ public Message(List sources, String message, Throwable cause) { this.sources = ImmutableList.copyOf(sources); this.message = checkNotNull(message, "message"); this.cause = cause; } public Message(Object source, String message) { this(ImmutableList.of(source), message, null); } public Message(String message) { this(ImmutableList.of(), message, null); } public String getSource() { return sources.isEmpty() ? SourceProvider.UNKNOWN_SOURCE.toString() : Errors.convert(sources.get(sources.size() - 1)).toString(); } /** @since 2.0 */ public List getSources() { return sources; } /** * Gets the error message text. */ public String getMessage() { return message; } /** @since 2.0 */ public T acceptVisitor(ElementVisitor visitor) { return visitor.visit(this); } /** * Returns the throwable that caused this message, or {@code null} if this * message was not caused by a throwable. * * @since 2.0 */ public Throwable getCause() { return cause; } @Override public String toString() { return message; } @Override public int hashCode() { return message.hashCode(); } @Override public boolean equals(Object o) { if (!(o instanceof Message)) { return false; } Message e = (Message) o; return message.equals(e.message) && Objects.equal(cause, e.cause) && sources.equals(e.sources); } /** @since 2.0 */ public void applyTo(Binder binder) { binder.withSource(getSource()).addError(this); } /** * When serialized, we eagerly convert sources to strings. This hurts our formatting, but it * guarantees that the receiving end will be able to read the message. */ private Object writeReplace() throws ObjectStreamException { Object[] sourcesAsStrings = sources.toArray(); for (int i = 0; i < sourcesAsStrings.length; i++) { sourcesAsStrings[i] = Errors.convert(sourcesAsStrings[i]).toString(); } return new Message(ImmutableList.copyOf(sourcesAsStrings), message, cause); } private static final long serialVersionUID = 0; } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/MembersInjectorLookup.java0000644000175000017500000000637111704661106027366 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import com.google.inject.Binder; import com.google.inject.MembersInjector; import com.google.inject.TypeLiteral; /** * A lookup of the members injector for a type. Lookups are created explicitly in a module using * {@link com.google.inject.Binder#getMembersInjector(Class) getMembersInjector()} statements: *
     *     MembersInjector<PaymentService> membersInjector
     *         = getMembersInjector(PaymentService.class);
    * * @author crazybob@google.com (Bob Lee) * @since 2.0 */ public final class MembersInjectorLookup implements Element { private final Object source; private final TypeLiteral type; private MembersInjector delegate; public MembersInjectorLookup(Object source, TypeLiteral type) { this.source = checkNotNull(source, "source"); this.type = checkNotNull(type, "type"); } public Object getSource() { return source; } /** * Gets the type containing the members to be injected. */ public TypeLiteral getType() { return type; } public T acceptVisitor(ElementVisitor visitor) { return visitor.visit(this); } /** * Sets the actual members injector. * * @throws IllegalStateException if the delegate is already set */ public void initializeDelegate(MembersInjector delegate) { checkState(this.delegate == null, "delegate already initialized"); this.delegate = checkNotNull(delegate, "delegate"); } public void applyTo(Binder binder) { initializeDelegate(binder.withSource(getSource()).getMembersInjector(type)); } /** * Returns the delegate members injector, or {@code null} if it has not yet been initialized. * The delegate will be initialized when this element is processed, or otherwise used to create * an injector. */ public MembersInjector getDelegate() { return delegate; } /** * Returns the looked up members injector. The result is not valid until this lookup has been * initialized, which usually happens when the injector is created. The members injector will * throw an {@code IllegalStateException} if you try to use it beforehand. */ public MembersInjector getMembersInjector() { return new MembersInjector() { public void injectMembers(T instance) { checkState(delegate != null, "This MembersInjector cannot be used until the Injector has been created."); delegate.injectMembers(instance); } @Override public String toString() { return "MembersInjector<" + type + ">"; } }; } }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/LinkedKeyBinding.java0000644000175000017500000000220011704661106026241 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binding; import com.google.inject.Key; /** * A binding to a linked key. The other key's binding is used to resolve injections. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public interface LinkedKeyBinding extends Binding { /** * Returns the linked key used to resolve injections. That binding can be retrieved from an * injector using {@link com.google.inject.Injector#getBinding(Key) Injector.getBinding(key)}. */ Key getLinkedKey(); }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/InterceptorBinding.java0000644000175000017500000000553111704661106026672 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.ImmutableList; import com.google.inject.Binder; import com.google.inject.matcher.Matcher; import org.aopalliance.intercept.MethodInterceptor; import java.lang.reflect.Method; import java.util.List; /** * Registration of interceptors for matching methods of matching classes. Instances are created * explicitly in a module using {@link com.google.inject.Binder#bindInterceptor( * Matcher, Matcher, MethodInterceptor[]) bindInterceptor()} statements: *
     *     bindInterceptor(Matchers.subclassesOf(MyAction.class),
     *         Matchers.annotatedWith(Transactional.class),
     *         new MyTransactionInterceptor());
    * * or from an injectable type listener using {@link TypeEncounter#bindInterceptor(Matcher, * org.aopalliance.intercept.MethodInterceptor[]) TypeEncounter.bindInterceptor()}. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public final class InterceptorBinding implements Element { private final Object source; private final Matcher> classMatcher; private final Matcher methodMatcher; private final ImmutableList interceptors; InterceptorBinding( Object source, Matcher> classMatcher, Matcher methodMatcher, MethodInterceptor[] interceptors) { this.source = checkNotNull(source, "source"); this.classMatcher = checkNotNull(classMatcher, "classMatcher"); this.methodMatcher = checkNotNull(methodMatcher, "methodMatcher"); this.interceptors = ImmutableList.copyOf(interceptors); } public Object getSource() { return source; } public Matcher> getClassMatcher() { return classMatcher; } public Matcher getMethodMatcher() { return methodMatcher; } public List getInterceptors() { return interceptors; } public T acceptVisitor(ElementVisitor visitor) { return visitor.visit(this); } public void applyTo(Binder binder) { binder.withSource(getSource()).bindInterceptor(classMatcher, methodMatcher, interceptors.toArray(new MethodInterceptor[interceptors.size()])); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/InstanceBinding.java0000644000175000017500000000226711704661106026143 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binding; import java.util.Set; /** * A binding to a single instance. The same instance is returned for every injection. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public interface InstanceBinding extends Binding, HasDependencies { /** * Returns the user-supplied instance. */ T getInstance(); /** * Returns the field and method injection points of the instance, injected at injector-creation * time only. * * @return a possibly empty set */ Set getInjectionPoints(); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/InjectionRequest.java0000644000175000017500000000547211704661106026400 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Binder; import com.google.inject.ConfigurationException; import com.google.inject.TypeLiteral; import java.util.Set; /** * A request to inject the instance fields and methods of an instance. Requests are created * explicitly in a module using {@link com.google.inject.Binder#requestInjection(Object) * requestInjection()} statements: *
     *     requestInjection(serviceInstance);
    * * @author mikeward@google.com (Mike Ward) * @since 2.0 */ public final class InjectionRequest implements Element { private final Object source; private final TypeLiteral type; private final T instance; public InjectionRequest(Object source, TypeLiteral type, T instance) { this.source = checkNotNull(source, "source"); this.type = checkNotNull(type, "type"); this.instance = checkNotNull(instance, "instance"); } public Object getSource() { return source; } public T getInstance() { return instance; } public TypeLiteral getType() { return type; } /** * Returns the instance methods and fields of {@code instance} that will be injected to fulfill * this request. * * @return a possibly empty set of injection points. The set has a specified iteration order. All * fields are returned and then all methods. Within the fields, supertype fields are returned * before subtype fields. Similarly, supertype methods are returned before subtype methods. * @throws ConfigurationException if there is a malformed injection point on the class of {@code * instance}, such as a field with multiple binding annotations. The exception's {@link * ConfigurationException#getPartialValue() partial value} is a {@code Set} * of the valid injection points. */ public Set getInjectionPoints() throws ConfigurationException { return InjectionPoint.forInstanceMethodsAndFields(instance.getClass()); } public R acceptVisitor(ElementVisitor visitor) { return visitor.visit(this); } public void applyTo(Binder binder) { binder.withSource(getSource()).requestInjection(type, instance); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/InjectionPoint.java0000644000175000017500000007354311704661106026045 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.inject.internal.MoreTypes.getRawType; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.inject.ConfigurationException; import com.google.inject.Inject; import com.google.inject.Key; import com.google.inject.TypeLiteral; import com.google.inject.internal.Annotations; import com.google.inject.internal.Errors; import com.google.inject.internal.ErrorsException; import com.google.inject.internal.Nullability; import com.google.inject.internal.util.Classes; import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; /** * A constructor, field or method that can receive injections. Typically this is a member with the * {@literal @}{@link Inject} annotation. For non-private, no argument constructors, the member may * omit the annotation. * * @author crazybob@google.com (Bob Lee) * @since 2.0 */ public final class InjectionPoint { private static final Logger logger = Logger.getLogger(InjectionPoint.class.getName()); private final boolean optional; private final Member member; private final TypeLiteral declaringType; private final ImmutableList> dependencies; InjectionPoint(TypeLiteral declaringType, Method method, boolean optional) { this.member = method; this.declaringType = declaringType; this.optional = optional; this.dependencies = forMember(method, declaringType, method.getParameterAnnotations()); } InjectionPoint(TypeLiteral declaringType, Constructor constructor) { this.member = constructor; this.declaringType = declaringType; this.optional = false; this.dependencies = forMember( constructor, declaringType, constructor.getParameterAnnotations()); } InjectionPoint(TypeLiteral declaringType, Field field, boolean optional) { this.member = field; this.declaringType = declaringType; this.optional = optional; Annotation[] annotations = field.getAnnotations(); Errors errors = new Errors(field); Key key = null; try { key = Annotations.getKey(declaringType.getFieldType(field), field, annotations, errors); } catch (ConfigurationException e) { errors.merge(e.getErrorMessages()); } catch (ErrorsException e) { errors.merge(e.getErrors()); } errors.throwConfigurationExceptionIfErrorsExist(); this.dependencies = ImmutableList.>of( newDependency(key, Nullability.allowsNull(annotations), -1)); } private ImmutableList> forMember(Member member, TypeLiteral type, Annotation[][] paramterAnnotations) { Errors errors = new Errors(member); Iterator annotationsIterator = Arrays.asList(paramterAnnotations).iterator(); List> dependencies = Lists.newArrayList(); int index = 0; for (TypeLiteral parameterType : type.getParameterTypes(member)) { try { Annotation[] parameterAnnotations = annotationsIterator.next(); Key key = Annotations.getKey(parameterType, member, parameterAnnotations, errors); dependencies.add(newDependency(key, Nullability.allowsNull(parameterAnnotations), index)); index++; } catch (ConfigurationException e) { errors.merge(e.getErrorMessages()); } catch (ErrorsException e) { errors.merge(e.getErrors()); } } errors.throwConfigurationExceptionIfErrorsExist(); return ImmutableList.copyOf(dependencies); } // This metohd is necessary to create a Dependency with proper generic type information private Dependency newDependency(Key key, boolean allowsNull, int parameterIndex) { return new Dependency(this, key, allowsNull, parameterIndex); } /** * Returns the injected constructor, field, or method. */ public Member getMember() { // TODO: Don't expose the original member (which probably has setAccessible(true)). return member; } /** * Returns the dependencies for this injection point. If the injection point is for a method or * constructor, the dependencies will correspond to that member's parameters. Field injection * points always have a single dependency for the field itself. * * @return a possibly-empty list */ public List> getDependencies() { return dependencies; } /** * Returns true if this injection point shall be skipped if the injector cannot resolve bindings * for all required dependencies. Both explicit bindings (as specified in a module), and implicit * bindings ({@literal @}{@link com.google.inject.ImplementedBy ImplementedBy}, default * constructors etc.) may be used to satisfy optional injection points. */ public boolean isOptional() { return optional; } /** * Returns true if the element is annotated with {@literal @}{@link Toolable}. * * @since 3.0 */ public boolean isToolable() { return ((AnnotatedElement)member).isAnnotationPresent(Toolable.class); } /** * Returns the generic type that defines this injection point. If the member exists on a * parameterized type, the result will include more type information than the member's {@link * Member#getDeclaringClass() raw declaring class}. * * @since 3.0 */ public TypeLiteral getDeclaringType() { return declaringType; } @Override public boolean equals(Object o) { return o instanceof InjectionPoint && member.equals(((InjectionPoint) o).member) && declaringType.equals(((InjectionPoint) o).declaringType); } @Override public int hashCode() { return member.hashCode() ^ declaringType.hashCode(); } @Override public String toString() { return Classes.toString(member); } /** * Returns a new injection point for the specified constructor. If the declaring type of {@code * constructor} is parameterized (such as {@code List}), prefer the overload that includes a * type literal. * * @param constructor any single constructor present on {@code type}. * * @since 3.0 */ public static InjectionPoint forConstructor(Constructor constructor) { return new InjectionPoint(TypeLiteral.get(constructor.getDeclaringClass()), constructor); } /** * Returns a new injection point for the specified constructor of {@code type}. * * @param constructor any single constructor present on {@code type}. * @param type the concrete type that defines {@code constructor}. * * @since 3.0 */ public static InjectionPoint forConstructor( Constructor constructor, TypeLiteral type) { if (type.getRawType() != constructor.getDeclaringClass()) { new Errors(type) .constructorNotDefinedByType(constructor, type) .throwConfigurationExceptionIfErrorsExist(); } return new InjectionPoint(type, constructor); } /** * Returns a new injection point for the injectable constructor of {@code type}. * * @param type a concrete type with exactly one constructor annotated {@literal @}{@link Inject}, * or a no-arguments constructor that is not private. * @throws ConfigurationException if there is no injectable constructor, more than one injectable * constructor, or if parameters of the injectable constructor are malformed, such as a * parameter with multiple binding annotations. */ public static InjectionPoint forConstructorOf(TypeLiteral type) { Class rawType = getRawType(type.getType()); Errors errors = new Errors(rawType); Constructor injectableConstructor = null; for (Constructor constructor : rawType.getDeclaredConstructors()) { boolean optional; Inject guiceInject = constructor.getAnnotation(Inject.class); if (guiceInject == null) { javax.inject.Inject javaxInject = constructor.getAnnotation(javax.inject.Inject.class); if (javaxInject == null) { continue; } optional = false; } else { optional = guiceInject.optional(); } if (optional) { errors.optionalConstructor(constructor); } if (injectableConstructor != null) { errors.tooManyConstructors(rawType); } injectableConstructor = constructor; checkForMisplacedBindingAnnotations(injectableConstructor, errors); } errors.throwConfigurationExceptionIfErrorsExist(); if (injectableConstructor != null) { return new InjectionPoint(type, injectableConstructor); } // If no annotated constructor is found, look for a no-arg constructor instead. try { Constructor noArgConstructor = rawType.getDeclaredConstructor(); // Disallow private constructors on non-private classes (unless they have @Inject) if (Modifier.isPrivate(noArgConstructor.getModifiers()) && !Modifier.isPrivate(rawType.getModifiers())) { errors.missingConstructor(rawType); throw new ConfigurationException(errors.getMessages()); } checkForMisplacedBindingAnnotations(noArgConstructor, errors); return new InjectionPoint(type, noArgConstructor); } catch (NoSuchMethodException e) { errors.missingConstructor(rawType); throw new ConfigurationException(errors.getMessages()); } } /** * Returns a new injection point for the injectable constructor of {@code type}. * * @param type a concrete type with exactly one constructor annotated {@literal @}{@link Inject}, * or a no-arguments constructor that is not private. * @throws ConfigurationException if there is no injectable constructor, more than one injectable * constructor, or if parameters of the injectable constructor are malformed, such as a * parameter with multiple binding annotations. */ public static InjectionPoint forConstructorOf(Class type) { return forConstructorOf(TypeLiteral.get(type)); } /** * Returns all static method and field injection points on {@code type}. * * @return a possibly empty set of injection points. The set has a specified iteration order. All * fields are returned and then all methods. Within the fields, supertype fields are returned * before subtype fields. Similarly, supertype methods are returned before subtype methods. * @throws ConfigurationException if there is a malformed injection point on {@code type}, such as * a field with multiple binding annotations. The exception's {@link * ConfigurationException#getPartialValue() partial value} is a {@code Set} * of the valid injection points. */ public static Set forStaticMethodsAndFields(TypeLiteral type) { Errors errors = new Errors(); Set result; if (type.getRawType().isInterface()) { errors.staticInjectionOnInterface(type.getRawType()); result = null; } else { result = getInjectionPoints(type, true, errors); } if (errors.hasErrors()) { throw new ConfigurationException(errors.getMessages()).withPartialValue(result); } return result; } /** * Returns all static method and field injection points on {@code type}. * * @return a possibly empty set of injection points. The set has a specified iteration order. All * fields are returned and then all methods. Within the fields, supertype fields are returned * before subtype fields. Similarly, supertype methods are returned before subtype methods. * @throws ConfigurationException if there is a malformed injection point on {@code type}, such as * a field with multiple binding annotations. The exception's {@link * ConfigurationException#getPartialValue() partial value} is a {@code Set} * of the valid injection points. */ public static Set forStaticMethodsAndFields(Class type) { return forStaticMethodsAndFields(TypeLiteral.get(type)); } /** * Returns all instance method and field injection points on {@code type}. * * @return a possibly empty set of injection points. The set has a specified iteration order. All * fields are returned and then all methods. Within the fields, supertype fields are returned * before subtype fields. Similarly, supertype methods are returned before subtype methods. * @throws ConfigurationException if there is a malformed injection point on {@code type}, such as * a field with multiple binding annotations. The exception's {@link * ConfigurationException#getPartialValue() partial value} is a {@code Set} * of the valid injection points. */ public static Set forInstanceMethodsAndFields(TypeLiteral type) { Errors errors = new Errors(); Set result = getInjectionPoints(type, false, errors); if (errors.hasErrors()) { throw new ConfigurationException(errors.getMessages()).withPartialValue(result); } return result; } /** * Returns all instance method and field injection points on {@code type}. * * @return a possibly empty set of injection points. The set has a specified iteration order. All * fields are returned and then all methods. Within the fields, supertype fields are returned * before subtype fields. Similarly, supertype methods are returned before subtype methods. * @throws ConfigurationException if there is a malformed injection point on {@code type}, such as * a field with multiple binding annotations. The exception's {@link * ConfigurationException#getPartialValue() partial value} is a {@code Set} * of the valid injection points. */ public static Set forInstanceMethodsAndFields(Class type) { return forInstanceMethodsAndFields(TypeLiteral.get(type)); } /** * Returns true if the binding annotation is in the wrong place. */ private static boolean checkForMisplacedBindingAnnotations(Member member, Errors errors) { Annotation misplacedBindingAnnotation = Annotations.findBindingAnnotation( errors, member, ((AnnotatedElement) member).getAnnotations()); if (misplacedBindingAnnotation == null) { return false; } // don't warn about misplaced binding annotations on methods when there's a field with the same // name. In Scala, fields always get accessor methods (that we need to ignore). See bug 242. if (member instanceof Method) { try { if (member.getDeclaringClass().getDeclaredField(member.getName()) != null) { return false; } } catch (NoSuchFieldException ignore) { } } errors.misplacedBindingAnnotation(member, misplacedBindingAnnotation); return true; } /** * Node in the doubly-linked list of injectable members (fields and methods). */ static abstract class InjectableMember { final TypeLiteral declaringType; final boolean optional; final boolean jsr330; InjectableMember previous; InjectableMember next; InjectableMember(TypeLiteral declaringType, Annotation atInject) { this.declaringType = declaringType; if (atInject.annotationType() == javax.inject.Inject.class) { optional = false; jsr330 = true; return; } jsr330 = false; optional = ((Inject) atInject).optional(); } abstract InjectionPoint toInjectionPoint(); } static class InjectableField extends InjectableMember { final Field field; InjectableField(TypeLiteral declaringType, Field field, Annotation atInject) { super(declaringType, atInject); this.field = field; } InjectionPoint toInjectionPoint() { return new InjectionPoint(declaringType, field, optional); } } static class InjectableMethod extends InjectableMember { final Method method; /** * true if this method overrode a method that was annotated * with com.google.inject.Inject. used to allow different * override behavior for guice inject vs javax.inject.Inject */ boolean overrodeGuiceInject; InjectableMethod(TypeLiteral declaringType, Method method, Annotation atInject) { super(declaringType, atInject); this.method = method; } InjectionPoint toInjectionPoint() { return new InjectionPoint(declaringType, method, optional); } public boolean isFinal() { return Modifier.isFinal(method.getModifiers()); } } static Annotation getAtInject(AnnotatedElement member) { Annotation a = member.getAnnotation(javax.inject.Inject.class); return a == null ? member.getAnnotation(Inject.class) : a; } /** * Linked list of injectable members. */ static class InjectableMembers { InjectableMember head; InjectableMember tail; void add(InjectableMember member) { if (head == null) { head = tail = member; } else { member.previous = tail; tail.next = member; tail = member; } } void remove(InjectableMember member) { if (member.previous != null) { member.previous.next = member.next; } if (member.next != null) { member.next.previous = member.previous; } if (head == member) { head = member.next; } if (tail == member) { tail = member.previous; } } boolean isEmpty() { return head == null; } } /** Position in type hierarchy. */ enum Position { TOP, // No need to check for overridden methods MIDDLE, BOTTOM // Methods won't be overridden } /** * Keeps track of injectable methods so we can remove methods that get overridden in O(1) time. * Uses our position in the type hierarchy to perform optimizations. */ static class OverrideIndex { final InjectableMembers injectableMembers; Map> bySignature; Position position = Position.TOP; OverrideIndex(InjectableMembers injectableMembers) { this.injectableMembers = injectableMembers; } /* Caches the signature for the last method. */ Method lastMethod; Signature lastSignature; /** * Removes a method overridden by the given method, if present. In order to * remain backwards compatible with prior Guice versions, this will *not* * remove overridden methods if 'alwaysRemove' is false and the overridden * signature was annotated with a com.google.inject.Inject. * * @param method * The method used to determine what is overridden and should be * removed. * @param alwaysRemove * true if overridden methods should be removed even if they were * guice @Inject * @param injectableMethod * if this method overrode any guice @Inject methods, * {@link InjectableMethod#overrodeGuiceInject} is set to true */ boolean removeIfOverriddenBy(Method method, boolean alwaysRemove, InjectableMethod injectableMethod) { if (position == Position.TOP) { // If we're at the top of the hierarchy, there's nothing to override. return false; } if (bySignature == null) { // We encountered a method in a subclass. Time to index the // methods in the parent class. bySignature = new HashMap>(); for (InjectableMember member = injectableMembers.head; member != null; member = member.next) { if (!(member instanceof InjectableMethod)) continue; InjectableMethod im = (InjectableMethod) member; if (im.isFinal()) continue; List methods = new ArrayList(); methods.add(im); bySignature.put(new Signature(im.method), methods); } } lastMethod = method; Signature signature = lastSignature = new Signature(method); List methods = bySignature.get(signature); boolean removed = false; if (methods != null) { for (Iterator iterator = methods.iterator(); iterator.hasNext();) { InjectableMethod possiblyOverridden = iterator.next(); if (overrides(method, possiblyOverridden.method)) { boolean wasGuiceInject = !possiblyOverridden.jsr330 || possiblyOverridden.overrodeGuiceInject; if(injectableMethod != null) { injectableMethod.overrodeGuiceInject = wasGuiceInject; } // Only actually remove the methods if we want to force // remove or if the signature never specified @com.google.inject.Inject // somewhere. if(alwaysRemove || !wasGuiceInject) { removed = true; iterator.remove(); injectableMembers.remove(possiblyOverridden); } } } } return removed; } /** * Adds the given method to the list of injection points. Keeps track of it in this index * in case it gets overridden. */ void add(InjectableMethod injectableMethod) { injectableMembers.add(injectableMethod); if (position == Position.BOTTOM || injectableMethod.isFinal()) { // This method can't be overridden, so there's no need to index it. return; } if (bySignature != null) { // Try to reuse the signature we created during removal Signature signature = injectableMethod.method == lastMethod ? lastSignature : new Signature(injectableMethod.method); List methods = bySignature.get(signature); if (methods == null) { methods = new ArrayList(); bySignature.put(signature, methods); } methods.add(injectableMethod); } } } /** * Returns an ordered, immutable set of injection points for the given type. Members in * superclasses come before members in subclasses. Within a class, fields come before methods. * Overridden methods are filtered out. * * @param statics true is this method should return static members, false for instance members * @param errors used to record errors */ private static Set getInjectionPoints(final TypeLiteral type, boolean statics, Errors errors) { InjectableMembers injectableMembers = new InjectableMembers(); OverrideIndex overrideIndex = null; List> hierarchy = hierarchyFor(type); int topIndex = hierarchy.size() - 1; for (int i = topIndex; i >= 0; i--) { if (overrideIndex != null && i < topIndex) { // Knowing the position within the hierarchy helps us make optimizations. if (i == 0) { overrideIndex.position = Position.BOTTOM; } else { overrideIndex.position = Position.MIDDLE; } } TypeLiteral current = hierarchy.get(i); for (Field field : current.getRawType().getDeclaredFields()) { if (Modifier.isStatic(field.getModifiers()) == statics) { Annotation atInject = getAtInject(field); if (atInject != null) { InjectableField injectableField = new InjectableField(current, field, atInject); if (injectableField.jsr330 && Modifier.isFinal(field.getModifiers())) { errors.cannotInjectFinalField(field); } injectableMembers.add(injectableField); } } } for (Method method : current.getRawType().getDeclaredMethods()) { if (Modifier.isStatic(method.getModifiers()) == statics) { Annotation atInject = getAtInject(method); if (atInject != null) { InjectableMethod injectableMethod = new InjectableMethod( current, method, atInject); if (checkForMisplacedBindingAnnotations(method, errors) | !isValidMethod(injectableMethod, errors)) { if (overrideIndex != null) { boolean removed = overrideIndex.removeIfOverriddenBy(method, false, injectableMethod); if(removed) { logger.log(Level.WARNING, "Method: {0} is not a valid injectable method (" + "because it either has misplaced binding annotations " + "or specifies type parameters) but is overriding a method that is valid. " + "Because it is not valid, the method will not be injected. " + "To fix this, make the method a valid injectable method.", method); } } continue; } if (statics) { injectableMembers.add(injectableMethod); } else { if (overrideIndex == null) { /* * Creating the override index lazily means that the first type in the hierarchy * with injectable methods (not necessarily the top most type) will be treated as * the TOP position and will enjoy the same optimizations (no checks for overridden * methods, etc.). */ overrideIndex = new OverrideIndex(injectableMembers); } else { // Forcibly remove the overriden method, otherwise we'll inject // it twice. overrideIndex.removeIfOverriddenBy(method, true, injectableMethod); } overrideIndex.add(injectableMethod); } } else { if(overrideIndex != null) { boolean removed = overrideIndex.removeIfOverriddenBy(method, false, null); if(removed) { logger.log(Level.WARNING, "Method: {0} is not annotated with @Inject but " + "is overriding a method that is annotated with @javax.inject.Inject. Because " + "it is not annotated with @Inject, the method will not be injected. " + "To fix this, annotate the method with @Inject.", method); } } } } } } if (injectableMembers.isEmpty()) { return Collections.emptySet(); } ImmutableSet.Builder builder = ImmutableSet.builder(); for (InjectableMember im = injectableMembers.head; im != null; im = im.next) { try { builder.add(im.toInjectionPoint()); } catch (ConfigurationException ignorable) { if (!im.optional) { errors.merge(ignorable.getErrorMessages()); } } } return builder.build(); } private static boolean isValidMethod(InjectableMethod injectableMethod, Errors errors) { boolean result = true; if (injectableMethod.jsr330) { Method method = injectableMethod.method; if (Modifier.isAbstract(method.getModifiers())) { errors.cannotInjectAbstractMethod(method); result = false; } if (method.getTypeParameters().length > 0) { errors.cannotInjectMethodWithTypeParameters(method); result = false; } } return result; } private static List> hierarchyFor(TypeLiteral type) { List> hierarchy = new ArrayList>(); TypeLiteral current = type; while (current.getRawType() != Object.class) { hierarchy.add(current); current = current.getSupertype(current.getRawType().getSuperclass()); } return hierarchy; } /** * Returns true if a overrides b. Assumes signatures of a and b are the same and a's declaring * class is a subclass of b's declaring class. */ private static boolean overrides(Method a, Method b) { // See JLS section 8.4.8.1 int modifiers = b.getModifiers(); if (Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers)) { return true; } if (Modifier.isPrivate(modifiers)) { return false; } // b must be package-private return a.getDeclaringClass().getPackage().equals(b.getDeclaringClass().getPackage()); } /** * A method signature. Used to handle method overridding. */ static class Signature { final String name; final Class[] parameterTypes; final int hash; Signature(Method method) { this.name = method.getName(); this.parameterTypes = method.getParameterTypes(); int h = name.hashCode(); h = h * 31 + parameterTypes.length; for (Class parameterType : parameterTypes) { h = h * 31 + parameterType.hashCode(); } this.hash = h; } @Override public int hashCode() { return this.hash; } @Override public boolean equals(Object o) { if (!(o instanceof Signature)) { return false; } Signature other = (Signature) o; if (!name.equals(other.name)) { return false; } if (parameterTypes.length != other.parameterTypes.length) { return false; } for (int i = 0; i < parameterTypes.length; i++) { if (parameterTypes[i] != other.parameterTypes[i]) { return false; } } return true; } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/InjectionListener.java0000644000175000017500000000214711704661106026531 0ustar tonytony/* * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; /** * Listens for injections into instances of type {@code I}. Useful for performing further * injections, post-injection initialization, and more. * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public interface InjectionListener { /** * Invoked by Guice after it injects the fields and methods of instance. * * @param injectee instance that Guice injected dependencies into */ void afterInjection(I injectee); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/HasDependencies.java0000644000175000017500000000234311704661106026121 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import java.util.Set; /** * Implemented by {@link com.google.inject.Binding bindings}, {@link com.google.inject.Provider * providers} and instances that expose their dependencies explicitly. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public interface HasDependencies { /** * Returns the known dependencies for this type. If this has dependencies whose values are not * known statically, a dependency for the {@link com.google.inject.Injector Injector} will be * included in the returned set. * * @return a possibly empty set */ Set> getDependencies(); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/ExposedBinding.java0000644000175000017500000000220011704661106025771 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binder; import com.google.inject.Binding; /** * A binding to a key exposed from an enclosed private environment. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public interface ExposedBinding extends Binding, HasDependencies { /** * Returns the enclosed environment that holds the original binding. */ PrivateElements getPrivateElements(); /** * Unsupported. Always throws {@link UnsupportedOperationException}. */ void applyTo(Binder binder); }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/Elements.java0000644000175000017500000002755111704661106024663 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.common.base.Preconditions.checkArgument; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.inject.AbstractModule; import com.google.inject.Binder; import com.google.inject.Binding; import com.google.inject.Key; import com.google.inject.MembersInjector; import com.google.inject.Module; import com.google.inject.PrivateBinder; import com.google.inject.PrivateModule; import com.google.inject.Provider; import com.google.inject.Scope; import com.google.inject.Stage; import com.google.inject.TypeLiteral; import com.google.inject.binder.AnnotatedBindingBuilder; import com.google.inject.binder.AnnotatedConstantBindingBuilder; import com.google.inject.binder.AnnotatedElementBuilder; import com.google.inject.internal.AbstractBindingBuilder; import com.google.inject.internal.BindingBuilder; import com.google.inject.internal.ConstantBindingBuilderImpl; import com.google.inject.internal.Errors; import com.google.inject.internal.ExposureBuilder; import com.google.inject.internal.PrivateElementsImpl; import com.google.inject.internal.ProviderMethodsModule; import com.google.inject.internal.util.SourceProvider; import com.google.inject.matcher.Matcher; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Set; /** * Exposes elements of a module so they can be inspected, validated or {@link * Element#applyTo(Binder) rewritten}. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public final class Elements { private static final BindingTargetVisitor GET_INSTANCE_VISITOR = new DefaultBindingTargetVisitor() { @Override public Object visit(InstanceBinding binding) { return binding.getInstance(); } @Override protected Object visitOther(Binding binding) { throw new IllegalArgumentException(); } }; /** * Records the elements executed by {@code modules}. */ public static List getElements(Module... modules) { return getElements(Stage.DEVELOPMENT, Arrays.asList(modules)); } /** * Records the elements executed by {@code modules}. */ public static List getElements(Stage stage, Module... modules) { return getElements(stage, Arrays.asList(modules)); } /** * Records the elements executed by {@code modules}. */ public static List getElements(Iterable modules) { return getElements(Stage.DEVELOPMENT, modules); } /** * Records the elements executed by {@code modules}. */ public static List getElements(Stage stage, Iterable modules) { RecordingBinder binder = new RecordingBinder(stage); for (Module module : modules) { binder.install(module); } return Collections.unmodifiableList(binder.elements); } /** * Returns the module composed of {@code elements}. */ public static Module getModule(final Iterable elements) { return new Module() { public void configure(Binder binder) { for (Element element : elements) { element.applyTo(binder); } } }; } @SuppressWarnings("unchecked") static BindingTargetVisitor getInstanceVisitor() { return (BindingTargetVisitor) GET_INSTANCE_VISITOR; } private static class RecordingBinder implements Binder, PrivateBinder { private final Stage stage; private final Set modules; private final List elements; private final Object source; private final SourceProvider sourceProvider; /** The binder where exposed bindings will be created */ private final RecordingBinder parent; private final PrivateElementsImpl privateElements; private RecordingBinder(Stage stage) { this.stage = stage; this.modules = Sets.newHashSet(); this.elements = Lists.newArrayList(); this.source = null; this.sourceProvider = SourceProvider.DEFAULT_INSTANCE.plusSkippedClasses( Elements.class, RecordingBinder.class, AbstractModule.class, ConstantBindingBuilderImpl.class, AbstractBindingBuilder.class, BindingBuilder.class); this.parent = null; this.privateElements = null; } /** Creates a recording binder that's backed by {@code prototype}. */ private RecordingBinder( RecordingBinder prototype, Object source, SourceProvider sourceProvider) { checkArgument(source == null ^ sourceProvider == null); this.stage = prototype.stage; this.modules = prototype.modules; this.elements = prototype.elements; this.source = source; this.sourceProvider = sourceProvider; this.parent = prototype.parent; this.privateElements = prototype.privateElements; } /** Creates a private recording binder. */ private RecordingBinder(RecordingBinder parent, PrivateElementsImpl privateElements) { this.stage = parent.stage; this.modules = Sets.newHashSet(); this.elements = privateElements.getElementsMutable(); this.source = parent.source; this.sourceProvider = parent.sourceProvider; this.parent = parent; this.privateElements = privateElements; } /*if[AOP]*/ public void bindInterceptor( Matcher> classMatcher, Matcher methodMatcher, org.aopalliance.intercept.MethodInterceptor... interceptors) { elements.add(new InterceptorBinding(getSource(), classMatcher, methodMatcher, interceptors)); } /*end[AOP]*/ public void bindScope(Class annotationType, Scope scope) { elements.add(new ScopeBinding(getSource(), annotationType, scope)); } @SuppressWarnings("unchecked") // it is safe to use the type literal for the raw type public void requestInjection(Object instance) { requestInjection((TypeLiteral) TypeLiteral.get(instance.getClass()), instance); } public void requestInjection(TypeLiteral type, T instance) { elements.add(new InjectionRequest(getSource(), type, instance)); } public MembersInjector getMembersInjector(final TypeLiteral typeLiteral) { final MembersInjectorLookup element = new MembersInjectorLookup(getSource(), typeLiteral); elements.add(element); return element.getMembersInjector(); } public MembersInjector getMembersInjector(Class type) { return getMembersInjector(TypeLiteral.get(type)); } public void bindListener(Matcher> typeMatcher, TypeListener listener) { elements.add(new TypeListenerBinding(getSource(), listener, typeMatcher)); } public void bindListener(Matcher> keyMatcher, ProvisionListener... listeners) { elements.add(new ProvisionListenerBinding(getSource(), keyMatcher, listeners)); } public void requestStaticInjection(Class... types) { for (Class type : types) { elements.add(new StaticInjectionRequest(getSource(), type)); } } public void install(Module module) { if (modules.add(module)) { Binder binder = this; if (module instanceof PrivateModule) { binder = binder.newPrivateBinder(); } try { module.configure(binder); } catch (RuntimeException e) { Collection messages = Errors.getMessagesFromThrowable(e); if (!messages.isEmpty()) { elements.addAll(messages); } else { addError(e); } } binder.install(ProviderMethodsModule.forModule(module)); } } public Stage currentStage() { return stage; } public void addError(String message, Object... arguments) { elements.add(new Message(getSource(), Errors.format(message, arguments))); } public void addError(Throwable t) { String message = "An exception was caught and reported. Message: " + t.getMessage(); elements.add(new Message(ImmutableList.of(getSource()), message, t)); } public void addError(Message message) { elements.add(message); } public AnnotatedBindingBuilder bind(Key key) { return new BindingBuilder(this, elements, getSource(), key); } public AnnotatedBindingBuilder bind(TypeLiteral typeLiteral) { return bind(Key.get(typeLiteral)); } public AnnotatedBindingBuilder bind(Class type) { return bind(Key.get(type)); } public AnnotatedConstantBindingBuilder bindConstant() { return new ConstantBindingBuilderImpl(this, elements, getSource()); } public Provider getProvider(final Key key) { final ProviderLookup element = new ProviderLookup(getSource(), key); elements.add(element); return element.getProvider(); } public Provider getProvider(Class type) { return getProvider(Key.get(type)); } public void convertToTypes(Matcher> typeMatcher, TypeConverter converter) { elements.add(new TypeConverterBinding(getSource(), typeMatcher, converter)); } public RecordingBinder withSource(final Object source) { return new RecordingBinder(this, source, null); } public RecordingBinder skipSources(Class... classesToSkip) { // if a source is specified explicitly, we don't need to skip sources if (source != null) { return this; } SourceProvider newSourceProvider = sourceProvider.plusSkippedClasses(classesToSkip); return new RecordingBinder(this, null, newSourceProvider); } public PrivateBinder newPrivateBinder() { PrivateElementsImpl privateElements = new PrivateElementsImpl(getSource()); elements.add(privateElements); return new RecordingBinder(this, privateElements); } public void disableCircularProxies() { elements.add(new DisableCircularProxiesOption(getSource())); } public void requireExplicitBindings() { elements.add(new RequireExplicitBindingsOption(getSource())); } public void expose(Key key) { exposeInternal(key); } public AnnotatedElementBuilder expose(Class type) { return exposeInternal(Key.get(type)); } public AnnotatedElementBuilder expose(TypeLiteral type) { return exposeInternal(Key.get(type)); } private AnnotatedElementBuilder exposeInternal(Key key) { if (privateElements == null) { addError("Cannot expose %s on a standard binder. " + "Exposed bindings are only applicable to private binders.", key); return new AnnotatedElementBuilder() { public void annotatedWith(Class annotationType) {} public void annotatedWith(Annotation annotation) {} }; } ExposureBuilder builder = new ExposureBuilder(this, getSource(), key); privateElements.addExposureBuilder(builder); return builder; } protected Object getSource() { return sourceProvider != null ? sourceProvider.get() : source; } @Override public String toString() { return "Binder"; } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/ElementVisitor.java0000644000175000017500000000517711704661106026060 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binding; /** * Visit elements. * * @param any type to be returned by the visit method. Use {@link Void} with * {@code return null} if no return type is needed. * * @since 2.0 */ public interface ElementVisitor { /** * Visit a mapping from a key (type and optional annotation) to the strategy for getting * instances of the type. */ V visit(Binding binding); /*if[AOP]*/ /** * Visit a registration of interceptors for matching methods of matching classes. */ V visit(InterceptorBinding binding); /*end[AOP]*/ /** * Visit a registration of a scope annotation with the scope that implements it. */ V visit(ScopeBinding binding); /** * Visit a registration of type converters for matching target types. */ V visit(TypeConverterBinding binding); /** * Visit a request to inject the instance fields and methods of an instance. */ V visit(InjectionRequest request); /** * Visit a request to inject the static fields and methods of type. */ V visit(StaticInjectionRequest request); /** * Visit a lookup of the provider for a type. */ V visit(ProviderLookup lookup); /** * Visit a lookup of the members injector. */ V visit(MembersInjectorLookup lookup); /** * Visit an error message and the context in which it occured. */ V visit(Message message); /** * Visit a collection of configuration elements for a {@linkplain com.google.inject.PrivateBinder * private binder}. */ V visit(PrivateElements elements); /** * Visit an injectable type listener binding. */ V visit(TypeListenerBinding binding); /** * Visit a provision listener binding. */ V visit(ProvisionListenerBinding binding); /** * Visit a require explicit bindings command. * * @since 3.0 */ V visit(RequireExplicitBindingsOption option); /** * Visit a disable circular proxies command. * * @since 3.0 */ V visit(DisableCircularProxiesOption option); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/Element.java0000644000175000017500000000437211704661106024474 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binder; /** * A core component of a module or injector. * *

    The elements of a module can be inspected, validated and rewritten. Use {@link * Elements#getElements(com.google.inject.Module[]) Elements.getElements()} to read the elements * from a module, and {@link Elements#getModule(Iterable) Elements.getModule()} to rewrite them. * This can be used for static analysis and generation of Guice modules. * *

    The elements of an injector can be inspected and exercised. Use {@link * com.google.inject.Injector#getBindings Injector.getBindings()} to reflect on Guice injectors. * * @author jessewilson@google.com (Jesse Wilson) * @author crazybob@google.com (Bob Lee) * @since 2.0 */ public interface Element { /** * Returns an arbitrary object containing information about the "place" where this element was * configured. Used by Guice in the production of descriptive error messages. * *

    Tools might specially handle types they know about; {@code StackTraceElement} is a good * example. Tools should simply call {@code toString()} on the source object if the type is * unfamiliar. */ Object getSource(); /** * Accepts an element visitor. Invokes the visitor method specific to this element's type. * * @param visitor to call back on */ T acceptVisitor(ElementVisitor visitor); /** * Writes this module element to the given binder (optional operation). * * @param binder to apply configuration element to * @throws UnsupportedOperationException if the {@code applyTo} method is not supported by this * element. */ void applyTo(Binder binder); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/DisableCircularProxiesOption.java0000644000175000017500000000242011704661106030666 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Binder; /** * A request to disable circular proxies. * * @author sameb@google.com (Sam Berlin) * @since 3.0 */ public final class DisableCircularProxiesOption implements Element { private final Object source; DisableCircularProxiesOption(Object source) { this.source = checkNotNull(source, "source"); } public Object getSource() { return source; } public void applyTo(Binder binder) { binder.withSource(getSource()).disableCircularProxies(); } public T acceptVisitor(ElementVisitor visitor) { return visitor.visit(this); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/DependencyAndSource.java0000644000175000017500000000462711704661106026770 0ustar tonytony/* * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.google.inject.spi; import com.google.inject.Binding; import com.google.inject.internal.util.StackTraceElements; import java.lang.reflect.Member; /** * A combination of a {@link Dependency} and the {@link Binding#getSource() * source} where the dependency was bound. * * @author sameb@google.com (Sam Berlin) */ public final class DependencyAndSource { private final Dependency dependency; private final Object source; public DependencyAndSource(Dependency dependency, Object source) { this.dependency = dependency; this.source = source; } /** * Returns the Dependency, if one exists. For anything that can be referenced * by {@link Injector#getBinding}, a dependency exists. A dependency will not * exist (and this will return null) for types initialized with * {@link Binder#requestInjection} or {@link Injector#injectMembers(Object), * nor will it exist for objects injected into Providers bound with * LinkedBindingBuilder#toProvider(Provider). */ public Dependency getDependency() { return dependency; } /** * Returns a string describing where this dependency was bound. If the binding * was just-in-time, there is no valid binding source, so this describes the * class in question. */ public String getBindingSource() { if (source instanceof Class) { return StackTraceElements.forType((Class) source).toString(); } else if (source instanceof Member) { return StackTraceElements.forMember((Member) source).toString(); } else { return source.toString(); } } @Override public String toString() { Dependency dep = getDependency(); Object source = getBindingSource(); if (dep != null) { return "Dependency: " + dep + ", source: " + source; } else { return "Source: " + source; } } }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/Dependency.java0000644000175000017500000000753411704661106025164 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.inject.Key; import java.util.List; import java.util.Set; /** * A variable that can be resolved by an injector. * *

    Use {@link #get} to build a freestanding dependency, or {@link InjectionPoint} to build one * that's attached to a constructor, method or field. * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public final class Dependency { private final InjectionPoint injectionPoint; private final Key key; private final boolean nullable; private final int parameterIndex; Dependency(InjectionPoint injectionPoint, Key key, boolean nullable, int parameterIndex) { this.injectionPoint = injectionPoint; this.key = checkNotNull(key, "key"); this.nullable = nullable; this.parameterIndex = parameterIndex; } /** * Returns a new dependency that is not attached to an injection point. The returned dependency is * nullable. */ public static Dependency get(Key key) { return new Dependency(null, key, true, -1); } /** * Returns the dependencies from the given injection points. */ public static Set> forInjectionPoints(Set injectionPoints) { List> dependencies = Lists.newArrayList(); for (InjectionPoint injectionPoint : injectionPoints) { dependencies.addAll(injectionPoint.getDependencies()); } return ImmutableSet.copyOf(dependencies); } /** * Returns the key to the binding that satisfies this dependency. */ public Key getKey() { return this.key; } /** * Returns true if null is a legal value for this dependency. */ public boolean isNullable() { return nullable; } /** * Returns the injection point to which this dependency belongs, or null if this dependency isn't * attached to a particular injection point. */ public InjectionPoint getInjectionPoint() { return injectionPoint; } /** * Returns the index of this dependency in the injection point's parameter list, or {@code -1} if * this dependency does not belong to a parameter list. Only method and constuctor dependencies * are elements in a parameter list. */ public int getParameterIndex() { return parameterIndex; } @Override public int hashCode() { return Objects.hashCode(injectionPoint, parameterIndex, key); } @Override public boolean equals(Object o) { if (o instanceof Dependency) { Dependency dependency = (Dependency) o; return Objects.equal(injectionPoint, dependency.injectionPoint) && Objects.equal(parameterIndex, dependency.parameterIndex) && Objects.equal(key, dependency.key); } else { return false; } } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(key); if (injectionPoint != null) { builder.append("@").append(injectionPoint); if (parameterIndex != -1) { builder.append("[").append(parameterIndex).append("]"); } } return builder.toString(); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/DefaultElementVisitor.java0000644000175000017500000000502511704661106027355 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binding; /** * No-op visitor for subclassing. All interface methods simply delegate to * {@link #visitOther(Element)}, returning its result. * * @param any type to be returned by the visit method. Use {@link Void} with * {@code return null} if no return type is needed. * * @author sberlin@gmail.com (Sam Berlin) * @since 2.0 */ public abstract class DefaultElementVisitor implements ElementVisitor { /** * Default visit implementation. Returns {@code null}. */ protected V visitOther(Element element) { return null; } public V visit(Message message) { return visitOther(message); } public V visit(Binding binding) { return visitOther(binding); } /*if[AOP]*/ public V visit(InterceptorBinding interceptorBinding) { return visitOther(interceptorBinding); } /*end[AOP]*/ public V visit(ScopeBinding scopeBinding) { return visitOther(scopeBinding); } public V visit(TypeConverterBinding typeConverterBinding) { return visitOther(typeConverterBinding); } public V visit(ProviderLookup providerLookup) { return visitOther(providerLookup); } public V visit(InjectionRequest injectionRequest) { return visitOther(injectionRequest); } public V visit(StaticInjectionRequest staticInjectionRequest) { return visitOther(staticInjectionRequest); } public V visit(PrivateElements privateElements) { return visitOther(privateElements); } public V visit(MembersInjectorLookup lookup) { return visitOther(lookup); } public V visit(TypeListenerBinding binding) { return visitOther(binding); } public V visit(ProvisionListenerBinding binding) { return visitOther(binding); } public V visit(DisableCircularProxiesOption option) { return visitOther(option); } public V visit(RequireExplicitBindingsOption option) { return visitOther(option); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/DefaultBindingTargetVisitor.java0000644000175000017500000000463111704661106030507 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binding; /** * No-op visitor for subclassing. All interface methods simply delegate to {@link * #visitOther(Binding)}, returning its result. * * @param any type to be returned by the visit method. Use {@link Void} with * {@code return null} if no return type is needed. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public abstract class DefaultBindingTargetVisitor implements BindingTargetVisitor { /** * Default visit implementation. Returns {@code null}. */ protected V visitOther(Binding binding) { return null; } public V visit(InstanceBinding instanceBinding) { return visitOther(instanceBinding); } public V visit(ProviderInstanceBinding providerInstanceBinding) { return visitOther(providerInstanceBinding); } public V visit(ProviderKeyBinding providerKeyBinding) { return visitOther(providerKeyBinding); } public V visit(LinkedKeyBinding linkedKeyBinding) { return visitOther(linkedKeyBinding); } public V visit(ExposedBinding exposedBinding) { return visitOther(exposedBinding); } public V visit(UntargettedBinding untargettedBinding) { return visitOther(untargettedBinding); } public V visit(ConstructorBinding constructorBinding) { return visitOther(constructorBinding); } public V visit(ConvertedConstantBinding convertedConstantBinding) { return visitOther(convertedConstantBinding); } // javac says it's an error to cast ProviderBinding to Binding @SuppressWarnings("unchecked") public V visit(ProviderBinding providerBinding) { return visitOther((Binding) providerBinding); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/DefaultBindingScopingVisitor.java0000644000175000017500000000301311704661106030654 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Scope; import java.lang.annotation.Annotation; /** * No-op visitor for subclassing. All interface methods simply delegate to * {@link #visitOther()}, returning its result. * * @param any type to be returned by the visit method. Use {@link Void} with * {@code return null} if no return type is needed. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public class DefaultBindingScopingVisitor implements BindingScopingVisitor { /** * Default visit implementation. Returns {@code null}. */ protected V visitOther() { return null; } public V visitEagerSingleton() { return visitOther(); } public V visitScope(Scope scope) { return visitOther(); } public V visitScopeAnnotation(Class scopeAnnotation) { return visitOther(); } public V visitNoScoping() { return visitOther(); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/ConvertedConstantBinding.java0000644000175000017500000000305311704661106030034 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binding; import com.google.inject.Key; import java.util.Set; /** * A binding created from converting a bound instance to a new type. The source binding has the same * binding annotation but a different type. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public interface ConvertedConstantBinding extends Binding, HasDependencies { /** * Returns the converted value. */ T getValue(); /** * Returns the type converter binding used to convert the constant. * * @since 3.0 */ TypeConverterBinding getTypeConverterBinding(); /** * Returns the key for the source binding. That binding can be retrieved from an injector using * {@link com.google.inject.Injector#getBinding(Key) Injector.getBinding(key)}. */ Key getSourceKey(); /** * Returns a singleton set containing only the converted key. */ Set> getDependencies(); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/ConstructorBinding.java0000644000175000017500000000347611704661106026727 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Binding; import java.lang.reflect.Method; import java.util.List; import java.util.Map; import java.util.Set; /** * A binding to the constructor of a concrete clss. To resolve injections, an instance is * instantiated by invoking the constructor. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public interface ConstructorBinding extends Binding, HasDependencies { /** * Gets the constructor this binding injects. */ InjectionPoint getConstructor(); /** * Returns all instance method and field injection points on {@code type}. * * @return a possibly empty set of injection points. The set has a specified iteration order. All * fields are returned and then all methods. Within the fields, supertype fields are returned * before subtype fields. Similarly, supertype methods are returned before subtype methods. */ Set getInjectableMembers(); /*if[AOP]*/ /** * Returns the interceptors applied to each method, in the order that they will be applied. * * @return a possibly empty map */ Map> getMethodInterceptors(); /*end[AOP]*/ }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/BindingTargetVisitor.java0000644000175000017500000000575111704661106027206 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; /** * Visits each of the strategies used to find an instance to satisfy an injection. * * @param any type to be returned by the visit method. Use {@link Void} with * {@code return null} if no return type is needed. * @since 2.0 */ public interface BindingTargetVisitor { /** * Visit a instance binding. The same instance is returned for every injection. This target is * found in both module and injector bindings. */ V visit(InstanceBinding binding); /** * Visit a provider instance binding. The provider's {@code get} method is invoked to resolve * injections. This target is found in both module and injector bindings. */ V visit(ProviderInstanceBinding binding); /** * Visit a provider key binding. To resolve injections, the provider key is first resolved, then * that provider's {@code get} method is invoked. This target is found in both module and injector * bindings. */ V visit(ProviderKeyBinding binding); /** * Visit a linked key binding. The other key's binding is used to resolve injections. This * target is found in both module and injector bindings. */ V visit(LinkedKeyBinding binding); /** * Visit a binding to a key exposed from an enclosed private environment. This target is only * found in injector bindings. */ V visit(ExposedBinding binding); /** * Visit an untargetted binding. This target is found only on module bindings. It indicates * that the injector should use its implicit binding strategies to resolve injections. */ V visit(UntargettedBinding binding); /** * Visit a constructor binding. To resolve injections, an instance is instantiated by invoking * {@code constructor}. This target is found only on injector bindings. */ V visit(ConstructorBinding binding); /** * Visit a binding created from converting a bound instance to a new type. The source binding * has the same binding annotation but a different type. This target is found only on injector * bindings. */ V visit(ConvertedConstantBinding binding); /** * Visit a binding to a {@link com.google.inject.Provider} that delegates to the binding for the * provided type. This target is found only on injector bindings. */ V visit(ProviderBinding binding); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/spi/BindingScopingVisitor.java0000644000175000017500000000363111704661106027355 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.spi; import com.google.inject.Scope; import java.lang.annotation.Annotation; /** * Visits each of the strategies used to scope an injection. * * @param any type to be returned by the visit method. Use {@link Void} with * {@code return null} if no return type is needed. * @since 2.0 */ public interface BindingScopingVisitor { /** * Visit an eager singleton or single instance. This scope strategy is found on both module and * injector bindings. */ V visitEagerSingleton(); /** * Visit a scope instance. This scope strategy is found on both module and injector bindings. */ V visitScope(Scope scope); /** * Visit a scope annotation. This scope strategy is found only on module bindings. The instance * that implements this scope is registered by {@link com.google.inject.Binder#bindScope(Class, * Scope) Binder.bindScope()}. */ V visitScopeAnnotation(Class scopeAnnotation); /** * Visit an unspecified or unscoped strategy. On a module, this strategy indicates that the * injector should use scoping annotations to find a scope. On an injector, it indicates that * no scope is applied to the binding. An unscoped binding will behave like a scoped one when it * is linked to a scoped binding. */ V visitNoScoping(); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/package-info.java0000644000175000017500000000330611704661106024630 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Google Guice (pronounced "juice") is an ultra-lightweight dependency * injection framework. Please refer to the Guice * User's Guide * for a gentle introduction. * *

    The principal public APIs in this package are: * *

    *
    {@link com.google.inject.Inject} *
    The annotation you will use in your implementation classes to tell Guice * where and how it should send in ("inject") the objects you depend on * (your "dependencies"). * *
    {@link com.google.inject.Module} *
    The interface you will implement in order to specify "bindings" -- * instructions for how Guice should handle injection -- for a particular * set of interfaces. * *
    {@link com.google.inject.Binder} *
    The object that Guice passes into your {@link com.google.inject.Module} * to collect these bindings. * *
    {@link com.google.inject.Provider} *
    The interface you will implement when you need to customize exactly how * Guice creates instances for a particular binding. * *
    * */ package com.google.inject;sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/name/0000755000175000017500000000000011704661106022357 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/name/package-info.java0000644000175000017500000000125111704661106025545 0ustar tonytony/* * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Support for binding to string-based names. */ package com.google.inject.name;sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/name/Names.java0000644000175000017500000000430011704661106024262 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.name; import com.google.inject.Binder; import com.google.inject.Key; import java.util.Enumeration; import java.util.Map; import java.util.Properties; /** * Utility methods for use with {@code @}{@link Named}. * * @author crazybob@google.com (Bob Lee) */ public class Names { private Names() {} /** * Creates a {@link Named} annotation with {@code name} as the value. */ public static Named named(String name) { return new NamedImpl(name); } /** * Creates a constant binding to {@code @Named(key)} for each entry in * {@code properties}. */ public static void bindProperties(Binder binder, Map properties) { binder = binder.skipSources(Names.class); for (Map.Entry entry : properties.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); binder.bind(Key.get(String.class, new NamedImpl(key))).toInstance(value); } } /** * Creates a constant binding to {@code @Named(key)} for each property. This * method binds all properties including those inherited from * {@link Properties#defaults defaults}. */ public static void bindProperties(Binder binder, Properties properties) { binder = binder.skipSources(Names.class); // use enumeration to include the default properties for (Enumeration e = properties.propertyNames(); e.hasMoreElements(); ) { String propertyName = (String) e.nextElement(); String value = properties.getProperty(propertyName); binder.bind(Key.get(String.class, new NamedImpl(propertyName))).toInstance(value); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/name/NamedImpl.java0000644000175000017500000000277511704661106025103 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.name; import static com.google.common.base.Preconditions.checkNotNull; import java.io.Serializable; import java.lang.annotation.Annotation; class NamedImpl implements Named, Serializable { private final String value; public NamedImpl(String value) { this.value = checkNotNull(value, "name"); } public String value() { return this.value; } public int hashCode() { // This is specified in java.lang.Annotation. return (127 * "value".hashCode()) ^ value.hashCode(); } public boolean equals(Object o) { if (!(o instanceof Named)) { return false; } Named other = (Named) o; return value.equals(other.value()); } public String toString() { return "@" + Named.class.getName() + "(value=" + value + ")"; } public Class annotationType() { return Named.class; } private static final long serialVersionUID = 0; } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/name/Named.java0000644000175000017500000000210311704661106024242 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.name; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.BindingAnnotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * Annotates named things. * * @author crazybob@google.com (Bob Lee) */ @Retention(RUNTIME) @Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @BindingAnnotation public @interface Named { String value(); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/matcher/0000755000175000017500000000000011704661106023062 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/matcher/package-info.java0000644000175000017500000000134111704661106026250 0ustar tonytony/* * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Used for matching things. Primarily used to pick out methods to which to * apply interceptors. */ package com.google.inject.matcher;sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/matcher/Matchers.java0000644000175000017500000002651511704661106025504 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.matcher; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import java.io.Serializable; import java.lang.annotation.Annotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Method; /** * Matcher implementations. Supports matching classes and methods. * * @author crazybob@google.com (Bob Lee) */ public class Matchers { private Matchers() {} /** * Returns a matcher which matches any input. */ public static Matcher any() { return ANY; } private static final Matcher ANY = new Any(); private static class Any extends AbstractMatcher implements Serializable { public boolean matches(Object o) { return true; } @Override public String toString() { return "any()"; } public Object readResolve() { return any(); } private static final long serialVersionUID = 0; } /** * Inverts the given matcher. */ public static Matcher not(final Matcher p) { return new Not(p); } private static class Not extends AbstractMatcher implements Serializable { final Matcher delegate; private Not(Matcher delegate) { this.delegate = checkNotNull(delegate, "delegate"); } public boolean matches(T t) { return !delegate.matches(t); } @Override public boolean equals(Object other) { return other instanceof Not && ((Not) other).delegate.equals(delegate); } @Override public int hashCode() { return -delegate.hashCode(); } @Override public String toString() { return "not(" + delegate + ")"; } private static final long serialVersionUID = 0; } private static void checkForRuntimeRetention( Class annotationType) { Retention retention = annotationType.getAnnotation(Retention.class); checkArgument(retention != null && retention.value() == RetentionPolicy.RUNTIME, "Annotation " + annotationType.getSimpleName() + " is missing RUNTIME retention"); } /** * Returns a matcher which matches elements (methods, classes, etc.) * with a given annotation. */ public static Matcher annotatedWith( final Class annotationType) { return new AnnotatedWithType(annotationType); } private static class AnnotatedWithType extends AbstractMatcher implements Serializable { private final Class annotationType; public AnnotatedWithType(Class annotationType) { this.annotationType = checkNotNull(annotationType, "annotation type"); checkForRuntimeRetention(annotationType); } public boolean matches(AnnotatedElement element) { return element.getAnnotation(annotationType) != null; } @Override public boolean equals(Object other) { return other instanceof AnnotatedWithType && ((AnnotatedWithType) other).annotationType.equals(annotationType); } @Override public int hashCode() { return 37 * annotationType.hashCode(); } @Override public String toString() { return "annotatedWith(" + annotationType.getSimpleName() + ".class)"; } private static final long serialVersionUID = 0; } /** * Returns a matcher which matches elements (methods, classes, etc.) * with a given annotation. */ public static Matcher annotatedWith( final Annotation annotation) { return new AnnotatedWith(annotation); } private static class AnnotatedWith extends AbstractMatcher implements Serializable { private final Annotation annotation; public AnnotatedWith(Annotation annotation) { this.annotation = checkNotNull(annotation, "annotation"); checkForRuntimeRetention(annotation.annotationType()); } public boolean matches(AnnotatedElement element) { Annotation fromElement = element.getAnnotation(annotation.annotationType()); return fromElement != null && annotation.equals(fromElement); } @Override public boolean equals(Object other) { return other instanceof AnnotatedWith && ((AnnotatedWith) other).annotation.equals(annotation); } @Override public int hashCode() { return 37 * annotation.hashCode(); } @Override public String toString() { return "annotatedWith(" + annotation + ")"; } private static final long serialVersionUID = 0; } /** * Returns a matcher which matches subclasses of the given type (as well as * the given type). */ public static Matcher subclassesOf(final Class superclass) { return new SubclassesOf(superclass); } private static class SubclassesOf extends AbstractMatcher implements Serializable { private final Class superclass; public SubclassesOf(Class superclass) { this.superclass = checkNotNull(superclass, "superclass"); } public boolean matches(Class subclass) { return superclass.isAssignableFrom(subclass); } @Override public boolean equals(Object other) { return other instanceof SubclassesOf && ((SubclassesOf) other).superclass.equals(superclass); } @Override public int hashCode() { return 37 * superclass.hashCode(); } @Override public String toString() { return "subclassesOf(" + superclass.getSimpleName() + ".class)"; } private static final long serialVersionUID = 0; } /** * Returns a matcher which matches objects equal to the given object. */ public static Matcher only(Object value) { return new Only(value); } private static class Only extends AbstractMatcher implements Serializable { private final Object value; public Only(Object value) { this.value = checkNotNull(value, "value"); } public boolean matches(Object other) { return value.equals(other); } @Override public boolean equals(Object other) { return other instanceof Only && ((Only) other).value.equals(value); } @Override public int hashCode() { return 37 * value.hashCode(); } @Override public String toString() { return "only(" + value + ")"; } private static final long serialVersionUID = 0; } /** * Returns a matcher which matches only the given object. */ public static Matcher identicalTo(final Object value) { return new IdenticalTo(value); } private static class IdenticalTo extends AbstractMatcher implements Serializable { private final Object value; public IdenticalTo(Object value) { this.value = checkNotNull(value, "value"); } public boolean matches(Object other) { return value == other; } @Override public boolean equals(Object other) { return other instanceof IdenticalTo && ((IdenticalTo) other).value == value; } @Override public int hashCode() { return 37 * System.identityHashCode(value); } @Override public String toString() { return "identicalTo(" + value + ")"; } private static final long serialVersionUID = 0; } /** * Returns a matcher which matches classes in the given package. Packages are specific to their * classloader, so classes with the same package name may not have the same package at runtime. */ public static Matcher inPackage(final Package targetPackage) { return new InPackage(targetPackage); } private static class InPackage extends AbstractMatcher implements Serializable { private final transient Package targetPackage; private final String packageName; public InPackage(Package targetPackage) { this.targetPackage = checkNotNull(targetPackage, "package"); this.packageName = targetPackage.getName(); } public boolean matches(Class c) { return c.getPackage().equals(targetPackage); } @Override public boolean equals(Object other) { return other instanceof InPackage && ((InPackage) other).targetPackage.equals(targetPackage); } @Override public int hashCode() { return 37 * targetPackage.hashCode(); } @Override public String toString() { return "inPackage(" + targetPackage.getName() + ")"; } public Object readResolve() { return inPackage(Package.getPackage(packageName)); } private static final long serialVersionUID = 0; } /** * Returns a matcher which matches classes in the given package and its subpackages. Unlike * {@link #inPackage(Package) inPackage()}, this matches classes from any classloader. * * @since 2.0 */ public static Matcher inSubpackage(final String targetPackageName) { return new InSubpackage(targetPackageName); } private static class InSubpackage extends AbstractMatcher implements Serializable { private final String targetPackageName; public InSubpackage(String targetPackageName) { this.targetPackageName = targetPackageName; } public boolean matches(Class c) { String classPackageName = c.getPackage().getName(); return classPackageName.equals(targetPackageName) || classPackageName.startsWith(targetPackageName + "."); } @Override public boolean equals(Object other) { return other instanceof InSubpackage && ((InSubpackage) other).targetPackageName.equals(targetPackageName); } @Override public int hashCode() { return 37 * targetPackageName.hashCode(); } @Override public String toString() { return "inSubpackage(" + targetPackageName + ")"; } private static final long serialVersionUID = 0; } /** * Returns a matcher which matches methods with matching return types. */ public static Matcher returns( final Matcher> returnType) { return new Returns(returnType); } private static class Returns extends AbstractMatcher implements Serializable { private final Matcher> returnType; public Returns(Matcher> returnType) { this.returnType = checkNotNull(returnType, "return type matcher"); } public boolean matches(Method m) { return returnType.matches(m.getReturnType()); } @Override public boolean equals(Object other) { return other instanceof Returns && ((Returns) other).returnType.equals(returnType); } @Override public int hashCode() { return 37 * returnType.hashCode(); } @Override public String toString() { return "returns(" + returnType + ")"; } private static final long serialVersionUID = 0; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/matcher/Matcher.java0000644000175000017500000000232411704661106025311 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.matcher; /** * Returns {@code true} or {@code false} for a given input. * * @author crazybob@google.com (Bob Lee) */ public interface Matcher { /** * Returns {@code true} if this matches {@code t}, {@code false} otherwise. */ boolean matches(T t); /** * Returns a new matcher which returns {@code true} if both this and the * given matcher return {@code true}. */ Matcher and(Matcher other); /** * Returns a new matcher which returns {@code true} if either this or the * given matcher return {@code true}. */ Matcher or(Matcher other); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/matcher/AbstractMatcher.java0000644000175000017500000000477011704661106027004 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.matcher; import java.io.Serializable; /** * Implements {@code and()} and {@code or()}. * * @author crazybob@google.com (Bob Lee) */ public abstract class AbstractMatcher implements Matcher { public Matcher and(final Matcher other) { return new AndMatcher(this, other); } public Matcher or(Matcher other) { return new OrMatcher(this, other); } private static class AndMatcher extends AbstractMatcher implements Serializable { private final Matcher a, b; public AndMatcher(Matcher a, Matcher b) { this.a = a; this.b = b; } public boolean matches(T t) { return a.matches(t) && b.matches(t); } @Override public boolean equals(Object other) { return other instanceof AndMatcher && ((AndMatcher) other).a.equals(a) && ((AndMatcher) other).b.equals(b); } @Override public int hashCode() { return 41 * (a.hashCode() ^ b.hashCode()); } @Override public String toString() { return "and(" + a + ", " + b + ")"; } private static final long serialVersionUID = 0; } private static class OrMatcher extends AbstractMatcher implements Serializable { private final Matcher a, b; public OrMatcher(Matcher a, Matcher b) { this.a = a; this.b = b; } public boolean matches(T t) { return a.matches(t) || b.matches(t); } @Override public boolean equals(Object other) { return other instanceof OrMatcher && ((OrMatcher) other).a.equals(a) && ((OrMatcher) other).b.equals(b); } @Override public int hashCode() { return 37 * (a.hashCode() ^ b.hashCode()); } @Override public String toString() { return "or(" + a + ", " + b + ")"; } private static final long serialVersionUID = 0; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/0000755000175000017500000000000011704661106023253 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/util/0000755000175000017500000000000011704661106024230 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/util/Stopwatch.java0000644000175000017500000000243511704661106027053 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal.util; import java.util.logging.Logger; /** * Enables simple performance monitoring. * * @author crazybob@google.com (Bob Lee) */ public final class Stopwatch { private static final Logger logger = Logger.getLogger(Stopwatch.class.getName()); private long start = System.currentTimeMillis(); /** * Resets and returns elapsed time in milliseconds. */ public long reset() { long now = System.currentTimeMillis(); try { return now - start; } finally { start = now; } } /** * Resets and logs elapsed time in milliseconds. */ public void resetAndLog(String label) { logger.fine(label + ": " + reset() + "ms"); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/util/StackTraceElements.java0000644000175000017500000000516311704661106030621 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal.util; import com.google.common.base.Function; import com.google.common.collect.MapMaker; import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.Member; import java.util.Map; /** * Creates stack trace elements for members. * * @author crazybob@google.com (Bob Lee) */ public class StackTraceElements { /*if[AOP]*/ static final Map, LineNumbers> lineNumbersCache = new MapMaker().weakKeys().softValues() .makeComputingMap(new Function, LineNumbers>() { public LineNumbers apply(Class key) { try { return new LineNumbers(key); } catch (IOException e) { throw new RuntimeException(e); } } }); /*end[AOP]*/ public static Object forMember(Member member) { if (member == null) { return SourceProvider.UNKNOWN_SOURCE; } Class declaringClass = member.getDeclaringClass(); /*if[AOP]*/ LineNumbers lineNumbers = lineNumbersCache.get(declaringClass); String fileName = lineNumbers.getSource(); Integer lineNumberOrNull = lineNumbers.getLineNumber(member); int lineNumber = lineNumberOrNull == null ? lineNumbers.getFirstLine() : lineNumberOrNull; /*end[AOP]*/ /*if[NO_AOP] String fileName = null; int lineNumber = -1; end[NO_AOP]*/ Class memberType = Classes.memberType(member); String memberName = memberType == Constructor.class ? "" : member.getName(); return new StackTraceElement(declaringClass.getName(), memberName, fileName, lineNumber); } public static Object forType(Class implementation) { /*if[AOP]*/ LineNumbers lineNumbers = lineNumbersCache.get(implementation); int lineNumber = lineNumbers.getFirstLine(); String fileName = lineNumbers.getSource(); /*end[AOP]*/ /*if[NO_AOP] String fileName = null; int lineNumber = -1; end[NO_AOP]*/ return new StackTraceElement(implementation.getName(), "class", fileName, lineNumber); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/util/SourceProvider.java0000644000175000017500000000435711704661106030057 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal.util; import static com.google.common.collect.Iterables.concat; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import java.util.List; /** * Provides access to the calling line of code. * * @author crazybob@google.com (Bob Lee) */ public final class SourceProvider { /** Indicates that the source is unknown. */ public static final Object UNKNOWN_SOURCE = "[unknown source]"; private final ImmutableSet classNamesToSkip; public static final SourceProvider DEFAULT_INSTANCE = new SourceProvider(ImmutableSet.of(SourceProvider.class.getName())); private SourceProvider(Iterable classesToSkip) { this.classNamesToSkip = ImmutableSet.copyOf(classesToSkip); } /** Returns a new instance that also skips {@code moreClassesToSkip}. */ public SourceProvider plusSkippedClasses(Class... moreClassesToSkip) { return new SourceProvider(concat(classNamesToSkip, asStrings(moreClassesToSkip))); } /** Returns the class names as Strings */ private static List asStrings(Class... classes) { List strings = Lists.newArrayList(); for (Class c : classes) { strings.add(c.getName()); } return strings; } /** * Returns the calling line of code. The selected line is the nearest to the top of the stack that * is not skipped. */ public StackTraceElement get() { for (final StackTraceElement element : new Throwable().getStackTrace()) { String className = element.getClassName(); if (!classNamesToSkip.contains(className)) { return element; } } throw new AssertionError(); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/util/LineNumbers.java0000644000175000017500000001660111704661106027322 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal.util; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Preconditions; import com.google.common.collect.Maps; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.Attribute; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.util.Map; /** * Looks up line numbers for classes and their members. * * @author Chris Nokleberg */ final class LineNumbers { private final Class type; private final Map lines = Maps.newHashMap(); private String source; private int firstLine = Integer.MAX_VALUE; /** * Reads line number information from the given class, if available. * * @param type the class to read line number information from * @throws IllegalArgumentException if the bytecode for the class cannot be found * @throws java.io.IOException if an error occurs while reading bytecode */ public LineNumbers(Class type) throws IOException { this.type = type; if (!type.isArray()) { InputStream in = type.getResourceAsStream("/" + type.getName().replace('.', '/') + ".class"); if (in != null) { new ClassReader(in).accept(new LineNumberReader(), ClassReader.SKIP_FRAMES); } } } /** * Get the source file name as read from the bytecode. * * @return the source file name if available, or null */ public String getSource() { return source; } /** * Get the line number associated with the given member. * * @param member a field, constructor, or method belonging to the class used during construction * @return the wrapped line number, or null if not available * @throws IllegalArgumentException if the member does not belong to the class used during * construction */ public Integer getLineNumber(Member member) { Preconditions.checkArgument(type == member.getDeclaringClass(), "Member %s belongs to %s, not %s", member, member.getDeclaringClass(), type); return lines.get(memberKey(member)); } /** Gets the first line number. */ public int getFirstLine() { return firstLine == Integer.MAX_VALUE ? 1 : firstLine; } private String memberKey(Member member) { checkNotNull(member, "member"); /*if[AOP]*/ if (member instanceof Field) { return member.getName(); } else if (member instanceof Method) { return member.getName() + org.objectweb.asm.Type.getMethodDescriptor((Method) member); } else if (member instanceof Constructor) { StringBuilder sb = new StringBuilder().append("("); for (Class param : ((Constructor) member).getParameterTypes()) { sb.append(org.objectweb.asm.Type.getDescriptor(param)); } return sb.append(")V").toString(); } else { throw new IllegalArgumentException( "Unsupported implementation class for Member, " + member.getClass()); } /*end[AOP]*/ /*if[NO_AOP] return ""; end[NO_AOP]*/ } private class LineNumberReader implements ClassVisitor, MethodVisitor, AnnotationVisitor { private int line = -1; private String pendingMethod; private String name; public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { this.name = name; } public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if ((access & Opcodes.ACC_PRIVATE) != 0) { return null; } pendingMethod = name + desc; line = -1; return this; } public void visitSource(String source, String debug) { LineNumbers.this.source = source; } public void visitLineNumber(int line, Label start) { if (line < firstLine) { firstLine = line; } this.line = line; if (pendingMethod != null) { lines.put(pendingMethod, line); pendingMethod = null; } } public void visitFieldInsn(int opcode, String owner, String name, String desc) { if (opcode == Opcodes.PUTFIELD && this.name.equals(owner) && !lines.containsKey(name) && line != -1) { lines.put(name, line); } } public void visitEnd() { } public void visitInnerClass(String name, String outerName, String innerName, int access) { } public void visitOuterClass(String owner, String name, String desc) { } public void visitAttribute(Attribute attr) { } public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { return null; } public AnnotationVisitor visitAnnotation(String desc, boolean visible) { return this; } public AnnotationVisitor visitAnnotation(String name, String desc) { return this; } public AnnotationVisitor visitAnnotationDefault() { return this; } public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) { return this; } public AnnotationVisitor visitArray(String name) { return this; } public void visitEnum(String name, String desc, String value) { } public void visit(String name, Object value) { } public void visitCode() { } public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) { } public void visitIincInsn(int var, int increment) { } public void visitInsn(int opcode) { } public void visitIntInsn(int opcode, int operand) { } public void visitJumpInsn(int opcode, Label label) { } public void visitLabel(Label label) { } public void visitLdcInsn(Object cst) { } public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) { } public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) { } public void visitMaxs(int maxStack, int maxLocals) { } public void visitMethodInsn(int opcode, String owner, String name, String desc) { } public void visitMultiANewArrayInsn(String desc, int dims) { } public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) { } public void visitTryCatchBlock(Label start, Label end, Label handler, String type) { } public void visitTypeInsn(int opcode, String desc) { } public void visitVarInsn(int opcode, int var) { } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/util/Classes.java0000644000175000017500000000475311704661106026501 0ustar tonytony/** * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal.util; import static com.google.common.base.Preconditions.checkNotNull; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.Modifier; /** * Class utilities. */ public final class Classes { public static boolean isInnerClass(Class clazz) { return !Modifier.isStatic(clazz.getModifiers()) && clazz.getEnclosingClass() != null; } public static boolean isConcrete(Class clazz) { int modifiers = clazz.getModifiers(); return !clazz.isInterface() && !Modifier.isAbstract(modifiers); } /** * Formats a member as concise string, such as {@code java.util.ArrayList.size}, * {@code java.util.ArrayList()} or {@code java.util.List.remove()}. */ public static String toString(Member member) { Class memberType = Classes.memberType(member); if (memberType == Method.class) { return member.getDeclaringClass().getName() + "." + member.getName() + "()"; } else if (memberType == Field.class) { return member.getDeclaringClass().getName() + "." + member.getName(); } else if (memberType == Constructor.class) { return member.getDeclaringClass().getName() + ".()"; } else { throw new AssertionError(); } } /** * Returns {@code Field.class}, {@code Method.class} or {@code Constructor.class}. */ public static Class memberType(Member member) { checkNotNull(member, "member"); if (member instanceof Field) { return Field.class; } else if (member instanceof Method) { return Method.class; } else if (member instanceof Constructor) { return Constructor.class; } else { throw new IllegalArgumentException( "Unsupported implementation class for Member, " + member.getClass()); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/package-info.java0000644000175000017500000000125311704661106026443 0ustar tonytony/* * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Guice (sounds like like "juice") */ package com.google.inject.internal;sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/WeakKeySet.java0000644000175000017500000000441711704661106026140 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.inject.Key; import com.google.inject.internal.util.SourceProvider; import java.util.Map; import java.util.Set; /** * Minimal set that doesn't hold strong references to the contained keys. * * @author jessewilson@google.com (Jesse Wilson) */ final class WeakKeySet { /** * We store strings rather than keys so we don't hold strong references. * *

    One potential problem with this approach is that parent and child injectors cannot define * keys whose class names are equal but class loaders are different. This shouldn't be an issue * in practice. */ private Map> backingSet; public void add(Key key, Object source) { if (backingSet == null) { backingSet = Maps.newHashMap(); } // if it's an instanceof Class, it was a JIT binding, which we don't // want to retain. if (source instanceof Class || source == SourceProvider.UNKNOWN_SOURCE) { source = null; } String k = key.toString(); Set sources = backingSet.get(k); if (sources == null) { sources = Sets.newLinkedHashSet(); backingSet.put(k, sources); } sources.add(Errors.convert(source)); } public boolean contains(Key key) { // avoid calling key.toString() if the backing set is empty. toString is expensive in aggregate, // and most WeakKeySets are empty in practice (because they're used by top-level injectors) return backingSet != null && backingSet.containsKey(key.toString()); } public Set getSources(Key key) { return backingSet.get(key.toString()); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/UntargettedBindingProcessor.java0000644000175000017500000000433311704661106031602 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.Binding; import com.google.inject.spi.UntargettedBinding; /** * Processes just UntargettedBindings. * * @author sameb@google.com (Sam Berlin) */ class UntargettedBindingProcessor extends AbstractBindingProcessor { UntargettedBindingProcessor(Errors errors, ProcessedBindingData bindingData) { super(errors, bindingData); } @Override public Boolean visit(Binding binding) { return binding.acceptTargetVisitor(new Processor((BindingImpl)binding) { public Boolean visit(UntargettedBinding untargetted) { prepareBinding(); // Error: Missing implementation. // Example: bind(Date.class).annotatedWith(Red.class); // We can't assume abstract types aren't injectable. They may have an // @ImplementedBy annotation or something. if (key.getAnnotationType() != null) { errors.missingImplementation(key); putBinding(invalidBinding(injector, key, source)); return true; } // This cast is safe after the preceeding check. try { BindingImpl binding = injector.createUninitializedBinding( key, scoping, source, errors, false); scheduleInitialization(binding); putBinding(binding); } catch (ErrorsException e) { errors.merge(e.getErrors()); putBinding(invalidBinding(injector, key, source)); } return true; } @Override protected Boolean visitOther(Binding binding) { return false; } }); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/UntargettedBindingImpl.java0000644000175000017500000000467211704661106030532 0ustar tonytony/* * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Objects; import com.google.inject.Binder; import com.google.inject.Key; import com.google.inject.spi.BindingTargetVisitor; import com.google.inject.spi.Dependency; import com.google.inject.spi.UntargettedBinding; final class UntargettedBindingImpl extends BindingImpl implements UntargettedBinding { UntargettedBindingImpl(InjectorImpl injector, Key key, Object source) { super(injector, key, source, new InternalFactory() { public T get(Errors errors, InternalContext context, Dependency dependency, boolean linked) { throw new AssertionError(); } }, Scoping.UNSCOPED); } public UntargettedBindingImpl(Object source, Key key, Scoping scoping) { super(source, key, scoping); } public V acceptTargetVisitor(BindingTargetVisitor visitor) { return visitor.visit(this); } public BindingImpl withScoping(Scoping scoping) { return new UntargettedBindingImpl(getSource(), getKey(), scoping); } public BindingImpl withKey(Key key) { return new UntargettedBindingImpl(getSource(), key, getScoping()); } public void applyTo(Binder binder) { getScoping().applyTo(binder.withSource(getSource()).bind(getKey())); } @Override public String toString() { return Objects.toStringHelper(UntargettedBinding.class) .add("key", getKey()) .add("source", getSource()) .toString(); } @Override public boolean equals(Object obj) { if(obj instanceof UntargettedBindingImpl) { UntargettedBindingImpl o = (UntargettedBindingImpl)obj; return getKey().equals(o.getKey()) && getScoping().equals(o.getScoping()); } else { return false; } } @Override public int hashCode() { return Objects.hashCode(getKey(), getScoping()); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/UniqueAnnotations.java0000644000175000017500000000376511704661106027615 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.google.inject.BindingAnnotation; import java.lang.annotation.Annotation; import java.lang.annotation.Retention; import java.util.concurrent.atomic.AtomicInteger; /** * @author jessewilson@google.com (Jesse Wilson) */ public class UniqueAnnotations { private UniqueAnnotations() {} private static final AtomicInteger nextUniqueValue = new AtomicInteger(1); /** * Returns an annotation instance that is not equal to any other annotation * instances, for use in creating distinct {@link com.google.inject.Key}s. */ public static Annotation create() { return create(nextUniqueValue.getAndIncrement()); } static Annotation create(final int value) { return new Internal() { public int value() { return value; } public Class annotationType() { return Internal.class; } @Override public String toString() { return "@" + Internal.class.getName() + "(value=" + value + ")"; } @Override public boolean equals(Object o) { return o instanceof Internal && ((Internal) o).value() == value(); } @Override public int hashCode() { return (127 * "value".hashCode()) ^ value; } }; } @Retention(RUNTIME) @BindingAnnotation @interface Internal { int value(); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/TypeConverterBindingProcessor.java0000644000175000017500000001362511704661106032131 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.TypeLiteral; import com.google.inject.internal.util.SourceProvider; import com.google.inject.matcher.AbstractMatcher; import com.google.inject.matcher.Matcher; import com.google.inject.matcher.Matchers; import com.google.inject.spi.TypeConverter; import com.google.inject.spi.TypeConverterBinding; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; /** * Handles {@code Binder.convertToTypes} commands. * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) */ final class TypeConverterBindingProcessor extends AbstractProcessor { TypeConverterBindingProcessor(Errors errors) { super(errors); } /** Installs default converters for primitives, enums, and class literals. */ void prepareBuiltInConverters(InjectorImpl injector) { this.injector = injector; try { // Configure type converters. convertToPrimitiveType(int.class, Integer.class); convertToPrimitiveType(long.class, Long.class); convertToPrimitiveType(boolean.class, Boolean.class); convertToPrimitiveType(byte.class, Byte.class); convertToPrimitiveType(short.class, Short.class); convertToPrimitiveType(float.class, Float.class); convertToPrimitiveType(double.class, Double.class); convertToClass(Character.class, new TypeConverter() { public Object convert(String value, TypeLiteral toType) { value = value.trim(); if (value.length() != 1) { throw new RuntimeException("Length != 1."); } return value.charAt(0); } @Override public String toString() { return "TypeConverter"; } }); convertToClasses(Matchers.subclassesOf(Enum.class), new TypeConverter() { @SuppressWarnings("unchecked") public Object convert(String value, TypeLiteral toType) { return Enum.valueOf((Class) toType.getRawType(), value); } @Override public String toString() { return "TypeConverter>"; } }); internalConvertToTypes( new AbstractMatcher>() { public boolean matches(TypeLiteral typeLiteral) { return typeLiteral.getRawType() == Class.class; } @Override public String toString() { return "Class"; } }, new TypeConverter() { @SuppressWarnings("unchecked") public Object convert(String value, TypeLiteral toType) { try { return Class.forName(value); } catch (ClassNotFoundException e) { throw new RuntimeException(e.getMessage()); } } @Override public String toString() { return "TypeConverter>"; } } ); } finally { this.injector = null; } } private void convertToPrimitiveType(Class primitiveType, final Class wrapperType) { try { final Method parser = wrapperType.getMethod( "parse" + capitalize(primitiveType.getName()), String.class); TypeConverter typeConverter = new TypeConverter() { @SuppressWarnings("unchecked") public Object convert(String value, TypeLiteral toType) { try { return parser.invoke(null, value); } catch (IllegalAccessException e) { throw new AssertionError(e); } catch (InvocationTargetException e) { throw new RuntimeException(e.getTargetException().getMessage()); } } @Override public String toString() { return "TypeConverter<" + wrapperType.getSimpleName() + ">"; } }; convertToClass(wrapperType, typeConverter); } catch (NoSuchMethodException e) { throw new AssertionError(e); } } private void convertToClass(Class type, TypeConverter converter) { convertToClasses(Matchers.identicalTo(type), converter); } private void convertToClasses(final Matcher> typeMatcher, TypeConverter converter) { internalConvertToTypes(new AbstractMatcher>() { public boolean matches(TypeLiteral typeLiteral) { Type type = typeLiteral.getType(); if (!(type instanceof Class)) { return false; } Class clazz = (Class) type; return typeMatcher.matches(clazz); } @Override public String toString() { return typeMatcher.toString(); } }, converter); } private void internalConvertToTypes(Matcher> typeMatcher, TypeConverter converter) { injector.state.addConverter( new TypeConverterBinding(SourceProvider.UNKNOWN_SOURCE, typeMatcher, converter)); } @Override public Boolean visit(TypeConverterBinding command) { injector.state.addConverter(new TypeConverterBinding( command.getSource(), command.getTypeMatcher(), command.getTypeConverter())); return true; } private static String capitalize(String s) { if (s.length() == 0) { return s; } char first = s.charAt(0); char capitalized = Character.toUpperCase(first); return (first == capitalized) ? s : capitalized + s.substring(1); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/State.java0000644000175000017500000001355411704661106025206 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.inject.Binding; import com.google.inject.Key; import com.google.inject.Scope; import com.google.inject.TypeLiteral; import com.google.inject.spi.ProvisionListenerBinding; import com.google.inject.spi.TypeConverterBinding; import com.google.inject.spi.TypeListenerBinding; import java.lang.annotation.Annotation; import java.util.List; import java.util.Map; import java.util.Set; /** * The inheritable data within an injector. This class is intended to allow parent and local * injector data to be accessed as a unit. * * @author jessewilson@google.com (Jesse Wilson) */ interface State { static final State NONE = new State() { public State parent() { throw new UnsupportedOperationException(); } public BindingImpl getExplicitBinding(Key key) { return null; } public Map, Binding> getExplicitBindingsThisLevel() { throw new UnsupportedOperationException(); } public void putBinding(Key key, BindingImpl binding) { throw new UnsupportedOperationException(); } public Scope getScope(Class scopingAnnotation) { return null; } public void putAnnotation(Class annotationType, Scope scope) { throw new UnsupportedOperationException(); } public void addConverter(TypeConverterBinding typeConverterBinding) { throw new UnsupportedOperationException(); } public TypeConverterBinding getConverter(String stringValue, TypeLiteral type, Errors errors, Object source) { throw new UnsupportedOperationException(); } public Iterable getConvertersThisLevel() { return ImmutableSet.of(); } /*if[AOP]*/ public void addMethodAspect(MethodAspect methodAspect) { throw new UnsupportedOperationException(); } public ImmutableList getMethodAspects() { return ImmutableList.of(); } /*end[AOP]*/ public void addTypeListener(TypeListenerBinding typeListenerBinding) { throw new UnsupportedOperationException(); } public List getTypeListenerBindings() { return ImmutableList.of(); } public void addProvisionListener(ProvisionListenerBinding provisionListenerBinding) { throw new UnsupportedOperationException(); } public List getProvisionListenerBindings() { return ImmutableList.of(); } public void blacklist(Key key, Object source) { } public boolean isBlacklisted(Key key) { return true; } public Set getSourcesForBlacklistedKey(Key key) { throw new UnsupportedOperationException(); } public Object lock() { throw new UnsupportedOperationException(); } public Map, Scope> getScopes() { return ImmutableMap.of(); } }; State parent(); /** Gets a binding which was specified explicitly in a module, or null. */ BindingImpl getExplicitBinding(Key key); /** Returns the explicit bindings at this level only. */ Map, Binding> getExplicitBindingsThisLevel(); void putBinding(Key key, BindingImpl binding); /** Returns the matching scope, or null. */ Scope getScope(Class scopingAnnotation); void putAnnotation(Class annotationType, Scope scope); void addConverter(TypeConverterBinding typeConverterBinding); /** Returns the matching converter for {@code type}, or null if none match. */ TypeConverterBinding getConverter( String stringValue, TypeLiteral type, Errors errors, Object source); /** Returns all converters at this level only. */ Iterable getConvertersThisLevel(); /*if[AOP]*/ void addMethodAspect(MethodAspect methodAspect); ImmutableList getMethodAspects(); /*end[AOP]*/ void addTypeListener(TypeListenerBinding typeListenerBinding); List getTypeListenerBindings(); void addProvisionListener(ProvisionListenerBinding provisionListenerBinding); List getProvisionListenerBindings(); /** * Forbids the corresponding injector from creating a binding to {@code key}. Child injectors * blacklist their bound keys on their parent injectors to prevent just-in-time bindings on the * parent injector that would conflict. */ void blacklist(Key key, Object source); /** * Returns true if {@code key} is forbidden from being bound in this injector. This indicates that * one of this injector's descendent's has bound the key. */ boolean isBlacklisted(Key key); /** Returns the source of a blacklisted key. */ Set getSourcesForBlacklistedKey(Key key); /** * Returns the shared lock for all injector data. This is a low-granularity, high-contention lock * to be used when reading mutable data (ie. just-in-time bindings, and binding blacklists). */ Object lock(); /** * Returns all the scope bindings at this level and parent levels. */ Map, Scope> getScopes(); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/SingleParameterInjector.java0000644000175000017500000000437711704661106030711 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.spi.Dependency; /** * Resolves a single parameter, to be used in a constructor or method invocation. */ final class SingleParameterInjector { private static final Object[] NO_ARGUMENTS = {}; private final Dependency dependency; private final BindingImpl binding; SingleParameterInjector(Dependency dependency, BindingImpl binding) { this.dependency = dependency; this.binding = binding; } private T inject(Errors errors, InternalContext context) throws ErrorsException { Dependency previous = context.pushDependency(dependency, binding.getSource()); try { return binding.getInternalFactory().get(errors.withSource(dependency), context, dependency, false); } finally { context.popStateAndSetDependency(previous); } } /** * Returns an array of parameter values. */ static Object[] getAll(Errors errors, InternalContext context, SingleParameterInjector[] parameterInjectors) throws ErrorsException { if (parameterInjectors == null) { return NO_ARGUMENTS; } int numErrorsBefore = errors.size(); int size = parameterInjectors.length; Object[] parameters = new Object[size]; // optimization: use manual for/each to save allocating an iterator here for (int i = 0; i < size; i++) { SingleParameterInjector parameterInjector = parameterInjectors[i]; try { parameters[i] = parameterInjector.inject(errors, context); } catch (ErrorsException e) { errors.merge(e.getErrors()); } } errors.throwIfNewErrors(numErrorsBefore); return parameters; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/SingleMethodInjector.java0000644000175000017500000000677011704661106030210 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.internal.BytecodeGen.Visibility; import com.google.inject.internal.InjectorImpl.MethodInvoker; import com.google.inject.spi.InjectionPoint; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; /** * Invokes an injectable method. */ final class SingleMethodInjector implements SingleMemberInjector { private final MethodInvoker methodInvoker; private final SingleParameterInjector[] parameterInjectors; private final InjectionPoint injectionPoint; SingleMethodInjector(InjectorImpl injector, InjectionPoint injectionPoint, Errors errors) throws ErrorsException { this.injectionPoint = injectionPoint; final Method method = (Method) injectionPoint.getMember(); methodInvoker = createMethodInvoker(method); parameterInjectors = injector.getParametersInjectors(injectionPoint.getDependencies(), errors); } private MethodInvoker createMethodInvoker(final Method method) { // We can't use FastMethod if the method is private. int modifiers = method.getModifiers(); if (!Modifier.isPrivate(modifiers) && !Modifier.isProtected(modifiers)) { /*if[AOP]*/ try { final net.sf.cglib.reflect.FastMethod fastMethod = BytecodeGen.newFastClass(method.getDeclaringClass(), Visibility.forMember(method)) .getMethod(method); return new MethodInvoker() { public Object invoke(Object target, Object... parameters) throws IllegalAccessException, InvocationTargetException { return fastMethod.invoke(target, parameters); } }; } catch (net.sf.cglib.core.CodeGenerationException e) {/* fall-through */} /*end[AOP]*/ } if (!Modifier.isPublic(modifiers) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) { method.setAccessible(true); } return new MethodInvoker() { public Object invoke(Object target, Object... parameters) throws IllegalAccessException, InvocationTargetException { return method.invoke(target, parameters); } }; } public InjectionPoint getInjectionPoint() { return injectionPoint; } public void inject(Errors errors, InternalContext context, Object o) { Object[] parameters; try { parameters = SingleParameterInjector.getAll(errors, context, parameterInjectors); } catch (ErrorsException e) { errors.merge(e.getErrors()); return; } try { methodInvoker.invoke(o, parameters); } catch (IllegalAccessException e) { throw new AssertionError(e); // a security manager is blocking us, we're hosed } catch (InvocationTargetException userException) { Throwable cause = userException.getCause() != null ? userException.getCause() : userException; errors.withSource(injectionPoint).errorInjectingMethod(cause); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/SingleMemberInjector.java0000644000175000017500000000155211704661106030170 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.spi.InjectionPoint; /** * Injects a field or method of a given object. */ interface SingleMemberInjector { void inject(Errors errors, InternalContext context, Object o); InjectionPoint getInjectionPoint(); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/SingleFieldInjector.java0000644000175000017500000000421311704661106030001 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.internal.InjectorImpl.JitLimitation; import com.google.inject.spi.Dependency; import com.google.inject.spi.InjectionPoint; import java.lang.reflect.Field; /** * Sets an injectable field. */ final class SingleFieldInjector implements SingleMemberInjector { final Field field; final InjectionPoint injectionPoint; final Dependency dependency; final BindingImpl binding; public SingleFieldInjector(InjectorImpl injector, InjectionPoint injectionPoint, Errors errors) throws ErrorsException { this.injectionPoint = injectionPoint; this.field = (Field) injectionPoint.getMember(); this.dependency = injectionPoint.getDependencies().get(0); // Ewwwww... field.setAccessible(true); binding = injector.getBindingOrThrow(dependency.getKey(), errors, JitLimitation.NO_JIT); } public InjectionPoint getInjectionPoint() { return injectionPoint; } public void inject(Errors errors, InternalContext context, Object o) { errors = errors.withSource(dependency); Dependency previous = context.pushDependency(dependency, binding.getSource()); try { Object value = binding.getInternalFactory().get(errors, context, dependency, false); field.set(o, value); } catch (ErrorsException e) { errors.withSource(injectionPoint).merge(e.getErrors()); } catch (IllegalAccessException e) { throw new AssertionError(e); // a security manager is blocking us, we're hosed } finally { context.popStateAndSetDependency(previous); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/Scoping.java0000644000175000017500000001667511704661106025537 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Objects; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.Scope; import com.google.inject.Scopes; import com.google.inject.Singleton; import com.google.inject.Stage; import com.google.inject.binder.ScopedBindingBuilder; import com.google.inject.spi.BindingScopingVisitor; import java.lang.annotation.Annotation; /** * References a scope, either directly (as a scope instance), or indirectly (as a scope annotation). * The scope's eager or laziness is also exposed. * * @author jessewilson@google.com (Jesse Wilson) */ public abstract class Scoping { /** * No scoping annotation has been applied. Note that this is different from {@code * in(Scopes.NO_SCOPE)}, where the 'NO_SCOPE' has been explicitly applied. */ public static final Scoping UNSCOPED = new Scoping() { public V acceptVisitor(BindingScopingVisitor visitor) { return visitor.visitNoScoping(); } @Override public Scope getScopeInstance() { return Scopes.NO_SCOPE; } @Override public String toString() { return Scopes.NO_SCOPE.toString(); } public void applyTo(ScopedBindingBuilder scopedBindingBuilder) { // do nothing } }; public static final Scoping SINGLETON_ANNOTATION = new Scoping() { public V acceptVisitor(BindingScopingVisitor visitor) { return visitor.visitScopeAnnotation(Singleton.class); } @Override public Class getScopeAnnotation() { return Singleton.class; } @Override public String toString() { return Singleton.class.getName(); } public void applyTo(ScopedBindingBuilder scopedBindingBuilder) { scopedBindingBuilder.in(Singleton.class); } }; public static final Scoping SINGLETON_INSTANCE = new Scoping() { public V acceptVisitor(BindingScopingVisitor visitor) { return visitor.visitScope(Scopes.SINGLETON); } @Override public Scope getScopeInstance() { return Scopes.SINGLETON; } @Override public String toString() { return Scopes.SINGLETON.toString(); } public void applyTo(ScopedBindingBuilder scopedBindingBuilder) { scopedBindingBuilder.in(Scopes.SINGLETON); } }; public static final Scoping EAGER_SINGLETON = new Scoping() { public V acceptVisitor(BindingScopingVisitor visitor) { return visitor.visitEagerSingleton(); } @Override public Scope getScopeInstance() { return Scopes.SINGLETON; } @Override public String toString() { return "eager singleton"; } public void applyTo(ScopedBindingBuilder scopedBindingBuilder) { scopedBindingBuilder.asEagerSingleton(); } }; public static Scoping forAnnotation(final Class scopingAnnotation) { if (scopingAnnotation == Singleton.class || scopingAnnotation == javax.inject.Singleton.class) { return SINGLETON_ANNOTATION; } return new Scoping() { public V acceptVisitor(BindingScopingVisitor visitor) { return visitor.visitScopeAnnotation(scopingAnnotation); } @Override public Class getScopeAnnotation() { return scopingAnnotation; } @Override public String toString() { return scopingAnnotation.getName(); } public void applyTo(ScopedBindingBuilder scopedBindingBuilder) { scopedBindingBuilder.in(scopingAnnotation); } }; } public static Scoping forInstance(final Scope scope) { if (scope == Scopes.SINGLETON) { return SINGLETON_INSTANCE; } return new Scoping() { public V acceptVisitor(BindingScopingVisitor visitor) { return visitor.visitScope(scope); } @Override public Scope getScopeInstance() { return scope; } @Override public String toString() { return scope.toString(); } public void applyTo(ScopedBindingBuilder scopedBindingBuilder) { scopedBindingBuilder.in(scope); } }; } /** * Returns true if this scope was explicitly applied. If no scope was explicitly applied then the * scoping annotation will be used. */ public boolean isExplicitlyScoped() { return this != UNSCOPED; } /** * Returns true if this is the default scope. In this case a new instance will be provided for * each injection. */ public boolean isNoScope() { return getScopeInstance() == Scopes.NO_SCOPE; } /** * Returns true if this scope is a singleton that should be loaded eagerly in {@code stage}. */ public boolean isEagerSingleton(Stage stage) { if (this == EAGER_SINGLETON) { return true; } if (stage == Stage.PRODUCTION) { return this == SINGLETON_ANNOTATION || this == SINGLETON_INSTANCE; } return false; } /** * Returns the scope instance, or {@code null} if that isn't known for this instance. */ public Scope getScopeInstance() { return null; } /** * Returns the scope annotation, or {@code null} if that isn't known for this instance. */ public Class getScopeAnnotation() { return null; } @Override public boolean equals(Object obj) { if(obj instanceof Scoping) { Scoping o = (Scoping)obj; return Objects.equal(getScopeAnnotation(), o.getScopeAnnotation()) && Objects.equal(getScopeInstance(), o.getScopeInstance()); } else { return false; } } @Override public int hashCode() { return Objects.hashCode(getScopeAnnotation(), getScopeInstance()); } public abstract V acceptVisitor(BindingScopingVisitor visitor); public abstract void applyTo(ScopedBindingBuilder scopedBindingBuilder); private Scoping() {} /** Scopes an internal factory. */ static InternalFactory scope(Key key, InjectorImpl injector, InternalFactory creator, Object source, Scoping scoping) { if (scoping.isNoScope()) { return creator; } Scope scope = scoping.getScopeInstance(); Provider scoped = scope.scope(key, new ProviderToInternalFactoryAdapter(injector, creator)); return new InternalFactoryToProviderAdapter(scoped, source); } /** * Replaces annotation scopes with instance scopes using the Injector's annotation-to-instance * map. If the scope annotation has no corresponding instance, an error will be added and unscoped * will be retuned. */ static Scoping makeInjectable(Scoping scoping, InjectorImpl injector, Errors errors) { Class scopeAnnotation = scoping.getScopeAnnotation(); if (scopeAnnotation == null) { return scoping; } Scope scope = injector.state.getScope(scopeAnnotation); if (scope != null) { return forInstance(scope); } errors.scopeNotFound(scopeAnnotation); return UNSCOPED; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ScopeBindingProcessor.java0000644000175000017500000000373111704661106030366 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Scope; import com.google.inject.spi.ScopeBinding; import java.lang.annotation.Annotation; /** * Handles {@code Binder.bindScope} commands. * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) */ final class ScopeBindingProcessor extends AbstractProcessor { ScopeBindingProcessor(Errors errors) { super(errors); } @Override public Boolean visit(ScopeBinding command) { Scope scope = command.getScope(); Class annotationType = command.getAnnotationType(); if (!Annotations.isScopeAnnotation(annotationType)) { errors.withSource(annotationType).missingScopeAnnotation(); // Go ahead and bind anyway so we don't get collateral errors. } if (!Annotations.isRetainedAtRuntime(annotationType)) { errors.withSource(annotationType) .missingRuntimeRetention(command.getSource()); // Go ahead and bind anyway so we don't get collateral errors. } Scope existing = injector.state.getScope(checkNotNull(annotationType, "annotation type")); if (existing != null) { errors.duplicateScopes(existing, annotationType, scope); } else { injector.state.putAnnotation(annotationType, checkNotNull(scope, "scope")); } return true; } }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ProxyFactory.java0000644000175000017500000002340711704661106026575 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.inject.internal.BytecodeGen.newFastClass; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.inject.spi.InjectionPoint; import net.sf.cglib.core.MethodWrapper; import net.sf.cglib.proxy.Callback; import net.sf.cglib.proxy.CallbackFilter; import net.sf.cglib.proxy.Enhancer; import net.sf.cglib.reflect.FastClass; import net.sf.cglib.reflect.FastConstructor; import org.aopalliance.intercept.MethodInterceptor; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; /** * Builds a construction proxy that can participate in AOP. This class manages applying type and * method matchers to come up with the set of intercepted methods. * * @author jessewilson@google.com (Jesse Wilson) */ final class ProxyFactory implements ConstructionProxyFactory { private static final Logger logger = Logger.getLogger(ProxyFactory.class.getName()); private final InjectionPoint injectionPoint; private final ImmutableMap> interceptors; private final Class declaringClass; private final List methods; private final Callback[] callbacks; /** * PUBLIC is default; it's used if all the methods we're intercepting are public. This impacts * which classloader we should use for loading the enhanced class */ private BytecodeGen.Visibility visibility = BytecodeGen.Visibility.PUBLIC; ProxyFactory(InjectionPoint injectionPoint, Iterable methodAspects) { this.injectionPoint = injectionPoint; @SuppressWarnings("unchecked") // the member of injectionPoint is always a Constructor Constructor constructor = (Constructor) injectionPoint.getMember(); declaringClass = constructor.getDeclaringClass(); // Find applicable aspects. Bow out if none are applicable to this class. List applicableAspects = Lists.newArrayList(); for (MethodAspect methodAspect : methodAspects) { if (methodAspect.matches(declaringClass)) { applicableAspects.add(methodAspect); } } if (applicableAspects.isEmpty()) { interceptors = ImmutableMap.of(); methods = ImmutableList.of(); callbacks = null; return; } // Get list of methods from cglib. methods = Lists.newArrayList(); Enhancer.getMethods(declaringClass, null, methods); // Create method/interceptor holders and record indices. List methodInterceptorsPairs = Lists.newArrayList(); for (Method method : methods) { methodInterceptorsPairs.add(new MethodInterceptorsPair(method)); } // Iterate over aspects and add interceptors for the methods they apply to boolean anyMatched = false; for (MethodAspect methodAspect : applicableAspects) { for (MethodInterceptorsPair pair : methodInterceptorsPairs) { if (methodAspect.matches(pair.method)) { if(pair.method.isSynthetic()) { logger.log(Level.WARNING, "Method [{0}] is synthetic and is being intercepted by {1}." + " This could indicate a bug. The method may be intercepted twice," + " or may not be intercepted at all.", new Object[] { pair.method, methodAspect.interceptors() }); } visibility = visibility.and(BytecodeGen.Visibility.forMember(pair.method)); pair.addAll(methodAspect.interceptors()); anyMatched = true; } } } if (!anyMatched) { interceptors = ImmutableMap.of(); callbacks = null; return; } ImmutableMap.Builder> interceptorsMapBuilder = null; // lazy callbacks = new Callback[methods.size()]; for (int i = 0; i < methods.size(); i++) { MethodInterceptorsPair pair = methodInterceptorsPairs.get(i); if (!pair.hasInterceptors()) { callbacks[i] = net.sf.cglib.proxy.NoOp.INSTANCE; continue; } if (interceptorsMapBuilder == null) { interceptorsMapBuilder = ImmutableMap.builder(); } interceptorsMapBuilder.put(pair.method, ImmutableList.copyOf(pair.interceptors)); callbacks[i] = new InterceptorStackCallback(pair.method, pair.interceptors); } interceptors = interceptorsMapBuilder != null ? interceptorsMapBuilder.build() : ImmutableMap.>of(); } /** * Returns the interceptors that apply to the constructed type. */ public ImmutableMap> getInterceptors() { return interceptors; } public ConstructionProxy create() throws ErrorsException { if (interceptors.isEmpty()) { return new DefaultConstructionProxyFactory(injectionPoint).create(); } @SuppressWarnings("unchecked") Class[] callbackTypes = new Class[callbacks.length]; for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] == net.sf.cglib.proxy.NoOp.INSTANCE) { callbackTypes[i] = net.sf.cglib.proxy.NoOp.class; } else { callbackTypes[i] = net.sf.cglib.proxy.MethodInterceptor.class; } } // Create the proxied class. We're careful to ensure that all enhancer state is not-specific // to this injector. Otherwise, the proxies for each injector will waste PermGen memory try { Enhancer enhancer = BytecodeGen.newEnhancer(declaringClass, visibility); enhancer.setCallbackFilter(new IndicesCallbackFilter(declaringClass, methods)); enhancer.setCallbackTypes(callbackTypes); return new ProxyConstructor(enhancer, injectionPoint, callbacks, interceptors); } catch (Throwable e) { throw new Errors().errorEnhancingClass(declaringClass, e).toException(); } } private static class MethodInterceptorsPair { final Method method; List interceptors; // lazy MethodInterceptorsPair(Method method) { this.method = method; } void addAll(List interceptors) { if (this.interceptors == null) { this.interceptors = Lists.newArrayList(); } this.interceptors.addAll(interceptors); } boolean hasInterceptors() { return interceptors != null; } } /** * A callback filter that maps methods to unique IDs. We define equals and hashCode using * the method-wrapper:indices map so that enhanced classes can be shared between injectors. */ private static class IndicesCallbackFilter implements CallbackFilter { final Map indices; final int hashCode; IndicesCallbackFilter(Class declaringClass, List methods) { final Map indices = Maps.newHashMap(); for (int i = 0; i < methods.size(); i++) { indices.put(MethodWrapper.create(methods.get(i)), i); } this.indices = indices; hashCode = indices.hashCode(); } public int accept(Method method) { return indices.get(MethodWrapper.create(method)); } @Override public boolean equals(Object o) { return o instanceof IndicesCallbackFilter && ((IndicesCallbackFilter) o).indices.equals(indices); } @Override public int hashCode() { return hashCode; } } /** * Constructs instances that participate in AOP. */ private static class ProxyConstructor implements ConstructionProxy { final Class enhanced; final InjectionPoint injectionPoint; final Constructor constructor; final Callback[] callbacks; final FastConstructor fastConstructor; final ImmutableMap> methodInterceptors; @SuppressWarnings("unchecked") // the constructor promises to construct 'T's ProxyConstructor(Enhancer enhancer, InjectionPoint injectionPoint, Callback[] callbacks, ImmutableMap> methodInterceptors) { this.enhanced = enhancer.createClass(); // this returns a cached class if possible this.injectionPoint = injectionPoint; this.constructor = (Constructor) injectionPoint.getMember(); this.callbacks = callbacks; this.methodInterceptors = methodInterceptors; FastClass fastClass = newFastClass(enhanced, BytecodeGen.Visibility.forMember(constructor)); this.fastConstructor = fastClass.getConstructor(constructor.getParameterTypes()); } @SuppressWarnings("unchecked") // the constructor promises to produce 'T's public T newInstance(Object... arguments) throws InvocationTargetException { Enhancer.registerCallbacks(enhanced, callbacks); try { return (T) fastConstructor.newInstance(arguments); } finally { Enhancer.registerCallbacks(enhanced, null); } } public InjectionPoint getInjectionPoint() { return injectionPoint; } public Constructor getConstructor() { return constructor; } public ImmutableMap> getMethodInterceptors() { return methodInterceptors; } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ProvisionListenerStackCallback.java0000644000175000017500000000764411704661106032232 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.Key; import com.google.inject.ProvisionException; import com.google.inject.spi.DependencyAndSource; import com.google.inject.spi.ProvisionListener; import java.util.List; /** * Intercepts provisions with a stack of listeners. * * @author sameb@google.com (Sam Berlin) */ final class ProvisionListenerStackCallback { private static final ProvisionListener EMPTY_LISTENER[] = new ProvisionListener[0]; private final ProvisionListener[] listeners; private final Key key; public ProvisionListenerStackCallback(Key key, List listeners) { this.key = key; if (listeners.isEmpty()) { this.listeners = EMPTY_LISTENER; } else { this.listeners = listeners.toArray(new ProvisionListener[listeners.size()]); } } public boolean hasListeners() { return listeners.length > 0; } public T provision(Errors errors, InternalContext context, ProvisionCallback callable) throws ErrorsException { Provision provision = new Provision(errors, context, callable); RuntimeException caught = null; try { provision.provision(); } catch(RuntimeException t) { caught = t; } if (provision.exceptionDuringProvision != null) { throw provision.exceptionDuringProvision; } else if (caught != null) { Object listener = provision.erredListener != null ? provision.erredListener.getClass() : "(unknown)"; throw errors .errorInUserCode(caught, "Error notifying ProvisionListener %s of %s.%n" + " Reason: %s", listener, key, caught) .toException(); } else { return provision.result; } } // TODO(sameb): Can this be more InternalFactory-like? public interface ProvisionCallback { public T call() throws ErrorsException; } private class Provision extends ProvisionListener.ProvisionInvocation { final Errors errors; final InternalContext context; final ProvisionCallback callable; int index = -1; T result; ErrorsException exceptionDuringProvision; ProvisionListener erredListener; public Provision(Errors errors, InternalContext context, ProvisionCallback callable) { this.callable = callable; this.context = context; this.errors = errors; } @Override public T provision() { index++; if (index == listeners.length) { try { result = callable.call(); } catch(ErrorsException ee) { exceptionDuringProvision = ee; throw new ProvisionException(errors.merge(ee.getErrors()).getMessages()); } } else if (index < listeners.length) { int currentIdx = index; try { listeners[index].onProvision(this); } catch(RuntimeException re) { erredListener = listeners[currentIdx]; throw re; } if (currentIdx == index) { // Our listener didn't provision -- do it for them. provision(); } } else { throw new IllegalStateException("Already provisioned in this listener."); } return result; } @Override public Key getKey() { return key; } @Override public List getDependencyChain() { return context.getDependencyChain(); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ProvisionListenerCallbackStore.java0000644000175000017500000000610311704661106032246 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.MapMaker; import com.google.inject.Key; import com.google.inject.spi.ProvisionListener; import com.google.inject.spi.ProvisionListenerBinding; import java.util.List; import java.util.Map; /** * {@link ProvisionListenerStackCallback} for each key. * * @author sameb@google.com (Sam Berlin) */ final class ProvisionListenerCallbackStore { private final ImmutableList listenerBindings; private final Map, ProvisionListenerStackCallback> cache = new MapMaker().makeComputingMap( new Function, ProvisionListenerStackCallback>() { public ProvisionListenerStackCallback apply(Key key) { return create(key); } }); ProvisionListenerCallbackStore(List listenerBindings) { this.listenerBindings = ImmutableList.copyOf(listenerBindings); } /** Returns a new {@link ProvisionListenerStackCallback} for the key. */ @SuppressWarnings("unchecked") // the ProvisionListenerStackCallback type always agrees with the passed type public ProvisionListenerStackCallback get(Key key) { return (ProvisionListenerStackCallback) cache.get(key); } /** * Purges a key from the cache. Use this only if the type is not actually valid for * binding and needs to be purged. (See issue 319 and * ImplicitBindingTest#testCircularJitBindingsLeaveNoResidue and * #testInstancesRequestingProvidersForThemselvesWithChildInjectors for examples of when this is * necessary.) * * Returns true if the type was stored in the cache, false otherwise. */ boolean remove(Key type) { return cache.remove(type) != null; } /** * Creates a new {@link ProvisionListenerStackCallback} with the correct listeners * for the key. */ private ProvisionListenerStackCallback create(Key key) { List listeners = null; for (ProvisionListenerBinding binding : listenerBindings) { if (binding.getKeyMatcher().matches(key)) { if (listeners == null) { listeners = Lists.newArrayList(); } listeners.addAll(binding.getListeners()); } } if (listeners == null) { listeners = ImmutableList.of(); } return new ProvisionListenerStackCallback(key, listeners); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ProviderToInternalFactoryAdapter.javasisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ProviderToInternalFactoryAdapter.jav0000644000175000017500000000372311704661106032405 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.Provider; import com.google.inject.ProvisionException; import com.google.inject.spi.Dependency; /** * @author crazybob@google.com (Bob Lee) */ final class ProviderToInternalFactoryAdapter implements Provider { private final InjectorImpl injector; private final InternalFactory internalFactory; public ProviderToInternalFactoryAdapter(InjectorImpl injector, InternalFactory internalFactory) { this.injector = injector; this.internalFactory = internalFactory; } public T get() { final Errors errors = new Errors(); try { T t = injector.callInContext(new ContextualCallable() { public T call(InternalContext context) throws ErrorsException { Dependency dependency = context.getDependency(); // Always pretend that we are a linked binding, to support // scoping implicit bindings. If we are not actually a linked // binding, we'll fail properly elsewhere in the chain. return internalFactory.get(errors, context, dependency, true); } }); errors.throwIfNewErrors(0); return t; } catch (ErrorsException e) { throw new ProvisionException(errors.merge(e.getErrors()).getMessages()); } } @Override public String toString() { return internalFactory.toString(); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ProviderMethodsModule.java0000644000175000017500000001331111704661106030401 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.inject.Binder; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provider; import com.google.inject.Provides; import com.google.inject.TypeLiteral; import com.google.inject.spi.Dependency; import com.google.inject.spi.Message; import com.google.inject.util.Modules; import java.lang.annotation.Annotation; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.util.List; import java.util.logging.Logger; /** * Creates bindings to methods annotated with {@literal @}{@link Provides}. Use the scope and * binding annotations on the provider method to configure the binding. * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) */ public final class ProviderMethodsModule implements Module { private final Object delegate; private final TypeLiteral typeLiteral; private ProviderMethodsModule(Object delegate) { this.delegate = checkNotNull(delegate, "delegate"); this.typeLiteral = TypeLiteral.get(this.delegate.getClass()); } /** * Returns a module which creates bindings for provider methods from the given module. */ public static Module forModule(Module module) { return forObject(module); } /** * Returns a module which creates bindings for provider methods from the given object. * This is useful notably for GIN */ public static Module forObject(Object object) { // avoid infinite recursion, since installing a module always installs itself if (object instanceof ProviderMethodsModule) { return Modules.EMPTY_MODULE; } return new ProviderMethodsModule(object); } public synchronized void configure(Binder binder) { for (ProviderMethod providerMethod : getProviderMethods(binder)) { providerMethod.configure(binder); } } public List> getProviderMethods(Binder binder) { List> result = Lists.newArrayList(); for (Class c = delegate.getClass(); c != Object.class; c = c.getSuperclass()) { for (Method method : c.getDeclaredMethods()) { if (method.isAnnotationPresent(Provides.class)) { result.add(createProviderMethod(binder, method)); } } } return result; } ProviderMethod createProviderMethod(Binder binder, final Method method) { binder = binder.withSource(method); Errors errors = new Errors(method); // prepare the parameter providers List> dependencies = Lists.newArrayList(); List> parameterProviders = Lists.newArrayList(); List> parameterTypes = typeLiteral.getParameterTypes(method); Annotation[][] parameterAnnotations = method.getParameterAnnotations(); for (int i = 0; i < parameterTypes.size(); i++) { Key key = getKey(errors, parameterTypes.get(i), method, parameterAnnotations[i]); if(key.equals(Key.get(Logger.class))) { // If it was a Logger, change the key to be unique & bind it to a // provider that provides a logger with a proper name. // This solves issue 482 (returning a new anonymous logger on every call exhausts memory) Key loggerKey = Key.get(Logger.class, UniqueAnnotations.create()); binder.bind(loggerKey).toProvider(new LogProvider(method)); key = loggerKey; } dependencies.add(Dependency.get(key)); parameterProviders.add(binder.getProvider(key)); } @SuppressWarnings("unchecked") // Define T as the method's return type. TypeLiteral returnType = (TypeLiteral) typeLiteral.getReturnType(method); Key key = getKey(errors, returnType, method, method.getAnnotations()); Class scopeAnnotation = Annotations.findScopeAnnotation(errors, method.getAnnotations()); for (Message message : errors.getMessages()) { binder.addError(message); } return new ProviderMethod(key, method, delegate, ImmutableSet.copyOf(dependencies), parameterProviders, scopeAnnotation); } Key getKey(Errors errors, TypeLiteral type, Member member, Annotation[] annotations) { Annotation bindingAnnotation = Annotations.findBindingAnnotation(errors, member, annotations); return bindingAnnotation == null ? Key.get(type) : Key.get(type, bindingAnnotation); } @Override public boolean equals(Object o) { return o instanceof ProviderMethodsModule && ((ProviderMethodsModule) o).delegate == delegate; } @Override public int hashCode() { return delegate.hashCode(); } /** A provider that returns a logger based on the method name. */ private static final class LogProvider implements Provider { private final String name; public LogProvider(Method method) { this.name = method.getDeclaringClass().getName() + "." + method.getName(); } public Logger get() { return Logger.getLogger(name); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ProviderMethod.java0000644000175000017500000001034111704661106027050 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.inject.Binder; import com.google.inject.Exposed; import com.google.inject.Key; import com.google.inject.PrivateBinder; import com.google.inject.Provider; import com.google.inject.internal.util.StackTraceElements; import com.google.inject.spi.Dependency; import com.google.inject.spi.ProviderWithDependencies; import java.lang.annotation.Annotation; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; import java.util.Set; /** * A provider that invokes a method and returns its result. * * @author jessewilson@google.com (Jesse Wilson) */ public class ProviderMethod implements ProviderWithDependencies { private final Key key; private final Class scopeAnnotation; private final Object instance; private final Method method; private final ImmutableSet> dependencies; private final List> parameterProviders; private final boolean exposed; /** * @param method the method to invoke. It's return type must be the same type as {@code key}. */ ProviderMethod(Key key, Method method, Object instance, ImmutableSet> dependencies, List> parameterProviders, Class scopeAnnotation) { this.key = key; this.scopeAnnotation = scopeAnnotation; this.instance = instance; this.dependencies = dependencies; this.method = method; this.parameterProviders = parameterProviders; this.exposed = method.isAnnotationPresent(Exposed.class); method.setAccessible(true); } public Key getKey() { return key; } public Method getMethod() { return method; } // exposed for GIN public Object getInstance() { return instance; } public void configure(Binder binder) { binder = binder.withSource(method); if (scopeAnnotation != null) { binder.bind(key).toProvider(this).in(scopeAnnotation); } else { binder.bind(key).toProvider(this); } if (exposed) { // the cast is safe 'cause the only binder we have implements PrivateBinder. If there's a // misplaced @Exposed, calling this will add an error to the binder's error queue ((PrivateBinder) binder).expose(key); } } public T get() { Object[] parameters = new Object[parameterProviders.size()]; for (int i = 0; i < parameters.length; i++) { parameters[i] = parameterProviders.get(i).get(); } try { // We know this cast is safe becase T is the method's return type. @SuppressWarnings({ "unchecked", "UnnecessaryLocalVariable" }) T result = (T) method.invoke(instance, parameters); return result; } catch (IllegalAccessException e) { throw new AssertionError(e); } catch (InvocationTargetException e) { throw Exceptions.rethrowCause(e); } } public Set> getDependencies() { return dependencies; } @Override public String toString() { return "@Provides " + StackTraceElements.forMember(method).toString(); } @Override public boolean equals(Object obj) { if (obj instanceof ProviderMethod) { ProviderMethod o = (ProviderMethod)obj; return method.equals(o.method) && instance.equals(o.instance); } else { return false; } } @Override public int hashCode() { // Avoid calling hashCode on 'instance', which is a user-object // that might not be expecting it. // (We need to call equals, so we do. But we can avoid hashCode.) return Objects.hashCode(method); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ProviderInternalFactory.java0000644000175000017500000000651311704661106030742 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.internal.ProvisionListenerStackCallback.ProvisionCallback; import com.google.inject.spi.Dependency; import javax.inject.Provider; /** * Base class for InternalFactories that are used by Providers, to handle * circular dependencies. * * @author sameb@google.com (Sam Berlin) */ abstract class ProviderInternalFactory implements InternalFactory { private final ProvisionListenerStackCallback provisionCallback; private final boolean allowProxy; protected final Object source; ProviderInternalFactory(Object source, boolean allowProxy, ProvisionListenerStackCallback provisionCallback) { this.provisionCallback = checkNotNull(provisionCallback, "provisionCallback"); this.source = checkNotNull(source, "source"); this.allowProxy = allowProxy; } protected T circularGet(final Provider provider, final Errors errors, InternalContext context, final Dependency dependency, boolean linked) throws ErrorsException { Class expectedType = dependency.getKey().getTypeLiteral().getRawType(); final ConstructionContext constructionContext = context.getConstructionContext(this); // We have a circular reference between constructors. Return a proxy. if (constructionContext.isConstructing()) { if (!allowProxy) { throw errors.circularProxiesDisabled(expectedType).toException(); } else { // TODO: if we can't proxy this object, can we proxy the other object? @SuppressWarnings("unchecked") T proxyType = (T) constructionContext.createProxy(errors, expectedType); return proxyType; } } // Optimization: Don't go through the callback stack if no one's listening. if (!provisionCallback.hasListeners()) { return provision(provider, errors, dependency, constructionContext); } else { return provisionCallback.provision(errors, context, new ProvisionCallback() { public T call() throws ErrorsException { return provision(provider, errors, dependency, constructionContext); } }); } } /** * Provisions a new instance. Subclasses should override this to catch * exceptions & rethrow as ErrorsExceptions. */ protected T provision(Provider provider, Errors errors, Dependency dependency, ConstructionContext constructionContext) throws ErrorsException { constructionContext.startConstruction(); try { T t = errors.checkForNull(provider.get(), source, dependency); constructionContext.setProxyDelegates(t); return t; } finally { constructionContext.finishConstruction(); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ProviderInstanceBindingImpl.java0000644000175000017500000001013211704661106031507 0ustar tonytony/* Copyright (C) 2007 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.inject.Binder; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.spi.BindingTargetVisitor; import com.google.inject.spi.Dependency; import com.google.inject.spi.HasDependencies; import com.google.inject.spi.InjectionPoint; import com.google.inject.spi.ProviderInstanceBinding; import com.google.inject.spi.ProviderWithExtensionVisitor; import java.util.Set; final class ProviderInstanceBindingImpl extends BindingImpl implements ProviderInstanceBinding { final Provider providerInstance; final ImmutableSet injectionPoints; public ProviderInstanceBindingImpl(InjectorImpl injector, Key key, Object source, InternalFactory internalFactory, Scoping scoping, Provider providerInstance, Set injectionPoints) { super(injector, key, source, internalFactory, scoping); this.providerInstance = providerInstance; this.injectionPoints = ImmutableSet.copyOf(injectionPoints); } public ProviderInstanceBindingImpl(Object source, Key key, Scoping scoping, Set injectionPoints, Provider providerInstance) { super(source, key, scoping); this.injectionPoints = ImmutableSet.copyOf(injectionPoints); this.providerInstance = providerInstance; } @SuppressWarnings("unchecked") // the extension type is always consistent with the provider type public V acceptTargetVisitor(BindingTargetVisitor visitor) { if(providerInstance instanceof ProviderWithExtensionVisitor) { return ((ProviderWithExtensionVisitor) providerInstance) .acceptExtensionVisitor(visitor, this); } else { return visitor.visit(this); } } public Provider getProviderInstance() { return providerInstance; } public Set getInjectionPoints() { return injectionPoints; } public Set> getDependencies() { return providerInstance instanceof HasDependencies ? ImmutableSet.copyOf(((HasDependencies) providerInstance).getDependencies()) : Dependency.forInjectionPoints(injectionPoints); } public BindingImpl withScoping(Scoping scoping) { return new ProviderInstanceBindingImpl( getSource(), getKey(), scoping, injectionPoints, providerInstance); } public BindingImpl withKey(Key key) { return new ProviderInstanceBindingImpl( getSource(), key, getScoping(), injectionPoints, providerInstance); } public void applyTo(Binder binder) { getScoping().applyTo( binder.withSource(getSource()).bind(getKey()).toProvider(getProviderInstance())); } @Override public String toString() { return Objects.toStringHelper(ProviderInstanceBinding.class) .add("key", getKey()) .add("source", getSource()) .add("scope", getScoping()) .add("provider", providerInstance) .toString(); } @Override public boolean equals(Object obj) { if(obj instanceof ProviderInstanceBindingImpl) { ProviderInstanceBindingImpl o = (ProviderInstanceBindingImpl)obj; return getKey().equals(o.getKey()) && getScoping().equals(o.getScoping()) && Objects.equal(providerInstance, o.providerInstance); } else { return false; } } @Override public int hashCode() { return Objects.hashCode(getKey(), getScoping()); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ProvidedByInternalFactory.java0000644000175000017500000000616411704661106031221 0ustar tonytony/* * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkState; import com.google.inject.Key; import com.google.inject.ProvidedBy; import com.google.inject.Provider; import com.google.inject.internal.InjectorImpl.JitLimitation; import com.google.inject.spi.Dependency; /** * An {@link InternalFactory} for {@literal @}{@link ProvidedBy} bindings. * * @author sameb@google.com (Sam Berlin) */ class ProvidedByInternalFactory extends ProviderInternalFactory implements DelayedInitialize { private final Class rawType; private final Class> providerType; private final Key> providerKey; private BindingImpl> providerBinding; ProvidedByInternalFactory( Class rawType, Class> providerType, Key> providerKey, boolean allowProxy, ProvisionListenerStackCallback provisionCallback) { super(providerKey, allowProxy, provisionCallback); this.rawType = rawType; this.providerType = providerType; this.providerKey = providerKey; } public void initialize(InjectorImpl injector, Errors errors) throws ErrorsException { providerBinding = injector.getBindingOrThrow(providerKey, errors, JitLimitation.NEW_OR_EXISTING_JIT); } @SuppressWarnings("unchecked")// public T get(Errors errors, InternalContext context, Dependency dependency, boolean linked) throws ErrorsException { checkState(providerBinding != null, "not initialized"); context.pushState(providerKey, providerBinding.getSource()); try { errors = errors.withSource(providerKey); Provider provider = providerBinding.getInternalFactory().get( errors, context, dependency, true); return circularGet(provider, errors, context, dependency, linked); } finally { context.popState(); } } protected T provision(javax.inject.Provider provider, Errors errors, Dependency dependency, ConstructionContext constructionContext) throws ErrorsException { try { Object o = super.provision(provider, errors, dependency, constructionContext); if (o != null && !rawType.isInstance(o)) { throw errors.subtypeNotProvided(providerType, rawType).toException(); } @SuppressWarnings("unchecked") // protected by isInstance() check above T t = (T) o; return t; } catch (RuntimeException e) { throw errors.errorInProvider(e).toException(); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ProcessedBindingData.java0000644000175000017500000000301711704661106030133 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.Lists; import java.util.List; /** * Keeps track of creation listeners & uninitialized bindings, * so they can be processed after bindings are recorded. * * @author sameb@google.com (Sam Berlin) */ class ProcessedBindingData { private final List creationListeners = Lists.newArrayList(); private final List uninitializedBindings = Lists.newArrayList(); void addCreationListener(CreationListener listener) { creationListeners.add(listener); } void addUninitializedBinding(Runnable runnable) { uninitializedBindings.add(runnable); } void initializeBindings() { for (Runnable initializer : uninitializedBindings) { initializer.run(); } } void runCreationListeners(Errors errors) { for (CreationListener creationListener : creationListeners) { creationListener.notify(errors); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/PrivateElementsImpl.java0000644000175000017500000001047211704661106030053 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.inject.Binder; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.PrivateBinder; import com.google.inject.spi.Element; import com.google.inject.spi.ElementVisitor; import com.google.inject.spi.PrivateElements; import java.util.List; import java.util.Map; import java.util.Set; /** * @author jessewilson@google.com (Jesse Wilson) */ public final class PrivateElementsImpl implements PrivateElements { /* * This class acts as both a value object and as a builder. When getElements() is called, an * immutable collection of elements is constructed and the original mutable list is nulled out. * Similarly, the exposed keys are made immutable on access. */ private final Object source; private List elementsMutable = Lists.newArrayList(); private List> exposureBuilders = Lists.newArrayList(); /** lazily instantiated */ private ImmutableList elements; /** lazily instantiated */ private ImmutableMap, Object> exposedKeysToSources; private Injector injector; public PrivateElementsImpl(Object source) { this.source = checkNotNull(source, "source"); } public Object getSource() { return source; } public List getElements() { if (elements == null) { elements = ImmutableList.copyOf(elementsMutable); elementsMutable = null; } return elements; } public Injector getInjector() { return injector; } public void initInjector(Injector injector) { checkState(this.injector == null, "injector already initialized"); this.injector = checkNotNull(injector, "injector"); } public Set> getExposedKeys() { if (exposedKeysToSources == null) { Map, Object> exposedKeysToSourcesMutable = Maps.newLinkedHashMap(); for (ExposureBuilder exposureBuilder : exposureBuilders) { exposedKeysToSourcesMutable.put(exposureBuilder.getKey(), exposureBuilder.getSource()); } exposedKeysToSources = ImmutableMap.copyOf(exposedKeysToSourcesMutable); exposureBuilders = null; } return exposedKeysToSources.keySet(); } public T acceptVisitor(ElementVisitor visitor) { return visitor.visit(this); } public List getElementsMutable() { return elementsMutable; } public void addExposureBuilder(ExposureBuilder exposureBuilder) { exposureBuilders.add(exposureBuilder); } public void applyTo(Binder binder) { PrivateBinder privateBinder = binder.withSource(source).newPrivateBinder(); for (Element element : getElements()) { element.applyTo(privateBinder); } getExposedKeys(); // ensure exposedKeysToSources is populated for (Map.Entry, Object> entry : exposedKeysToSources.entrySet()) { privateBinder.withSource(entry.getValue()).expose(entry.getKey()); } } public Object getExposedSource(Key key) { getExposedKeys(); // ensure exposedKeysToSources is populated Object source = exposedKeysToSources.get(key); checkArgument(source != null, "%s not exposed by %s.", key, this); return source; } @Override public String toString() { return Objects.toStringHelper(PrivateElements.class) .add("exposedKeys", getExposedKeys()) .add("source", getSource()) .toString(); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/PrivateElementProcessor.java0000644000175000017500000000265411704661106030751 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.Lists; import com.google.inject.spi.PrivateElements; import java.util.List; /** * Handles {@code Binder.newPrivateBinder()} elements. * * @author jessewilson@google.com (Jesse Wilson) */ final class PrivateElementProcessor extends AbstractProcessor { private final List injectorShellBuilders = Lists.newArrayList(); PrivateElementProcessor(Errors errors) { super(errors); } @Override public Boolean visit(PrivateElements privateElements) { InjectorShell.Builder builder = new InjectorShell.Builder() .parent(injector) .privateElements(privateElements); injectorShellBuilders.add(builder); return true; } public List getInjectorShellBuilders() { return injectorShellBuilders; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/Nullability.java0000644000175000017500000000175611704661106026417 0ustar tonytonypackage com.google.inject.internal; import java.lang.annotation.Annotation; /** * Whether a member supports null values injected. * *

    Support for {@code Nullable} annotations in Guice is loose. * Any annotation type whose simplename is "Nullable" is sufficient to indicate * support for null values injected. * *

    This allows support for JSR-305's * * javax.annotation.meta.Nullable annotation and IntelliJ IDEA's * * org.jetbrains.annotations.Nullable. * * @author jessewilson@google.com (Jesse Wilson) */ public class Nullability { private Nullability() {} public static boolean allowsNull(Annotation[] annotations) { for(Annotation a : annotations) { Class type = a.annotationType(); if ("Nullable".equals(type.getSimpleName())) { return true; } } return false; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/MoreTypes.java0000644000175000017500000004301511704661106026050 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Objects; import com.google.common.collect.ImmutableMap; import com.google.inject.ConfigurationException; import com.google.inject.TypeLiteral; import com.google.inject.util.Types; import java.io.Serializable; import java.lang.reflect.Array; import java.lang.reflect.GenericArrayType; import java.lang.reflect.GenericDeclaration; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import java.lang.reflect.WildcardType; import java.util.Arrays; import java.util.Map; import java.util.NoSuchElementException; /** * Static methods for working with types that we aren't publishing in the * public {@code Types} API. * * @author jessewilson@google.com (Jesse Wilson) */ public class MoreTypes { public static final Type[] EMPTY_TYPE_ARRAY = new Type[] {}; private MoreTypes() {} private static final Map, TypeLiteral> PRIMITIVE_TO_WRAPPER = new ImmutableMap.Builder, TypeLiteral>() .put(TypeLiteral.get(boolean.class), TypeLiteral.get(Boolean.class)) .put(TypeLiteral.get(byte.class), TypeLiteral.get(Byte.class)) .put(TypeLiteral.get(short.class), TypeLiteral.get(Short.class)) .put(TypeLiteral.get(int.class), TypeLiteral.get(Integer.class)) .put(TypeLiteral.get(long.class), TypeLiteral.get(Long.class)) .put(TypeLiteral.get(float.class), TypeLiteral.get(Float.class)) .put(TypeLiteral.get(double.class), TypeLiteral.get(Double.class)) .put(TypeLiteral.get(char.class), TypeLiteral.get(Character.class)) .put(TypeLiteral.get(void.class), TypeLiteral.get(Void.class)) .build(); /** * Returns an type that's appropriate for use in a key. * *

    If the raw type of {@code typeLiteral} is a {@code javax.inject.Provider}, this returns a * {@code com.google.inject.Provider} with the same type parameters. * *

    If the type is a primitive, the corresponding wrapper type will be returned. * * @throws ConfigurationException if {@code type} contains a type variable */ public static TypeLiteral canonicalizeForKey(TypeLiteral typeLiteral) { Type type = typeLiteral.getType(); if (!isFullySpecified(type)) { Errors errors = new Errors().keyNotFullySpecified(typeLiteral); throw new ConfigurationException(errors.getMessages()); } if (typeLiteral.getRawType() == javax.inject.Provider.class) { ParameterizedType parameterizedType = (ParameterizedType) type; // the following casts are generally unsafe, but com.google.inject.Provider extends // javax.inject.Provider and is covariant @SuppressWarnings("unchecked") TypeLiteral guiceProviderType = (TypeLiteral) TypeLiteral.get( Types.providerOf(parameterizedType.getActualTypeArguments()[0])); return guiceProviderType; } @SuppressWarnings("unchecked") TypeLiteral wrappedPrimitives = (TypeLiteral) PRIMITIVE_TO_WRAPPER.get(typeLiteral); return wrappedPrimitives != null ? wrappedPrimitives : typeLiteral; } /** * Returns true if {@code type} is free from type variables. */ private static boolean isFullySpecified(Type type) { if (type instanceof Class) { return true; } else if (type instanceof CompositeType) { return ((CompositeType) type).isFullySpecified(); } else if (type instanceof TypeVariable){ return false; } else { return ((CompositeType) canonicalize(type)).isFullySpecified(); } } /** * Returns a type that is functionally equal but not necessarily equal * according to {@link Object#equals(Object) Object.equals()}. The returned * type is {@link Serializable}. */ public static Type canonicalize(Type type) { if (type instanceof Class) { Class c = (Class) type; return c.isArray() ? new GenericArrayTypeImpl(canonicalize(c.getComponentType())) : c; } else if (type instanceof CompositeType) { return type; } else if (type instanceof ParameterizedType) { ParameterizedType p = (ParameterizedType) type; return new ParameterizedTypeImpl(p.getOwnerType(), p.getRawType(), p.getActualTypeArguments()); } else if (type instanceof GenericArrayType) { GenericArrayType g = (GenericArrayType) type; return new GenericArrayTypeImpl(g.getGenericComponentType()); } else if (type instanceof WildcardType) { WildcardType w = (WildcardType) type; return new WildcardTypeImpl(w.getUpperBounds(), w.getLowerBounds()); } else { // type is either serializable as-is or unsupported return type; } } public static Class getRawType(Type type) { if (type instanceof Class) { // type is a normal class. return (Class) type; } else if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; // I'm not exactly sure why getRawType() returns Type instead of Class. // Neal isn't either but suspects some pathological case related // to nested classes exists. Type rawType = parameterizedType.getRawType(); checkArgument(rawType instanceof Class, "Expected a Class, but <%s> is of type %s", type, type.getClass().getName()); return (Class) rawType; } else if (type instanceof GenericArrayType) { Type componentType = ((GenericArrayType)type).getGenericComponentType(); return Array.newInstance(getRawType(componentType), 0).getClass(); } else if (type instanceof TypeVariable) { // we could use the variable's bounds, but that'll won't work if there are multiple. // having a raw type that's more general than necessary is okay return Object.class; } else { throw new IllegalArgumentException("Expected a Class, ParameterizedType, or " + "GenericArrayType, but <" + type + "> is of type " + type.getClass().getName()); } } /** * Returns true if {@code a} and {@code b} are equal. */ public static boolean equals(Type a, Type b) { if (a == b) { // also handles (a == null && b == null) return true; } else if (a instanceof Class) { // Class already specifies equals(). return a.equals(b); } else if (a instanceof ParameterizedType) { if (!(b instanceof ParameterizedType)) { return false; } // TODO: save a .clone() call ParameterizedType pa = (ParameterizedType) a; ParameterizedType pb = (ParameterizedType) b; return Objects.equal(pa.getOwnerType(), pb.getOwnerType()) && pa.getRawType().equals(pb.getRawType()) && Arrays.equals(pa.getActualTypeArguments(), pb.getActualTypeArguments()); } else if (a instanceof GenericArrayType) { if (!(b instanceof GenericArrayType)) { return false; } GenericArrayType ga = (GenericArrayType) a; GenericArrayType gb = (GenericArrayType) b; return equals(ga.getGenericComponentType(), gb.getGenericComponentType()); } else if (a instanceof WildcardType) { if (!(b instanceof WildcardType)) { return false; } WildcardType wa = (WildcardType) a; WildcardType wb = (WildcardType) b; return Arrays.equals(wa.getUpperBounds(), wb.getUpperBounds()) && Arrays.equals(wa.getLowerBounds(), wb.getLowerBounds()); } else if (a instanceof TypeVariable) { if (!(b instanceof TypeVariable)) { return false; } TypeVariable va = (TypeVariable) a; TypeVariable vb = (TypeVariable) b; return va.getGenericDeclaration() == vb.getGenericDeclaration() && va.getName().equals(vb.getName()); } else { // This isn't a type we support. Could be a generic array type, wildcard type, etc. return false; } } private static int hashCodeOrZero(Object o) { return o != null ? o.hashCode() : 0; } public static String typeToString(Type type) { return type instanceof Class ? ((Class) type).getName() : type.toString(); } /** * Returns the generic supertype for {@code supertype}. For example, given a class {@code * IntegerSet}, the result for when supertype is {@code Set.class} is {@code Set} and the * result when the supertype is {@code Collection.class} is {@code Collection}. */ public static Type getGenericSupertype(Type type, Class rawType, Class toResolve) { if (toResolve == rawType) { return type; } // we skip searching through interfaces if unknown is an interface if (toResolve.isInterface()) { Class[] interfaces = rawType.getInterfaces(); for (int i = 0, length = interfaces.length; i < length; i++) { if (interfaces[i] == toResolve) { return rawType.getGenericInterfaces()[i]; } else if (toResolve.isAssignableFrom(interfaces[i])) { return getGenericSupertype(rawType.getGenericInterfaces()[i], interfaces[i], toResolve); } } } // check our supertypes if (!rawType.isInterface()) { while (rawType != Object.class) { Class rawSupertype = rawType.getSuperclass(); if (rawSupertype == toResolve) { return rawType.getGenericSuperclass(); } else if (toResolve.isAssignableFrom(rawSupertype)) { return getGenericSupertype(rawType.getGenericSuperclass(), rawSupertype, toResolve); } rawType = rawSupertype; } } // we can't resolve this further return toResolve; } public static Type resolveTypeVariable(Type type, Class rawType, TypeVariable unknown) { Class declaredByRaw = declaringClassOf(unknown); // we can't reduce this further if (declaredByRaw == null) { return unknown; } Type declaredBy = getGenericSupertype(type, rawType, declaredByRaw); if (declaredBy instanceof ParameterizedType) { int index = indexOf(declaredByRaw.getTypeParameters(), unknown); return ((ParameterizedType) declaredBy).getActualTypeArguments()[index]; } return unknown; } private static int indexOf(Object[] array, Object toFind) { for (int i = 0; i < array.length; i++) { if (toFind.equals(array[i])) { return i; } } throw new NoSuchElementException(); } /** * Returns the declaring class of {@code typeVariable}, or {@code null} if it was not declared by * a class. */ private static Class declaringClassOf(TypeVariable typeVariable) { GenericDeclaration genericDeclaration = typeVariable.getGenericDeclaration(); return genericDeclaration instanceof Class ? (Class) genericDeclaration : null; } public static class ParameterizedTypeImpl implements ParameterizedType, Serializable, CompositeType { private final Type ownerType; private final Type rawType; private final Type[] typeArguments; public ParameterizedTypeImpl(Type ownerType, Type rawType, Type... typeArguments) { // require an owner type if the raw type needs it if (rawType instanceof Class) { Class rawTypeAsClass = (Class) rawType; checkArgument(ownerType != null || rawTypeAsClass.getEnclosingClass() == null, "No owner type for enclosed %s", rawType); checkArgument(ownerType == null || rawTypeAsClass.getEnclosingClass() != null, "Owner type for unenclosed %s", rawType); } this.ownerType = ownerType == null ? null : canonicalize(ownerType); this.rawType = canonicalize(rawType); this.typeArguments = typeArguments.clone(); for (int t = 0; t < this.typeArguments.length; t++) { checkNotNull(this.typeArguments[t], "type parameter"); checkNotPrimitive(this.typeArguments[t], "type parameters"); this.typeArguments[t] = canonicalize(this.typeArguments[t]); } } public Type[] getActualTypeArguments() { return typeArguments.clone(); } public Type getRawType() { return rawType; } public Type getOwnerType() { return ownerType; } public boolean isFullySpecified() { if (ownerType != null && !MoreTypes.isFullySpecified(ownerType)) { return false; } if (!MoreTypes.isFullySpecified(rawType)) { return false; } for (Type type : typeArguments) { if (!MoreTypes.isFullySpecified(type)) { return false; } } return true; } @Override public boolean equals(Object other) { return other instanceof ParameterizedType && MoreTypes.equals(this, (ParameterizedType) other); } @Override public int hashCode() { return Arrays.hashCode(typeArguments) ^ rawType.hashCode() ^ hashCodeOrZero(ownerType); } @Override public String toString() { StringBuilder stringBuilder = new StringBuilder(30 * (typeArguments.length + 1)); stringBuilder.append(typeToString(rawType)); if (typeArguments.length == 0) { return stringBuilder.toString(); } stringBuilder.append("<").append(typeToString(typeArguments[0])); for (int i = 1; i < typeArguments.length; i++) { stringBuilder.append(", ").append(typeToString(typeArguments[i])); } return stringBuilder.append(">").toString(); } private static final long serialVersionUID = 0; } public static class GenericArrayTypeImpl implements GenericArrayType, Serializable, CompositeType { private final Type componentType; public GenericArrayTypeImpl(Type componentType) { this.componentType = canonicalize(componentType); } public Type getGenericComponentType() { return componentType; } public boolean isFullySpecified() { return MoreTypes.isFullySpecified(componentType); } @Override public boolean equals(Object o) { return o instanceof GenericArrayType && MoreTypes.equals(this, (GenericArrayType) o); } @Override public int hashCode() { return componentType.hashCode(); } @Override public String toString() { return typeToString(componentType) + "[]"; } private static final long serialVersionUID = 0; } /** * The WildcardType interface supports multiple upper bounds and multiple * lower bounds. We only support what the Java 6 language needs - at most one * bound. If a lower bound is set, the upper bound must be Object.class. */ public static class WildcardTypeImpl implements WildcardType, Serializable, CompositeType { private final Type upperBound; private final Type lowerBound; public WildcardTypeImpl(Type[] upperBounds, Type[] lowerBounds) { checkArgument(lowerBounds.length <= 1, "Must have at most one lower bound."); checkArgument(upperBounds.length == 1, "Must have exactly one upper bound."); if (lowerBounds.length == 1) { checkNotNull(lowerBounds[0], "lowerBound"); checkNotPrimitive(lowerBounds[0], "wildcard bounds"); checkArgument(upperBounds[0] == Object.class, "bounded both ways"); this.lowerBound = canonicalize(lowerBounds[0]); this.upperBound = Object.class; } else { checkNotNull(upperBounds[0], "upperBound"); checkNotPrimitive(upperBounds[0], "wildcard bounds"); this.lowerBound = null; this.upperBound = canonicalize(upperBounds[0]); } } public Type[] getUpperBounds() { return new Type[] { upperBound }; } public Type[] getLowerBounds() { return lowerBound != null ? new Type[] { lowerBound } : EMPTY_TYPE_ARRAY; } public boolean isFullySpecified() { return MoreTypes.isFullySpecified(upperBound) && (lowerBound == null || MoreTypes.isFullySpecified(lowerBound)); } @Override public boolean equals(Object other) { return other instanceof WildcardType && MoreTypes.equals(this, (WildcardType) other); } @Override public int hashCode() { // this equals Arrays.hashCode(getLowerBounds()) ^ Arrays.hashCode(getUpperBounds()); return (lowerBound != null ? 31 + lowerBound.hashCode() : 1) ^ (31 + upperBound.hashCode()); } @Override public String toString() { if (lowerBound != null) { return "? super " + typeToString(lowerBound); } else if (upperBound == Object.class) { return "?"; } else { return "? extends " + typeToString(upperBound); } } private static final long serialVersionUID = 0; } private static void checkNotPrimitive(Type type, String use) { checkArgument(!(type instanceof Class) || !((Class) type).isPrimitive(), "Primitive types are not allowed in %s: %s", use, type); } /** A type formed from other types, such as arrays, parameterized types or wildcard types */ private interface CompositeType { /** Returns true if there are no type variables in this type. */ boolean isFullySpecified(); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/MethodAspect.java0000644000175000017500000000435111704661106026501 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.matcher.Matcher; import org.aopalliance.intercept.MethodInterceptor; import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; /** * Ties a matcher to a method interceptor. * * @author crazybob@google.com (Bob Lee) */ final class MethodAspect { private final Matcher> classMatcher; private final Matcher methodMatcher; private final List interceptors; /** * @param classMatcher matches classes the interceptor should apply to. For example: {@code * only(Runnable.class)}. * @param methodMatcher matches methods the interceptor should apply to. For example: {@code * annotatedWith(Transactional.class)}. * @param interceptors to apply */ MethodAspect(Matcher> classMatcher, Matcher methodMatcher, List interceptors) { this.classMatcher = checkNotNull(classMatcher, "class matcher"); this.methodMatcher = checkNotNull(methodMatcher, "method matcher"); this.interceptors = checkNotNull(interceptors, "interceptors"); } MethodAspect(Matcher> classMatcher, Matcher methodMatcher, MethodInterceptor... interceptors) { this(classMatcher, methodMatcher, Arrays.asList(interceptors)); } boolean matches(Class clazz) { return classMatcher.matches(clazz); } boolean matches(Method method) { return methodMatcher.matches(method); } List interceptors() { return interceptors; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/MessageProcessor.java0000644000175000017500000000313111704661106027400 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.Guice; import com.google.inject.spi.Message; import java.util.logging.Level; import java.util.logging.Logger; /** * Handles {@code Binder.addError} commands. * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) */ final class MessageProcessor extends AbstractProcessor { private static final Logger logger = Logger.getLogger(Guice.class.getName()); MessageProcessor(Errors errors) { super(errors); } @Override public Boolean visit(Message message) { if (message.getCause() != null) { String rootMessage = getRootMessage(message.getCause()); logger.log(Level.INFO, "An exception was caught and reported. Message: " + rootMessage, message.getCause()); } errors.addMessage(message); return true; } public static String getRootMessage(Throwable t) { Throwable cause = t.getCause(); return cause == null ? t.toString() : getRootMessage(cause); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/MembersInjectorStore.java0000644000175000017500000001157311704661106030232 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.inject.ConfigurationException; import com.google.inject.TypeLiteral; import com.google.inject.spi.InjectionPoint; import com.google.inject.spi.TypeListenerBinding; import java.lang.reflect.Field; import java.util.List; import java.util.Set; /** * Members injectors by type. * * @author jessewilson@google.com (Jesse Wilson) */ final class MembersInjectorStore { private final InjectorImpl injector; private final ImmutableList typeListenerBindings; private final FailableCache, MembersInjectorImpl> cache = new FailableCache, MembersInjectorImpl>() { @Override protected MembersInjectorImpl create(TypeLiteral type, Errors errors) throws ErrorsException { return createWithListeners(type, errors); } }; MembersInjectorStore(InjectorImpl injector, List typeListenerBindings) { this.injector = injector; this.typeListenerBindings = ImmutableList.copyOf(typeListenerBindings); } /** * Returns true if any type listeners are installed. Other code may take shortcuts when there * aren't any type listeners. */ public boolean hasTypeListeners() { return !typeListenerBindings.isEmpty(); } /** * Returns a new complete members injector with injection listeners registered. */ @SuppressWarnings("unchecked") // the MembersInjector type always agrees with the passed type public MembersInjectorImpl get(TypeLiteral key, Errors errors) throws ErrorsException { return (MembersInjectorImpl) cache.get(key, errors); } /** * Purges a type literal from the cache. Use this only if the type is not actually valid for * binding and needs to be purged. (See issue 319 and * ImplicitBindingTest#testCircularJitBindingsLeaveNoResidue and * #testInstancesRequestingProvidersForThemselvesWithChildInjectors for examples of when this is * necessary.) * * Returns true if the type was stored in the cache, false otherwise. */ boolean remove(TypeLiteral type) { return cache.remove(type); } /** * Creates a new members injector and attaches both injection listeners and method aspects. */ private MembersInjectorImpl createWithListeners(TypeLiteral type, Errors errors) throws ErrorsException { int numErrorsBefore = errors.size(); Set injectionPoints; try { injectionPoints = InjectionPoint.forInstanceMethodsAndFields(type); } catch (ConfigurationException e) { errors.merge(e.getErrorMessages()); injectionPoints = e.getPartialValue(); } ImmutableList injectors = getInjectors(injectionPoints, errors); errors.throwIfNewErrors(numErrorsBefore); EncounterImpl encounter = new EncounterImpl(errors, injector.lookups); for (TypeListenerBinding typeListener : typeListenerBindings) { if (typeListener.getTypeMatcher().matches(type)) { try { typeListener.getListener().hear(type, encounter); } catch (RuntimeException e) { errors.errorNotifyingTypeListener(typeListener, type, e); } } } encounter.invalidate(); errors.throwIfNewErrors(numErrorsBefore); return new MembersInjectorImpl(injector, type, encounter, injectors); } /** * Returns the injectors for the specified injection points. */ ImmutableList getInjectors( Set injectionPoints, Errors errors) { List injectors = Lists.newArrayList(); for (InjectionPoint injectionPoint : injectionPoints) { try { Errors errorsForMember = injectionPoint.isOptional() ? new Errors(injectionPoint) : errors.withSource(injectionPoint); SingleMemberInjector injector = injectionPoint.getMember() instanceof Field ? new SingleFieldInjector(this.injector, injectionPoint, errorsForMember) : new SingleMethodInjector(this.injector, injectionPoint, errorsForMember); injectors.add(injector); } catch (ErrorsException ignoredForNow) { // ignored for now } } return ImmutableList.copyOf(injectors); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/MembersInjectorImpl.java0000644000175000017500000001247411704661106030040 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.inject.Key; import com.google.inject.MembersInjector; import com.google.inject.TypeLiteral; import com.google.inject.spi.InjectionListener; import com.google.inject.spi.InjectionPoint; /** * Injects members of instances of a given type. * * @author jessewilson@google.com (Jesse Wilson) */ final class MembersInjectorImpl implements MembersInjector { private final TypeLiteral typeLiteral; private final InjectorImpl injector; private final ImmutableList memberInjectors; private final ImmutableList> userMembersInjectors; private final ImmutableList> injectionListeners; /*if[AOP]*/ private final ImmutableList addedAspects; /*end[AOP]*/ MembersInjectorImpl(InjectorImpl injector, TypeLiteral typeLiteral, EncounterImpl encounter, ImmutableList memberInjectors) { this.injector = injector; this.typeLiteral = typeLiteral; this.memberInjectors = memberInjectors; this.userMembersInjectors = encounter.getMembersInjectors(); this.injectionListeners = encounter.getInjectionListeners(); /*if[AOP]*/ this.addedAspects = encounter.getAspects(); /*end[AOP]*/ } public ImmutableList getMemberInjectors() { return memberInjectors; } public void injectMembers(T instance) { Errors errors = new Errors(typeLiteral); try { injectAndNotify(instance, errors, null, typeLiteral, false); } catch (ErrorsException e) { errors.merge(e.getErrors()); } errors.throwProvisionExceptionIfErrorsExist(); } void injectAndNotify(final T instance, final Errors errors, final Key key, final Object source, final boolean toolableOnly) throws ErrorsException { if (instance == null) { return; } injector.callInContext(new ContextualCallable() { public Void call(InternalContext context) throws ErrorsException { context.pushState(key, source); try { injectMembers(instance, errors, context, toolableOnly); } finally { context.popState(); } return null; } }); // TODO: We *could* notify listeners too here, // but it's not clear if we want to. There's no way to know // if a MembersInjector from the usersMemberInjector list wants // toolable injections, so do we really want to notify // about injection? (We could take a strategy of only notifying // if atleast one InjectionPoint was toolable, in which case // the above callInContext could return 'true' if it injected // anything.) if(!toolableOnly) { notifyListeners(instance, errors); } } void notifyListeners(T instance, Errors errors) throws ErrorsException { int numErrorsBefore = errors.size(); for (InjectionListener injectionListener : injectionListeners) { try { injectionListener.afterInjection(instance); } catch (RuntimeException e) { errors.errorNotifyingInjectionListener(injectionListener, typeLiteral, e); } } errors.throwIfNewErrors(numErrorsBefore); } void injectMembers(T t, Errors errors, InternalContext context, boolean toolableOnly) { // optimization: use manual for/each to save allocating an iterator here for (int i = 0, size = memberInjectors.size(); i < size; i++) { SingleMemberInjector injector = memberInjectors.get(i); if(!toolableOnly || injector.getInjectionPoint().isToolable()) { injector.inject(errors, context, t); } } // TODO: There's no way to know if a user's MembersInjector wants toolable injections. if(!toolableOnly) { // optimization: use manual for/each to save allocating an iterator here for (int i = 0, size = userMembersInjectors.size(); i < size; i++) { MembersInjector userMembersInjector = userMembersInjectors.get(i); try { userMembersInjector.injectMembers(t); } catch (RuntimeException e) { errors.errorInUserInjector(userMembersInjector, typeLiteral, e); } } } } @Override public String toString() { return "MembersInjector<" + typeLiteral + ">"; } public ImmutableSet getInjectionPoints() { ImmutableSet.Builder builder = ImmutableSet.builder(); for (SingleMemberInjector memberInjector : memberInjectors) { builder.add(memberInjector.getInjectionPoint()); } return builder.build(); } /*if[AOP]*/ public ImmutableList getAddedAspects() { return addedAspects; } /*end[AOP]*/ } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/Lookups.java0000644000175000017500000000212211704661106025547 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.Key; import com.google.inject.MembersInjector; import com.google.inject.Provider; import com.google.inject.TypeLiteral; /** * Accessors for providers and members injectors. The returned values will not be functional until * the injector has been created. * * @author jessewilson@google.com (Jesse Wilson) */ interface Lookups { Provider getProvider(Key key); MembersInjector getMembersInjector(TypeLiteral type); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/LookupProcessor.java0000644000175000017500000000346311704661106027275 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.MembersInjector; import com.google.inject.Provider; import com.google.inject.spi.MembersInjectorLookup; import com.google.inject.spi.ProviderLookup; /** * Handles {@code Binder.getProvider} and {@code Binder.getMembersInjector(TypeLiteral)} commands. * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) */ final class LookupProcessor extends AbstractProcessor { LookupProcessor(Errors errors) { super(errors); } @Override public Boolean visit(MembersInjectorLookup lookup) { try { MembersInjector membersInjector = injector.membersInjectorStore.get(lookup.getType(), errors); lookup.initializeDelegate(membersInjector); } catch (ErrorsException e) { errors.merge(e.getErrors()); // TODO: source } return true; } @Override public Boolean visit(ProviderLookup lookup) { // ensure the provider can be created try { Provider provider = injector.getProviderOrThrow(lookup.getKey(), errors); lookup.initializeDelegate(provider); } catch (ErrorsException e) { errors.merge(e.getErrors()); // TODO: source } return true; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ListenerBindingProcessor.java0000644000175000017500000000235111704661106031077 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.spi.ProvisionListenerBinding; import com.google.inject.spi.TypeListenerBinding; /** * Handles {@code Binder#bindListener} commands. * * @author jessewilson@google.com (Jesse Wilson) */ final class ListenerBindingProcessor extends AbstractProcessor { ListenerBindingProcessor(Errors errors) { super(errors); } @Override public Boolean visit(TypeListenerBinding binding) { injector.state.addTypeListener(binding); return true; } @Override public Boolean visit(ProvisionListenerBinding binding) { injector.state.addProvisionListener(binding); return true; } }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/LinkedProviderBindingImpl.java0000644000175000017500000001047111704661106031157 0ustar tonytony/* * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.inject.Binder; import com.google.inject.Key; import com.google.inject.spi.BindingTargetVisitor; import com.google.inject.spi.Dependency; import com.google.inject.spi.HasDependencies; import com.google.inject.spi.ProviderKeyBinding; import java.util.Set; final class LinkedProviderBindingImpl extends BindingImpl implements ProviderKeyBinding, HasDependencies, DelayedInitialize { final Key> providerKey; final DelayedInitialize delayedInitializer; private LinkedProviderBindingImpl(InjectorImpl injector, Key key, Object source, InternalFactory internalFactory, Scoping scoping, Key> providerKey, DelayedInitialize delayedInitializer) { super(injector, key, source, internalFactory, scoping); this.providerKey = providerKey; this.delayedInitializer = delayedInitializer; } public LinkedProviderBindingImpl(InjectorImpl injector, Key key, Object source, InternalFactory internalFactory, Scoping scoping, Key> providerKey) { this(injector, key, source, internalFactory, scoping, providerKey, null); } LinkedProviderBindingImpl(Object source, Key key, Scoping scoping, Key> providerKey) { super(source, key, scoping); this.providerKey = providerKey; this.delayedInitializer = null; } static LinkedProviderBindingImpl createWithInitializer(InjectorImpl injector, Key key, Object source, InternalFactory internalFactory, Scoping scoping, Key> providerKey, DelayedInitialize delayedInitializer) { return new LinkedProviderBindingImpl(injector, key, source, internalFactory, scoping, providerKey, delayedInitializer); } public V acceptTargetVisitor(BindingTargetVisitor visitor) { return visitor.visit(this); } public Key> getProviderKey() { return providerKey; } public void initialize(InjectorImpl injector, Errors errors) throws ErrorsException { if (delayedInitializer != null) { delayedInitializer.initialize(injector, errors); } } public Set> getDependencies() { return ImmutableSet.>of(Dependency.get(providerKey)); } public BindingImpl withScoping(Scoping scoping) { return new LinkedProviderBindingImpl(getSource(), getKey(), scoping, providerKey); } public BindingImpl withKey(Key key) { return new LinkedProviderBindingImpl(getSource(), key, getScoping(), providerKey); } public void applyTo(Binder binder) { getScoping().applyTo(binder.withSource(getSource()) .bind(getKey()).toProvider(getProviderKey())); } @Override public String toString() { return Objects.toStringHelper(ProviderKeyBinding.class) .add("key", getKey()) .add("source", getSource()) .add("scope", getScoping()) .add("provider", providerKey) .toString(); } @Override public boolean equals(Object obj) { if(obj instanceof LinkedProviderBindingImpl) { LinkedProviderBindingImpl o = (LinkedProviderBindingImpl)obj; return getKey().equals(o.getKey()) && getScoping().equals(o.getScoping()) && Objects.equal(providerKey, o.providerKey); } else { return false; } } @Override public int hashCode() { return Objects.hashCode(getKey(), getScoping(), providerKey); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/LinkedBindingImpl.java0000644000175000017500000000571011704661106027444 0ustar tonytony/* * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.inject.Binder; import com.google.inject.Key; import com.google.inject.spi.BindingTargetVisitor; import com.google.inject.spi.Dependency; import com.google.inject.spi.HasDependencies; import com.google.inject.spi.LinkedKeyBinding; import java.util.Set; public final class LinkedBindingImpl extends BindingImpl implements LinkedKeyBinding, HasDependencies { final Key targetKey; public LinkedBindingImpl(InjectorImpl injector, Key key, Object source, InternalFactory internalFactory, Scoping scoping, Key targetKey) { super(injector, key, source, internalFactory, scoping); this.targetKey = targetKey; } public LinkedBindingImpl(Object source, Key key, Scoping scoping, Key targetKey) { super(source, key, scoping); this.targetKey = targetKey; } public V acceptTargetVisitor(BindingTargetVisitor visitor) { return visitor.visit(this); } public Key getLinkedKey() { return targetKey; } public Set> getDependencies() { return ImmutableSet.>of(Dependency.get(targetKey)); } public BindingImpl withScoping(Scoping scoping) { return new LinkedBindingImpl(getSource(), getKey(), scoping, targetKey); } public BindingImpl withKey(Key key) { return new LinkedBindingImpl(getSource(), key, getScoping(), targetKey); } public void applyTo(Binder binder) { getScoping().applyTo(binder.withSource(getSource()).bind(getKey()).to(getLinkedKey())); } @Override public String toString() { return Objects.toStringHelper(LinkedKeyBinding.class) .add("key", getKey()) .add("source", getSource()) .add("scope", getScoping()) .add("target", targetKey) .toString(); } @Override public boolean equals(Object obj) { if(obj instanceof LinkedBindingImpl) { LinkedBindingImpl o = (LinkedBindingImpl)obj; return getKey().equals(o.getKey()) && getScoping().equals(o.getScoping()) && Objects.equal(targetKey, o.targetKey); } else { return false; } } @Override public int hashCode() { return Objects.hashCode(getKey(), getScoping(), targetKey); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/InternalInjectorCreator.java0000644000175000017500000002665111704661106030722 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.inject.Binding; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.MembersInjector; import com.google.inject.Module; import com.google.inject.Provider; import com.google.inject.Scope; import com.google.inject.Stage; import com.google.inject.TypeLiteral; import com.google.inject.internal.util.Stopwatch; import com.google.inject.spi.Dependency; import com.google.inject.spi.TypeConverterBinding; import java.lang.annotation.Annotation; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; /** * Builds a tree of injectors. This is a primary injector, plus child injectors needed for each * {@code Binder.newPrivateBinder() private environment}. The primary injector is not necessarily a * top-level injector. * *

    Injector construction happens in two phases. *

      *
    1. Static building. In this phase, we interpret commands, create bindings, and inspect * dependencies. During this phase, we hold a lock to ensure consistency with parent injectors. * No user code is executed in this phase.
    2. *
    3. Dynamic injection. In this phase, we call user code. We inject members that requested * injection. This may require user's objects be created and their providers be called. And we * create eager singletons. In this phase, user code may have started other threads. This phase * is not executed for injectors created using {@link Stage#TOOL the tool stage}
    4. *
    * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) */ public final class InternalInjectorCreator { private final Stopwatch stopwatch = new Stopwatch(); private final Errors errors = new Errors(); private final Initializer initializer = new Initializer(); private final ProcessedBindingData bindingData; private final InjectionRequestProcessor injectionRequestProcessor; private final InjectorShell.Builder shellBuilder = new InjectorShell.Builder(); private List shells; public InternalInjectorCreator() { injectionRequestProcessor = new InjectionRequestProcessor(errors, initializer); bindingData = new ProcessedBindingData(); } public InternalInjectorCreator stage(Stage stage) { shellBuilder.stage(stage); return this; } /** * Sets the parent of the injector to-be-constructed. As a side effect, this sets this injector's * stage to the stage of {@code parent} and sets {@link #requireExplicitBindings()} if the parent * injector also required them. */ public InternalInjectorCreator parentInjector(InjectorImpl parent) { shellBuilder.parent(parent); return this; } public InternalInjectorCreator addModules(Iterable modules) { shellBuilder.addModules(modules); return this; } public Injector build() { if (shellBuilder == null) { throw new AssertionError("Already built, builders are not reusable."); } // Synchronize while we're building up the bindings and other injector state. This ensures that // the JIT bindings in the parent injector don't change while we're being built synchronized (shellBuilder.lock()) { shells = shellBuilder.build(initializer, bindingData, stopwatch, errors); stopwatch.resetAndLog("Injector construction"); initializeStatically(); } injectDynamically(); if (shellBuilder.getStage() == Stage.TOOL) { // wrap the primaryInjector in a ToolStageInjector // to prevent non-tool-friendy methods from being called. return new ToolStageInjector(primaryInjector()); } else { return primaryInjector(); } } /** Initialize and validate everything. */ private void initializeStatically() { bindingData.initializeBindings(); stopwatch.resetAndLog("Binding initialization"); for (InjectorShell shell : shells) { shell.getInjector().index(); } stopwatch.resetAndLog("Binding indexing"); injectionRequestProcessor.process(shells); stopwatch.resetAndLog("Collecting injection requests"); bindingData.runCreationListeners(errors); stopwatch.resetAndLog("Binding validation"); injectionRequestProcessor.validate(); stopwatch.resetAndLog("Static validation"); initializer.validateOustandingInjections(errors); stopwatch.resetAndLog("Instance member validation"); new LookupProcessor(errors).process(shells); for (InjectorShell shell : shells) { ((DeferredLookups) shell.getInjector().lookups).initialize(errors); } stopwatch.resetAndLog("Provider verification"); for (InjectorShell shell : shells) { if (!shell.getElements().isEmpty()) { throw new AssertionError("Failed to execute " + shell.getElements()); } } errors.throwCreationExceptionIfErrorsExist(); } /** * Returns the injector being constructed. This is not necessarily the root injector. */ private Injector primaryInjector() { return shells.get(0).getInjector(); } /** * Inject everything that can be injected. This method is intentionally not synchronized. If we * locked while injecting members (ie. running user code), things would deadlock should the user * code build a just-in-time binding from another thread. */ private void injectDynamically() { injectionRequestProcessor.injectMembers(); stopwatch.resetAndLog("Static member injection"); initializer.injectAll(errors); stopwatch.resetAndLog("Instance injection"); errors.throwCreationExceptionIfErrorsExist(); if(shellBuilder.getStage() != Stage.TOOL) { for (InjectorShell shell : shells) { loadEagerSingletons(shell.getInjector(), shellBuilder.getStage(), errors); } stopwatch.resetAndLog("Preloading singletons"); } errors.throwCreationExceptionIfErrorsExist(); } /** * Loads eager singletons, or all singletons if we're in Stage.PRODUCTION. Bindings discovered * while we're binding these singletons are not be eager. */ void loadEagerSingletons(InjectorImpl injector, Stage stage, final Errors errors) { @SuppressWarnings("unchecked") // casting Collection to Collection is safe Iterable> candidateBindings = ImmutableList.copyOf(Iterables.concat( (Collection) injector.state.getExplicitBindingsThisLevel().values(), injector.jitBindings.values())); for (final BindingImpl binding : candidateBindings) { if (isEagerSingleton(injector, binding, stage)) { try { injector.callInContext(new ContextualCallable() { Dependency dependency = Dependency.get(binding.getKey()); public Void call(InternalContext context) { Dependency previous = context.pushDependency(dependency, binding.getSource()); Errors errorsForBinding = errors.withSource(dependency); try { binding.getInternalFactory().get(errorsForBinding, context, dependency, false); } catch (ErrorsException e) { errorsForBinding.merge(e.getErrors()); } finally { context.popStateAndSetDependency(previous); } return null; } }); } catch (ErrorsException e) { throw new AssertionError(); } } } } private boolean isEagerSingleton(InjectorImpl injector, BindingImpl binding, Stage stage) { if (binding.getScoping().isEagerSingleton(stage)) { return true; } // handle a corner case where a child injector links to a binding in a parent injector, and // that binding is singleton. We won't catch this otherwise because we only iterate the child's // bindings. if (binding instanceof LinkedBindingImpl) { Key linkedBinding = ((LinkedBindingImpl) binding).getLinkedKey(); return isEagerSingleton(injector, injector.getBinding(linkedBinding), stage); } return false; } /** {@link Injector} exposed to users in {@link Stage#TOOL}. */ static class ToolStageInjector implements Injector { private final Injector delegateInjector; ToolStageInjector(Injector delegateInjector) { this.delegateInjector = delegateInjector; } public void injectMembers(Object o) { throw new UnsupportedOperationException( "Injector.injectMembers(Object) is not supported in Stage.TOOL"); } public Map, Binding> getBindings() { return this.delegateInjector.getBindings(); } public Map, Binding> getAllBindings() { return this.delegateInjector.getAllBindings(); } public Binding getBinding(Key key) { return this.delegateInjector.getBinding(key); } public Binding getBinding(Class type) { return this.delegateInjector.getBinding(type); } public Binding getExistingBinding(Key key) { return this.delegateInjector.getExistingBinding(key); } public List> findBindingsByType(TypeLiteral type) { return this.delegateInjector.findBindingsByType(type); } public Injector getParent() { return delegateInjector.getParent(); } public Injector createChildInjector(Iterable modules) { return delegateInjector.createChildInjector(modules); } public Injector createChildInjector(Module... modules) { return delegateInjector.createChildInjector(modules); } public Map, Scope> getScopeBindings() { return delegateInjector.getScopeBindings(); } public Set getTypeConverterBindings() { return delegateInjector.getTypeConverterBindings(); } public Provider getProvider(Key key) { throw new UnsupportedOperationException( "Injector.getProvider(Key) is not supported in Stage.TOOL"); } public Provider getProvider(Class type) { throw new UnsupportedOperationException( "Injector.getProvider(Class) is not supported in Stage.TOOL"); } public MembersInjector getMembersInjector(TypeLiteral typeLiteral) { throw new UnsupportedOperationException( "Injector.getMembersInjector(TypeLiteral) is not supported in Stage.TOOL"); } public MembersInjector getMembersInjector(Class type) { throw new UnsupportedOperationException( "Injector.getMembersInjector(Class) is not supported in Stage.TOOL"); } public T getInstance(Key key) { throw new UnsupportedOperationException( "Injector.getInstance(Key) is not supported in Stage.TOOL"); } public T getInstance(Class type) { throw new UnsupportedOperationException( "Injector.getInstance(Class) is not supported in Stage.TOOL"); } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/InternalFactoryToProviderAdapter.javasisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/InternalFactoryToProviderAdapter.jav0000644000175000017500000000322211704661106032377 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Provider; import com.google.inject.spi.Dependency; /** * @author crazybob@google.com (Bob Lee) */ final class InternalFactoryToProviderAdapter implements InternalFactory { private final Provider provider; private final Object source; public InternalFactoryToProviderAdapter(Provider provider, Object source) { this.provider = checkNotNull(provider, "provider"); this.source = checkNotNull(source, "source"); } public T get(Errors errors, InternalContext context, Dependency dependency, boolean linked) throws ErrorsException { // TODO(sameb): Does this need to push state into the context? try { return errors.checkForNull(provider.get(), source, dependency); } catch (RuntimeException userException) { throw errors.withSource(source).errorInProvider(userException).toException(); } } @Override public String toString() { return provider.toString(); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootsisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/InternalFactoryToInitializableAdapter.javasisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/InternalFactoryToInitializableAdapte0000644000175000017500000000424611704661106032433 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Provider; import com.google.inject.spi.Dependency; import com.google.inject.spi.ProviderInstanceBinding; /** * Adapts {@link ProviderInstanceBinding} providers, ensuring circular proxies * fail (or proxy) properly. * * @author sameb@google.com (Sam Berlin) */ final class InternalFactoryToInitializableAdapter extends ProviderInternalFactory { private final Initializable> initializable; public InternalFactoryToInitializableAdapter( Initializable> initializable, Object source, boolean allowProxy, ProvisionListenerStackCallback provisionCallback) { super(source, allowProxy, provisionCallback); this.initializable = checkNotNull(initializable, "provider"); } public T get(Errors errors, InternalContext context, Dependency dependency, boolean linked) throws ErrorsException { return circularGet(initializable.get(errors), errors, context, dependency, linked); } @Override protected T provision(javax.inject.Provider provider, Errors errors, Dependency dependency, ConstructionContext constructionContext) throws ErrorsException { try { return super.provision(provider, errors, dependency, constructionContext); } catch(RuntimeException userException) { throw errors.withSource(source).errorInProvider(userException).toException(); } } @Override public String toString() { return initializable.toString(); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/InternalFactory.java0000644000175000017500000000227111704661106027224 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.spi.Dependency; /** * Creates objects which will be injected. * * @author crazybob@google.com (Bob Lee) */ interface InternalFactory { /** * Creates an object to be injected. * @param context of this injection * @param linked true if getting as a result of a linked binding * * @throws com.google.inject.internal.ErrorsException if a value cannot be provided * @return instance to be injected */ T get(Errors errors, InternalContext context, Dependency dependency, boolean linked) throws ErrorsException; } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/InternalContext.java0000644000175000017500000000556211704661106027247 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; import com.google.inject.Key; import com.google.inject.spi.Dependency; import com.google.inject.spi.DependencyAndSource; import java.util.LinkedList; import java.util.List; import java.util.Map; /** * Internal context. Used to coordinate injections and support circular * dependencies. * * @author crazybob@google.com (Bob Lee) */ final class InternalContext { private Map> constructionContexts = Maps.newHashMap(); /** Keeps track of the type that is currently being requested for injection. */ private Dependency dependency; /** Keeps track of the hierarchy of types needed during injection. */ private LinkedList state = new LinkedList(); @SuppressWarnings("unchecked") public ConstructionContext getConstructionContext(Object key) { ConstructionContext constructionContext = (ConstructionContext) constructionContexts.get(key); if (constructionContext == null) { constructionContext = new ConstructionContext(); constructionContexts.put(key, constructionContext); } return constructionContext; } public Dependency getDependency() { return dependency; } /** Sets the new current dependency & adds it to the state. */ public Dependency pushDependency(Dependency dependency, Object source) { Dependency previous = this.dependency; this.dependency = dependency; state.addLast(new DependencyAndSource(dependency, source)); return previous; } /** Pops the current state & sets the new dependency. */ public void popStateAndSetDependency(Dependency newDependency) { popState(); this.dependency = newDependency; } /** Adds to the state without setting the dependency. */ public void pushState(Key key, Object source) { state.addLast(new DependencyAndSource(key == null ? null : Dependency.get(key), source)); } /** Pops from the state without setting a dependency. */ public void popState() { state.removeLast(); } /** Returns the current dependency chain (all the state). */ public List getDependencyChain() { return ImmutableList.copyOf(state); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/InterceptorStackCallback.java0000644000175000017500000000710311704661106031020 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.Lists; import net.sf.cglib.proxy.MethodProxy; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Method; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; /** * Intercepts a method with a stack of interceptors. * * @author crazybob@google.com (Bob Lee) */ final class InterceptorStackCallback implements net.sf.cglib.proxy.MethodInterceptor { private static final Set AOP_INTERNAL_CLASSES = new HashSet(Arrays.asList( InterceptorStackCallback.class.getName(), InterceptedMethodInvocation.class.getName(), MethodProxy.class.getName())); final MethodInterceptor[] interceptors; final Method method; public InterceptorStackCallback(Method method, List interceptors) { this.method = method; this.interceptors = interceptors.toArray(new MethodInterceptor[interceptors.size()]); } public Object intercept(Object proxy, Method method, Object[] arguments, MethodProxy methodProxy) throws Throwable { return new InterceptedMethodInvocation(proxy, methodProxy, arguments).proceed(); } private class InterceptedMethodInvocation implements MethodInvocation { final Object proxy; final Object[] arguments; final MethodProxy methodProxy; int index = -1; public InterceptedMethodInvocation(Object proxy, MethodProxy methodProxy, Object[] arguments) { this.proxy = proxy; this.methodProxy = methodProxy; this.arguments = arguments; } public Object proceed() throws Throwable { try { index++; return index == interceptors.length ? methodProxy.invokeSuper(proxy, arguments) : interceptors[index].invoke(this); } catch (Throwable t) { pruneStacktrace(t); throw t; } finally { index--; } } public Method getMethod() { return method; } public Object[] getArguments() { return arguments; } public Object getThis() { return proxy; } public AccessibleObject getStaticPart() { return getMethod(); } } /** * Removes stacktrace elements related to AOP internal mechanics from the * throwable's stack trace and any causes it may have. */ private void pruneStacktrace(Throwable throwable) { for(Throwable t = throwable; t != null; t = t.getCause()) { StackTraceElement[] stackTrace = t.getStackTrace(); List pruned = Lists.newArrayList(); for (StackTraceElement element : stackTrace) { String className = element.getClassName(); if (!AOP_INTERNAL_CLASSES.contains(className) && !className.contains("$EnhancerByGuice$")) { pruned.add(element); } } t.setStackTrace(pruned.toArray(new StackTraceElement[pruned.size()])); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/InterceptorBindingProcessor.java0000644000175000017500000000227011704661106031610 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.spi.InterceptorBinding; /** * Handles {@code Binder.bindInterceptor} commands. * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) */ final class InterceptorBindingProcessor extends AbstractProcessor { InterceptorBindingProcessor(Errors errors) { super(errors); } @Override public Boolean visit(InterceptorBinding command) { injector.state.addMethodAspect(new MethodAspect( command.getClassMatcher(), command.getMethodMatcher(), command.getInterceptors())); return true; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/InstanceBindingImpl.java0000644000175000017500000000720411704661106030002 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.inject.Binder; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.spi.BindingTargetVisitor; import com.google.inject.spi.Dependency; import com.google.inject.spi.HasDependencies; import com.google.inject.spi.InjectionPoint; import com.google.inject.spi.InstanceBinding; import com.google.inject.util.Providers; import java.util.Set; final class InstanceBindingImpl extends BindingImpl implements InstanceBinding { final T instance; final Provider provider; final ImmutableSet injectionPoints; public InstanceBindingImpl(InjectorImpl injector, Key key, Object source, InternalFactory internalFactory, Set injectionPoints, T instance) { super(injector, key, source, internalFactory, Scoping.EAGER_SINGLETON); this.injectionPoints = ImmutableSet.copyOf(injectionPoints); this.instance = instance; this.provider = Providers.of(instance); } public InstanceBindingImpl(Object source, Key key, Scoping scoping, Set injectionPoints, T instance) { super(source, key, scoping); this.injectionPoints = ImmutableSet.copyOf(injectionPoints); this.instance = instance; this.provider = Providers.of(instance); } @Override public Provider getProvider() { return this.provider; } public V acceptTargetVisitor(BindingTargetVisitor visitor) { return visitor.visit(this); } public T getInstance() { return instance; } public Set getInjectionPoints() { return injectionPoints; } public Set> getDependencies() { return instance instanceof HasDependencies ? ImmutableSet.copyOf(((HasDependencies) instance).getDependencies()) : Dependency.forInjectionPoints(injectionPoints); } public BindingImpl withScoping(Scoping scoping) { return new InstanceBindingImpl(getSource(), getKey(), scoping, injectionPoints, instance); } public BindingImpl withKey(Key key) { return new InstanceBindingImpl(getSource(), key, getScoping(), injectionPoints, instance); } public void applyTo(Binder binder) { // instance bindings aren't scoped binder.withSource(getSource()).bind(getKey()).toInstance(instance); } @Override public String toString() { return Objects.toStringHelper(InstanceBinding.class) .add("key", getKey()) .add("source", getSource()) .add("instance", instance) .toString(); } @Override public boolean equals(Object obj) { if(obj instanceof InstanceBindingImpl) { InstanceBindingImpl o = (InstanceBindingImpl)obj; return getKey().equals(o.getKey()) && getScoping().equals(o.getScoping()) && Objects.equal(instance, o.instance); } else { return false; } } @Override public int hashCode() { return Objects.hashCode(getKey(), getScoping()); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/InjectorShell.java0000644000175000017500000002701711704661106026672 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static com.google.inject.Scopes.SINGLETON; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.inject.Binder; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provider; import com.google.inject.Singleton; import com.google.inject.Stage; import com.google.inject.internal.InjectorImpl.InjectorOptions; import com.google.inject.internal.util.SourceProvider; import com.google.inject.internal.util.Stopwatch; import com.google.inject.spi.Dependency; import com.google.inject.spi.Element; import com.google.inject.spi.Elements; import com.google.inject.spi.InjectionPoint; import com.google.inject.spi.PrivateElements; import com.google.inject.spi.ProvisionListenerBinding; import com.google.inject.spi.TypeListenerBinding; import java.util.List; import java.util.logging.Logger; /** * A partially-initialized injector. See {@link InternalInjectorCreator}, which * uses this to build a tree of injectors in batch. * * @author jessewilson@google.com (Jesse Wilson) */ final class InjectorShell { private final List elements; private final InjectorImpl injector; private InjectorShell(Builder builder, List elements, InjectorImpl injector) { this.elements = elements; this.injector = injector; } InjectorImpl getInjector() { return injector; } List getElements() { return elements; } static class Builder { private final List elements = Lists.newArrayList(); private final List modules = Lists.newArrayList(); /** lazily constructed */ private State state; private InjectorImpl parent; private InjectorOptions options; private Stage stage; /** null unless this exists in a {@link Binder#newPrivateBinder private environment} */ private PrivateElementsImpl privateElements; Builder stage(Stage stage) { this.stage = stage; return this; } Builder parent(InjectorImpl parent) { this.parent = parent; this.state = new InheritingState(parent.state); this.options = parent.options; this.stage = options.stage; return this; } Builder privateElements(PrivateElements privateElements) { this.privateElements = (PrivateElementsImpl) privateElements; this.elements.addAll(privateElements.getElements()); return this; } void addModules(Iterable modules) { for (Module module : modules) { this.modules.add(module); } } Stage getStage() { return options.stage; } /** Synchronize on this before calling {@link #build}. */ Object lock() { return getState().lock(); } /** * Creates and returns the injector shells for the current modules. Multiple shells will be * returned if any modules contain {@link Binder#newPrivateBinder private environments}. The * primary injector will be first in the returned list. */ List build( Initializer initializer, ProcessedBindingData bindingData, Stopwatch stopwatch, Errors errors) { checkState(stage != null, "Stage not initialized"); checkState(privateElements == null || parent != null, "PrivateElements with no parent"); checkState(state != null, "no state. Did you remember to lock() ?"); // bind Stage and Singleton if this is a top-level injector if (parent == null) { modules.add(0, new RootModule(stage)); } elements.addAll(Elements.getElements(stage, modules)); // Look for injector-changing options InjectorOptionsProcessor optionsProcessor = new InjectorOptionsProcessor(errors); optionsProcessor.process(null, elements); options = optionsProcessor.getOptions(stage, options); InjectorImpl injector = new InjectorImpl(parent, state, options); if (privateElements != null) { privateElements.initInjector(injector); } // add default type converters if this is a top-level injector if (parent == null) { new TypeConverterBindingProcessor(errors).prepareBuiltInConverters(injector); } stopwatch.resetAndLog("Module execution"); new MessageProcessor(errors).process(injector, elements); /*if[AOP]*/ new InterceptorBindingProcessor(errors).process(injector, elements); stopwatch.resetAndLog("Interceptors creation"); /*end[AOP]*/ new ListenerBindingProcessor(errors).process(injector, elements); List typeListenerBindings = injector.state.getTypeListenerBindings(); injector.membersInjectorStore = new MembersInjectorStore(injector, typeListenerBindings); List provisionListenerBindings = injector.state.getProvisionListenerBindings(); injector.provisionListenerStore = new ProvisionListenerCallbackStore(provisionListenerBindings); stopwatch.resetAndLog("TypeListeners & ProvisionListener creation"); new ScopeBindingProcessor(errors).process(injector, elements); stopwatch.resetAndLog("Scopes creation"); new TypeConverterBindingProcessor(errors).process(injector, elements); stopwatch.resetAndLog("Converters creation"); bindInjector(injector); bindLogger(injector); // Process all normal bindings, then UntargettedBindings. // This is necessary because UntargettedBindings can create JIT bindings // and need all their other dependencies set up ahead of time. new BindingProcessor(errors, initializer, bindingData).process(injector, elements); new UntargettedBindingProcessor(errors, bindingData).process(injector, elements); stopwatch.resetAndLog("Binding creation"); List injectorShells = Lists.newArrayList(); injectorShells.add(new InjectorShell(this, elements, injector)); // recursively build child shells PrivateElementProcessor processor = new PrivateElementProcessor(errors); processor.process(injector, elements); for (Builder builder : processor.getInjectorShellBuilders()) { injectorShells.addAll(builder.build(initializer, bindingData, stopwatch, errors)); } stopwatch.resetAndLog("Private environment creation"); return injectorShells; } private State getState() { if (state == null) { state = new InheritingState(State.NONE); } return state; } } /** * The Injector is a special case because we allow both parent and child injectors to both have * a binding for that key. */ private static void bindInjector(InjectorImpl injector) { Key key = Key.get(Injector.class); InjectorFactory injectorFactory = new InjectorFactory(injector); injector.state.putBinding(key, new ProviderInstanceBindingImpl(injector, key, SourceProvider.UNKNOWN_SOURCE, injectorFactory, Scoping.UNSCOPED, injectorFactory, ImmutableSet.of())); } private static class InjectorFactory implements InternalFactory, Provider { private final Injector injector; private InjectorFactory(Injector injector) { this.injector = injector; } public Injector get(Errors errors, InternalContext context, Dependency dependency, boolean linked) throws ErrorsException { return injector; } public Injector get() { return injector; } public String toString() { return "Provider"; } } /** * The Logger is a special case because it knows the injection point of the injected member. It's * the only binding that does this. */ private static void bindLogger(InjectorImpl injector) { Key key = Key.get(Logger.class); LoggerFactory loggerFactory = new LoggerFactory(); injector.state.putBinding(key, new ProviderInstanceBindingImpl(injector, key, SourceProvider.UNKNOWN_SOURCE, loggerFactory, Scoping.UNSCOPED, loggerFactory, ImmutableSet.of())); try { Key slf4jKey = Key.get(org.slf4j.Logger.class); SLF4JLoggerFactory slf4jLoggerFactory = new SLF4JLoggerFactory(injector); injector.state.putBinding(slf4jKey, new ProviderInstanceBindingImpl(injector, slf4jKey, SourceProvider.UNKNOWN_SOURCE, slf4jLoggerFactory, Scoping.UNSCOPED, slf4jLoggerFactory, ImmutableSet.of())); } catch (Throwable e) {} } private static class LoggerFactory implements InternalFactory, Provider { public Logger get(Errors errors, InternalContext context, Dependency dependency, boolean linked) { InjectionPoint injectionPoint = dependency.getInjectionPoint(); return injectionPoint == null ? Logger.getAnonymousLogger() : Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); } public Logger get() { return Logger.getAnonymousLogger(); } public String toString() { return "Provider"; } } private static class SLF4JLoggerFactory implements InternalFactory, Provider { 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"; } } private static class RootModule implements Module { final Stage stage; private RootModule(Stage stage) { this.stage = checkNotNull(stage, "stage"); } public void configure(Binder binder) { binder = binder.withSource(SourceProvider.UNKNOWN_SOURCE); binder.bind(Stage.class).toInstance(stage); binder.bindScope(Singleton.class, SINGLETON); binder.bindScope(javax.inject.Singleton.class, SINGLETON); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/InjectorOptionsProcessor.java0000644000175000017500000000405611704661106031154 0ustar tonytony/* * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import com.google.inject.Stage; import com.google.inject.internal.InjectorImpl.InjectorOptions; import com.google.inject.spi.DisableCircularProxiesOption; import com.google.inject.spi.RequireExplicitBindingsOption; /** * A processor to gather injector options. * * @author sameb@google.com (Sam Berlin) */ class InjectorOptionsProcessor extends AbstractProcessor { private boolean disableCircularProxies = false; private boolean jitDisabled = false; InjectorOptionsProcessor(Errors errors) { super(errors); } @Override public Boolean visit(DisableCircularProxiesOption option) { disableCircularProxies = true; return true; } @Override public Boolean visit(RequireExplicitBindingsOption option) { jitDisabled = true; return true; } InjectorOptions getOptions(Stage stage, InjectorOptions parentOptions) { checkNotNull(stage, "stage must be set"); if(parentOptions == null) { return new InjectorOptions( stage, jitDisabled, disableCircularProxies); } else { checkState(stage == parentOptions.stage, "child & parent stage don't match"); return new InjectorOptions( stage, jitDisabled || parentOptions.jitDisabled, disableCircularProxies || parentOptions.disableCircularProxies); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/InjectorImpl.java0000644000175000017500000011540311704661106026521 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.inject.Binder; import com.google.inject.Binding; import com.google.inject.ConfigurationException; import com.google.inject.ImplementedBy; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.MembersInjector; import com.google.inject.Module; import com.google.inject.ProvidedBy; import com.google.inject.Provider; import com.google.inject.ProvisionException; import com.google.inject.Scope; import com.google.inject.Stage; import com.google.inject.TypeLiteral; import com.google.inject.internal.util.SourceProvider; import com.google.inject.spi.BindingTargetVisitor; import com.google.inject.spi.ConvertedConstantBinding; import com.google.inject.spi.Dependency; import com.google.inject.spi.HasDependencies; import com.google.inject.spi.InjectionPoint; import com.google.inject.spi.ProviderBinding; import com.google.inject.spi.TypeConverterBinding; import com.google.inject.util.Providers; import java.lang.annotation.Annotation; import java.lang.reflect.GenericArrayType; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; /** * Default {@link Injector} implementation. * * @author crazybob@google.com (Bob Lee) */ final class InjectorImpl implements Injector, Lookups { public static final TypeLiteral STRING_TYPE = TypeLiteral.get(String.class); /** Options that control how the injector behaves. */ static class InjectorOptions { final Stage stage; final boolean jitDisabled; final boolean disableCircularProxies; InjectorOptions(Stage stage, boolean jitDisabled, boolean disableCircularProxies) { this.stage = stage; this.jitDisabled = jitDisabled; this.disableCircularProxies = disableCircularProxies; } @Override public String toString() { return Objects.toStringHelper(getClass()) .add("stage", stage) .add("jitDisabled", jitDisabled) .add("disableCircularProxies", disableCircularProxies) .toString(); } } /** some limitations on what just in time bindings are allowed. */ enum JitLimitation { /** does not allow just in time bindings */ NO_JIT, /** allows existing just in time bindings, but does not allow new ones */ EXISTING_JIT, /** allows existing just in time bindings & allows new ones to be created */ NEW_OR_EXISTING_JIT, } final State state; final InjectorImpl parent; final BindingsMultimap bindingsMultimap = new BindingsMultimap(); final InjectorOptions options; /** Just-in-time binding cache. Guarded by state.lock() */ final Map, BindingImpl> jitBindings = Maps.newHashMap(); /** * Cache of Keys that we were unable to create JIT bindings for, so we don't * keep trying. Also guarded by state.lock(). */ final Set> failedJitBindings = Sets.newHashSet(); Lookups lookups = new DeferredLookups(this); InjectorImpl(InjectorImpl parent, State state, InjectorOptions injectorOptions) { this.parent = parent; this.state = state; this.options = injectorOptions; if (parent != null) { localContext = parent.localContext; } else { localContext = new ThreadLocal() { @Override protected Object[] initialValue() { return new Object[1]; } }; } } /** Indexes bindings by type. */ void index() { for (Binding binding : state.getExplicitBindingsThisLevel().values()) { index(binding); } } void index(Binding binding) { bindingsMultimap.put(binding.getKey().getTypeLiteral(), binding); } public List> findBindingsByType(TypeLiteral type) { return bindingsMultimap.getAll(type); } /** Returns the binding for {@code key} */ public BindingImpl getBinding(Key key) { Errors errors = new Errors(key); try { BindingImpl result = getBindingOrThrow(key, errors, JitLimitation.EXISTING_JIT); errors.throwConfigurationExceptionIfErrorsExist(); return result; } catch (ErrorsException e) { throw new ConfigurationException(errors.merge(e.getErrors()).getMessages()); } } public BindingImpl getExistingBinding(Key key) { // Check explicit bindings, i.e. bindings created by modules. BindingImpl explicitBinding = state.getExplicitBinding(key); if (explicitBinding != null) { return explicitBinding; } synchronized (state.lock()) { // See if any jit bindings have been created for this key. for (InjectorImpl injector = this; injector != null; injector = injector.parent) { @SuppressWarnings("unchecked") BindingImpl jitBinding = (BindingImpl) injector.jitBindings.get(key); if(jitBinding != null) { return jitBinding; } } } // If Key is a Provider, we have to see if the type it is providing exists, // and, if so, we have to create the binding for the provider. if(isProvider(key)) { try { // This is safe because isProvider above ensures that T is a Provider @SuppressWarnings("unchecked") Key providedKey = (Key)getProvidedKey((Key)key, new Errors()); if(getExistingBinding(providedKey) != null) { return getBinding(key); } } catch(ErrorsException e) { throw new ConfigurationException(e.getErrors().getMessages()); } } // No existing binding exists. return null; } /** * Gets a binding implementation. First, it check to see if the parent has a binding. If the * parent has a binding and the binding is scoped, it will use that binding. Otherwise, this * checks for an explicit binding. If no explicit binding is found, it looks for a just-in-time * binding. */ BindingImpl getBindingOrThrow(Key key, Errors errors, JitLimitation jitType) throws ErrorsException { // Check explicit bindings, i.e. bindings created by modules. BindingImpl binding = state.getExplicitBinding(key); if (binding != null) { return binding; } // Look for an on-demand binding. return getJustInTimeBinding(key, errors, jitType); } public Binding getBinding(Class type) { return getBinding(Key.get(type)); } public Injector getParent() { return parent; } public Injector createChildInjector(Iterable modules) { return new InternalInjectorCreator() .parentInjector(this) .addModules(modules) .build(); } public Injector createChildInjector(Module... modules) { return createChildInjector(ImmutableList.copyOf(modules)); } /** * Returns a just-in-time binding for {@code key}, creating it if necessary. * * @throws ErrorsException if the binding could not be created. */ private BindingImpl getJustInTimeBinding(Key key, Errors errors, JitLimitation jitType) throws ErrorsException { boolean jitOverride = isProvider(key) || isTypeLiteral(key) || isMembersInjector(key); synchronized (state.lock()) { // first try to find a JIT binding that we've already created for (InjectorImpl injector = this; injector != null; injector = injector.parent) { @SuppressWarnings("unchecked") // we only store bindings that match their key BindingImpl binding = (BindingImpl) injector.jitBindings.get(key); if (binding != null) { // If we found a JIT binding and we don't allow them, // fail. (But allow bindings created through TypeConverters.) if (options.jitDisabled && jitType == JitLimitation.NO_JIT && !jitOverride && !(binding instanceof ConvertedConstantBindingImpl)) { throw errors.jitDisabled(key).toException(); } else { return binding; } } } // If we previously failed creating this JIT binding and our Errors has // already recorded an error, then just directly throw that error. // We need to do this because it's possible we already cleaned up the // entry in jitBindings (during cleanup), and we may be trying // to create it again (in the case of a recursive JIT binding). // We need both of these guards for different reasons // failedJitBindings.contains: We want to continue processing if we've never // failed before, so that our initial error message contains // as much useful information as possible about what errors exist. // errors.hasErrors: If we haven't already failed, then it's OK to // continue processing, to make sure the ultimate error message // is the correct one. // See: ImplicitBindingsTest#testRecursiveJitBindingsCleanupCorrectly // for where this guard compes into play. if (failedJitBindings.contains(key) && errors.hasErrors()) { throw errors.toException(); } return createJustInTimeBindingRecursive(key, errors, options.jitDisabled, jitType); } // end synchronized(state.lock()) } /** Returns true if the key type is Provider (but not a subclass of Provider). */ private static boolean isProvider(Key key) { return key.getTypeLiteral().getRawType().equals(Provider.class); } private static boolean isTypeLiteral(Key key) { return key.getTypeLiteral().getRawType().equals(TypeLiteral.class); } private static Key getProvidedKey(Key> key, Errors errors) throws ErrorsException { Type providerType = key.getTypeLiteral().getType(); // If the Provider has no type parameter (raw Provider)... if (!(providerType instanceof ParameterizedType)) { throw errors.cannotInjectRawProvider().toException(); } Type entryType = ((ParameterizedType) providerType).getActualTypeArguments()[0]; @SuppressWarnings("unchecked") // safe because T came from Key> Key providedKey = (Key) key.ofType(entryType); return providedKey; } /** Returns true if the key type is MembersInjector (but not a subclass of MembersInjector). */ private static boolean isMembersInjector(Key key) { return key.getTypeLiteral().getRawType().equals(MembersInjector.class) && !(key.getAnnotationType() != null); } private BindingImpl> createMembersInjectorBinding( Key> key, Errors errors) throws ErrorsException { Type membersInjectorType = key.getTypeLiteral().getType(); if (!(membersInjectorType instanceof ParameterizedType)) { throw errors.cannotInjectRawMembersInjector().toException(); } @SuppressWarnings("unchecked") // safe because T came from Key> TypeLiteral instanceType = (TypeLiteral) TypeLiteral.get( ((ParameterizedType) membersInjectorType).getActualTypeArguments()[0]); MembersInjector membersInjector = membersInjectorStore.get(instanceType, errors); InternalFactory> factory = new ConstantFactory>( Initializables.of(membersInjector)); return new InstanceBindingImpl>(this, key, SourceProvider.UNKNOWN_SOURCE, factory, ImmutableSet.of(), membersInjector); } /** * Creates a synthetic binding to {@code Provider}, i.e. a binding to the provider from * {@code Binding}. */ private BindingImpl> createProviderBinding(Key> key, Errors errors) throws ErrorsException { Key providedKey = getProvidedKey(key, errors); BindingImpl delegate = getBindingOrThrow(providedKey, errors, JitLimitation.NO_JIT); return new ProviderBindingImpl(this, key, delegate); } private static class ProviderBindingImpl extends BindingImpl> implements ProviderBinding>, HasDependencies { final BindingImpl providedBinding; ProviderBindingImpl(InjectorImpl injector, Key> key, Binding providedBinding) { super(injector, key, providedBinding.getSource(), createInternalFactory(providedBinding), Scoping.UNSCOPED); this.providedBinding = (BindingImpl) providedBinding; } static InternalFactory> createInternalFactory(Binding providedBinding) { final Provider provider = providedBinding.getProvider(); return new InternalFactory>() { public Provider get(Errors errors, InternalContext context, Dependency dependency, boolean linked) { return provider; } }; } public Key getProvidedKey() { return providedBinding.getKey(); } public V acceptTargetVisitor(BindingTargetVisitor, V> visitor) { return visitor.visit(this); } public void applyTo(Binder binder) { throw new UnsupportedOperationException("This element represents a synthetic binding."); } @Override public String toString() { return Objects.toStringHelper(ProviderBinding.class) .add("key", getKey()) .add("providedKey", getProvidedKey()) .toString(); } public Set> getDependencies() { return ImmutableSet.>of(Dependency.get(getProvidedKey())); } @Override public boolean equals(Object obj) { if(obj instanceof ProviderBindingImpl) { ProviderBindingImpl o = (ProviderBindingImpl)obj; return getKey().equals(o.getKey()) && getScoping().equals(o.getScoping()) && Objects.equal(providedBinding, o.providedBinding); } else { return false; } } @Override public int hashCode() { return Objects.hashCode(getKey(), getScoping(), providedBinding); } } /** * Converts a constant string binding to the required type. * * @return the binding if it could be resolved, or null if the binding doesn't exist * @throws com.google.inject.internal.ErrorsException if there was an error resolving the binding */ private BindingImpl convertConstantStringBinding(Key key, Errors errors) throws ErrorsException { // Find a constant string binding. Key stringKey = key.ofType(STRING_TYPE); BindingImpl stringBinding = state.getExplicitBinding(stringKey); if (stringBinding == null || !stringBinding.isConstant()) { return null; } String stringValue = stringBinding.getProvider().get(); Object source = stringBinding.getSource(); // Find a matching type converter. TypeLiteral type = key.getTypeLiteral(); TypeConverterBinding typeConverterBinding = state.getConverter(stringValue, type, errors, source); if (typeConverterBinding == null) { // No converter can handle the given type. return null; } // Try to convert the string. A failed conversion results in an error. try { @SuppressWarnings("unchecked") // This cast is safe because we double check below. T converted = (T) typeConverterBinding.getTypeConverter().convert(stringValue, type); if (converted == null) { throw errors.converterReturnedNull(stringValue, source, type, typeConverterBinding) .toException(); } if (!type.getRawType().isInstance(converted)) { throw errors.conversionTypeError(stringValue, source, type, typeConverterBinding, converted) .toException(); } return new ConvertedConstantBindingImpl(this, key, converted, stringBinding, typeConverterBinding); } catch (ErrorsException e) { throw e; } catch (RuntimeException e) { throw errors.conversionError(stringValue, source, type, typeConverterBinding, e) .toException(); } } private static class ConvertedConstantBindingImpl extends BindingImpl implements ConvertedConstantBinding { final T value; final Provider provider; final Binding originalBinding; final TypeConverterBinding typeConverterBinding; ConvertedConstantBindingImpl( InjectorImpl injector, Key key, T value, Binding originalBinding, TypeConverterBinding typeConverterBinding) { super(injector, key, originalBinding.getSource(), new ConstantFactory(Initializables.of(value)), Scoping.UNSCOPED); this.value = value; provider = Providers.of(value); this.originalBinding = originalBinding; this.typeConverterBinding = typeConverterBinding; } @Override public Provider getProvider() { return provider; } public V acceptTargetVisitor(BindingTargetVisitor visitor) { return visitor.visit(this); } public T getValue() { return value; } public TypeConverterBinding getTypeConverterBinding() { return typeConverterBinding; } public Key getSourceKey() { return originalBinding.getKey(); } public Set> getDependencies() { return ImmutableSet.>of(Dependency.get(getSourceKey())); } public void applyTo(Binder binder) { throw new UnsupportedOperationException("This element represents a synthetic binding."); } @Override public String toString() { return Objects.toStringHelper(ConvertedConstantBinding.class) .add("key", getKey()) .add("sourceKey", getSourceKey()) .add("value", value) .toString(); } @Override public boolean equals(Object obj) { if(obj instanceof ConvertedConstantBindingImpl) { ConvertedConstantBindingImpl o = (ConvertedConstantBindingImpl)obj; return getKey().equals(o.getKey()) && getScoping().equals(o.getScoping()) && Objects.equal(value, o.value); } else { return false; } } @Override public int hashCode() { return Objects.hashCode(getKey(), getScoping(), value); } } void initializeBinding(BindingImpl binding, Errors errors) throws ErrorsException { if (binding instanceof DelayedInitialize) { ((DelayedInitialize) binding).initialize(this, errors); } } void initializeJitBinding(BindingImpl binding, Errors errors) throws ErrorsException { // Put the partially constructed binding in the map a little early. This enables us to handle // circular dependencies. Example: FooImpl -> BarImpl -> FooImpl. // Note: We don't need to synchronize on state.lock() during injector creation. if (binding instanceof DelayedInitialize) { Key key = binding.getKey(); jitBindings.put(key, binding); boolean successful = false; DelayedInitialize delayed = (DelayedInitialize)binding; try { delayed.initialize(this, errors); successful = true; } finally { if (!successful) { // We do not pass cb.getInternalConstructor as the second parameter // so that cached exceptions while constructing it get stored. // See TypeListenerTest#testTypeListenerThrows removeFailedJitBinding(key, null); cleanup(binding, new HashSet()); } } } } /** * Iterates through the binding's dependencies to clean up any stray bindings that were leftover * from a failed JIT binding. This is required because the bindings are eagerly & * optimistically added to allow circular dependency support, so dependencies may pass where they * should have failed. */ private boolean cleanup(BindingImpl binding, Set encountered) { boolean bindingFailed = false; Set> deps = getInternalDependencies(binding); for(Dependency dep : deps) { Key depKey = dep.getKey(); InjectionPoint ip = dep.getInjectionPoint(); if(encountered.add(depKey)) { // only check if we haven't looked at this key yet BindingImpl depBinding = jitBindings.get(depKey); if(depBinding != null) { // if the binding still exists, validate boolean failed = cleanup(depBinding, encountered); // if children fail, we fail if(depBinding instanceof ConstructorBindingImpl) { ConstructorBindingImpl ctorBinding = (ConstructorBindingImpl)depBinding; ip = ctorBinding.getInternalConstructor(); if(!ctorBinding.isInitialized()) { failed = true; } } if(failed) { removeFailedJitBinding(depKey, ip); bindingFailed = true; } } else if(state.getExplicitBinding(depKey) == null) { // ignore keys if they were explicitly bound, but if neither JIT // nor explicit, it's also invalid & should let parent know. bindingFailed = true; } } } return bindingFailed; } /** Cleans up any state that may have been cached when constructing the JIT binding. */ private void removeFailedJitBinding(Key key, InjectionPoint ip) { failedJitBindings.add(key); jitBindings.remove(key); membersInjectorStore.remove(key.getTypeLiteral()); provisionListenerStore.remove(key); if(ip != null) { constructors.remove(ip); } } /** Safely gets the dependencies of possibly not initialized bindings. */ @SuppressWarnings("unchecked") private Set> getInternalDependencies(BindingImpl binding) { if(binding instanceof ConstructorBindingImpl) { return ((ConstructorBindingImpl)binding).getInternalDependencies(); } else if(binding instanceof HasDependencies) { return ((HasDependencies)binding).getDependencies(); } else { return ImmutableSet.of(); } } /** * Creates a binding for an injectable type with the given scope. Looks for a scope on the type if * none is specified. */ BindingImpl createUninitializedBinding(Key key, Scoping scoping, Object source, Errors errors, boolean jitBinding) throws ErrorsException { Class rawType = key.getTypeLiteral().getRawType(); // Don't try to inject arrays, or enums. if (rawType.isArray() || rawType.isEnum()) { throw errors.missingImplementation(key).toException(); } // Handle TypeLiteral by binding the inner type if (rawType == TypeLiteral.class) { @SuppressWarnings("unchecked") // we have to fudge the inner type as Object BindingImpl binding = (BindingImpl) createTypeLiteralBinding( (Key>) key, errors); return binding; } // Handle @ImplementedBy ImplementedBy implementedBy = rawType.getAnnotation(ImplementedBy.class); if (implementedBy != null) { Annotations.checkForMisplacedScopeAnnotations(rawType, source, errors); return createImplementedByBinding(key, scoping, implementedBy, errors); } // Handle @ProvidedBy. ProvidedBy providedBy = rawType.getAnnotation(ProvidedBy.class); if (providedBy != null) { Annotations.checkForMisplacedScopeAnnotations(rawType, source, errors); return createProvidedByBinding(key, scoping, providedBy, errors); } return ConstructorBindingImpl.create(this, key, null, source, scoping, errors, jitBinding && options.jitDisabled); } /** * Converts a binding for a {@code Key>} to the value {@code TypeLiteral}. It's * a bit awkward because we have to pull out the inner type in the type literal. */ private BindingImpl> createTypeLiteralBinding( Key> key, Errors errors) throws ErrorsException { Type typeLiteralType = key.getTypeLiteral().getType(); if (!(typeLiteralType instanceof ParameterizedType)) { throw errors.cannotInjectRawTypeLiteral().toException(); } ParameterizedType parameterizedType = (ParameterizedType) typeLiteralType; Type innerType = parameterizedType.getActualTypeArguments()[0]; // this is unforunate. We don't support building TypeLiterals for type variable like 'T'. If // this proves problematic, we can probably fix TypeLiteral to support type variables if (!(innerType instanceof Class) && !(innerType instanceof GenericArrayType) && !(innerType instanceof ParameterizedType)) { throw errors.cannotInjectTypeLiteralOf(innerType).toException(); } @SuppressWarnings("unchecked") // by definition, innerType == T, so this is safe TypeLiteral value = (TypeLiteral) TypeLiteral.get(innerType); InternalFactory> factory = new ConstantFactory>( Initializables.of(value)); return new InstanceBindingImpl>(this, key, SourceProvider.UNKNOWN_SOURCE, factory, ImmutableSet.of(), value); } /** Creates a binding for a type annotated with @ProvidedBy. */ BindingImpl createProvidedByBinding(Key key, Scoping scoping, ProvidedBy providedBy, Errors errors) throws ErrorsException { Class rawType = key.getTypeLiteral().getRawType(); Class> providerType = providedBy.value(); // Make sure it's not the same type. TODO: Can we check for deeper loops? if (providerType == rawType) { throw errors.recursiveProviderType().toException(); } // Assume the provider provides an appropriate type. We double check at runtime. @SuppressWarnings("unchecked") Key> providerKey = (Key>) Key.get(providerType); ProvidedByInternalFactory internalFactory = new ProvidedByInternalFactory(rawType, providerType, providerKey, !options.disableCircularProxies, provisionListenerStore.get(key)); Object source = rawType; return LinkedProviderBindingImpl.createWithInitializer( this, key, source, Scoping.scope(key, this, internalFactory, source, scoping), scoping, providerKey, internalFactory); } /** Creates a binding for a type annotated with @ImplementedBy. */ private BindingImpl createImplementedByBinding(Key key, Scoping scoping, ImplementedBy implementedBy, Errors errors) throws ErrorsException { Class rawType = key.getTypeLiteral().getRawType(); Class implementationType = implementedBy.value(); // Make sure it's not the same type. TODO: Can we check for deeper cycles? if (implementationType == rawType) { throw errors.recursiveImplementationType().toException(); } // Make sure implementationType extends type. if (!rawType.isAssignableFrom(implementationType)) { throw errors.notASubtype(implementationType, rawType).toException(); } @SuppressWarnings("unchecked") // After the preceding check, this cast is safe. Class subclass = (Class) implementationType; // Look up the target binding. final Key targetKey = Key.get(subclass); final BindingImpl targetBinding = getBindingOrThrow(targetKey, errors, JitLimitation.NEW_OR_EXISTING_JIT); InternalFactory internalFactory = new InternalFactory() { public T get(Errors errors, InternalContext context, Dependency dependency, boolean linked) throws ErrorsException { context.pushState(targetKey, targetBinding.getSource()); try { return targetBinding.getInternalFactory().get( errors.withSource(targetKey), context, dependency, true); } finally { context.popState(); } } }; Object source = rawType; return new LinkedBindingImpl( this, key, source, Scoping.scope(key, this, internalFactory, source, scoping), scoping, targetKey); } /** * Attempts to create a just-in-time binding for {@code key} in the root injector, falling back to * other ancestor injectors until this injector is tried. */ private BindingImpl createJustInTimeBindingRecursive(Key key, Errors errors, boolean jitDisabled, JitLimitation jitType) throws ErrorsException { // ask the parent to create the JIT binding if (parent != null) { try { return parent.createJustInTimeBindingRecursive(key, new Errors(), jitDisabled, parent.options.jitDisabled ? JitLimitation.NO_JIT : jitType); } catch (ErrorsException ignored) { } } if (state.isBlacklisted(key)) { Set sources = state.getSourcesForBlacklistedKey(key); throw errors.childBindingAlreadySet(key, sources).toException(); } BindingImpl binding = createJustInTimeBinding(key, errors, jitDisabled, jitType); state.parent().blacklist(key, binding.getSource()); jitBindings.put(key, binding); return binding; } /** * Returns a new just-in-time binding created by resolving {@code key}. The strategies used to * create just-in-time bindings are: *
      *
    1. Internalizing Providers. If the requested binding is for {@code Provider}, we delegate * to the binding for {@code T}. *
    2. Converting constants. *
    3. ImplementedBy and ProvidedBy annotations. Only for unannotated keys. *
    4. The constructor of the raw type. Only for unannotated keys. *
    * * @throws com.google.inject.internal.ErrorsException if the binding cannot be created. */ private BindingImpl createJustInTimeBinding(Key key, Errors errors, boolean jitDisabled, JitLimitation jitType) throws ErrorsException { int numErrorsBefore = errors.size(); if (state.isBlacklisted(key)) { Set sources = state.getSourcesForBlacklistedKey(key); throw errors.childBindingAlreadySet(key, sources).toException(); } // Handle cases where T is a Provider. if (isProvider(key)) { // These casts are safe. We know T extends Provider and that given Key>, // createProviderBinding() will return BindingImpl>. @SuppressWarnings("unchecked") BindingImpl binding = (BindingImpl) createProviderBinding((Key) key, errors); return binding; } // Handle cases where T is a MembersInjector if (isMembersInjector(key)) { // These casts are safe. T extends MembersInjector and that given Key>, // createMembersInjectorBinding() will return BindingImpl>. @SuppressWarnings("unchecked") BindingImpl binding = (BindingImpl) createMembersInjectorBinding((Key) key, errors); return binding; } // Try to convert a constant string binding to the requested type. BindingImpl convertedBinding = convertConstantStringBinding(key, errors); if (convertedBinding != null) { return convertedBinding; } if (!isTypeLiteral(key) && jitDisabled && jitType != JitLimitation.NEW_OR_EXISTING_JIT) { throw errors.jitDisabled(key).toException(); } // If the key has an annotation... if (key.getAnnotationType() != null) { // Look for a binding without annotation attributes or return null. if (key.hasAttributes()) { try { Errors ignored = new Errors(); return getBindingOrThrow(key.withoutAttributes(), ignored, JitLimitation.NO_JIT); } catch (ErrorsException ignored) { // throw with a more appropriate message below } } throw errors.missingImplementation(key).toException(); } Object source = key.getTypeLiteral().getRawType(); BindingImpl binding = createUninitializedBinding(key, Scoping.UNSCOPED, source, errors, true); errors.throwIfNewErrors(numErrorsBefore); initializeJitBinding(binding, errors); return binding; } InternalFactory getInternalFactory(Key key, Errors errors, JitLimitation jitType) throws ErrorsException { return getBindingOrThrow(key, errors, jitType).getInternalFactory(); } public Map, Binding> getBindings() { return state.getExplicitBindingsThisLevel(); } public Map, Binding> getAllBindings() { synchronized (state.lock()) { return new ImmutableMap.Builder, Binding>() .putAll(state.getExplicitBindingsThisLevel()) .putAll(jitBindings) .build(); } } public Map, Scope> getScopeBindings() { return ImmutableMap.copyOf(state.getScopes()); } public Set getTypeConverterBindings() { return ImmutableSet.copyOf(state.getConvertersThisLevel()); } private static class BindingsMultimap { final Map, List>> multimap = Maps.newHashMap(); void put(TypeLiteral type, Binding binding) { List> bindingsForType = multimap.get(type); if (bindingsForType == null) { bindingsForType = Lists.newArrayList(); multimap.put(type, bindingsForType); } bindingsForType.add(binding); } @SuppressWarnings("unchecked") // safe because we only put matching entries into the map List> getAll(TypeLiteral type) { List> bindings = multimap.get(type); return bindings != null ? Collections.>unmodifiableList((List) multimap.get(type)) : ImmutableList.>of(); } } /** * Returns parameter injectors, or {@code null} if there are no parameters. */ SingleParameterInjector[] getParametersInjectors( List> parameters, Errors errors) throws ErrorsException { if (parameters.isEmpty()) { return null; } int numErrorsBefore = errors.size(); SingleParameterInjector[] result = new SingleParameterInjector[parameters.size()]; int i = 0; for (Dependency parameter : parameters) { try { result[i++] = createParameterInjector(parameter, errors.withSource(parameter)); } catch (ErrorsException rethrownBelow) { // rethrown below } } errors.throwIfNewErrors(numErrorsBefore); return result; } SingleParameterInjector createParameterInjector(final Dependency dependency, final Errors errors) throws ErrorsException { BindingImpl binding = getBindingOrThrow(dependency.getKey(), errors, JitLimitation.NO_JIT); return new SingleParameterInjector(dependency, binding); } /** Invokes a method. */ interface MethodInvoker { Object invoke(Object target, Object... parameters) throws IllegalAccessException, InvocationTargetException; } /** Cached constructor injectors for each type */ final ConstructorInjectorStore constructors = new ConstructorInjectorStore(this); /** Cached field and method injectors for each type. */ MembersInjectorStore membersInjectorStore; /** Cached provision listener callbacks for each key. */ ProvisionListenerCallbackStore provisionListenerStore; @SuppressWarnings("unchecked") // the members injector type is consistent with instance's type public void injectMembers(Object instance) { MembersInjector membersInjector = getMembersInjector(instance.getClass()); membersInjector.injectMembers(instance); } public MembersInjector getMembersInjector(TypeLiteral typeLiteral) { Errors errors = new Errors(typeLiteral); try { return membersInjectorStore.get(typeLiteral, errors); } catch (ErrorsException e) { throw new ConfigurationException(errors.merge(e.getErrors()).getMessages()); } } public MembersInjector getMembersInjector(Class type) { return getMembersInjector(TypeLiteral.get(type)); } public Provider getProvider(Class type) { return getProvider(Key.get(type)); } Provider getProviderOrThrow(final Key key, Errors errors) throws ErrorsException { final BindingImpl binding = getBindingOrThrow(key, errors, JitLimitation.NO_JIT); final Dependency dependency = Dependency.get(key); return new Provider() { public T get() { final Errors errors = new Errors(dependency); try { T t = callInContext(new ContextualCallable() { public T call(InternalContext context) throws ErrorsException { Dependency previous = context.pushDependency(dependency, binding.getSource()); try { return binding.getInternalFactory().get(errors, context, dependency, false); } finally { context.popStateAndSetDependency(previous); } } }); errors.throwIfNewErrors(0); return t; } catch (ErrorsException e) { throw new ProvisionException(errors.merge(e.getErrors()).getMessages()); } } @Override public String toString() { return binding.getInternalFactory().toString(); } }; } public Provider getProvider(final Key key) { Errors errors = new Errors(key); try { Provider result = getProviderOrThrow(key, errors); errors.throwIfNewErrors(0); return result; } catch (ErrorsException e) { throw new ConfigurationException(errors.merge(e.getErrors()).getMessages()); } } public T getInstance(Key key) { return getProvider(key).get(); } public T getInstance(Class type) { return getProvider(type).get(); } final ThreadLocal localContext; /** Looks up thread local context. Creates (and removes) a new context if necessary. */ T callInContext(ContextualCallable callable) throws ErrorsException { Object[] reference = localContext.get(); if (reference[0] == null) { reference[0] = new InternalContext(); try { return callable.call((InternalContext)reference[0]); } finally { // Only clear the context if this call created it. reference[0] = null; } } else { // Someone else will clean up this context. return callable.call((InternalContext)reference[0]); } } @Override public String toString() { return Objects.toStringHelper(Injector.class) .add("bindings", state.getExplicitBindingsThisLevel().values()) .toString(); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/InjectionRequestProcessor.java0000644000175000017500000001040711704661106031313 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.inject.ConfigurationException; import com.google.inject.Stage; import com.google.inject.spi.InjectionPoint; import com.google.inject.spi.InjectionRequest; import com.google.inject.spi.StaticInjectionRequest; import java.util.List; import java.util.Set; /** * Handles {@code Binder.requestInjection} and {@code Binder.requestStaticInjection} commands. * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) * @author mikeward@google.com (Mike Ward) */ final class InjectionRequestProcessor extends AbstractProcessor { private final List staticInjections = Lists.newArrayList(); private final Initializer initializer; InjectionRequestProcessor(Errors errors, Initializer initializer) { super(errors); this.initializer = initializer; } @Override public Boolean visit(StaticInjectionRequest request) { staticInjections.add(new StaticInjection(injector, request)); return true; } @Override public Boolean visit(InjectionRequest request) { Set injectionPoints; try { injectionPoints = request.getInjectionPoints(); } catch (ConfigurationException e) { errors.merge(e.getErrorMessages()); injectionPoints = e.getPartialValue(); } initializer.requestInjection( injector, request.getInstance(), null, request.getSource(), injectionPoints); return true; } void validate() { for (StaticInjection staticInjection : staticInjections) { staticInjection.validate(); } } void injectMembers() { /* * TODO: If you request both a parent class and one of its * subclasses, the parent class's static members will be * injected twice. */ for (StaticInjection staticInjection : staticInjections) { staticInjection.injectMembers(); } } /** A requested static injection. */ private class StaticInjection { final InjectorImpl injector; final Object source; final StaticInjectionRequest request; ImmutableList memberInjectors; public StaticInjection(InjectorImpl injector, StaticInjectionRequest request) { this.injector = injector; this.source = request.getSource(); this.request = request; } void validate() { Errors errorsForMember = errors.withSource(source); Set injectionPoints; try { injectionPoints = request.getInjectionPoints(); } catch (ConfigurationException e) { errorsForMember.merge(e.getErrorMessages()); injectionPoints = e.getPartialValue(); } if (injectionPoints != null) { memberInjectors = injector.membersInjectorStore.getInjectors( injectionPoints, errorsForMember); } else { memberInjectors = ImmutableList.of(); } errors.merge(errorsForMember); } void injectMembers() { try { injector.callInContext(new ContextualCallable() { public Void call(InternalContext context) { for (SingleMemberInjector memberInjector : memberInjectors) { // Run injections if we're not in tool stage (ie, PRODUCTION or DEV), // or if we are in tool stage and the injection point is toolable. if(injector.options.stage != Stage.TOOL || memberInjector.getInjectionPoint().isToolable()) { memberInjector.inject(errors, context, null); } } return null; } }); } catch (ErrorsException e) { throw new AssertionError(); } } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/Initializer.java0000644000175000017500000001522611704661106026407 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.inject.Key; import com.google.inject.Stage; import com.google.inject.TypeLiteral; import com.google.inject.spi.InjectionPoint; import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; /** * Manages and injects instances at injector-creation time. This is made more complicated by * instances that request other instances while they're being injected. We overcome this by using * {@link Initializable}, which attempts to perform injection before use. * * @author jessewilson@google.com (Jesse Wilson) */ final class Initializer { /** the only thread that we'll use to inject members. */ private final Thread creatingThread = Thread.currentThread(); /** zero means everything is injected. */ private final CountDownLatch ready = new CountDownLatch(1); /** Maps from instances that need injection to the MembersInjector that will inject them. */ private final Map> pendingMembersInjectors = Maps.newIdentityHashMap(); /** Maps instances that need injection to a source that registered them */ private final Map> pendingInjection = Maps.newIdentityHashMap(); /** * Registers an instance for member injection when that step is performed. * * @param instance an instance that optionally has members to be injected (each annotated with * @Inject). * @param key a key to use for keeping the state of the dependency chain * @param source the source location that this injection was requested */ Initializable requestInjection(InjectorImpl injector, T instance, Key key, Object source, Set injectionPoints) { checkNotNull(source); // short circuit if the object has no injections if (instance == null || (injectionPoints.isEmpty() && !injector.membersInjectorStore.hasTypeListeners())) { return Initializables.of(instance); } InjectableReference initializable = new InjectableReference(injector, instance, key, source); pendingInjection.put(instance, initializable); return initializable; } /** * Prepares member injectors for all injected instances. This prompts Guice to do static analysis * on the injected instances. */ void validateOustandingInjections(Errors errors) { for (InjectableReference reference : pendingInjection.values()) { try { pendingMembersInjectors.put(reference.instance, reference.validate(errors)); } catch (ErrorsException e) { errors.merge(e.getErrors()); } } } /** * Performs creation-time injections on all objects that require it. Whenever fulfilling an * injection depends on another object that requires injection, we inject it first. If the two * instances are codependent (directly or transitively), ordering of injection is arbitrary. */ void injectAll(final Errors errors) { // loop over a defensive copy since ensureInjected() mutates the set. Unfortunately, that copy // is made complicated by a bug in IBM's JDK, wherein entrySet().toArray(Object[]) doesn't work for (InjectableReference reference : Lists.newArrayList(pendingInjection.values())) { try { reference.get(errors); } catch (ErrorsException e) { errors.merge(e.getErrors()); } } if (!pendingInjection.isEmpty()) { throw new AssertionError("Failed to satisfy " + pendingInjection); } ready.countDown(); } private class InjectableReference implements Initializable { private final InjectorImpl injector; private final T instance; private final Object source; private final Key key; public InjectableReference(InjectorImpl injector, T instance, Key key, Object source) { this.injector = injector; this.key = key; // possibly null! this.instance = checkNotNull(instance, "instance"); this.source = checkNotNull(source, "source"); } public MembersInjectorImpl validate(Errors errors) throws ErrorsException { @SuppressWarnings("unchecked") // the type of 'T' is a TypeLiteral TypeLiteral type = TypeLiteral.get((Class) instance.getClass()); return injector.membersInjectorStore.get(type, errors.withSource(source)); } /** * Reentrant. If {@code instance} was registered for injection at injector-creation time, this * method will ensure that all its members have been injected before returning. */ public T get(Errors errors) throws ErrorsException { if (ready.getCount() == 0) { return instance; } // just wait for everything to be injected by another thread if (Thread.currentThread() != creatingThread) { try { ready.await(); return instance; } catch (InterruptedException e) { // Give up, since we don't know if our injection is ready throw new RuntimeException(e); } } // toInject needs injection, do it right away. we only do this once, even if it fails if (pendingInjection.remove(instance) != null) { // safe because we only insert a members injector for the appropriate instance @SuppressWarnings("unchecked") MembersInjectorImpl membersInjector = (MembersInjectorImpl)pendingMembersInjectors.remove(instance); Preconditions.checkState(membersInjector != null, "No membersInjector available for instance: %s, from key: %s", instance, key); // if in Stage.TOOL, we only want to inject & notify toolable injection points. // (otherwise we'll inject all of them) membersInjector.injectAndNotify(instance, errors.withSource(source), key, source, injector.options.stage == Stage.TOOL); } return instance; } @Override public String toString() { return instance.toString(); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/Initializables.java0000644000175000017500000000211311704661106027056 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; /** * @author jessewilson@google.com (Jesse Wilson) */ final class Initializables { /** * Returns an initializable for an instance that requires no initialization. */ static Initializable of(final T instance) { return new Initializable() { public T get(Errors errors) throws ErrorsException { return instance; } @Override public String toString() { return String.valueOf(instance); } }; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/Initializable.java0000644000175000017500000000164611704661106026705 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; /** * Holds a reference that requires initialization to be performed before it can be used. * * @author jessewilson@google.com (Jesse Wilson) */ interface Initializable { /** * Ensures the reference is initialized, then returns it. */ T get(Errors errors) throws ErrorsException; } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/InheritingState.java0000644000175000017500000001345511704661106027227 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.inject.Binding; import com.google.inject.Key; import com.google.inject.Scope; import com.google.inject.TypeLiteral; import com.google.inject.spi.ProvisionListenerBinding; import com.google.inject.spi.TypeConverterBinding; import com.google.inject.spi.TypeListenerBinding; import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; /** * @author jessewilson@google.com (Jesse Wilson) */ final class InheritingState implements State { private final State parent; // Must be a linked hashmap in order to preserve order of bindings in Modules. private final Map, Binding> explicitBindingsMutable = Maps.newLinkedHashMap(); private final Map, Binding> explicitBindings = Collections.unmodifiableMap(explicitBindingsMutable); private final Map, Scope> scopes = Maps.newHashMap(); private final List converters = Lists.newArrayList(); /*if[AOP]*/ private final List methodAspects = Lists.newArrayList(); /*end[AOP]*/ private final List typeListenerBindings = Lists.newArrayList(); private final List provisionListenerBindings = Lists.newArrayList(); private final WeakKeySet blacklistedKeys = new WeakKeySet(); private final Object lock; InheritingState(State parent) { this.parent = checkNotNull(parent, "parent"); this.lock = (parent == State.NONE) ? this : parent.lock(); } public State parent() { return parent; } @SuppressWarnings("unchecked") // we only put in BindingImpls that match their key types public BindingImpl getExplicitBinding(Key key) { Binding binding = explicitBindings.get(key); return binding != null ? (BindingImpl) binding : parent.getExplicitBinding(key); } public Map, Binding> getExplicitBindingsThisLevel() { return explicitBindings; } public void putBinding(Key key, BindingImpl binding) { explicitBindingsMutable.put(key, binding); } public Scope getScope(Class annotationType) { Scope scope = scopes.get(annotationType); return scope != null ? scope : parent.getScope(annotationType); } public void putAnnotation(Class annotationType, Scope scope) { scopes.put(annotationType, scope); } public Iterable getConvertersThisLevel() { return converters; } public void addConverter(TypeConverterBinding typeConverterBinding) { converters.add(typeConverterBinding); } public TypeConverterBinding getConverter( String stringValue, TypeLiteral type, Errors errors, Object source) { TypeConverterBinding matchingConverter = null; for (State s = this; s != State.NONE; s = s.parent()) { for (TypeConverterBinding converter : s.getConvertersThisLevel()) { if (converter.getTypeMatcher().matches(type)) { if (matchingConverter != null) { errors.ambiguousTypeConversion(stringValue, source, type, matchingConverter, converter); } matchingConverter = converter; } } } return matchingConverter; } /*if[AOP]*/ public void addMethodAspect(MethodAspect methodAspect) { methodAspects.add(methodAspect); } public ImmutableList getMethodAspects() { return new ImmutableList.Builder() .addAll(parent.getMethodAspects()) .addAll(methodAspects) .build(); } /*end[AOP]*/ public void addTypeListener(TypeListenerBinding listenerBinding) { typeListenerBindings.add(listenerBinding); } public List getTypeListenerBindings() { List parentBindings = parent.getTypeListenerBindings(); List result = new ArrayList(parentBindings.size() + 1); result.addAll(parentBindings); result.addAll(typeListenerBindings); return result; } public void addProvisionListener(ProvisionListenerBinding listenerBinding) { provisionListenerBindings.add(listenerBinding); } public List getProvisionListenerBindings() { List parentBindings = parent.getProvisionListenerBindings(); List result = new ArrayList(parentBindings.size() + 1); result.addAll(parentBindings); result.addAll(provisionListenerBindings); return result; } public void blacklist(Key key, Object source) { parent.blacklist(key, source); blacklistedKeys.add(key, source); } public boolean isBlacklisted(Key key) { return blacklistedKeys.contains(key); } public Set getSourcesForBlacklistedKey(Key key) { return blacklistedKeys.getSources(key); } public Object lock() { return lock; } public Map, Scope> getScopes() { return scopes; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/FailableCache.java0000644000175000017500000000371211704661106026544 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Function; import com.google.common.collect.MapMaker; import java.util.Map; /** * Lazily creates (and caches) values for keys. If creating the value fails (with errors), an * exception is thrown on retrieval. * * @author jessewilson@google.com (Jesse Wilson) */ public abstract class FailableCache { private final Map delegate = new MapMaker().makeComputingMap( new Function() { public Object apply(K key) { Errors errors = new Errors(); V result = null; try { result = FailableCache.this.create(key, errors); } catch (ErrorsException e) { errors.merge(e.getErrors()); } return errors.hasErrors() ? errors : result; } }); protected abstract V create(K key, Errors errors) throws ErrorsException; public V get(K key, Errors errors) throws ErrorsException { Object resultOrError = delegate.get(key); if (resultOrError instanceof Errors) { errors.merge((Errors) resultOrError); throw errors.toException(); } else { @SuppressWarnings("unchecked") // create returned a non-error result, so this is safe V result = (V) resultOrError; return result; } } boolean remove(K key) { return delegate.remove(key) != null; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/FactoryProxy.java0000644000175000017500000000431211704661106026567 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Objects; import com.google.inject.Key; import com.google.inject.internal.InjectorImpl.JitLimitation; import com.google.inject.spi.Dependency; /** * A placeholder which enables us to swap in the real factory once the injector is created. * Used for a linked binding, so that getting the linked binding returns the link's factory. */ final class FactoryProxy implements InternalFactory, CreationListener { private final InjectorImpl injector; private final Key key; private final Key targetKey; private final Object source; private InternalFactory targetFactory; FactoryProxy(InjectorImpl injector, Key key, Key targetKey, Object source) { this.injector = injector; this.key = key; this.targetKey = targetKey; this.source = source; } public void notify(final Errors errors) { try { targetFactory = injector.getInternalFactory(targetKey, errors.withSource(source), JitLimitation.NEW_OR_EXISTING_JIT); } catch (ErrorsException e) { errors.merge(e.getErrors()); } } public T get(Errors errors, InternalContext context, Dependency dependency, boolean linked) throws ErrorsException { context.pushState(targetKey, source); try { return targetFactory.get(errors.withSource(targetKey), context, dependency, true); } finally { context.popState(); } } @Override public String toString() { return Objects.toStringHelper(FactoryProxy.class) .add("key", key) .add("provider", targetFactory) .toString(); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ExposureBuilder.java0000644000175000017500000000365411704661106027247 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Preconditions; import com.google.inject.Binder; import com.google.inject.Key; import com.google.inject.binder.AnnotatedElementBuilder; import java.lang.annotation.Annotation; /** * For private binder's expose() method. */ public class ExposureBuilder implements AnnotatedElementBuilder { private final Binder binder; private final Object source; private Key key; public ExposureBuilder(Binder binder, Object source, Key key) { this.binder = binder; this.source = source; this.key = key; } protected void checkNotAnnotated() { if (key.getAnnotationType() != null) { binder.addError(AbstractBindingBuilder.ANNOTATION_ALREADY_SPECIFIED); } } public void annotatedWith(Class annotationType) { Preconditions.checkNotNull(annotationType, "annotationType"); checkNotAnnotated(); key = Key.get(key.getTypeLiteral(), annotationType); } public void annotatedWith(Annotation annotation) { Preconditions.checkNotNull(annotation, "annotation"); checkNotAnnotated(); key = Key.get(key.getTypeLiteral(), annotation); } public Key getKey() { return key; } public Object getSource() { return source; } @Override public String toString() { return "AnnotatedElementBuilder"; } }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ExposedKeyFactory.java0000644000175000017500000000400111704661106027521 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.Key; import com.google.inject.spi.Dependency; import com.google.inject.spi.PrivateElements; /** * This factory exists in a parent injector. When invoked, it retrieves its value from a child * injector. */ final class ExposedKeyFactory implements InternalFactory, CreationListener { private final Key key; private final PrivateElements privateElements; private BindingImpl delegate; ExposedKeyFactory(Key key, PrivateElements privateElements) { this.key = key; this.privateElements = privateElements; } public void notify(Errors errors) { InjectorImpl privateInjector = (InjectorImpl) privateElements.getInjector(); BindingImpl explicitBinding = privateInjector.state.getExplicitBinding(key); // validate that the child injector has its own factory. If the getInternalFactory() returns // this, then that child injector doesn't have a factory (and getExplicitBinding has returned // its parent's binding instead if (explicitBinding.getInternalFactory() == this) { errors.withSource(explicitBinding.getSource()).exposedButNotBound(key); return; } this.delegate = explicitBinding; } public T get(Errors errors, InternalContext context, Dependency dependency, boolean linked) throws ErrorsException { return delegate.getInternalFactory().get(errors, context, dependency, linked); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ExposedBindingImpl.java0000644000175000017500000000441611704661106027647 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.inject.Binder; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.spi.BindingTargetVisitor; import com.google.inject.spi.Dependency; import com.google.inject.spi.ExposedBinding; import com.google.inject.spi.PrivateElements; import java.util.Set; public final class ExposedBindingImpl extends BindingImpl implements ExposedBinding { private final PrivateElements privateElements; public ExposedBindingImpl(InjectorImpl injector, Object source, Key key, InternalFactory factory, PrivateElements privateElements) { super(injector, key, source, factory, Scoping.UNSCOPED); this.privateElements = privateElements; } public V acceptTargetVisitor(BindingTargetVisitor visitor) { return visitor.visit(this); } public Set> getDependencies() { return ImmutableSet.>of(Dependency.get(Key.get(Injector.class))); } public PrivateElements getPrivateElements() { return privateElements; } @Override public String toString() { return Objects.toStringHelper(ExposedBinding.class) .add("key", getKey()) .add("source", getSource()) .add("privateElements", privateElements) .toString(); } public void applyTo(Binder binder) { throw new UnsupportedOperationException("This element represents a synthetic binding."); } // Purposely does not override equals/hashcode, because exposed bindings are only equal to // themselves right now -- that is, there cannot be "duplicate" exposed bindings. } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/Exceptions.java0000644000175000017500000000364211704661106026244 0ustar tonytony/** * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; /** * Rethrows user-code exceptions in wrapped exceptions so that Errors can target the correct * exception. * * @author sameb@google.com (Sam Berlin) */ class Exceptions { /** * Rethrows the exception (or it's cause, if it has one) directly if possible. * If it was a checked exception, this wraps the exception in a stack trace * with no frames, so that the exception is shown immediately with no frames * above it. */ public static RuntimeException rethrowCause(Throwable throwable) { Throwable cause = throwable; if(cause.getCause() != null) { cause = cause.getCause(); } return rethrow(cause); } /** Rethrows the exception. */ public static RuntimeException rethrow(Throwable throwable) { if(throwable instanceof RuntimeException) { throw (RuntimeException)throwable; } else if(throwable instanceof Error) { throw (Error)throwable; } else { throw new UnhandledCheckedUserException(throwable); } } /** * A marker exception class that we look for in order to unwrap the exception * into the user exception, to provide a cleaner stack trace. */ static class UnhandledCheckedUserException extends RuntimeException { public UnhandledCheckedUserException(Throwable cause) { super(cause); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ErrorsException.java0000644000175000017500000000213011704661106027245 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; /** * Indicates that a result could not be returned while preparing or resolving a binding. The caller * should {@link Errors#merge(Errors) merge} the errors from this exception with their existing * errors. * * @author jessewilson@google.com (Jesse Wilson) */ public class ErrorsException extends Exception { private final Errors errors; public ErrorsException(Errors errors) { this.errors = errors; } public Errors getErrors() { return errors; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/Errors.java0000644000175000017500000006011411704661106025374 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.inject.ConfigurationException; import com.google.inject.CreationException; import com.google.inject.Key; import com.google.inject.MembersInjector; import com.google.inject.Provider; import com.google.inject.ProvisionException; import com.google.inject.Scope; import com.google.inject.TypeLiteral; import com.google.inject.internal.util.Classes; import com.google.inject.internal.util.SourceProvider; import com.google.inject.internal.util.StackTraceElements; import com.google.inject.spi.Dependency; import com.google.inject.spi.InjectionListener; import com.google.inject.spi.InjectionPoint; import com.google.inject.spi.Message; import com.google.inject.spi.TypeConverterBinding; import com.google.inject.spi.TypeListenerBinding; import java.io.PrintWriter; import java.io.Serializable; import java.io.StringWriter; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.Formatter; import java.util.List; import java.util.Set; /** * A collection of error messages. If this type is passed as a method parameter, the method is * considered to have executed successfully only if new errors were not added to this collection. * *

    Errors can be chained to provide additional context. To add context, call {@link #withSource} * to create a new Errors instance that contains additional context. All messages added to the * returned instance will contain full context. * *

    To avoid messages with redundant context, {@link #withSource} should be added sparingly. A * good rule of thumb is to assume a ethod's caller has already specified enough context to * identify that method. When calling a method that's defined in a different context, call that * method with an errors object that includes its context. * * @author jessewilson@google.com (Jesse Wilson) */ public final class Errors implements Serializable { /** * The root errors object. Used to access the list of error messages. */ private final Errors root; /** * The parent errors object. Used to obtain the chain of source objects. */ private final Errors parent; /** * The leaf source for errors added here. */ private final Object source; /** * null unless (root == this) and error messages exist. Never an empty list. */ private List errors; // lazy, use getErrorsForAdd() public Errors() { this.root = this; this.parent = null; this.source = SourceProvider.UNKNOWN_SOURCE; } public Errors(Object source) { this.root = this; this.parent = null; this.source = source; } private Errors(Errors parent, Object source) { this.root = parent.root; this.parent = parent; this.source = source; } /** * Returns an instance that uses {@code source} as a reference point for newly added errors. */ public Errors withSource(Object source) { return source == SourceProvider.UNKNOWN_SOURCE ? this : new Errors(this, source); } /** * We use a fairly generic error message here. The motivation is to share the * same message for both bind time errors: *

    Guice.createInjector(new AbstractModule() {
       *   public void configure() {
       *     bind(Runnable.class);
       *   }
       * }
    * ...and at provide-time errors: *
    Guice.createInjector().getInstance(Runnable.class);
    * Otherwise we need to know who's calling when resolving a just-in-time * binding, which makes things unnecessarily complex. */ public Errors missingImplementation(Key key) { return addMessage("No implementation for %s was bound.", key); } public Errors jitDisabled(Key key) { return addMessage("Explicit bindings are required and %s is not explicitly bound.", key); } public Errors converterReturnedNull(String stringValue, Object source, TypeLiteral type, TypeConverterBinding typeConverterBinding) { return addMessage("Received null converting '%s' (bound at %s) to %s%n" + " using %s.", stringValue, convert(source), type, typeConverterBinding); } public Errors conversionTypeError(String stringValue, Object source, TypeLiteral type, TypeConverterBinding typeConverterBinding, Object converted) { return addMessage("Type mismatch converting '%s' (bound at %s) to %s%n" + " using %s.%n" + " Converter returned %s.", stringValue, convert(source), type, typeConverterBinding, converted); } public Errors conversionError(String stringValue, Object source, TypeLiteral type, TypeConverterBinding typeConverterBinding, RuntimeException cause) { return errorInUserCode(cause, "Error converting '%s' (bound at %s) to %s%n" + " using %s.%n" + " Reason: %s", stringValue, convert(source), type, typeConverterBinding, cause); } public Errors ambiguousTypeConversion(String stringValue, Object source, TypeLiteral type, TypeConverterBinding a, TypeConverterBinding b) { return addMessage("Multiple converters can convert '%s' (bound at %s) to %s:%n" + " %s and%n" + " %s.%n" + " Please adjust your type converter configuration to avoid overlapping matches.", stringValue, convert(source), type, a, b); } public Errors bindingToProvider() { return addMessage("Binding to Provider is not allowed."); } public Errors subtypeNotProvided(Class> providerType, Class type) { return addMessage("%s doesn't provide instances of %s.", providerType, type); } public Errors notASubtype(Class implementationType, Class type) { return addMessage("%s doesn't extend %s.", implementationType, type); } public Errors recursiveImplementationType() { return addMessage("@ImplementedBy points to the same class it annotates."); } public Errors recursiveProviderType() { return addMessage("@ProvidedBy points to the same class it annotates."); } public Errors missingRuntimeRetention(Object source) { return addMessage("Please annotate with @Retention(RUNTIME).%n" + " Bound at %s.", convert(source)); } public Errors missingScopeAnnotation() { return addMessage("Please annotate with @ScopeAnnotation."); } public Errors optionalConstructor(Constructor constructor) { return addMessage("%s is annotated @Inject(optional=true), " + "but constructors cannot be optional.", constructor); } public Errors cannotBindToGuiceType(String simpleName) { return addMessage("Binding to core guice framework type is not allowed: %s.", simpleName); } public Errors scopeNotFound(Class scopeAnnotation) { return addMessage("No scope is bound to %s.", scopeAnnotation); } public Errors scopeAnnotationOnAbstractType( Class scopeAnnotation, Class type, Object source) { return addMessage("%s is annotated with %s, but scope annotations are not supported " + "for abstract types.%n Bound at %s.", type, scopeAnnotation, convert(source)); } public Errors misplacedBindingAnnotation(Member member, Annotation bindingAnnotation) { return addMessage("%s is annotated with %s, but binding annotations should be applied " + "to its parameters instead.", member, bindingAnnotation); } private static final String CONSTRUCTOR_RULES = "Classes must have either one (and only one) constructor " + "annotated with @Inject or a zero-argument constructor that is not private."; public Errors missingConstructor(Class implementation) { return addMessage("Could not find a suitable constructor in %s. " + CONSTRUCTOR_RULES, implementation); } public Errors tooManyConstructors(Class implementation) { return addMessage("%s has more than one constructor annotated with @Inject. " + CONSTRUCTOR_RULES, implementation); } public Errors constructorNotDefinedByType(Constructor constructor, TypeLiteral type) { return addMessage("%s does not define %s", type, constructor); } public Errors duplicateScopes(Scope existing, Class annotationType, Scope scope) { return addMessage("Scope %s is already bound to %s. Cannot bind %s.", existing, annotationType, scope); } public Errors voidProviderMethod() { return addMessage("Provider methods must return a value. Do not return void."); } public Errors missingConstantValues() { return addMessage("Missing constant value. Please call to(...)."); } public Errors cannotInjectInnerClass(Class type) { return addMessage("Injecting into inner classes is not supported. " + "Please use a 'static' class (top-level or nested) instead of %s.", type); } public Errors duplicateBindingAnnotations(Member member, Class a, Class b) { return addMessage("%s has more than one annotation annotated with @BindingAnnotation: " + "%s and %s", member, a, b); } public Errors staticInjectionOnInterface(Class clazz) { return addMessage("%s is an interface, but interfaces have no static injection points.", clazz); } public Errors cannotInjectFinalField(Field field) { return addMessage("Injected field %s cannot be final.", field); } public Errors cannotInjectAbstractMethod(Method method) { return addMessage("Injected method %s cannot be abstract.", method); } public Errors cannotInjectNonVoidMethod(Method method) { return addMessage("Injected method %s must return void.", method); } public Errors cannotInjectMethodWithTypeParameters(Method method) { return addMessage("Injected method %s cannot declare type parameters of its own.", method); } public Errors duplicateScopeAnnotations( Class a, Class b) { return addMessage("More than one scope annotation was found: %s and %s.", a, b); } public Errors recursiveBinding() { return addMessage("Binding points to itself."); } public Errors bindingAlreadySet(Key key, Object source) { return addMessage("A binding to %s was already configured at %s.", key, convert(source)); } public Errors jitBindingAlreadySet(Key key) { return addMessage("A just-in-time binding to %s was already configured on a parent injector.", key); } public Errors childBindingAlreadySet(Key key, Set sources) { Formatter allSources = new Formatter(); for (Object source : sources) { if (source == null) { allSources.format("%n (bound by a just-in-time binding)"); } else { allSources.format("%n bound at %s", source); } } Errors errors = addMessage( "Unable to create binding for %s." + " It was already configured on one or more child injectors or private modules" + "%s%n" + " If it was in a PrivateModule, did you forget to expose the binding?", key, allSources.out()); return errors; } public Errors errorCheckingDuplicateBinding(Key key, Object source, Throwable t) { return addMessage( "A binding to %s was already configured at %s and an error was thrown " + "while checking duplicate bindings. Error: %s", key, convert(source), t); } public Errors errorInjectingMethod(Throwable cause) { return errorInUserCode(cause, "Error injecting method, %s", cause); } public Errors errorNotifyingTypeListener(TypeListenerBinding listener, TypeLiteral type, Throwable cause) { return errorInUserCode(cause, "Error notifying TypeListener %s (bound at %s) of %s.%n" + " Reason: %s", listener.getListener(), convert(listener.getSource()), type, cause); } public Errors errorInjectingConstructor(Throwable cause) { return errorInUserCode(cause, "Error injecting constructor, %s", cause); } public Errors errorInProvider(RuntimeException runtimeException) { Throwable unwrapped = unwrap(runtimeException); return errorInUserCode(unwrapped, "Error in custom provider, %s", unwrapped); } public Errors errorInUserInjector( MembersInjector listener, TypeLiteral type, RuntimeException cause) { return errorInUserCode(cause, "Error injecting %s using %s.%n" + " Reason: %s", type, listener, cause); } public Errors errorNotifyingInjectionListener( InjectionListener listener, TypeLiteral type, RuntimeException cause) { return errorInUserCode(cause, "Error notifying InjectionListener %s of %s.%n" + " Reason: %s", listener, type, cause); } public Errors exposedButNotBound(Key key) { return addMessage("Could not expose() %s, it must be explicitly bound.", key); } public Errors keyNotFullySpecified(TypeLiteral typeLiteral) { return addMessage("%s cannot be used as a key; It is not fully specified.", typeLiteral); } public Errors errorEnhancingClass(Class clazz, Throwable cause) { return errorInUserCode(cause, "Unable to method intercept: %s", clazz); } public static Collection getMessagesFromThrowable(Throwable throwable) { if (throwable instanceof ProvisionException) { return ((ProvisionException) throwable).getErrorMessages(); } else if (throwable instanceof ConfigurationException) { return ((ConfigurationException) throwable).getErrorMessages(); } else if (throwable instanceof CreationException) { return ((CreationException) throwable).getErrorMessages(); } else { return ImmutableSet.of(); } } public Errors errorInUserCode(Throwable cause, String messageFormat, Object... arguments) { Collection messages = getMessagesFromThrowable(cause); if (!messages.isEmpty()) { return merge(messages); } else { return addMessage(cause, messageFormat, arguments); } } private Throwable unwrap(RuntimeException runtimeException) { if(runtimeException instanceof Exceptions.UnhandledCheckedUserException) { return runtimeException.getCause(); } else { return runtimeException; } } public Errors cannotInjectRawProvider() { return addMessage("Cannot inject a Provider that has no type parameter"); } public Errors cannotInjectRawMembersInjector() { return addMessage("Cannot inject a MembersInjector that has no type parameter"); } public Errors cannotInjectTypeLiteralOf(Type unsupportedType) { return addMessage("Cannot inject a TypeLiteral of %s", unsupportedType); } public Errors cannotInjectRawTypeLiteral() { return addMessage("Cannot inject a TypeLiteral that has no type parameter"); } public Errors cannotSatisfyCircularDependency(Class expectedType) { return addMessage( "Tried proxying %s to support a circular dependency, but it is not an interface.", expectedType); } public Errors circularProxiesDisabled(Class expectedType) { return addMessage( "Tried proxying %s to support a circular dependency, but circular proxies are disabled.", expectedType); } public void throwCreationExceptionIfErrorsExist() { if (!hasErrors()) { return; } throw new CreationException(getMessages()); } public void throwConfigurationExceptionIfErrorsExist() { if (!hasErrors()) { return; } throw new ConfigurationException(getMessages()); } public void throwProvisionExceptionIfErrorsExist() { if (!hasErrors()) { return; } throw new ProvisionException(getMessages()); } private Message merge(Message message) { List sources = Lists.newArrayList(); sources.addAll(getSources()); sources.addAll(message.getSources()); return new Message(sources, message.getMessage(), message.getCause()); } public Errors merge(Collection messages) { for (Message message : messages) { addMessage(merge(message)); } return this; } public Errors merge(Errors moreErrors) { if (moreErrors.root == root || moreErrors.root.errors == null) { return this; } merge(moreErrors.root.errors); return this; } public List getSources() { List sources = Lists.newArrayList(); for (Errors e = this; e != null; e = e.parent) { if (e.source != SourceProvider.UNKNOWN_SOURCE) { sources.add(0, e.source); } } return sources; } public void throwIfNewErrors(int expectedSize) throws ErrorsException { if (size() == expectedSize) { return; } throw toException(); } public ErrorsException toException() { return new ErrorsException(this); } public boolean hasErrors() { return root.errors != null; } public Errors addMessage(String messageFormat, Object... arguments) { return addMessage(null, messageFormat, arguments); } private Errors addMessage(Throwable cause, String messageFormat, Object... arguments) { String message = format(messageFormat, arguments); addMessage(new Message(getSources(), message, cause)); return this; } public Errors addMessage(Message message) { if (root.errors == null) { root.errors = Lists.newArrayList(); } root.errors.add(message); return this; } public static String format(String messageFormat, Object... arguments) { for (int i = 0; i < arguments.length; i++) { arguments[i] = Errors.convert(arguments[i]); } return String.format(messageFormat, arguments); } public List getMessages() { if (root.errors == null) { return ImmutableList.of(); } List result = Lists.newArrayList(root.errors); Collections.sort(result, new Comparator() { public int compare(Message a, Message b) { return a.getSource().compareTo(b.getSource()); } }); return result; } /** Returns the formatted message for an exception with the specified messages. */ public static String format(String heading, Collection errorMessages) { Formatter fmt = new Formatter().format(heading).format(":%n%n"); int index = 1; boolean displayCauses = getOnlyCause(errorMessages) == null; for (Message errorMessage : errorMessages) { fmt.format("%s) %s%n", index++, errorMessage.getMessage()); List dependencies = errorMessage.getSources(); for (int i = dependencies.size() - 1; i >= 0; i--) { Object source = dependencies.get(i); formatSource(fmt, source); } Throwable cause = errorMessage.getCause(); if (displayCauses && cause != null) { StringWriter writer = new StringWriter(); cause.printStackTrace(new PrintWriter(writer)); fmt.format("Caused by: %s", writer.getBuffer()); } fmt.format("%n"); } if (errorMessages.size() == 1) { fmt.format("1 error"); } else { fmt.format("%s errors", errorMessages.size()); } return fmt.toString(); } /** * Returns {@code value} if it is non-null allowed to be null. Otherwise a message is added and * an {@code ErrorsException} is thrown. */ public T checkForNull(T value, Object source, Dependency dependency) throws ErrorsException { if (value != null || dependency.isNullable() ) { return value; } int parameterIndex = dependency.getParameterIndex(); String parameterName = (parameterIndex != -1) ? "parameter " + parameterIndex + " of " : ""; addMessage("null returned by binding at %s%n but %s%s is not @Nullable", source, parameterName, dependency.getInjectionPoint().getMember()); throw toException(); } /** * Returns the cause throwable if there is exactly one cause in {@code messages}. If there are * zero or multiple messages with causes, null is returned. */ public static Throwable getOnlyCause(Collection messages) { Throwable onlyCause = null; for (Message message : messages) { Throwable messageCause = message.getCause(); if (messageCause == null) { continue; } if (onlyCause != null) { return null; } onlyCause = messageCause; } return onlyCause; } public int size() { return root.errors == null ? 0 : root.errors.size(); } private static abstract class Converter { final Class type; Converter(Class type) { this.type = type; } boolean appliesTo(Object o) { return o != null && type.isAssignableFrom(o.getClass()); } String convert(Object o) { return toString(type.cast(o)); } abstract String toString(T t); } private static final Collection> converters = ImmutableList.of( new Converter(Class.class) { public String toString(Class c) { return c.getName(); } }, new Converter(Member.class) { public String toString(Member member) { return Classes.toString(member); } }, new Converter(Key.class) { public String toString(Key key) { if (key.getAnnotationType() != null) { return key.getTypeLiteral() + " annotated with " + (key.getAnnotation() != null ? key.getAnnotation() : key.getAnnotationType()); } else { return key.getTypeLiteral().toString(); } } }); public static Object convert(Object o) { for (Converter converter : converters) { if (converter.appliesTo(o)) { return converter.convert(o); } } return o; } public static void formatSource(Formatter formatter, Object source) { if (source instanceof Dependency) { Dependency dependency = (Dependency) source; InjectionPoint injectionPoint = dependency.getInjectionPoint(); if (injectionPoint != null) { formatInjectionPoint(formatter, dependency, injectionPoint); } else { formatSource(formatter, dependency.getKey()); } } else if (source instanceof InjectionPoint) { formatInjectionPoint(formatter, null, (InjectionPoint) source); } else if (source instanceof Class) { formatter.format(" at %s%n", StackTraceElements.forType((Class) source)); } else if (source instanceof Member) { formatter.format(" at %s%n", StackTraceElements.forMember((Member) source)); } else if (source instanceof TypeLiteral) { formatter.format(" while locating %s%n", source); } else if (source instanceof Key) { Key key = (Key) source; formatter.format(" while locating %s%n", convert(key)); } else { formatter.format(" at %s%n", source); } } public static void formatInjectionPoint(Formatter formatter, Dependency dependency, InjectionPoint injectionPoint) { Member member = injectionPoint.getMember(); Class memberType = Classes.memberType(member); if (memberType == Field.class) { dependency = injectionPoint.getDependencies().get(0); formatter.format(" while locating %s%n", convert(dependency.getKey())); formatter.format(" for field at %s%n", StackTraceElements.forMember(member)); } else if (dependency != null) { formatter.format(" while locating %s%n", convert(dependency.getKey())); formatter.format(" for parameter %s at %s%n", dependency.getParameterIndex(), StackTraceElements.forMember(member)); } else { formatSource(formatter, injectionPoint.getMember()); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ErrorHandler.java0000644000175000017500000000166511704661106026515 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.spi.Message; /** * Handles errors in the Injector. * * @author crazybob@google.com (Bob Lee) */ interface ErrorHandler { /** * Handles an error. */ void handle(Object source, Errors errors); /** * Handles a user-reported error. */ void handle(Message message); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/EncounterImpl.java0000644000175000017500000001075111704661106026706 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkState; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.inject.Key; import com.google.inject.MembersInjector; import com.google.inject.Provider; import com.google.inject.TypeLiteral; import com.google.inject.matcher.Matcher; import com.google.inject.matcher.Matchers; import com.google.inject.spi.InjectionListener; import com.google.inject.spi.Message; import com.google.inject.spi.TypeEncounter; import java.lang.reflect.Method; import java.util.List; /** * @author jessewilson@google.com (Jesse Wilson) */ final class EncounterImpl implements TypeEncounter { private final Errors errors; private final Lookups lookups; private List> membersInjectors; // lazy private List> injectionListeners; // lazy /*if[AOP]*/ private List aspects; // lazy /*end[AOP]*/ private boolean valid = true; EncounterImpl(Errors errors, Lookups lookups) { this.errors = errors; this.lookups = lookups; } void invalidate() { valid = false; } /*if[AOP]*/ ImmutableList getAspects() { return aspects == null ? ImmutableList.of() : ImmutableList.copyOf(aspects); } public void bindInterceptor(Matcher methodMatcher, org.aopalliance.intercept.MethodInterceptor... interceptors) { checkState(valid, "Encounters may not be used after hear() returns."); // make sure the applicable aspects is mutable if (aspects == null) { aspects = Lists.newArrayList(); } aspects.add(new MethodAspect(Matchers.any(), methodMatcher, interceptors)); } /*end[AOP]*/ ImmutableList> getMembersInjectors() { return membersInjectors == null ? ImmutableList.>of() : ImmutableList.copyOf(membersInjectors); } ImmutableList> getInjectionListeners() { return injectionListeners == null ? ImmutableList.>of() : ImmutableList.copyOf(injectionListeners); } public void register(MembersInjector membersInjector) { checkState(valid, "Encounters may not be used after hear() returns."); if (membersInjectors == null) { membersInjectors = Lists.newArrayList(); } membersInjectors.add(membersInjector); } public void register(InjectionListener injectionListener) { checkState(valid, "Encounters may not be used after hear() returns."); if (injectionListeners == null) { injectionListeners = Lists.newArrayList(); } injectionListeners.add(injectionListener); } public void addError(String message, Object... arguments) { checkState(valid, "Encounters may not be used after hear() returns."); errors.addMessage(message, arguments); } public void addError(Throwable t) { checkState(valid, "Encounters may not be used after hear() returns."); errors.errorInUserCode(t, "An exception was caught and reported. Message: %s", t.getMessage()); } public void addError(Message message) { checkState(valid, "Encounters may not be used after hear() returns."); errors.addMessage(message); } public Provider getProvider(Key key) { checkState(valid, "Encounters may not be used after hear() returns."); return lookups.getProvider(key); } public Provider getProvider(Class type) { return getProvider(Key.get(type)); } public MembersInjector getMembersInjector(TypeLiteral typeLiteral) { checkState(valid, "Encounters may not be used after hear() returns."); return lookups.getMembersInjector(typeLiteral); } public MembersInjector getMembersInjector(Class type) { return getMembersInjector(TypeLiteral.get(type)); } }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/DelegatingInvocationHandler.java0000644000175000017500000000341011704661106031507 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; class DelegatingInvocationHandler implements InvocationHandler { private T delegate; public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (delegate == null) { throw new IllegalStateException("This is a proxy used to support" + " circular references. The object we're" + " proxying is not constructed yet. Please wait until after" + " injection has completed to use this object."); } try { // TODO: method.setAccessible(true); ? // this would fix visibility errors when we proxy a // non-public interface. return method.invoke(delegate, args); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw e.getTargetException(); } } public T getDelegate() { return delegate; } void setDelegate(T delegate) { this.delegate = delegate; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/DelayedInitialize.java0000644000175000017500000000077111704661106027514 0ustar tonytony// Copyright 2011 Google Inc. All Rights Reserved. package com.google.inject.internal; /** * Something that needs some delayed initialization, typically * a binding or internal factory that needs to be created & put * into the bindings map & then initialized later. * * @author sameb@google.com (Sam Berlin) */ interface DelayedInitialize { /** Initializes this binding, throwing any errors if necessary. */ void initialize(InjectorImpl injector, Errors errors) throws ErrorsException; } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/DeferredLookups.java0000644000175000017500000000404311704661106027214 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.Lists; import com.google.inject.Key; import com.google.inject.MembersInjector; import com.google.inject.Provider; import com.google.inject.TypeLiteral; import com.google.inject.spi.Element; import com.google.inject.spi.MembersInjectorLookup; import com.google.inject.spi.ProviderLookup; import java.util.List; /** * Returns providers and members injectors that haven't yet been initialized. As a part of injector * creation it's necessary to {@link #initialize initialize} these lookups. * * @author jessewilson@google.com (Jesse Wilson) */ final class DeferredLookups implements Lookups { private final InjectorImpl injector; private final List lookups = Lists.newArrayList(); DeferredLookups(InjectorImpl injector) { this.injector = injector; } /** * Initialize the specified lookups, either immediately or when the injector is created. */ void initialize(Errors errors) { injector.lookups = injector; new LookupProcessor(errors).process(injector, lookups); } public Provider getProvider(Key key) { ProviderLookup lookup = new ProviderLookup(key, key); lookups.add(lookup); return lookup.getProvider(); } public MembersInjector getMembersInjector(TypeLiteral type) { MembersInjectorLookup lookup = new MembersInjectorLookup(type, type); lookups.add(lookup); return lookup.getMembersInjector(); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/DefaultConstructionProxyFactory.java0000644000175000017500000000733511704661106032517 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.ImmutableMap; import com.google.inject.internal.BytecodeGen.Visibility; import com.google.inject.spi.InjectionPoint; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.List; /** * Produces construction proxies that invoke the class constructor. * * @author crazybob@google.com (Bob Lee) */ final class DefaultConstructionProxyFactory implements ConstructionProxyFactory { private final InjectionPoint injectionPoint; /** * @param injectionPoint an injection point whose member is a constructor of {@code T}. */ DefaultConstructionProxyFactory(InjectionPoint injectionPoint) { this.injectionPoint = injectionPoint; } public ConstructionProxy create() { @SuppressWarnings("unchecked") // the injection point is for a constructor of T final Constructor constructor = (Constructor) injectionPoint.getMember(); // Use FastConstructor if the constructor is public. if (Modifier.isPublic(constructor.getModifiers())) { Class classToConstruct = constructor.getDeclaringClass(); /*if[AOP]*/ try { final net.sf.cglib.reflect.FastConstructor fastConstructor = BytecodeGen.newFastClass(classToConstruct, Visibility.forMember(constructor)) .getConstructor(constructor); return new ConstructionProxy() { @SuppressWarnings("unchecked") public T newInstance(Object... arguments) throws InvocationTargetException { return (T) fastConstructor.newInstance(arguments); } public InjectionPoint getInjectionPoint() { return injectionPoint; } public Constructor getConstructor() { return constructor; } public ImmutableMap> getMethodInterceptors() { return ImmutableMap.of(); } }; } catch (net.sf.cglib.core.CodeGenerationException e) {/* fall-through */} /*end[AOP]*/ if (!Modifier.isPublic(classToConstruct.getModifiers())) { constructor.setAccessible(true); } } else { constructor.setAccessible(true); } return new ConstructionProxy() { public T newInstance(Object... arguments) throws InvocationTargetException { try { return constructor.newInstance(arguments); } catch (InstantiationException e) { throw new AssertionError(e); // shouldn't happen, we know this is a concrete type } catch (IllegalAccessException e) { throw new AssertionError(e); // a security manager is blocking us, we're hosed } } public InjectionPoint getInjectionPoint() { return injectionPoint; } public Constructor getConstructor() { return constructor; } /*if[AOP]*/ public ImmutableMap> getMethodInterceptors() { return ImmutableMap.of(); } /*end[AOP]*/ }; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/CreationListener.java0000644000175000017500000000142711704661106027374 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; /** Something that is notified upon creation. */ interface CreationListener { /** Notifies that creation should happen. */ void notify(Errors errors); }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ContextualCallable.java0000644000175000017500000000141111704661106027661 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; /** * @author crazybob@google.com (Bob Lee) */ interface ContextualCallable { T call(InternalContext context) throws ErrorsException; } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ConstructorInjectorStore.java0000644000175000017500000000670611704661106031167 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.collect.Iterables.concat; import com.google.common.collect.ImmutableList; import com.google.inject.spi.InjectionPoint; /** * Constructor injectors by type. * * @author jessewilson@google.com (Jesse Wilson) */ final class ConstructorInjectorStore { private final InjectorImpl injector; private final FailableCache> cache = new FailableCache> () { @Override protected ConstructorInjector create(InjectionPoint constructorInjector, Errors errors) throws ErrorsException { return createConstructor(constructorInjector, errors); } }; ConstructorInjectorStore(InjectorImpl injector) { this.injector = injector; } /** * Returns a new complete constructor injector with injection listeners registered. */ public ConstructorInjector get(InjectionPoint constructorInjector, Errors errors) throws ErrorsException { return cache.get(constructorInjector, errors); } /** * Purges an injection point from the cache. Use this only if the cache is not actually valid and * needs to be purged. (See issue 319 and * ImplicitBindingTest#testCircularJitBindingsLeaveNoResidue and * #testInstancesRequestingProvidersForThemselvesWithChildInjectors for examples of when this is * necessary.) * * Returns true if the injector for that point was stored in the cache, false otherwise. */ boolean remove(InjectionPoint ip) { return cache.remove(ip); } private ConstructorInjector createConstructor(InjectionPoint injectionPoint, Errors errors) throws ErrorsException { int numErrorsBefore = errors.size(); SingleParameterInjector[] constructorParameterInjectors = injector.getParametersInjectors(injectionPoint.getDependencies(), errors); @SuppressWarnings("unchecked") // the injector type agrees with the injection point type MembersInjectorImpl membersInjector = (MembersInjectorImpl) injector.membersInjectorStore .get(injectionPoint.getDeclaringType(), errors); /*if[AOP]*/ ImmutableList injectorAspects = injector.state.getMethodAspects(); ImmutableList methodAspects = membersInjector.getAddedAspects().isEmpty() ? injectorAspects : ImmutableList.copyOf(concat(injectorAspects, membersInjector.getAddedAspects())); ConstructionProxyFactory factory = new ProxyFactory(injectionPoint, methodAspects); /*end[AOP]*/ /*if[NO_AOP] ConstructionProxyFactory factory = new DefaultConstructionProxyFactory(injectionPoint); end[NO_AOP]*/ errors.throwIfNewErrors(numErrorsBefore); return new ConstructorInjector(membersInjector.getInjectionPoints(), factory.create(), constructorParameterInjectors, membersInjector); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ConstructorInjector.java0000644000175000017500000001113611704661106030143 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.ImmutableSet; import com.google.inject.internal.ProvisionListenerStackCallback.ProvisionCallback; import com.google.inject.spi.InjectionPoint; import java.lang.reflect.InvocationTargetException; import java.util.Set; /** * Creates instances using an injectable constructor. After construction, all injectable fields and * methods are injected. * * @author crazybob@google.com (Bob Lee) */ final class ConstructorInjector { private final ImmutableSet injectableMembers; private final SingleParameterInjector[] parameterInjectors; private final ConstructionProxy constructionProxy; private final MembersInjectorImpl membersInjector; ConstructorInjector(Set injectableMembers, ConstructionProxy constructionProxy, SingleParameterInjector[] parameterInjectors, MembersInjectorImpl membersInjector) { this.injectableMembers = ImmutableSet.copyOf(injectableMembers); this.constructionProxy = constructionProxy; this.parameterInjectors = parameterInjectors; this.membersInjector = membersInjector; } public ImmutableSet getInjectableMembers() { return injectableMembers; } ConstructionProxy getConstructionProxy() { return constructionProxy; } /** * Construct an instance. Returns {@code Object} instead of {@code T} because * it may return a proxy. */ Object construct(final Errors errors, final InternalContext context, Class expectedType, boolean allowProxy, ProvisionListenerStackCallback provisionCallback) throws ErrorsException { final ConstructionContext constructionContext = context.getConstructionContext(this); // We have a circular reference between constructors. Return a proxy. if (constructionContext.isConstructing()) { if(!allowProxy) { throw errors.circularProxiesDisabled(expectedType).toException(); } else { // TODO (crazybob): if we can't proxy this object, can we proxy the other object? return constructionContext.createProxy(errors, expectedType); } } // If we're re-entering this factory while injecting fields or methods, // return the same instance. This prevents infinite loops. T t = constructionContext.getCurrentReference(); if (t != null) { return t; } try { // Optimization: Don't go through the callback stack if we have no listeners. if (!provisionCallback.hasListeners()) { return provision(errors, context, constructionContext); } else { return provisionCallback.provision(errors, context, new ProvisionCallback() { public T call() throws ErrorsException { return provision(errors, context, constructionContext); } }); } } finally { constructionContext.removeCurrentReference(); } } /** Provisions a new T. */ private T provision(Errors errors, InternalContext context, ConstructionContext constructionContext) throws ErrorsException { try { constructionContext.startConstruction(); T t; try { Object[] parameters = SingleParameterInjector.getAll(errors, context, parameterInjectors); t = constructionProxy.newInstance(parameters); constructionContext.setProxyDelegates(t); } finally { constructionContext.finishConstruction(); } // Store reference. If an injector re-enters this factory, they'll get the same reference. constructionContext.setCurrentReference(t); membersInjector.injectMembers(t, errors, context, false); membersInjector.notifyListeners(t, errors); return t; } catch (InvocationTargetException userException) { Throwable cause = userException.getCause() != null ? userException.getCause() : userException; throw errors.withSource(constructionProxy.getInjectionPoint()) .errorInjectingConstructor(cause).toException(); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ConstructorBindingImpl.java0000644000175000017500000002426511704661106030571 0ustar tonytony/* * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkState; import static com.google.inject.internal.Annotations.findScopeAnnotation; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.inject.Binder; import com.google.inject.ConfigurationException; import com.google.inject.Key; import com.google.inject.TypeLiteral; import com.google.inject.internal.util.Classes; import com.google.inject.spi.BindingTargetVisitor; import com.google.inject.spi.ConstructorBinding; import com.google.inject.spi.Dependency; import com.google.inject.spi.InjectionPoint; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.List; import java.util.Map; import java.util.Set; final class ConstructorBindingImpl extends BindingImpl implements ConstructorBinding, DelayedInitialize { private final Factory factory; private final InjectionPoint constructorInjectionPoint; private ConstructorBindingImpl(InjectorImpl injector, Key key, Object source, InternalFactory scopedFactory, Scoping scoping, Factory factory, InjectionPoint constructorInjectionPoint) { super(injector, key, source, scopedFactory, scoping); this.factory = factory; this.constructorInjectionPoint = constructorInjectionPoint; } public ConstructorBindingImpl(Key key, Object source, Scoping scoping, InjectionPoint constructorInjectionPoint, Set injectionPoints) { super(source, key, scoping); this.factory = new Factory(false, key); ConstructionProxy constructionProxy = new DefaultConstructionProxyFactory(constructorInjectionPoint).create(); this.constructorInjectionPoint = constructorInjectionPoint; factory.constructorInjector = new ConstructorInjector( injectionPoints, constructionProxy, null, null); } /** * @param constructorInjector the constructor to use, or {@code null} to use the default. * @param failIfNotLinked true if this ConstructorBindingImpl's InternalFactory should * only succeed if retrieved from a linked binding */ static ConstructorBindingImpl create(InjectorImpl injector, Key key, InjectionPoint constructorInjector, Object source, Scoping scoping, Errors errors, boolean failIfNotLinked) throws ErrorsException { int numErrors = errors.size(); @SuppressWarnings("unchecked") // constructorBinding guarantees type is consistent Class rawType = constructorInjector == null ? key.getTypeLiteral().getRawType() : (Class) constructorInjector.getDeclaringType().getRawType(); // We can't inject abstract classes. if (Modifier.isAbstract(rawType.getModifiers())) { errors.missingImplementation(key); } // Error: Inner class. if (Classes.isInnerClass(rawType)) { errors.cannotInjectInnerClass(rawType); } errors.throwIfNewErrors(numErrors); // Find a constructor annotated @Inject if (constructorInjector == null) { try { constructorInjector = InjectionPoint.forConstructorOf(key.getTypeLiteral()); } catch (ConfigurationException e) { throw errors.merge(e.getErrorMessages()).toException(); } } // if no scope is specified, look for a scoping annotation on the concrete class if (!scoping.isExplicitlyScoped()) { Class annotatedType = constructorInjector.getMember().getDeclaringClass(); Class scopeAnnotation = findScopeAnnotation(errors, annotatedType); if (scopeAnnotation != null) { scoping = Scoping.makeInjectable(Scoping.forAnnotation(scopeAnnotation), injector, errors.withSource(rawType)); } } errors.throwIfNewErrors(numErrors); Factory factoryFactory = new Factory(failIfNotLinked, key); InternalFactory scopedFactory = Scoping.scope(key, injector, factoryFactory, source, scoping); return new ConstructorBindingImpl( injector, key, source, scopedFactory, scoping, factoryFactory, constructorInjector); } @SuppressWarnings("unchecked") // the result type always agrees with the ConstructorInjector type public void initialize(InjectorImpl injector, Errors errors) throws ErrorsException { factory.allowCircularProxy = !injector.options.disableCircularProxies; factory.constructorInjector = (ConstructorInjector) injector.constructors.get(constructorInjectionPoint, errors); factory.provisionCallback = injector.provisionListenerStore.get(getKey()); } /** True if this binding has been initialized and is ready for use. */ boolean isInitialized() { return factory.constructorInjector != null; } /** Returns an injection point that can be used to clean up the constructor store. */ InjectionPoint getInternalConstructor() { if(factory.constructorInjector != null) { return factory.constructorInjector.getConstructionProxy().getInjectionPoint(); } else { return constructorInjectionPoint; } } /** Returns a set of dependencies that can be iterated over to clean up stray JIT bindings. */ Set> getInternalDependencies() { ImmutableSet.Builder builder = ImmutableSet.builder(); if(factory.constructorInjector == null) { builder.add(constructorInjectionPoint); // If the below throws, it's OK -- we just ignore those dependencies, because no one // could have used them anyway. try { builder.addAll(InjectionPoint.forInstanceMethodsAndFields(constructorInjectionPoint.getDeclaringType())); } catch(ConfigurationException ignored) {} } else { builder.add(getConstructor()) .addAll(getInjectableMembers()); } return Dependency.forInjectionPoints(builder.build()); } public V acceptTargetVisitor(BindingTargetVisitor visitor) { checkState(factory.constructorInjector != null, "not initialized"); return visitor.visit(this); } public InjectionPoint getConstructor() { checkState(factory.constructorInjector != null, "Binding is not ready"); return factory.constructorInjector.getConstructionProxy().getInjectionPoint(); } public Set getInjectableMembers() { checkState(factory.constructorInjector != null, "Binding is not ready"); return factory.constructorInjector.getInjectableMembers(); } /*if[AOP]*/ public Map> getMethodInterceptors() { checkState(factory.constructorInjector != null, "Binding is not ready"); return factory.constructorInjector.getConstructionProxy().getMethodInterceptors(); } /*end[AOP]*/ public Set> getDependencies() { return Dependency.forInjectionPoints(new ImmutableSet.Builder() .add(getConstructor()) .addAll(getInjectableMembers()) .build()); } @Override protected BindingImpl withScoping(Scoping scoping) { return new ConstructorBindingImpl( null, getKey(), getSource(), factory, scoping, factory, constructorInjectionPoint); } @Override protected BindingImpl withKey(Key key) { return new ConstructorBindingImpl( null, key, getSource(), factory, getScoping(), factory, constructorInjectionPoint); } @SuppressWarnings("unchecked") // the raw constructor member and declaring type always agree public void applyTo(Binder binder) { InjectionPoint constructor = getConstructor(); getScoping().applyTo(binder.withSource(getSource()).bind(getKey()).toConstructor( (Constructor) getConstructor().getMember(), (TypeLiteral) constructor.getDeclaringType())); } @Override public String toString() { return Objects.toStringHelper(ConstructorBinding.class) .add("key", getKey()) .add("source", getSource()) .add("scope", getScoping()) .toString(); } @Override public boolean equals(Object obj) { if(obj instanceof ConstructorBindingImpl) { ConstructorBindingImpl o = (ConstructorBindingImpl)obj; return getKey().equals(o.getKey()) && getScoping().equals(o.getScoping()) && Objects.equal(constructorInjectionPoint, o.constructorInjectionPoint); } else { return false; } } @Override public int hashCode() { return Objects.hashCode(getKey(), getScoping(), constructorInjectionPoint); } private static class Factory implements InternalFactory { private final boolean failIfNotLinked; private final Key key; private boolean allowCircularProxy; private ConstructorInjector constructorInjector; private ProvisionListenerStackCallback provisionCallback; Factory(boolean failIfNotLinked, Key key) { this.failIfNotLinked = failIfNotLinked; this.key = key; } @SuppressWarnings("unchecked") public T get(Errors errors, InternalContext context, Dependency dependency, boolean linked) throws ErrorsException { checkState(constructorInjector != null, "Constructor not ready"); if(failIfNotLinked && !linked) { throw errors.jitDisabled(key).toException(); } // This may not actually be safe because it could return a super type of T (if that's all the // client needs), but it should be OK in practice thanks to the wonders of erasure. return (T) constructorInjector.construct(errors, context, dependency.getKey().getTypeLiteral().getRawType(), allowCircularProxy, provisionCallback); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ConstructionProxyFactory.java0000644000175000017500000000160711704661106031206 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; /** * Creates {@link ConstructionProxy} instances. * * @author crazybob@google.com (Bob Lee) */ interface ConstructionProxyFactory { /** * Gets a construction proxy for the given constructor. */ ConstructionProxy create() throws ErrorsException; } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ConstructionProxy.java0000644000175000017500000000331611704661106027655 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.ImmutableMap; import com.google.inject.spi.InjectionPoint; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; /** * Proxies calls to a {@link java.lang.reflect.Constructor} for a class * {@code T}. * * @author crazybob@google.com (Bob Lee) */ interface ConstructionProxy { /** * Constructs an instance of {@code T} for the given arguments. */ T newInstance(Object... arguments) throws InvocationTargetException; /** * Returns the injection point for this constructor. */ InjectionPoint getInjectionPoint(); /** * Returns the injected constructor. If the injected constructor is synthetic (such as generated * code for method interception), the natural constructor is returned. */ Constructor getConstructor(); /*if[AOP]*/ /** * Returns the interceptors applied to each method, in order of invocation. */ ImmutableMap> getMethodInterceptors(); /*end[AOP]*/ } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ConstructionContext.java0000644000175000017500000000506211704661106030160 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import java.lang.reflect.Proxy; import java.util.ArrayList; import java.util.List; /** * Context of a dependency construction. Used to manage circular references. * * @author crazybob@google.com (Bob Lee) */ final class ConstructionContext { T currentReference; boolean constructing; List> invocationHandlers; public T getCurrentReference() { return currentReference; } public void removeCurrentReference() { this.currentReference = null; } public void setCurrentReference(T currentReference) { this.currentReference = currentReference; } public boolean isConstructing() { return constructing; } public void startConstruction() { this.constructing = true; } public void finishConstruction() { this.constructing = false; invocationHandlers = null; } public Object createProxy(Errors errors, Class expectedType) throws ErrorsException { // TODO: if I create a proxy which implements all the interfaces of // the implementation type, I'll be able to get away with one proxy // instance (as opposed to one per caller). if (!expectedType.isInterface()) { throw errors.cannotSatisfyCircularDependency(expectedType).toException(); } if (invocationHandlers == null) { invocationHandlers = new ArrayList>(); } DelegatingInvocationHandler invocationHandler = new DelegatingInvocationHandler(); invocationHandlers.add(invocationHandler); ClassLoader classLoader = BytecodeGen.getClassLoader(expectedType); return expectedType.cast(Proxy.newProxyInstance(classLoader, new Class[] { expectedType, CircularDependencyProxy.class }, invocationHandler)); } public void setProxyDelegates(T delegate) { if (invocationHandlers != null) { for (DelegatingInvocationHandler handler : invocationHandlers) { handler.setDelegate(delegate); } } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ConstantFactory.java0000644000175000017500000000242311704661106027240 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Objects; import com.google.inject.spi.Dependency; /** * @author crazybob@google.com (Bob Lee) */ final class ConstantFactory implements InternalFactory { private final Initializable initializable; public ConstantFactory(Initializable initializable) { this.initializable = initializable; } public T get(Errors errors, InternalContext context, Dependency dependency, boolean linked) throws ErrorsException { return initializable.get(errors); } public String toString() { return Objects.toStringHelper(ConstantFactory.class) .add("value", initializable) .toString(); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/ConstantBindingBuilderImpl.java0000644000175000017500000000720711704661106031341 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.ImmutableSet; import com.google.inject.Binder; import com.google.inject.Key; import com.google.inject.binder.AnnotatedConstantBindingBuilder; import com.google.inject.binder.ConstantBindingBuilder; import com.google.inject.spi.Element; import com.google.inject.spi.InjectionPoint; import java.lang.annotation.Annotation; import java.util.List; /** * Bind a constant. * * @author jessewilson@google.com (Jesse Wilson) */ public final class ConstantBindingBuilderImpl extends AbstractBindingBuilder implements AnnotatedConstantBindingBuilder, ConstantBindingBuilder { @SuppressWarnings("unchecked") // constant bindings start out with T unknown public ConstantBindingBuilderImpl(Binder binder, List elements, Object source) { super(binder, elements, source, (Key) NULL_KEY); } public ConstantBindingBuilder annotatedWith(Class annotationType) { annotatedWithInternal(annotationType); return this; } public ConstantBindingBuilder annotatedWith(Annotation annotation) { annotatedWithInternal(annotation); return this; } public void to(final String value) { toConstant(String.class, value); } public void to(final int value) { toConstant(Integer.class, value); } public void to(final long value) { toConstant(Long.class, value); } public void to(final boolean value) { toConstant(Boolean.class, value); } public void to(final double value) { toConstant(Double.class, value); } public void to(final float value) { toConstant(Float.class, value); } public void to(final short value) { toConstant(Short.class, value); } public void to(final char value) { toConstant(Character.class, value); } public void to(final byte value) { toConstant(Byte.class, value); } public void to(final Class value) { toConstant(Class.class, value); } public > void to(final E value) { toConstant(value.getDeclaringClass(), value); } private void toConstant(Class type, Object instance) { // this type will define T, so these assignments are safe @SuppressWarnings("unchecked") Class typeAsClassT = (Class) type; @SuppressWarnings("unchecked") T instanceAsT = (T) instance; if (keyTypeIsSet()) { binder.addError(CONSTANT_VALUE_ALREADY_SET); return; } BindingImpl base = getBinding(); Key key; if (base.getKey().getAnnotation() != null) { key = Key.get(typeAsClassT, base.getKey().getAnnotation()); } else if (base.getKey().getAnnotationType() != null) { key = Key.get(typeAsClassT, base.getKey().getAnnotationType()); } else { key = Key.get(typeAsClassT); } if (instanceAsT == null) { binder.addError(BINDING_TO_NULL); } setBinding(new InstanceBindingImpl( base.getSource(), key, base.getScoping(), ImmutableSet.of(), instanceAsT)); } @Override public String toString() { return "ConstantBindingBuilder"; } }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/CircularDependencyProxy.java0000644000175000017500000000136611704661106030731 0ustar tonytony/** * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; /** * @author jessewilson@google.com (Jesse Wilson) */ public interface CircularDependencyProxy { // marker interface } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/BytecodeGen.java0000644000175000017500000003067511704661106026321 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; import com.google.common.collect.MapMaker; import java.lang.reflect.Constructor; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Map; import java.util.logging.Logger; /** * Utility methods for runtime code generation and class loading. We use this stuff for {@link * net.sf.cglib.reflect.FastClass faster reflection}, {@link net.sf.cglib.proxy.Enhancer method * interceptors} and to proxy circular dependencies. * *

    When loading classes, we need to be careful of: *

      *
    • Memory leaks. Generated classes need to be garbage collected in long-lived * applications. Once an injector and any instances it created can be garbage collected, the * corresponding generated classes should be collectable. *
    • Visibility. Containers like OSGi use class loader boundaries * to enforce modularity at runtime. *
    * *

    For each generated class, there's multiple class loaders involved: *

      *
    • The related class's class loader. Every generated class services exactly * one user-supplied class. This class loader must be used to access members with private and * package visibility. *
    • Guice's class loader. *
    • Our bridge class loader. This is a child of the user's class loader. It * selectively delegates to either the user's class loader (for user classes) or the Guice * class loader (for internal classes that are used by the generated classes). This class * loader that owns the classes generated by Guice. *
    * * @author mcculls@gmail.com (Stuart McCulloch) * @author jessewilson@google.com (Jesse Wilson) */ public final class BytecodeGen { static final Logger logger = Logger.getLogger(BytecodeGen.class.getName()); static final ClassLoader GUICE_CLASS_LOADER = canonicalize(BytecodeGen.class.getClassLoader()); // initialization-on-demand... private static class SystemBridgeHolder { static final BridgeClassLoader SYSTEM_BRIDGE = new BridgeClassLoader(); } /** ie. "com.google.inject.internal" */ static final String GUICE_INTERNAL_PACKAGE = BytecodeGen.class.getName().replaceFirst("\\.internal\\..*$", ".internal"); /*if[AOP]*/ /** either "net.sf.cglib", or "com.google.inject.internal.cglib" */ static final String CGLIB_PACKAGE = net.sf.cglib.proxy.Enhancer.class.getName().replaceFirst("\\.cglib\\..*$", ".cglib"); static final net.sf.cglib.core.NamingPolicy FASTCLASS_NAMING_POLICY = new net.sf.cglib.core.DefaultNamingPolicy() { @Override protected String getTag() { return "ByGuice"; } @Override public String getClassName(String prefix, String source, Object key, net.sf.cglib.core.Predicate names) { // we explicitly set the source here to "FastClass" so that our jarjar renaming // to $FastClass doesn't leak into the class names. if we did not do this, // classes would end up looking like $$$FastClassByGuice$$, with the extra $ // at the front. return super.getClassName(prefix, "FastClass", key, names); } }; static final net.sf.cglib.core.NamingPolicy ENHANCER_NAMING_POLICY = new net.sf.cglib.core.DefaultNamingPolicy() { @Override protected String getTag() { return "ByGuice"; } @Override public String getClassName(String prefix, String source, Object key, net.sf.cglib.core.Predicate names) { // we explicitly set the source here to "Enhancer" so that our jarjar renaming // to $Enhancer doesn't leak into the class names. if we did not do this, // classes would end up looking like $$$EnhancerByGuice$$, with the extra $ // at the front. return super.getClassName(prefix, "Enhancer", key, names); } }; /*end[AOP]*/ /*if[NO_AOP] private static final String CGLIB_PACKAGE = " "; // any string that's illegal in a package name end[NO_AOP]*/ /** Use "-Dguice.custom.loader=false" to disable custom classloading. */ private static final boolean CUSTOM_LOADER_ENABLED; /** * Weak cache of bridge class loaders that make the Guice implementation * classes visible to various code-generated proxies of client classes. */ private static final Map CLASS_LOADER_CACHE; static { boolean customLoaderEnabled; try { customLoaderEnabled = Boolean.parseBoolean(System.getProperty("guice.custom.loader", "true")); } catch (Throwable e) { customLoaderEnabled = false; // unlikely we'll also have permissions for custom loading } CUSTOM_LOADER_ENABLED = customLoaderEnabled; if (CUSTOM_LOADER_ENABLED) { CLASS_LOADER_CACHE = new MapMaker().weakKeys().weakValues().makeComputingMap( new Function() { public ClassLoader apply(final ClassLoader typeClassLoader) { logger.fine("Creating a bridge ClassLoader for " + typeClassLoader); return AccessController.doPrivileged(new PrivilegedAction() { public ClassLoader run() { return new BridgeClassLoader(typeClassLoader); } }); } }); } else { CLASS_LOADER_CACHE = ImmutableMap.of(); } } /** * Attempts to canonicalize null references to the system class loader. * May return null if for some reason the system loader is unavailable. */ private static ClassLoader canonicalize(ClassLoader classLoader) { return classLoader != null ? classLoader : SystemBridgeHolder.SYSTEM_BRIDGE.getParent(); } /** * Returns the class loader to host generated classes for {@code type}. */ public static ClassLoader getClassLoader(Class type) { return getClassLoader(type, type.getClassLoader()); } private static ClassLoader getClassLoader(Class type, ClassLoader delegate) { // simple case: do nothing! if (!CUSTOM_LOADER_ENABLED) { return delegate; } // java.* types can be seen everywhere if (type.getName().startsWith("java.")) { return GUICE_CLASS_LOADER; } delegate = canonicalize(delegate); // no need for a bridge if using same class loader, or it's already a bridge if (delegate == GUICE_CLASS_LOADER || delegate instanceof BridgeClassLoader) { return delegate; } // don't try bridging private types as it won't work if (Visibility.forType(type) == Visibility.PUBLIC) { if (delegate != SystemBridgeHolder.SYSTEM_BRIDGE.getParent()) { // delegate guaranteed to be non-null here return CLASS_LOADER_CACHE.get(delegate); } // delegate may or may not be null here return SystemBridgeHolder.SYSTEM_BRIDGE; } return delegate; // last-resort: do nothing! } /*if[AOP]*/ // use fully-qualified names so imports don't need preprocessor statements public static net.sf.cglib.reflect.FastClass newFastClass(Class type, Visibility visibility) { net.sf.cglib.reflect.FastClass.Generator generator = new net.sf.cglib.reflect.FastClass.Generator(); generator.setType(type); if (visibility == Visibility.PUBLIC) { generator.setClassLoader(getClassLoader(type)); } generator.setNamingPolicy(FASTCLASS_NAMING_POLICY); logger.fine("Loading " + type + " FastClass with " + generator.getClassLoader()); return generator.create(); } public static net.sf.cglib.proxy.Enhancer newEnhancer(Class type, Visibility visibility) { net.sf.cglib.proxy.Enhancer enhancer = new net.sf.cglib.proxy.Enhancer(); enhancer.setSuperclass(type); enhancer.setUseFactory(false); if (visibility == Visibility.PUBLIC) { enhancer.setClassLoader(getClassLoader(type)); } enhancer.setNamingPolicy(ENHANCER_NAMING_POLICY); logger.fine("Loading " + type + " Enhancer with " + enhancer.getClassLoader()); return enhancer; } /*end[AOP]*/ /** * The required visibility of a user's class from a Guice-generated class. Visibility of * package-private members depends on the loading classloader: only if two classes were loaded by * the same classloader can they see each other's package-private members. We need to be careful * when choosing which classloader to use for generated classes. We prefer our bridge classloader, * since it's OSGi-safe and doesn't leak permgen space. But often we cannot due to visibility. */ public enum Visibility { /** * Indicates that Guice-generated classes only need to call and override public members of the * target class. These generated classes may be loaded by our bridge classloader. */ PUBLIC { @Override public Visibility and(Visibility that) { return that; } }, /** * Indicates that Guice-generated classes need to call or override package-private members. * These generated classes must be loaded in the same classloader as the target class. They * won't work with OSGi, and won't get garbage collected until the target class' classloader is * garbage collected. */ SAME_PACKAGE { @Override public Visibility and(Visibility that) { return this; } }; public static Visibility forMember(Member member) { if ((member.getModifiers() & (Modifier.PROTECTED | Modifier.PUBLIC)) == 0) { return SAME_PACKAGE; } Class[] parameterTypes; if (member instanceof Constructor) { parameterTypes = ((Constructor) member).getParameterTypes(); } else { Method method = (Method) member; if (forType(method.getReturnType()) == SAME_PACKAGE) { return SAME_PACKAGE; } parameterTypes = method.getParameterTypes(); } for (Class type : parameterTypes) { if (forType(type) == SAME_PACKAGE) { return SAME_PACKAGE; } } return PUBLIC; } public static Visibility forType(Class type) { return (type.getModifiers() & (Modifier.PROTECTED | Modifier.PUBLIC)) != 0 ? PUBLIC : SAME_PACKAGE; } public abstract Visibility and(Visibility that); } /** * Loader for Guice-generated classes. For referenced classes, this delegates to either either the * user's classloader (which is the parent of this classloader) or Guice's class loader. */ private static class BridgeClassLoader extends ClassLoader { BridgeClassLoader() { // use system loader as parent } BridgeClassLoader(ClassLoader usersClassLoader) { super(usersClassLoader); } @Override protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { if (name.startsWith("sun.reflect")) { // these reflection classes must be loaded from bootstrap class loader return SystemBridgeHolder.SYSTEM_BRIDGE.classicLoadClass(name, resolve); } if (name.startsWith(GUICE_INTERNAL_PACKAGE) || name.startsWith(CGLIB_PACKAGE)) { if (null == GUICE_CLASS_LOADER) { // use special system bridge to load classes from bootstrap class loader return SystemBridgeHolder.SYSTEM_BRIDGE.classicLoadClass(name, resolve); } try { Class clazz = GUICE_CLASS_LOADER.loadClass(name); if (resolve) { resolveClass(clazz); } return clazz; } catch (Throwable e) { // fall-back to classic delegation } } return classicLoadClass(name, resolve); } // make the classic delegating loadClass method visible Class classicLoadClass(String name, boolean resolve) throws ClassNotFoundException { return super.loadClass(name, resolve); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/BoundProviderFactory.java0000644000175000017500000000525111704661106030233 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.Key; import com.google.inject.internal.InjectorImpl.JitLimitation; import com.google.inject.spi.Dependency; import javax.inject.Provider; /** * Delegates to a custom factory which is also bound in the injector. */ final class BoundProviderFactory extends ProviderInternalFactory implements CreationListener { private final InjectorImpl injector; final Key> providerKey; private InternalFactory> providerFactory; BoundProviderFactory( InjectorImpl injector, Key> providerKey, Object source, boolean allowProxy, ProvisionListenerStackCallback provisionCallback) { super(source, allowProxy, provisionCallback); this.injector = injector; this.providerKey = providerKey; } public void notify(Errors errors) { try { providerFactory = injector.getInternalFactory(providerKey, errors.withSource(source), JitLimitation.NEW_OR_EXISTING_JIT); } catch (ErrorsException e) { errors.merge(e.getErrors()); } } public T get(Errors errors, InternalContext context, Dependency dependency, boolean linked) throws ErrorsException { context.pushState(providerKey, source); try { errors = errors.withSource(providerKey); javax.inject.Provider provider = providerFactory.get(errors, context, dependency, true); return circularGet(provider, errors, context, dependency, linked); } finally { context.popState(); } } @Override protected T provision(Provider provider, Errors errors, Dependency dependency, ConstructionContext constructionContext) throws ErrorsException { try { return super.provision(provider, errors, dependency, constructionContext); } catch(RuntimeException userException) { throw errors.errorInProvider(userException).toException(); } } @Override public String toString() { return providerKey.toString(); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/BindingProcessor.java0000644000175000017500000001644011704661106027375 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.Binder; import com.google.inject.Binding; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.spi.ConstructorBinding; import com.google.inject.spi.ConvertedConstantBinding; import com.google.inject.spi.ExposedBinding; import com.google.inject.spi.InjectionPoint; import com.google.inject.spi.InstanceBinding; import com.google.inject.spi.LinkedKeyBinding; import com.google.inject.spi.PrivateElements; import com.google.inject.spi.ProviderBinding; import com.google.inject.spi.ProviderInstanceBinding; import com.google.inject.spi.ProviderKeyBinding; import com.google.inject.spi.UntargettedBinding; import java.util.Set; /** * Handles {@link Binder#bind} and {@link Binder#bindConstant} elements. * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) */ final class BindingProcessor extends AbstractBindingProcessor { private final Initializer initializer; BindingProcessor(Errors errors, Initializer initializer, ProcessedBindingData bindingData) { super(errors, bindingData); this.initializer = initializer; } @Override public Boolean visit(Binding command) { Class rawType = command.getKey().getTypeLiteral().getRawType(); if (Void.class.equals(rawType)) { if (command instanceof ProviderInstanceBinding && ((ProviderInstanceBinding) command).getProviderInstance() instanceof ProviderMethod) { errors.voidProviderMethod(); } else { errors.missingConstantValues(); } return true; } if (rawType == Provider.class) { errors.bindingToProvider(); return true; } return command.acceptTargetVisitor(new Processor((BindingImpl)command) { public Boolean visit(ConstructorBinding binding) { prepareBinding(); try { ConstructorBindingImpl onInjector = ConstructorBindingImpl.create(injector, key, binding.getConstructor(), source, scoping, errors, false); scheduleInitialization(onInjector); putBinding(onInjector); } catch (ErrorsException e) { errors.merge(e.getErrors()); putBinding(invalidBinding(injector, key, source)); } return true; } public Boolean visit(InstanceBinding binding) { prepareBinding(); Set injectionPoints = binding.getInjectionPoints(); T instance = binding.getInstance(); Initializable ref = initializer.requestInjection( injector, instance, key, source, injectionPoints); ConstantFactory factory = new ConstantFactory(ref); InternalFactory scopedFactory = Scoping.scope(key, injector, factory, source, scoping); putBinding(new InstanceBindingImpl(injector, key, source, scopedFactory, injectionPoints, instance)); return true; } public Boolean visit(ProviderInstanceBinding binding) { prepareBinding(); Provider provider = binding.getProviderInstance(); Set injectionPoints = binding.getInjectionPoints(); Initializable> initializable = initializer .>requestInjection(injector, provider, null, source, injectionPoints); InternalFactory factory = new InternalFactoryToInitializableAdapter( initializable, source, !injector.options.disableCircularProxies, injector.provisionListenerStore.get(key)); InternalFactory scopedFactory = Scoping.scope(key, injector, factory, source, scoping); putBinding(new ProviderInstanceBindingImpl(injector, key, source, scopedFactory, scoping, provider, injectionPoints)); return true; } public Boolean visit(ProviderKeyBinding binding) { prepareBinding(); Key> providerKey = binding.getProviderKey(); BoundProviderFactory boundProviderFactory = new BoundProviderFactory( injector, providerKey, source, !injector.options.disableCircularProxies, injector.provisionListenerStore.get(key)); bindingData.addCreationListener(boundProviderFactory); InternalFactory scopedFactory = Scoping.scope( key, injector, (InternalFactory) boundProviderFactory, source, scoping); putBinding(new LinkedProviderBindingImpl( injector, key, source, scopedFactory, scoping, providerKey)); return true; } public Boolean visit(LinkedKeyBinding binding) { prepareBinding(); Key linkedKey = binding.getLinkedKey(); if (key.equals(linkedKey)) { errors.recursiveBinding(); } FactoryProxy factory = new FactoryProxy(injector, key, linkedKey, source); bindingData.addCreationListener(factory); InternalFactory scopedFactory = Scoping.scope(key, injector, factory, source, scoping); putBinding( new LinkedBindingImpl(injector, key, source, scopedFactory, scoping, linkedKey)); return true; } public Boolean visit(UntargettedBinding untargetted) { return false; } public Boolean visit(ExposedBinding binding) { throw new IllegalArgumentException("Cannot apply a non-module element"); } public Boolean visit(ConvertedConstantBinding binding) { throw new IllegalArgumentException("Cannot apply a non-module element"); } public Boolean visit(ProviderBinding binding) { throw new IllegalArgumentException("Cannot apply a non-module element"); } @Override protected Boolean visitOther(Binding binding) { throw new IllegalStateException("BindingProcessor should override all visitations"); } }); } @Override public Boolean visit(PrivateElements privateElements) { for (Key key : privateElements.getExposedKeys()) { bindExposed(privateElements, key); } return false; // leave the private elements for the PrivateElementsProcessor to handle } private void bindExposed(PrivateElements privateElements, Key key) { ExposedKeyFactory exposedKeyFactory = new ExposedKeyFactory(key, privateElements); bindingData.addCreationListener(exposedKeyFactory); putBinding(new ExposedBindingImpl( injector, privateElements.getExposedSource(key), key, exposedKeyFactory, privateElements)); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/BindingImpl.java0000644000175000017500000000613511704661106026317 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Objects; import com.google.inject.Binding; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.spi.BindingScopingVisitor; import com.google.inject.spi.ElementVisitor; import com.google.inject.spi.InstanceBinding; /** * @author crazybob@google.com (Bob Lee) */ public abstract class BindingImpl implements Binding { private final InjectorImpl injector; private final Key key; private final Object source; private final Scoping scoping; private final InternalFactory internalFactory; public BindingImpl(InjectorImpl injector, Key key, Object source, InternalFactory internalFactory, Scoping scoping) { this.injector = injector; this.key = key; this.source = source; this.internalFactory = internalFactory; this.scoping = scoping; } protected BindingImpl(Object source, Key key, Scoping scoping) { this.internalFactory = null; this.injector = null; this.source = source; this.key = key; this.scoping = scoping; } public Key getKey() { return key; } public Object getSource() { return source; } private volatile Provider provider; public Provider getProvider() { if (provider == null) { if (injector == null) { throw new UnsupportedOperationException("getProvider() not supported for module bindings"); } provider = injector.getProvider(key); } return provider; } public InternalFactory getInternalFactory() { return internalFactory; } public Scoping getScoping() { return scoping; } /** * Is this a constant binding? This returns true for constant bindings as * well as toInstance() bindings. */ public boolean isConstant() { return this instanceof InstanceBinding; } public V acceptVisitor(ElementVisitor visitor) { return visitor.visit(this); } public V acceptScopingVisitor(BindingScopingVisitor visitor) { return scoping.acceptVisitor(visitor); } protected BindingImpl withScoping(Scoping scoping) { throw new AssertionError(); } protected BindingImpl withKey(Key key) { throw new AssertionError(); } @Override public String toString() { return Objects.toStringHelper(Binding.class) .add("key", key) .add("scope", scoping) .add("source", source) .toString(); } public InjectorImpl getInjector() { return injector; } }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/BindingBuilder.java0000644000175000017500000001351611704661106027005 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.ImmutableSet; import com.google.inject.Binder; import com.google.inject.ConfigurationException; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.TypeLiteral; import com.google.inject.binder.AnnotatedBindingBuilder; import com.google.inject.binder.ScopedBindingBuilder; import com.google.inject.spi.Element; import com.google.inject.spi.InjectionPoint; import com.google.inject.spi.Message; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.util.List; import java.util.Set; /** * Bind a non-constant key. * * @author jessewilson@google.com (Jesse Wilson) */ public class BindingBuilder extends AbstractBindingBuilder implements AnnotatedBindingBuilder { public BindingBuilder(Binder binder, List elements, Object source, Key key) { super(binder, elements, source, key); } public BindingBuilder annotatedWith(Class annotationType) { annotatedWithInternal(annotationType); return this; } public BindingBuilder annotatedWith(Annotation annotation) { annotatedWithInternal(annotation); return this; } public BindingBuilder to(Class implementation) { return to(Key.get(implementation)); } public BindingBuilder to(TypeLiteral implementation) { return to(Key.get(implementation)); } public BindingBuilder to(Key linkedKey) { checkNotNull(linkedKey, "linkedKey"); checkNotTargetted(); BindingImpl base = getBinding(); setBinding(new LinkedBindingImpl( base.getSource(), base.getKey(), base.getScoping(), linkedKey)); return this; } public void toInstance(T instance) { checkNotTargetted(); // lookup the injection points, adding any errors to the binder's errors list Set injectionPoints; if (instance != null) { try { injectionPoints = InjectionPoint.forInstanceMethodsAndFields(instance.getClass()); } catch (ConfigurationException e) { copyErrorsToBinder(e); injectionPoints = e.getPartialValue(); } } else { binder.addError(BINDING_TO_NULL); injectionPoints = ImmutableSet.of(); } BindingImpl base = getBinding(); setBinding(new InstanceBindingImpl( base.getSource(), base.getKey(), Scoping.EAGER_SINGLETON, injectionPoints, instance)); } public BindingBuilder toProvider(Provider provider) { checkNotNull(provider, "provider"); checkNotTargetted(); // lookup the injection points, adding any errors to the binder's errors list Set injectionPoints; try { injectionPoints = InjectionPoint.forInstanceMethodsAndFields(provider.getClass()); } catch (ConfigurationException e) { copyErrorsToBinder(e); injectionPoints = e.getPartialValue(); } BindingImpl base = getBinding(); setBinding(new ProviderInstanceBindingImpl( base.getSource(), base.getKey(), base.getScoping(), injectionPoints, provider)); return this; } public BindingBuilder toProvider( Class> providerType) { return toProvider(Key.get(providerType)); } public BindingBuilder toProvider( TypeLiteral> providerType) { return toProvider(Key.get(providerType)); } public BindingBuilder toProvider( Key> providerKey) { checkNotNull(providerKey, "providerKey"); checkNotTargetted(); BindingImpl base = getBinding(); setBinding(new LinkedProviderBindingImpl( base.getSource(), base.getKey(), base.getScoping(), providerKey)); return this; } public ScopedBindingBuilder toConstructor(Constructor constructor) { return toConstructor(constructor, TypeLiteral.get(constructor.getDeclaringClass())); } public ScopedBindingBuilder toConstructor(Constructor constructor, TypeLiteral type) { checkNotNull(constructor, "constructor"); checkNotNull(type, "type"); checkNotTargetted(); BindingImpl base = getBinding(); Set injectionPoints; try { injectionPoints = InjectionPoint.forInstanceMethodsAndFields(type); } catch (ConfigurationException e) { copyErrorsToBinder(e); injectionPoints = e.getPartialValue(); } try { @SuppressWarnings("unchecked") // safe; constructor is a subtype of toConstruct InjectionPoint constructorPoint = InjectionPoint.forConstructor(constructor, type); setBinding(new ConstructorBindingImpl(base.getKey(), base.getSource(), base.getScoping(), constructorPoint, injectionPoints)); } catch (ConfigurationException e) { copyErrorsToBinder(e); } return this; } @Override public String toString() { return "BindingBuilder<" + getBinding().getKey().getTypeLiteral() + ">"; } private void copyErrorsToBinder(ConfigurationException e) { for (Message message : e.getErrorMessages()) { binder.addError(message); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/Annotations.java0000644000175000017500000001612211704661106026415 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.base.Function; import com.google.common.collect.MapMaker; import com.google.inject.BindingAnnotation; import com.google.inject.Key; import com.google.inject.ScopeAnnotation; import com.google.inject.TypeLiteral; import com.google.inject.internal.util.Classes; import com.google.inject.name.Named; import com.google.inject.name.Names; import java.lang.annotation.Annotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.reflect.Member; import java.util.Arrays; import java.util.Collection; import java.util.Map; import javax.inject.Qualifier; /** * Annotation utilities. * * @author crazybob@google.com (Bob Lee) */ public class Annotations { /** * Returns {@code true} if the given annotation type has no attributes. */ public static boolean isMarker(Class annotationType) { return annotationType.getDeclaredMethods().length == 0; } /** * Returns true if the given annotation is retained at runtime. */ public static boolean isRetainedAtRuntime(Class annotationType) { Retention retention = annotationType.getAnnotation(Retention.class); return retention != null && retention.value() == RetentionPolicy.RUNTIME; } /** Returns the scope annotation on {@code type}, or null if none is specified. */ public static Class findScopeAnnotation( Errors errors, Class implementation) { return findScopeAnnotation(errors, implementation.getAnnotations()); } /** Returns the scoping annotation, or null if there isn't one. */ public static Class findScopeAnnotation(Errors errors, Annotation[] annotations) { Class found = null; for (Annotation annotation : annotations) { Class annotationType = annotation.annotationType(); if (isScopeAnnotation(annotationType)) { if (found != null) { errors.duplicateScopeAnnotations(found, annotationType); } else { found = annotationType; } } } return found; } /** * Checks for the presence of annotations. Caches results because Android doesn't. */ static class AnnotationChecker { private final Collection> annotationTypes; /** Returns true if the given class has one of the desired annotations. */ private Function, Boolean> hasAnnotations = new Function, Boolean>() { public Boolean apply(Class annotationType) { for (Annotation annotation : annotationType.getAnnotations()) { if (annotationTypes.contains(annotation.annotationType())) { return true; } } return false; } }; final Map, Boolean> cache = new MapMaker().weakKeys() .makeComputingMap(hasAnnotations); /** * Constructs a new checker that looks for annotations of the given types. */ AnnotationChecker(Collection> annotationTypes) { this.annotationTypes = annotationTypes; } /** * Returns true if the given type has one of the desired annotations. */ boolean hasAnnotations(Class annotated) { return cache.get(annotated); } } private static final AnnotationChecker scopeChecker = new AnnotationChecker( Arrays.asList(ScopeAnnotation.class, javax.inject.Scope.class)); public static boolean isScopeAnnotation(Class annotationType) { return scopeChecker.hasAnnotations(annotationType); } /** * Adds an error if there is a misplaced annotations on {@code type}. Scoping * annotations are not allowed on abstract classes or interfaces. */ public static void checkForMisplacedScopeAnnotations( Class type, Object source, Errors errors) { if (Classes.isConcrete(type)) { return; } Class scopeAnnotation = findScopeAnnotation(errors, type); if (scopeAnnotation != null) { errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source); } } /** Gets a key for the given type, member and annotations. */ public static Key getKey(TypeLiteral type, Member member, Annotation[] annotations, Errors errors) throws ErrorsException { int numErrorsBefore = errors.size(); Annotation found = findBindingAnnotation(errors, member, annotations); errors.throwIfNewErrors(numErrorsBefore); return found == null ? Key.get(type) : Key.get(type, found); } /** * Returns the binding annotation on {@code member}, or null if there isn't one. */ public static Annotation findBindingAnnotation( Errors errors, Member member, Annotation[] annotations) { Annotation found = null; for (Annotation annotation : annotations) { Class annotationType = annotation.annotationType(); if (isBindingAnnotation(annotationType)) { if (found != null) { errors.duplicateBindingAnnotations(member, found.annotationType(), annotationType); } else { found = annotation; } } } return found; } private static final AnnotationChecker bindingAnnotationChecker = new AnnotationChecker( Arrays.asList(BindingAnnotation.class, Qualifier.class)); /** * Returns true if annotations of the specified type are binding annotations. */ public static boolean isBindingAnnotation(Class annotationType) { return bindingAnnotationChecker.hasAnnotations(annotationType); } /** * If the annotation is an instance of {@code javax.inject.Named}, canonicalizes to * com.google.guice.name.Named. Returns the given annotation otherwise. */ public static Annotation canonicalizeIfNamed(Annotation annotation) { if(annotation instanceof javax.inject.Named) { return Names.named(((javax.inject.Named)annotation).value()); } else { return annotation; } } /** * If the annotation is the class {@code javax.inject.Named}, canonicalizes to * com.google.guice.name.Named. Returns the given annotation class otherwise. */ public static Class canonicalizeIfNamed( Class annotationType) { if (annotationType == javax.inject.Named.class) { return Named.class; } else { return annotationType; } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/AbstractProcessor.java0000644000175000017500000000414511704661106027565 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.inject.spi.DefaultElementVisitor; import com.google.inject.spi.Element; import java.util.Iterator; import java.util.List; /** * Abstract base class for creating an injector from module elements. * *

    Extending classes must return {@code true} from any overridden * {@code visit*()} methods, in order for the element processor to remove the * handled element. * * @author jessewilson@google.com (Jesse Wilson) */ abstract class AbstractProcessor extends DefaultElementVisitor { protected Errors errors; protected InjectorImpl injector; protected AbstractProcessor(Errors errors) { this.errors = errors; } public void process(Iterable isolatedInjectorBuilders) { for (InjectorShell injectorShell : isolatedInjectorBuilders) { process(injectorShell.getInjector(), injectorShell.getElements()); } } public void process(InjectorImpl injector, List elements) { Errors errorsAnyElement = this.errors; this.injector = injector; try { for (Iterator i = elements.iterator(); i.hasNext(); ) { Element element = i.next(); this.errors = errorsAnyElement.withSource(element.getSource()); Boolean allDone = element.acceptVisitor(this); if (allDone) { i.remove(); } } } finally { this.errors = errorsAnyElement; this.injector = null; } } @Override protected Boolean visitOther(Element element) { return false; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/AbstractBindingProcessor.java0000644000175000017500000001477411704661106031071 0ustar tonytony/** * Copyright (C) 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import com.google.common.collect.ImmutableSet; import com.google.inject.AbstractModule; import com.google.inject.Binder; import com.google.inject.Binding; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.MembersInjector; import com.google.inject.Module; import com.google.inject.Provider; import com.google.inject.Scope; import com.google.inject.TypeLiteral; import com.google.inject.spi.DefaultBindingTargetVisitor; import java.util.Set; /** * Guarantees that processing of Binding elements happens in a sane way. * * @author sameb@google.com (Sam Berlin) */ abstract class AbstractBindingProcessor extends AbstractProcessor { //------------------------------------------------------------------------------ private static final boolean DISABLE_MISPLACED_ANNOTATION_CHECK; static { boolean disableCheck; try { disableCheck = Boolean.parseBoolean(System.getProperty( "guice.disable.misplaced.annotation.check", "false")); } catch (Throwable e) { disableCheck = false; } DISABLE_MISPLACED_ANNOTATION_CHECK = disableCheck; } //------------------------------------------------------------------------------ // It's unfortunate that we have to maintain a blacklist of specific // classes, but we can't easily block the whole package because of // all our unit tests. private static final Set> FORBIDDEN_TYPES = ImmutableSet.>of( AbstractModule.class, Binder.class, Binding.class, Injector.class, Key.class, MembersInjector.class, Module.class, Provider.class, Scope.class, TypeLiteral.class); // TODO(jessewilson): fix BuiltInModule, then add Stage protected final ProcessedBindingData bindingData; AbstractBindingProcessor(Errors errors, ProcessedBindingData bindingData) { super(errors); this.bindingData = bindingData; } protected UntargettedBindingImpl invalidBinding( InjectorImpl injector, Key key, Object source) { return new UntargettedBindingImpl(injector, key, source); } protected void putBinding(BindingImpl binding) { Key key = binding.getKey(); Class rawType = key.getTypeLiteral().getRawType(); if (FORBIDDEN_TYPES.contains(rawType)) { errors.cannotBindToGuiceType(rawType.getSimpleName()); return; } BindingImpl original = injector.getExistingBinding(key); if (original != null) { // If it failed because of an explicit duplicate binding... if (injector.state.getExplicitBinding(key) != null) { try { if(!isOkayDuplicate(original, binding, injector.state)) { errors.bindingAlreadySet(key, original.getSource()); return; } } catch(Throwable t) { errors.errorCheckingDuplicateBinding(key, original.getSource(), t); return; } } else { // Otherwise, it failed because of a duplicate JIT binding // in the parent errors.jitBindingAlreadySet(key); return; } } // prevent the parent from creating a JIT binding for this key injector.state.parent().blacklist(key, binding.getSource()); injector.state.putBinding(key, binding); } /** * We tolerate duplicate bindings if one exposes the other or if the two bindings * are considered duplicates (see {@link Bindings#areDuplicates(BindingImpl, BindingImpl)}. * * @param original the binding in the parent injector (candidate for an exposing binding) * @param binding the binding to check (candidate for the exposed binding) */ private boolean isOkayDuplicate(BindingImpl original, BindingImpl binding, State state) { if (original instanceof ExposedBindingImpl) { ExposedBindingImpl exposed = (ExposedBindingImpl) original; InjectorImpl exposedFrom = (InjectorImpl) exposed.getPrivateElements().getInjector(); return (exposedFrom == binding.getInjector()); } else { original = (BindingImpl)state.getExplicitBindingsThisLevel().get(binding.getKey()); // If no original at this level, the original was on a parent, and we don't // allow deduplication between parents & children. if(original == null) { return false; } else { return original.equals(binding); } } } private void validateKey(Object source, Key key) { //------------------------------------------------------------------------------ if (!DISABLE_MISPLACED_ANNOTATION_CHECK) { //------------------------------------------------------------------------------ Annotations.checkForMisplacedScopeAnnotations( key.getTypeLiteral().getRawType(), source, errors); //------------------------------------------------------------------------------ } //------------------------------------------------------------------------------ } /** * Processor for visiting bindings. Each overriden method that wants to * actually process the binding should call prepareBinding first. */ abstract class Processor extends DefaultBindingTargetVisitor { final Object source; final Key key; final Class rawType; Scoping scoping; Processor(BindingImpl binding) { source = binding.getSource(); key = binding.getKey(); rawType = key.getTypeLiteral().getRawType(); scoping = binding.getScoping(); } protected void prepareBinding() { validateKey(source, key); scoping = Scoping.makeInjectable(scoping, injector, errors); } protected void scheduleInitialization(final BindingImpl binding) { bindingData.addUninitializedBinding(new Runnable() { public void run() { try { binding.getInjector().initializeBinding(binding, errors.withSource(source)); } catch (ErrorsException e) { errors.merge(e.getErrors()); } } }); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/internal/AbstractBindingBuilder.java0000644000175000017500000001067011704661106030467 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.internal; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Binder; import com.google.inject.Key; import com.google.inject.Scope; import com.google.inject.spi.Element; import com.google.inject.spi.InstanceBinding; import java.lang.annotation.Annotation; import java.util.List; /** * Bind a value or constant. * * @author jessewilson@google.com (Jesse Wilson) */ public abstract class AbstractBindingBuilder { public static final String IMPLEMENTATION_ALREADY_SET = "Implementation is set more than once."; public static final String SINGLE_INSTANCE_AND_SCOPE = "Setting the scope is not permitted when binding to a single instance."; public static final String SCOPE_ALREADY_SET = "Scope is set more than once."; public static final String BINDING_TO_NULL = "Binding to null instances is not allowed. " + "Use toProvider(Providers.of(null)) if this is your intended behaviour."; public static final String CONSTANT_VALUE_ALREADY_SET = "Constant value is set more than once."; public static final String ANNOTATION_ALREADY_SPECIFIED = "More than one annotation is specified for this binding."; protected static final Key NULL_KEY = Key.get(Void.class); protected List elements; protected int position; protected final Binder binder; private BindingImpl binding; public AbstractBindingBuilder(Binder binder, List elements, Object source, Key key) { this.binder = binder; this.elements = elements; this.position = elements.size(); this.binding = new UntargettedBindingImpl(source, key, Scoping.UNSCOPED); elements.add(position, this.binding); } protected BindingImpl getBinding() { return binding; } protected BindingImpl setBinding(BindingImpl binding) { this.binding = binding; elements.set(position, binding); return binding; } /** Sets the binding to a copy with the specified annotation on the bound key */ protected BindingImpl annotatedWithInternal(Class annotationType) { checkNotNull(annotationType, "annotationType"); checkNotAnnotated(); return setBinding(binding.withKey( Key.get(this.binding.getKey().getTypeLiteral(), annotationType))); } /** Sets the binding to a copy with the specified annotation on the bound key */ protected BindingImpl annotatedWithInternal(Annotation annotation) { checkNotNull(annotation, "annotation"); checkNotAnnotated(); return setBinding(binding.withKey( Key.get(this.binding.getKey().getTypeLiteral(), annotation))); } public void in(final Class scopeAnnotation) { checkNotNull(scopeAnnotation, "scopeAnnotation"); checkNotScoped(); setBinding(getBinding().withScoping(Scoping.forAnnotation(scopeAnnotation))); } public void in(final Scope scope) { checkNotNull(scope, "scope"); checkNotScoped(); setBinding(getBinding().withScoping(Scoping.forInstance(scope))); } public void asEagerSingleton() { checkNotScoped(); setBinding(getBinding().withScoping(Scoping.EAGER_SINGLETON)); } protected boolean keyTypeIsSet() { return !Void.class.equals(binding.getKey().getTypeLiteral().getType()); } protected void checkNotTargetted() { if (!(binding instanceof UntargettedBindingImpl)) { binder.addError(IMPLEMENTATION_ALREADY_SET); } } protected void checkNotAnnotated() { if (binding.getKey().getAnnotationType() != null) { binder.addError(ANNOTATION_ALREADY_SPECIFIED); } } protected void checkNotScoped() { // Scoping isn't allowed when we have only one instance. if (binding instanceof InstanceBinding) { binder.addError(SINGLE_INSTANCE_AND_SCOPE); return; } if (binding.getScoping().isExplicitlyScoped()) { binder.addError(SCOPE_ALREADY_SET); } } }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/binder/0000755000175000017500000000000011704661106022702 5ustar tonytonysisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/binder/package-info.java0000644000175000017500000000132411704661106026071 0ustar tonytony/* * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Interfaces which make up {@link com.google.inject.Binder}'s * expression language. */ package com.google.inject.binder;sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/binder/ScopedBindingBuilder.java0000644000175000017500000000254111704661106027566 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.binder; import com.google.inject.Scope; import java.lang.annotation.Annotation; /** * See the EDSL examples at {@link com.google.inject.Binder}. * * @author crazybob@google.com (Bob Lee) */ public interface ScopedBindingBuilder { /** * See the EDSL examples at {@link com.google.inject.Binder}. */ void in(Class scopeAnnotation); /** * See the EDSL examples at {@link com.google.inject.Binder}. */ void in(Scope scope); /** * Instructs the {@link com.google.inject.Injector} to eagerly initialize this * singleton-scoped binding upon creation. Useful for application * initialization logic. See the EDSL examples at * {@link com.google.inject.Binder}. */ void asEagerSingleton(); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/binder/LinkedBindingBuilder.java0000644000175000017500000000521111704661106027554 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.binder; import com.google.inject.Key; import com.google.inject.Provider; import com.google.inject.TypeLiteral; import java.lang.reflect.Constructor; /** * See the EDSL examples at {@link com.google.inject.Binder}. * * @author crazybob@google.com (Bob Lee) */ public interface LinkedBindingBuilder extends ScopedBindingBuilder { /** * See the EDSL examples at {@link com.google.inject.Binder}. */ ScopedBindingBuilder to(Class implementation); /** * See the EDSL examples at {@link com.google.inject.Binder}. */ ScopedBindingBuilder to(TypeLiteral implementation); /** * See the EDSL examples at {@link com.google.inject.Binder}. */ ScopedBindingBuilder to(Key targetKey); /** * See the EDSL examples at {@link com.google.inject.Binder}. * * @see com.google.inject.Injector#injectMembers */ void toInstance(T instance); /** * See the EDSL examples at {@link com.google.inject.Binder}. * * @see com.google.inject.Injector#injectMembers */ ScopedBindingBuilder toProvider(Provider provider); /** * See the EDSL examples at {@link com.google.inject.Binder}. */ ScopedBindingBuilder toProvider( Class> providerType); /** * See the EDSL examples at {@link com.google.inject.Binder}. */ ScopedBindingBuilder toProvider( TypeLiteral> providerType); /** * See the EDSL examples at {@link com.google.inject.Binder}. */ ScopedBindingBuilder toProvider( Key> providerKey); /** * See the EDSL examples at {@link com.google.inject.Binder}. * * @since 3.0 */ ScopedBindingBuilder toConstructor(Constructor constructor); /** * See the EDSL examples at {@link com.google.inject.Binder}. * * @since 3.0 */ ScopedBindingBuilder toConstructor( Constructor constructor, TypeLiteral type); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/binder/ConstantBindingBuilder.java0000644000175000017500000000310011704661106030132 0ustar tonytony/* * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.binder; /** * Binds to a constant value. */ public interface ConstantBindingBuilder { /** * Binds constant to the given value. */ void to(String value); /** * Binds constant to the given value. */ void to(int value); /** * Binds constant to the given value. */ void to(long value); /** * Binds constant to the given value. */ void to(boolean value); /** * Binds constant to the given value. */ void to(double value); /** * Binds constant to the given value. */ void to(float value); /** * Binds constant to the given value. */ void to(short value); /** * Binds constant to the given value. */ void to(char value); /** * Binds constant to the given value. * * @since 3.0 */ void to(byte value); /** * Binds constant to the given value. */ void to(Class value); /** * Binds constant to the given value. */ > void to(E value); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/binder/AnnotatedElementBuilder.java0000644000175000017500000000213711704661106030306 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.binder; import java.lang.annotation.Annotation; /** * See the EDSL examples at {@link com.google.inject.Binder}. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public interface AnnotatedElementBuilder { /** * See the EDSL examples at {@link com.google.inject.Binder}. */ void annotatedWith(Class annotationType); /** * See the EDSL examples at {@link com.google.inject.Binder}. */ void annotatedWith(Annotation annotation); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/binder/AnnotatedConstantBindingBuilder.java0000644000175000017500000000217411704661106032002 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.binder; import java.lang.annotation.Annotation; /** * See the EDSL examples at {@link com.google.inject.Binder}. * * @author crazybob@google.com (Bob Lee) */ public interface AnnotatedConstantBindingBuilder { /** * See the EDSL examples at {@link com.google.inject.Binder}. */ ConstantBindingBuilder annotatedWith( Class annotationType); /** * See the EDSL examples at {@link com.google.inject.Binder}. */ ConstantBindingBuilder annotatedWith(Annotation annotation); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/binder/AnnotatedBindingBuilder.java0000644000175000017500000000223111704661106030262 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject.binder; import java.lang.annotation.Annotation; /** * See the EDSL examples at {@link com.google.inject.Binder}. * * @author crazybob@google.com (Bob Lee) */ public interface AnnotatedBindingBuilder extends LinkedBindingBuilder { /** * See the EDSL examples at {@link com.google.inject.Binder}. */ LinkedBindingBuilder annotatedWith( Class annotationType); /** * See the EDSL examples at {@link com.google.inject.Binder}. */ LinkedBindingBuilder annotatedWith(Annotation annotation); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/TypeLiteral.java0000644000175000017500000002702311704661106024544 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.inject.internal.MoreTypes.canonicalize; import com.google.common.collect.ImmutableList; import com.google.inject.internal.MoreTypes; import com.google.inject.util.Types; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.GenericArrayType; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import java.lang.reflect.WildcardType; import java.util.List; /** * Represents a generic type {@code T}. Java doesn't yet provide a way to * represent generic types, so this class does. Forces clients to create a * subclass of this class which enables retrieval the type information even at * runtime. * *

    For example, to create a type literal for {@code List}, you can * create an empty anonymous inner class: * *

    * {@code TypeLiteral> list = new TypeLiteral>() {};} * *

    Along with modeling generic types, this class can resolve type parameters. * For example, to figure out what type {@code keySet()} returns on a {@code * Map}, use this code:

       {@code
     *
     *   TypeLiteral> mapType
     *       = new TypeLiteral>() {};
     *   TypeLiteral keySetType
     *       = mapType.getReturnType(Map.class.getMethod("keySet"));
     *   System.out.println(keySetType); // prints "Set"}
    * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) */ public class TypeLiteral { final Class rawType; final Type type; final int hashCode; /** * Constructs a new type literal. Derives represented class from type * parameter. * *

    Clients create an empty anonymous subclass. Doing so embeds the type * parameter in the anonymous class's type hierarchy so we can reconstitute it * at runtime despite erasure. */ @SuppressWarnings("unchecked") protected TypeLiteral() { this.type = getSuperclassTypeParameter(getClass()); this.rawType = (Class) MoreTypes.getRawType(type); this.hashCode = type.hashCode(); } /** * Unsafe. Constructs a type literal manually. */ @SuppressWarnings("unchecked") TypeLiteral(Type type) { this.type = canonicalize(checkNotNull(type, "type")); this.rawType = (Class) MoreTypes.getRawType(this.type); this.hashCode = this.type.hashCode(); } /** * Returns the type from super class's type parameter in {@link MoreTypes#canonicalize(Type) * canonical form}. */ static Type getSuperclassTypeParameter(Class subclass) { Type superclass = subclass.getGenericSuperclass(); if (superclass instanceof Class) { throw new RuntimeException("Missing type parameter."); } ParameterizedType parameterized = (ParameterizedType) superclass; return canonicalize(parameterized.getActualTypeArguments()[0]); } /** * Gets type literal from super class's type parameter. */ static TypeLiteral fromSuperclassTypeParameter(Class subclass) { return new TypeLiteral(getSuperclassTypeParameter(subclass)); } /** * Returns the raw (non-generic) type for this type. * * @since 2.0 */ public final Class getRawType() { return rawType; } /** * Gets underlying {@code Type} instance. */ public final Type getType() { return type; } /** * Gets the type of this type's provider. */ @SuppressWarnings("unchecked") final TypeLiteral> providerType() { // This cast is safe and wouldn't generate a warning if Type had a type // parameter. return (TypeLiteral>) get(Types.providerOf(getType())); } @Override public final int hashCode() { return this.hashCode; } @Override public final boolean equals(Object o) { return o instanceof TypeLiteral && MoreTypes.equals(type, ((TypeLiteral) o).type); } @Override public final String toString() { return MoreTypes.typeToString(type); } /** * Gets type literal for the given {@code Type} instance. */ public static TypeLiteral get(Type type) { return new TypeLiteral(type); } /** * Gets type literal for the given {@code Class} instance. */ public static TypeLiteral get(Class type) { return new TypeLiteral(type); } /** Returns an immutable list of the resolved types. */ private List> resolveAll(Type[] types) { TypeLiteral[] result = new TypeLiteral[types.length]; for (int t = 0; t < types.length; t++) { result[t] = resolve(types[t]); } return ImmutableList.copyOf(result); } /** * Resolves known type parameters in {@code toResolve} and returns the result. */ TypeLiteral resolve(Type toResolve) { return TypeLiteral.get(resolveType(toResolve)); } Type resolveType(Type toResolve) { // this implementation is made a little more complicated in an attempt to avoid object-creation while (true) { if (toResolve instanceof TypeVariable) { TypeVariable original = (TypeVariable) toResolve; toResolve = MoreTypes.resolveTypeVariable(type, rawType, original); if (toResolve == original) { return toResolve; } } else if (toResolve instanceof GenericArrayType) { GenericArrayType original = (GenericArrayType) toResolve; Type componentType = original.getGenericComponentType(); Type newComponentType = resolveType(componentType); return componentType == newComponentType ? original : Types.arrayOf(newComponentType); } else if (toResolve instanceof ParameterizedType) { ParameterizedType original = (ParameterizedType) toResolve; Type ownerType = original.getOwnerType(); Type newOwnerType = resolveType(ownerType); boolean changed = newOwnerType != ownerType; Type[] args = original.getActualTypeArguments(); for (int t = 0, length = args.length; t < length; t++) { Type resolvedTypeArgument = resolveType(args[t]); if (resolvedTypeArgument != args[t]) { if (!changed) { args = args.clone(); changed = true; } args[t] = resolvedTypeArgument; } } return changed ? Types.newParameterizedTypeWithOwner(newOwnerType, original.getRawType(), args) : original; } else if (toResolve instanceof WildcardType) { WildcardType original = (WildcardType) toResolve; Type[] originalLowerBound = original.getLowerBounds(); Type[] originalUpperBound = original.getUpperBounds(); if (originalLowerBound.length == 1) { Type lowerBound = resolveType(originalLowerBound[0]); if (lowerBound != originalLowerBound[0]) { return Types.supertypeOf(lowerBound); } } else if (originalUpperBound.length == 1) { Type upperBound = resolveType(originalUpperBound[0]); if (upperBound != originalUpperBound[0]) { return Types.subtypeOf(upperBound); } } return original; } else { return toResolve; } } } /** * Returns the generic form of {@code supertype}. For example, if this is {@code * ArrayList}, this returns {@code Iterable} given the input {@code * Iterable.class}. * * @param supertype a superclass of, or interface implemented by, this. * @since 2.0 */ public TypeLiteral getSupertype(Class supertype) { checkArgument(supertype.isAssignableFrom(rawType), "%s is not a supertype of %s", supertype, this.type); return resolve(MoreTypes.getGenericSupertype(type, rawType, supertype)); } /** * Returns the resolved generic type of {@code field}. * * @param field a field defined by this or any superclass. * @since 2.0 */ public TypeLiteral getFieldType(Field field) { checkArgument(field.getDeclaringClass().isAssignableFrom(rawType), "%s is not defined by a supertype of %s", field, type); return resolve(field.getGenericType()); } /** * Returns the resolved generic parameter types of {@code methodOrConstructor}. * * @param methodOrConstructor a method or constructor defined by this or any supertype. * @since 2.0 */ public List> getParameterTypes(Member methodOrConstructor) { Type[] genericParameterTypes; if (methodOrConstructor instanceof Method) { Method method = (Method) methodOrConstructor; checkArgument(method.getDeclaringClass().isAssignableFrom(rawType), "%s is not defined by a supertype of %s", method, type); genericParameterTypes = method.getGenericParameterTypes(); } else if (methodOrConstructor instanceof Constructor) { Constructor constructor = (Constructor) methodOrConstructor; checkArgument(constructor.getDeclaringClass().isAssignableFrom(rawType), "%s does not construct a supertype of %s", constructor, type); genericParameterTypes = constructor.getGenericParameterTypes(); } else { throw new IllegalArgumentException("Not a method or a constructor: " + methodOrConstructor); } return resolveAll(genericParameterTypes); } /** * Returns the resolved generic exception types thrown by {@code constructor}. * * @param methodOrConstructor a method or constructor defined by this or any supertype. * @since 2.0 */ public List> getExceptionTypes(Member methodOrConstructor) { Type[] genericExceptionTypes; if (methodOrConstructor instanceof Method) { Method method = (Method) methodOrConstructor; checkArgument(method.getDeclaringClass().isAssignableFrom(rawType), "%s is not defined by a supertype of %s", method, type); genericExceptionTypes = method.getGenericExceptionTypes(); } else if (methodOrConstructor instanceof Constructor) { Constructor constructor = (Constructor) methodOrConstructor; checkArgument(constructor.getDeclaringClass().isAssignableFrom(rawType), "%s does not construct a supertype of %s", constructor, type); genericExceptionTypes = constructor.getGenericExceptionTypes(); } else { throw new IllegalArgumentException("Not a method or a constructor: " + methodOrConstructor); } return resolveAll(genericExceptionTypes); } /** * Returns the resolved generic return type of {@code method}. * * @param method a method defined by this or any supertype. * @since 2.0 */ public TypeLiteral getReturnType(Method method) { checkArgument(method.getDeclaringClass().isAssignableFrom(rawType), "%s is not defined by a supertype of %s", method, type); return resolve(method.getGenericReturnType()); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/Stage.java0000644000175000017500000000245611704661106023354 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; /** * The stage we're running in. * * @author crazybob@google.com (Bob Lee) */ public enum Stage { /** * We're running in a tool (an IDE plugin for example). We need binding meta data but not a * functioning Injector. Do not inject members of instances. Do not load eager singletons. Do as * little as possible so our tools run nice and snappy. Injectors created in this stage cannot * be used to satisfy injections. */ TOOL, /** * We want fast startup times at the expense of runtime performance and some up front error * checking. */ DEVELOPMENT, /** * We want to catch errors as early as possible and take performance hits up front. */ PRODUCTION } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/Singleton.java0000644000175000017500000000214111704661106024242 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * Apply this to implementation classes when you want only one instance * (per {@link Injector}) to be reused for all injections for that binding. * * @author crazybob@google.com (Bob Lee) */ @Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RUNTIME) @ScopeAnnotation public @interface Singleton {} sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/Scopes.java0000644000175000017500000002000711704661106023535 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import com.google.inject.internal.CircularDependencyProxy; import com.google.inject.internal.LinkedBindingImpl; import com.google.inject.spi.BindingScopingVisitor; import com.google.inject.spi.ExposedBinding; import java.lang.annotation.Annotation; /** * Built-in scope implementations. * * @author crazybob@google.com (Bob Lee) */ public class Scopes { private Scopes() {} /** A sentinel value representing null. */ private static final Object NULL = new Object(); /** * One instance per {@link Injector}. Also see {@code @}{@link Singleton}. */ public static final Scope SINGLETON = new Scope() { public Provider scope(final Key key, final Provider creator) { return new Provider() { /* * The lazily initialized singleton instance. Once set, this will either have type T or will * be equal to NULL. */ private volatile Object instance; // DCL on a volatile is safe as of Java 5, which we obviously require. @SuppressWarnings("DoubleCheckedLocking") public T get() { if (instance == null) { /* * This block is re-entrant for circular dependencies. */ synchronized (this) { if (instance == null) { T provided = creator.get(); // don't remember proxies; these exist only to serve circular dependencies if (isCircularProxy(provided)) { return provided; } Object providedOrSentinel = (provided == null) ? NULL : provided; if (instance != null && instance != providedOrSentinel) { throw new ProvisionException( "Provider was reentrant while creating a singleton"); } instance = providedOrSentinel; } } } Object localInstance = instance; // This is safe because instance has type T or is equal to NULL @SuppressWarnings("unchecked") T returnedInstance = (localInstance != NULL) ? (T) localInstance : null; return returnedInstance; } @Override public String toString() { return String.format("%s[%s]", creator, SINGLETON); } }; } @Override public String toString() { return "Scopes.SINGLETON"; } }; /** * No scope; the same as not applying any scope at all. Each time the * Injector obtains an instance of an object with "no scope", it injects this * instance then immediately forgets it. When the next request for the same * binding arrives it will need to obtain the instance over again. * *

    This exists only in case a class has been annotated with a scope * annotation such as {@link Singleton @Singleton}, and you need to override * this to "no scope" in your binding. * * @since 2.0 */ public static final Scope NO_SCOPE = new Scope() { public Provider scope(Key key, Provider unscoped) { return unscoped; } @Override public String toString() { return "Scopes.NO_SCOPE"; } }; private static final BindingScopingVisitor IS_SINGLETON_VISITOR = new BindingScopingVisitor() { public Boolean visitNoScoping() { return false; } public Boolean visitScopeAnnotation(Class scopeAnnotation) { return scopeAnnotation == Singleton.class || scopeAnnotation == javax.inject.Singleton.class; } public Boolean visitScope(Scope scope) { return scope == Scopes.SINGLETON; } public Boolean visitEagerSingleton() { return true; } }; /** * Returns true if {@code binding} is singleton-scoped. If the binding is a {@link * com.google.inject.spi.LinkedKeyBinding linked key binding} and belongs to an injector (ie. it * was retrieved via {@link Injector#getBinding Injector.getBinding()}), then this method will * also true if the target binding is singleton-scoped. * * @since 3.0 */ public static boolean isSingleton(Binding binding) { do { boolean singleton = binding.acceptScopingVisitor(IS_SINGLETON_VISITOR); if (singleton) { return true; } if (binding instanceof LinkedBindingImpl) { LinkedBindingImpl linkedBinding = (LinkedBindingImpl) binding; Injector injector = linkedBinding.getInjector(); if (injector != null) { binding = injector.getBinding(linkedBinding.getLinkedKey()); continue; } } else if(binding instanceof ExposedBinding) { ExposedBinding exposedBinding = (ExposedBinding)binding; Injector injector = exposedBinding.getPrivateElements().getInjector(); if (injector != null) { binding = injector.getBinding(exposedBinding.getKey()); continue; } } return false; } while (true); } /** * Returns true if {@code binding} has the given scope. If the binding is a {@link * com.google.inject.spi.LinkedKeyBinding linked key binding} and belongs to an injector (ie. it * was retrieved via {@link Injector#getBinding Injector.getBinding()}), then this method will * also true if the target binding has the given scope. * * @param binding binding to check * @param scope scope implementation instance * @param scopeAnnotation scope annotation class */ public static boolean isScoped(Binding binding, final Scope scope, final Class scopeAnnotation) { do { boolean matches = binding.acceptScopingVisitor(new BindingScopingVisitor() { public Boolean visitNoScoping() { return false; } public Boolean visitScopeAnnotation(Class visitedAnnotation) { return visitedAnnotation == scopeAnnotation; } public Boolean visitScope(Scope visitedScope) { return visitedScope == scope; } public Boolean visitEagerSingleton() { return false; } }); if (matches) { return true; } if (binding instanceof LinkedBindingImpl) { LinkedBindingImpl linkedBinding = (LinkedBindingImpl) binding; Injector injector = linkedBinding.getInjector(); if (injector != null) { binding = injector.getBinding(linkedBinding.getLinkedKey()); continue; } } else if(binding instanceof ExposedBinding) { ExposedBinding exposedBinding = (ExposedBinding)binding; Injector injector = exposedBinding.getPrivateElements().getInjector(); if (injector != null) { binding = injector.getBinding(exposedBinding.getKey()); continue; } } return false; } while (true); } /** * Returns true if the object is a proxy for a circular dependency, * constructed by Guice because it encountered a circular dependency. Scope * implementations should be careful to not cache circular proxies, * because the proxies are not intended for general purpose use. (They are * designed just to fulfill the immediate injection, not all injections. * Caching them can lead to IllegalArgumentExceptions or ClassCastExceptions.) */ public static boolean isCircularProxy(Object object) { return object instanceof CircularDependencyProxy; } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/ScopeAnnotation.java0000644000175000017500000000250011704661106025403 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static java.lang.annotation.ElementType.ANNOTATION_TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * Annotates annotations which are used for scoping. Only one such annotation * may apply to a single implementation class. You must also annotate scope * annotations with {@code @Retention(RUNTIME)}. For example: * *

     *   {@code @}Retention(RUNTIME)
     *   {@code @}Target(TYPE, METHOD)
     *   {@code @}ScopeAnnotation
     *   public {@code @}interface SessionScoped {}
     * 
    * * @author crazybob@google.com (Bob Lee) */ @Target(ANNOTATION_TYPE) @Retention(RUNTIME) public @interface ScopeAnnotation {} sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/Scope.java0000644000175000017500000000436411704661106023362 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; /** * A scope is a level of visibility that instances provided by Guice may have. * By default, an instance created by the {@link Injector} has no scope, * meaning it has no state from the framework's perspective -- the * {@code Injector} creates it, injects it once into the class that required it, * and then immediately forgets it. Associating a scope with a particular * binding allows the created instance to be "remembered" and possibly used * again for other injections. * *

    An example of a scope is {@link Scopes#SINGLETON}. * * @author crazybob@google.com (Bob Lee) */ public interface Scope { /** * Scopes a provider. The returned provider returns objects from this scope. * If an object does not exist in this scope, the provider can use the given * unscoped provider to retrieve one. * *

    Scope implementations are strongly encouraged to override * {@link Object#toString} in the returned provider and include the backing * provider's {@code toString()} output. * * @param key binding key * @param unscoped locates an instance when one doesn't already exist in this * scope. * @return a new provider which only delegates to the given unscoped provider * when an instance of the requested object doesn't already exist in this * scope */ public Provider scope(Key key, Provider unscoped); /** * A short but useful description of this scope. For comparison, the standard * scopes that ship with guice use the descriptions * {@code "Scopes.SINGLETON"}, {@code "ServletScopes.SESSION"} and * {@code "ServletScopes.REQUEST"}. */ String toString(); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/ProvisionException.java0000644000175000017500000000403311704661106026151 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.common.base.Preconditions.checkArgument; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.inject.internal.Errors; import com.google.inject.spi.Message; import java.util.Collection; /** * Indicates that there was a runtime failure while providing an instance. * * @author kevinb@google.com (Kevin Bourrillion) * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public final class ProvisionException extends RuntimeException { private final ImmutableSet messages; /** Creates a ProvisionException containing {@code messages}. */ public ProvisionException(Iterable messages) { this.messages = ImmutableSet.copyOf(messages); checkArgument(!this.messages.isEmpty()); initCause(Errors.getOnlyCause(this.messages)); } public ProvisionException(String message, Throwable cause) { super(cause); this.messages = ImmutableSet.of(new Message(ImmutableList.of(), message, cause)); } public ProvisionException(String message) { this.messages = ImmutableSet.of(new Message(message)); } /** Returns messages for the errors that caused this exception. */ public Collection getErrorMessages() { return messages; } @Override public String getMessage() { return Errors.format("Guice provision errors", messages); } private static final long serialVersionUID = 0; } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/Provides.java0000644000175000017500000000225611704661106024102 0ustar tonytony/** * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * Annotates methods of a {@link Module} to create a provider method binding. The method's return * type is bound to it's returned value. Guice will pass dependencies to the method as parameters. * * @author crazybob@google.com (Bob Lee) * @since 2.0 */ @Documented @Target(METHOD) @Retention(RUNTIME) public @interface Provides {} sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/Provider.java0000644000175000017500000000453611704661106024104 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; /** * An object capable of providing instances of type {@code T}. Providers are used in numerous ways * by Guice: * *

      *
    • When the default means for obtaining instances (an injectable or parameterless constructor) * is insufficient for a particular binding, the module can specify a custom {@code Provider} * instead, to control exactly how Guice creates or obtains instances for the binding. * *
    • An implementation class may always choose to have a {@code Provider} instance injected, * rather than having a {@code T} injected directly. This may give you access to multiple * instances, instances you wish to safely mutate and discard, instances which are out of scope * (e.g. using a {@code @RequestScoped} object from within a {@code @SessionScoped} object), or * instances that will be initialized lazily. * *
    • A custom {@link Scope} is implemented as a decorator of {@code Provider}, which decides * when to delegate to the backing provider and when to provide the instance some other way. * *
    • The {@link Injector} offers access to the {@code Provider} it uses to fulfill requests * for a given key, via the {@link Injector#getProvider} methods. *
    * * @param the type of object this provides * * @author crazybob@google.com (Bob Lee) */ public interface Provider extends javax.inject.Provider { /** * Provides an instance of {@code T}. Must never return {@code null}. * * @throws OutOfScopeException when an attempt is made to access a scoped object while the scope * in question is not currently active * @throws ProvisionException if an instance cannot be provided. Such exceptions include messages * and throwables to describe why provision failed. */ T get(); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/ProvidedBy.java0000644000175000017500000000205711704661106024355 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * A pointer to the default provider type for a type. * * @author crazybob@google.com (Bob Lee) */ @Retention(RUNTIME) @Target(TYPE) public @interface ProvidedBy { /** * The implementation type. */ Class> value(); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/PrivateModule.java0000644000175000017500000002214011704661106025061 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.common.base.Preconditions.checkState; import com.google.inject.binder.AnnotatedBindingBuilder; import com.google.inject.binder.AnnotatedConstantBindingBuilder; import com.google.inject.binder.AnnotatedElementBuilder; import com.google.inject.binder.LinkedBindingBuilder; import com.google.inject.matcher.Matcher; import com.google.inject.spi.Message; import com.google.inject.spi.TypeConverter; import com.google.inject.spi.TypeListener; import java.lang.annotation.Annotation; import java.lang.reflect.Method; /** * A module whose configuration information is hidden from its environment by default. Only bindings * that are explicitly exposed will be available to other modules and to the users of the injector. * This module may expose the bindings it creates and the bindings of the modules it installs. * *

    A private module can be nested within a regular module or within another private module using * {@link Binder#install install()}. Its bindings live in a new environment that inherits bindings, * type converters, scopes, and interceptors from the surrounding ("parent") environment. When you * nest multiple private modules, the result is a tree of environments where the injector's * environment is the root. * *

    Guice EDSL bindings can be exposed with {@link #expose(Class) expose()}. {@literal @}{@link * com.google.inject.Provides Provides} bindings can be exposed with the {@literal @}{@link * Exposed} annotation: * *

     * public class FooBarBazModule extends PrivateModule {
     *   protected void configure() {
     *     bind(Foo.class).to(RealFoo.class);
     *     expose(Foo.class);
     *
     *     install(new TransactionalBarModule());
     *     expose(Bar.class).annotatedWith(Transactional.class);
     *
     *     bind(SomeImplementationDetail.class);
     *     install(new MoreImplementationDetailsModule());
     *   }
     *
     *   {@literal @}Provides {@literal @}Exposed
     *   public Baz provideBaz() {
     *     return new SuperBaz();
     *   }
     * }
     * 
    * *

    Private modules are implemented using {@link Injector#createChildInjector(Module[]) parent * injectors}. When it can satisfy their dependencies, just-in-time bindings will be created in the * root environment. Such bindings are shared among all environments in the tree. * *

    The scope of a binding is constrained to its environment. A singleton bound in a private * module will be unique to its environment. But a binding for the same type in a different private * module will yield a different instance. * *

    A shared binding that injects the {@code Injector} gets the root injector, which only has * access to bindings in the root environment. An explicit binding that injects the {@code Injector} * gets access to all bindings in the child environment. * *

    To promote a just-in-time binding to an explicit binding, bind it: *

     *   bind(FooImpl.class);
     * 
    * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public abstract class PrivateModule implements Module { /** Like abstract module, the binder of the current private module */ private PrivateBinder binder; public final synchronized void configure(Binder binder) { checkState(this.binder == null, "Re-entry is not allowed."); // Guice treats PrivateModules specially and passes in a PrivateBinder automatically. this.binder = (PrivateBinder) binder.skipSources(PrivateModule.class); try { configure(); } finally { this.binder = null; } } /** * Creates bindings and other configurations private to this module. Use {@link #expose(Class) * expose()} to make the bindings in this module available externally. */ protected abstract void configure(); /** Makes the binding for {@code key} available to other modules and the injector. */ protected final void expose(Key key) { binder().expose(key); } /** * Makes a binding for {@code type} available to other modules and the injector. Use {@link * AnnotatedElementBuilder#annotatedWith(Class) annotatedWith()} to expose {@code type} with a * binding annotation. */ protected final AnnotatedElementBuilder expose(Class type) { return binder().expose(type); } /** * Makes a binding for {@code type} available to other modules and the injector. Use {@link * AnnotatedElementBuilder#annotatedWith(Class) annotatedWith()} to expose {@code type} with a * binding annotation. */ protected final AnnotatedElementBuilder expose(TypeLiteral type) { return binder().expose(type); } // everything below is copied from AbstractModule /** * Returns the current binder. */ protected final PrivateBinder binder() { checkState(binder != null, "The binder can only be used inside configure()"); return binder; } /** * @see Binder#bindScope(Class, Scope) */ protected final void bindScope(Class scopeAnnotation, Scope scope) { binder().bindScope(scopeAnnotation, scope); } /** * @see Binder#bind(Key) */ protected final LinkedBindingBuilder bind(Key key) { return binder().bind(key); } /** * @see Binder#bind(TypeLiteral) */ protected final AnnotatedBindingBuilder bind(TypeLiteral typeLiteral) { return binder().bind(typeLiteral); } /** * @see Binder#bind(Class) */ protected final AnnotatedBindingBuilder bind(Class clazz) { return binder().bind(clazz); } /** * @see Binder#bindConstant() */ protected final AnnotatedConstantBindingBuilder bindConstant() { return binder().bindConstant(); } /** * @see Binder#install(Module) */ protected final void install(Module module) { binder().install(module); } /** * @see Binder#addError(String, Object[]) */ protected final void addError(String message, Object... arguments) { binder().addError(message, arguments); } /** * @see Binder#addError(Throwable) */ protected final void addError(Throwable t) { binder().addError(t); } /** * @see Binder#addError(Message) */ protected final void addError(Message message) { binder().addError(message); } /** * @see Binder#requestInjection(Object) */ protected final void requestInjection(Object instance) { binder().requestInjection(instance); } /** * @see Binder#requestStaticInjection(Class[]) */ protected final void requestStaticInjection(Class... types) { binder().requestStaticInjection(types); } /*if[AOP]*/ /** * @see Binder#bindInterceptor(com.google.inject.matcher.Matcher, com.google.inject.matcher.Matcher, org.aopalliance.intercept.MethodInterceptor[]) */ protected final void bindInterceptor(Matcher> classMatcher, Matcher methodMatcher, org.aopalliance.intercept.MethodInterceptor... interceptors) { binder().bindInterceptor(classMatcher, methodMatcher, interceptors); } /*end[AOP]*/ /** * Instructs Guice to require a binding to the given key. */ protected final void requireBinding(Key key) { binder().getProvider(key); } /** * Instructs Guice to require a binding to the given type. */ protected final void requireBinding(Class type) { binder().getProvider(type); } /** * @see Binder#getProvider(Key) */ protected final Provider getProvider(Key key) { return binder().getProvider(key); } /** * @see Binder#getProvider(Class) */ protected final Provider getProvider(Class type) { return binder().getProvider(type); } /** * @see Binder#convertToTypes(com.google.inject.matcher.Matcher, com.google.inject.spi.TypeConverter) */ protected final void convertToTypes(Matcher> typeMatcher, TypeConverter converter) { binder().convertToTypes(typeMatcher, converter); } /** * @see Binder#currentStage() */ protected final Stage currentStage() { return binder().currentStage(); } /** * @see Binder#getMembersInjector(Class) */ protected MembersInjector getMembersInjector(Class type) { return binder().getMembersInjector(type); } /** * @see Binder#getMembersInjector(TypeLiteral) */ protected MembersInjector getMembersInjector(TypeLiteral type) { return binder().getMembersInjector(type); } /** * @see Binder#bindListener(com.google.inject.matcher.Matcher, com.google.inject.spi.TypeListener) */ protected void bindListener(Matcher> typeMatcher, TypeListener listener) { binder().bindListener(typeMatcher, listener); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/PrivateBinder.java0000644000175000017500000000334211704661106025042 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import com.google.inject.binder.AnnotatedElementBuilder; /** * Returns a binder whose configuration information is hidden from its environment by default. See * {@link com.google.inject.PrivateModule PrivateModule} for details. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public interface PrivateBinder extends Binder { /** Makes the binding for {@code key} available to the enclosing environment */ void expose(Key key); /** * Makes a binding for {@code type} available to the enclosing environment. Use {@link * com.google.inject.binder.AnnotatedElementBuilder#annotatedWith(Class) annotatedWith()} to expose {@code type} with a * binding annotation. */ AnnotatedElementBuilder expose(Class type); /** * Makes a binding for {@code type} available to the enclosing environment. Use {@link * AnnotatedElementBuilder#annotatedWith(Class) annotatedWith()} to expose {@code type} with a * binding annotation. */ AnnotatedElementBuilder expose(TypeLiteral type); PrivateBinder withSource(Object source); PrivateBinder skipSources(Class... classesToSkip); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/OutOfScopeException.java0000644000175000017500000000217411704661106026213 0ustar tonytony/** * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; /** * Thrown from {@link Provider#get} when an attempt is made to access a scoped * object while the scope in question is not currently active. * * @author kevinb@google.com (Kevin Bourrillion) * @since 2.0 */ public final class OutOfScopeException extends RuntimeException { public OutOfScopeException(String message) { super(message); } public OutOfScopeException(String message, Throwable cause) { super(message, cause); } public OutOfScopeException(Throwable cause) { super(cause); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/Module.java0000644000175000017500000000320011704661106023522 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; /** * A module contributes configuration information, typically interface * bindings, which will be used to create an {@link Injector}. A Guice-based * application is ultimately composed of little more than a set of * {@code Module}s and some bootstrapping code. * *

    Your Module classes can use a more streamlined syntax by extending * {@link AbstractModule} rather than implementing this interface directly. * *

    In addition to the bindings configured via {@link #configure}, bindings * will be created for all methods annotated with {@literal @}{@link Provides}. * Use scope and binding annotations on these methods to configure the * bindings. */ public interface Module { /** * Contributes bindings and other configurations for this module to {@code binder}. * *

    Do not invoke this method directly to install submodules. Instead use * {@link Binder#install(Module)}, which ensures that {@link Provides provider methods} are * discovered. */ void configure(Binder binder); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/MembersInjector.java0000644000175000017500000000270711704661106025400 0ustar tonytony/* * Copyright (C) 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; /** * Injects dependencies into the fields and methods on instances of type {@code T}. Ignores the * presence or absence of an injectable constructor. * * @param type to inject members of * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public interface MembersInjector { /** * Injects dependencies into the fields and methods of {@code instance}. Ignores the presence or * absence of an injectable constructor. * *

    Whenever Guice creates an instance, it performs this injection automatically (after first * performing constructor injection), so if you're able to let Guice create all your objects for * you, you'll never need to use this method. * * @param instance to inject members on. May be {@code null}. */ void injectMembers(T instance); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/Key.java0000644000175000017500000003315211704661106023036 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.internal.Annotations; import com.google.inject.internal.MoreTypes; import java.lang.annotation.Annotation; import java.lang.reflect.Type; /** * Binding key consisting of an injection type and an optional annotation. * Matches the type and annotation at a point of injection. * *

    For example, {@code Key.get(Service.class, Transactional.class)} will * match: * *

     *   {@literal @}Inject
     *   public void setService({@literal @}Transactional Service service) {
     *     ...
     *   }
     * 
    * *

    {@code Key} supports generic types via subclassing just like {@link * TypeLiteral}. * *

    Keys do not differentiate between primitive types (int, char, etc.) and * their correpsonding wrapper types (Integer, Character, etc.). Primitive * types will be replaced with their wrapper types when keys are created. * * @author crazybob@google.com (Bob Lee) */ public class Key { private final AnnotationStrategy annotationStrategy; private final TypeLiteral typeLiteral; private final int hashCode; /** * Constructs a new key. Derives the type from this class's type parameter. * *

    Clients create an empty anonymous subclass. Doing so embeds the type * parameter in the anonymous class's type hierarchy so we can reconstitute it * at runtime despite erasure. * *

    Example usage for a binding of type {@code Foo} annotated with * {@code @Bar}: * *

    {@code new Key(Bar.class) {}}. */ @SuppressWarnings("unchecked") protected Key(Class annotationType) { this.annotationStrategy = strategyFor(annotationType); this.typeLiteral = (TypeLiteral) TypeLiteral.fromSuperclassTypeParameter(getClass()); this.hashCode = computeHashCode(); } /** * Constructs a new key. Derives the type from this class's type parameter. * *

    Clients create an empty anonymous subclass. Doing so embeds the type * parameter in the anonymous class's type hierarchy so we can reconstitute it * at runtime despite erasure. * *

    Example usage for a binding of type {@code Foo} annotated with * {@code @Bar}: * *

    {@code new Key(new Bar()) {}}. */ @SuppressWarnings("unchecked") protected Key(Annotation annotation) { // no usages, not test-covered this.annotationStrategy = strategyFor(annotation); this.typeLiteral = (TypeLiteral) TypeLiteral.fromSuperclassTypeParameter(getClass()); this.hashCode = computeHashCode(); } /** * Constructs a new key. Derives the type from this class's type parameter. * *

    Clients create an empty anonymous subclass. Doing so embeds the type * parameter in the anonymous class's type hierarchy so we can reconstitute it * at runtime despite erasure. * *

    Example usage for a binding of type {@code Foo}: * *

    {@code new Key() {}}. */ @SuppressWarnings("unchecked") protected Key() { this.annotationStrategy = NullAnnotationStrategy.INSTANCE; this.typeLiteral = (TypeLiteral) TypeLiteral.fromSuperclassTypeParameter(getClass()); this.hashCode = computeHashCode(); } /** * Unsafe. Constructs a key from a manually specified type. */ @SuppressWarnings("unchecked") private Key(Type type, AnnotationStrategy annotationStrategy) { this.annotationStrategy = annotationStrategy; this.typeLiteral = MoreTypes.canonicalizeForKey((TypeLiteral) TypeLiteral.get(type)); this.hashCode = computeHashCode(); } /** Constructs a key from a manually specified type. */ private Key(TypeLiteral typeLiteral, AnnotationStrategy annotationStrategy) { this.annotationStrategy = annotationStrategy; this.typeLiteral = MoreTypes.canonicalizeForKey(typeLiteral); this.hashCode = computeHashCode(); } private int computeHashCode() { return typeLiteral.hashCode() * 31 + annotationStrategy.hashCode(); } /** * Gets the key type. */ public final TypeLiteral getTypeLiteral() { return typeLiteral; } /** * Gets the annotation type. */ public final Class getAnnotationType() { return annotationStrategy.getAnnotationType(); } /** * Gets the annotation. */ public final Annotation getAnnotation() { return annotationStrategy.getAnnotation(); } boolean hasAnnotationType() { return annotationStrategy.getAnnotationType() != null; } String getAnnotationName() { Annotation annotation = annotationStrategy.getAnnotation(); if (annotation != null) { return annotation.toString(); } // not test-covered return annotationStrategy.getAnnotationType().toString(); } Class getRawType() { return typeLiteral.getRawType(); } /** * Gets the key of this key's provider. */ Key> providerKey() { return ofType(typeLiteral.providerType()); } @Override public final boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof Key)) { return false; } Key other = (Key) o; return annotationStrategy.equals(other.annotationStrategy) && typeLiteral.equals(other.typeLiteral); } @Override public final int hashCode() { return this.hashCode; } @Override public final String toString() { return "Key[type=" + typeLiteral + ", annotation=" + annotationStrategy + "]"; } /** * Gets a key for an injection type and an annotation strategy. */ static Key get(Class type, AnnotationStrategy annotationStrategy) { return new Key(type, annotationStrategy); } /** * Gets a key for an injection type. */ public static Key get(Class type) { return new Key(type, NullAnnotationStrategy.INSTANCE); } /** * Gets a key for an injection type and an annotation type. */ public static Key get(Class type, Class annotationType) { return new Key(type, strategyFor(annotationType)); } /** * Gets a key for an injection type and an annotation. */ public static Key get(Class type, Annotation annotation) { return new Key(type, strategyFor(annotation)); } /** * Gets a key for an injection type. */ public static Key get(Type type) { return new Key(type, NullAnnotationStrategy.INSTANCE); } /** * Gets a key for an injection type and an annotation type. */ public static Key get(Type type, Class annotationType) { return new Key(type, strategyFor(annotationType)); } /** * Gets a key for an injection type and an annotation. */ public static Key get(Type type, Annotation annotation) { return new Key(type, strategyFor(annotation)); } /** * Gets a key for an injection type. */ public static Key get(TypeLiteral typeLiteral) { return new Key(typeLiteral, NullAnnotationStrategy.INSTANCE); } /** * Gets a key for an injection type and an annotation type. */ public static Key get(TypeLiteral typeLiteral, Class annotationType) { return new Key(typeLiteral, strategyFor(annotationType)); } /** * Gets a key for an injection type and an annotation. */ public static Key get(TypeLiteral typeLiteral, Annotation annotation) { return new Key(typeLiteral, strategyFor(annotation)); } /** * Returns a new key of the specified type with the same annotation as this * key. * * @since 3.0 */ public Key ofType(Class type) { return new Key(type, annotationStrategy); } /** * Returns a new key of the specified type with the same annotation as this * key. * * @since 3.0 */ public Key ofType(Type type) { return new Key(type, annotationStrategy); } /** * Returns a new key of the specified type with the same annotation as this * key. * * @since 3.0 */ public Key ofType(TypeLiteral type) { return new Key(type, annotationStrategy); } /** * Returns true if this key has annotation attributes. * * @since 3.0 */ public boolean hasAttributes() { return annotationStrategy.hasAttributes(); } /** * Returns this key without annotation attributes, i.e. with only the * annotation type. * * @since 3.0 */ public Key withoutAttributes() { return new Key(typeLiteral, annotationStrategy.withoutAttributes()); } interface AnnotationStrategy { Annotation getAnnotation(); Class getAnnotationType(); boolean hasAttributes(); AnnotationStrategy withoutAttributes(); } /** * Gets the strategy for an annotation. */ static AnnotationStrategy strategyFor(Annotation annotation) { checkNotNull(annotation, "annotation"); Class annotationType = annotation.annotationType(); ensureRetainedAtRuntime(annotationType); ensureIsBindingAnnotation(annotationType); if (Annotations.isMarker(annotationType)) { return new AnnotationTypeStrategy(annotationType, annotation); } return new AnnotationInstanceStrategy(Annotations.canonicalizeIfNamed(annotation)); } /** * Gets the strategy for an annotation type. */ static AnnotationStrategy strategyFor(Class annotationType) { checkNotNull(annotationType, "annotation type"); ensureRetainedAtRuntime(annotationType); ensureIsBindingAnnotation(annotationType); return new AnnotationTypeStrategy(Annotations.canonicalizeIfNamed(annotationType), null); } private static void ensureRetainedAtRuntime( Class annotationType) { checkArgument(Annotations.isRetainedAtRuntime(annotationType), "%s is not retained at runtime. Please annotate it with @Retention(RUNTIME).", annotationType.getName()); } private static void ensureIsBindingAnnotation(Class annotationType) { checkArgument(Annotations.isBindingAnnotation(annotationType), "%s is not a binding annotation. Please annotate it with @BindingAnnotation.", annotationType.getName()); } static enum NullAnnotationStrategy implements AnnotationStrategy { INSTANCE; public boolean hasAttributes() { return false; } public AnnotationStrategy withoutAttributes() { throw new UnsupportedOperationException("Key already has no attributes."); } public Annotation getAnnotation() { return null; } public Class getAnnotationType() { return null; } @Override public String toString() { return "[none]"; } } // this class not test-covered static class AnnotationInstanceStrategy implements AnnotationStrategy { final Annotation annotation; AnnotationInstanceStrategy(Annotation annotation) { this.annotation = checkNotNull(annotation, "annotation"); } public boolean hasAttributes() { return true; } public AnnotationStrategy withoutAttributes() { return new AnnotationTypeStrategy(getAnnotationType(), annotation); } public Annotation getAnnotation() { return annotation; } public Class getAnnotationType() { return annotation.annotationType(); } @Override public boolean equals(Object o) { if (!(o instanceof AnnotationInstanceStrategy)) { return false; } AnnotationInstanceStrategy other = (AnnotationInstanceStrategy) o; return annotation.equals(other.annotation); } @Override public int hashCode() { return annotation.hashCode(); } @Override public String toString() { return annotation.toString(); } } static class AnnotationTypeStrategy implements AnnotationStrategy { final Class annotationType; // Keep the instance around if we have it so the client can request it. final Annotation annotation; AnnotationTypeStrategy(Class annotationType, Annotation annotation) { this.annotationType = checkNotNull(annotationType, "annotation type"); this.annotation = annotation; } public boolean hasAttributes() { return false; } public AnnotationStrategy withoutAttributes() { throw new UnsupportedOperationException("Key already has no attributes."); } public Annotation getAnnotation() { return annotation; } public Class getAnnotationType() { return annotationType; } @Override public boolean equals(Object o) { if (!(o instanceof AnnotationTypeStrategy)) { return false; } AnnotationTypeStrategy other = (AnnotationTypeStrategy) o; return annotationType.equals(other.annotationType); } @Override public int hashCode() { return annotationType.hashCode(); } @Override public String toString() { return "@" + annotationType.getName(); } } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/Injector.java0000644000175000017500000002544711704661106024073 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import com.google.inject.spi.TypeConverterBinding; import java.lang.annotation.Annotation; import java.util.List; import java.util.Map; import java.util.Set; /** * Builds the graphs of objects that make up your application. The injector tracks the dependencies * for each type and uses bindings to inject them. This is the core of Guice, although you rarely * interact with it directly. This "behind-the-scenes" operation is what distinguishes dependency * injection from its cousin, the service locator pattern. * *

    Contains several default bindings: * *

      *
    • This {@link Injector} instance itself *
    • A {@code Provider} for each binding of type {@code T} *
    • The {@link java.util.logging.Logger} for the class being injected *
    • The {@link Stage} in which the Injector was created *
    * * Injectors are created using the facade class {@link Guice}. * *

    An injector can also {@link #injectMembers(Object) inject the dependencies} of * already-constructed instances. This can be used to interoperate with objects created by other * frameworks or services. * *

    Injectors can be {@link #createChildInjector(Iterable) hierarchical}. Child injectors inherit * the configuration of their parent injectors, but the converse does not hold. * *

    The injector's {@link #getBindings() internal bindings} are available for introspection. This * enables tools and extensions to operate on an injector reflectively. * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) */ public interface Injector { /** * Injects dependencies into the fields and methods of {@code instance}. Ignores the presence or * absence of an injectable constructor. * *

    Whenever Guice creates an instance, it performs this injection automatically (after first * performing constructor injection), so if you're able to let Guice create all your objects for * you, you'll never need to use this method. * * @param instance to inject members on * * @see Binder#getMembersInjector(Class) for a preferred alternative that supports checks before * run time */ void injectMembers(Object instance); /** * Returns the members injector used to inject dependencies into methods and fields on instances * of the given type {@code T}. * * @param typeLiteral type to get members injector for * @see Binder#getMembersInjector(TypeLiteral) for an alternative that offers up front error * detection * @since 2.0 */ MembersInjector getMembersInjector(TypeLiteral typeLiteral); /** * Returns the members injector used to inject dependencies into methods and fields on instances * of the given type {@code T}. When feasible, use {@link Binder#getMembersInjector(TypeLiteral)} * instead to get increased up front error detection. * * @param type type to get members injector for * @see Binder#getMembersInjector(Class) for an alternative that offers up front error * detection * @since 2.0 */ MembersInjector getMembersInjector(Class type); /** * Returns this injector's explicit bindings. * *

    The returned map does not include bindings inherited from a {@link #getParent() parent * injector}, should one exist. The returned map is guaranteed to iterate (for example, with * its {@link Map#entrySet()} iterator) in the order of insertion. In other words, the order in * which bindings appear in user Modules. * *

    This method is part of the Guice SPI and is intended for use by tools and extensions. */ Map, Binding> getBindings(); /** * Returns a snapshot of this injector's bindings, both explicit and * just-in-time. The returned map is immutable; it contains only the bindings that were * present when {@code getAllBindings()} was invoked. Subsequent calls may return a map with * additional just-in-time bindings. * *

    The returned map does not include bindings inherited from a {@link #getParent() parent * injector}, should one exist. * *

    This method is part of the Guice SPI and is intended for use by tools and extensions. * * @since 3.0 */ Map, Binding> getAllBindings(); /** * Returns the binding for the given injection key. This will be an explicit bindings if the key * was bound explicitly by a module, or an implicit binding otherwise. The implicit binding will * be created if necessary. * *

    This method is part of the Guice SPI and is intended for use by tools and extensions. * * @throws ConfigurationException if this injector cannot find or create the binding. */ Binding getBinding(Key key); /** * Returns the binding for the given type. This will be an explicit bindings if the injection key * was bound explicitly by a module, or an implicit binding otherwise. The implicit binding will * be created if necessary. * *

    This method is part of the Guice SPI and is intended for use by tools and extensions. * * @throws ConfigurationException if this injector cannot find or create the binding. * @since 2.0 */ Binding getBinding(Class type); /** * Returns the binding if it already exists, or null if does not exist. Unlike * {@link #getBinding(Key)}, this does not attempt to create just-in-time bindings * for keys that aren't bound. * *

    This method is part of the Guice SPI and is intended for use by tools and extensions. * * @since 3.0 */ Binding getExistingBinding(Key key); /** * Returns all explicit bindings for {@code type}. * *

    This method is part of the Guice SPI and is intended for use by tools and extensions. */ List> findBindingsByType(TypeLiteral type); /** * Returns the provider used to obtain instances for the given injection key. When feasible, avoid * using this method, in favor of having Guice inject your dependencies ahead of time. * * @throws ConfigurationException if this injector cannot find or create the provider. * @see Binder#getProvider(Key) for an alternative that offers up front error detection */ Provider getProvider(Key key); /** * Returns the provider used to obtain instances for the given type. When feasible, avoid * using this method, in favor of having Guice inject your dependencies ahead of time. * * @throws ConfigurationException if this injector cannot find or create the provider. * @see Binder#getProvider(Class) for an alternative that offers up front error detection */ Provider getProvider(Class type); /** * Returns the appropriate instance for the given injection key; equivalent to {@code * getProvider(key).get()}. When feasible, avoid using this method, in favor of having Guice * inject your dependencies ahead of time. * * @throws ConfigurationException if this injector cannot find or create the provider. * @throws ProvisionException if there was a runtime failure while providing an instance. */ T getInstance(Key key); /** * Returns the appropriate instance for the given injection type; equivalent to {@code * getProvider(type).get()}. When feasible, avoid using this method, in favor of having Guice * inject your dependencies ahead of time. * * @throws ConfigurationException if this injector cannot find or create the provider. * @throws ProvisionException if there was a runtime failure while providing an instance. */ T getInstance(Class type); /** * Returns this injector's parent, or {@code null} if this is a top-level injector. * * @since 2.0 */ Injector getParent(); /** * Returns a new injector that inherits all state from this injector. All bindings, scopes, * interceptors and type converters are inherited -- they are visible to the child injector. * Elements of the child injector are not visible to its parent. * *

    Just-in-time bindings created for child injectors will be created in an ancestor injector * whenever possible. This allows for scoped instances to be shared between injectors. Use * explicit bindings to prevent bindings from being shared with the parent injector. Optional * injections in just-in-time bindings (created in the parent injector) may be silently * ignored if the optional dependencies are from the child injector. * *

    No key may be bound by both an injector and one of its ancestors. This includes just-in-time * bindings. The lone exception is the key for {@code Injector.class}, which is bound by each * injector to itself. * * @since 2.0 */ Injector createChildInjector(Iterable modules); /** * Returns a new injector that inherits all state from this injector. All bindings, scopes, * interceptors and type converters are inherited -- they are visible to the child injector. * Elements of the child injector are not visible to its parent. * *

    Just-in-time bindings created for child injectors will be created in an ancestor injector * whenever possible. This allows for scoped instances to be shared between injectors. Use * explicit bindings to prevent bindings from being shared with the parent injector. * *

    No key may be bound by both an injector and one of its ancestors. This includes just-in-time * bindings. The lone exception is the key for {@code Injector.class}, which is bound by each * injector to itself. * * @since 2.0 */ Injector createChildInjector(Module... modules); /** * Returns a map containing all scopes in the injector. The maps keys are scoping annotations * like {@code Singleton.class}, and the values are scope instances, such as {@code * Scopes.SINGLETON}. The returned map is immutable. * *

    This method is part of the Guice SPI and is intended for use by tools and extensions. * * @since 3.0 */ Map, Scope> getScopeBindings(); /** * Returns a set containing all type converter bindings in the injector. The returned set is * immutable. * *

    This method is part of the Guice SPI and is intended for use by tools and extensions. * * @since 3.0 */ Set getTypeConverterBindings(); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/Inject.java0000644000175000017500000000524611704661106023525 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static java.lang.annotation.ElementType.CONSTRUCTOR; import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * Annotates members of your implementation class (constructors, methods * and fields) into which the {@link Injector} should inject values. * The Injector fulfills injection requests for: * *

      *
    • Every instance it constructs. The class being constructed must have * exactly one of its constructors marked with {@code @Inject} or must have a * constructor taking no parameters. The Injector then proceeds to perform * method and field injections. * *
    • Pre-constructed instances passed to {@link Injector#injectMembers}, * {@link com.google.inject.binder.LinkedBindingBuilder#toInstance(Object)} and * {@link com.google.inject.binder.LinkedBindingBuilder#toProvider(Provider)}. * In this case all constructors are, of course, ignored. * *
    • Static fields and methods of classes which any {@link Module} has * specifically requested static injection for, using * {@link Binder#requestStaticInjection}. *
    * * In all cases, a member can be injected regardless of its Java access * specifier (private, default, protected, public). * * @author crazybob@google.com (Bob Lee) */ @Target({ METHOD, CONSTRUCTOR, FIELD }) @Retention(RUNTIME) @Documented public @interface Inject { /** * If true, and the appropriate binding is not found, * the Injector will skip injection of this method or field rather than * produce an error. When applied to a field, any default value already * assigned to the field will remain (guice will not actively null out the * field). When applied to a method, the method will only be invoked if * bindings for all parameters are found. When applied to a * constructor, an error will result upon Injector creation. */ boolean optional() default false; } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/ImplementedBy.java0000644000175000017500000000203611704661106025041 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * A pointer to the default implementation of a type. * * @author crazybob@google.com (Bob Lee) */ @Retention(RUNTIME) @Target(TYPE) public @interface ImplementedBy { /** * The implementation type. */ Class value(); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/Guice.java0000644000175000017500000000636711704661106023352 0ustar tonytony/* * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import com.google.inject.internal.InternalInjectorCreator; import java.util.Arrays; /** * The entry point to the Guice framework. Creates {@link Injector}s from * {@link Module}s. * *

    Guice supports a model of development that draws clear boundaries between * APIs, Implementations of these APIs, Modules which configure these * implementations, and finally Applications which consist of a collection of * Modules. It is the Application, which typically defines your {@code main()} * method, that bootstraps the Guice Injector using the {@code Guice} class, as * in this example: *

     *     public class FooApplication {
     *       public static void main(String[] args) {
     *         Injector injector = Guice.createInjector(
     *             new ModuleA(),
     *             new ModuleB(),
     *             . . .
     *             new FooApplicationFlagsModule(args)
     *         );
     *
     *         // Now just bootstrap the application and you're done
     *         FooStarter starter = injector.getInstance(FooStarter.class);
     *         starter.runApplication();
     *       }
     *     }
     * 
    */ public final class Guice { private Guice() {} /** * Creates an injector for the given set of modules. This is equivalent to * calling {@link #createInjector(Stage, Module...)} with Stage.DEVELOPMENT. * * @throws CreationException if one or more errors occur during injector * construction */ public static Injector createInjector(Module... modules) { return createInjector(Arrays.asList(modules)); } /** * Creates an injector for the given set of modules. This is equivalent to * calling {@link #createInjector(Stage, Iterable)} with Stage.DEVELOPMENT. * * @throws CreationException if one or more errors occur during injector * creation */ public static Injector createInjector(Iterable modules) { return createInjector(Stage.DEVELOPMENT, modules); } /** * Creates an injector for the given set of modules, in a given development * stage. * * @throws CreationException if one or more errors occur during injector * creation. */ public static Injector createInjector(Stage stage, Module... modules) { return createInjector(stage, Arrays.asList(modules)); } /** * Creates an injector for the given set of modules, in a given development * stage. * * @throws CreationException if one or more errors occur during injector * construction */ public static Injector createInjector(Stage stage, Iterable modules) { return new InternalInjectorCreator() .stage(stage) .addModules(modules) .build(); } } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/Exposed.java0000644000175000017500000000222311704661106023710 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * Acccompanies a {@literal @}{@link com.google.inject.Provides Provides} method annotation in a * private module to indicate that the provided binding is exposed. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ @Target(ElementType.METHOD) @Retention(RUNTIME) @Documented public @interface Exposed {} sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/CreationException.java0000644000175000017500000000334111704661106025726 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.common.base.Preconditions.checkArgument; import com.google.common.collect.ImmutableSet; import com.google.inject.internal.Errors; import com.google.inject.spi.Message; import java.util.Collection; /** * Thrown when errors occur while creating a {@link Injector}. Includes a list of encountered * errors. Clients should catch this exception, log it, and stop execution. * * @author crazybob@google.com (Bob Lee) */ public class CreationException extends RuntimeException { private final ImmutableSet messages; /** Creates a CreationException containing {@code messages}. */ public CreationException(Collection messages) { this.messages = ImmutableSet.copyOf(messages); checkArgument(!this.messages.isEmpty()); initCause(Errors.getOnlyCause(this.messages)); } /** Returns messages for the errors that caused this exception. */ public Collection getErrorMessages() { return messages; } @Override public String getMessage() { return Errors.format("Guice creation errors", messages); } private static final long serialVersionUID = 0; } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/ConfigurationException.java0000644000175000017500000000524111704661106026772 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.common.base.Preconditions.checkState; import com.google.common.collect.ImmutableSet; import com.google.inject.internal.Errors; import com.google.inject.spi.Message; import java.util.Collection; /** * Thrown when a programming error such as a misplaced annotation, illegal binding, or unsupported * scope is found. Clients should catch this exception, log it, and stop execution. * * @author jessewilson@google.com (Jesse Wilson) * @since 2.0 */ public final class ConfigurationException extends RuntimeException { private final ImmutableSet messages; private Object partialValue = null; /** Creates a ConfigurationException containing {@code messages}. */ public ConfigurationException(Iterable messages) { this.messages = ImmutableSet.copyOf(messages); initCause(Errors.getOnlyCause(this.messages)); } /** Returns a copy of this configuration exception with the specified partial value. */ public ConfigurationException withPartialValue(Object partialValue) { checkState(this.partialValue == null, "Can't clobber existing partial value %s with %s", this.partialValue, partialValue); ConfigurationException result = new ConfigurationException(messages); result.partialValue = partialValue; return result; } /** Returns messages for the errors that caused this exception. */ public Collection getErrorMessages() { return messages; } /** * Returns a value that was only partially computed due to this exception. The caller can use * this while collecting additional configuration problems. * * @return the partial value, or {@code null} if none was set. The type of the partial value is * specified by the throwing method. */ @SuppressWarnings("unchecked") // this is *extremely* unsafe. We trust the caller here. public E getPartialValue() { return (E) partialValue; } @Override public String getMessage() { return Errors.format("Guice configuration errors", messages); } private static final long serialVersionUID = 0; }sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/BindingAnnotation.java0000644000175000017500000000252011704661106025706 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static java.lang.annotation.ElementType.ANNOTATION_TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * Annotates annotations which are used for binding. Only one such annotation * may apply to a single injection point. You must also annotate binder * annotations with {@code @Retention(RUNTIME)}. For example: * *
     *   {@code @}Retention(RUNTIME)
     *   {@code @}Target({ FIELD, PARAMETER, METHOD })
     *   {@code @}BindingAnnotation
     *   public {@code @}interface Transactional {}
     * 
    * * @author crazybob@google.com (Bob Lee) */ @Target(ANNOTATION_TYPE) @Retention(RUNTIME) public @interface BindingAnnotation {} sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/Binding.java0000644000175000017500000000713311704661106023660 0ustar tonytony/** * Copyright (C) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import com.google.inject.spi.BindingScopingVisitor; import com.google.inject.spi.BindingTargetVisitor; import com.google.inject.spi.Element; /** * A mapping from a key (type and optional annotation) to the strategy for getting instances of the * type. This interface is part of the introspection API and is intended primarily for use by * tools. * *

    Bindings are created in several ways: *

      *
    • Explicitly in a module, via {@code bind()} and {@code bindConstant()} * statements: *
       *     bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);
       *     bindConstant().annotatedWith(ServerHost.class).to(args[0]);
    • *
    • Implicitly by the Injector by following a type's {@link ImplementedBy * pointer} {@link ProvidedBy annotations} or by using its {@link Inject annotated} or * default constructor.
    • *
    • By converting a bound instance to a different type.
    • *
    • For {@link Provider providers}, by delegating to the binding for the provided type.
    • *
    * * *

    They exist on both modules and on injectors, and their behaviour is different for each: *

      *
    • Module bindings are incomplete and cannot be used to provide instances. * This is because the applicable scopes and interceptors may not be known until an injector * is created. From a tool's perspective, module bindings are like the injector's source * code. They can be inspected or rewritten, but this analysis must be done statically.
    • *
    • Injector bindings are complete and valid and can be used to provide * instances. From a tools' perspective, injector bindings are like reflection for an * injector. They have full runtime information, including the complete graph of injections * necessary to satisfy a binding.
    • *
    * * @param the bound type. The injected is always assignable to this type. * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) */ public interface Binding extends Element { /** * Returns the key for this binding. */ Key getKey(); /** * Returns the scoped provider guice uses to fulfill requests for this * binding. * * @throws UnsupportedOperationException when invoked on a {@link Binding} * created via {@link com.google.inject.spi.Elements#getElements}. This * method is only supported on {@link Binding}s returned from an injector. */ Provider getProvider(); /** * Accepts a target visitor. Invokes the visitor method specific to this binding's target. * * @param visitor to call back on * @since 2.0 */ V acceptTargetVisitor(BindingTargetVisitor visitor); /** * Accepts a scoping visitor. Invokes the visitor method specific to this binding's scoping. * * @param visitor to call back on * @since 2.0 */ V acceptScopingVisitor(BindingScopingVisitor visitor); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/Binder.java0000644000175000017500000004676411704661106023526 0ustar tonytony/* * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import com.google.inject.binder.AnnotatedBindingBuilder; import com.google.inject.binder.AnnotatedConstantBindingBuilder; import com.google.inject.binder.LinkedBindingBuilder; import com.google.inject.matcher.Matcher; import com.google.inject.spi.Message; import com.google.inject.spi.ProvisionListener; import com.google.inject.spi.TypeConverter; import com.google.inject.spi.TypeListener; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.lang.reflect.Proxy; /** * Collects configuration information (primarily bindings) which will be * used to create an {@link Injector}. Guice provides this object to your * application's {@link Module} implementors so they may each contribute * their own bindings and other registrations. * *

    The Guice Binding EDSL

    * * Guice uses an embedded domain-specific language, or EDSL, to help you * create bindings simply and readably. This approach is great for overall * usability, but it does come with a small cost: it is difficult to * learn how to use the Binding EDSL by reading * method-level javadocs. Instead, you should consult the series of * examples below. To save space, these examples omit the opening * {@code binder}, just as you will if your module extends * {@link AbstractModule}. * *
     *     bind(ServiceImpl.class);
    * * This statement does essentially nothing; it "binds the {@code ServiceImpl} * class to itself" and does not change Guice's default behavior. You may still * want to use this if you prefer your {@link Module} class to serve as an * explicit manifest for the services it provides. Also, in rare cases, * Guice may be unable to validate a binding at injector creation time unless it * is given explicitly. * *
     *     bind(Service.class).to(ServiceImpl.class);
    * * Specifies that a request for a {@code Service} instance with no binding * annotations should be treated as if it were a request for a * {@code ServiceImpl} instance. This overrides the function of any * {@link ImplementedBy @ImplementedBy} or {@link ProvidedBy @ProvidedBy} * annotations found on {@code Service}, since Guice will have already * "moved on" to {@code ServiceImpl} before it reaches the point when it starts * looking for these annotations. * *
     *     bind(Service.class).toProvider(ServiceProvider.class);
    * * In this example, {@code ServiceProvider} must extend or implement * {@code Provider}. This binding specifies that Guice should resolve * an unannotated injection request for {@code Service} by first resolving an * instance of {@code ServiceProvider} in the regular way, then calling * {@link Provider#get get()} on the resulting Provider instance to obtain the * {@code Service} instance. * *

    The {@link Provider} you use here does not have to be a "factory"; that * is, a provider which always creates each instance it provides. * However, this is generally a good practice to follow. You can then use * Guice's concept of {@link Scope scopes} to guide when creation should happen * -- "letting Guice work for you". * *

     *     bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class);
    * * Like the previous example, but only applies to injection requests that use * the binding annotation {@code @Red}. If your module also includes bindings * for particular values of the {@code @Red} annotation (see below), * then this binding will serve as a "catch-all" for any values of {@code @Red} * that have no exact match in the bindings. * *
     *     bind(ServiceImpl.class).in(Singleton.class);
     *     // or, alternatively
     *     bind(ServiceImpl.class).in(Scopes.SINGLETON);
    * * Either of these statements places the {@code ServiceImpl} class into * singleton scope. Guice will create only one instance of {@code ServiceImpl} * and will reuse it for all injection requests of this type. Note that it is * still possible to bind another instance of {@code ServiceImpl} if the second * binding is qualified by an annotation as in the previous example. Guice is * not overly concerned with preventing you from creating multiple * instances of your "singletons", only with enabling your application to * share only one instance if that's all you tell Guice you need. * *

    Note: a scope specified in this way overrides any scope that * was specified with an annotation on the {@code ServiceImpl} class. * *

    Besides {@link Singleton}/{@link Scopes#SINGLETON}, there are * servlet-specific scopes available in * {@code com.google.inject.servlet.ServletScopes}, and your Modules can * contribute their own custom scopes for use here as well. * *

     *     bind(new TypeLiteral<PaymentService<CreditCard>>() {})
     *         .to(CreditCardPaymentService.class);
    * * This admittedly odd construct is the way to bind a parameterized type. It * tells Guice how to honor an injection request for an element of type * {@code PaymentService}. The class * {@code CreditCardPaymentService} must implement the * {@code PaymentService} interface. Guice cannot currently bind or * inject a generic type, such as {@code Set}; all type parameters must be * fully specified. * *
     *     bind(Service.class).toInstance(new ServiceImpl());
     *     // or, alternatively
     *     bind(Service.class).toInstance(SomeLegacyRegistry.getService());
    * * In this example, your module itself, not Guice, takes responsibility * for obtaining a {@code ServiceImpl} instance, then asks Guice to always use * this single instance to fulfill all {@code Service} injection requests. When * the {@link Injector} is created, it will automatically perform field * and method injection for this instance, but any injectable constructor on * {@code ServiceImpl} is simply ignored. Note that using this approach results * in "eager loading" behavior that you can't control. * *
     *     bindConstant().annotatedWith(ServerHost.class).to(args[0]);
    * * Sets up a constant binding. Constant injections must always be annotated. * When a constant binding's value is a string, it is eligile for conversion to * all primitive types, to {@link Enum#valueOf(Class, String) all enums}, and to * {@link Class#forName class literals}. Conversions for other types can be * configured using {@link #convertToTypes(Matcher, TypeConverter) * convertToTypes()}. * *
     *   {@literal @}Color("red") Color red; // A member variable (field)
     *    . . .
     *     red = MyModule.class.getDeclaredField("red").getAnnotation(Color.class);
     *     bind(Service.class).annotatedWith(red).to(RedService.class);
    * * If your binding annotation has parameters you can apply different bindings to * different specific values of your annotation. Getting your hands on the * right instance of the annotation is a bit of a pain -- one approach, shown * above, is to apply a prototype annotation to a field in your module class, so * that you can read this annotation instance and give it to Guice. * *
     *     bind(Service.class)
     *         .annotatedWith(Names.named("blue"))
     *         .to(BlueService.class);
    * * Differentiating by names is a common enough use case that we provided a * standard annotation, {@link com.google.inject.name.Named @Named}. Because of * Guice's library support, binding by name is quite easier than in the * arbitrary binding annotation case we just saw. However, remember that these * names will live in a single flat namespace with all the other names used in * your application. * *
     *     Constructor loneCtor = getLoneCtorFromServiceImplViaReflection();
     *     bind(ServiceImpl.class)
     *         .toConstructor(loneCtor);
    * * In this example, we directly tell Guice which constructor to use in a concrete * class implementation. It means that we do not need to place {@literal @}Inject * on any of the constructors and that Guice treats the provided constructor as though * it were annotated so. It is useful for cases where you cannot modify existing * classes and is a bit simpler than using a {@link Provider}. * *

    The above list of examples is far from exhaustive. If you can think of * how the concepts of one example might coexist with the concepts from another, * you can most likely weave the two together. If the two concepts make no * sense with each other, you most likely won't be able to do it. In a few * cases Guice will let something bogus slip by, and will then inform you of * the problems at runtime, as soon as you try to create your Injector. * *

    The other methods of Binder such as {@link #bindScope}, * {@link #bindInterceptor}, {@link #install}, {@link #requestStaticInjection}, * {@link #addError} and {@link #currentStage} are not part of the Binding EDSL; * you can learn how to use these in the usual way, from the method * documentation. * * @author crazybob@google.com (Bob Lee) * @author jessewilson@google.com (Jesse Wilson) * @author kevinb@google.com (Kevin Bourrillion) */ public interface Binder { /*if[AOP]*/ /** * Binds method interceptor[s] to methods matched by class and method matchers. A method is * eligible for interception if: * *

      *
    • Guice created the instance the method is on
    • *
    • Neither the enclosing type nor the method is final
    • *
    • And the method is package-private, protected, or public
    • *
    * * @param classMatcher matches classes the interceptor should apply to. For * example: {@code only(Runnable.class)}. * @param methodMatcher matches methods the interceptor should apply to. For * example: {@code annotatedWith(Transactional.class)}. * @param interceptors to bind. The interceptors are called in the order they * are given. */ void bindInterceptor(Matcher> classMatcher, Matcher methodMatcher, org.aopalliance.intercept.MethodInterceptor... interceptors); /*end[AOP]*/ /** * Binds a scope to an annotation. */ void bindScope(Class annotationType, Scope scope); /** * See the EDSL examples at {@link Binder}. */ LinkedBindingBuilder bind(Key key); /** * See the EDSL examples at {@link Binder}. */ AnnotatedBindingBuilder bind(TypeLiteral typeLiteral); /** * See the EDSL examples at {@link Binder}. */ AnnotatedBindingBuilder bind(Class type); /** * See the EDSL examples at {@link Binder}. */ AnnotatedConstantBindingBuilder bindConstant(); /** * Upon successful creation, the {@link Injector} will inject instance fields * and methods of the given object. * * @param type of instance * @param instance for which members will be injected * @since 2.0 */ void requestInjection(TypeLiteral type, T instance); /** * Upon successful creation, the {@link Injector} will inject instance fields * and methods of the given object. * * @param instance for which members will be injected * @since 2.0 */ void requestInjection(Object instance); /** * Upon successful creation, the {@link Injector} will inject static fields * and methods in the given classes. * * @param types for which static members will be injected */ void requestStaticInjection(Class... types); /** * Uses the given module to configure more bindings. */ void install(Module module); /** * Gets the current stage. */ Stage currentStage(); /** * Records an error message which will be presented to the user at a later * time. Unlike throwing an exception, this enable us to continue * configuring the Injector and discover more errors. Uses {@link * String#format(String, Object[])} to insert the arguments into the * message. */ void addError(String message, Object... arguments); /** * Records an exception, the full details of which will be logged, and the * message of which will be presented to the user at a later * time. If your Module calls something that you worry may fail, you should * catch the exception and pass it into this. */ void addError(Throwable t); /** * Records an error message to be presented to the user at a later time. * * @since 2.0 */ void addError(Message message); /** * Returns the provider used to obtain instances for the given injection key. * The returned provider will not be valid until the {@link Injector} has been * created. The provider will throw an {@code IllegalStateException} if you * try to use it beforehand. * * @since 2.0 */ Provider getProvider(Key key); /** * Returns the provider used to obtain instances for the given injection type. * The returned provider will not be valid until the {@link Injector} has been * created. The provider will throw an {@code IllegalStateException} if you * try to use it beforehand. * * @since 2.0 */ Provider getProvider(Class type); /** * Returns the members injector used to inject dependencies into methods and fields on instances * of the given type {@code T}. The returned members injector will not be valid until the main * {@link Injector} has been created. The members injector will throw an {@code * IllegalStateException} if you try to use it beforehand. * * @param typeLiteral type to get members injector for * @since 2.0 */ MembersInjector getMembersInjector(TypeLiteral typeLiteral); /** * Returns the members injector used to inject dependencies into methods and fields on instances * of the given type {@code T}. The returned members injector will not be valid until the main * {@link Injector} has been created. The members injector will throw an {@code * IllegalStateException} if you try to use it beforehand. * * @param type type to get members injector for * @since 2.0 */ MembersInjector getMembersInjector(Class type); /** * Binds a type converter. The injector will use the given converter to * convert string constants to matching types as needed. * * @param typeMatcher matches types the converter can handle * @param converter converts values * @since 2.0 */ void convertToTypes(Matcher> typeMatcher, TypeConverter converter); /** * Registers a listener for injectable types. Guice will notify the listener when it encounters * injectable types matched by the given type matcher. * * @param typeMatcher that matches injectable types the listener should be notified of * @param listener for injectable types matched by typeMatcher * @since 2.0 */ void bindListener(Matcher> typeMatcher, TypeListener listener); /** * Registers listeners for provisioned objects. Guice will notify the * listeners just before and after the object is provisioned. Provisioned * objects that are also injectable (everything except objects provided * through Providers) can also be notified through TypeListeners registered in * {@link #bindListener}. * * @param keyMatcher that matches keys of provisioned objects the listener * should be notified of * @param listeners for provisioned objects matched by keyMatcher * * @since 4.0 */ void bindListener(Matcher> keyMatcher, ProvisionListener... listeners); /** * Returns a binder that uses {@code source} as the reference location for * configuration errors. This is typically a {@link StackTraceElement} * for {@code .java} source but it could any binding source, such as the * path to a {@code .properties} file. * * @param source any object representing the source location and has a * concise {@link Object#toString() toString()} value * @return a binder that shares its configuration with this binder * @since 2.0 */ Binder withSource(Object source); /** * Returns a binder that skips {@code classesToSkip} when identify the * calling code. The caller's {@link StackTraceElement} is used to locate * the source of configuration errors. * * @param classesToSkip library classes that create bindings on behalf of * their clients. * @return a binder that shares its configuration with this binder. * @since 2.0 */ Binder skipSources(Class... classesToSkip); /** * Creates a new private child environment for bindings and other configuration. The returned * binder can be used to add and configuration information in this environment. See {@link * PrivateModule} for details. * * @return a binder that inherits configuration from this binder. Only exposed configuration on * the returned binder will be visible to this binder. * @since 2.0 */ PrivateBinder newPrivateBinder(); /** * Instructs the Injector that bindings must be listed in a Module in order to * be injected. Classes that are not explicitly bound in a module cannot be * injected. Bindings created through a linked binding ( * bind(Foo.class).to(FooImpl.class)) are allowed, but the * implicit binding (FooImpl) cannot be directly injected unless * it is also explicitly bound (bind(FooImpl.class)). *

    * Tools can still retrieve bindings for implicit bindings (bindings created * through a linked binding) if explicit bindings are required, however * {@link Binding#getProvider} will fail. *

    * By default, explicit bindings are not required. *

    * If a parent injector requires explicit bindings, then all child injectors * (and private modules within that injector) also require explicit bindings. * If a parent does not require explicit bindings, a child injector or private * module may optionally declare itself as requiring explicit bindings. If it * does, the behavior is limited only to that child or any grandchildren. No * siblings of the child will require explicit bindings. *

    * If the parent did not require explicit bindings but the child does, it is * possible that a linked binding in the child may add a JIT binding to the * parent. The child will not be allowed to reference the target binding * directly, but the parent and other children of the parent may be able to. * * @since 3.0 */ void requireExplicitBindings(); /** * Prevents Guice from constructing a {@link Proxy} when a circular dependency * is found. By default, circular proxies are not disabled. *

    * If a parent injector disables circular proxies, then all child injectors * (and private modules within that injector) also disable circular proxies. * If a parent does not disable circular proxies, a child injector or private * module may optionally declare itself as disabling circular proxies. If it * does, the behavior is limited only to that child or any grandchildren. No * siblings of the child will disable circular proxies. * * @since 3.0 */ void disableCircularProxies(); } sisu-guice-sisu-guice-3.1.1/core/src/com/google/inject/AbstractModule.java0000644000175000017500000001573411704661106025225 0ustar tonytony/** * Copyright (C) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.inject; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import com.google.inject.binder.AnnotatedBindingBuilder; import com.google.inject.binder.AnnotatedConstantBindingBuilder; import com.google.inject.binder.LinkedBindingBuilder; import com.google.inject.matcher.Matcher; import com.google.inject.spi.Message; import com.google.inject.spi.ProvisionListener; import com.google.inject.spi.TypeConverter; import com.google.inject.spi.TypeListener; import java.lang.annotation.Annotation; import java.lang.reflect.Method; /** * A support class for {@link Module}s which reduces repetition and results in * a more readable configuration. Simply extend this class, implement {@link * #configure()}, and call the inherited methods which mirror those found in * {@link Binder}. For example: * *

     * public class MyModule extends AbstractModule {
     *   protected void configure() {
     *     bind(Service.class).to(ServiceImpl.class).in(Singleton.class);
     *     bind(CreditCardPaymentService.class);
     *     bind(PaymentService.class).to(CreditCardPaymentService.class);
     *     bindConstant().annotatedWith(Names.named("port")).to(8080);
     *   }
     * }
     * 
    * * @author crazybob@google.com (Bob Lee) */ public abstract class AbstractModule implements Module { Binder binder; public final synchronized void configure(Binder builder) { checkState(this.binder == null, "Re-entry is not allowed."); this.binder = checkNotNull(builder, "builder"); try { configure(); } finally { this.binder = null; } } /** * Configures a {@link Binder} via the exposed methods. */ protected abstract void configure(); /** * Gets direct access to the underlying {@code Binder}. */ protected Binder binder() { checkState(binder != null, "The binder can only be used inside configure()"); return binder; } /** * @see Binder#bindScope(Class, Scope) */ protected void bindScope(Class scopeAnnotation, Scope scope) { binder().bindScope(scopeAnnotation, scope); } /** * @see Binder#bind(Key) */ protected LinkedBindingBuilder bind(Key key) { return binder().bind(key); } /** * @see Binder#bind(TypeLiteral) */ protected AnnotatedBindingBuilder bind(TypeLiteral typeLiteral) { return binder().bind(typeLiteral); } /** * @see Binder#bind(Class) */ protected AnnotatedBindingBuilder bind(Class clazz) { return binder().bind(clazz); } /** * @see Binder#bindConstant() */ protected AnnotatedConstantBindingBuilder bindConstant() { return binder().bindConstant(); } /** * @see Binder#install(Module) */ protected void install(Module module) { binder().install(module); } /** * @see Binder#addError(String, Object[]) */ protected void addError(String message, Object... arguments) { binder().addError(message, arguments); } /** * @see Binder#addError(Throwable) */ protected void addError(Throwable t) { binder().addError(t); } /** * @see Binder#addError(Message) * @since 2.0 */ protected void addError(Message message) { binder().addError(message); } /** * @see Binder#requestInjection(Object) * @since 2.0 */ protected void requestInjection(Object instance) { binder().requestInjection(instance); } /** * @see Binder#requestStaticInjection(Class[]) */ protected void requestStaticInjection(Class... types) { binder().requestStaticInjection(types); } /*if[AOP]*/ /** * @see Binder#bindInterceptor(com.google.inject.matcher.Matcher, * com.google.inject.matcher.Matcher, * org.aopalliance.intercept.MethodInterceptor[]) */ protected void bindInterceptor(Matcher> classMatcher, Matcher methodMatcher, org.aopalliance.intercept.MethodInterceptor... interceptors) { binder().bindInterceptor(classMatcher, methodMatcher, interceptors); } /*end[AOP]*/ /** * Adds a dependency from this module to {@code key}. When the injector is * created, Guice will report an error if {@code key} cannot be injected. * Note that this requirement may be satisfied by implicit binding, such as * a public no-arguments constructor. * * @since 2.0 */ protected void requireBinding(Key key) { binder().getProvider(key); } /** * Adds a dependency from this module to {@code type}. When the injector is * created, Guice will report an error if {@code type} cannot be injected. * Note that this requirement may be satisfied by implicit binding, such as * a public no-arguments constructor. * * @since 2.0 */ protected void requireBinding(Class type) { binder().getProvider(type); } /** * @see Binder#getProvider(Key) * @since 2.0 */ protected Provider getProvider(Key key) { return binder().getProvider(key); } /** * @see Binder#getProvider(Class) * @since 2.0 */ protected Provider getProvider(Class type) { return binder().getProvider(type); } /** * @see Binder#convertToTypes * @since 2.0 */ protected void convertToTypes(Matcher> typeMatcher, TypeConverter converter) { binder().convertToTypes(typeMatcher, converter); } /** * @see Binder#currentStage() * @since 2.0 */ protected Stage currentStage() { return binder().currentStage(); } /** * @see Binder#getMembersInjector(Class) * @since 2.0 */ protected MembersInjector getMembersInjector(Class type) { return binder().getMembersInjector(type); } /** * @see Binder#getMembersInjector(TypeLiteral) * @since 2.0 */ protected MembersInjector getMembersInjector(TypeLiteral type) { return binder().getMembersInjector(type); } /** * @see Binder#bindListener(com.google.inject.matcher.Matcher, * com.google.inject.spi.TypeListener) * @since 2.0 */ protected void bindListener(Matcher> typeMatcher, TypeListener listener) { binder().bindListener(typeMatcher, listener); } /** * @see Binder#bindListener(Matcher, ProvisionListener) * @since 4.0 */ protected void bindListener(Matcher> keyMatcher, ProvisionListener... listener) { binder().bindListener(keyMatcher, listener); } } sisu-guice-sisu-guice-3.1.1/core/pom.xml0000644000175000017500000002364611704661106016672 0ustar tonytony 4.0.0 org.sonatype.sisu.inject guice-parent 3.1.1 org.sonatype.sisu sisu-guice Sisu Guice - Core Library javax.inject javax.inject 1 aopalliance aopalliance 1.0 org.sonatype.sisu sisu-guava 0.11.1 cglib cglib 2.2.2 true org.slf4j slf4j-api 1.6.3 true javax.inject javax.inject-tck 1 test org.springframework spring-beans 3.0.6.RELEASE test biz.aQute bnd 0.0.384 test org.apache.felix org.apache.felix.framework 4.0.1 test maven-remote-resources-plugin org.codehaus.mojo animal-sniffer-maven-plugin maven-surefire-plugin org.slf4j:slf4j-api **/OSGiContainerTest* org.apache.felix maven-bundle-plugin ${project.artifactId}$(if;$(classes;NAMED;*.Interceptor*);; (no_aop)) org.sonatype.sisu.guava org.slf4j true maven-jar-plugin LICENSE NOTICE guice.with.no_aop guice.with.no_aop !false org.sonatype.plugins munge-maven-plugin 1.0 prepare-package munge-fork NO_AOP **/InterceptorBinding.java, **/InterceptorBindingProcessor.java, **/InterceptorStackCallback.java, **/LineNumbers.java, **/MethodAspect.java, **/ProxyFactory.java, **/BytecodeGenTest.java, **/IntegrationTest.java, **/MethodInterceptionTest.java, **/ProxyFactoryTest.java maven-jar-plugin no_aop package jar ${project.build.directory}/munged/classes no_aop ${project.build.directory}/munged/classes/META-INF/MANIFEST.MF guice.with.jarjar guice.with.jarjar !false org.sonatype.plugins jarjar-maven-plugin 1.5 true *:asm *:cglib net.sf.cglib.* com.google.inject.internal.cglib.$@1 net.sf.cglib.**.* com.google.inject.internal.cglib.@1.$@2 org.objectweb.asm.* com.google.inject.internal.asm.$@1 org.objectweb.asm.**.* com.google.inject.internal.asm.@1.$@2 com.google.inject.** com.googlecode.** jarjar-classes process-test-classes jarjar {classes} jarjar-test-classes process-test-classes jarjar {test-classes} m2e m2e.version org.eclipse.m2e lifecycle-mapping 1.0.0 org.sonatype.plugins jarjar-maven-plugin [1.4,) jarjar sisu-guice-sisu-guice-3.1.1/copy.sh0000755000175000017500000000405511704661106015727 0ustar tonytony#!/bin/sh # Copies classes into Guice's internal package. client=/usr/local/google/clients/collect/google3 srcdir=core/src/com/google/inject/internal testdir=core/test/com/google/inject/internal filter() { sed 's/com.google.common.base.internal/com.google.inject.internal/' | \ sed 's/com.google.common.base/com.google.inject.internal/' | \ sed 's/com.google.common.collect/com.google.inject.internal/' } copy() { inFile=$1; fileName=`basename $inFile` dest=$2 destpath=$dest/$fileName filter < $client/${inFile} > $destpath } commonpath=java/com/google/common copy $commonpath/collect/ComputationException.java $srcdir copy $commonpath/collect/AsynchronousComputationException.java $srcdir copy $commonpath/collect/CustomConcurrentHashMap.java $srcdir copy $commonpath/collect/ExpirationTimer.java $srcdir copy $commonpath/collect/MapMaker.java $srcdir copy $commonpath/collect/NullOutputException.java $srcdir copy $commonpath/base/Function.java $srcdir copy $commonpath/base/Nullable.java $srcdir copy $commonpath/base/FinalizableReference.java $srcdir copy $commonpath/base/FinalizableReferenceQueue.java $srcdir copy $commonpath/base/internal/Finalizer.java $srcdir copy $commonpath/base/FinalizableWeakReference.java $srcdir copy $commonpath/base/FinalizableSoftReference.java $srcdir copy $commonpath/base/FinalizablePhantomReference.java $srcdir commontestspath=javatests/com/google/common copy $commontestspath/base/FinalizableReferenceQueueTest.java $testdir copy $commontestspath/collect/MapMakerTestSuite.java $testdir copy $commontestspath/collect/Jsr166HashMap.java $testdir copy $commontestspath/collect/Jsr166HashMapTest.java $testdir copy $commonpath/collect/ForwardingConcurrentMap.java $testdir copy $commonpath/collect/ForwardingMap.java $testdir copy $commonpath/collect/ForwardingCollection.java $testdir copy $commonpath/collect/ForwardingObject.java $testdir copy $commonpath/collect/ForwardingSet.java $testdir copy $commonpath/collect/ForwardingMap.java $testdir copy $commonpath/base/Preconditions.java $testdir chmod +w -R $srcdir $testdir sisu-guice-sisu-guice-3.1.1/compareBuilds.sh0000755000175000017500000000422311704661106017543 0ustar tonytony#!/bin/bash # Compares the ant jars to the maven jars and makes sure they're the same # (or different where/how expected) # Build everything first. function cleanAndBuild { mvn clean ant clean.all ant no_aop ant dist test.dist mvn package cd build/no_aop ant dist test.dist cd ../.. } function findAndCompareJars { version=3.0 for ANT in `find -name "*-snapshot.jar" -path "./build/dist/*"` do if [ $ANT = "./build/dist/guice-snapshot.jar" ]; then #Check main build MVN=./core/target/guice-$version-SNAPSHOT.jar extension=core compareJars "$ANT" "$MVN" $extension compareJars "./build/no_aop/$ANT" "./core/target/guice-$version-SNAPSHOT-no_aop.jar" "no_aop: $extension" #also compare no_aop core else # Check extensions extension=`echo $ANT | awk -F"-" '{print $2 }'` MVN=./extensions/$extension/target/guice-$extension-$version-SNAPSHOT.jar compareJars "$ANT" "$MVN" $extension fi done; } function compareJars { ANT=$1 MVN=$2 extension=$3 echo Comparing $3 mkdir tmp$$ cp $ANT tmp$$/ant.jar cp $MVN tmp$$/mvn.jar cd tmp$$ mkdir ant mkdir mvn cd ant jar -xf ../ant.jar cd .. cd mvn jar -xf ../mvn.jar cd .. # ant puts LICENSE & NOTICE files in a different place echo LICENSE > excludes echo NOTICE >> excludes # ant does not create DEPENDENCIES echo DEPENDENCIES >> excludes # ant/mvn slightly different in MANIFEST.MF echo MANIFEST.MF >> excludes # ant leaves empty directories for some jarjar'd paths -- # we grep -v instead of exclude because we want to make sure # if any files in those directories exist, that they're diff'd diff -u --recursive -Xexcludes ant mvn | grep -v "Only in ant/com/google/inject/internal/asm: signature" | grep -v "Only in ant/com/google/inject/internal/cglib: beans" | grep -v "Only in ant/com/google/inject/internal/cglib: transform" | grep -v "Only in ant/com/google/inject/internal/cglib: util" cd .. rm -rf "tmp$$" } cleanAndBuild echo "Starting to compare jars... Check the output closely!" echo findAndCompareJars echo echo "If the only thing that printed out is 'Comparing ', then you're good!"sisu-guice-sisu-guice-3.1.1/common.xml0000644000175000017500000002031311704661106016423 0ustar tonytony sisu-guice-sisu-guice-3.1.1/build.xml0000644000175000017500000002764211704661106016246 0ustar tonytony ]]> ]]> ]]> sisu-guice-sisu-guice-3.1.1/build.properties0000644000175000017500000000234411704661106017632 0ustar tonytonylib.dir=lib src.dir=core/src test.dir=core/test servlet.src.dir=extensions/servlet/src spring.src.dir=extensions/spring/src assistedinject.src.dir=extensions/assistedinject/src jmx.src.dir=extensions/jmx/src jndi.src.dir=extensions/jndi/src throwingproviders.src.dir=extensions/throwingproviders/src multibindings.src.dir=extensions/multibindings/src privatemodules.src.dir=extensions/privatemodules/src lifecycle.src.dir=extensions/lifecycle/src persist.src.dir=extensions/persist/src struts2.src.dir=extensions/struts2/src grapher.src.dir=extensions/grapher/src build.dir=build javadoc.packagenames=com.google.inject,com.google.inject.spi,\ com.google.inject.matcher,\ com.google.inject.servlet,\ com.google.inject.name,\ com.google.inject.tools.jmx,\ com.google.inject.binder,\ com.google.inject.jndi,\ com.google.inject.spring,\ com.google.inject.assistedinject,\ com.google.inject.throwingproviders,\ com.google.inject.multibindings,\ com.google.inject.privatemodules,\ com.google.inject.util,\ com.google.inject.persist,\ com.google.inject.persist.finder,\ com.google.inject.persist.jpa test.class=com.google.inject.AllTests module=com.google.inject imports=!net.sf.cglib.*,!org.objectweb.asm.*,!com.google.common.* sisu-guice-sisu-guice-3.1.1/README0000644000175000017500000000014111704661106015266 0ustar tonytonyPatched build of http://code.google.com/p/google-guice/ - see PATCHES for the exact differences. sisu-guice-sisu-guice-3.1.1/PATCHES0000644000175000017500000014416111704661106015433 0ustar tonytonydiff --git a/core/pom.xml b/core/pom.xml index 12ed258..eccd787 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,18 +4,15 @@ 4.0.0 - com.google.inject + org.sonatype.sisu.inject guice-parent - 3.0-SNAPSHOT + 3.2.0-SNAPSHOT - guice + org.sonatype.sisu + sisu-guice - Google Guice - Core Library - - - 2.2.2 - + Sisu Guice - Core Library @@ -29,14 +26,21 @@ 1.0 - com.google.guava - guava - 11.0.1 + org.sonatype.sisu + sisu-guava + 0.11.1 cglib cglib - ${cglib.version} + 2.2.2 + true + + + org.slf4j + slf4j-api + 1.6.3 + true javax.inject @@ -47,7 +51,7 @@ org.springframework spring-beans - 3.0.5.RELEASE + 3.0.6.RELEASE test @@ -59,7 +63,7 @@ org.apache.felix org.apache.felix.framework - 3.0.5 + 4.0.1 test @@ -83,12 +87,16 @@ maven-surefire-plugin + + org.slf4j:slf4j-api + + **/OSGiContainerTest* - **/ScopesTest* - **/TypeConversionTest* @@ -100,6 +108,11 @@ maven-bundle-plugin + + ${project.artifactId}$(if;$(classes;NAMED;*.Interceptor*);; (no_aop)) + + org.sonatype.sisu.guava + org.slf4j true @@ -197,46 +210,65 @@ !false - - - - cglib - cglib - ${cglib.version} - true - - org.sonatype.plugins jarjar-maven-plugin + 1.5 + true *:asm *:cglib - *:guava - *:jsr305 + + + net.sf.cglib.* + com.google.inject.internal.cglib.$@1 + + + net.sf.cglib.**.* + com.google.inject.internal.cglib.@1.$@2 + + + org.objectweb.asm.* + com.google.inject.internal.asm.$@1 + + + org.objectweb.asm.**.* + com.google.inject.internal.asm.@1.$@2 + + + com.google.inject.** + + + com.googlecode.** + + - - - maven-jar-plugin - no_deps - package + jarjar-classes + process-test-classes - jar + jarjar + + + {classes} + + + + jarjar-test-classes + process-test-classes + + jarjar - ${project.build.directory}/original-classes - no_deps + {test-classes} @@ -244,6 +276,43 @@ + + + m2e + + + m2e.version + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.sonatype.plugins + jarjar-maven-plugin + [1.4,) + jarjar + + + + + + + + + + + diff --git a/core/src/com/google/inject/Scopes.java b/core/src/com/google/inject/Scopes.java index fe44c15..035bd43 100644 --- a/core/src/com/google/inject/Scopes.java +++ b/core/src/com/google/inject/Scopes.java @@ -17,7 +17,6 @@ package com.google.inject; import com.google.inject.internal.CircularDependencyProxy; -import com.google.inject.internal.InternalInjectorCreator; import com.google.inject.internal.LinkedBindingImpl; import com.google.inject.spi.BindingScopingVisitor; import com.google.inject.spi.ExposedBinding; @@ -53,14 +52,9 @@ public class Scopes { public T get() { if (instance == null) { /* - * Use a pretty coarse lock. We don't want to run into deadlocks - * when two threads try to load circularly-dependent objects. - * Maybe one of these days we will identify independent graphs of - * objects and offer to load them in parallel. - * * This block is re-entrant for circular dependencies. */ - synchronized (InternalInjectorCreator.class) { + synchronized (this) { if (instance == null) { T provided = creator.get(); diff --git a/core/src/com/google/inject/internal/AbstractBindingProcessor.java b/core/src/com/google/inject/internal/AbstractBindingProcessor.java index f09c40b..8fe03de 100644 --- a/core/src/com/google/inject/internal/AbstractBindingProcessor.java +++ b/core/src/com/google/inject/internal/AbstractBindingProcessor.java @@ -38,6 +38,20 @@ import java.util.Set; */ abstract class AbstractBindingProcessor extends AbstractProcessor { +//------------------------------------------------------------------------------ + private static final boolean DISABLE_MISPLACED_ANNOTATION_CHECK; + static { + boolean disableCheck; + try { + disableCheck = Boolean.parseBoolean(System.getProperty( + "guice.disable.misplaced.annotation.check", "false")); + } catch (Throwable e) { + disableCheck = false; + } + DISABLE_MISPLACED_ANNOTATION_CHECK = disableCheck; + } +//------------------------------------------------------------------------------ + // It's unfortunate that we have to maintain a blacklist of specific // classes, but we can't easily block the whole package because of // all our unit tests. @@ -126,8 +140,14 @@ abstract class AbstractBindingProcessor extends AbstractProcessor { } private void validateKey(Object source, Key key) { +//------------------------------------------------------------------------------ +if (!DISABLE_MISPLACED_ANNOTATION_CHECK) { +//------------------------------------------------------------------------------ Annotations.checkForMisplacedScopeAnnotations( key.getTypeLiteral().getRawType(), source, errors); +//------------------------------------------------------------------------------ +} +//------------------------------------------------------------------------------ } /** diff --git a/core/src/com/google/inject/internal/BytecodeGen.java b/core/src/com/google/inject/internal/BytecodeGen.java index d0a14fc..55ad161 100644 --- a/core/src/com/google/inject/internal/BytecodeGen.java +++ b/core/src/com/google/inject/internal/BytecodeGen.java @@ -118,8 +118,7 @@ public final class BytecodeGen { end[NO_AOP]*/ /** Use "-Dguice.custom.loader=false" to disable custom classloading. */ - private static final boolean CUSTOM_LOADER_ENABLED - = Boolean.parseBoolean(System.getProperty("guice.custom.loader", "true")); + private static final boolean CUSTOM_LOADER_ENABLED; /** * Weak cache of bridge class loaders that make the Guice implementation @@ -128,6 +127,14 @@ public final class BytecodeGen { private static final Map CLASS_LOADER_CACHE; static { + boolean customLoaderEnabled; + try { + customLoaderEnabled = Boolean.parseBoolean(System.getProperty("guice.custom.loader", "true")); + } catch (Throwable e) { + customLoaderEnabled = false; // unlikely we'll also have permissions for custom loading + } + CUSTOM_LOADER_ENABLED = customLoaderEnabled; + if (CUSTOM_LOADER_ENABLED) { CLASS_LOADER_CACHE = new MapMaker().weakKeys().weakValues().makeComputingMap( new Function() { diff --git a/core/src/com/google/inject/internal/InjectorShell.java b/core/src/com/google/inject/internal/InjectorShell.java index 4985f8c..6f3ade3 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(injector, key, SourceProvider.UNKNOWN_SOURCE, loggerFactory, Scoping.UNSCOPED, loggerFactory, ImmutableSet.of())); + + try { + Key slf4jKey = Key.get(org.slf4j.Logger.class); + SLF4JLoggerFactory slf4jLoggerFactory = new SLF4JLoggerFactory(injector); + injector.state.putBinding(slf4jKey, + new ProviderInstanceBindingImpl(injector, slf4jKey, + SourceProvider.UNKNOWN_SOURCE, slf4jLoggerFactory, Scoping.UNSCOPED, + slf4jLoggerFactory, ImmutableSet.of())); + } catch (Throwable e) {} } private static class LoggerFactory implements InternalFactory, Provider { @@ -270,6 +279,44 @@ final class InjectorShell { } } + private static class SLF4JLoggerFactory implements InternalFactory, Provider { + 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"; + } + } + private static class RootModule implements Module { final Stage stage; diff --git a/core/src/com/google/inject/internal/ProxyFactory.java b/core/src/com/google/inject/internal/ProxyFactory.java index 3ab04bd..f4e93d2 100644 --- a/core/src/com/google/inject/internal/ProxyFactory.java +++ b/core/src/com/google/inject/internal/ProxyFactory.java @@ -24,6 +24,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.inject.spi.InjectionPoint; +import net.sf.cglib.core.MethodWrapper; import net.sf.cglib.proxy.Callback; import net.sf.cglib.proxy.CallbackFilter; import net.sf.cglib.proxy.Enhancer; @@ -198,35 +199,34 @@ final class ProxyFactory implements ConstructionProxyFactory { } /** - * A callback filter that maps methods to unique IDs. We define equals and hashCode using the - * declaring class so that enhanced classes can be shared between injectors. + * A callback filter that maps methods to unique IDs. We define equals and hashCode using + * the method-wrapper:indices map so that enhanced classes can be shared between injectors. */ private static class IndicesCallbackFilter implements CallbackFilter { - final Class declaringClass; - final Map indices; + final Map indices; + final int hashCode; IndicesCallbackFilter(Class declaringClass, List methods) { - this.declaringClass = declaringClass; - final Map indices = Maps.newHashMap(); + final Map indices = Maps.newHashMap(); for (int i = 0; i < methods.size(); i++) { - Method method = methods.get(i); - indices.put(method, i); + indices.put(MethodWrapper.create(methods.get(i)), i); } this.indices = indices; + hashCode = indices.hashCode(); } public int accept(Method method) { - return indices.get(method); + return indices.get(MethodWrapper.create(method)); } @Override public boolean equals(Object o) { return o instanceof IndicesCallbackFilter && - ((IndicesCallbackFilter) o).declaringClass == declaringClass; + ((IndicesCallbackFilter) o).indices.equals(indices); } @Override public int hashCode() { - return declaringClass.hashCode(); + return hashCode; } } diff --git a/core/test/com/google/inject/ScopesTest.java b/core/test/com/google/inject/ScopesTest.java index 7fd328a..689aec4 100644 --- a/core/test/com/google/inject/ScopesTest.java +++ b/core/test/com/google/inject/ScopesTest.java @@ -241,7 +241,7 @@ public class ScopesTest extends TestCase { Asserts.assertNotSerializable(Scopes.NO_SCOPE); } - public void testUnscopedProviderWorksOutsideOfRequestedScope() { + public void ignoreTestUnscopedProviderWorksOutsideOfRequestedScope() { final RememberProviderScope scope = new RememberProviderScope(); Injector injector = Guice.createInjector(new AbstractModule() { diff --git a/core/test/com/google/inject/TypeConversionTest.java b/core/test/com/google/inject/TypeConversionTest.java index 02fb442..df3ee93 100644 --- a/core/test/com/google/inject/TypeConversionTest.java +++ b/core/test/com/google/inject/TypeConversionTest.java @@ -402,7 +402,7 @@ public class TypeConversionTest extends TestCase { @Inject @NumericValue Date date; } - public void testCannotConvertUnannotatedBindings() { + public void ignoreTestCannotConvertUnannotatedBindings() { Injector injector = Guice.createInjector(new AbstractModule() { protected void configure() { bind(String.class).toInstance("55"); diff --git a/core/test/com/googlecode/guice/OSGiContainerTest.java b/core/test/com/googlecode/guice/OSGiContainerTest.java index 77ab8fa..068a541 100644 --- a/core/test/com/googlecode/guice/OSGiContainerTest.java +++ b/core/test/com/googlecode/guice/OSGiContainerTest.java @@ -33,6 +33,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.Iterator; +import java.util.Map; import java.util.Properties; import javax.imageio.spi.ServiceRegistry; @@ -134,7 +135,7 @@ public class OSGiContainerTest // test each available OSGi framework in turn Iterator f = ServiceRegistry.lookupProviders(FrameworkFactory.class); while (f.hasNext()) { - Framework framework = f.next().newFramework(properties); + Framework framework = f.next().newFramework((Map)properties); framework.start(); BundleContext systemContext = framework.getBundleContext(); diff --git a/extensions/assistedinject/pom.xml b/extensions/assistedinject/pom.xml index 745d6b4..4959704 100644 --- a/extensions/assistedinject/pom.xml +++ b/extensions/assistedinject/pom.xml @@ -4,13 +4,13 @@ 4.0.0 - com.google.inject.extensions - extensions-parent - 3.0-SNAPSHOT + org.sonatype.sisu.inject + guice-extensions + 3.2.0-SNAPSHOT guice-assistedinject - Google Guice - Extensions - AssistedInject + Sisu Guice - Extensions - AssistedInject diff --git a/extensions/grapher/pom.xml b/extensions/grapher/pom.xml index 015db56..3e20d17 100644 --- a/extensions/grapher/pom.xml +++ b/extensions/grapher/pom.xml @@ -4,23 +4,23 @@ 4.0.0 - com.google.inject.extensions - extensions-parent - 3.0-SNAPSHOT + org.sonatype.sisu.inject + guice-extensions + 3.2.0-SNAPSHOT guice-grapher - Google Guice - Extensions - Grapher + Sisu Guice - Extensions - Grapher - com.google.inject.extensions + org.sonatype.sisu.inject guice-assistedinject ${project.version} - com.google.inject.extensions + org.sonatype.sisu.inject guice-multibindings ${project.version} diff --git a/extensions/jmx/pom.xml b/extensions/jmx/pom.xml index d8188ca..1bb98a8 100644 --- a/extensions/jmx/pom.xml +++ b/extensions/jmx/pom.xml @@ -4,13 +4,13 @@ 4.0.0 - com.google.inject.extensions - extensions-parent - 3.0-SNAPSHOT + org.sonatype.sisu.inject + guice-extensions + 3.2.0-SNAPSHOT guice-jmx - Google Guice - Extensions - JMX + Sisu Guice - Extensions - JMX diff --git a/extensions/jndi/pom.xml b/extensions/jndi/pom.xml index ff04c5f..f186f1c 100644 --- a/extensions/jndi/pom.xml +++ b/extensions/jndi/pom.xml @@ -4,13 +4,13 @@ 4.0.0 - com.google.inject.extensions - extensions-parent - 3.0-SNAPSHOT + org.sonatype.sisu.inject + guice-extensions + 3.2.0-SNAPSHOT guice-jndi - Google Guice - Extensions - JNDI + Sisu Guice - Extensions - JNDI diff --git a/extensions/mini/pom.xml b/extensions/mini/pom.xml index 3fa7032..69e979b 100644 --- a/extensions/mini/pom.xml +++ b/extensions/mini/pom.xml @@ -4,13 +4,13 @@ 4.0.0 - com.google.inject.extensions - extensions-parent + org.sonatype.sisu.inject + guice-extensions 3.0-SNAPSHOT guice-mini - Google Guice - Extensions - Mini + Sisu Guice - Extensions - Mini diff --git a/extensions/multibindings/pom.xml b/extensions/multibindings/pom.xml index b49283c..48cf744 100644 --- a/extensions/multibindings/pom.xml +++ b/extensions/multibindings/pom.xml @@ -4,13 +4,13 @@ 4.0.0 - com.google.inject.extensions - extensions-parent - 3.0-SNAPSHOT + org.sonatype.sisu.inject + guice-extensions + 3.2.0-SNAPSHOT guice-multibindings - Google Guice - Extensions - MultiBindings + Sisu Guice - Extensions - MultiBindings diff --git a/extensions/persist/pom.xml b/extensions/persist/pom.xml index 2c787b1..4fb1820 100644 --- a/extensions/persist/pom.xml +++ b/extensions/persist/pom.xml @@ -4,14 +4,14 @@ 4.0.0 - com.google.inject.extensions - extensions-parent - 3.0-SNAPSHOT + org.sonatype.sisu.inject + guice-extensions + 3.2.0-SNAPSHOT guice-persist - Google Guice - Extensions - Persist + Sisu Guice - Extensions - Persist @@ -29,7 +29,7 @@ org.slf4j slf4j-simple - 1.6.1 + 1.6.3 test @@ -41,20 +41,9 @@ org.hsqldb hsqldb-j5 - 2.0.0 + 2.2.4 test - - - - maven-surefire-plugin - - never - - - - - diff --git a/extensions/persist/src/com/google/inject/persist/jpa/JpaPersistModule.java b/extensions/persist/src/com/google/inject/persist/jpa/JpaPersistModule.java index b318b27..5e9e364 100644 --- a/extensions/persist/src/com/google/inject/persist/jpa/JpaPersistModule.java +++ b/extensions/persist/src/com/google/inject/persist/jpa/JpaPersistModule.java @@ -37,6 +37,7 @@ import java.lang.reflect.Proxy; import java.util.List; import java.util.Properties; +import javax.inject.Provider; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; @@ -55,6 +56,7 @@ public final class JpaPersistModule extends PersistModule { } private Properties properties; + private Class> propertiesProvider; private MethodInterceptor transactionInterceptor; @Override protected void configurePersistence() { @@ -62,6 +64,9 @@ public final class JpaPersistModule extends PersistModule { if (null != properties) { bind(Properties.class).annotatedWith(Jpa.class).toInstance(properties); + } else if (null != propertiesProvider) { + bind(Properties.class).annotatedWith(Jpa.class) + .toProvider(propertiesProvider); } else { bind(Properties.class).annotatedWith(Jpa.class) .toProvider(Providers.of(null)); @@ -99,6 +104,11 @@ public final class JpaPersistModule extends PersistModule { return this; } + public JpaPersistModule properties(Class> provider) { + this.propertiesProvider = provider; + return this; + } + private final List> dynamicFinders = Lists.newArrayList(); /** diff --git a/extensions/persist/src/com/google/inject/persist/jpa/JpaPersistService.java b/extensions/persist/src/com/google/inject/persist/jpa/JpaPersistService.java index b8fe35c..68d76a7 100644 --- a/extensions/persist/src/com/google/inject/persist/jpa/JpaPersistService.java +++ b/extensions/persist/src/com/google/inject/persist/jpa/JpaPersistService.java @@ -42,11 +42,11 @@ class JpaPersistService implements Provider, UnitOfWork, PersistS private final ThreadLocal entityManager = new ThreadLocal(); private final String persistenceUnitName; - private final Properties persistenceProperties; + private final Provider persistenceProperties; @Inject public JpaPersistService(@Jpa String persistenceUnitName, - @Nullable @Jpa Properties persistenceProperties) { + @Nullable @Jpa Provider persistenceProperties) { this.persistenceUnitName = persistenceUnitName; this.persistenceProperties = persistenceProperties; } @@ -95,7 +95,7 @@ class JpaPersistService implements Provider, UnitOfWork, PersistS if (null != persistenceProperties) { this.emFactory = Persistence - .createEntityManagerFactory(persistenceUnitName, persistenceProperties); + .createEntityManagerFactory(persistenceUnitName, persistenceProperties.get()); } else { this.emFactory = Persistence.createEntityManagerFactory(persistenceUnitName); } diff --git a/extensions/pom.xml b/extensions/pom.xml index 309e092..823c103 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -4,17 +4,16 @@ 4.0.0 - com.google.inject + org.sonatype.sisu.inject guice-parent - 3.0-SNAPSHOT + 3.2.0-SNAPSHOT pom - com.google.inject.extensions - extensions-parent + guice-extensions - Google Guice - Extensions + Sisu Guice - Extensions assistedinject @@ -40,16 +39,16 @@ | All extensions depend on the core --> - com.google.inject - guice + org.sonatype.sisu + sisu-guice ${project.version} - com.google.inject - guice + org.sonatype.sisu + sisu-guice ${project.version} tests test @@ -79,7 +78,7 @@ maven-bundle-plugin - com.google.inject + org.sonatype.sisu.guice @@ -89,41 +88,22 @@ - guice.with.jarjar guice.with.jarjar - !false + false - - com.google.inject - guice - ${project.version} - no_deps - true + cglib + cglib + 2.2.2 + test - - - - org.sonatype.plugins - jarjar-maven-plugin - - - *:* - - - - - diff --git a/extensions/service/pom.xml b/extensions/service/pom.xml index d4efef8..df91f36 100644 --- a/extensions/service/pom.xml +++ b/extensions/service/pom.xml @@ -4,13 +4,13 @@ 4.0.0 - com.google.inject.extensions - extensions-parent + org.sonatype.sisu.inject + guice-extensions 3.0-SNAPSHOT guice-service - Google Guice - Extensions - Service + Sisu Guice - Extensions - Service diff --git a/extensions/servlet/pom.xml b/extensions/servlet/pom.xml index 4f34f2f..9017372 100644 --- a/extensions/servlet/pom.xml +++ b/extensions/servlet/pom.xml @@ -4,14 +4,14 @@ 4.0.0 - com.google.inject.extensions - extensions-parent - 3.0-SNAPSHOT + org.sonatype.sisu.inject + guice-extensions + 3.2.0-SNAPSHOT guice-servlet - Google Guice - Extensions - Servlet + Sisu Guice - Extensions - Servlet diff --git a/extensions/servlet/src/com/google/inject/servlet/FilterPipeline.java b/extensions/servlet/src/com/google/inject/servlet/FilterPipeline.java index 985064b..d85d97c 100755 --- a/extensions/servlet/src/com/google/inject/servlet/FilterPipeline.java +++ b/extensions/servlet/src/com/google/inject/servlet/FilterPipeline.java @@ -39,7 +39,7 @@ import javax.servlet.ServletResponse; * @author dhanji@gmail.com (Dhanji R. Prasanna) */ @ImplementedBy(DefaultFilterPipeline.class) -interface FilterPipeline { +public interface FilterPipeline { void initPipeline(ServletContext context) throws ServletException; void destroyPipeline(); diff --git a/extensions/servlet/src/com/google/inject/servlet/GuiceFilter.java b/extensions/servlet/src/com/google/inject/servlet/GuiceFilter.java index d069c96..1967da6 100644 --- a/extensions/servlet/src/com/google/inject/servlet/GuiceFilter.java +++ b/extensions/servlet/src/com/google/inject/servlet/GuiceFilter.java @@ -85,7 +85,7 @@ public class GuiceFilter implements Filter { this(null); } - @Inject GuiceFilter(FilterPipeline filterPipeline) { + @Inject protected GuiceFilter(FilterPipeline filterPipeline) { injectedPipeline = filterPipeline; } diff --git a/extensions/spring/pom.xml b/extensions/spring/pom.xml index f81f6ad..edc79f7 100644 --- a/extensions/spring/pom.xml +++ b/extensions/spring/pom.xml @@ -4,20 +4,20 @@ 4.0.0 - com.google.inject.extensions - extensions-parent - 3.0-SNAPSHOT + org.sonatype.sisu.inject + guice-extensions + 3.2.0-SNAPSHOT guice-spring - Google Guice - Extensions - Spring + Sisu Guice - Extensions - Spring org.springframework spring-beans - 3.0.5.RELEASE + 3.0.6.RELEASE provided diff --git a/extensions/struts2/pom.xml b/extensions/struts2/pom.xml index 38d313a..b85203c 100644 --- a/extensions/struts2/pom.xml +++ b/extensions/struts2/pom.xml @@ -4,18 +4,18 @@ 4.0.0 - com.google.inject.extensions - extensions-parent - 3.0-SNAPSHOT + org.sonatype.sisu.inject + guice-extensions + 3.2.0-SNAPSHOT guice-struts2 - Google Guice - Extensions - Struts2 + Sisu Guice - Extensions - Struts2 - com.google.inject.extensions + org.sonatype.sisu.inject guice-servlet ${project.version} @@ -28,7 +28,7 @@ org.apache.struts struts2-core - 2.2.1 + 2.2.3.1 provided diff --git a/extensions/throwingproviders/pom.xml b/extensions/throwingproviders/pom.xml index bd67158..e89521e 100644 --- a/extensions/throwingproviders/pom.xml +++ b/extensions/throwingproviders/pom.xml @@ -4,13 +4,13 @@ 4.0.0 - com.google.inject.extensions - extensions-parent - 3.0-SNAPSHOT + org.sonatype.sisu.inject + guice-extensions + 3.2.0-SNAPSHOT guice-throwingproviders - Google Guice - Extensions - ThrowingProviders + Sisu Guice - Extensions - ThrowingProviders diff --git a/lib/build/doclava.jar b/lib/build/doclava.jar index 6abed4b..259cae6 100644 Binary files a/lib/build/doclava.jar and b/lib/build/doclava.jar differ diff --git a/pom.xml b/pom.xml index 3b76484..88c0d85 100644 --- a/pom.xml +++ b/pom.xml @@ -18,21 +18,21 @@ See the Apache License Version 2.0 for the specific language governing permissio 4.0.0 - com.google - google - 5 + org.sonatype.forge + forge-parent + 10 pom - com.google.inject + org.sonatype.sisu.inject guice-parent - 3.0-SNAPSHOT + 3.2.0-SNAPSHOT - Google Guice + Sisu Guice - Guice is a lightweight dependency injection framework for Java 5 and above + Patched build of Guice: a lightweight dependency injection framework for Java 5 and above http://code.google.com/p/google-guice/ @@ -47,23 +47,23 @@ See the Apache License Version 2.0 for the specific language governing permissio Guice Users List http://groups.google.com/group/google-guice/topics - http://groups.google.com/group/google-guice/subscribe - http://groups.google.com/group/google-guice/subscribe + google-guice+subscribe@googlegroups.com + google-guice+unsubscribe@googlegroups.com http://groups.google.com/group/google-guice/post Guice Developers List http://groups.google.com/group/google-guice-dev/topics - http://groups.google.com/group/google-guice-dev/subscribe - http://groups.google.com/group/google-guice-dev/subscribe + google-guice-dev+subscribe@googlegroups.com + google-guice-dev+unsubscribe@googlegroups.com http://groups.google.com/group/google-guice-dev/post - scm:svn:http://google-guice.googlecode.com/svn/trunk - scm:svn:https://google-guice.googlecode.com/svn/trunk - http://code.google.com/p/google-guice/source/browse + scm:git:git@github.com:sonatype/sisu-guice.git + scm:git:git@github.com:sonatype/sisu-guice.git + http://github.com/sonatype/sisu-guice @@ -73,7 +73,7 @@ See the Apache License Version 2.0 for the specific language governing permissio Hudson - https://grid.sonatype.org/ci/job/Google-Guice/ + https://builds.sonatype.org/job/sisu-guice/ @@ -97,7 +97,7 @@ See the Apache License Version 2.0 for the specific language governing permissio - 1.3 + 1.4 UTF-8 maven-remote-resources-plugin - 1.1 + 1.2.1 @@ -177,7 +176,7 @@ See the Apache License Version 2.0 for the specific language governing permissio org.codehaus.mojo animal-sniffer-maven-plugin - 1.6 + 1.7 org.codehaus.mojo.signature @@ -195,81 +194,9 @@ See the Apache License Version 2.0 for the specific language governing permissio - - - org.sonatype.plugins - jarjar-maven-plugin - 1.4 - - - - net.sf.cglib.* - com.google.inject.internal.cglib.$@1 - - - net.sf.cglib.**.* - com.google.inject.internal.cglib.@1.$@2 - - - org.objectweb.asm.* - com.google.inject.internal.asm.$@1 - - - org.objectweb.asm.**.* - com.google.inject.internal.asm.@1.$@2 - - - com.google.common.* - com.google.inject.internal.guava.$@1 - - - com.google.common.**.* - com.google.inject.internal.guava.@1.$@2 - - - com.google.inject.** - - - com.googlecode.** - - - - com.google.common.base.Throwables - - - - - - - jarjar-classes - process-test-classes - - jarjar - - - {classes} - - - - jarjar-test-classes - process-test-classes - - jarjar - - - {test-classes} - - - - maven-surefire-plugin - 2.5 + 2.10 true @@ -280,21 +207,19 @@ See the Apache License Version 2.0 for the specific language governing permissio org.apache.felix maven-bundle-plugin - 2.1.0 + 2.3.6 - com.google.inject - <_include>-${project.basedir}/build.properties + ${project.artifactId} + $(maven-symbolicname);singleton:=true Copyright (C) 2006 Google Inc. http://code.google.com/p/google-guice/ - ${project.artifactId} - $(module) + Sonatype, Inc. J2SE-1.5,JavaSE-1.6 - !com.google.inject.*,* - <_exportcontents>!*.internal.*,$(module).*;version=${guice.api.version} - <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@))) + <_exportcontents>!*.internal.*,*;version=${guice.api.version} + !com.google.*,* <_nouses>true <_removeheaders> Embed-Dependency,Embed-Transitive, @@ -304,6 +229,9 @@ See the Apache License Version 2.0 for the specific language governing permissio Ignore-Package,Bnd-LastModified + + true + @@ -319,12 +247,11 @@ See the Apache License Version 2.0 for the specific language governing permissio --> maven-jar-plugin - 2.3.1 + 2.3.2 ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - false + false @@ -338,7 +265,35 @@ See the Apache License Version 2.0 for the specific language governing permissio maven-javadoc-plugin - 2.7 + 2.8 + + com.google.doclava.Doclava + + ${project.basedir}/../lib/build/doclava.jar: + ${project.basedir}/../../lib/build/doclava.jar + + + ${sun.boot.class.path} + *.internal + + -quiet + -federate JDK http://download.oracle.com/javase/6/docs/api/index.html? + -federationxml JDK http://doclava.googlecode.com/svn/static/api/openjdk-6.xml + -hdf project.name "${project.name} (patched build of Google Guice)" + -d ${project.build.directory}/apidocs + + false + + -J-Xmx1024m + + + + maven-site-plugin + 3.0 maven-source-plugin @@ -346,46 +301,21 @@ See the Apache License Version 2.0 for the specific language governing permissio maven-gpg-plugin - 1.1 + 1.4 maven-release-plugin - 2.1 + 2.2.1 true maven-deploy-plugin - 2.5 + 2.7 - - - - sonatype-grid - - forge-releases - http://repository.sonatype.org:8081/service/local/staging/deploy/maven2 - forge-snapshots - http://repository.sonatype.org/content/repositories/snapshots - - - - ${forgeReleaseId} - ${forgeReleaseUrl} - - - ${forgeSnapshotId} - ${forgeSnapshotUrl} - - - - - sisu-guice-sisu-guice-3.1.1/COPYING0000644000175000017500000002613611704661106015455 0ustar tonytony Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. sisu-guice-sisu-guice-3.1.1/.gitignore0000644000175000017500000000016411704661106016403 0ustar tonytony# Maven target/ *.ser *.ec # IntelliJ Idea .idea/ out/ *.ipr *.iws *.iml # Eclipse .classpath .project .settings/