Refine search
public LevelFactory resolve() { if(factory.isUnsatisfied()){ return defFactory; }else{ return factory.get(); } } }
private CacheContainer getCacheContainer(Set<Annotation> qualifiers) { Instance<EmbeddedCacheManager> cacheContainer = cacheManagers.select(qualifiers.toArray(Reflections.EMPTY_ANNOTATION_ARRAY)); if (cacheContainer.isUnsatisfied()) { return defaultCacheContainer; } else { return cacheContainer.get(); } }
public void onRootDeviceSelected(@Observes RootDeviceSelected rootDeviceSelected) { if (!view.switchDeviceView(rootDeviceSelected.device)) { DeviceView deviceView = deviceViewInstance.select().get(); deviceView.setPresenter(this); deviceView.setDevice( configuration.getNamespace(), rootDeviceSelected.icon, rootDeviceSelected.device ); view.addDeviceView(deviceView); } }
@Override public String getId() { if( delegate.isUnsatisfied() ) { return UNKNOWN_SESSION_ID; } // default try { return delegate.get().getId(); } catch ( Exception e ) { return UNKNOWN_SESSION_ID; } }
private CacheContainer getCacheContainer(Set<Annotation> qualifiers) { Instance<EmbeddedCacheManager> cacheContainer = cacheManagers.select(qualifiers.toArray(Reflections.EMPTY_ANNOTATION_ARRAY)); if (cacheContainer.isUnsatisfied()) { return defaultCacheContainer; } else { return cacheContainer.get(); } }
@Override public ContextHandle createContextHandle() { final BeanManagerImpl beanManager = getBeanManager(); return () -> { if (beanManager == null || beanManager.isContextActive(RequestScoped.class)) { return () -> { }; } final RequestContext requestContext = beanManager.instance().select(RequestContext.class, UnboundLiteral.INSTANCE).get(); requestContext.activate(); return () -> { requestContext.invalidate(); requestContext.deactivate(); }; }; }
@Inject public void setExecutorService(Instance<ExecutorService> executorService) { if (!executorService.isUnsatisfied()) { super.setExecutorService(executorService.get()); } }
private static <T extends CamelContext> T selectContext(InjectionPoint ip, Instance<T> instance, CdiCamelExtension extension) { Collection<Annotation> qualifiers = new HashSet<>(ip.getQualifiers()); qualifiers.retainAll(extension.getContextQualifiers()); if (qualifiers.isEmpty() && !instance.select(DEFAULT).isUnsatisfied()) { return instance.select(DEFAULT).get(); } return instance.select(qualifiers.toArray(new Annotation[0])).get(); }
@Override public boolean hasRole(String role) { if (request.isUnsatisfied()) { return request.get().isUserInRole(role); } return getRoles().contains(role); }
@Test @SpecAssertion(section = BEFORE_BEAN_DISCOVERY, id = "c") public void testQualifierAddition() { Instance<Foo> fooInstance = instance.select(Foo.class, CustomQualifier.CustomQualifierLiteral.INSTANCE); Assert.assertFalse(fooInstance.isUnsatisfied()); Assert.assertNotNull(fooInstance.get()); }
@Override public void service(ChannelHandlerContext ctx, HttpRequest request, HttpResponse response, boolean handleNotFound) throws IOException { BoundRequestContext context = this.instance.select(BoundRequestContext.class).get(); Map<String,Object> contextMap = new HashMap<String,Object>(); context.associate(contextMap); context.activate(); try { super.service(ctx, request,response,handleNotFound); } finally { context.invalidate(); context.deactivate(); context.dissociate(contextMap); } } }
@Inject public SSHKeyAuthenticatorImpl(final SSHKeyStoreService keyStoreService, final Instance<WorkbenchUserManager> workbenchUserManagerInstance) { this.keyStoreService = keyStoreService; if (!workbenchUserManagerInstance.isUnsatisfied() && !workbenchUserManagerInstance.isAmbiguous()) { this.userManager = workbenchUserManagerInstance.get(); } else { LOGGER.warn("Cannot find any implementation of 'WorkbenchUserManager'. Loading default implementation on SSH module"); this.userManager = this::getUser; } }
private Job getBean(final Class<? extends Job> jobClass) { final Instance<? extends Job> job = jobInstance.select(jobClass); if (job.isAmbiguous()) { throw new IllegalStateException("Cannot produce job: ambiguous instance"); } if (job.isUnsatisfied()) { throw new IllegalStateException("Cannot produce job: unsatisfied instance"); } return job.get(); }
@Produces @RequestScoped public PermissionManager producePermissionManager() { if (this.defaultPartition.isUnsatisfied() || this.defaultPartition.get() == null) { return this.partitionManager.createPermissionManager(); } return this.partitionManager.createPermissionManager(this.defaultPartition.get()); }
private List<Configurable> getConfigurations(ConfigurationUnit annotation) { Supplier<InputStream> stream = readStream(annotation); String extension = getExtension(annotation); Instance<ConfigurableReader> select = readers.select(new NamedLiteral(extension)); if (select.isUnsatisfied()) { throw new ConfigurationException(String.format("The extension %s is not supported", extension)); } return select.get().read(stream, annotation); }
@Override public boolean hasRole(String role) { if (request.isUnsatisfied()) { return request.get().isUserInRole(role); } return getRoles().contains(role); }