public void configureHighlightingTokenDefProvider(final Binder binder) { AnnotatedBindingBuilder<ITokenDefProvider> _bind = binder.<ITokenDefProvider>bind(ITokenDefProvider.class); Named _named = Names.named(LexerIdeBindings.HIGHLIGHTING); LinkedBindingBuilder<ITokenDefProvider> _annotatedWith = _bind.annotatedWith(_named); _annotatedWith.to(AntlrTokenDefProvider.class); }
public void configureLanguageSpecificPsiModelAssociations(final Binder binder) { AnnotatedBindingBuilder<IPsiModelAssociations> _bind = binder.<IPsiModelAssociations>bind(IPsiModelAssociations.class); LinkedBindingBuilder<IPsiModelAssociations> _annotatedWith = _bind.annotatedWith(LanguageSpecific.class); _annotatedWith.to(PsiModelAssociations.class); }
public void configureResourceBaseProvider(final Binder binder) { AnnotatedBindingBuilder<IResourceBaseProvider> _bind = binder.<IResourceBaseProvider>bind(IResourceBaseProvider.class); String _resourceBase = this.getResourceBase(); ResourceBaseProviderImpl _resourceBaseProviderImpl = new ResourceBaseProviderImpl(_resourceBase); _bind.toInstance(_resourceBaseProviderImpl); }
public void configureLineSeparatorInformation(final Binder binder) { AnnotatedBindingBuilder<ILineSeparatorInformation> _bind = binder.<ILineSeparatorInformation>bind(ILineSeparatorInformation.class); final ILineSeparatorInformation _function = new ILineSeparatorInformation() { @Override public String getLineSeparator() { return DefaultGeneratorModule.this.code.getLineDelimiter(); } }; _bind.toInstance(_function); }
public void configureIEncodingProvider(final Binder binder) { AnnotatedBindingBuilder<IEncodingProvider> _bind = binder.<IEncodingProvider>bind(IEncodingProvider.class); IEncodingProvider.Runtime _runtime = new IEncodingProvider.Runtime(); final Procedure1<IEncodingProvider.Runtime> _function = new Procedure1<IEncodingProvider.Runtime>() { @Override public void apply(final IEncodingProvider.Runtime it) { String _encoding = DefaultGeneratorModule.this.code.getEncoding(); it.setDefaultEncoding(_encoding); } }; IEncodingProvider.Runtime _doubleArrow = ObjectExtensions.<IEncodingProvider.Runtime>operator_doubleArrow(_runtime, _function); _bind.toInstance(_doubleArrow); }
@Override protected void bindSessionManager(final AnnotatedBindingBuilder<SessionManager> bind) { // use native web session management instead of delegating to servlet container // workaround for NEXUS-5727, see NexusDefaultWebSessionManager javadoc for clues bind.to(NexusWebSessionManager.class).asEagerSingleton(); // this is a PrivateModule, so explicitly binding the NexusDefaultSessionManager class bind(NexusWebSessionManager.class); }
@SuppressWarnings({"unchecked", "rawtypes"}) @Before public void before() { binder = mock(PrivateBinder.class); AnnotatedBindingBuilder ab = mock(AnnotatedBindingBuilder.class); when(binder.bind(any(Class.class))).thenReturn(ab); when(ab.annotatedWith(any(Annotation.class))).thenReturn(ab); AnnotatedElementBuilder aeb = mock(AnnotatedElementBuilder.class); when(binder.expose(any(Class.class))).thenReturn(aeb); ScopedBindingBuilder sb = mock(ScopedBindingBuilder.class); when(ab.toProvider(any(Class.class))).thenReturn(sb); when(binder.bind(any(TypeLiteral.class))).thenReturn(ab); when(binder.skipSources(any(Class.class), any(Class.class))).thenReturn(binder); securityConfigurer = mock(SeedSecurityConfigurer.class); underTest = new SecurityInternalModule( securityConfigurer, new HashMap<String, Class<? extends Scope>>()); Whitebox.setInternalState(underTest, "binder", binder); }
/** * Binds the security manager. Override this method in order to provide your own security manager * binding. * * <p>By default, a {@link org.apache.shiro.mgt.DefaultSecurityManager} is bound as an eager * singleton. * * @param bind */ protected void bindSecurityManager(AnnotatedBindingBuilder<? super SecurityManager> bind) { try { bind.toConstructor(DefaultSecurityManager.class.getConstructor(Collection.class)) .asEagerSingleton(); } catch (NoSuchMethodException e) { throw new ConfigurationException( "This really shouldn't happen. Either something has changed in Shiro, or there's a bug in " + ShiroModule.class.getSimpleName(), e); } }
@Override @SuppressWarnings("unchecked") protected void configure() { // Bind mock controllet to this instance, to automatically replay/verify all mocks created by // runner. bind(MockController.class).toInstance(this); // map field values by type for (Field field : fields.keySet()) { TypeLiteral literal = TypeLiteral.get(field.getGenericType()); AnnotatedBindingBuilder builder = bind(literal); // Check field annotations. Annotation[] fieldAnnotations = field.getAnnotations(); for (Annotation annotation : fieldAnnotations) { Class<? extends Annotation> annotationType = annotation.annotationType(); if ( /* annotationType.isAnnotationPresent(Qualifier.class)|| */ annotationType .isAnnotationPresent(BindingAnnotation.class)) { builder.annotatedWith(annotation); } if (annotationType.isAnnotationPresent(ScopeAnnotation.class)) { builder.in(annotationType); } } Binding binding = fields.get(field); if (null != binding.getValue()) { builder.toInstance(binding.getValue()); } else if (null != binding.getImplementation()) { builder.to(binding.getImplementation()); } else if (null != binding.getProvider()) { builder.toProvider(binding.getProvider()); } } }
@Override protected void bindWebSecurityManager( final AnnotatedBindingBuilder<? super WebSecurityManager> bind) { bind(NexusWebSecurityManager.class).asEagerSingleton(); // bind RealmSecurityManager and WebSecurityManager to _same_ component bind(RealmSecurityManager.class).to(NexusWebSecurityManager.class); bind.to(NexusWebSecurityManager.class); // bindings used by external modules expose(RealmSecurityManager.class); expose(WebSecurityManager.class); }
@SuppressWarnings("unchecked") @Test public void configure() { Binder binder = createNiceMock(Binder.class); AnnotatedBindingBuilder<LangFactory> bindLangFactory = createMock(AnnotatedBindingBuilder.class); AnnotatedBindingBuilder<ILinkingDiagnosticMessageProvider.Extended> bindLinkingDMP = createMock(AnnotatedBindingBuilder.class); AnnotatedBindingBuilder<ILaunchManager> bindLaunchManager = createMock(AnnotatedBindingBuilder.class); final ILaunchManager launchManager = createMock(ILaunchManager.class); final AnnotatedBindingBuilder<Console> bindConsole = createMock(AnnotatedBindingBuilder.class); final Console console = createMock(Console.class); expect(binder.bind(LangFactory.class)).andReturn(bindLangFactory); expect(binder.bind(ILinkingDiagnosticMessageProvider.Extended.class)).andReturn(bindLinkingDMP); expect(binder.bind(ILaunchManager.class)).andReturn(bindLaunchManager); expect(binder.bind(Console.class)).andReturn(bindConsole); bindLangFactory.toInstance(LangFactory.eINSTANCE); expect(bindLinkingDMP.to(Antlr4MissingReferenceMessageProvider.class)).andReturn(null); bindLaunchManager.toInstance(launchManager); bindConsole.toInstance(console); Object[] mocks = {binder, bindLangFactory, bindLinkingDMP, launchManager, console}; replay(mocks); new Antlr4RuntimeModule() { @Override protected ILaunchManager getLaunchManager() { return launchManager; } @Override protected Console getConsole() { return console; } }.configure(binder); verify(mocks); }
protected void bindCallableStatementExecutorBlockService( AnnotatedBindingBuilder<CallableStatementExecutorBlockService> builder) { builder.to(CallableStatementExecutorBlockServiceImpl.class); }
protected void bindOutputParametersGetterBlockService( AnnotatedBindingBuilder<OutputParametersGetterBlockService> builder) { builder.to(OutputParametersGetterBlockServiceImpl.class); }
protected void bindDaoMethodInfo(AnnotatedBindingBuilder<DAOMethodInfo> builder) { builder.to(DaoMethodInfoGuice.class).in(Singleton.class); }
protected void bindParameterConverterService( AnnotatedBindingBuilder<ParameterConverterService> builder) { builder.to(ParameterConverterServiceImpl.class); }
/** * Binds the environment. Override this method in order to provide your own environment binding. * * <p>By default, a {@link GuiceEnvironment} is bound as an eager singleton. * * @param bind */ protected void bindEnvironment(AnnotatedBindingBuilder<Environment> bind) { bind.to(GuiceEnvironment.class).asEagerSingleton(); }
protected void bindCallableStatementSetStrategyFactory( AnnotatedBindingBuilder<ICallableStatementSetStrategyFactory> aBuilder) { aBuilder.to(CallableStatementSetStrategyFactoryNameImpl.class); }
protected void bindSettings(AnnotatedBindingBuilder<Settings> bindSettings) { bindSettings.to(DefaultSettings.class); }
protected void bindResultSetConverterBlockService( AnnotatedBindingBuilder<ResultSetConverterBlockService> builder) { builder.to(ResultSetConverterBlockServiceImpl.class); }
public void configureCodeConfig(final Binder binder) { AnnotatedBindingBuilder<CodeConfig> _bind = binder.<CodeConfig>bind(CodeConfig.class); _bind.toInstance(this.code); }
public void configureResourceSet(final Binder binder) { AnnotatedBindingBuilder<ResourceSet> _bind = binder.<ResourceSet>bind(ResourceSet.class); _bind.to(XtextResourceSet.class); }
@Override protected void configure() { AnnotatedBindingBuilder<Resource.Factory> _bind = this.<Resource.Factory>bind(Resource.Factory.class); _bind.to(JavaResource.Factory.class); AnnotatedBindingBuilder<IResourceValidator> _bind_1 = this.<IResourceValidator>bind(IResourceValidator.class); _bind_1.toInstance(IResourceValidator.NULL); AnnotatedBindingBuilder<IGenerator> _bind_2 = this.<IGenerator>bind(IGenerator.class); _bind_2.to(IGenerator.NullGenerator.class); AnnotatedBindingBuilder<IEncodingProvider> _bind_3 = this.<IEncodingProvider>bind(IEncodingProvider.class); _bind_3.to(IEncodingProvider.Runtime.class); AnnotatedBindingBuilder<IResourceServiceProvider> _bind_4 = this.<IResourceServiceProvider>bind(IResourceServiceProvider.class); _bind_4.to(JavaResourceServiceProvider.class); AnnotatedBindingBuilder<IContainer.Manager> _bind_5 = this.<IContainer.Manager>bind(IContainer.Manager.class); _bind_5.to(SimpleResourceDescriptionsBasedContainerManager.class); AnnotatedBindingBuilder<IResourceDescription.Manager> _bind_6 = this.<IResourceDescription.Manager>bind(IResourceDescription.Manager.class); _bind_6.to(JavaResourceDescriptionManager.class); AnnotatedBindingBuilder<IQualifiedNameProvider> _bind_7 = this.<IQualifiedNameProvider>bind(IQualifiedNameProvider.class); _bind_7.to(JvmIdentifiableQualifiedNameProvider.class); AnnotatedBindingBuilder<String> _bind_8 = this.<String>bind(String.class); Named _named = Names.named(Constants.FILE_EXTENSIONS); LinkedBindingBuilder<String> _annotatedWith = _bind_8.annotatedWith(_named); _annotatedWith.toInstance("java"); AnnotatedBindingBuilder<String> _bind_9 = this.<String>bind(String.class); Named _named_1 = Names.named(Constants.LANGUAGE_NAME); LinkedBindingBuilder<String> _annotatedWith_1 = _bind_9.annotatedWith(_named_1); _annotatedWith_1.toInstance("org.eclipse.xtext.java.Java"); AnnotatedBindingBuilder<IJvmTypeProvider.Factory> _bind_10 = this.<IJvmTypeProvider.Factory>bind(IJvmTypeProvider.Factory.class); _bind_10.to(ClasspathTypeProviderFactory.class); AnnotatedBindingBuilder<ClassLoader> _bind_11 = this.<ClassLoader>bind(ClassLoader.class); ClassLoader _classLoader = JavaSourceLanguageRuntimeModule.class.getClassLoader(); _bind_11.toInstance(_classLoader); AnnotatedBindingBuilder<IReferableElementsUnloader> _bind_12 = this.<IReferableElementsUnloader>bind(IReferableElementsUnloader.class); _bind_12.to(IReferableElementsUnloader.GenericUnloader.class); AnnotatedBindingBuilder<IResourceDescriptionsProvider> _bind_13 = this.<IResourceDescriptionsProvider>bind(IResourceDescriptionsProvider.class); final IResourceDescriptionsProvider _function = new IResourceDescriptionsProvider() { @Override public IResourceDescriptions getResourceDescriptions(final ResourceSet it) { return ChunkedResourceDescriptions.findInEmfObject(it); } }; _bind_13.toInstance(_function); }
/** * Binds the session manager. Override this method in order to provide your own session manager * binding. * * <p>By default, a {@link org.apache.shiro.session.mgt.DefaultSessionManager} is bound as an * eager singleton. * * @param bind */ protected void bindSessionManager(AnnotatedBindingBuilder<SessionManager> bind) { bind.to(DefaultSessionManager.class).asEagerSingleton(); }
public ScopedBindingBuilder configureContentAssistLexer(final Binder binder) { AnnotatedBindingBuilder<Lexer> _bind = binder.<Lexer>bind(Lexer.class); Named _named = Names.named(LexerIdeBindings.CONTENT_ASSIST); LinkedBindingBuilder<Lexer> _annotatedWith = _bind.annotatedWith(_named); return _annotatedWith.to(InternalEntitiesLexer.class); }
protected void bindParametersSetterBlockService( AnnotatedBindingBuilder<ParametersSetterBlockService> builder) { builder.to(ParametersSetterBlockServiceImpl.class); }
protected void bindProgressHandler(AnnotatedBindingBuilder<ProgressHandler> bindProgressHandler) { bindProgressHandler.to(BlockingProgressHandler.class); }
protected void bindRegisterOutParametersBlockService( AnnotatedBindingBuilder<RegisterOutParametersBlockService> builder) { builder.to(RegisterOutParametersBlockServiceImpl.class); }
protected void bindStoredProcedureInfoManager( AnnotatedBindingBuilder<IStoredProcedureInfoManager> builder) { builder.to(StoredProcedureInfoManagerInitOnStartup.class); }
public void configureXtextProjectConfig(final Binder binder) { AnnotatedBindingBuilder<IXtextProjectConfig> _bind = binder.<IXtextProjectConfig>bind(IXtextProjectConfig.class); _bind.toInstance(this.project); }
public void configureGlobalModificationTracker(final Binder binder) { AnnotatedBindingBuilder<Key> _bind = binder.<Key>bind(Key.class); Named _named = Names.named(BaseXtextFile.GLOBAL_MODIFICATION_COUNT); LinkedBindingBuilder<Key> _annotatedWith = _bind.annotatedWith(_named); _annotatedWith.toInstance(PsiModificationTracker.MODIFICATION_COUNT); }