/** * Find a type of the class given it's Superclass. * * @param inspectedClass Class whose type is searched for. * @param superClass Class relatively to which the search is performed. * @return */ public static Class<?> getClassType(Class<?> inspectedClass, Class<?> superClass) { ReflectionHelper.DeclaringClassInterfacePair p = ReflectionHelper.getClass(inspectedClass, superClass); Class[] as = ReflectionHelper.getParameterizedClassArguments(p); if (as == null) { return null; } else { return as[0]; } }
private ClientManager(String containerProviderClassName, WebSocketContainer webSocketContainer) { final ErrorCollector collector = new ErrorCollector(); componentProvider = ComponentProviderService.createClient(); Class engineProviderClazz; try { engineProviderClazz = ReflectionHelper.classForNameWithException(containerProviderClassName); } catch (ClassNotFoundException e) { collector.addException(e); throw new RuntimeException(collector.composeComprehensiveException()); } LOGGER.config(String.format("Provider class loaded: %s", containerProviderClassName)); this.container = (ClientContainer) ReflectionHelper.getInstance(engineProviderClazz, collector); if (!collector.isEmpty()) { throw new RuntimeException(collector.composeComprehensiveException()); } this.webSocketContainer = webSocketContainer; }