001/*
002 * GWTEventService
003 * Copyright (c) 2011 and beyond, strawbill UG (haftungsbeschr?nkt)
004 *
005 * This is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU Lesser General Public License as
007 * published by the Free Software Foundation; either version 3 of
008 * the License, or (at your option) any later version.
009 * Other licensing for GWTEventService may also be possible on request.
010 * Please view the license.txt of the project for more information.
011 *
012 * This software is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * You should have received a copy of the GNU Lesser General Public
018 * License along with this software; if not, write to the Free
019 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021 */
022package de.novanic.eventservice.client.connection.strategy.connector;
023
024import com.google.gwt.user.client.rpc.AsyncCallback;
025import de.novanic.eventservice.client.event.DomainEvent;
026import de.novanic.eventservice.client.event.listener.EventNotification;
027import de.novanic.eventservice.client.event.service.EventServiceAsync;
028
029import java.util.List;
030
031/**
032 * The {@link ConnectionStrategyClientConnector} listens for occurred events ({@link de.novanic.eventservice.client.event.Event})
033 * of the server side and has the task to encode / process the transferred events at the client side.
034 * 
035 * @author sstrohschein
036 *         <br>Date: 16.04.2010
037 *         <br>Time: 23:22:31
038 */
039public interface ConnectionStrategyClientConnector
040{
041    /**
042     * Initializes the {@link de.novanic.eventservice.client.connection.strategy.connector.ConnectionStrategyClientConnector} with
043     * the {@link de.novanic.eventservice.client.event.service.EventServiceAsync}.
044     * @param anEventService the {@link de.novanic.eventservice.client.event.service.EventServiceAsync}
045     */
046    void init(EventServiceAsync anEventService);
047
048    /**
049     * Deactivates the {@link de.novanic.eventservice.client.connection.strategy.connector.ConnectionStrategyClientConnector}.
050     */
051    void deactivate();
052
053    /**
054     * Checks if the {@link de.novanic.eventservice.client.connection.strategy.connector.ConnectionStrategyClientConnector} is
055     * initialized.
056     * @return true when the {@link de.novanic.eventservice.client.connection.strategy.connector.ConnectionStrategyClientConnector} is
057     * initialized, otherwise false
058     */
059    boolean isInitialized();
060
061    /**
062     * The listen method implements the listen / connection strategy to receive occurred events. The occurred events
063     * will be passed to the {@link de.novanic.eventservice.client.event.listener.EventNotification} and to the callback.
064     * @param anEventNotification {@link de.novanic.eventservice.client.event.listener.EventNotification} which will be notified about occurred / received events
065     * @param aCallback The callback will be notified about occurred / received events.
066     */
067    void listen(EventNotification anEventNotification, AsyncCallback<List<DomainEvent>> aCallback);
068}