├── .gitattributes ├── .github ├── actions │ ├── bazel-build │ │ └── action.yml │ ├── bazel-test │ │ └── action.yml │ ├── local-artifact-tests │ │ └── action.yml │ ├── maven-test │ │ └── action.yml │ └── publish-snapshot │ │ └── action.yml └── workflows │ └── ci.yml ├── .gitignore ├── BUILD ├── CONTRIBUTING.md ├── COPYING ├── README.md ├── WORKSPACE ├── bom ├── BUILD └── pom.xml ├── build.properties ├── build_defs.bzl ├── core ├── pom.xml ├── src │ └── com │ │ └── google │ │ └── inject │ │ ├── AbstractModule.java │ │ ├── BUILD │ │ ├── Binder.java │ │ ├── Binding.java │ │ ├── BindingAnnotation.java │ │ ├── ConfigurationException.java │ │ ├── CreationException.java │ │ ├── Exposed.java │ │ ├── Guice.java │ │ ├── ImplementedBy.java │ │ ├── Inject.java │ │ ├── Injector.java │ │ ├── Key.java │ │ ├── MembersInjector.java │ │ ├── Module.java │ │ ├── OutOfScopeException.java │ │ ├── PrivateBinder.java │ │ ├── PrivateModule.java │ │ ├── ProvidedBy.java │ │ ├── Provider.java │ │ ├── Provides.java │ │ ├── ProvisionException.java │ │ ├── RestrictedBindingSource.java │ │ ├── Scope.java │ │ ├── ScopeAnnotation.java │ │ ├── Scopes.java │ │ ├── Singleton.java │ │ ├── Stage.java │ │ ├── TypeLiteral.java │ │ ├── binder │ │ ├── AnnotatedBindingBuilder.java │ │ ├── AnnotatedConstantBindingBuilder.java │ │ ├── AnnotatedElementBuilder.java │ │ ├── ConstantBindingBuilder.java │ │ ├── LinkedBindingBuilder.java │ │ ├── ScopedBindingBuilder.java │ │ └── package-info.java │ │ ├── internal │ │ ├── AbstractBindingBuilder.java │ │ ├── AbstractBindingProcessor.java │ │ ├── AbstractProcessor.java │ │ ├── Annotations.java │ │ ├── BindingAlreadySetError.java │ │ ├── BindingBuilder.java │ │ ├── BindingImpl.java │ │ ├── BindingProcessor.java │ │ ├── BoundProviderFactory.java │ │ ├── BytecodeGen.java │ │ ├── ChildBindingAlreadySetError.java │ │ ├── ConstantBindingBuilderImpl.java │ │ ├── ConstantFactory.java │ │ ├── ConstantProviderInternalFactory.java │ │ ├── ConstructionProxy.java │ │ ├── ConstructionProxyFactory.java │ │ ├── ConstructorBindingImpl.java │ │ ├── ConstructorInjector.java │ │ ├── ConstructorInjectorStore.java │ │ ├── CreationListener.java │ │ ├── CycleDetectingLock.java │ │ ├── DeclaredMembers.java │ │ ├── DefaultConstructionProxyFactory.java │ │ ├── DeferredLookups.java │ │ ├── DelayedInitialize.java │ │ ├── DelegatingInvocationHandler.java │ │ ├── DuplicateElementError.java │ │ ├── DuplicateMapKeyError.java │ │ ├── Element.java │ │ ├── EncounterImpl.java │ │ ├── ErrorFormatter.java │ │ ├── ErrorHandler.java │ │ ├── ErrorId.java │ │ ├── Errors.java │ │ ├── ErrorsException.java │ │ ├── ExposedBindingImpl.java │ │ ├── ExposedKeyFactory.java │ │ ├── ExposureBuilder.java │ │ ├── FactoryProxy.java │ │ ├── FailableCache.java │ │ ├── GenericErrorDetail.java │ │ ├── GuiceInternal.java │ │ ├── Indexer.java │ │ ├── Initializable.java │ │ ├── InitializableFactory.java │ │ ├── Initializer.java │ │ ├── InjectionRequestProcessor.java │ │ ├── InjectorBindingData.java │ │ ├── InjectorImpl.java │ │ ├── InjectorJitBindingData.java │ │ ├── InjectorOptionsProcessor.java │ │ ├── InjectorShell.java │ │ ├── InstanceBindingImpl.java │ │ ├── InterceptorBindingProcessor.java │ │ ├── InterceptorStackCallback.java │ │ ├── InternalClassesToSkipSources.java │ │ ├── InternalContext.java │ │ ├── InternalErrorDetail.java │ │ ├── InternalFactory.java │ │ ├── InternalFactoryToInitializableAdapter.java │ │ ├── InternalFactoryToScopedProviderAdapter.java │ │ ├── InternalFlags.java │ │ ├── InternalInjectorCreator.java │ │ ├── InternalMethodHandles.java │ │ ├── InternalProviderInstanceBindingImpl.java │ │ ├── InternalProvisionException.java │ │ ├── KotlinSupport.java │ │ ├── KotlinSupportInterface.java │ │ ├── LinkageContext.java │ │ ├── LinkedBindingImpl.java │ │ ├── LinkedProviderBindingImpl.java │ │ ├── ListenerBindingProcessor.java │ │ ├── LookupBindingProcessor.java │ │ ├── LookupProcessor.java │ │ ├── Lookups.java │ │ ├── MembersInjectorImpl.java │ │ ├── MembersInjectorStore.java │ │ ├── MessageProcessor.java │ │ ├── Messages.java │ │ ├── MethodAspect.java │ │ ├── MissingConstructorError.java │ │ ├── MissingImplementationError.java │ │ ├── MissingImplementationErrorHints.java │ │ ├── ModuleAnnotatedMethodScannerProcessor.java │ │ ├── MoreTypes.java │ │ ├── Nullability.java │ │ ├── PackageNameCompressor.java │ │ ├── PrivateElementProcessor.java │ │ ├── PrivateElementsImpl.java │ │ ├── ProcessedBindingData.java │ │ ├── ProvidedByInternalFactory.java │ │ ├── ProviderInstanceBindingImpl.java │ │ ├── ProviderInternalFactory.java │ │ ├── ProviderMethod.java │ │ ├── ProviderMethodsModule.java │ │ ├── ProviderToInternalFactoryAdapter.java │ │ ├── ProvidesMethodScanner.java │ │ ├── ProvisionListenerCallbackStore.java │ │ ├── ProvisionListenerStackCallback.java │ │ ├── ProxyFactory.java │ │ ├── RealElement.java │ │ ├── RealMapBinder.java │ │ ├── RealMultibinder.java │ │ ├── RealOptionalBinder.java │ │ ├── ScopeBindingProcessor.java │ │ ├── ScopeNotFoundError.java │ │ ├── Scoping.java │ │ ├── SingleFieldInjector.java │ │ ├── SingleMemberInjector.java │ │ ├── SingleMethodInjector.java │ │ ├── SingleParameterInjector.java │ │ ├── SingletonScope.java │ │ ├── SourceFormatter.java │ │ ├── TypeConverterBindingProcessor.java │ │ ├── UniqueAnnotations.java │ │ ├── UntargettedBindingImpl.java │ │ ├── UntargettedBindingProcessor.java │ │ ├── WeakKeySet.java │ │ ├── aop │ │ │ ├── AbstractGlueGenerator.java │ │ │ ├── AnonymousClassDefiner.java │ │ │ ├── BytecodeTasks.java │ │ │ ├── ChildClassDefiner.java │ │ │ ├── ClassBuilding.java │ │ │ ├── ClassDefiner.java │ │ │ ├── ClassDefining.java │ │ │ ├── Enhancer.java │ │ │ ├── EnhancerBuilderImpl.java │ │ │ ├── FastClass.java │ │ │ ├── GeneratedClassDefiner.java │ │ │ ├── GlueException.java │ │ │ ├── HiddenClassDefiner.java │ │ │ ├── ImmutableStringTrie.java │ │ │ ├── MethodPartition.java │ │ │ ├── UnsafeClassDefiner.java │ │ │ └── UnsafeGetter.java │ │ ├── package-info.java │ │ └── util │ │ │ ├── CallerFinder.java │ │ │ ├── Classes.java │ │ │ ├── ContinuousStopwatch.java │ │ │ ├── DirectStackWalkerFinder.java │ │ │ ├── LineNumbers.java │ │ │ ├── NewThrowableFinder.java │ │ │ ├── SourceProvider.java │ │ │ └── StackTraceElements.java │ │ ├── matcher │ │ ├── AbstractMatcher.java │ │ ├── Matcher.java │ │ ├── Matchers.java │ │ └── package-info.java │ │ ├── multibindings │ │ ├── ClassMapKey.java │ │ ├── MapBinder.java │ │ ├── MapBinderBinding.java │ │ ├── MapKey.java │ │ ├── Multibinder.java │ │ ├── MultibinderBinding.java │ │ ├── MultibindingsScanner.java │ │ ├── MultibindingsTargetVisitor.java │ │ ├── OptionalBinder.java │ │ ├── OptionalBinderBinding.java │ │ ├── ProvidesIntoMap.java │ │ ├── ProvidesIntoOptional.java │ │ ├── ProvidesIntoSet.java │ │ ├── StringMapKey.java │ │ └── package-info.java │ │ ├── name │ │ ├── Named.java │ │ ├── NamedImpl.java │ │ ├── Names.java │ │ └── package-info.java │ │ ├── package-info.java │ │ ├── spi │ │ ├── BindingScopingVisitor.java │ │ ├── BindingSourceRestriction.java │ │ ├── BindingTargetVisitor.java │ │ ├── ConstructorBinding.java │ │ ├── ConvertedConstantBinding.java │ │ ├── DefaultBindingScopingVisitor.java │ │ ├── DefaultBindingTargetVisitor.java │ │ ├── DefaultElementVisitor.java │ │ ├── Dependency.java │ │ ├── DisableCircularProxiesOption.java │ │ ├── Element.java │ │ ├── ElementSource.java │ │ ├── ElementVisitor.java │ │ ├── Elements.java │ │ ├── ErrorDetail.java │ │ ├── ExposedBinding.java │ │ ├── HasDependencies.java │ │ ├── InjectionListener.java │ │ ├── InjectionPoint.java │ │ ├── InjectionRequest.java │ │ ├── InstanceBinding.java │ │ ├── InterceptorBinding.java │ │ ├── LinkedKeyBinding.java │ │ ├── MembersInjectorLookup.java │ │ ├── Message.java │ │ ├── ModuleAnnotatedMethodScanner.java │ │ ├── ModuleAnnotatedMethodScannerBinding.java │ │ ├── ModuleSource.java │ │ ├── PrivateElements.java │ │ ├── ProviderBinding.java │ │ ├── ProviderInstanceBinding.java │ │ ├── ProviderKeyBinding.java │ │ ├── ProviderLookup.java │ │ ├── ProviderWithDependencies.java │ │ ├── ProviderWithExtensionVisitor.java │ │ ├── ProvidesMethodBinding.java │ │ ├── ProvidesMethodTargetVisitor.java │ │ ├── ProvisionListener.java │ │ ├── ProvisionListenerBinding.java │ │ ├── RequireAtInjectOnConstructorsOption.java │ │ ├── RequireExactBindingAnnotationsOption.java │ │ ├── RequireExplicitBindingsOption.java │ │ ├── ScopeBinding.java │ │ ├── StaticInjectionRequest.java │ │ ├── Toolable.java │ │ ├── TypeConverter.java │ │ ├── TypeConverterBinding.java │ │ ├── TypeEncounter.java │ │ ├── TypeListener.java │ │ ├── TypeListenerBinding.java │ │ ├── UntargettedBinding.java │ │ └── package-info.java │ │ └── util │ │ ├── Enhanced.java │ │ ├── Modules.java │ │ ├── Providers.java │ │ ├── Types.java │ │ └── package-info.java └── test │ └── com │ ├── google │ └── inject │ │ ├── AllTests.java │ │ ├── Asserts.java │ │ ├── BUILD │ │ ├── BinderTest.java │ │ ├── BinderTestSuite.java │ │ ├── BindingAnnotationTest.java │ │ ├── BindingOrderTest.java │ │ ├── BindingTest.java │ │ ├── BoundInstanceInjectionTest.java │ │ ├── BoundProviderTest.java │ │ ├── CircularDependencyTest.java │ │ ├── DefaultMethodInterceptionTest.java │ │ ├── DuplicateBindingsTest.java │ │ ├── EagerSingletonTest.java │ │ ├── GenericInjectionTest.java │ │ ├── ImplicitBindingJdkPackagePrivateTest.java │ │ ├── ImplicitBindingTest.java │ │ ├── InjectorTest.java │ │ ├── IntegrationTest.java │ │ ├── Java8LanguageFeatureBindingTest.java │ │ ├── JitBindingsTest.java │ │ ├── KeyTest.java │ │ ├── KotlinSupportDoesNotBreakJavaTest.java │ │ ├── LoggerInjectionTest.java │ │ ├── MaxArityTest.java │ │ ├── MembersInjectorTest.java │ │ ├── MethodInterceptionTest.java │ │ ├── ModuleTest.java │ │ ├── ModulesTest.java │ │ ├── NullableInjectionPointTest.java │ │ ├── OptionalBindingTest.java │ │ ├── ParentInjectorTest.java │ │ ├── PrivateModuleTest.java │ │ ├── ProviderInjectionTest.java │ │ ├── ProvisionExceptionTest.java │ │ ├── ProvisionExceptionsTest.java │ │ ├── ProvisionListenerTest.java │ │ ├── ReflectionTest.java │ │ ├── RequestInjectionTest.java │ │ ├── RequireAtInjectOnConstructorsTest.java │ │ ├── RestrictedBindingSourceTest.java │ │ ├── ScopesTest.java │ │ ├── SerializationTest.java │ │ ├── SuiteUtils.java │ │ ├── SuperclassTest.java │ │ ├── TypeConversionTest.java │ │ ├── TypeListenerTest.java │ │ ├── TypeLiteralInjectionTest.java │ │ ├── TypeLiteralTest.java │ │ ├── TypeLiteralTypeResolutionTest.java │ │ ├── errors │ │ ├── BUILD │ │ ├── BindingAlreadySetErrorTest.java │ │ ├── ChildBindingAlreadySetErrorTest.java │ │ ├── DuplicateElementErrorTest.java │ │ ├── DuplicateMapKeyErrorTest.java │ │ ├── ErrorMessageTestUtils.java │ │ ├── ErrorMessagesTest.java │ │ ├── GenericErrorTest.java │ │ ├── MissingConstructorErrorTest.java │ │ ├── MissingImplementationErrorTest.java │ │ ├── NullInjectedIntoNonNullableTest.java │ │ ├── ScopeNotFoundErrorTest.java │ │ └── testdata │ │ │ ├── binding_already_set_errors_with_module_stack.txt │ │ │ ├── child_binding_already_set_by_just_in_time_binding.txt │ │ │ ├── child_binding_already_set_error.txt │ │ │ ├── child_binding_already_set_multiple_times_error.txt │ │ │ ├── class_names_are_compressed_in_error_message.txt │ │ │ ├── class_names_are_compressed_in_error_message_with_dot_annots.txt │ │ │ ├── custom_error.txt │ │ │ ├── duplicate_element_error.txt │ │ │ ├── duplicate_map_key_error.txt │ │ │ ├── duplicate_map_keys_error_class_key_is_not_compressed.txt │ │ │ ├── error_in_custom_provider.txt │ │ │ ├── error_injecting_constructor.txt │ │ │ ├── missing_constructor_errors.txt │ │ │ ├── missing_constructor_errors_at_inject_required.txt │ │ │ ├── missing_constructor_errors_merged.txt │ │ │ ├── missing_implementation_errors.txt │ │ │ ├── missing_implementation_errors_with_dot_annots.txt │ │ │ ├── missing_implementation_has_unnecessary_extends_clause.txt │ │ │ ├── missing_implementation_has_unnecessary_extends_clause_java.txt │ │ │ ├── missing_implementation_has_unnecessary_super_clause.txt │ │ │ ├── missing_implementation_has_unnecessary_super_clause_java.txt │ │ │ ├── missing_implementation_missing_extends_clause.txt │ │ │ ├── missing_implementation_missing_extends_clause_java.txt │ │ │ ├── missing_implementation_missing_super_clause.txt │ │ │ ├── missing_implementation_missing_super_clause_java.txt │ │ │ ├── missing_implementation_same_type_missing_annotation.txt │ │ │ ├── missing_implementation_with_hints.txt │ │ │ ├── missing_implementation_with_hints_with_dot_annots.txt │ │ │ ├── missing_implementation_with_mismatched_optionals.txt │ │ │ ├── missing_implementation_with_module_stack.txt │ │ │ ├── multiple_binding_already_set_errors.txt │ │ │ ├── multiple_child_binding_already_set_errors.txt │ │ │ ├── multiple_duplicate_elements_error.txt │ │ │ ├── multiple_duplicate_map_keys_error.txt │ │ │ ├── null_returned_from_provider.txt │ │ │ ├── null_returned_from_provider_with_module_stack.txt │ │ │ ├── null_returned_from_provides_method.txt │ │ │ ├── scope_not_found_error.txt │ │ │ └── single_binding_already_set_error.txt │ │ ├── example │ │ ├── ClientServiceWithDependencyInjection.java │ │ ├── ClientServiceWithFactories.java │ │ ├── ClientServiceWithGuice.java │ │ ├── ClientServiceWithGuiceDefaults.java │ │ ├── JndiProvider.java │ │ └── JndiProviderClient.java │ │ ├── internal │ │ ├── Collector.java │ │ ├── CycleDetectingLockTest.java │ │ ├── InternalContextTest.java │ │ ├── InternalFactoryTest.java │ │ ├── InternalMethodHandlesTest.java │ │ ├── InternalProvisionExceptionTest.java │ │ ├── LinkageContextTest.java │ │ ├── MapBinderTest.java │ │ ├── MessagesTest.java │ │ ├── MoreTypesTest.java │ │ ├── MultibinderTest.java │ │ ├── OptionalBinderTest.java │ │ ├── PackageNameCompressorTest.java │ │ ├── ProxyFactoryTest.java │ │ ├── RealElementTest.java │ │ ├── SimilarLookingTypesTest.java │ │ ├── SpiUtils.java │ │ ├── UniqueAnnotationsTest.java │ │ ├── WeakKeySetTest.java │ │ ├── WeakKeySetUtils.java │ │ ├── aop │ │ │ └── ImmutableStringTrieTest.java │ │ └── util │ │ │ ├── ContinuousStopwatchTest.java │ │ │ └── LineNumbersTest.java │ │ ├── matcher │ │ └── MatcherTest.java │ │ ├── multibindings │ │ └── ProvidesIntoTest.java │ │ ├── name │ │ ├── NamedEquivalanceTest.java │ │ └── NamesTest.java │ │ ├── spi │ │ ├── BindingSourceRestrictionTest.java │ │ ├── BindingTargetVisitorTest.java │ │ ├── ElementApplyToTest.java │ │ ├── ElementSourceTest.java │ │ ├── ElementsTest.java │ │ ├── FailingBindingScopingVisitor.java │ │ ├── FailingElementVisitor.java │ │ ├── FailingTargetVisitor.java │ │ ├── HasDependenciesTest.java │ │ ├── InjectionPointTest.java │ │ ├── InjectorSpiTest.java │ │ ├── MessageTest.java │ │ ├── ModuleAnnotatedMethodScannerTest.java │ │ ├── ModuleRewriterTest.java │ │ ├── ModuleSourceTest.java │ │ ├── ProviderMethodsTest.java │ │ ├── SourcesTest.java │ │ ├── SpiBindingsTest.java │ │ └── ToolStageInjectorTest.java │ │ └── util │ │ ├── EnhancedTest.java │ │ ├── NoopOverrideTest.java │ │ ├── OverrideModuleTest.java │ │ ├── ProvidersTest.java │ │ └── TypesTest.java │ └── googlecode │ └── guice │ ├── BUILD │ ├── BytecodeGenTest.java │ ├── GuiceJakartaTck.java │ ├── JakartaTest.java │ ├── OSGiContainerTest.java │ ├── PackageVisibilityTestModule.java │ └── bundle │ └── OSGiTestActivator.java ├── examples └── guice-demo │ ├── pom.xml │ └── src │ ├── main │ └── java │ │ └── com │ │ └── example │ │ ├── App.java │ │ └── Printer.java │ └── test │ └── java │ └── com │ └── example │ └── AppTest.java ├── extensions ├── assistedinject │ ├── .gitignore │ ├── build.properties │ ├── pom.xml │ ├── src │ │ └── com │ │ │ └── google │ │ │ └── inject │ │ │ └── assistedinject │ │ │ ├── Assisted.java │ │ │ ├── AssistedConstructor.java │ │ │ ├── AssistedInject.java │ │ │ ├── AssistedInjectBinding.java │ │ │ ├── AssistedInjectTargetVisitor.java │ │ │ ├── AssistedMethod.java │ │ │ ├── BUILD │ │ │ ├── BindingCollector.java │ │ │ ├── FactoryModuleBuilder.java │ │ │ ├── FactoryProvider.java │ │ │ ├── FactoryProvider2.java │ │ │ ├── Parameter.java │ │ │ ├── ParameterListKey.java │ │ │ ├── internal │ │ │ └── LookupTester.java │ │ │ └── package-info.java │ └── test │ │ └── com │ │ └── google │ │ └── inject │ │ └── assistedinject │ │ ├── BUILD │ │ ├── ExtensionSpiTest.java │ │ ├── FactoryModuleBuilderTest.java │ │ ├── FactoryProvider2Test.java │ │ ├── FactoryProviderTest.java │ │ ├── ManyConstructorsTest.java │ │ ├── StaticInterfaceMethodsTest.java │ │ └── subpkg │ │ ├── SubpackageTest.java │ │ └── SubpackageTestPrivateFallbackOnly.java ├── dagger-adapter │ ├── build.properties │ ├── pom.xml │ ├── src │ │ └── com │ │ │ └── google │ │ │ └── inject │ │ │ └── daggeradapter │ │ │ ├── Annotations.java │ │ │ ├── BUILD │ │ │ ├── DaggerAdapter.java │ │ │ ├── DaggerMethodScanner.java │ │ │ ├── Keys.java │ │ │ └── SupportedAnnotations.java │ └── test │ │ └── com │ │ └── google │ │ └── inject │ │ └── daggeradapter │ │ ├── BUILD │ │ ├── BindingSubject.java │ │ ├── BindsTest.java │ │ ├── DaggerAdapterTest.java │ │ ├── IntoMapTest.java │ │ ├── ModuleIncludesTest.java │ │ ├── ModuleSubcomponentsTest.java │ │ ├── MultibindsTest.java │ │ └── OptionalBindingsTest.java ├── grapher │ ├── build.properties │ ├── pom.xml │ ├── src │ │ └── com │ │ │ └── google │ │ │ └── inject │ │ │ └── grapher │ │ │ ├── AbstractInjectorGrapher.java │ │ │ ├── Alias.java │ │ │ ├── AliasCreator.java │ │ │ ├── BUILD │ │ │ ├── BindingEdge.java │ │ │ ├── DefaultEdgeCreator.java │ │ │ ├── DefaultNodeCreator.java │ │ │ ├── DefaultRootKeySetCreator.java │ │ │ ├── DependencyEdge.java │ │ │ ├── Edge.java │ │ │ ├── EdgeCreator.java │ │ │ ├── ImplementationNode.java │ │ │ ├── InjectorGrapher.java │ │ │ ├── InstanceNode.java │ │ │ ├── InterfaceNode.java │ │ │ ├── NameFactory.java │ │ │ ├── Node.java │ │ │ ├── NodeCreator.java │ │ │ ├── NodeId.java │ │ │ ├── ProviderAliasCreator.java │ │ │ ├── RootKeySetCreator.java │ │ │ ├── ShortNameFactory.java │ │ │ ├── TransitiveDependencyVisitor.java │ │ │ └── graphviz │ │ │ ├── ArrowType.java │ │ │ ├── CompassPoint.java │ │ │ ├── EdgeStyle.java │ │ │ ├── Graphviz.java │ │ │ ├── GraphvizEdge.java │ │ │ ├── GraphvizGrapher.java │ │ │ ├── GraphvizModule.java │ │ │ ├── GraphvizNode.java │ │ │ ├── NodeShape.java │ │ │ ├── NodeStyle.java │ │ │ ├── PortIdFactory.java │ │ │ └── PortIdFactoryImpl.java │ └── test │ │ └── com │ │ └── google │ │ └── inject │ │ └── grapher │ │ ├── AbstractInjectorGrapherTest.java │ │ ├── AllTests.java │ │ ├── BUILD │ │ ├── ShortNameFactoryTest.java │ │ ├── TransitiveDependencyVisitorTest.java │ │ └── demo │ │ ├── AssistedInjectModule.java │ │ ├── BackToTheFutureModule.java │ │ ├── DanceParty.java │ │ ├── DancePartyFactory.java │ │ ├── DancePartyImpl.java │ │ ├── DeLorian.java │ │ ├── DocBrown.java │ │ ├── Driver.java │ │ ├── EnergySource.java │ │ ├── EnergySourceProvider.java │ │ ├── FluxCapacitor.java │ │ ├── InjectorGrapherDemo.java │ │ ├── Inventor.java │ │ ├── Lightning.java │ │ ├── MartyMcFly.java │ │ ├── MultibinderModule.java │ │ ├── Nuclear.java │ │ ├── Person.java │ │ ├── PinballParts.java │ │ ├── Plutonium.java │ │ ├── PlutoniumProvider.java │ │ ├── PrivateTestModule.java │ │ ├── Renewable.java │ │ └── Used.java ├── jmx │ ├── .gitignore │ ├── build.properties │ ├── pom.xml │ ├── src │ │ └── com │ │ │ └── google │ │ │ └── inject │ │ │ └── tools │ │ │ └── jmx │ │ │ ├── BUILD │ │ │ ├── ManagedBinding.java │ │ │ ├── ManagedBindingMBean.java │ │ │ ├── Manager.java │ │ │ └── package-info.java │ └── test │ │ └── com │ │ └── google │ │ └── inject │ │ └── tools │ │ └── jmx │ │ ├── BUILD │ │ └── JmxTest.java ├── jndi │ ├── build.properties │ ├── pom.xml │ └── src │ │ └── com │ │ └── google │ │ └── inject │ │ └── jndi │ │ ├── BUILD │ │ ├── JndiIntegration.java │ │ └── package-info.java ├── persist │ ├── build.properties │ ├── pom.xml │ ├── src │ │ └── com │ │ │ └── google │ │ │ └── inject │ │ │ └── persist │ │ │ ├── BUILD │ │ │ ├── PersistFilter.java │ │ │ ├── PersistModule.java │ │ │ ├── PersistService.java │ │ │ ├── Transactional.java │ │ │ ├── UnitOfWork.java │ │ │ ├── finder │ │ │ ├── DynamicFinder.java │ │ │ ├── Finder.java │ │ │ ├── FirstResult.java │ │ │ ├── MaxResults.java │ │ │ └── package-info.java │ │ │ ├── jpa │ │ │ ├── Jpa.java │ │ │ ├── JpaFinderProxy.java │ │ │ ├── JpaLocalTxnInterceptor.java │ │ │ ├── JpaPersistModule.java │ │ │ ├── JpaPersistOptions.java │ │ │ ├── JpaPersistService.java │ │ │ └── package-info.java │ │ │ └── package-info.java │ └── test │ │ ├── META-INF │ │ └── persistence.xml │ │ ├── com │ │ └── google │ │ │ └── inject │ │ │ └── persist │ │ │ ├── AllTests.java │ │ │ ├── BUILD │ │ │ ├── EdslTest.java │ │ │ ├── config │ │ │ ├── BUILD │ │ │ └── META-INF │ │ │ │ └── persistence.xml │ │ │ └── jpa │ │ │ ├── ClassLevelManagedLocalTransactionsTest.java │ │ │ ├── CustomPropsEntityManagerFactoryProvisionTest.java │ │ │ ├── DynamicFinderTest.java │ │ │ ├── EnsureJpaCanTakeObjectsInPropertiesTest.java │ │ │ ├── EntityManagerFactoryProvisionTest.java │ │ │ ├── EntityManagerPerRequestProvisionTest.java │ │ │ ├── EntityManagerProvisionTest.java │ │ │ ├── JoiningLocalTransactionsTest.java │ │ │ ├── JpaParentTestEntity.java │ │ │ ├── JpaPersistServiceTest.java │ │ │ ├── JpaTestEntity.java │ │ │ ├── JpaWorkManagerTest.java │ │ │ ├── ManagedLocalTransactionsAcrossRequestTest.java │ │ │ ├── ManagedLocalTransactionsTest.java │ │ │ ├── ManualLocalTransactionsConfidenceTest.java │ │ │ ├── ManualLocalTransactionsTest.java │ │ │ ├── ManualLocalTransactionsWithCustomMatcherTest.java │ │ │ └── TrackedEntityManagerFactory.java │ │ └── log4j.properties ├── pom.xml ├── servlet │ ├── build.properties │ ├── pom.xml │ ├── src │ │ └── com │ │ │ └── google │ │ │ └── inject │ │ │ └── servlet │ │ │ ├── AbstractServletModuleBinding.java │ │ │ ├── BUILD │ │ │ ├── ContinuingHttpServletRequest.java │ │ │ ├── DefaultFilterPipeline.java │ │ │ ├── FilterChainInvocation.java │ │ │ ├── FilterDefinition.java │ │ │ ├── FilterPipeline.java │ │ │ ├── FiltersModuleBuilder.java │ │ │ ├── GuiceFilter.java │ │ │ ├── GuiceServletContextListener.java │ │ │ ├── InstanceFilterBinding.java │ │ │ ├── InstanceFilterBindingImpl.java │ │ │ ├── InstanceServletBinding.java │ │ │ ├── InstanceServletBindingImpl.java │ │ │ ├── InternalServletModule.java │ │ │ ├── LinkedFilterBinding.java │ │ │ ├── LinkedFilterBindingImpl.java │ │ │ ├── LinkedServletBinding.java │ │ │ ├── LinkedServletBindingImpl.java │ │ │ ├── ManagedFilterPipeline.java │ │ │ ├── ManagedServletPipeline.java │ │ │ ├── RequestParameters.java │ │ │ ├── RequestScoped.java │ │ │ ├── RequestScoper.java │ │ │ ├── ScopingException.java │ │ │ ├── ScopingOnly.java │ │ │ ├── ServletDefinition.java │ │ │ ├── ServletModule.java │ │ │ ├── ServletModuleBinding.java │ │ │ ├── ServletModuleTargetVisitor.java │ │ │ ├── ServletScopes.java │ │ │ ├── ServletUtils.java │ │ │ ├── ServletsModuleBuilder.java │ │ │ ├── SessionScoped.java │ │ │ ├── UriPatternMatcher.java │ │ │ ├── UriPatternType.java │ │ │ └── package-info.java │ └── test │ │ └── com │ │ └── google │ │ └── inject │ │ └── servlet │ │ ├── AllTests.java │ │ ├── BUILD │ │ ├── ContextPathTest.java │ │ ├── ContinuingHttpServletRequestTest.java │ │ ├── ContinuingRequestIntegrationTest.java │ │ ├── DummyFilterImpl.java │ │ ├── DummyServlet.java │ │ ├── EdslTest.java │ │ ├── ExtensionSpiTest.java │ │ ├── FilterDefinitionTest.java │ │ ├── FilterDispatchIntegrationTest.java │ │ ├── FilterPipelineTest.java │ │ ├── InjectedFilterPipelineTest.java │ │ ├── InvalidScopeBindingTest.java │ │ ├── MultiModuleDispatchIntegrationTest.java │ │ ├── MultipleServletInjectorsTest.java │ │ ├── ScopeRequestIntegrationTest.java │ │ ├── ServletDefinitionPathsTest.java │ │ ├── ServletDefinitionTest.java │ │ ├── ServletDispatchIntegrationTest.java │ │ ├── ServletModuleTest.java │ │ ├── ServletPipelineRequestDispatcherTest.java │ │ ├── ServletScopesTest.java │ │ ├── ServletSpiVisitor.java │ │ ├── ServletTest.java │ │ ├── ServletTestUtils.java │ │ ├── ServletUtilsTest.java │ │ ├── TransferRequestIntegrationTest.java │ │ ├── UriPatternTypeTest.java │ │ ├── VarargsFilterDispatchIntegrationTest.java │ │ └── VarargsServletDispatchIntegrationTest.java ├── spring │ ├── .gitignore │ ├── build.properties │ ├── pom.xml │ ├── src │ │ └── com │ │ │ └── google │ │ │ └── inject │ │ │ └── spring │ │ │ ├── BUILD │ │ │ ├── SpringIntegration.java │ │ │ └── package-info.java │ └── test │ │ └── com │ │ └── google │ │ └── inject │ │ └── spring │ │ ├── BUILD │ │ └── SpringIntegrationTest.java ├── struts2 │ ├── .gitignore │ ├── build.properties │ ├── example │ │ ├── build.properties │ │ ├── build.xml │ │ ├── root │ │ │ ├── Counter.jsp │ │ │ └── WEB-INF │ │ │ │ └── web.xml │ │ └── src │ │ │ ├── com │ │ │ └── google │ │ │ │ └── inject │ │ │ │ └── struts2 │ │ │ │ └── example │ │ │ │ ├── Count.java │ │ │ │ ├── Counter.java │ │ │ │ ├── ExampleListener.java │ │ │ │ ├── Main.java │ │ │ │ ├── Service.java │ │ │ │ └── ServiceImpl.java │ │ │ └── struts.xml │ ├── pom.xml │ ├── src │ │ ├── com │ │ │ └── google │ │ │ │ └── inject │ │ │ │ └── struts2 │ │ │ │ ├── BUILD │ │ │ │ ├── GuiceObjectFactory.java │ │ │ │ ├── Struts2Factory.java │ │ │ │ └── Struts2GuicePluginModule.java │ │ └── struts-plugin.xml │ └── test │ │ └── com │ │ └── google │ │ └── inject │ │ └── struts2 │ │ ├── BUILD │ │ └── Struts2FactoryTest.java ├── testlib │ ├── build.properties │ ├── pom.xml │ ├── src │ │ └── com │ │ │ └── google │ │ │ └── inject │ │ │ └── testing │ │ │ ├── BUILD │ │ │ ├── fieldbinder │ │ │ ├── BUILD │ │ │ ├── Bind.java │ │ │ └── BoundFieldModule.java │ │ │ └── throwingproviders │ │ │ ├── BUILD │ │ │ └── CheckedProviderSubject.java │ └── test │ │ └── com │ │ └── google │ │ └── inject │ │ └── testing │ │ ├── fieldbinder │ │ ├── BUILD │ │ ├── BoundFieldModuleTest.java │ │ └── TestPermit.java │ │ └── throwingproviders │ │ ├── BUILD │ │ └── CheckedProviderSubjectTest.java └── throwingproviders │ ├── build.properties │ ├── pom.xml │ ├── src │ └── com │ │ └── google │ │ └── inject │ │ └── throwingproviders │ │ ├── BUILD │ │ ├── CheckedProvideUtils.java │ │ ├── CheckedProvider.java │ │ ├── CheckedProviderMethod.java │ │ ├── CheckedProviderMethodsModule.java │ │ ├── CheckedProviderWithDependencies.java │ │ ├── CheckedProviders.java │ │ ├── CheckedProvides.java │ │ ├── ProviderChecker.java │ │ ├── ThrowingInject.java │ │ ├── ThrowingProvider.java │ │ ├── ThrowingProviderBinder.java │ │ └── package-info.java │ └── test │ └── com │ └── google │ └── inject │ └── throwingproviders │ ├── BUILD │ ├── CheckedProviderMethodsModuleTest.java │ ├── CheckedProviderTest.java │ ├── CheckedProvidersTest.java │ ├── TestScope.java │ └── ThrowingProviderTest.java ├── mvn.bzl ├── osgi.bzl ├── pom-template.xml ├── pom.xml ├── test_defs.bzl ├── third_party └── java │ ├── aopalliance │ └── BUILD │ ├── asm │ └── BUILD │ ├── auto │ └── BUILD │ ├── bnd │ └── BUILD │ ├── dagger │ └── BUILD │ ├── easymock │ └── BUILD │ ├── error_prone │ └── BUILD │ ├── guava │ ├── BUILD │ ├── annotations │ │ └── BUILD │ ├── base │ │ └── BUILD │ ├── cache │ │ └── BUILD │ ├── collect │ │ └── BUILD │ ├── escape │ │ └── BUILD │ ├── io │ │ └── BUILD │ ├── net │ │ └── BUILD │ ├── primitives │ │ └── BUILD │ ├── testing │ │ └── BUILD │ └── util │ │ └── concurrent │ │ └── BUILD │ ├── hamcrest │ └── BUILD │ ├── hibernate │ └── BUILD │ ├── hsqldb │ └── BUILD │ ├── jakarta_inject │ └── BUILD │ ├── jakarta_inject_tck │ └── BUILD │ ├── jakarta_persistence │ └── BUILD │ ├── jakarta_servlet_api │ └── BUILD │ ├── jspecify_annotations │ └── BUILD │ ├── jsr305_annotations │ └── BUILD │ ├── junit │ └── BUILD │ ├── mockito │ └── BUILD │ ├── picocli │ └── BUILD │ ├── spring │ └── BUILD │ ├── struts2 │ └── BUILD │ └── truth │ └── BUILD ├── tools ├── BUILD └── OsgiWrapper.java └── util ├── api-diffs.index.html ├── deploy-guice.sh ├── deploy-library.sh ├── diff-jars.sh ├── generate-latest-docs.sh ├── install-local-snapshot.sh └── publish-latest-docs.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Known text files 5 | *.java text 6 | *.xml text 7 | *.yml text 8 | *.md text 9 | *.properties text 10 | *.sh text 11 | 12 | # Known binary files 13 | *.jar binary 14 | *.gif binary 15 | -------------------------------------------------------------------------------- /.github/actions/bazel-build/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Bazel Build' 2 | description: 'Builds artifacts and creates local snapshots maven artifacts.' 3 | 4 | runs: 5 | using: "composite" 6 | steps: 7 | - name: 'Set up JDK' 8 | uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 9 | with: 10 | distribution: ${{ env.USE_JAVA_DISTRIBUTION }} 11 | java-version: ${{ env.USE_JAVA_VERSION }} 12 | - name: 'Check out repository' 13 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 14 | - name: 'Cache Bazel files' 15 | uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf 16 | with: 17 | path: ~/.cache/bazel 18 | key: ${{ runner.os }}-bazel-build-${{ hashFiles('**/WORKSPACE') }} 19 | restore-keys: | 20 | ${{ runner.os }}-bazel-build- 21 | - name: 'Bazel build' 22 | # Cross compile for Java 11, see http://openjdk.java.net/jeps/247 23 | run: bazel build --javacopt="--release 11" //... 24 | shell: bash 25 | - name: 'Install local snapshot' 26 | run: ./util/install-local-snapshot.sh 27 | shell: bash 28 | - name: 'Upload local snapshot for local mvn artifiact tests' 29 | uses: actions/upload-artifact@v4 30 | with: 31 | name: local-snapshot 32 | path: ~/.m2/repository/com/google/inject 33 | -------------------------------------------------------------------------------- /.github/actions/bazel-test/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Bazel Tests' 2 | description: 'Runs all tests using bazel.' 3 | 4 | runs: 5 | using: "composite" 6 | steps: 7 | - name: Set up JDK 8 | uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 9 | with: 10 | java-version: ${{ matrix.java }} 11 | distribution: ${{ env.USE_JAVA_DISTRIBUTION }} 12 | - name: 'Cache bazel files' 13 | uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf 14 | with: 15 | path: ~/.cache/bazel 16 | key: ${{ runner.os }}-java-${{matrix.java}}-bazel-test-${{ hashFiles('**/WORKSPACE') }} 17 | restore-keys: | 18 | ${{ runner.os }}-java-${{matrix.java}}-bazel-test- 19 | - name: Bazel test 20 | run: bazel test --javacopt="--release 11" //... --test_output=errors 21 | shell: bash 22 | -------------------------------------------------------------------------------- /.github/actions/local-artifact-tests/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Local Artifact Tests' 2 | description: 'Runs local tests on the installed Guice LOCAL-SNAPSHOT artifacts.' 3 | 4 | runs: 5 | using: "composite" 6 | steps: 7 | - name: 'Set up JDK' 8 | uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 9 | with: 10 | distribution: ${{ env.USE_JAVA_DISTRIBUTION }} 11 | java-version: ${{ env.USE_JAVA_VERSION }} 12 | - name: 'Cache Maven files' 13 | uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf 14 | with: 15 | path: ~/.m2/repository 16 | key: ${{ runner.os }}-artifact-tests-${{ hashFiles('examples/**/pom.xml') }} 17 | restore-keys: | 18 | ${{ runner.os }}-artifact-tests- 19 | - name: 'Delete any stale artifacts from cache' 20 | run: rm -rf ~/.m2/repository/com/google/inject 21 | shell: bash 22 | - name: 'Download local snapshot for tests' 23 | uses: actions/download-artifact@v4 24 | with: 25 | name: local-snapshot 26 | path: ~/.m2/repository/com/google/inject 27 | - name: 'Maven Java local tests' 28 | run: mvn -f examples/guice-demo/pom.xml verify -Dguice.version=LOCAL-SNAPSHOT --fail-at-end 29 | shell: bash 30 | - name: 'Clean up Maven cache' 31 | run: rm -rf ~/.m2/repository/com/google/inject 32 | shell: bash 33 | -------------------------------------------------------------------------------- /.github/actions/maven-test/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Maven Tests' 2 | description: 'Runs all tests using maven.' 3 | 4 | runs: 5 | using: "composite" 6 | steps: 7 | - name: Set up JDK 8 | uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 9 | with: 10 | java-version: ${{ matrix.java }} 11 | distribution: ${{ env.USE_JAVA_DISTRIBUTION }} 12 | - name: 'Cache local Maven repository' 13 | uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf 14 | with: 15 | path: ~/.m2/repository 16 | key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} 17 | restore-keys: | 18 | ${{ runner.os }}-maven- 19 | - name: Verify with Maven 20 | run: mvn -B verify --fail-at-end -Dsource.skip=true -Dmaven.javadoc.skip=true 21 | shell: bash 22 | -------------------------------------------------------------------------------- /.github/actions/publish-snapshot/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Publish Snapshot' 2 | description: 'Publish snapshot artifacts and latest API doc.' 3 | 4 | runs: 5 | using: "composite" 6 | steps: 7 | - name: Setup JDK 8 | uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 9 | with: 10 | distribution: ${{ env.USE_JAVA_DISTRIBUTION }} 11 | java-version: ${{ env.USE_JAVA_VERSION }} 12 | server-id: google-snapshots 13 | server-username: MAVEN_USERNAME 14 | server-password: MAVEN_PASSWORD 15 | - name: 'Cache local Maven repository' 16 | uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf 17 | with: 18 | path: ~/.m2/repository 19 | key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} 20 | restore-keys: | 21 | ${{ runner.os }}-maven- 22 | - name: Publish Javadoc 23 | run: | 24 | chmod +x util/publish-latest-docs.sh 25 | ./util/publish-latest-docs.sh 26 | shell: bash 27 | - name: Publish Snapshot 28 | run: mvn clean deploy -DskipTests=true -Dmaven.javadoc.skip=true 29 | shell: bash 30 | 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | bazel-* 3 | target/ 4 | bin/ 5 | .project 6 | .classpath 7 | .settings/ 8 | *~ 9 | *.orig 10 | *.new 11 | .idea/ 12 | *.iml 13 | *.ipr 14 | extensions/**/build/ -------------------------------------------------------------------------------- /build.properties: -------------------------------------------------------------------------------- 1 | module=com.google.inject 2 | imports=!org.objectweb.asm.* 3 | -------------------------------------------------------------------------------- /build_defs.bzl: -------------------------------------------------------------------------------- 1 | """This file defines constants used across the Guice build""" 2 | # Copyright (C) 2022 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | JAVAC_OPTS = [ 17 | "-Xdoclint:html,syntax", 18 | "-source", 19 | "11", 20 | "-target", 21 | "11", 22 | ] 23 | 24 | POM_VERSION = "${project.version}" 25 | -------------------------------------------------------------------------------- /core/src/com/google/inject/Exposed.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject; 18 | 19 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 20 | 21 | import java.lang.annotation.Documented; 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Accompanies a {@literal @}{@link com.google.inject.Provides Provides} method annotation in a 28 | * private module to indicate that the provided binding is exposed. 29 | * 30 | * @author jessewilson@google.com (Jesse Wilson) 31 | * @since 2.0 32 | */ 33 | @Target(ElementType.METHOD) 34 | @Retention(RUNTIME) 35 | @Documented 36 | public @interface Exposed {} 37 | -------------------------------------------------------------------------------- /core/src/com/google/inject/ImplementedBy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject; 18 | 19 | import static java.lang.annotation.ElementType.TYPE; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * A pointer to the default implementation of a type. 27 | * 28 | * @author crazybob@google.com (Bob Lee) 29 | */ 30 | @Retention(RUNTIME) 31 | @Target(TYPE) 32 | public @interface ImplementedBy { 33 | 34 | /** The implementation type. */ 35 | Class value(); 36 | } 37 | -------------------------------------------------------------------------------- /core/src/com/google/inject/OutOfScopeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject; 18 | 19 | /** 20 | * Thrown from {@link Provider#get} when an attempt is made to access a scoped object while the 21 | * scope in question is not currently active. 22 | * 23 | * @author kevinb@google.com (Kevin Bourrillion) 24 | * @since 2.0 25 | */ 26 | public final class OutOfScopeException extends RuntimeException { 27 | 28 | public OutOfScopeException(String message) { 29 | super(message); 30 | } 31 | 32 | public OutOfScopeException(String message, Throwable cause) { 33 | super(message, cause); 34 | } 35 | 36 | public OutOfScopeException(Throwable cause) { 37 | super(cause); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /core/src/com/google/inject/ProvidedBy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject; 18 | 19 | import static java.lang.annotation.ElementType.TYPE; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * A pointer to the default provider type for a type. 27 | * 28 | * @author crazybob@google.com (Bob Lee) 29 | */ 30 | @Retention(RUNTIME) 31 | @Target(TYPE) 32 | public @interface ProvidedBy { 33 | 34 | /** The implementation type. */ 35 | Class> value(); 36 | } 37 | -------------------------------------------------------------------------------- /core/src/com/google/inject/Provides.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject; 18 | 19 | import static java.lang.annotation.ElementType.METHOD; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import com.google.errorprone.annotations.Keep; 23 | import java.lang.annotation.Documented; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.Target; 26 | 27 | /** 28 | * Annotates methods of a {@link Module} to create a provider method binding. The method's return 29 | * type is bound to its returned value. Guice will pass dependencies to the method as parameters. 30 | * 31 | * @author crazybob@google.com (Bob Lee) 32 | * @since 2.0 33 | */ 34 | @Documented 35 | @Target(METHOD) 36 | @Retention(RUNTIME) 37 | @Keep 38 | public @interface Provides {} 39 | -------------------------------------------------------------------------------- /core/src/com/google/inject/Singleton.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject; 18 | 19 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 20 | 21 | import java.lang.annotation.ElementType; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Apply this to implementation classes when you want only one instance (per {@link Injector}) to be 27 | * reused for all injections for that binding. 28 | * 29 | * @author crazybob@google.com (Bob Lee) 30 | */ 31 | @Target({ElementType.TYPE, ElementType.METHOD}) 32 | @Retention(RUNTIME) 33 | @ScopeAnnotation 34 | public @interface Singleton {} 35 | -------------------------------------------------------------------------------- /core/src/com/google/inject/binder/AnnotatedBindingBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.binder; 18 | 19 | import java.lang.annotation.Annotation; 20 | 21 | /** 22 | * See the EDSL examples at {@link com.google.inject.Binder}. 23 | * 24 | * @author crazybob@google.com (Bob Lee) 25 | */ 26 | public interface AnnotatedBindingBuilder extends LinkedBindingBuilder { 27 | 28 | /** See the EDSL examples at {@link com.google.inject.Binder}. */ 29 | LinkedBindingBuilder annotatedWith(Class annotationType); 30 | 31 | /** See the EDSL examples at {@link com.google.inject.Binder}. */ 32 | LinkedBindingBuilder annotatedWith(Annotation annotation); 33 | } 34 | -------------------------------------------------------------------------------- /core/src/com/google/inject/binder/AnnotatedConstantBindingBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.binder; 18 | 19 | import java.lang.annotation.Annotation; 20 | 21 | /** 22 | * See the EDSL examples at {@link com.google.inject.Binder}. 23 | * 24 | * @author crazybob@google.com (Bob Lee) 25 | */ 26 | public interface AnnotatedConstantBindingBuilder { 27 | 28 | /** See the EDSL examples at {@link com.google.inject.Binder}. */ 29 | ConstantBindingBuilder annotatedWith(Class annotationType); 30 | 31 | /** See the EDSL examples at {@link com.google.inject.Binder}. */ 32 | ConstantBindingBuilder annotatedWith(Annotation annotation); 33 | } 34 | -------------------------------------------------------------------------------- /core/src/com/google/inject/binder/AnnotatedElementBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.binder; 18 | 19 | import java.lang.annotation.Annotation; 20 | 21 | /** 22 | * See the EDSL examples at {@link com.google.inject.Binder}. 23 | * 24 | * @author jessewilson@google.com (Jesse Wilson) 25 | * @since 2.0 26 | */ 27 | public interface AnnotatedElementBuilder { 28 | 29 | /** See the EDSL examples at {@link com.google.inject.Binder}. */ 30 | void annotatedWith(Class annotationType); 31 | 32 | /** See the EDSL examples at {@link com.google.inject.Binder}. */ 33 | void annotatedWith(Annotation annotation); 34 | } 35 | -------------------------------------------------------------------------------- /core/src/com/google/inject/binder/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** Interfaces which make up {@link com.google.inject.Binder}'s expression language. */ 18 | package com.google.inject.binder; 19 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/ConstructionProxyFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.internal; 18 | 19 | /** 20 | * Creates {@link ConstructionProxy} instances. 21 | * 22 | * @author crazybob@google.com (Bob Lee) 23 | */ 24 | interface ConstructionProxyFactory { 25 | 26 | /** Gets a construction proxy for the given constructor. */ 27 | ConstructionProxy create() throws ErrorsException; 28 | } 29 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/CreationListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.internal; 18 | 19 | /** Something that is notified upon creation. */ 20 | interface CreationListener { 21 | 22 | /** Notifies that creation should happen. */ 23 | void notify(Errors errors); 24 | } 25 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/DelayedInitialize.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.internal; 18 | 19 | /** 20 | * Something that needs some delayed initialization, typically a binding or internal factory that 21 | * needs to be created; put into the bindings map and then initialized later. 22 | * 23 | * @author sameb@google.com (Sam Berlin) 24 | */ 25 | interface DelayedInitialize { 26 | 27 | /** Initializes this binding, throwing any errors if necessary. */ 28 | void initialize(InjectorImpl injector, Errors errors) throws ErrorsException; 29 | } 30 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/ErrorFormatter.java: -------------------------------------------------------------------------------- 1 | package com.google.inject.internal; 2 | 3 | import java.util.Formatter; 4 | import java.util.List; 5 | 6 | /** Helper for formatting Guice errors. */ 7 | final class ErrorFormatter { 8 | private ErrorFormatter() {} 9 | 10 | /** 11 | * Format a list of sources to the given {@code formatter}, prefixed by the give {@code index}. 12 | */ 13 | static void formatSources(int index, List sources, Formatter formatter) { 14 | for (int i = 0; i < sources.size(); i++) { 15 | Object source = sources.get(i); 16 | if (i == 0) { 17 | formatter.format("%-3s: ", index); 18 | } else { 19 | formatter.format(SourceFormatter.INDENT); 20 | } 21 | new SourceFormatter(source, formatter, i == 0).format(); 22 | } 23 | } 24 | 25 | /** Format a list of sources to the given {@code formatter}. */ 26 | static void formatSources(List sources, Formatter formatter) { 27 | for (int i = 0; i < sources.size(); i++) { 28 | Object source = sources.get(i); 29 | formatter.format(" "); 30 | new SourceFormatter(source, formatter, i == 0).format(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/ErrorHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.internal; 18 | 19 | import com.google.inject.spi.Message; 20 | 21 | /** 22 | * Handles errors in the Injector. 23 | * 24 | * @author crazybob@google.com (Bob Lee) 25 | */ 26 | interface ErrorHandler { 27 | 28 | /** Handles an error. */ 29 | void handle(Object source, Errors errors); 30 | 31 | /** Handles a user-reported error. */ 32 | void handle(Message message); 33 | } 34 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/GuiceInternal.java: -------------------------------------------------------------------------------- 1 | package com.google.inject.internal; 2 | 3 | /** 4 | * Class used for restricting APIs in other packages to only be used by this package. 5 | * 6 | *

Other packages can reference this class but only this package can reference an instance of it, 7 | * so adding this class as a method param ensures that only this package can call it (provided null 8 | * is disallowed). 9 | */ 10 | public final class GuiceInternal { 11 | static final GuiceInternal GUICE_INTERNAL = new GuiceInternal(); 12 | 13 | private GuiceInternal() {} 14 | } 15 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/Initializable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.internal; 18 | 19 | /** 20 | * Holds a reference that requires initialization to be performed before it can be used. 21 | * 22 | * @author jessewilson@google.com (Jesse Wilson) 23 | */ 24 | interface Initializable { 25 | 26 | /** Ensures the reference is initialized, then returns it. */ 27 | T get(InternalContext context) throws InternalProvisionException; 28 | } 29 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/InternalClassesToSkipSources.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.internal; 18 | 19 | import com.google.common.collect.ImmutableSet; 20 | 21 | /** Returns internal classes that should be skipped when calculating sources. */ 22 | public final class InternalClassesToSkipSources { 23 | 24 | private InternalClassesToSkipSources() {} 25 | 26 | public static ImmutableSet> classesToSkipSources() { 27 | return ImmutableSet.of( 28 | RealMapBinder.class, 29 | RealMapBinder.MultimapBinder.class, 30 | RealMultibinder.class, 31 | RealOptionalBinder.class, 32 | ProviderMethodsModule.class); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/Lookups.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.internal; 18 | 19 | import com.google.inject.Key; 20 | import com.google.inject.MembersInjector; 21 | import com.google.inject.Provider; 22 | import com.google.inject.TypeLiteral; 23 | 24 | /** 25 | * Accessors for providers and members injectors. The returned values will not be functional until 26 | * the injector has been created. 27 | * 28 | * @author jessewilson@google.com (Jesse Wilson) 29 | */ 30 | interface Lookups { 31 | 32 | Provider getProvider(Key key); 33 | 34 | MembersInjector getMembersInjector(TypeLiteral type); 35 | } 36 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/ModuleAnnotatedMethodScannerProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.internal; 18 | 19 | import com.google.inject.spi.ModuleAnnotatedMethodScannerBinding; 20 | 21 | /** 22 | * Handles {@code Binder.scanModulesForAnnotatedMethods} commands. 23 | * 24 | * @author sameb@google.com (Sam Berlin) 25 | */ 26 | final class ModuleAnnotatedMethodScannerProcessor extends AbstractProcessor { 27 | 28 | ModuleAnnotatedMethodScannerProcessor(Errors errors) { 29 | super(errors); 30 | } 31 | 32 | @Override 33 | public Boolean visit(ModuleAnnotatedMethodScannerBinding command) { 34 | injector.getBindingData().addScanner(command); 35 | return true; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/SingleMemberInjector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.internal; 18 | 19 | import com.google.inject.spi.InjectionPoint; 20 | import java.lang.invoke.MethodHandle; 21 | 22 | /** Injects a field or method of a given object. */ 23 | interface SingleMemberInjector { 24 | void inject(InternalContext context, Object o) throws InternalProvisionException; 25 | 26 | /** 27 | * Returns a method handle for injecting the member. 28 | * 29 | *

The signature is {@code (Object, InternalContext) -> void} where the first parameter is the 30 | * instance to inject into. 31 | */ 32 | MethodHandle getInjectHandle(LinkageContext linkageContext); 33 | 34 | InjectionPoint getInjectionPoint(); 35 | } 36 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/aop/ClassDefiner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.internal.aop; 18 | 19 | /** Defines dynamically generated classes. */ 20 | interface ClassDefiner { 21 | 22 | /** Defines a new class relative to the host. */ 23 | Class define(Class hostClass, byte[] bytecode) throws Exception; 24 | } 25 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/aop/GeneratedClassDefiner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.internal.aop; 18 | 19 | import java.util.function.BiFunction; 20 | 21 | /** 22 | * {@link ClassDefiner} that defines classes using a generated access function. 23 | * 24 | * @author mcculls@gmail.com (Stuart McCulloch) 25 | */ 26 | final class GeneratedClassDefiner implements ClassDefiner { 27 | 28 | private final BiFunction> defineAccess; 29 | 30 | GeneratedClassDefiner(BiFunction> defineAccess) { 31 | this.defineAccess = defineAccess; 32 | } 33 | 34 | @Override 35 | public Class define(Class hostClass, byte[] bytecode) { 36 | return defineAccess.apply(hostClass.getClassLoader(), bytecode); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/aop/GlueException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.internal.aop; 18 | 19 | /** Thrown when errors occur defining enhancer/fast-class glue. */ 20 | final class GlueException extends RuntimeException { 21 | public GlueException(String message, Throwable cause) { 22 | super(message, cause); 23 | } 24 | 25 | private static final long serialVersionUID = 0; 26 | } 27 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** Guice (sounds like "juice") */ 18 | package com.google.inject.internal; 19 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/util/CallerFinder.java: -------------------------------------------------------------------------------- 1 | package com.google.inject.internal.util; 2 | 3 | import java.util.function.Predicate; 4 | 5 | /** 6 | * An interface around finding the caller of the stack trace, so we can have different strategies 7 | * for implementing it. 8 | */ 9 | interface CallerFinder { 10 | StackTraceElement findCaller(Predicate shouldBeSkipped); 11 | } 12 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/util/DirectStackWalkerFinder.java: -------------------------------------------------------------------------------- 1 | package com.google.inject.internal.util; 2 | 3 | import java.util.function.Predicate; 4 | 5 | /** A CallerFinder directly compiled against StackWalker. Requires compiling against jdk11+. */ 6 | final class DirectStackWalkerFinder implements CallerFinder { 7 | private static final StackWalker WALKER = 8 | StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); 9 | 10 | @Override 11 | public StackTraceElement findCaller(Predicate shouldBeSkipped) { 12 | return WALKER 13 | .walk(s -> s.skip(2).filter(f -> !shouldBeSkipped.test(f.getClassName())).findFirst()) 14 | .map(StackWalker.StackFrame::toStackTraceElement) 15 | .orElseThrow(AssertionError::new); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /core/src/com/google/inject/internal/util/NewThrowableFinder.java: -------------------------------------------------------------------------------- 1 | package com.google.inject.internal.util; 2 | 3 | import java.util.function.Predicate; 4 | 5 | /** A CallerFinder that construcst a new Throwable and iterates through its stack trace. */ 6 | class NewThrowableFinder implements CallerFinder { 7 | @Override 8 | public StackTraceElement findCaller(Predicate shouldBeSkipped) { 9 | StackTraceElement[] stackTraceElements = new Throwable().getStackTrace(); 10 | for (StackTraceElement element : stackTraceElements) { 11 | String className = element.getClassName(); 12 | if (!shouldBeSkipped.test(className)) { 13 | return element; 14 | } 15 | } 16 | throw new AssertionError(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/com/google/inject/matcher/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** Used for matching things. Primarily used to pick out methods to which to apply interceptors. */ 18 | package com.google.inject.matcher; 19 | -------------------------------------------------------------------------------- /core/src/com/google/inject/multibindings/ClassMapKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.multibindings; 18 | 19 | import static java.lang.annotation.ElementType.METHOD; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Documented; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Allows {@literal @}{@link ProvidesIntoMap} to specify a class map key. 28 | * 29 | * @since 4.0 30 | */ 31 | @MapKey(unwrapValue = true) 32 | @Documented 33 | @Target(METHOD) 34 | @Retention(RUNTIME) 35 | public @interface ClassMapKey { 36 | Class value(); 37 | } 38 | -------------------------------------------------------------------------------- /core/src/com/google/inject/multibindings/StringMapKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.multibindings; 18 | 19 | import static java.lang.annotation.ElementType.METHOD; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Documented; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Allows {@literal @}{@link ProvidesIntoMap} to specify a string map key. 28 | * 29 | * @since 4.0 30 | */ 31 | @MapKey(unwrapValue = true) 32 | @Documented 33 | @Target(METHOD) 34 | @Retention(RUNTIME) 35 | public @interface StringMapKey { 36 | String value(); 37 | } 38 | -------------------------------------------------------------------------------- /core/src/com/google/inject/multibindings/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Extension for binding multiple instances in a collection; this extension requires {@code 19 | * guice-multibindings.jar}. 20 | */ 21 | package com.google.inject.multibindings; 22 | -------------------------------------------------------------------------------- /core/src/com/google/inject/name/Named.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.name; 18 | 19 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 20 | 21 | import com.google.inject.BindingAnnotation; 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Annotates named things. 28 | * 29 | * @author crazybob@google.com (Bob Lee) 30 | */ 31 | @Retention(RUNTIME) 32 | @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) 33 | @BindingAnnotation 34 | public @interface Named { 35 | String value(); 36 | } 37 | -------------------------------------------------------------------------------- /core/src/com/google/inject/name/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** Support for binding to string-based names. */ 18 | package com.google.inject.name; 19 | -------------------------------------------------------------------------------- /core/src/com/google/inject/spi/ExposedBinding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.spi; 18 | 19 | import com.google.inject.Binder; 20 | import com.google.inject.Binding; 21 | 22 | /** 23 | * A binding to a key exposed from an enclosed private environment. 24 | * 25 | * @author jessewilson@google.com (Jesse Wilson) 26 | * @since 2.0 27 | */ 28 | public interface ExposedBinding extends Binding, HasDependencies { 29 | 30 | /** Returns the enclosed environment that holds the original binding. */ 31 | PrivateElements getPrivateElements(); 32 | 33 | /** Unsupported. Always throws {@link UnsupportedOperationException}. */ 34 | @Override 35 | void applyTo(Binder binder); 36 | } 37 | -------------------------------------------------------------------------------- /core/src/com/google/inject/spi/InjectionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.spi; 18 | 19 | /** 20 | * Listens for injections into instances of type {@code I}. Useful for performing further 21 | * injections, post-injection initialization, and more. 22 | * 23 | * @author crazybob@google.com (Bob Lee) 24 | * @author jessewilson@google.com (Jesse Wilson) 25 | * @since 2.0 26 | */ 27 | public interface InjectionListener { 28 | 29 | /** 30 | * Invoked by Guice after it injects the fields and methods of instance. 31 | * 32 | * @param injectee instance that Guice injected dependencies into 33 | */ 34 | void afterInjection(I injectee); 35 | } 36 | -------------------------------------------------------------------------------- /core/src/com/google/inject/spi/InstanceBinding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.spi; 18 | 19 | import com.google.inject.Binding; 20 | import java.util.Set; 21 | 22 | /** 23 | * A binding to a single instance. The same instance is returned for every injection. 24 | * 25 | * @author jessewilson@google.com (Jesse Wilson) 26 | * @since 2.0 27 | */ 28 | public interface InstanceBinding extends Binding, HasDependencies { 29 | 30 | /** Returns the user-supplied instance. */ 31 | T getInstance(); 32 | 33 | /** 34 | * Returns the field and method injection points of the instance, injected at injector-creation 35 | * time only. 36 | * 37 | * @return a possibly empty set 38 | */ 39 | Set getInjectionPoints(); 40 | } 41 | -------------------------------------------------------------------------------- /core/src/com/google/inject/spi/LinkedKeyBinding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.spi; 18 | 19 | import com.google.inject.Binding; 20 | import com.google.inject.Key; 21 | 22 | /** 23 | * A binding to a linked key. The other key's binding is used to resolve injections. 24 | * 25 | * @author jessewilson@google.com (Jesse Wilson) 26 | * @since 2.0 27 | */ 28 | public interface LinkedKeyBinding extends Binding { 29 | 30 | /** 31 | * Returns the linked key used to resolve injections. That binding can be retrieved from an 32 | * injector using {@link com.google.inject.Injector#getBinding(Key) Injector.getBinding(key)}. 33 | */ 34 | Key getLinkedKey(); 35 | } 36 | -------------------------------------------------------------------------------- /core/src/com/google/inject/spi/ProviderWithDependencies.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.spi; 18 | 19 | import com.google.inject.Provider; 20 | 21 | /** 22 | * A provider with dependencies on other injected types. If a {@link Provider} has dependencies that 23 | * aren't specified in injections, this interface should be used to expose all dependencies. 24 | * 25 | * @since 2.0 26 | */ 27 | public interface ProviderWithDependencies extends Provider, HasDependencies {} 28 | -------------------------------------------------------------------------------- /core/src/com/google/inject/spi/ProvidesMethodTargetVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.spi; 18 | 19 | import com.google.inject.Provides; 20 | 21 | /** 22 | * A visitor for the {@literal @}{@link Provides} bindings. 23 | * 24 | *

If your {@link com.google.inject.spi.BindingTargetVisitor} implements this interface, bindings 25 | * created by using {@code @Provides} will be visited through this interface. 26 | * 27 | * @since 4.0 28 | * @author sameb@google.com (Sam Berlin) 29 | */ 30 | public interface ProvidesMethodTargetVisitor extends BindingTargetVisitor { 31 | 32 | /** 33 | * Visits an {@link ProvidesMethodBinding} created with an {@literal @}{@link Provides} method. 34 | */ 35 | V visit(ProvidesMethodBinding providesMethodBinding); 36 | } 37 | -------------------------------------------------------------------------------- /core/src/com/google/inject/spi/TypeConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.spi; 18 | 19 | import com.google.inject.TypeLiteral; 20 | 21 | /** 22 | * Converts constant string values to a different type. 23 | * 24 | * @author crazybob@google.com (Bob Lee) 25 | * @since 2.0 26 | */ 27 | public interface TypeConverter { 28 | 29 | /** Converts a string value. Throws an exception if a conversion error occurs. */ 30 | Object convert(String value, TypeLiteral toType); 31 | } 32 | -------------------------------------------------------------------------------- /core/src/com/google/inject/spi/UntargettedBinding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.spi; 18 | 19 | import com.google.inject.Binding; 20 | 21 | /** 22 | * An untargetted binding. This binding indicates that the injector should use its implicit binding 23 | * strategies to resolve injections. 24 | * 25 | * @author jessewilson@google.com (Jesse Wilson) 26 | * @since 2.0 27 | */ 28 | public interface UntargettedBinding extends Binding {} 29 | -------------------------------------------------------------------------------- /core/src/com/google/inject/spi/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** Guice service provider interface */ 18 | package com.google.inject.spi; 19 | -------------------------------------------------------------------------------- /core/src/com/google/inject/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** Helper methods for working with Guice. */ 18 | package com.google.inject.util; 19 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/child_binding_already_set_by_just_in_time_binding.txt: -------------------------------------------------------------------------------- 1 | Guice configuration errors: 2 | 3 | 1) [Guice/ChildBindingAlreadySet]: Unable to create binding for ChildBindingAlreadySetErrorTest$DependsOnFoo because it was already configured on one or more child injectors or private modules. 4 | 5 | Bound at: 6 | 1 : as a just-in-time binding 7 | 2 : ChildBindingAlreadySetErrorTest$ChildModule4.configure(ChildBindingAlreadySetErrorTest.java:105) 8 | 9 | 1 error 10 | 11 | ====================== 12 | Full classname legend: 13 | ====================== 14 | ChildBindingAlreadySetErrorTest$ChildModule4: "com.google.inject.errors.ChildBindingAlreadySetErrorTest$ChildModule4" 15 | ChildBindingAlreadySetErrorTest$DependsOnFoo: "com.google.inject.errors.ChildBindingAlreadySetErrorTest$DependsOnFoo" 16 | ======================== 17 | End of classname legend: 18 | ======================== 19 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/child_binding_already_set_error.txt: -------------------------------------------------------------------------------- 1 | Guice configuration errors: 2 | 3 | 1) [Guice/ChildBindingAlreadySet]: Unable to create binding for ChildBindingAlreadySetErrorTest$Foo because it was already configured on one or more child injectors or private modules. 4 | 5 | Bound at: 6 | 1 : ChildBindingAlreadySetErrorTest$ChildModule.configure(ChildBindingAlreadySetErrorTest.java:34) 7 | 8 | 1 error 9 | 10 | ====================== 11 | Full classname legend: 12 | ====================== 13 | ChildBindingAlreadySetErrorTest$ChildModule: "com.google.inject.errors.ChildBindingAlreadySetErrorTest$ChildModule" 14 | ChildBindingAlreadySetErrorTest$Foo: "com.google.inject.errors.ChildBindingAlreadySetErrorTest$Foo" 15 | ======================== 16 | End of classname legend: 17 | ======================== 18 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/child_binding_already_set_multiple_times_error.txt: -------------------------------------------------------------------------------- 1 | Guice configuration errors: 2 | 3 | 1) [Guice/ChildBindingAlreadySet]: Unable to create binding for ChildBindingAlreadySetErrorTest$Foo because it was already configured on one or more child injectors or private modules. 4 | 5 | Bound at: 6 | 1 : ChildBindingAlreadySetErrorTest$ChildModule.configure(ChildBindingAlreadySetErrorTest.java:34) 7 | 2 : ChildBindingAlreadySetErrorTest$ChildModule2.provideFoo() 8 | 9 | Requested by: 10 | 1 : ChildBindingAlreadySetErrorTest$DependsOnFoo 11 | at ChildBindingAlreadySetErrorTest$DependsOnFoo.(ChildBindingAlreadySetErrorTest.java:58) 12 | \_ for 1st parameter foo 13 | 14 | 1 error 15 | 16 | ====================== 17 | Full classname legend: 18 | ====================== 19 | ChildBindingAlreadySetErrorTest$ChildModule: "com.google.inject.errors.ChildBindingAlreadySetErrorTest$ChildModule" 20 | ChildBindingAlreadySetErrorTest$ChildModule2: "com.google.inject.errors.ChildBindingAlreadySetErrorTest$ChildModule2" 21 | ChildBindingAlreadySetErrorTest$DependsOnFoo: "com.google.inject.errors.ChildBindingAlreadySetErrorTest$DependsOnFoo" 22 | ChildBindingAlreadySetErrorTest$Foo: "com.google.inject.errors.ChildBindingAlreadySetErrorTest$Foo" 23 | ======================== 24 | End of classname legend: 25 | ======================== 26 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/custom_error.txt: -------------------------------------------------------------------------------- 1 | Unable to create injector, see the following errors: 2 | 3 | 1) Custom error 4 | at GenericErrorTest$ErrorModule.configure(GenericErrorTest.java:22) 5 | 6 | 1 error 7 | 8 | ====================== 9 | Full classname legend: 10 | ====================== 11 | GenericErrorTest$ErrorModule: "com.google.inject.errors.GenericErrorTest$ErrorModule" 12 | ======================== 13 | End of classname legend: 14 | ======================== 15 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/duplicate_element_error.txt: -------------------------------------------------------------------------------- 1 | Unable to provision, see the following errors: 2 | 3 | 1) [Guice/DuplicateElement]: Duplicate elements found in Multibinder Set. 4 | 5 | Duplicates: 6 | 1 : Element: element 7 | Bound at: 8 | 1 : DuplicateElementErrorTest$DuplicateElementModule.configure(DuplicateElementErrorTest.java:37) 9 | 2 : DuplicateElementErrorTest$DuplicateElementModule.provideFirst(DuplicateElementErrorTest.java:27) 10 | 3 : DuplicateElementErrorTest$DuplicateElementModule.provideSecond(DuplicateElementErrorTest.java:32) 11 | 12 | Multibinder declared at: 13 | DuplicateElementErrorTest$DuplicateElementModule.configure(DuplicateElementErrorTest.java:37) 14 | \_ installed by: DuplicateElementErrorTest$DuplicateElementModule -> RealMultibinder 15 | 16 | Learn more: 17 | https://github.com/google/guice/wiki/DUPLICATE_ELEMENT 18 | 19 | 1 error 20 | 21 | ====================== 22 | Full classname legend: 23 | ====================== 24 | DuplicateElementErrorTest$DuplicateElementModule: "com.google.inject.errors.DuplicateElementErrorTest$DuplicateElementModule" 25 | RealMultibinder: "com.google.inject.internal.RealMultibinder" 26 | ======================== 27 | End of classname legend: 28 | ======================== 29 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/duplicate_map_key_error.txt: -------------------------------------------------------------------------------- 1 | Unable to create injector, see the following errors: 2 | 3 | 1) [Guice/DuplicateMapKey]: Duplicate key "first" found in Map. 4 | 5 | Duplicates: 6 | Key: "first" 7 | Bound at: 8 | 1 : DuplicateMapKeyErrorTest$MapModule.configure(DuplicateMapKeyErrorTest.java:32) 9 | 2 : DuplicateMapKeyErrorTest$MapModule.configure(DuplicateMapKeyErrorTest.java:33) 10 | 3 : DuplicateMapKeyErrorTest$ContributorModule.provideFirstIntoMap(DuplicateMapKeyErrorTest.java:47) 11 | 12 | MapBinder declared at: 13 | DuplicateMapKeyErrorTest$MapModule.configure(DuplicateMapKeyErrorTest.java:31) 14 | \_ installed by: DuplicateMapKeyErrorTest$MapModule -> RealMapBinder 15 | 16 | 1 error 17 | 18 | ====================== 19 | Full classname legend: 20 | ====================== 21 | DuplicateMapKeyErrorTest$ContributorModule: "com.google.inject.errors.DuplicateMapKeyErrorTest$ContributorModule" 22 | DuplicateMapKeyErrorTest$MapModule: "com.google.inject.errors.DuplicateMapKeyErrorTest$MapModule" 23 | RealMapBinder: "com.google.inject.internal.RealMapBinder" 24 | ======================== 25 | End of classname legend: 26 | ======================== 27 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/duplicate_map_keys_error_class_key_is_not_compressed.txt: -------------------------------------------------------------------------------- 1 | Unable to create injector, see the following errors: 2 | 3 | 1) [Guice/DuplicateMapKey]: Duplicate key "class com.google.inject.errors.DuplicateMapKeyErrorTest$Foo" found in Map, String>. 4 | 5 | Duplicates: 6 | Key: "class com.google.inject.errors.DuplicateMapKeyErrorTest$Foo" 7 | Bound at: 8 | 1 : DuplicateMapKeyErrorTest$ClassKeyMapBinderModule.provideFoo(DuplicateMapKeyErrorTest.java:104) 9 | 2 : DuplicateMapKeyErrorTest$ClassKeyMapBinderModule.provideFoo2(DuplicateMapKeyErrorTest.java:110) 10 | 11 | MapBinder declared at: 12 | DuplicateMapKeyErrorTest$ClassKeyMapBinderModule.provideFoo(DuplicateMapKeyErrorTest.java:104) 13 | \_ installed by: DuplicateMapKeyErrorTest$ClassKeyMapBinderModule -> RealMapBinder 14 | 15 | 1 error 16 | 17 | ====================== 18 | Full classname legend: 19 | ====================== 20 | DuplicateMapKeyErrorTest$ClassKeyMapBinderModule: "com.google.inject.errors.DuplicateMapKeyErrorTest$ClassKeyMapBinderModule" 21 | RealMapBinder: "com.google.inject.internal.RealMapBinder" 22 | ======================== 23 | End of classname legend: 24 | ======================== 25 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/error_in_custom_provider.txt: -------------------------------------------------------------------------------- 1 | Unable to provision, see the following errors: 2 | 3 | 1) [Guice/ErrorInCustomProvider]: RuntimeException: can't do that 4 | at GenericErrorTest$ProvisionErrorModule.provideString(GenericErrorTest.java:36) 5 | while locating String 6 | 7 | Learn more: 8 | https://github.com/google/guice/wiki/ERROR_IN_CUSTOM_PROVIDER 9 | 10 | 1 error 11 | 12 | ====================== 13 | Full classname legend: 14 | ====================== 15 | GenericErrorTest$ProvisionErrorModule: "com.google.inject.errors.GenericErrorTest$ProvisionErrorModule" 16 | ======================== 17 | End of classname legend: 18 | ======================== 19 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/error_injecting_constructor.txt: -------------------------------------------------------------------------------- 1 | Unable to provision, see the following errors: 2 | 3 | 1) [Guice/ErrorInjectingConstructor]: RuntimeException: bad 4 | at GenericErrorTest$BadConstructor.(GenericErrorTest.java:27) 5 | at GenericErrorTest$ProvisionErrorModule.provideObject(GenericErrorTest.java:41) 6 | \_ for 1st parameter bad 7 | at GenericErrorTest$ProvisionErrorModule.provideObject(GenericErrorTest.java:41) 8 | while locating Object 9 | 10 | Learn more: 11 | https://github.com/google/guice/wiki/ERROR_INJECTING_CONSTRUCTOR 12 | 13 | 1 error 14 | 15 | ====================== 16 | Full classname legend: 17 | ====================== 18 | GenericErrorTest$BadConstructor: "com.google.inject.errors.GenericErrorTest$BadConstructor" 19 | GenericErrorTest$ProvisionErrorModule: "com.google.inject.errors.GenericErrorTest$ProvisionErrorModule" 20 | ======================== 21 | End of classname legend: 22 | ======================== 23 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/missing_implementation_has_unnecessary_extends_clause_java.txt: -------------------------------------------------------------------------------- 1 | Unable to create injector, see the following errors: 2 | 3 | 1) [Guice/MissingImplementation]: No implementation for List was bound. 4 | 5 | Did you mean? 6 | * List bound at MissingImplementationErrorTest$InjectionHasUnnecessaryExtendsClauseModule.provideString(MissingImplementationErrorTest.java:293) 7 | 8 | Requested by: 9 | 1 : MissingImplementationErrorTest$InjectionHasUnnecessaryExtendsClauseModule.provideInteger(MissingImplementationErrorTest.java:298) 10 | \_ for 1st parameter dep 11 | at MissingImplementationErrorTest$InjectionHasUnnecessaryExtendsClauseModule.provideInteger(MissingImplementationErrorTest.java:298) 12 | 13 | Learn more: 14 | https://github.com/google/guice/wiki/MISSING_IMPLEMENTATION 15 | 16 | 1 error 17 | 18 | ====================== 19 | Full classname legend: 20 | ====================== 21 | MissingImplementationErrorTest$InjectionHasUnnecessaryExtendsClauseModule: "com.google.inject.errors.MissingImplementationErrorTest$InjectionHasUnnecessaryExtendsClauseModule" 22 | ======================== 23 | End of classname legend: 24 | ======================== 25 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/missing_implementation_has_unnecessary_super_clause_java.txt: -------------------------------------------------------------------------------- 1 | Unable to create injector, see the following errors: 2 | 3 | 1) [Guice/MissingImplementation]: No implementation for List was bound. 4 | 5 | Did you mean? 6 | * List bound at MissingImplementationErrorTest$InjectionHasUnnecessarySuperClauseModule.provideString(MissingImplementationErrorTest.java:318) 7 | 8 | Requested by: 9 | 1 : MissingImplementationErrorTest$InjectionHasUnnecessarySuperClauseModule.provideInteger(MissingImplementationErrorTest.java:323) 10 | \_ for 1st parameter dep 11 | at MissingImplementationErrorTest$InjectionHasUnnecessarySuperClauseModule.provideInteger(MissingImplementationErrorTest.java:323) 12 | 13 | Learn more: 14 | https://github.com/google/guice/wiki/MISSING_IMPLEMENTATION 15 | 16 | 1 error 17 | 18 | ====================== 19 | Full classname legend: 20 | ====================== 21 | MissingImplementationErrorTest$InjectionHasUnnecessarySuperClauseModule: "com.google.inject.errors.MissingImplementationErrorTest$InjectionHasUnnecessarySuperClauseModule" 22 | ======================== 23 | End of classname legend: 24 | ======================== 25 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/missing_implementation_missing_extends_clause_java.txt: -------------------------------------------------------------------------------- 1 | Unable to create injector, see the following errors: 2 | 3 | 1) [Guice/MissingImplementation]: No implementation for List was bound. 4 | 5 | Did you mean? 6 | * List bound at MissingImplementationErrorTest$InjectionMissingExtendsClauseModule.provideString(MissingImplementationErrorTest.java:243) 7 | 8 | Requested by: 9 | 1 : MissingImplementationErrorTest$InjectionMissingExtendsClauseModule.provideInteger(MissingImplementationErrorTest.java:248) 10 | \_ for 1st parameter dep 11 | at MissingImplementationErrorTest$InjectionMissingExtendsClauseModule.provideInteger(MissingImplementationErrorTest.java:248) 12 | 13 | Learn more: 14 | https://github.com/google/guice/wiki/MISSING_IMPLEMENTATION 15 | 16 | 1 error 17 | 18 | ====================== 19 | Full classname legend: 20 | ====================== 21 | MissingImplementationErrorTest$InjectionMissingExtendsClauseModule: "com.google.inject.errors.MissingImplementationErrorTest$InjectionMissingExtendsClauseModule" 22 | ======================== 23 | End of classname legend: 24 | ======================== 25 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/missing_implementation_missing_super_clause_java.txt: -------------------------------------------------------------------------------- 1 | Unable to create injector, see the following errors: 2 | 3 | 1) [Guice/MissingImplementation]: No implementation for List was bound. 4 | 5 | Did you mean? 6 | * List bound at MissingImplementationErrorTest$InjectionMissingSuperClauseModule.provideString(MissingImplementationErrorTest.java:268) 7 | 8 | Requested by: 9 | 1 : MissingImplementationErrorTest$InjectionMissingSuperClauseModule.provideInteger(MissingImplementationErrorTest.java:273) 10 | \_ for 1st parameter dep 11 | at MissingImplementationErrorTest$InjectionMissingSuperClauseModule.provideInteger(MissingImplementationErrorTest.java:273) 12 | 13 | Learn more: 14 | https://github.com/google/guice/wiki/MISSING_IMPLEMENTATION 15 | 16 | 1 error 17 | 18 | ====================== 19 | Full classname legend: 20 | ====================== 21 | MissingImplementationErrorTest$InjectionMissingSuperClauseModule: "com.google.inject.errors.MissingImplementationErrorTest$InjectionMissingSuperClauseModule" 22 | ======================== 23 | End of classname legend: 24 | ======================== 25 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/missing_implementation_with_mismatched_optionals.txt: -------------------------------------------------------------------------------- 1 | Unable to create injector, see the following errors: 2 | 3 | 1) [Guice/MissingImplementation]: No implementation for base.Optional was bound. 4 | 5 | Did you mean? 6 | * util.Optional bound at MissingImplementationErrorTest$MismatchedOptionalsModule.provideString(MissingImplementationErrorTest.java:218) 7 | 8 | Requested by: 9 | 1 : MissingImplementationErrorTest$MismatchedOptionalsModule.provideInteger(MissingImplementationErrorTest.java:223) 10 | \_ for 1st parameter dep 11 | at MissingImplementationErrorTest$MismatchedOptionalsModule.provideInteger(MissingImplementationErrorTest.java:223) 12 | 13 | Learn more: 14 | https://github.com/google/guice/wiki/MISSING_IMPLEMENTATION 15 | 16 | 1 error 17 | 18 | ====================== 19 | Full classname legend: 20 | ====================== 21 | MissingImplementationErrorTest$MismatchedOptionalsModule: "com.google.inject.errors.MissingImplementationErrorTest$MismatchedOptionalsModule" 22 | base.Optional: "com.google.common.base.Optional" 23 | util.Optional: "java.util.Optional" 24 | ======================== 25 | End of classname legend: 26 | ======================== 27 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/null_returned_from_provider.txt: -------------------------------------------------------------------------------- 1 | Unable to provision, see the following errors: 2 | 3 | 1) [Guice/NullInjectedIntoNonNullable]: null returned by binding at NullInjectedIntoNonNullableTest$FromProviderModule.configure(NullInjectedIntoNonNullableTest.java:44) 4 | but the 1st parameter string of NullInjectedIntoNonNullableTest$Foo.(NullInjectedIntoNonNullableTest.java:30) is not @Nullable 5 | at NullInjectedIntoNonNullableTest$FromProviderModule.configure(NullInjectedIntoNonNullableTest.java:44) 6 | at NullInjectedIntoNonNullableTest$Foo.(NullInjectedIntoNonNullableTest.java:30) 7 | \_ for 1st parameter string 8 | while locating NullInjectedIntoNonNullableTest$Foo 9 | 10 | Learn more: 11 | https://github.com/google/guice/wiki/NULL_INJECTED_INTO_NON_NULLABLE 12 | 13 | 1 error 14 | 15 | ====================== 16 | Full classname legend: 17 | ====================== 18 | NullInjectedIntoNonNullableTest$Foo: "com.google.inject.errors.NullInjectedIntoNonNullableTest$Foo" 19 | NullInjectedIntoNonNullableTest$FromProviderModule: "com.google.inject.errors.NullInjectedIntoNonNullableTest$FromProviderModule" 20 | ======================== 21 | End of classname legend: 22 | ======================== 23 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/null_returned_from_provides_method.txt: -------------------------------------------------------------------------------- 1 | Unable to provision, see the following errors: 2 | 3 | 1) [Guice/NullInjectedIntoNonNullable]: null returned by binding at NullInjectedIntoNonNullableTest$FromProvidesMethodModule.provideString() 4 | but the 1st parameter string of NullInjectedIntoNonNullableTest$Foo.(NullInjectedIntoNonNullableTest.java:30) is not @Nullable 5 | at NullInjectedIntoNonNullableTest$FromProvidesMethodModule.provideString(NullInjectedIntoNonNullableTest.java:37) 6 | at NullInjectedIntoNonNullableTest$FromProvidesMethodModule.provideString(NullInjectedIntoNonNullableTest.java:37) 7 | at NullInjectedIntoNonNullableTest$Foo.(NullInjectedIntoNonNullableTest.java:30) 8 | \_ for 1st parameter string 9 | while locating NullInjectedIntoNonNullableTest$Foo 10 | 11 | Learn more: 12 | https://github.com/google/guice/wiki/NULL_INJECTED_INTO_NON_NULLABLE 13 | 14 | 1 error 15 | 16 | ====================== 17 | Full classname legend: 18 | ====================== 19 | NullInjectedIntoNonNullableTest$Foo: "com.google.inject.errors.NullInjectedIntoNonNullableTest$Foo" 20 | NullInjectedIntoNonNullableTest$FromProvidesMethodModule: "com.google.inject.errors.NullInjectedIntoNonNullableTest$FromProvidesMethodModule" 21 | ======================== 22 | End of classname legend: 23 | ======================== 24 | -------------------------------------------------------------------------------- /core/test/com/google/inject/errors/testdata/single_binding_already_set_error.txt: -------------------------------------------------------------------------------- 1 | Unable to create injector, see the following errors: 2 | 3 | 1) [Guice/BindingAlreadySet]: BindingAlreadySetErrorTest$First was bound multiple times. 4 | 5 | Bound at: 6 | 1 : BindingAlreadySetErrorTest$BindWithProviderMethodModule.provideFirstClass(BindingAlreadySetErrorTest.java:33) 7 | 2 : BindingAlreadySetErrorTest$BindWithDslModule.configure(BindingAlreadySetErrorTest.java:40) 8 | 9 | Learn more: 10 | https://github.com/google/guice/wiki/BINDING_ALREADY_SET 11 | 12 | 1 error 13 | 14 | ====================== 15 | Full classname legend: 16 | ====================== 17 | BindingAlreadySetErrorTest$BindWithDslModule: "com.google.inject.errors.BindingAlreadySetErrorTest$BindWithDslModule" 18 | BindingAlreadySetErrorTest$BindWithProviderMethodModule: "com.google.inject.errors.BindingAlreadySetErrorTest$BindWithProviderMethodModule" 19 | BindingAlreadySetErrorTest$First: "com.google.inject.errors.BindingAlreadySetErrorTest$First" 20 | ======================== 21 | End of classname legend: 22 | ======================== 23 | -------------------------------------------------------------------------------- /core/test/com/google/inject/internal/UniqueAnnotationsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.internal; 18 | 19 | import java.lang.annotation.Annotation; 20 | import junit.framework.TestCase; 21 | 22 | /** @author jessewilson@google.com (Jesse Wilson) */ 23 | public class UniqueAnnotationsTest extends TestCase { 24 | 25 | @UniqueAnnotations.Internal(31) 26 | public Void unused; 27 | 28 | public void testEqualsHashCodeToString() { 29 | Annotation actual = UniqueAnnotations.create(31); 30 | 31 | Annotation expected = getClass().getFields()[0].getAnnotations()[0]; 32 | 33 | assertEquals(expected.toString(), actual.toString()); 34 | assertEquals(expected.hashCode(), actual.hashCode()); 35 | assertEquals(expected, actual); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /core/test/com/google/inject/spi/BindingTargetVisitorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.inject.spi; 17 | 18 | import com.google.inject.Binding; 19 | import com.google.inject.Guice; 20 | import com.google.inject.Injector; 21 | import junit.framework.TestCase; 22 | 23 | /** 24 | * Simple little test that should compile. Ensures that wildcards on the generics are correct. 25 | * 26 | * @author phopkins@gmail.com 27 | */ 28 | public class BindingTargetVisitorTest extends TestCase { 29 | public void testBindingTargetVisitorTypeTest() throws Exception { 30 | Injector injector = Guice.createInjector(); 31 | for (Binding binding : injector.getBindings().values()) { 32 | binding.acceptTargetVisitor(new DefaultBindingTargetVisitor() {}); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /core/test/com/google/inject/spi/ElementApplyToTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.spi; 18 | 19 | import com.google.inject.Module; 20 | 21 | /** @author jessewilson@google.com (Jesse Wilson) */ 22 | public class ElementApplyToTest extends ElementsTest { 23 | 24 | @Override 25 | protected void checkModule(Module module, ElementVisitor... visitors) { 26 | // convert from module to elements and back 27 | super.checkModule(Elements.getModule(Elements.getElements(module)), visitors); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/test/com/google/inject/spi/FailingElementVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.spi; 18 | 19 | import junit.framework.AssertionFailedError; 20 | 21 | class FailingElementVisitor extends DefaultElementVisitor { 22 | @Override 23 | protected Void visitOther(Element element) { 24 | throw new AssertionFailedError(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/test/com/google/inject/spi/FailingTargetVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.spi; 18 | 19 | import com.google.inject.Binding; 20 | import junit.framework.AssertionFailedError; 21 | 22 | public class FailingTargetVisitor extends DefaultBindingTargetVisitor { 23 | @Override 24 | protected Void visitOther(Binding binding) { 25 | throw new AssertionFailedError(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/test/com/google/inject/spi/MessageTest.java: -------------------------------------------------------------------------------- 1 | package com.google.inject.spi; 2 | 3 | import com.google.common.collect.Lists; 4 | import java.util.List; 5 | import junit.framework.TestCase; 6 | 7 | /** Tests for {@link Message}. */ 8 | public class MessageTest extends TestCase { 9 | 10 | public void testMessageHashCodeVariesWithSource() { 11 | String innerMessage = "This is the message."; 12 | Message firstMessage = new Message(1, innerMessage); 13 | Message secondMessage = new Message(2, innerMessage); 14 | assertFalse(firstMessage.hashCode() == secondMessage.hashCode()); 15 | } 16 | 17 | public void testMessageHashCodeVariesWithCause() { 18 | String innerMessage = "This is the message."; 19 | List sourceList = Lists.newArrayList(new Object()); 20 | // the throwable argument of each Message below do not have value equality 21 | Message firstMessage = new Message(sourceList, innerMessage, new Exception(innerMessage)); 22 | Message secondMessage = new Message(sourceList, innerMessage, new Exception(innerMessage)); 23 | assertFalse(firstMessage.hashCode() == secondMessage.hashCode()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/test/com/google/inject/util/NoopOverrideTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.util; 18 | 19 | import com.google.inject.Module; 20 | import com.google.inject.spi.ElementVisitor; 21 | import com.google.inject.spi.ElementsTest; 22 | 23 | /** @author jessewilson@google.com (Jesse Wilson) */ 24 | public class NoopOverrideTest extends ElementsTest { 25 | 26 | @Override 27 | protected void checkModule(Module module, ElementVisitor... visitors) { 28 | Module overridden = Modules.override(module).with(Modules.EMPTY_MODULE); 29 | super.checkModule(overridden, visitors); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/test/com/googlecode/guice/PackageVisibilityTestModule.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.guice; 2 | 3 | import com.google.inject.AbstractModule; 4 | import com.google.inject.Inject; 5 | 6 | public class PackageVisibilityTestModule extends AbstractModule { 7 | 8 | @Override 9 | protected void configure() { 10 | bind(PackagePrivateInterface.class).to(PackagePrivateImpl.class); 11 | } 12 | 13 | public static class PublicUserOfPackagePrivate { 14 | @Inject 15 | public PublicUserOfPackagePrivate(PackagePrivateInterface ppi) {} 16 | 17 | @Inject 18 | public void acceptPackagePrivateParameter(PackagePrivateInterface ppi) {} 19 | } 20 | 21 | interface PackagePrivateInterface {} 22 | 23 | static class PackagePrivateImpl implements PackagePrivateInterface {} 24 | } 25 | -------------------------------------------------------------------------------- /examples/guice-demo/src/main/java/com/example/Printer.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | /** Interface for printing messages. */ 4 | public interface Printer { 5 | void printMessage(String message); 6 | } 7 | -------------------------------------------------------------------------------- /examples/guice-demo/src/test/java/com/example/AppTest.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import com.google.inject.Guice; 6 | import com.google.inject.testing.fieldbinder.Bind; 7 | import com.google.inject.testing.fieldbinder.BoundFieldModule; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | import jakarta.inject.Inject; 11 | import org.junit.Before; 12 | import org.junit.Test; 13 | import org.junit.runner.RunWith; 14 | import org.junit.runners.JUnit4; 15 | 16 | /** Unit test for simple App. */ 17 | @RunWith(JUnit4.class) 18 | public final class AppTest { 19 | private final List messages = new ArrayList<>(); 20 | 21 | @Bind @App.Message private final String message = "hello, test"; 22 | 23 | @Bind 24 | private final Printer printer = 25 | new Printer() { 26 | @Override 27 | public void printMessage(String message) { 28 | messages.add(message); 29 | } 30 | }; 31 | 32 | @Inject private App app; 33 | 34 | @Before 35 | public void setUp() { 36 | Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this); 37 | } 38 | 39 | @Test 40 | public void run_printsMessage() { 41 | app.run(); 42 | 43 | assertEquals(1, messages.size()); 44 | assertEquals(message, messages.get(0)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /extensions/assistedinject/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | -------------------------------------------------------------------------------- /extensions/assistedinject/build.properties: -------------------------------------------------------------------------------- 1 | module=com.google.inject.assistedinject 2 | fragment=true 3 | -------------------------------------------------------------------------------- /extensions/assistedinject/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | 7 | com.google.inject.extensions 8 | extensions-parent 9 | 7.0.1-SNAPSHOT 10 | 11 | 12 | guice-assistedinject 13 | 14 | Google Guice - Extensions - AssistedInject 15 | 16 | 17 | 18 | 19 | maven-jar-plugin 20 | 21 | 22 | 23 | com.google.guice.extensions.assistedinject 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | com.google.truth 34 | truth 35 | 36 | 37 | com.google.errorprone 38 | error_prone_annotations 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /extensions/assistedinject/src/com/google/inject/assistedinject/AssistedInjectBinding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.assistedinject; 18 | 19 | import com.google.inject.Key; 20 | import java.util.Collection; 21 | 22 | /** 23 | * A binding for a factory created by FactoryModuleBuilder. 24 | * 25 | * @param The fully qualified type of the factory. 26 | * @since 3.0 27 | * @author ramakrishna@google.com (Ramakrishna Rajanna) 28 | */ 29 | public interface AssistedInjectBinding { 30 | 31 | /** Returns the {@link Key} for the factory binding. */ 32 | Key getKey(); 33 | 34 | /** Returns an {@link AssistedMethod} for each method in the factory. */ 35 | Collection getAssistedMethods(); 36 | } 37 | -------------------------------------------------------------------------------- /extensions/assistedinject/src/com/google/inject/assistedinject/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Google Inc. All rights reserved. 2 | # Author: sameb@google.com (Sam Berlin) 3 | load("@rules_java//java:defs.bzl", "java_library") 4 | load( 5 | "//:build_defs.bzl", 6 | "JAVAC_OPTS", 7 | "POM_VERSION", 8 | ) 9 | load("//:mvn.bzl", "gen_maven_artifact") 10 | 11 | package( 12 | default_visibility = ["//:src"], 13 | ) 14 | 15 | java_library( 16 | name = "assistedinject", 17 | srcs = glob(["**/*.java"]), 18 | javacopts = JAVAC_OPTS, 19 | tags = ["maven_coordinates=com.google.inject.extensions:guice-assitedinject:" + POM_VERSION], 20 | deps = [ 21 | "//core/src/com/google/inject", 22 | "//third_party/java/error_prone:annotations", 23 | "//third_party/java/guava/base", 24 | "//third_party/java/guava/collect", 25 | "//third_party/java/jakarta_inject", 26 | ], 27 | ) 28 | 29 | filegroup( 30 | name = "javadoc-srcs", 31 | srcs = glob(["*.java"]), 32 | ) 33 | 34 | gen_maven_artifact( 35 | name = "artifact", 36 | artifact_id = "guice-assistedinject", 37 | artifact_name = "Google Guice - Extensions - AssistedInject", 38 | artifact_target = ":assistedinject", 39 | is_extension = True, 40 | javadoc_srcs = [":javadoc-srcs"], 41 | ) 42 | -------------------------------------------------------------------------------- /extensions/assistedinject/src/com/google/inject/assistedinject/internal/LookupTester.java: -------------------------------------------------------------------------------- 1 | package com.google.inject.assistedinject.internal; 2 | 3 | import com.google.errorprone.annotations.Keep; 4 | import java.lang.invoke.MethodHandles; 5 | 6 | /** 7 | * An interface in a different package, so that AssistedInject's main package can't see it. Used at 8 | * runtime to determine which kind of Lookup method we'll support. 9 | */ 10 | @Keep 11 | class LookupTester { 12 | @Keep static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); 13 | 14 | @Keep 15 | interface Hidden { 16 | default Hidden method() { 17 | return null; 18 | } 19 | } 20 | 21 | private LookupTester() {} 22 | } 23 | -------------------------------------------------------------------------------- /extensions/assistedinject/src/com/google/inject/assistedinject/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Extension for combining factory interfaces with injection; this extension requires {@code 19 | * guice-assistedinject.jar}. 20 | */ 21 | package com.google.inject.assistedinject; 22 | -------------------------------------------------------------------------------- /extensions/dagger-adapter/build.properties: -------------------------------------------------------------------------------- 1 | module=com.google.inject.daggeradapter 2 | fragment=true 3 | -------------------------------------------------------------------------------- /extensions/dagger-adapter/src/com/google/inject/daggeradapter/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Google Inc. All rights reserved. 2 | # Author: cgruber@google.com (Christian Gruber) 3 | load("@rules_java//java:defs.bzl", "java_library") 4 | load( 5 | "//:build_defs.bzl", 6 | "JAVAC_OPTS", 7 | "POM_VERSION", 8 | ) 9 | load("//:mvn.bzl", "gen_maven_artifact") 10 | 11 | package( 12 | default_visibility = ["//:src"], 13 | ) 14 | 15 | java_library( 16 | name = "daggeradapter", 17 | srcs = glob(["*.java"]), 18 | javacopts = JAVAC_OPTS, 19 | tags = ["maven_coordinates=com.google.inject.extensions:guice-dagger-adapter:" + POM_VERSION], 20 | deps = [ 21 | "//core/src/com/google/inject", 22 | "//third_party/java/dagger", 23 | "//third_party/java/guava/base", 24 | "//third_party/java/guava/collect", 25 | "//third_party/java/jakarta_inject", 26 | ], 27 | ) 28 | 29 | filegroup( 30 | name = "javadoc-srcs", 31 | srcs = glob(["*.java"]), 32 | ) 33 | 34 | gen_maven_artifact( 35 | name = "artifact", 36 | artifact_id = "guice-dagger-adapter", 37 | artifact_name = "Google Guice - Extensions - Dagger", 38 | artifact_target = ":daggeradapter", 39 | is_extension = True, 40 | javadoc_srcs = [":javadoc-srcs"], 41 | ) 42 | -------------------------------------------------------------------------------- /extensions/grapher/build.properties: -------------------------------------------------------------------------------- 1 | module=com.google.inject.grapher 2 | fragment=true 3 | -------------------------------------------------------------------------------- /extensions/grapher/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | 7 | com.google.inject.extensions 8 | extensions-parent 9 | 7.0.1-SNAPSHOT 10 | 11 | 12 | guice-grapher 13 | 14 | Google Guice - Extensions - Grapher 15 | 16 | 17 | 18 | com.google.inject.extensions 19 | guice-assistedinject 20 | ${project.version} 21 | 22 | 23 | 24 | 25 | 26 | 27 | maven-jar-plugin 28 | 29 | 30 | 31 | com.google.guice.extensions.grapher 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /extensions/grapher/src/com/google/inject/grapher/Alias.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher; 18 | 19 | /** 20 | * Alias between two nodes. Causes the 'from' node to be aliased with the 'to' node, which means 21 | * that the 'from' node is not rendered and all edges going to it instead go to the 'to' node. 22 | * 23 | * @author bojand@google.com (Bojan Djordjevic) 24 | * @since 4.0 25 | */ 26 | public final class Alias { 27 | private final NodeId fromId; 28 | private final NodeId toId; 29 | 30 | public Alias(NodeId fromId, NodeId toId) { 31 | this.fromId = fromId; 32 | this.toId = toId; 33 | } 34 | 35 | public NodeId getFromId() { 36 | return fromId; 37 | } 38 | 39 | public NodeId getToId() { 40 | return toId; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /extensions/grapher/src/com/google/inject/grapher/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Google Inc. All rights reserved. 2 | # Author: sameb@google.com (Sam Berlin) 3 | load("@rules_java//java:defs.bzl", "java_library") 4 | load( 5 | "//:build_defs.bzl", 6 | "JAVAC_OPTS", 7 | "POM_VERSION", 8 | ) 9 | load("//:mvn.bzl", "gen_maven_artifact") 10 | 11 | package( 12 | default_visibility = ["//:src"], 13 | ) 14 | 15 | java_library( 16 | name = "grapher", 17 | srcs = glob(["**/*.java"]), 18 | javacopts = JAVAC_OPTS, 19 | tags = ["maven_coordinates=com.google.inject.extensions:guice-grapher:" + POM_VERSION], 20 | deps = [ 21 | "//core/src/com/google/inject", 22 | "//third_party/java/guava/base", 23 | "//third_party/java/guava/collect", 24 | ], 25 | ) 26 | 27 | filegroup( 28 | name = "javadoc-srcs", 29 | srcs = glob(["**/*.java"]), 30 | ) 31 | 32 | gen_maven_artifact( 33 | name = "artifact", 34 | artifact_id = "guice-grapher", 35 | artifact_name = "Google Guice - Extensions - Grapher", 36 | artifact_target = ":grapher", 37 | is_extension = True, 38 | javadoc_srcs = [":javadoc-srcs"], 39 | ) 40 | -------------------------------------------------------------------------------- /extensions/grapher/src/com/google/inject/grapher/EdgeCreator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher; 18 | 19 | import com.google.inject.Binding; 20 | 21 | /** 22 | * Creator of graph edges to render. All edges will be rendered on the graph after node aliasing is 23 | * performed. 24 | * 25 | * @author bojand@google.com (Bojan Djordjevic) 26 | * @since 4.0 27 | */ 28 | public interface EdgeCreator { 29 | 30 | /** Returns edges for the given dependency graph. */ 31 | Iterable getEdges(Iterable> bindings); 32 | } 33 | -------------------------------------------------------------------------------- /extensions/grapher/src/com/google/inject/grapher/NameFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher; 18 | 19 | import com.google.inject.Key; 20 | import java.lang.reflect.Member; 21 | 22 | /** 23 | * Interface for a service that provides nice {@link String}s that we can display in the graph for 24 | * the types that come up in {@link com.google.inject.Binding}s. 25 | * 26 | * @author phopkins@gmail.com (Pete Hopkins) 27 | */ 28 | public interface NameFactory { 29 | String getMemberName(Member member); 30 | 31 | String getClassName(Key key); 32 | 33 | String getInstanceName(Object instance); 34 | 35 | String getAnnotationName(Key key); 36 | 37 | String getSourceName(Object source); 38 | } 39 | -------------------------------------------------------------------------------- /extensions/grapher/src/com/google/inject/grapher/NodeCreator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher; 18 | 19 | import com.google.inject.Binding; 20 | 21 | /** 22 | * Creator of graph nodes. 23 | * 24 | * @author bojand@google.com (Bojan Djordjevic) 25 | * @since 4.0 26 | */ 27 | public interface NodeCreator { 28 | 29 | /** Returns nodes for the given dependency graph. */ 30 | Iterable getNodes(Iterable> bindings); 31 | } 32 | -------------------------------------------------------------------------------- /extensions/grapher/src/com/google/inject/grapher/RootKeySetCreator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher; 18 | 19 | import com.google.inject.Injector; 20 | import com.google.inject.Key; 21 | import java.util.Set; 22 | 23 | /** 24 | * Creator of the default starting set of keys to graph. These keys and their transitive 25 | * dependencies will be graphed. 26 | * 27 | * @author bojand@google.com (Bojan Djordjevic) 28 | * @since 4.0 29 | */ 30 | public interface RootKeySetCreator { 31 | 32 | /** Returns the set of starting keys to graph. */ 33 | Set> getRootKeys(Injector injector); 34 | } 35 | -------------------------------------------------------------------------------- /extensions/grapher/src/com/google/inject/grapher/graphviz/EdgeStyle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.graphviz; 18 | 19 | /** 20 | * Styles for edges. 21 | * 22 | *

See: http://www.graphviz.org/doc/info/attrs.html#k:style 23 | * 24 | * @author phopkins@gmail.com (Pete Hopkins) 25 | */ 26 | public enum EdgeStyle { 27 | BOLD("bold"), 28 | DASHED("dashed"), 29 | DOTTED("dotted"), 30 | INVISIBLE("invis"), 31 | SOLID("solid"); 32 | 33 | private final String name; 34 | 35 | EdgeStyle(String name) { 36 | this.name = name; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return name; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /extensions/grapher/src/com/google/inject/grapher/graphviz/Graphviz.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.graphviz; 18 | 19 | import com.google.inject.BindingAnnotation; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | 23 | /** 24 | * Annotation for types used by the graphviz grapher. 25 | * 26 | * @author bojand@google.com (Bojan Djordjevic) 27 | */ 28 | @BindingAnnotation 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @interface Graphviz {} 31 | -------------------------------------------------------------------------------- /extensions/grapher/src/com/google/inject/grapher/graphviz/GraphvizModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.graphviz; 18 | 19 | import com.google.inject.AbstractModule; 20 | import com.google.inject.grapher.NameFactory; 21 | import com.google.inject.grapher.ShortNameFactory; 22 | 23 | /** 24 | * Module that provides classes needed by {@link GraphvizGrapher}. 25 | * 26 | * @author phopkins@gmail.com (Pete Hopkins) 27 | */ 28 | public class GraphvizModule extends AbstractModule { 29 | @Override 30 | protected void configure() { 31 | bind(NameFactory.class).annotatedWith(Graphviz.class).to(ShortNameFactory.class); 32 | bind(PortIdFactory.class).annotatedWith(Graphviz.class).to(PortIdFactoryImpl.class); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /extensions/grapher/src/com/google/inject/grapher/graphviz/NodeShape.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.graphviz; 18 | 19 | /** 20 | * Enum for the shapes that are most interesting for Guice graphing. 21 | * 22 | *

See: http://www.graphviz.org/doc/info/shapes.html 23 | * 24 | * @author phopkins@gmail.com (Pete Hopkins) 25 | */ 26 | public enum NodeShape { 27 | BOX("box"), 28 | ELLIPSE("ellipse"), 29 | NONE("none"); 30 | 31 | private final String shape; 32 | 33 | NodeShape(String shape) { 34 | this.shape = shape; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return shape; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /extensions/grapher/src/com/google/inject/grapher/graphviz/NodeStyle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.graphviz; 18 | 19 | /** 20 | * Styles for nodes. Similar to {@link EdgeStyle} but with a few more options. 21 | * 22 | *

See: http://www.graphviz.org/doc/info/attrs.html#k:style 23 | * 24 | * @author phopkins@gmail.com (Pete Hopkins) 25 | */ 26 | public enum NodeStyle { 27 | BOLD("bold"), 28 | DASHED("dashed"), 29 | DIAGONALS("diagonals"), 30 | DOTTED("dotted"), 31 | INVISIBLE("invis"), 32 | FILLED("filled"), 33 | ROUNDED("rounded"), 34 | SOLID("solid"); 35 | 36 | private final String name; 37 | 38 | NodeStyle(String name) { 39 | this.name = name; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return name; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /extensions/grapher/src/com/google/inject/grapher/graphviz/PortIdFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.graphviz; 18 | 19 | import java.lang.reflect.Member; 20 | 21 | /** 22 | * Interface for a service that returns Graphviz port IDs, used for naming the rows in {@link 23 | * com.google.inject.grapher.ImplementationNode}-displaying {@link GraphvizNode}s. 24 | * 25 | * @author phopkins@gmail.com (Pete Hopkins) 26 | */ 27 | public interface PortIdFactory { 28 | String getPortId(Member member); 29 | } 30 | -------------------------------------------------------------------------------- /extensions/grapher/src/com/google/inject/grapher/graphviz/PortIdFactoryImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.graphviz; 18 | 19 | import java.lang.reflect.Member; 20 | 21 | /** 22 | * Implementation of {@link PortIdFactory}. Bound in {@link GraphvizModule}. 23 | * 24 | * @author phopkins@gmail.com (Pete Hopkins) 25 | */ 26 | public class PortIdFactoryImpl implements PortIdFactory { 27 | @Override 28 | public String getPortId(Member member) { 29 | return "m_" + Integer.toHexString(member.hashCode()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/AllTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher; 18 | 19 | import junit.framework.Test; 20 | import junit.framework.TestSuite; 21 | 22 | /** @author phopkins@gmail.com (Pete Hopkins) */ 23 | public class AllTests { 24 | 25 | public static Test suite() { 26 | TestSuite suite = new TestSuite(); 27 | suite.addTestSuite(AbstractInjectorGrapherTest.class); 28 | suite.addTestSuite(ShortNameFactoryTest.class); 29 | suite.addTestSuite(TransitiveDependencyVisitorTest.class); 30 | return suite; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Google Inc. All rights reserved. 2 | # Author: sameb@google.com (Sam Berlin) 3 | load("@rules_java//java:defs.bzl", "java_library") 4 | load("//:build_defs.bzl", "JAVAC_OPTS") 5 | load("//:test_defs.bzl", "guice_test_suites") 6 | 7 | package( 8 | default_testonly = 1, 9 | ) 10 | 11 | java_library( 12 | name = "tests", 13 | srcs = glob(["**/*.java"]), 14 | javacopts = JAVAC_OPTS, 15 | deps = [ 16 | "//core/src/com/google/inject", 17 | "//extensions/assistedinject/src/com/google/inject/assistedinject", 18 | "//extensions/grapher/src/com/google/inject/grapher", 19 | "//third_party/java/guava/collect", 20 | "//third_party/java/junit", 21 | ], 22 | ) 23 | 24 | guice_test_suites( 25 | name = "gen_tests", 26 | sizes = [ 27 | "small", 28 | "medium", 29 | ], 30 | deps = [":tests"], 31 | ) 32 | 33 | [guice_test_suites( 34 | name = "gen_tests_%s" % include_stack_trace_option, 35 | args = ["--guice_include_stack_traces=%s" % include_stack_trace_option], 36 | sizes = [ 37 | "small", 38 | "medium", 39 | ], 40 | suffix = "_stack_trace_%s" % include_stack_trace_option, 41 | deps = [":tests"], 42 | ) for include_stack_trace_option in [ 43 | "OFF", 44 | ]] 45 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/AssistedInjectModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import com.google.inject.AbstractModule; 20 | import com.google.inject.assistedinject.FactoryModuleBuilder; 21 | 22 | /** 23 | * Module to add {@link AssistedInject}-based elements to the demo {@link Injector}. 24 | * 25 | * @author phopkins@gmail.com (Pete Hopkins) 26 | */ 27 | public class AssistedInjectModule extends AbstractModule { 28 | @Override 29 | protected void configure() { 30 | install( 31 | new FactoryModuleBuilder() 32 | .implement(DanceParty.class, DancePartyImpl.class) 33 | .build(DancePartyFactory.class)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/DanceParty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | interface DanceParty {} 20 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/DancePartyFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | /** 20 | * Interface to be used with {@link FactoryProvider}. 21 | * 22 | * @author phopkins@gmail.com (Pete Hopkins) 23 | */ 24 | interface DancePartyFactory { 25 | DanceParty newDanceParty(String thatNewSound); 26 | } 27 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/DancePartyImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import com.google.inject.Inject; 20 | import com.google.inject.assistedinject.Assisted; 21 | 22 | class DancePartyImpl implements DanceParty { 23 | @Inject 24 | public DancePartyImpl(@Assisted String thatNewSound, MartyMcFly guitarist) {} 25 | } 26 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/DeLorian.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import com.google.inject.Inject; 20 | import com.google.inject.Provider; 21 | 22 | class DeLorian { 23 | // We @Inject a Provider to demonstrate that the graph doesn't differentiate 24 | // between a Provider and just @Injecting T. 25 | @Inject @Driver Provider driver; 26 | @Inject FluxCapacitor fluxCapacitor; 27 | @Inject PrivateTestModule.Exposed exposed; 28 | 29 | @Inject 30 | public void setEnergySource(EnergySource energySource) {} 31 | } 32 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/DocBrown.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import com.google.inject.Inject; 20 | 21 | class DocBrown implements Person { 22 | // handy because it introduces a cycle 23 | @Inject DeLorian stylishCar; 24 | } 25 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/Driver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 20 | 21 | import com.google.inject.BindingAnnotation; 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | @Retention(RUNTIME) 27 | @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) 28 | @BindingAnnotation 29 | @interface Driver {} 30 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/EnergySource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import com.google.inject.ProvidedBy; 20 | 21 | @ProvidedBy(EnergySourceProvider.class) 22 | interface EnergySource {} 23 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/EnergySourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import com.google.inject.Inject; 20 | import com.google.inject.Provider; 21 | import com.google.inject.name.Named; 22 | 23 | class EnergySourceProvider implements Provider { 24 | @Inject 25 | void setSources(@Nuclear EnergySource nuclear, @Renewable EnergySource renewable) {} 26 | 27 | // This will demonstrate a ConvertedConstantBinding. 28 | @Inject 29 | void setYear(@Named("year") int year) {} 30 | 31 | @Override 32 | public EnergySource get() { 33 | return null; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/FluxCapacitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | class FluxCapacitor {} 20 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/Inventor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 20 | 21 | import com.google.inject.BindingAnnotation; 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | @Retention(RUNTIME) 27 | @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) 28 | @BindingAnnotation 29 | @interface Inventor {} 30 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/Lightning.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import com.google.inject.Inject; 20 | import com.google.inject.name.Named; 21 | 22 | class Lightning implements EnergySource { 23 | @Inject 24 | @Named("year") 25 | String yearOfStrike; 26 | } 27 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/MartyMcFly.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | class MartyMcFly implements Person {} 20 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/MultibinderModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import com.google.inject.AbstractModule; 20 | import com.google.inject.multibindings.Multibinder; 21 | 22 | /** 23 | * Module to add {@link Multibinder}-based bindings to the injector. 24 | * 25 | * @author phopkins@gmail.com (Pete Hopkins) 26 | */ 27 | public class MultibinderModule extends AbstractModule { 28 | @Override 29 | protected void configure() { 30 | Multibinder charactersBinder = Multibinder.newSetBinder(binder(), Person.class); 31 | charactersBinder.addBinding().to(MartyMcFly.class); 32 | charactersBinder.addBinding().to(DocBrown.class); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/Nuclear.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 20 | 21 | import com.google.inject.BindingAnnotation; 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | @Retention(RUNTIME) 27 | @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) 28 | @BindingAnnotation 29 | @interface Nuclear {} 30 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | interface Person {} 20 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/PinballParts.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import com.google.inject.Inject; 20 | import com.google.inject.Provider; 21 | 22 | class PinballParts { 23 | // Shows up as an injection point on an instance. We use a Provider so that 24 | // it doesn't have to be satisfied when the Injector is created. 25 | @Inject Provider salvager; 26 | } 27 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/Plutonium.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | class Plutonium implements EnergySource {} 20 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/PlutoniumProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import com.google.inject.Inject; 20 | import com.google.inject.Provider; 21 | 22 | class PlutoniumProvider implements Provider { 23 | @Inject 24 | public PlutoniumProvider(@Inventor Person inventor, @Used PinballParts parts) {} 25 | 26 | @Override 27 | public Plutonium get() { 28 | return null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/PrivateTestModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import com.google.inject.PrivateModule; 20 | 21 | /** 22 | * Module to test private modules and exposed bindings. 23 | * 24 | * @author bojand@google.com (Bojan Djordjevic) 25 | */ 26 | public class PrivateTestModule extends PrivateModule { 27 | interface Exposed {} 28 | 29 | static class Hidden implements Exposed {} 30 | 31 | @Override 32 | protected void configure() { 33 | bind(Exposed.class).to(Hidden.class); 34 | expose(Exposed.class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/Renewable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 20 | 21 | import com.google.inject.BindingAnnotation; 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | @Retention(RUNTIME) 27 | @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) 28 | @BindingAnnotation 29 | @interface Renewable {} 30 | -------------------------------------------------------------------------------- /extensions/grapher/test/com/google/inject/grapher/demo/Used.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.grapher.demo; 18 | 19 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 20 | 21 | import com.google.inject.BindingAnnotation; 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | @Retention(RUNTIME) 27 | @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) 28 | @BindingAnnotation 29 | @interface Used {} 30 | -------------------------------------------------------------------------------- /extensions/jmx/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | -------------------------------------------------------------------------------- /extensions/jmx/build.properties: -------------------------------------------------------------------------------- 1 | module=com.google.inject.tools.jmx 2 | fragment=true -------------------------------------------------------------------------------- /extensions/jmx/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | 7 | com.google.inject.extensions 8 | extensions-parent 9 | 7.0.1-SNAPSHOT 10 | 11 | 12 | guice-jmx 13 | 14 | Google Guice - Extensions - JMX 15 | 16 | 17 | 18 | 19 | maven-surefire-plugin 20 | 21 | true 22 | 23 | 24 | 25 | 26 | maven-jar-plugin 27 | 28 | 29 | 30 | com.google.guice.extensions.jmx 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /extensions/jmx/src/com/google/inject/tools/jmx/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Google Inc. All rights reserved. 2 | # Author: sameb@google.com (Sam Berlin) 3 | load("@rules_java//java:defs.bzl", "java_library") 4 | load( 5 | "//:build_defs.bzl", 6 | "JAVAC_OPTS", 7 | "POM_VERSION", 8 | ) 9 | load("//:mvn.bzl", "gen_maven_artifact") 10 | 11 | package( 12 | default_visibility = ["//:src"], 13 | ) 14 | 15 | java_library( 16 | name = "jmx", 17 | srcs = glob(["*.java"]), 18 | javacopts = JAVAC_OPTS, 19 | tags = ["maven_coordinates=com.google.inject.extensions:guice-jmx:" + POM_VERSION], 20 | deps = [ 21 | "//core/src/com/google/inject", 22 | ], 23 | ) 24 | 25 | filegroup( 26 | name = "javadoc-srcs", 27 | srcs = glob(["*.java"]), 28 | ) 29 | 30 | gen_maven_artifact( 31 | name = "artifact", 32 | artifact_id = "guice-jmx", 33 | artifact_name = "Google Guice - Extensions - JMX", 34 | artifact_target = ":jmx", 35 | is_extension = True, 36 | javadoc_srcs = [":javadoc-srcs"], 37 | ) 38 | -------------------------------------------------------------------------------- /extensions/jmx/src/com/google/inject/tools/jmx/ManagedBinding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.tools.jmx; 18 | 19 | import com.google.inject.Binding; 20 | 21 | class ManagedBinding implements ManagedBindingMBean { 22 | 23 | final Binding binding; 24 | 25 | ManagedBinding(Binding binding) { 26 | this.binding = binding; 27 | } 28 | 29 | @Override 30 | public String getSource() { 31 | return binding.getSource().toString(); 32 | } 33 | 34 | @Override 35 | public String getKey() { 36 | return binding.getKey().toString(); 37 | } 38 | 39 | @Override 40 | public String getProvider() { 41 | return binding.getProvider().toString(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /extensions/jmx/src/com/google/inject/tools/jmx/ManagedBindingMBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.tools.jmx; 18 | 19 | /** 20 | * JMX interface to bindings. 21 | * 22 | * @author crazybob@google.com (Bob Lee) 23 | */ 24 | public interface ManagedBindingMBean { 25 | 26 | /** Gets the source of this binding. */ 27 | String getSource(); 28 | 29 | /** Gets the provider to which this binding is bound. */ 30 | String getProvider(); 31 | 32 | /** Gets the binding key. */ 33 | String getKey(); 34 | } 35 | -------------------------------------------------------------------------------- /extensions/jmx/src/com/google/inject/tools/jmx/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** JMX integration; this extension requires {@code guice-jmx.jar}. */ 18 | package com.google.inject.tools.jmx; 19 | -------------------------------------------------------------------------------- /extensions/jmx/test/com/google/inject/tools/jmx/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Google Inc. All rights reserved. 2 | # Author: sameb@google.com (Sam Berlin) 3 | load("@rules_java//java:defs.bzl", "java_library") 4 | load("//:build_defs.bzl", "JAVAC_OPTS") 5 | 6 | package( 7 | default_testonly = 1, 8 | ) 9 | 10 | java_library( 11 | name = "tests", 12 | srcs = glob(["**/*.java"]), 13 | javacopts = JAVAC_OPTS, 14 | deps = [ 15 | "//core/src/com/google/inject", 16 | "//extensions/jmx/src/com/google/inject/tools/jmx", 17 | ], 18 | ) 19 | 20 | # There are no actual tests here, just some code that's intended to be 21 | # run manually. 22 | # TODO(sameb): Add some tests. 23 | #load("//testing/build_defs:junit3_test_suites.bzl", "junit3_test_suites") 24 | #junit3_test_suites(name = "gen_tests", 25 | # deps = [ ":tests", ], 26 | # sizes = [ 'small', ], 27 | # include_suites = True, 28 | # subpackages = True,) 29 | -------------------------------------------------------------------------------- /extensions/jndi/build.properties: -------------------------------------------------------------------------------- 1 | module=com.google.inject.jndi 2 | fragment=true -------------------------------------------------------------------------------- /extensions/jndi/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | 7 | com.google.inject.extensions 8 | extensions-parent 9 | 7.0.1-SNAPSHOT 10 | 11 | 12 | guice-jndi 13 | 14 | Google Guice - Extensions - JNDI 15 | 16 | 17 | 18 | 19 | maven-jar-plugin 20 | 21 | 22 | 23 | com.google.guice.extensions.jndi 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /extensions/jndi/src/com/google/inject/jndi/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Google Inc. All rights reserved. 2 | # Author: sameb@google.com (Sam Berlin) 3 | load("@rules_java//java:defs.bzl", "java_library") 4 | load( 5 | "//:build_defs.bzl", 6 | "JAVAC_OPTS", 7 | "POM_VERSION", 8 | ) 9 | load("//:mvn.bzl", "gen_maven_artifact") 10 | 11 | package( 12 | default_visibility = ["//:src"], 13 | ) 14 | 15 | java_library( 16 | name = "jndi", 17 | srcs = glob(["*.java"]), 18 | javacopts = JAVAC_OPTS, 19 | tags = ["maven_coordinates=com.google.inject.extensions:guice-jndi:" + POM_VERSION], 20 | deps = [ 21 | "//core/src/com/google/inject", 22 | ], 23 | ) 24 | 25 | filegroup( 26 | name = "javadoc-srcs", 27 | srcs = glob(["*.java"]), 28 | ) 29 | 30 | gen_maven_artifact( 31 | name = "artifact", 32 | artifact_id = "guice-jndi", 33 | artifact_name = "Google Guice - Extensions - JNDI", 34 | artifact_target = ":jndi", 35 | is_extension = True, 36 | javadoc_srcs = [ 37 | ":javadoc-srcs", 38 | ], 39 | ) 40 | -------------------------------------------------------------------------------- /extensions/jndi/src/com/google/inject/jndi/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** JNDI integration; this extension requires {@code guice-jndi.jar}. */ 18 | package com.google.inject.jndi; 19 | -------------------------------------------------------------------------------- /extensions/persist/build.properties: -------------------------------------------------------------------------------- 1 | module=com.google.inject.persist 2 | fragment=true 3 | -------------------------------------------------------------------------------- /extensions/persist/src/com/google/inject/persist/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Google Inc. All rights reserved. 2 | # Author: sameb@google.com (Sam Berlin) 3 | load("@rules_java//java:defs.bzl", "java_library") 4 | load( 5 | "//:build_defs.bzl", 6 | "JAVAC_OPTS", 7 | "POM_VERSION", 8 | ) 9 | load("//:mvn.bzl", "gen_maven_artifact") 10 | 11 | package( 12 | default_visibility = ["//:src"], 13 | ) 14 | 15 | java_library( 16 | name = "persist", 17 | srcs = glob(["**/*.java"]), 18 | javacopts = JAVAC_OPTS, 19 | tags = ["maven_coordinates=com.google.inject.extensions:guice-persist:" + POM_VERSION], 20 | deps = [ 21 | "//core/src/com/google/inject", 22 | "//third_party/java/aopalliance", 23 | "//third_party/java/guava/annotations", 24 | "//third_party/java/guava/base", 25 | "//third_party/java/guava/collect", 26 | "//third_party/java/jakarta_inject", 27 | "//third_party/java/jakarta_persistence", 28 | "//third_party/java/jakarta_servlet_api", 29 | ], 30 | ) 31 | 32 | filegroup( 33 | name = "javadoc-srcs", 34 | srcs = glob(["**/*.java"]), 35 | ) 36 | 37 | gen_maven_artifact( 38 | name = "artifact", 39 | artifact_id = "guice-persist", 40 | artifact_name = "Google Guice - Extensions - Persist", 41 | artifact_target = ":persist", 42 | is_extension = True, 43 | javadoc_srcs = [ 44 | ":javadoc-srcs", 45 | ], 46 | ) 47 | -------------------------------------------------------------------------------- /extensions/persist/src/com/google/inject/persist/finder/FirstResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Google, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.persist.finder; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Annotate any dynamic finder method's integer argument with this to pass in the index of the first 26 | * result in the result set you are interested in. Useful for paging result sets. Complemented by 27 | * {@link MaxResults}. 28 | * 29 | * @author Dhanji R. Prasanna (dhanji@gmail.com) 30 | */ 31 | @Target(ElementType.PARAMETER) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | public @interface FirstResult {} 34 | -------------------------------------------------------------------------------- /extensions/persist/src/com/google/inject/persist/finder/MaxResults.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Google, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.persist.finder; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Annotate any dynamic finder method's integer argument with this to pass in the maximum size of 26 | * returned result window. Useful for paging result sets. Complement of {@link FirstResult}. 27 | * 28 | * @author Dhanji R. Prasanna (dhanji@gmail.com) 29 | */ 30 | @Target(ElementType.PARAMETER) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface MaxResults {} 33 | -------------------------------------------------------------------------------- /extensions/persist/src/com/google/inject/persist/finder/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** Dynamic Finder API for Guice Persist. */ 18 | package com.google.inject.persist.finder; 19 | -------------------------------------------------------------------------------- /extensions/persist/src/com/google/inject/persist/jpa/Jpa.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Google, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.persist.jpa; 18 | 19 | import com.google.inject.BindingAnnotation; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | 23 | /** 24 | * A binding annotation for internal JPA module properties. 25 | * 26 | * @author dhanji@gmail.com (Dhanji R. Prasanna) 27 | */ 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @BindingAnnotation 30 | @interface Jpa {} 31 | -------------------------------------------------------------------------------- /extensions/persist/src/com/google/inject/persist/jpa/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** guice-persist's Java Persistence API (JPA) support. */ 18 | package com.google.inject.persist.jpa; 19 | -------------------------------------------------------------------------------- /extensions/persist/src/com/google/inject/persist/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Guice Persist: a lightweight persistence library for Guice; this extension requires {@code 19 | * guice-persist.jar}. 20 | */ 21 | package com.google.inject.persist; 22 | -------------------------------------------------------------------------------- /extensions/persist/test/com/google/inject/persist/EdslTest.java: -------------------------------------------------------------------------------- 1 | package com.google.inject.persist; 2 | 3 | import com.google.inject.AbstractModule; 4 | import com.google.inject.Guice; 5 | import com.google.inject.Stage; 6 | import com.google.inject.persist.jpa.JpaPersistModule; 7 | import java.util.logging.Logger; 8 | import junit.framework.TestCase; 9 | 10 | /** @author dhanji@google.com (Dhanji R. Prasanna) */ 11 | public class EdslTest extends TestCase { 12 | 13 | public void testModuleConfigUsingJpa() throws Exception { 14 | Logger.getLogger(getClass().getName()).info("Starting EDSL test."); 15 | Guice.createInjector( 16 | Stage.PRODUCTION, 17 | new AbstractModule() { 18 | @Override 19 | protected void configure() { 20 | install(new JpaPersistModule("myunit")); 21 | binder().requireExplicitBindings(); 22 | } 23 | }); 24 | Logger.getLogger(getClass().getName()).info("Completed EDSL test."); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /extensions/persist/test/com/google/inject/persist/config/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Google Inc. All Rights Reserved. 2 | # Author: sameb@google.com (Sam Berlin) 3 | 4 | package( 5 | default_visibility = ["//:src"], 6 | ) 7 | 8 | # A genrule to take everything under META-INF and move it the 9 | # root of the classpath. 10 | genrule( 11 | name = "metainf", 12 | srcs = glob(["META-INF/*"]), 13 | outs = ["jpa-manifest.jar"], 14 | cmd = "$(JAVABASE)/bin/jar cvf $@ -C " + 15 | "extensions/persist/test/com/google/inject/persist/config META-INF", 16 | toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"], 17 | tools = ["@bazel_tools//tools/jdk:current_java_runtime"], 18 | ) 19 | -------------------------------------------------------------------------------- /extensions/persist/test/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=warn, console 2 | 3 | log4j.appender.console=org.apache.log4j.ConsoleAppender 4 | log4j.appender.console.Target=System.out 5 | log4j.appender.console.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.console.layout.ConversionPattern=%p [%c{1}] - %m %n 7 | -------------------------------------------------------------------------------- /extensions/servlet/build.properties: -------------------------------------------------------------------------------- 1 | module=com.google.inject.servlet 2 | fragment=true 3 | -------------------------------------------------------------------------------- /extensions/servlet/src/com/google/inject/servlet/InstanceFilterBinding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.servlet; 18 | 19 | import jakarta.servlet.Filter; 20 | 21 | /** 22 | * A binding to a single instance of a filter. 23 | * 24 | * @author sameb@google.com 25 | * @since 3.0 26 | */ 27 | public interface InstanceFilterBinding extends ServletModuleBinding { 28 | 29 | /** Returns the filter instance that will be used. */ 30 | Filter getFilterInstance(); 31 | } 32 | -------------------------------------------------------------------------------- /extensions/servlet/src/com/google/inject/servlet/InstanceServletBinding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.servlet; 18 | 19 | import jakarta.servlet.http.HttpServlet; 20 | 21 | /** 22 | * A binding to a single instance of a servlet. 23 | * 24 | * @author sameb@google.com 25 | * @since 3.0 26 | */ 27 | public interface InstanceServletBinding extends ServletModuleBinding { 28 | 29 | /** Returns the servlet instance that will be used. */ 30 | HttpServlet getServletInstance(); 31 | } 32 | -------------------------------------------------------------------------------- /extensions/servlet/src/com/google/inject/servlet/LinkedFilterBinding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.servlet; 18 | 19 | import com.google.inject.Key; 20 | import jakarta.servlet.Filter; 21 | 22 | /** 23 | * A linked binding to a filter. 24 | * 25 | * @author sameb@google.com 26 | * @since 3.0 27 | */ 28 | public interface LinkedFilterBinding extends ServletModuleBinding { 29 | 30 | /** Returns the key used to lookup the filter instance. */ 31 | Key getLinkedKey(); 32 | } 33 | -------------------------------------------------------------------------------- /extensions/servlet/src/com/google/inject/servlet/LinkedServletBinding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.servlet; 18 | 19 | import com.google.inject.Key; 20 | import jakarta.servlet.http.HttpServlet; 21 | 22 | /** 23 | * A linked binding to a servlet. 24 | * 25 | * @author sameb@google.com 26 | * @since 3.0 27 | */ 28 | public interface LinkedServletBinding extends ServletModuleBinding { 29 | 30 | /** Returns the key used to lookup the servlet instance. */ 31 | Key getLinkedKey(); 32 | } 33 | -------------------------------------------------------------------------------- /extensions/servlet/src/com/google/inject/servlet/RequestParameters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.servlet; 18 | 19 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 20 | 21 | import com.google.inject.BindingAnnotation; 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Apply this to field or parameters of type {@code Map} when you want the HTTP 28 | * request parameter map to be injected. 29 | * 30 | * @author crazybob@google.com (Bob Lee) 31 | */ 32 | @Retention(RUNTIME) 33 | @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) 34 | @BindingAnnotation 35 | public @interface RequestParameters {} 36 | -------------------------------------------------------------------------------- /extensions/servlet/src/com/google/inject/servlet/RequestScoped.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.servlet; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | import jakarta.inject.Scope; 24 | 25 | /** 26 | * Apply this to implementation classes when you want one instance per request. 27 | * 28 | * @author crazybob@google.com (Bob Lee) 29 | */ 30 | @Target({ElementType.TYPE, ElementType.METHOD}) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Scope 33 | public @interface RequestScoped {} 34 | -------------------------------------------------------------------------------- /extensions/servlet/src/com/google/inject/servlet/RequestScoper.java: -------------------------------------------------------------------------------- 1 | package com.google.inject.servlet; 2 | 3 | import java.io.Closeable; 4 | 5 | /** Object that can be used to apply a request scope to a block of code. */ 6 | public interface RequestScoper { 7 | /** 8 | * Opens up the request scope until the returned object is closed. Implementations should ensure 9 | * (e.g. by blocking) that multiple threads cannot open the same request scope concurrently. It is 10 | * allowable to open the same request scope on the same thread, as long as open/close calls are 11 | * correctly nested. 12 | */ 13 | CloseableScope open(); 14 | 15 | /** Closeable subclass that does not throw any exceptions from close. */ 16 | public interface CloseableScope extends Closeable { 17 | @Override 18 | void close(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /extensions/servlet/src/com/google/inject/servlet/ScopingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.servlet; 18 | 19 | /** 20 | * Exception thrown when there was a failure entering request scope. 21 | * 22 | * @author Chris Nokleberg 23 | * @since 4.0 24 | */ 25 | public final class ScopingException extends IllegalStateException { 26 | public ScopingException(String message) { 27 | super(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /extensions/servlet/src/com/google/inject/servlet/ScopingOnly.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.servlet; 18 | 19 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 20 | 21 | import com.google.inject.BindingAnnotation; 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Annotates a {@link GuiceFilter} that provides scope functionality, but doesn't dispatch to {@link 28 | * ServletModule} bound servlets or filters. 29 | * 30 | * @author iqshum@google.com (Isaac Shum) 31 | * @since 4.0 32 | */ 33 | @Retention(RUNTIME) 34 | @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) 35 | @BindingAnnotation 36 | public @interface ScopingOnly {} 37 | -------------------------------------------------------------------------------- /extensions/servlet/src/com/google/inject/servlet/SessionScoped.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.servlet; 18 | 19 | import com.google.inject.ScopeAnnotation; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Apply this to implementation classes when you want one instance per session. 27 | * 28 | * @see com.google.inject.Scopes#SINGLETON 29 | * @author crazybob@google.com (Bob Lee) 30 | */ 31 | @Target({ElementType.TYPE, ElementType.METHOD}) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | @ScopeAnnotation 34 | public @interface SessionScoped {} 35 | -------------------------------------------------------------------------------- /extensions/servlet/src/com/google/inject/servlet/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Servlet API scopes, bindings and registration; this extension requires {@code guice-servlet.jar}. 19 | * 20 | *

Apply {@link com.google.inject.servlet.GuiceFilter} to any servlets which will use the servlet 21 | * scopes. Install {@link com.google.inject.servlet.ServletModule} into your {@link 22 | * com.google.inject.Injector} to install everything at once. 23 | */ 24 | package com.google.inject.servlet; 25 | -------------------------------------------------------------------------------- /extensions/servlet/test/com/google/inject/servlet/DummyServlet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.inject.servlet; 17 | 18 | import com.google.inject.Singleton; 19 | import jakarta.servlet.http.HttpServlet; 20 | 21 | /** 22 | * Used in unit tests to verify the EDSL. 23 | * 24 | * @author Dhanji R. Prasanna (dhanji@gmail com) 25 | */ 26 | @Singleton 27 | public class DummyServlet extends HttpServlet {} 28 | -------------------------------------------------------------------------------- /extensions/spring/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | -------------------------------------------------------------------------------- /extensions/spring/build.properties: -------------------------------------------------------------------------------- 1 | module=com.google.inject.spring 2 | fragment=true 3 | -------------------------------------------------------------------------------- /extensions/spring/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | 7 | com.google.inject.extensions 8 | extensions-parent 9 | 7.0.1-SNAPSHOT 10 | 11 | 12 | guice-spring 13 | 14 | Google Guice - Extensions - Spring 15 | 16 | 17 | 18 | org.springframework 19 | spring-beans 20 | 5.3.18 21 | provided 22 | 23 | 24 | 25 | 26 | 27 | 28 | maven-jar-plugin 29 | 30 | 31 | 32 | com.google.guice.extensions.spring 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /extensions/spring/src/com/google/inject/spring/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Google Inc. All rights reserved. 2 | # Author: sameb@google.com (Sam Berlin) 3 | load("@rules_java//java:defs.bzl", "java_library") 4 | load( 5 | "//:build_defs.bzl", 6 | "JAVAC_OPTS", 7 | "POM_VERSION", 8 | ) 9 | load("//:mvn.bzl", "gen_maven_artifact") 10 | 11 | package( 12 | default_visibility = ["//:src"], 13 | ) 14 | 15 | java_library( 16 | name = "spring", 17 | srcs = glob(["*.java"]), 18 | javacopts = JAVAC_OPTS, 19 | tags = ["maven_coordinates=com.google.inject.extensions:guice-spring:" + POM_VERSION], 20 | deps = [ 21 | "//core/src/com/google/inject", 22 | "//third_party/java/guava/base", 23 | "//third_party/java/spring:beans", 24 | ], 25 | ) 26 | 27 | filegroup( 28 | name = "javadoc-srcs", 29 | srcs = glob(["*.java"]), 30 | ) 31 | 32 | gen_maven_artifact( 33 | name = "artifact", 34 | artifact_id = "guice-spring", 35 | artifact_name = "Google Guice - Extensions - Spring", 36 | artifact_target = ":spring", 37 | is_extension = True, 38 | javadoc_srcs = [":javadoc-srcs"], 39 | ) 40 | -------------------------------------------------------------------------------- /extensions/spring/src/com/google/inject/spring/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** Spring integration; this extension requires {@code guice-spring.jar}. */ 18 | package com.google.inject.spring; 19 | -------------------------------------------------------------------------------- /extensions/struts2/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | -------------------------------------------------------------------------------- /extensions/struts2/build.properties: -------------------------------------------------------------------------------- 1 | module=com.google.inject.struts2 2 | fragment=true 3 | -------------------------------------------------------------------------------- /extensions/struts2/example/build.properties: -------------------------------------------------------------------------------- 1 | lib.dir=../lib 2 | src.dir=src 3 | build.dir=build 4 | -------------------------------------------------------------------------------- /extensions/struts2/example/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /extensions/struts2/example/root/Counter.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="s" uri="/struts-tags" %> 2 | 3 | 4 | 5 |

Counter Example

6 |

Hits in this session: 7 |

8 | 9 |

Status: 10 |

11 | 12 |

Message: 13 |

14 | 15 | 16 | -------------------------------------------------------------------------------- /extensions/struts2/example/root/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | com.google.inject.struts2.example.ExampleListener 9 | 10 | 11 | 12 | guice 13 | com.google.inject.servlet.GuiceFilter 14 | 15 | 16 | 17 | guice 18 | /* 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /extensions/struts2/example/src/com/google/inject/struts2/example/Counter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.struts2.example; 18 | 19 | import com.google.inject.servlet.SessionScoped; 20 | 21 | /** Session-scoped counter. */ 22 | @SessionScoped 23 | public class Counter { 24 | 25 | int count = 0; 26 | 27 | /** Increments the count and returns the new value. */ 28 | public synchronized int increment() { 29 | return count++; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /extensions/struts2/example/src/com/google/inject/struts2/example/Service.java: -------------------------------------------------------------------------------- 1 | package com.google.inject.struts2.example; 2 | 3 | public interface Service { 4 | 5 | String getStatus(); 6 | } 7 | -------------------------------------------------------------------------------- /extensions/struts2/example/src/com/google/inject/struts2/example/ServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.google.inject.struts2.example; 2 | 3 | public class ServiceImpl implements Service { 4 | 5 | public String getStatus() { 6 | return "We're looking good."; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /extensions/struts2/example/src/struts.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | /Counter.jsp 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /extensions/struts2/src/com/google/inject/struts2/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Google Inc. All rights reserved. 2 | # Author: sameb@google.com (Sam Berlin) 3 | 4 | package( 5 | 6 | default_visibility = ["//:src"], 7 | ) 8 | 9 | # Note: The struts2 build does not support jakarta.servlet, so it is not in the opensource build. 10 | -------------------------------------------------------------------------------- /extensions/struts2/src/com/google/inject/struts2/Struts2GuicePluginModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.struts2; 18 | 19 | import com.google.inject.AbstractModule; 20 | 21 | /** 22 | * Initializes the Struts 2 Guice Plugin. Must be added to the injector returned by {@link 23 | * com.google.inject.servlet.GuiceServletContextListener#getInjector}. 24 | * 25 | * @author benmccann.com 26 | */ 27 | public class Struts2GuicePluginModule extends AbstractModule { 28 | 29 | @Override 30 | protected void configure() { 31 | requestStaticInjection(Struts2Factory.class); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /extensions/struts2/src/struts-plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /extensions/struts2/test/com/google/inject/struts2/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Google Inc. All Rights Reserved. 2 | # Author: sameb@google.com (Sam Berlin) 3 | 4 | package( 5 | 6 | default_testonly = 1, 7 | ) 8 | 9 | # Note: The struts2 build does not support jakarta.servlet, so it is not in the opensource build. 10 | -------------------------------------------------------------------------------- /extensions/testlib/build.properties: -------------------------------------------------------------------------------- 1 | module=com.google.inject.testing 2 | fragment=true 3 | -------------------------------------------------------------------------------- /extensions/testlib/src/com/google/inject/testing/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. All rights reserved. 2 | load("@rules_java//java:defs.bzl", "java_library") 3 | load("//:mvn.bzl", "gen_maven_artifact") 4 | load( 5 | "//:build_defs.bzl", 6 | "POM_VERSION", 7 | ) 8 | 9 | package( 10 | 11 | default_testonly = 1, 12 | default_visibility = ["//:src"], 13 | ) 14 | 15 | java_library( 16 | name = "testlib", 17 | tags = ["maven_coordinates=com.google.inject.extensions:guice-testlib:" + POM_VERSION], 18 | exports = [ 19 | "//extensions/testlib/src/com/google/inject/testing/fieldbinder", 20 | "//extensions/testlib/src/com/google/inject/testing/throwingproviders", 21 | ], 22 | ) 23 | 24 | gen_maven_artifact( 25 | name = "artifact", 26 | artifact_id = "guice-testlib", 27 | artifact_name = "Google Guice - Extensions - TestLib", 28 | artifact_target = ":testlib", 29 | artifact_target_libs = [ 30 | "//extensions/testlib/src/com/google/inject/testing/fieldbinder", 31 | "//extensions/testlib/src/com/google/inject/testing/throwingproviders", 32 | ], 33 | is_extension = True, 34 | javadoc_srcs = [ 35 | "//extensions/testlib/src/com/google/inject/testing/fieldbinder:javadoc-srcs", 36 | "//extensions/testlib/src/com/google/inject/testing/throwingproviders:javadoc-srcs", 37 | ], 38 | ) 39 | -------------------------------------------------------------------------------- /extensions/testlib/src/com/google/inject/testing/fieldbinder/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # Author: eatnumber1@google.com (Russ Harmon) 3 | load("@rules_java//java:defs.bzl", "java_library") 4 | load( 5 | "//:build_defs.bzl", 6 | "JAVAC_OPTS", 7 | ) 8 | 9 | package( 10 | default_testonly = 1, 11 | default_visibility = ["//:src"], 12 | ) 13 | 14 | java_library( 15 | name = "fieldbinder", 16 | srcs = glob(["*.java"]), 17 | javacopts = JAVAC_OPTS, 18 | deps = [ 19 | "//core/src/com/google/inject", 20 | "//third_party/java/error_prone:annotations", 21 | "//third_party/java/guava/base", 22 | "//third_party/java/guava/collect", 23 | "//third_party/java/jakarta_inject", 24 | ], 25 | ) 26 | 27 | filegroup( 28 | name = "javadoc-srcs", 29 | srcs = glob(["*.java"]), 30 | ) 31 | -------------------------------------------------------------------------------- /extensions/testlib/src/com/google/inject/testing/throwingproviders/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_library") 2 | load( 3 | "//:build_defs.bzl", 4 | "JAVAC_OPTS", 5 | ) 6 | 7 | package( 8 | default_testonly = 1, 9 | default_visibility = ["//:src"], 10 | ) 11 | 12 | java_library( 13 | name = "throwingproviders", 14 | srcs = glob(["*.java"]), 15 | javacopts = JAVAC_OPTS, 16 | deps = [ 17 | "//extensions/throwingproviders/src/com/google/inject/throwingproviders", 18 | "//third_party/java/jsr305_annotations", 19 | "//third_party/java/truth", 20 | ], 21 | ) 22 | 23 | filegroup( 24 | name = "javadoc-srcs", 25 | srcs = glob(["*.java"]), 26 | ) 27 | -------------------------------------------------------------------------------- /extensions/testlib/test/com/google/inject/testing/fieldbinder/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # Author: eatnumber1@google.com (Russ Harmon) 3 | load("@rules_java//java:defs.bzl", "java_library") 4 | load("//:build_defs.bzl", "JAVAC_OPTS") 5 | load("//:test_defs.bzl", "guice_test_suites") 6 | 7 | package( 8 | default_testonly = 1, 9 | ) 10 | 11 | java_library( 12 | name = "tests", 13 | srcs = glob(["*.java"]), 14 | javacopts = JAVAC_OPTS, 15 | deps = [ 16 | "//core/src/com/google/inject", 17 | "//core/test/com/google/inject:testsupport", 18 | "//extensions/testlib/src/com/google/inject/testing/fieldbinder", 19 | "//third_party/java/guava/collect", 20 | "//third_party/java/jakarta_inject", 21 | "//third_party/java/junit", 22 | ], 23 | ) 24 | 25 | guice_test_suites( 26 | name = "gen_tests", 27 | sizes = ["small"], 28 | deps = [ 29 | ":tests", 30 | ], 31 | ) 32 | 33 | guice_test_suites( 34 | name = "gen_tests_OFF", 35 | args = [ 36 | "--guice_include_stack_traces=OFF", 37 | ], 38 | sizes = ["small"], 39 | suffix = "_stack_trace_OFF", 40 | deps = [ 41 | ":tests", 42 | ], 43 | ) 44 | -------------------------------------------------------------------------------- /extensions/testlib/test/com/google/inject/testing/fieldbinder/TestPermit.java: -------------------------------------------------------------------------------- 1 | package com.google.inject.testing.fieldbinder; 2 | 3 | import static java.lang.annotation.ElementType.TYPE; 4 | import static java.lang.annotation.ElementType.TYPE_USE; 5 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 6 | 7 | import com.google.inject.RestrictedBindingSource; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.Target; 10 | 11 | /** Test annotation used to test restricted binding source feature in Kotlin. */ 12 | @RestrictedBindingSource.Permit 13 | @Retention(RUNTIME) 14 | @Target({TYPE, TYPE_USE}) 15 | public @interface TestPermit {} 16 | -------------------------------------------------------------------------------- /extensions/testlib/test/com/google/inject/testing/throwingproviders/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_library") 2 | load("//:build_defs.bzl", "JAVAC_OPTS") 3 | load("//:test_defs.bzl", "guice_test_suites") 4 | 5 | package( 6 | default_testonly = 1, 7 | ) 8 | 9 | java_library( 10 | name = "tests", 11 | srcs = glob(["*.java"]), 12 | javacopts = JAVAC_OPTS, 13 | deps = [ 14 | "//extensions/testlib/src/com/google/inject/testing/throwingproviders", 15 | "//extensions/throwingproviders/src/com/google/inject/throwingproviders", 16 | "//third_party/java/junit", 17 | "//third_party/java/truth", 18 | ], 19 | ) 20 | 21 | guice_test_suites( 22 | name = "gen_tests", 23 | sizes = ["small"], 24 | deps = [":tests"], 25 | ) 26 | -------------------------------------------------------------------------------- /extensions/throwingproviders/build.properties: -------------------------------------------------------------------------------- 1 | module=com.google.inject.throwingproviders 2 | fragment=true 3 | -------------------------------------------------------------------------------- /extensions/throwingproviders/src/com/google/inject/throwingproviders/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Google Inc. All rights reserved. 2 | # Author: sameb@google.com (Sam Berlin) 3 | load("@rules_java//java:defs.bzl", "java_library") 4 | load( 5 | "//:build_defs.bzl", 6 | "JAVAC_OPTS", 7 | "POM_VERSION", 8 | ) 9 | load("//:mvn.bzl", "gen_maven_artifact") 10 | 11 | package( 12 | default_visibility = ["//:src"], 13 | ) 14 | 15 | java_library( 16 | name = "throwingproviders", 17 | srcs = glob(["*.java"]), 18 | javacopts = JAVAC_OPTS, 19 | tags = ["maven_coordinates=com.google.inject.extensions:guice-throwingproviders:" + POM_VERSION], 20 | deps = [ 21 | "//core/src/com/google/inject", 22 | "//third_party/java/error_prone:annotations", 23 | "//third_party/java/guava/base", 24 | "//third_party/java/guava/collect", 25 | "//third_party/java/jsr305_annotations", 26 | ], 27 | ) 28 | 29 | filegroup( 30 | name = "javadoc-srcs", 31 | srcs = glob(["*.java"]), 32 | ) 33 | 34 | gen_maven_artifact( 35 | name = "artifact", 36 | artifact_id = "guice-throwingproviders", 37 | artifact_name = "Google Guice - Extensions - ThrowingProviders", 38 | artifact_target = ":throwingproviders", 39 | is_extension = True, 40 | javadoc_srcs = [":javadoc-srcs"], 41 | ) 42 | -------------------------------------------------------------------------------- /extensions/throwingproviders/src/com/google/inject/throwingproviders/CheckedProviderWithDependencies.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.inject.throwingproviders; 18 | 19 | import com.google.inject.spi.HasDependencies; 20 | import com.google.inject.throwingproviders.ThrowingProviderBinder.SecondaryBinder; 21 | 22 | /** 23 | * A checked provider with dependencies, so {@link HasDependencies} can be implemented when using 24 | * the {@link SecondaryBinder#using} methods. 25 | * 26 | * @author sameb@google.com (Sam Berlin) 27 | */ 28 | interface CheckedProviderWithDependencies extends CheckedProvider, HasDependencies {} 29 | -------------------------------------------------------------------------------- /extensions/throwingproviders/src/com/google/inject/throwingproviders/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Extension for injecting objects that may throw at provision time; this extension requires {@code 19 | * guice-throwingproviders.jar}. 20 | */ 21 | package com.google.inject.throwingproviders; 22 | -------------------------------------------------------------------------------- /third_party/java/aopalliance/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "aopalliance", 5 | actual = "@maven//:aopalliance_aopalliance", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/asm/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "asm", 5 | actual = "@maven//:org_ow2_asm_asm", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/auto/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "value", 5 | actual = "@maven//:com_google_auto_value_auto_value", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/bnd/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "bndlib", 5 | actual = "@maven//:biz_aQute_bnd_bndlib", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/dagger/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "dagger", 5 | actual = "@maven//:com_google_dagger_dagger", 6 | ) 7 | 8 | alias( 9 | name = "producers", 10 | actual = "@maven//:com_google_dagger_dagger_producers", 11 | ) 12 | -------------------------------------------------------------------------------- /third_party/java/easymock/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "easymock", 5 | actual = "@maven//:org_easymock_easymock", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/error_prone/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "annotations", 5 | actual = "@maven//:com_google_errorprone_error_prone_annotations", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/guava/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | -------------------------------------------------------------------------------- /third_party/java/guava/annotations/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "annotations", 5 | actual = "@maven//:com_google_guava_guava", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/guava/base/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "base", 5 | actual = "@maven//:com_google_guava_guava", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/guava/cache/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "cache", 5 | actual = "@maven//:com_google_guava_guava", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/guava/collect/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "collect", 5 | actual = "@maven//:com_google_guava_guava", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/guava/escape/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "escape", 5 | actual = "@maven//:com_google_guava_guava", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/guava/io/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "io", 5 | actual = "@maven//:com_google_guava_guava", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/guava/net/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "net", 5 | actual = "@maven//:com_google_guava_guava", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/guava/primitives/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "primitives", 5 | actual = "@maven//:com_google_guava_guava", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/guava/testing/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "testing", 5 | actual = "@maven//:com_google_guava_guava_testlib", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/guava/util/concurrent/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "concurrent", 5 | actual = "@maven//:com_google_guava_guava", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/hamcrest/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "hamcrest", 5 | actual = "@maven//:org_hamcrest_hamcrest", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/hibernate/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "hibernate5", 5 | actual = "@maven//:org_hibernate_hibernate_core_jakarta", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/hsqldb/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "hsqldb2", 5 | actual = "@maven//:org_hsqldb_hsqldb_j5", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/jakarta_inject/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "jakarta_inject", 5 | actual = "@maven//:jakarta_inject_jakarta_inject_api", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/jakarta_inject_tck/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "jakarta_inject_tck", 5 | actual = "@maven//:jakarta_inject_jakarta_inject_tck", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/jakarta_persistence/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "jakarta_persistence", 5 | actual = "@maven//:jakarta_persistence_jakarta_persistence_api", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/jakarta_servlet_api/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "jakarta_servlet_api", 5 | actual = "@maven//:jakarta_servlet_jakarta_servlet_api", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/jspecify_annotations/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "jspecify_annotations", 5 | actual = "@maven//:org_jspecify_jspecify", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/jsr305_annotations/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "jsr305_annotations", 5 | actual = "@maven//:com_google_code_findbugs_jsr305", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/junit/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_library") 2 | 3 | package(default_visibility = ["//:src"]) 4 | 5 | java_library( 6 | name = "junit", 7 | testonly = 1, 8 | exports = [ 9 | "@maven//:junit_junit", 10 | "@maven//:org_hamcrest_hamcrest", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /third_party/java/mockito/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "mockito", 5 | actual = "@maven//:org_mockito_mockito_core", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/picocli/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:src"]) 2 | 3 | alias( 4 | name = "picocli", 5 | actual = "@maven//:info_picocli_picocli", 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/java/spring/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_library") 2 | 3 | package(default_visibility = ["//:src"]) 4 | 5 | java_library( 6 | name = "beans", 7 | exports = [ 8 | "@maven//:org_springframework_spring_beans", 9 | "@maven//:org_springframework_spring_core", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /third_party/java/struts2/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_library") 2 | 3 | package(default_visibility = ["//:src"]) 4 | 5 | java_library( 6 | name = "struts2", 7 | exports = [ 8 | "@maven//:org_apache_struts_struts2_core", 9 | "@maven//:org_apache_struts_xwork_xwork_core", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /third_party/java/truth/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_library") 2 | 3 | package(default_visibility = ["//:src"]) 4 | 5 | java_library( 6 | name = "truth", 7 | testonly = True, 8 | exports = [ 9 | "@maven//:com_google_truth_extensions_truth_java8_extension", 10 | "@maven//:com_google_truth_truth", 11 | ], 12 | runtime_deps = [ 13 | "//third_party/java/asm", 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /tools/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_binary") 2 | 3 | package( 4 | default_visibility = ["//:src"], 5 | ) 6 | 7 | java_binary( 8 | name = "osgi_wrapper", 9 | srcs = ["OsgiWrapper.java"], 10 | main_class = "com.google.inject.tools.OsgiWrapper", 11 | deps = [ 12 | "//third_party/java/bnd:bndlib", 13 | "//third_party/java/guava/io", 14 | "//third_party/java/picocli", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /util/api-diffs.index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Guice API changes 7 | 8 | 9 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /util/diff-jars.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | while getopts o:n: flag 4 | do 5 | case "${flag}" in 6 | o) OLD_VERSION=${OPTARG};; 7 | n) NEW_VERSION=${OPTARG};; 8 | esac 9 | done 10 | 11 | BASE_URL=https://repo1.maven.org/maven2/com/google/inject 12 | REPO_DIR=$PWD 13 | 14 | # Downloading old versions from maven central 15 | mkdir -p /tmp/guice-jars 16 | cd /tmp/guice-jars 17 | 18 | echo "Old version: $OLD_VERSION, new version: $NEW_VERSION" 19 | 20 | echo "Downloading core..." 21 | wget $BASE_URL/guice/$OLD_VERSION/guice-$OLD_VERSION.jar 22 | 23 | echo "Diffing core..." 24 | pkgdiff guice-$OLD_VERSION.jar $REPO_DIR/core/target/guice-$NEW_VERSION.jar & 25 | 26 | # struts2 not listed because we don't build it past the 7.0 line. 27 | for EXT in assistedinject dagger-adapter grapher jmx jndi persist servlet spring testlib throwingproviders 28 | do 29 | echo "Dowloading $EXT extension..." 30 | wget $BASE_URL/extensions/guice-$EXT/$OLD_VERSION/guice-$EXT-$OLD_VERSION.jar 31 | echo "Diffing $EXT..." 32 | pkgdiff guice-$EXT-$OLD_VERSION.jar $REPO_DIR/extensions/$EXT/target/guice-$EXT-$NEW_VERSION.jar & 33 | done 34 | 35 | python3 -m http.server --directory pkgdiff_reports/ 36 | -------------------------------------------------------------------------------- /util/generate-latest-docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | echo -e "Generating latest javadoc & JDiff...\n" 6 | 7 | if [[ -d "build/docs" ]]; then 8 | rm -r build/docs 9 | fi 10 | 11 | mkdir -p build/docs/{javadoc,api-diffs} 12 | 13 | mvn clean install -Dguice.skipTests=true 14 | mvn javadoc:aggregate -Dguice.skipTests=true 15 | cp -r target/site/apidocs/* build/docs/javadoc 16 | 17 | cp util/api-diffs.index.html build/docs/api-diffs/index.html 18 | 19 | mvn spf4j-jdiff:jdiff -pl core -Dguice.skipTests=true 20 | cp -r core/target/site/api-diffs/* build/docs/api-diffs/ 21 | 22 | EXTENSIONS=( $(ls -1 $(dirname $0)/../extensions) ) 23 | for ext in "${EXTENSIONS[@]}" 24 | do 25 | if [[ $ext == 'struts2' ]]; then 26 | continue # struts2 doesn't support jakarta, so we drop support. 27 | fi 28 | if [[ -f extensions/$ext/pom.xml ]]; then 29 | echo -e "Generating latest API diff for extension ${ext}\n" 30 | mvn spf4j-jdiff:jdiff -pl extensions/$ext -Dguice.skipTests=true 31 | cp -r extensions/$ext/target/site/api-diffs/* build/docs/api-diffs/ 32 | fi 33 | done 34 | 35 | # Hacky way to remove the ugly blue background on jdiff reports 36 | find build/docs/api-diffs -name stylesheet-jdiff.css \ 37 | | xargs sed -i 's/background: #CCFFFF url(background.gif);//g' 38 | -------------------------------------------------------------------------------- /util/install-local-snapshot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | echo -e "Installing maven snapshot locally...\n" 6 | 7 | bash $(dirname $0)/deploy-guice.sh \ 8 | "install:install-file" \ 9 | "LOCAL-SNAPSHOT" -------------------------------------------------------------------------------- /util/publish-latest-docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | bash $(dirname $0)/generate-latest-docs.sh 6 | 7 | echo -e "Publishing javadoc & JDiff...\n" 8 | mkdir -p $HOME/guice-docs/latest 9 | cp -R build/docs/* $HOME/guice-docs/latest/ 10 | 11 | cd $HOME 12 | git config --global user.email "guice-dev+github@google.com" 13 | git config --global user.name "guice-dev+github" 14 | git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/google/guice gh-pages > /dev/null 15 | 16 | cd gh-pages 17 | if [[ -d api-docs/latest ]]; then 18 | git rm -rf api-docs/latest 19 | fi 20 | mkdir -p api-docs/latest 21 | cp -rf $HOME/guice-docs/latest/* api-docs/latest/ 22 | git add -f . 23 | git commit -m "Latest javadoc & api-diffs on successful CI build $GITHUB_SHA auto-pushed to gh-pages" 24 | git push -fq origin gh-pages > /dev/null 25 | 26 | echo -e "Published Javadoc & JDiff to gh-pages.\n" 27 | --------------------------------------------------------------------------------