/** * Shortcut for {@code Jenkins.getInstanceOrNull()?.lookup.get(type)} */ public static @CheckForNull <T> T lookup(Class<T> type) { Jenkins j = Jenkins.getInstanceOrNull(); return j != null ? j.lookup.get(type) : null; }
/** * Retrieves the currently active singleton instance of {@link ConfidentialStore}. */ public static @Nonnull ConfidentialStore get() { if (TEST!=null) return TEST.get(); Jenkins j = Jenkins.getInstance(); Lookup lookup = j.lookup; ConfidentialStore cs = lookup.get(ConfidentialStore.class); if (cs==null) { try { Iterator<ConfidentialStore> it = ServiceLoader.load(ConfidentialStore.class, ConfidentialStore.class.getClassLoader()).iterator(); if (it.hasNext()) { cs = it.next(); } } catch (ServiceConfigurationError e) { LOGGER.log(Level.WARNING, "Failed to list up ConfidentialStore implementations",e); // fall through } if (cs==null) try { cs = new DefaultConfidentialStore(); } catch (Exception e) { // if it's still null, bail out throw new Error(e); } cs = lookup.setIfNull(ConfidentialStore.class,cs); } return cs; }
/** * Shortcut for {@code Jenkins.getInstanceOrNull()?.lookup.get(type)} */ public static @CheckForNull <T> T lookup(Class<T> type) { Jenkins j = Jenkins.getInstanceOrNull(); return j != null ? j.lookup.get(type) : null; }
/** * Shortcut for {@code Hudson.getInstance().lookup.get(type)} */ public static <T> T lookup(Class<T> type) { return Hudson.getInstance().lookup.get(type); }
/** * Shortcut for {@code Hudson.getInstance().lookup.get(type)} */ public static <T> T lookup(Class<T> type) { return Hudson.getInstance().lookup.get(type); }
/** * Shortcut for {@code Hudson.getInstance().lookup.get(type)} */ public static <T> T lookup(Class<T> type) { return Hudson.getInstance().lookup.get(type); }
/** * Shortcut for {@code Hudson.getInstance().lookup.get(type)} */ public static <T> T lookup(Class<T> type) { return Hudson.getInstance().lookup.get(type); }
/** * Retrieves the currently active singleton instance of {@link ConfidentialStore}. */ public static @Nonnull ConfidentialStore get() { if (TEST!=null) return TEST.get(); Jenkins j = Jenkins.getInstance(); Lookup lookup = j.lookup; ConfidentialStore cs = lookup.get(ConfidentialStore.class); if (cs==null) { try { List<ConfidentialStore> r = (List) Service.loadInstances(ConfidentialStore.class.getClassLoader(), ConfidentialStore.class); if (!r.isEmpty()) cs = r.get(0); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to list up ConfidentialStore implementations",e); // fall through } if (cs==null) try { cs = new DefaultConfidentialStore(); } catch (Exception e) { // if it's still null, bail out throw new Error(e); } cs = lookup.setIfNull(ConfidentialStore.class,cs); } return cs; }