// Path: c5-replicator-api/src/main/java/c5db/interfaces/C5Module.java
// public interface C5Module extends Service {
//   ModuleType getModuleType();
// 
//   boolean hasPort();
// 
//   int port();
// 
//   String acceptCommand(String commandString) throws InterruptedException;
// }


import c5db.interfaces.C5Module;
import com.google.common.util.concurrent.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.function.Consumer;
/*
 * Copyright 2014 WANdisco
 *
 *  WANdisco licenses this file to you 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 c5db;



/**
 * A {@link com.google.common.util.concurrent.Service.Listener} that logs the module lifecycle
 * and performs a single action when the module stops or fails.
 */
public class SimpleC5ModuleListener implements Service.Listener {
  private final Logger logger = LoggerFactory.getLogger(this.getClass());
  private final C5Module module;
  private final Runnable onRunningModule;
  private final Runnable onStoppingModule;
  private final Consumer<Throwable> throwableConsumer;

// Path: c5-replicator-api/src/main/java/c5db/interfaces/C5Module.java
// public interface C5Module extends Service {
//   ModuleType getModuleType();
// 
//   boolean hasPort();
// 
//   int port();
// 
//   String acceptCommand(String commandString) throws InterruptedException;
// }


// Path: c5-replicator-api/src/main/java/c5db/SimpleC5ModuleListener.java
import c5db.interfaces.C5Module;
import com.google.common.util.concurrent.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.function.Consumer;

/*
 * Copyright 2014 WANdisco
 *
 *  WANdisco licenses this file to you 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 c5db;



/**
 * A {@link com.google.common.util.concurrent.Service.Listener} that logs the module lifecycle
 * and performs a single action when the module stops or fails.
 */
public class SimpleC5ModuleListener implements Service.Listener {
  private final Logger logger = LoggerFactory.getLogger(this.getClass());
  private final C5Module module;
  private final Runnable onRunningModule;
  private final Runnable onStoppingModule;
  private final Consumer<Throwable> throwableConsumer;

  public SimpleC5ModuleListener(C5Module module,