Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2014 Cisco Systems, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 
 
 
 
 package com.cisco.oss.foundation.directory.impl;
 
 import static com.cisco.oss.foundation.directory.ServiceDirectory.getServiceDirectoryConfig;

It is the default ServiceDirectoryManagerFactory to access remote ServiceDirectory server node. When there is no other ServiceDirectoryManagerFactory provider assigned, Service Directory API will initialize this class to provide ServiceDirectory services.
 
 public class DefaultServiceDirectoryManagerFactory implements
         ServiceDirectoryManagerFactory {
    
The LookupManager cache enabled property.
 
     public static final String SD_API_CACHE_ENABLED_PROPERTY = "com.cisco.oss.foundation.directory.cache.enabled";

    
The default cache enabled property value.
 
     public static final boolean SD_API_CACHE_ENABLED_DEFAULT = true;

    
The Registration heartbeat and health check enabled property name.
 
     public static final String SD_API_HEARTBEAT_ENABLED_PROPERTY = "com.cisco.oss.foundation.directory.heartbeat.enabled";

    
the default value of hearbeat enabled property value.
 
     public static final boolean SD_API_HEARTBEAT_ENABLED_DEFAULT = true;
 
 
     private static final DirectoryServiceClient dirSvcClient = new DirectoryServiceClient();

    
The XXXImpl holders for wired lazy-init requirement Sigh! where is spring!
 
     private static class LookupManagerImplHolder {
         public static final LookupManagerImpl INSTANCE =
                 new LookupManagerImpl(new DirectoryLookupService());
     }
     private static class CachedLookupManagerImplHolder {
         public static final CachedLookupManagerImpl INSTANCE =
                 new CachedLookupManagerImpl(new CachedDirectoryLookupService());
     }
     private static class HeartbeatRegistrationManagerImplHolder {
         public static final HeartbeatRegistrationManagerImpl INSTANCE
     }
     private static class RegistrationManagerImplHolder {
         public static final RegistrationManagerImpl INSTANCE
                 = new RegistrationManagerImpl(new DirectoryRegistrationService());
     }

    
Default constructor.
 
     }

    
Get RegistrationManager. It is thread safe.

Returns:
the RegistrationManager implementation instance.
 
     @Override
        return _getRegistrationMgrImpl();
     }
     private static RegistrationManagerImpl _getRegistrationMgrImpl(){
        boolean heartbeatEnabled = getServiceDirectoryConfig().getBoolean(,
                );
        if(heartbeatEnabled){
            return .;
        } else {
            return .;
        }
    }

    
Get LookupManager It is thread safe.

Returns:
the LookupManager implementation instance.
    @Override
    public LookupManager getLookupManager() {
        return _getLookupMgrImpl();
    }
    private static LookupManagerImpl _getLookupMgrImpl(){
        boolean cacheEnabled = getServiceDirectoryConfig().getBoolean(,
                );
        if(cacheEnabled){
            return .;
        } else {
            return .;
        }
    }

    
get the DirectoryServiceClient to access remote directory server.

Returns:
the DirectoryServiceClient.
    @Override
        return ;
    }
    @Override
    public void start() {
        _getRegistrationMgrImpl().start();
        _getLookupMgrImpl().start();
    }
    @Override
    public void stop() {
        _getRegistrationMgrImpl().stop();
        _getLookupMgrImpl().stop();
    }
New to GrepCode? Check out our FAQ X