类com.google.inject.matcher.AbstractMatcher源码实例Demo

下面列出了怎么用com.google.inject.matcher.AbstractMatcher的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: EDDI   文件: BackupServiceModule.java
@Override
protected void configure() {
    registerConfigFiles(this.configFiles);
    bind(IRestExportService.class).to(RestExportService.class).in(Scopes.SINGLETON);
    bind(IRestImportService.class).to(RestImportService.class).in(Scopes.SINGLETON);
    bind(IRestGitBackupService.class).to(RestGitBackupService.class).in(Scopes.SINGLETON);

    // AutoGit Injection - all methods that are annotated with @ConfigurationUpdate and start with
    // update or delete trigger a new commit/push
    bindInterceptor(Matchers.any(), new AbstractMatcher<>() {
        @Override
        public boolean matches(Method method) {
            return method.isAnnotationPresent(IResourceStore.ConfigurationUpdate.class) && !method.isSynthetic();
        }

    }, new GitConfigurationUpdateService(getProvider(IRestGitBackupService.class),
                                         getProvider(IBotStore.class),
                                         getProvider(IDeploymentStore.class),
                                         getProvider(IPackageStore.class),
                                         getProvider(IJsonSerialization.class)));
    bind(IZipArchive.class).to(ZipArchive.class).in(Scopes.SINGLETON);
}
 
源代码2 项目: dropwizard-guicey   文件: ConstantModule.java
@Override
protected void configure() {
    convertToTypes(new AbstractMatcher<TypeLiteral<?>>() {
        @Override
        public boolean matches(TypeLiteral<?> typeLiteral) {
            return typeLiteral.getType().equals(Sample.class);
        }
    }, new TypeConverter() {
        @Override
        public Object convert(String value, TypeLiteral<?> toType) {
            return new Sample();
        }
    });
    bindConstant().annotatedWith(Names.named("smth")).to(12);
    bindConstant().annotatedWith(Names.named("string")).to("12");
}
 
源代码3 项目: dropwizard-guicey   文件: CasesModule.java
@Override
protected void configure() {
    bindListener(new AbstractMatcher<TypeLiteral<?>>() {
        @Override
        public boolean matches(TypeLiteral<?> typeLiteral) {
            return false;
        }
    }, new CustomTypeListener());

    bindListener(new AbstractMatcher<Object>() {
        @Override
        public boolean matches(Object o) {
            return false;
        }
    }, new CustomProvisionListener());

    bindInterceptor(Matchers.subclassesOf(AopedService.class), Matchers.any(),
            new CustomAop());

    bind(AopedService.class);
    bind(BindService.class).to(OverriddenService.class);
    bind(BindService2.class).toInstance(new BindService2() {});
}
 
源代码4 项目: guice-persist-orient   文件: RepositoryModule.java
/**
 * Configures repository annotations interceptor.
 */
protected void configureAop() {
    final RepositoryMethodInterceptor proxy = new RepositoryMethodInterceptor();
    requestInjection(proxy);
    // repository specific method annotations (query, function, delegate, etc.)
    bindInterceptor(Matchers.any(), new AbstractMatcher<Method>() {
        @Override
        public boolean matches(final Method method) {
            // this will throw error if two or more annotations specified (fail fast)
            try {
                return ExtUtils.findMethodAnnotation(method) != null;
            } catch (Exception ex) {
                throw new MethodDefinitionException(String.format("Error declaration on method %s",
                        RepositoryUtils.methodToString(method)), ex);
            }
        }
    }, proxy);
}
 
源代码5 项目: seed   文件: ValidationModule.java
private Matcher<? super Binding<?>> staticValidationMatcher() {
    return new AbstractMatcher<Binding<?>>() {
        @Override
        public boolean matches(Binding<?> binding) {
            Class<?> candidate = binding.getKey().getTypeLiteral().getRawType();
            for (Field field : candidate.getDeclaredFields()) {
                for (Annotation annotation : field.getAnnotations()) {
                    if (hasConstraintOrValidAnnotation(annotation)) {
                        return true;
                    }
                }
            }
            return false;
        }
    };
}
 
源代码6 项目: attic-aurora   文件: GuiceUtils.java
/**
 * Creates a matcher that will match methods of an interface, optionally excluding inherited
 * methods.
 *
 * @param matchInterface The interface to match.
 * @param declaredMethodsOnly if {@code true} only methods directly declared in the interface
 *                            will be matched, otherwise all methods on the interface are matched.
 * @return A new matcher instance.
 */
public static Matcher<Method> interfaceMatcher(
    Class<?> matchInterface,
    boolean declaredMethodsOnly) {

  Method[] methods =
      declaredMethodsOnly ? matchInterface.getDeclaredMethods() : matchInterface.getMethods();
  final Set<Pair<String, Class<?>[]>> interfaceMethods =
      ImmutableSet.copyOf(Iterables.transform(ImmutableList.copyOf(methods), CANONICALIZE));
  final LoadingCache<Method, Pair<String, Class<?>[]>> cache = CacheBuilder.newBuilder()
      .build(CacheLoader.from(CANONICALIZE));

  return new AbstractMatcher<Method>() {
    @Override
    public boolean matches(Method method) {
      return interfaceMethods.contains(cache.getUnchecked(method));
    }
  };
}
 
源代码7 项目: act-platform   文件: AbstractAspect.java
/**
 * Create a Matcher which matches against a service method.
 *
 * @return Matcher matching a service method
 */
Matcher<Method> matchServiceMethod() {
  return new AbstractMatcher<Method>() {
    @Override
    public boolean matches(Method method) {
      return isServiceMethod(method);
    }
  };
}
 
源代码8 项目: ProjectAres   文件: FunctionalMatcher.java
@Override
default Matcher<T> and(com.google.inject.matcher.Matcher<? super T> other) {
    return new AbstractMatcher<T>() {
        @Override public boolean matches(T t) {
            return FunctionalMatcher.this.matches(t) && other.matches(t);
        }
    };
}
 
源代码9 项目: ProjectAres   文件: FunctionalMatcher.java
@Override
default Matcher<T> or(com.google.inject.matcher.Matcher<? super T> other) {
    return new AbstractMatcher<T>() {
        @Override public boolean matches(T t) {
            return FunctionalMatcher.this.matches(t) || other.matches(t);
        }
    };
}
 
源代码10 项目: rh-che   文件: Fabric8WsMasterModule.java
@Override
protected void configure() {
  bind(GitHubOAuthAuthenticator.class)
      .to(OpenShiftGitHubOAuthAuthenticator.class)
      .asEagerSingleton();
  bind(OAuthAPIProvider.class).to(Fabric8OAuthAPIProvider.class);
  bind(KeycloakServiceClient.class).to(Fabric8AuthServiceClient.class).asEagerSingleton();
  final DisableAuthenticationInterceptor disableAuthenticationInterceptor =
      new DisableAuthenticationInterceptor();
  requestInjection(disableAuthenticationInterceptor);
  bindInterceptor(
      Matchers.subclassesOf(MultiUserEnvironmentInitializationFilter.class),
      new AbstractMatcher<Method>() {
        @Override
        public boolean matches(Method m) {
          return "doFilter".equals(m.getName());
        }
      },
      disableAuthenticationInterceptor);

  final Multibinder<MachineAuthenticatedResource> machineAuthenticatedResources =
      Multibinder.newSetBinder(binder(), MachineAuthenticatedResource.class);
  machineAuthenticatedResources
      .addBinding()
      .toInstance(
          new MachineAuthenticatedResource(
              "/fabric8-che-analytics", "segmentWriteKey", "woopraDomain", "warning", "error"));

  machineAuthenticatedResources
      .addBinding()
      .toInstance(new MachineAuthenticatedResource("/bayesian", "getBayesianToken"));
}
 
源代码11 项目: gef   文件: AdapterInjectionSupport.java
/**
 * Binds an {@link AdaptableTypeListener} (via
 * {@link #bindListener(Matcher, TypeListener)}) and ensures it gets
 * properly injected ({@link #requestInjection(Object)}).
 */
@Override
protected void configure() {
	AdaptableTypeListener adaptableTypeListener = new AdaptableTypeListener(
			loggingMode);
	requestInjection(adaptableTypeListener);
	bindListener(new AbstractMatcher<TypeLiteral<?>>() {
		@Override
		public boolean matches(TypeLiteral<?> t) {
			return IAdaptable.class.isAssignableFrom(t.getRawType());
		}
	}, adaptableTypeListener);
}
 
源代码12 项目: guice-persist-orient   文件: OrientModule.java
@Override
protected void bindInterceptor(final Matcher<? super Class<?>> classMatcher,
                               final Matcher<? super Method> methodMatcher,
                               final MethodInterceptor... interceptors) {
    // hack to correctly bind @Transactional annotation for java8:
    // aop tries to intercept synthetic methods which cause a lot of warnings
    // (and generally not correct)
    super.bindInterceptor(classMatcher, new AbstractMatcher<Method>() {
        @Override
        public boolean matches(final Method method) {
            return !method.isSynthetic() && !method.isBridge() && methodMatcher.matches(method);
        }
    }, interceptors);
}
 
源代码13 项目: seed   文件: ValidationModule.java
private Matcher<Method> dynamicValidationMatcher() {
    return new AbstractMatcher<Method>() {
        @Override
        public boolean matches(Method method) {
            return shouldValidateParameters(method) || shouldValidateReturnType(method);
        }
    };
}
 
源代码14 项目: seed   文件: CoreModule.java
private <T> Matcher<T> createMatcherFromPredicate(Predicate<T> predicate) {
    return new AbstractMatcher<T>() {
        @Override
        public boolean matches(T t) {
            return predicate.test(t);
        }
    };
}
 
 类所在包
 同包方法