1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.directory.mitosis.service.protocol.handler; 21 22 23 import org.apache.directory.mitosis.service.ReplicationContext; 24 import org.apache.mina.common.IdleStatus; 25 import org.apache.mina.common.IoHandler; 26 27 /** 28 * An interface that provides handler methods for events which occurs 29 * when a two replicas communicate with each other. This interface is 30 * very similar to MINA {@link IoHandler}, but there's a difference 31 * in that this interface provide a {@link ReplicationContext} instead of 32 * an {@link IoHandler}. It's usually wrapped by 33 * {@link ReplicationProtocolHandler} to work with MINA. 34 * 35 * @author The Apache Directory Project (dev@directory.apache.org) 36 * @version $Rev$, $Date$ 37 */ 38 public interface ReplicationContextHandler 39 { 40 /** 41 * Invoked when a connection is established between two replicas. 42 */ 43 void contextBegin( ReplicationContext ctx ) throws Exception; 44 45 /** 46 * Invoked when a connection is closed between two replicas. 47 */ 48 void contextEnd( ReplicationContext ctx ) throws Exception; 49 50 /** 51 * Invoked when a message is received from a peer replica. 52 */ 53 void messageReceived( ReplicationContext ctx, Object message ) throws Exception; 54 55 /** 56 * Invoked when a message is received from a peer replica. 57 */ 58 void messageSent( ReplicationContext ctx, Object message ) throws Exception; 59 60 /** 61 * Invoked when an exception is raised during the communication or 62 * executing replication logic. 63 */ 64 void exceptionCaught( ReplicationContext ctx, Throwable cause ) throws Exception; 65 66 /** 67 * Invoked when two replicas are not exchanging any data for certain 68 * amount of time. 69 */ 70 void contextIdle( ReplicationContext ctx, IdleStatus status ) throws Exception; 71 }