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;
 
 
 
Abstract base class for lookup and registration manger
 
 public abstract class AbstractServiceDirectoryManager implements StoppableAutoCloseable {
 
     public static final Logger LOGGER = LoggerFactory.getLogger(AbstractServiceDirectoryManager.class);

    
Mark component started or not
 
     protected final AtomicBoolean isStarted = new AtomicBoolean(false);

    
Mark the Manager closed. The manager can not be reused when it is closed.
 
     protected final AtomicBoolean isClosed = new AtomicBoolean(false);
 
     private CloseListener listener;
    
Setter

Parameters:
listener The CloseListener
 
     public synchronized void setCloseListener(CloseListener listener){
         this. = listener;
     }
 
     @Override
     public void start() {
         .set(true);
     }
 
     @Override
     public void stop() {
         .set(false);
     }

    
Check if the manager is started or not

Returns:
boolean indicating whether it is started or not
Throws:
com.cisco.oss.foundation.directory.exception.ServiceException
 
     public boolean isStarted() throws ServiceException {
         return .get();
     }
 
     @Override
     public void close() throws ServiceException {
         try {
             fireClose();
         }catch(Throwable cause){
             .error("{} is failed to close"this);
             throw new ServiceException(.,cause,
                     ..getMessageTemplate(),this);
         }
         .set(true);
         .info("{} is closed",this);
     }
 
     protected void fireClose() {
         if ( !=null) {
             .onManagerClose(this);
         }
     }
 
     @Override
     public String toString() {
         return getClass().getSimpleName() + "@" + Integer.toHexString(hashCode());
     }

    
Getter

Returns:
The ServiceDirectoryService
    public abstract ServiceDirectoryService getService();
New to GrepCode? Check out our FAQ X