Ejemplo n.º 1
0
 /**
  * Returns a list of services matching provided service class/interface. <br>
  * </br> <b>CoreServices will be placed at the beginning of the list.</b>
  */
 List<ServiceInfo> getServiceInfos(Class serviceClass) {
   final LinkedList<ServiceInfo> result = new LinkedList<ServiceInfo>();
   for (ServiceInfo serviceInfo : services.values()) {
     if (serviceInfo.isInstanceOf(serviceClass)) {
       if (serviceInfo.isCoreService()) {
         result.addFirst(serviceInfo);
       } else {
         result.addLast(serviceInfo);
       }
     }
   }
   return result;
 }
Ejemplo n.º 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);
   }
 }