예제 #1
0
 private void initService(
     Map<String, Properties> serviceProps,
     Map<String, Object> serviceConfigObjects,
     ServiceInfo serviceInfo) {
   final Object service = serviceInfo.getService();
   if (serviceInfo.isConfigurableService()) {
     try {
       if (logger.isFinestEnabled()) {
         logger.finest("Configuring service -> " + service);
       }
       final Object configObject = serviceConfigObjects.get(serviceInfo.getName());
       ((ConfigurableService) service).configure(configObject);
     } catch (Throwable t) {
       logger.severe("Error while configuring service: " + t.getMessage(), t);
     }
   }
   if (serviceInfo.isManagedService()) {
     try {
       if (logger.isFinestEnabled()) {
         logger.finest("Initializing service -> " + service);
       }
       final Properties props = serviceProps.get(serviceInfo.getName());
       ((ManagedService) service).init(nodeEngine, props != null ? props : new Properties());
     } catch (Throwable t) {
       logger.severe("Error while initializing service: " + t.getMessage(), t);
     }
   }
 }
예제 #2
0
 private synchronized void registerService(String serviceName, Object service) {
   if (logger.isFinestEnabled()) {
     logger.finest("Registering service: '" + serviceName + "'");
   }
   final ServiceInfo serviceInfo = new ServiceInfo(serviceName, service);
   final ServiceInfo currentServiceInfo = services.putIfAbsent(serviceName, serviceInfo);
   if (currentServiceInfo != null) {
     logger.warning("Replacing " + currentServiceInfo + " with " + serviceInfo);
     if (currentServiceInfo.isCoreService()) {
       throw new HazelcastException(
           "Can not replace a CoreService! Name: "
               + serviceName
               + ", Service: "
               + currentServiceInfo.getService());
     }
     if (currentServiceInfo.isManagedService()) {
       shutdownService((ManagedService) currentServiceInfo.getService(), false);
     }
     services.put(serviceName, serviceInfo);
   }
 }