/** * Creates a {@link RedisKeyValueAdapterBean}, requires a {@link RedisOperations} bean with the same qualifiers. * * @param qualifiers the qualifiers to be applied to the bean. * @param beanManager the BeanManager instance. * @return */ private RedisKeyValueAdapterBean createRedisKeyValueAdapterBean(Set<Annotation> qualifiers, BeanManager beanManager) { // Determine the RedisOperations bean which matches the qualifiers of the repository. Bean<RedisOperations<?, ?>> redisOperationsBean = this.redisOperations.get(qualifiers); if (redisOperationsBean == null) { throw new UnsatisfiedResolutionException(String.format("Unable to resolve a bean for '%s' with qualifiers %s.", RedisOperations.class.getName(), qualifiers)); } // Construct and return the repository bean. return new RedisKeyValueAdapterBean(redisOperationsBean, qualifiers, beanManager); }
/** * Creates a {@link RedisKeyValueTemplateBean}, requires a {@link RedisKeyValueAdapter} bean with the same qualifiers. * * @param qualifiers the qualifiers to be applied to the bean. * @param beanManager the BeanManager instance. * @return */ private RedisKeyValueTemplateBean createRedisKeyValueTemplateBean(Set<Annotation> qualifiers, BeanManager beanManager) { // Determine the RedisKeyValueAdapter bean which matches the qualifiers of the repository. Bean<RedisKeyValueAdapter> redisKeyValueAdapterBean = this.redisKeyValueAdapters.get(qualifiers); if (redisKeyValueAdapterBean == null) { throw new UnsatisfiedResolutionException(String.format("Unable to resolve a bean for '%s' with qualifiers %s.", RedisKeyValueAdapter.class.getName(), qualifiers)); } // Construct and return the repository bean. return new RedisKeyValueTemplateBean(redisKeyValueAdapterBean, qualifiers, beanManager); }
/** * Creates a {@link Bean}. * * @param <T> The type of the repository. * @param repositoryType The class representing the repository. * @param beanManager The BeanManager instance. * @return The bean. */ private <T> CdiRepositoryBean<T> createRepositoryBean(Class<T> repositoryType, Set<Annotation> qualifiers, BeanManager beanManager) { // Determine the entity manager bean which matches the qualifiers of the repository. Bean<EntityManager> entityManagerBean = entityManagers.get(qualifiers); if (entityManagerBean == null) { throw new UnsatisfiedResolutionException(String.format("Unable to resolve a bean for '%s' with qualifiers %s.", EntityManager.class.getName(), qualifiers)); } // Construct and return the repository bean. return new JpaRepositoryBean<T>(beanManager, entityManagerBean, qualifiers, repositoryType, Optional.of(getCustomImplementationDetector())); } }
/** * Creates a {@link CdiRepositoryBean} for the repository of the given type, requires a {@link KeyValueOperations} * bean with the same qualifiers. * * @param <T> the type of the repository. * @param repositoryType the class representing the repository. * @param qualifiers the qualifiers to be applied to the bean. * @param beanManager the BeanManager instance. * @return */ private <T> CdiRepositoryBean<T> createRepositoryBean(Class<T> repositoryType, Set<Annotation> qualifiers, BeanManager beanManager) { // Determine the KeyValueOperations bean which matches the qualifiers of the repository. Bean<KeyValueOperations> redisKeyValueTemplate = this.redisKeyValueTemplates.get(qualifiers); if (redisKeyValueTemplate == null) { throw new UnsatisfiedResolutionException(String.format("Unable to resolve a bean for '%s' with qualifiers %s.", RedisKeyValueTemplate.class.getName(), qualifiers)); } // Construct and return the repository bean. return new RedisRepositoryBean<>(redisKeyValueTemplate, qualifiers, repositoryType, beanManager, getCustomImplementationDetector()); }
/** * Creates a {@link CdiRepositoryBean} for the repository of the given type. * * @param <T> the type of the repository. * @param repositoryType the class representing the repository. * @param qualifiers the qualifiers to be applied to the bean. * @param beanManager the BeanManager instance. * @return */ private <T> CdiRepositoryBean<T> createRepositoryBean(Class<T> repositoryType, Set<Annotation> qualifiers, BeanManager beanManager) { // Determine the MongoOperations bean which matches the qualifiers of the repository. Bean<MongoOperations> mongoOperations = this.mongoOperations.get(qualifiers); if (mongoOperations == null) { throw new UnsatisfiedResolutionException(String.format("Unable to resolve a bean for '%s' with qualifiers %s.", MongoOperations.class.getName(), qualifiers)); } // Construct and return the repository bean. return new MongoRepositoryBean<T>(mongoOperations, qualifiers, repositoryType, beanManager, Optional.of(getCustomImplementationDetector())); } }
/** * Creates a {@link Bean}. * * @param <T> The type of the repository. * @param repositoryType The class representing the repository. * @param beanManager The BeanManager instance. * @return The bean. */ private <T> CdiRepositoryBean<T> createRepositoryBean(Class<T> repositoryType, Set<Annotation> qualifiers, BeanManager beanManager) { Bean<Session> sessionBean = this.sessions.get(qualifiers); if (sessionBean == null) { throw new UnsatisfiedResolutionException( String.format("Unable to resolve a bean for '%s' with qualifiers %s.", Session.class.getName(), qualifiers)); } return new Neo4jCdiRepositoryBean<T>(sessionBean, qualifiers, repositoryType, beanManager, Optional.of(getCustomImplementationDetector())); } }
/** * Creates a {@link CdiRepositoryBean} for the repository of the given type. * * @param <T> the type of the repository. * @param repositoryType the class representing the repository. * @param qualifiers the qualifiers to be applied to the bean. * @param beanManager the BeanManager instance. * @return */ private <T> CdiRepositoryBean<T> createRepositoryBean(Class<T> repositoryType, Set<Annotation> qualifiers, BeanManager beanManager) { // Determine the MongoOperations bean which matches the qualifiers of the repository. Bean<MongoOperations> mongoOperations = this.mongoOperations.get(qualifiers); if (mongoOperations == null) { throw new UnsatisfiedResolutionException(String.format("Unable to resolve a bean for '%s' with qualifiers %s.", MongoOperations.class.getName(), qualifiers)); } // Construct and return the repository bean. return new MongoRepositoryBean<T>(mongoOperations, qualifiers, repositoryType, beanManager, Optional.of(getCustomImplementationDetector())); } }
private static <T extends CamelContext> T selectContext(String name, Instance<T> instance) { for (T context : instance) { if (name.equals(context.getName())) { return context; } } throw new UnsatisfiedResolutionException("No Camel context with name [" + name + "] is deployed!"); }
private <T> Bean<T> resolveUniqueBean(Type type, Set<Bean<T>> beans) { if (beans.size() == 0) { throw new UnsatisfiedResolutionException("Unable to resolve any beans of " + type); } else if (beans.size() > 1) { throw new AmbiguousResolutionException("More than one bean available (" + beans + ")"); } return beans.iterator().next(); }
private <T> Bean<T> createRepositoryBean(Class<T> repositoryType, Set<Annotation> qualifiers, BeanManager beanManager) { Bean<SolrOperations> solrOperationBeans = this.solrOperationsMap.get(qualifiers.toString()); if (solrOperationBeans == null) { throw new UnsatisfiedResolutionException(String.format("Unable to resolve a bean for '%s' with qualifiers %s.", SolrOperations.class.getName(), qualifiers)); } return new SolrRepositoryBean<>(solrOperationBeans, qualifiers, repositoryType, beanManager, Optional.ofNullable(getCustomImplementationDetector())); }
private CamelContext getOrLookupCamelContext(String contextName) { // TODO: proper support for custom context qualifiers return getReferenceByType(manager, CamelContext.class, contextName.isEmpty() ? DEFAULT : ContextName.Literal.of(contextName)) .orElseThrow(() -> new UnsatisfiedResolutionException("No Camel context with name [" + contextName + "] is deployed!")); }
@Override public <T> T getBean(String name, Class<T> type) { Set<Bean<?>> beans = delegate.getBeans(name); if (beans.isEmpty()) { throw new UnsatisfiedResolutionException("no qualifying beans named '" + name + "'"); } Bean<?> bean = delegate.resolve(hasAlternative(beans) ? alternatives(beans) : beans); return getReference(bean, type); }
@Override public final UnsatisfiedResolutionException unableToResolveBean(final Object param1, final Object param2) { final UnsatisfiedResolutionException result = new UnsatisfiedResolutionException(java.text.MessageFormat.format(unableToResolveBean$str(), param1, param2)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String jandexIndexNotCreated = "WELD-ENV-000019: Jandex index is null in the constructor of class: {0}";
@Override public final UnsatisfiedResolutionException unableToResolveBean(final Object param1, final Object param2) { final UnsatisfiedResolutionException result = new UnsatisfiedResolutionException(java.text.MessageFormat.format(unableToResolveBean$str(), param1, param2)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String jandexIndexNotCreated = "WELD-ENV-000019: Jandex index is null in the constructor of class: {0}";
@Override public final UnsatisfiedResolutionException unableToResolveBean(final Object param1, final Object param2) { final UnsatisfiedResolutionException result = new UnsatisfiedResolutionException(java.text.MessageFormat.format(unableToResolveBean$str(), param1, param2)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String jandexIndexNotCreated = "WELD-ENV-000019: Jandex index is null in the constructor of class: {0}";
@Override public final UnsatisfiedResolutionException unableToResolveBean(final Object param1, final Object param2) { final UnsatisfiedResolutionException result = new UnsatisfiedResolutionException(java.text.MessageFormat.format(unableToResolveBean$str(), param1, param2)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String jandexIndexNotCreated = "WELD-ENV-000019: Jandex index is null in the constructor of class: {0}";
@Override public final UnsatisfiedResolutionException unableToResolveBean(final Object param1, final Object param2) { final UnsatisfiedResolutionException result = new UnsatisfiedResolutionException(java.text.MessageFormat.format(unableToResolveBean$str(), param1, param2)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String jandexIndexNotCreated = "WELD-ENV-000019: Jandex index is null in the constructor of class: {0}";
@Override public final UnsatisfiedResolutionException unableToResolveBean(final Object param1, final Object param2) { final UnsatisfiedResolutionException result = new UnsatisfiedResolutionException(java.text.MessageFormat.format(unableToResolveBean$str(), param1, param2)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String jandexIndexNotCreated = "WELD-ENV-000019: Jandex index is null in the constructor of class: {0}";
@Override protected ProducerTemplate findOrCreateCamelTemplate() { return getReferenceByType(cdiContainer.getBeanManager(), CamelContext.class) .orElseThrow( () -> new UnsatisfiedResolutionException("No default Camel context is deployed, " + "cannot create default ProducerTemplate!")) .createProducerTemplate(); }
public static void throwUnsatisfiedResolutionException( Class type, InjectionPoint injectionPoint, Annotation... qualifiers) { ViolationMessageBuilder violationMessage = newViolation("Api type [", type.getName(), "] is not found with the qualifiers "); violationMessage.addLine(createQualifierMessage(injectionPoint, qualifiers)); if (injectionPoint != null) { violationMessage.addLine("for injection into ", injectionPoint.toString()); } throw new UnsatisfiedResolutionException(violationMessage.toString()); }