Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2013-2014 by Cisco Systems, Inc. All rights reserved.
  
  package com.cisco.oss.foundation.directory.impl;
  
  import org.slf4j.Logger;
  
The ServiceDirectory context class. This class initializes RegistrationManager, LookupManager, and ServiceDirectoryService with the getter methods.

Author(s):
zuxiang
 
 	
 	public static final Logger LOGGER = LoggerFactory.getLogger(ServiceDirectoryImpl.class);

The customer ServiceDirectoryManagerFactory implementation class name property name.
 
 	public static final String SD_API_SERVICE_DIRECTORY_MANAGER_FACTORY_PROVIDER_PROPERTY = "service.directory.manager.factory.provider";

ServiceDirectory server node client, it is lazy initialized.
 
ServiceDirectoryManagerFactory, it is lazy initialized.
 
The singleton instance.
 
 	private static ServiceDirectoryImpl instance = new ServiceDirectoryImpl(); 
 	
 	private boolean isShutdown = false;
 	
 	// Singleton, private the constructor.
 	private ServiceDirectoryImpl() {
 	}

Get the ServiceDirectoryImpl singleton instance.

Returns:
the ServiceDirectoryImpl instance.
 
 	public static ServiceDirectoryImpl getInstance(){
 		return ;
 	}

Get RegistrationManager from ServiceDirectoryManagerFactory.

Returns:
the RegistrationManager instance.
Throws:
com.cisco.oss.foundation.directory.exception.ServiceException
 
 	}

get LookupManager from ServiceDirectoryManagerFactory.

Returns:
the LookupManager instance.
Throws:
com.cisco.oss.foundation.directory.exception.ServiceException
 
 	}

Get the ServiceDirectoryConfig in sd-api.

Returns:
the ServiceDirectory configuration.
 
 		return new ServiceDirectoryConfig(Configurations.getConfiguration());
 	}

Set the ServiceDirectoryManagerFactory in the sd-api.

Parameters:
factory the ServiceDirectoryManagerFactory.
Throws:
com.cisco.oss.foundation.directory.exception.ServiceException
		if (factory == null) {
			throw new IllegalArgumentException("The ServiceDirectoryManagerFactory cannot be NULL.");
		}
		synchronized(this){
				throw new ServiceException(error);
			}
			if (this. != null) {
				if ( instanceof Closable) {
				}
				.info("Resetting ServiceDirectoryManagerFactory, old="
", new=" + factory.getClass().getName() + ".");
				this. = factory;
else {
				this. = factory;
				.info("Setting ServiceDirectoryManagerFactory,  factory="
factory.getClass().getName() + ".");
			}
		}
	}

		if( == null){
			synchronized(this){
					throw new ServiceException(error);
				}
				if( == null){
				}
			}
		}
		return ;
	}

Shutdown the ServiceDirectory and the ServiceDirectoryManagerFactory.
	public void shutdown(){
		synchronized(this){
			if(! ){
				if ( != null) {
					if ( instanceof Closable) {
					}
				}
				if ( != null) {
					 = null;
				}
				this. = true;
			}
		}
	}

Get the ServiceDirectoryManagerFactory. It is lazy initialized and thread safe. It looks up the configuration "service.directory.manager.factory.provider". If the configuration is null or the provider instantialization fails, it will instantialize the DefaultServiceDirectoryManagerFactory.

Returns:
the ServiceDirectoryManagerFactory instance.
			synchronized(this){
					throw new ServiceException(error);
				}
					String custProvider = Configurations
					if (custProvider != null && !custProvider.isEmpty()) {
						try {
							Class<?> provider = Class.forName(custProvider);
									.isAssignableFrom(provider)) {
								.info("Instantialized the ServiceDirectoryManager with customer implementation " + custProvider + ".");
							}
catch (Exception e) {
									"Instantialize ServiceDirectoryManagerFactory from "
custProvider + " failed."e);
						}
					}
					if ( == null) {
						.info("Instantialized the ServiceDirectoryManager with default implementation StandServiceDirectoryManager.");
					}
				}
			}
		}
	}

Keep it default for Unit test. Revert the ServiceDirectory from shutdown.
		false;
	}
New to GrepCode? Check out our FAQ X