private synchronized Map<String, T> getTypes() { if (types.size()==0) { ClassLoader cl = getClass().getClassLoader(); logger.debug("loading service types for " + serviceType.getSimpleName()); ServiceLoader<? extends T> sl = ServiceLoader.load(serviceType); try { for (T inputType : sl) { if (types.get(inputType.getName()) != null) { throw new RuntimeException("ActivityType '" + inputType.getName() + "' is already defined."); } types.put(inputType.getName(),inputType); } } catch (Throwable t) { throw new RuntimeException(t); } } logger.info("Loaded Types:" + types.keySet()); return types; }