List of usage examples for java.lang Class getDeclaredConstructor
@CallerSensitive public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException
From source file:de.innovationgate.wgpublisher.WGACore.java
public void initClusterService(WGAConfiguration oldConfig) { if (oldConfig == null || !getWgaConfiguration().getClusterConfiguration().equals(oldConfig.getClusterConfiguration())) { logCategoryInfo("Cluster Service", 1); if (_clusterService != null) { try { getLog().info("Shutting down current cluster service instance to apply config changes."); _clusterService.shutdown(); _clusterService = null;/*from w w w . j ava 2 s.com*/ } catch (Throwable e) { getLog().error("Failed to shutdown cluster service instance '" + _clusterService.getClass().getName() + "'", e); } } // choose cluster service String implClass = getWgaConfiguration().getClusterConfiguration().getImplClassName(); if (implClass != null && getWgaConfiguration().getClusterConfiguration().isEnabled()) { try { Class<ClusterService> clusterServiceImplClass = (Class<ClusterService>) getLibraryLoader() .loadClass(implClass); Constructor<ClusterService> c = clusterServiceImplClass.getDeclaredConstructor(WGACore.class); _clusterService = c.newInstance(this); } catch (Throwable e) { getLog().error("Failed to create cluster service instance of type '" + implClass + "'", e); } } // nothing configured or impl class not found - fallback to single node cluster if (_clusterService == null) { _clusterService = new SingleNodeClusterService(this); } try { getLog().info( "Starting cluster service implementation '" + _clusterService.getClass().getName() + "'"); _clusterService.startup(); } catch (Throwable e) { getLog().error("Startup of cluster service implementation '" + _clusterService.getClass().getName() + "' failed.", e); // fallback to single node cluster if possible if (!_clusterService.getClass().equals(SingleNodeClusterService.class)) { getLog().info("Falling back to default implementation '" + SingleNodeClusterService.class.getName() + "'"); try { _clusterService = new SingleNodeClusterService(this); _clusterService.startup(); } catch (Throwable e1) { getLog().error("Startup of cluster service implementation '" + _clusterService.getClass().getName() + "' failed.", e1); } } } } }