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

org.eclipse.serializer.communication.binarydynamic.ComHostChannelDynamic 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.ComHost;
import org.eclipse.serializer.communication.types.ComHostChannel;
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 ComHostChannelDynamic
	extends ComChannelDynamic
	implements ComHostChannel
{
	///////////////////////////////////////////////////////////////////////////
	// instance fields //
	////////////////////
	
	protected final ComHost parent;
	
	///////////////////////////////////////////////////////////////////////////
	// constructors //
	/////////////////
	
	public ComHostChannelDynamic(
		final PersistenceManager                 persistenceManager  ,
		final C                                     connection          ,
		final ComProtocol                           protocol            ,
		final ComHost                            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(
			ComMessageClientTypeMismatch.class,
			new ComHandlerReceiveMessageClientTypeMismatch(this));
		
		this.handlers.registerReceiveHandler(
			ComMessageStatus.class,
			new ComHandlerReceiveMessageStatus(this));
		
		this.handlers.registerSendHandler(
			ComMessageStatus.class,
			new ComHandlerReceiveMessageStatus(this));
		
		this.handlers.registerReceiveHandler(
			ComMessageData.class,
			new ComHandlerSendReceiveMessageData(this));
			
		this.handlers.registerSendHandler(
			ComMessageData.class,
			new ComHandlerSendReceiveMessageData(this));
	}
	
	@Override
	public final ComHost 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