001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.cluster;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    
020    import java.io.InputStream;
021    import java.io.OutputStream;
022    
023    import org.jgroups.Address;
024    import org.jgroups.Message;
025    import org.jgroups.Receiver;
026    import org.jgroups.View;
027    
028    /**
029     * @author Tina Tian
030     */
031    public class BaseReceiver implements Receiver {
032    
033            @Override
034            public void block() {
035            }
036    
037            @Override
038            public void getState(OutputStream outputStream) throws Exception {
039            }
040    
041            public View getView() {
042                    return view;
043            }
044    
045            @Override
046            public void receive(Message message) {
047            }
048    
049            @Override
050            public void setState(InputStream inputStream) throws Exception {
051            }
052    
053            @Override
054            public void suspect(Address address) {
055            }
056    
057            @Override
058            public void unblock() {
059            }
060    
061            @Override
062            public void viewAccepted(View view) {
063                    if (_log.isInfoEnabled()) {
064                            _log.info("Accepted view " + view);
065                    }
066    
067                    this.view = view;
068            }
069    
070            protected volatile View view;
071    
072            private static Log _log = LogFactoryUtil.getLog(BaseReceiver.class);
073    
074    }