private final float factor() { final ComponentServiceObjects<FrameworkClock> service = this.clock; if (service == null) return 1; FrameworkClock clock = null; try { clock = service.getService(); return clock.getSimulationFactor(); } catch (IllegalArgumentException e) { return 1; } finally { if (clock != null) service.ungetService(clock); } }
private static String getId(final ComponentServiceObjects<ProfileTemplate> service) { Object id0 = service.getServiceReference().getProperty(ProfileTemplate.ID_PROPERTY); String id = id0 != null ? id0.toString() : null; if (id == null) { final ProfileTemplate template = service.getService(); try { id = template.id(); } finally { service.ungetService(template); } } return id; }
private void doUngetService(ComponentContextImpl<S> key, final T service) { try { key.getComponentServiceObjectsHelper().getServiceObjects(getRef()).ungetService(service); } catch (final IllegalStateException ise) { // ignore } }
public <T> T getPrototypeRefInstance(final ServiceReference<T> ref) { return (T) getServiceObjects(ref).getService(); }
private void doUngetService(ComponentContextImpl<S> key, final T service) { try { key.getComponentServiceObjectsHelper().getServiceObjects(getRef()).ungetService( service ); } catch ( final IllegalStateException ise ) { // ignore } } }
public <T> T getPrototypeRefInstance(final ServiceReference<T> ref) { return (T) getServiceObjects(ref).getService(); }
private final long time() { final ComponentServiceObjects<FrameworkClock> service = this.clock; if (service == null) return System.currentTimeMillis(); FrameworkClock clock = null; try { clock = service.getService(); return clock.getExecutionTime(); } catch (IllegalArgumentException e) { return System.currentTimeMillis(); } finally { if (clock != null) service.ungetService(clock); } }
private void doUngetService(ComponentContextImpl<S> key, final T service) { try { key.getComponentServiceObjectsHelper().getServiceObjects(getRef()).ungetService( service ); } catch ( final IllegalStateException ise ) { // ignore } } }
private boolean setUsername(final HttpServletRequest request) { final PermissionManager permMan = permManService.getService(); try { final String user = permMan.getAccessManager().getCurrentUser(); if (user == null) return false; request.setAttribute(REMOTE_USER, user); return true; } finally { permManService.ungetService(permMan); } }
private void doUngetService(ComponentContextImpl<S> key, final T service) { try { key.getComponentServiceObjectsHelper().getServiceObjects(getRef()).ungetService(service); } catch (final IllegalStateException ise) { // ignore } }
@Reference( service=ProfileTemplate.class, cardinality=ReferenceCardinality.MULTIPLE, policy=ReferencePolicy.DYNAMIC, policyOption=ReferencePolicyOption.GREEDY, bind="addTemplate", unbind="removeTemplate" ) protected void addTemplate(final ComponentServiceObjects<ProfileTemplate> templateRef) { final String id = getId(templateRef); if (id == null) throw new ComponentException("Profile template without id: " + templateRef); final ComponentServiceObjects<ProfileTemplate> old = templates.put(id, templateRef); if (old != null) { final ProfileTemplate oldTemplate = old.getService(); final ProfileTemplate newTemplate = templateRef.getService(); try { LoggerFactory.getLogger(getClass()).warn("Duplicate profile template id {}: {}, {}", id, oldTemplate, newTemplate); } finally { templateRef.ungetService(newTemplate); old.ungetService(oldTemplate); } } }
private AccessControlContext getContext(final HttpServletRequest req) throws ServletException, IOException { final RestAccess ra = restAccService.getService(); try { final AccessControlContext ctx = ra.getAccessContext(req, null); if (ctx != null) return ctx; } catch (NullPointerException expected) { } finally { restAccService.ungetService(ra); } final String token = req.getHeader("Authorization"); if (token == null || !token.toLowerCase().startsWith("bearer ")) return null; final String token1 = token.substring("bearer ".length()); final AppAuthentication appAuth = appAuthService.getService(); try { return appAuth.getContext(token1.toCharArray()); } finally { appAuthService.ungetService(appAuth); } }
return; final RestAccess ra = restAccessService.getService(); final AccessControlContext ctx; try { ctx = ra.getAccessContext(req, resp); } finally { restAccessService.ungetService(ra);
throw new IllegalStateException("Template provider for id " + templateId + " not available"); final ProfileTemplate template = service.getService(); try { final List<DataPoint> primary = template.primaryData(); return profile; } finally { service.ungetService(template);