private void refreshInput() { if (service != null) { try { if (service instanceof IKundenServiceAsync) { final IKundenServiceAsync serviceAsync = (IKundenServiceAsync) service; final IFuture kunden = serviceAsync.listKundenAsync(); try { // do something else here before kunden gets used // doSomeHeavyComputation(); if (kunden.isDone()) { setInput((Kunde[]) kunden.get()); } // do again something else first // doAnotherHeavyComputation(); if (kunden.isDone()) { setInput((Kunde[]) kunden.get()); } // finally wait for 1000ms to set the input and fail otherwise setInput((Kunde[]) kunden.get(1000)); } catch (OperationCanceledException e) { // TODO handle e somehow, but how? e.printStackTrace(); } catch (InterruptedException e) { // TODO handle e somehow, but how? e.printStackTrace(); } catch (TimeoutException e) { // TODO handle e somehow, but how? e.printStackTrace(); } } else { setInput(service.listKunden()); } } catch (ServiceException e) { e.printStackTrace(); } } else { setInput(new Kunde[0]); } }
private final Set<Class<?>> findJAXRSResourceClasses() { BundleContext ctx = getBundleContext(); String bundleName = ctx.getBundle().getSymbolicName(); Set<Class<?>> result = new HashSet<Class<?>>(); ServiceException recordException = null; try { IBundleScanService svc = lookupBundleScanner(ctx); result.addAll( svc.getAnnotatedClasses( ctx, new String[] {javax.ws.rs.Path.class.getName()}, null, false)); } catch (ServiceException se) { recordException = se; LOGGER.debug( "Error finding JAXRS resource annotated classes in " + "bundle: {} error: {}.", bundleName, se.getMessage()); // the bundle scan service cannot be lookedup. Lets attempt to // lookup the resources from the bundle manifest header for (String c : parseManifestEntry(ctx, JAXRS_RESOURCES_MANIFEST_NAME)) { try { result.add(ctx.getBundle().loadClass(c)); } catch (ClassNotFoundException cnfe) { LOGGER.error( "Cannot load class: {} in bundle: {} " + "defined as MANIFEST JAX-RS resource", c, bundleName, cnfe); } } } if (result.size() == 0) { if (recordException != null) { throw recordException; } else { throw new ServiceException( "No resource classes found in bundle:" + ctx.getBundle().getSymbolicName()); } } return result; }