com.google.inject.internal.UniqueAnnotations Java Examples

The following examples show how to use com.google.inject.internal.UniqueAnnotations. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JerseyMultiGuiceModule.java    From soabase with Apache License 2.0 5 votes vote down vote up
@Override
protected final void configure()
{
    internalConfigure();
    configureServlets();

    for ( FilterDefinition filterDefinition : filterDefinitions )
    {
        bind(FilterDefinition.class).annotatedWith(UniqueAnnotations.create()).toInstance(filterDefinition);
    }
    for ( ServletDefinition servletDefinition : servletDefinitions )
    {
        bind(ServletDefinition.class).annotatedWith(UniqueAnnotations.create()).toInstance(servletDefinition);
    }
}
 
Example #2
Source File: GuiceRsModule.java    From digdag with Apache License 2.0 5 votes vote down vote up
protected <T extends HttpServlet> ServletBindingBuilder bindServlet(Class<T> servlet)
{
    Annotation annotation = UniqueAnnotations.create();
    Key<T> servletKey = Key.get(servlet, UniqueAnnotations.create());
    binder().bind(servletKey).to(servlet).in(Scopes.SINGLETON);
    return new ServletBindingBuilder(binder(), servletKey);
}
 
Example #3
Source File: GuiceRsModule.java    From digdag with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public ApplicationBindingBuilder addResources(Class<?>... annotatedClass)
{
    for (Class<?> clazz : annotatedClass) {
        Key<Object> key = Key.get((Class<Object>) clazz, UniqueAnnotations.create());
        binder.bind(key).to(clazz);
        initializer.addResource(key, clazz);
    }
    return this;
}
 
Example #4
Source File: GuiceRsModule.java    From digdag with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public <T> ApplicationBindingBuilder addResources(Class<T> annotatedClass, Provider<? extends T> resourceProvider)
{
    Key<T> key = Key.get(annotatedClass, UniqueAnnotations.create());
    binder.bind(key).toProvider(resourceProvider);
    initializer.addResource((Key<Object>) key, annotatedClass);
    return this;
}
 
Example #5
Source File: GuiceRsModule.java    From digdag with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public ApplicationBindingBuilder addProvider(Class<?> annotatedClass)
{
    Key<Object> key = Key.get((Class<Object>) annotatedClass, UniqueAnnotations.create());
    binder.bind(key).to(annotatedClass);
    initializer.addProvider(key);
    return this;
}
 
Example #6
Source File: GuiceRsModule.java    From digdag with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public ApplicationBindingBuilder addProviderInstance(Object object)
{
    Key<Object> key = Key.get((Class<Object>) object.getClass(), UniqueAnnotations.create());
    binder.bind(key).toInstance(object);
    initializer.addProvider(key);
    return this;
}
 
Example #7
Source File: GuiceRsModule.java    From digdag with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public <T> ApplicationBindingBuilder addProvider(Class<T> annotatedClass, Provider<? extends T> providerProvider)
{
    Key<T> key = Key.get(annotatedClass, UniqueAnnotations.create());
    binder.bind(key).toProvider(providerProvider);
    initializer.addProvider((Key<Object>) key);
    return this;
}
 
Example #8
Source File: GuiceRsModule.java    From digdag with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public <T> ApplicationBindingBuilder addProvider(Class<T> annotatedClass, Class<? extends Provider<? extends T>> providerProvider)
{
    Key<T> key = Key.get(annotatedClass, UniqueAnnotations.create());
    binder.bind(key).toProvider(providerProvider);
    initializer.addProvider((Key<Object>) key);
    return this;
}
 
Example #9
Source File: GuiceBindingVisitor.java    From dropwizard-guicey with MIT License 5 votes vote down vote up
@Override
public BindingDeclaration visit(final InstanceBinding binding) {
    // Filter extension bindings, for example created for filter. Such bindings are marker as @Internal
    final Class annotationType = binding.getKey().getAnnotationType();
    if (annotationType != null && annotationType.getDeclaringClass() != null
            && annotationType.getDeclaringClass().equals(UniqueAnnotations.class)) {
        return null;
    }
    final BindingDeclaration res = new BindingDeclaration(DeclarationType.Instance, binding);
    res.setKey(binding.getKey());
    return res;
}
 
Example #10
Source File: FilterKeyBindingBuilderImpl.java    From soabase with Apache License 2.0 4 votes vote down vote up
public void through(Filter filter, Map<String, String> initParams)
{
    Key<Filter> filterKey = Key.get(Filter.class, UniqueAnnotations.create());
    module.add(filterKey, filter);
    through(filterKey, initParams, filter);
}
 
Example #11
Source File: ServletKeyBindingBuilderImpl.java    From soabase with Apache License 2.0 4 votes vote down vote up
public void with(HttpServlet servlet, Map<String, String> initParams)
{
    Key<HttpServlet> servletKey = Key.get(HttpServlet.class, UniqueAnnotations.create());
    module.add(servletKey, servlet);
    with(servletKey, initParams, servlet);
}
 
Example #12
Source File: GuiceRsModule.java    From digdag with Apache License 2.0 3 votes vote down vote up
AbstractServletBindingBuilder(Binder binder, Initializer initializer)
{
    this.initializer = initializer;
    binder.bind(GuiceRsServletInitializer.class).annotatedWith(UniqueAnnotations.create()).toInstance(initializer);
}