All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.serializer.communication.binarydynamic.ComClientChannelDynamic Maven / Gradle / Ivy

There is a newer version: 2.1.3
Show newest version
package org.eclipse.serializer.communication.binarydynamic;

/*-
 * #%L
 * Eclipse Serializer Communication Binary
 * %%
 * Copyright (C) 2023 MicroStream Software
 * %%
 * 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/
 * 
 * SPDX-License-Identifier: EPL-2.0
 * #L%
 */

import org.eclipse.serializer.communication.types.ComClient;
import org.eclipse.serializer.communication.types.ComClientChannel;
import org.eclipse.serializer.communication.types.ComProtocol;
import org.eclipse.serializer.persistence.binary.types.Binary;
import org.eclipse.serializer.persistence.types.PersistenceManager;
import org.eclipse.serializer.persistence.types.PersistenceTypeHandlerEnsurer;
import org.eclipse.serializer.persistence.types.PersistenceTypeHandlerManager;

public class ComClientChannelDynamic
	extends ComChannelDynamic
	implements ComClientChannel
{
	///////////////////////////////////////////////////////////////////////////
	// instance fields //
	////////////////////
	
	protected final ComClient parent;
	
	
		
	///////////////////////////////////////////////////////////////////////////
	// constructors //
	/////////////////
	
	public ComClientChannelDynamic(
		final PersistenceManager persistenceManager,
		final C connection,
		final ComProtocol protocol,
		final ComClient parent,
		final PersistenceTypeHandlerManager typeHandlerManager,
		final ComTypeDefinitionBuilder typeDefintionBuilder,
		final PersistenceTypeHandlerEnsurer typeHandlerEnsurer
		)
	{
		super(persistenceManager, connection, protocol);
		this.parent = parent;
		
		final ComTypeDescriptionRegistrationObserver observer = new ComTypeDescriptionRegistrationObserver(this);
		this.persistenceManager.typeDictionary().setTypeDescriptionRegistrationObserver(observer);
		this.initalizeHandlersInternal(typeHandlerManager, typeDefintionBuilder, typeHandlerEnsurer);
	}

	
	
	///////////////////////////////////////////////////////////////////////////
	// methods //
	////////////

	private void initalizeHandlersInternal(
		final PersistenceTypeHandlerManager typeHandlerManager  ,
		final ComTypeDefinitionBuilder              typeDefintionBuilder,
		final PersistenceTypeHandlerEnsurer typeHandlerEnsurer
	)
	{
		this.handlers.registerReceiveHandler(
			ComMessageNewType.class,
			new ComHandlerReceiveMessageNewType(
				typeHandlerManager,
				typeDefintionBuilder,
				typeHandlerEnsurer
			)
		);
		
		this.handlers.registerSendHandler(
			ComMessageNewType.class,
			new ComHandlerSendMessageNewType(this)
		);
		
		this.handlers.registerReceiveHandler(
			ComMessageData.class,
			new ComHandlerSendReceiveMessageData(this)
		);
		
		this.handlers.registerSendHandler(
			ComMessageData.class,
			new ComHandlerSendReceiveMessageData(this)
		);
		
		this.handlers.registerReceiveHandler(
			ComMessageStatus.class,
			new ComHandlerReceiveMessageStatus(this)
		);
		
		this.handlers.registerSendHandler(
			ComMessageStatus.class,
			new ComHandlerReceiveMessageStatus(this)
		);
		
		this.handlers.registerSendHandler(
			ComMessageClientTypeMismatch.class,
			new ComHandlerSendMessageClientTypeMismatch(this)
		);
	}


	@Override
	public final ComClient parent()
	{
		return this.parent;
	}


	@Override
	public C connection()
	{
		return this.connection;
	}


	@Override
	public ComProtocol protocol()
	{
		return this.protocol;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy