Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3d651569d44a36f16674bad7f31a2c1767e55ce2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/****************************************************************************
 * Copyright (c) 2009 EclipseSource and others.
 *
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * Contributors:
 *   EclipseSource - initial API and implementation
 *
 * SPDX-License-Identifier: EPL-2.0
 *****************************************************************************/
/**
 * 
 */
package org.eclipse.ecf.server.generic;

import org.eclipse.ecf.core.IContainerListener;
import org.eclipse.ecf.core.events.*;
import org.eclipse.ecf.core.sharedobject.ISharedObjectContainerConfig;
import org.eclipse.ecf.provider.generic.TCPServerSOContainer;
import org.eclipse.ecf.provider.generic.TCPServerSOContainerGroup;

/**
 * 
 * @since 2.0
 *
 */
public class GenericServerContainer extends TCPServerSOContainer {

	final AbstractGenericServer abstractGenericServer;

	private IContainerListener departedListener = new IContainerListener() {
		public void handleEvent(IContainerEvent event) {
			if (event instanceof IContainerDisconnectedEvent) {
				IContainerDisconnectedEvent de = (IContainerDisconnectedEvent) event;
				GenericServerContainer.this.abstractGenericServer.handleDisconnect(de.getTargetID());
			} else if (event instanceof IContainerEjectedEvent) {
				IContainerEjectedEvent de = (IContainerEjectedEvent) event;
				GenericServerContainer.this.abstractGenericServer.handleEject(de.getTargetID());
			}
		}
	};

	public GenericServerContainer(AbstractGenericServer abstractGenericServer, ISharedObjectContainerConfig config, TCPServerSOContainerGroup listener, String path, int keepAlive) {
		super(config, listener, path, keepAlive);
		this.abstractGenericServer = abstractGenericServer;
		addListener(departedListener);
	}

	public void dispose() {
		removeListener(departedListener);
		super.dispose();
	}
}

Back to the top