@Override public boolean bind(Class<?> component, Set<Class<?>> providerContracts) { if (ctx == null) { return false; } if (AnnotationUtils.findAnnotation(component, Component.class) != null) { String[] beanNames = ctx.getBeanNamesForType(component); if (beanNames == null || beanNames.length != 1) { LOGGER.severe(LocalizationMessages.NONE_OR_MULTIPLE_BEANS_AVAILABLE(component)); return false; } String beanName = beanNames[0]; Binding binding = Bindings.supplier(new SpringManagedBeanFactory(ctx, injectionManager, beanName)) .to(component) .to(providerContracts); injectionManager.register(binding); LOGGER.config(LocalizationMessages.BEAN_REGISTERED(beanNames[0])); return true; } return false; }
@Override @SuppressWarnings("unchecked") protected void configure() { ContextInjectionResolverImpl resolver = new ContextInjectionResolverImpl(beanManager); /* * Binding for CDI, without this binding JerseyInjectionTarget wouldn't know about the ContextInjectionTarget and * injection into fields would be disabled. */ bind(resolver) .to(new GenericType<InjectionResolver<Context>>() {}) .to(ContextInjectionResolver.class); /* * Binding for Jersey, without this binding Jersey wouldn't put together ContextInjectionResolver and * DelegatedInjectionValueParamProvider and therefore injection into resource method would be disabled. */ bind(Bindings.service(resolver)) .to(new GenericType<InjectionResolver<Context>>() {}) .to(ContextInjectionResolver.class); } }
@SuppressWarnings("unchecked") @Override public boolean bind(Class<?> component, Set<Class<?>> providerContracts) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(LocalizationMessages.EJB_CLASS_BEING_CHECKED(component)); } if (injectionManager == null) { throw new IllegalStateException(LocalizationMessages.EJB_COMPONENT_PROVIDER_NOT_INITIALIZED_PROPERLY()); } if (!isEjbComponent(component)) { return false; } if (!ejbInterceptorRegistered) { registerEjbInterceptor(); } Binding binding = Bindings.supplier(new EjbFactory(component, initialContext, EjbComponentProvider.this)) .to(component) .to(providerContracts); injectionManager.register(binding); if (LOGGER.isLoggable(Level.CONFIG)) { LOGGER.config(LocalizationMessages.EJB_CLASS_BOUND_WITH_CDI(component)); } return true; }
@Override public boolean bind(Class<?> component, Set<Class<?>> providerContracts) { if (ctx == null) { return false; } if (AnnotationUtils.findAnnotation(component, Component.class) != null) { String[] beanNames = ctx.getBeanNamesForType(component); if (beanNames == null || beanNames.length != 1) { LOGGER.severe(LocalizationMessages.NONE_OR_MULTIPLE_BEANS_AVAILABLE(component)); return false; } String beanName = beanNames[0]; Binding binding = Bindings.supplier(new SpringManagedBeanFactory(ctx, injectionManager, beanName)) .to(component) .to(providerContracts); injectionManager.register(binding); LOGGER.config(LocalizationMessages.BEAN_REGISTERED(beanNames[0])); return true; } return false; }