-
Notifications
You must be signed in to change notification settings - Fork 215
/
DefaultClientActorPropsFactory.java
83 lines (74 loc) · 3.54 KB
/
DefaultClientActorPropsFactory.java
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.connectivity.service.messaging;
import javax.annotation.concurrent.Immutable;
import org.eclipse.ditto.base.model.headers.DittoHeaders;
import org.eclipse.ditto.connectivity.model.Connection;
import org.eclipse.ditto.connectivity.model.ConnectionType;
import org.eclipse.ditto.connectivity.service.messaging.amqp.AmqpClientActor;
import org.eclipse.ditto.connectivity.service.messaging.httppush.HttpPushClientActor;
import org.eclipse.ditto.connectivity.service.messaging.kafka.KafkaClientActor;
import org.eclipse.ditto.connectivity.service.messaging.mqtt.hivemq.HiveMqtt3ClientActor;
import org.eclipse.ditto.connectivity.service.messaging.mqtt.hivemq.HiveMqtt5ClientActor;
import org.eclipse.ditto.connectivity.service.messaging.rabbitmq.RabbitMQClientActor;
import com.typesafe.config.Config;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
/**
* The default implementation of {@link ClientActorPropsFactory}. Singleton which is created just once
* and otherwise returns the already created instance.
*/
@Immutable
public final class DefaultClientActorPropsFactory implements ClientActorPropsFactory {
public DefaultClientActorPropsFactory(final ActorSystem actorSystem) {
}
@Override
public Props getActorPropsForType(final Connection connection, final ActorRef commandForwarderActor,
final ActorRef connectionActor,
final ActorSystem actorSystem,
final DittoHeaders dittoHeaders,
final Config connectivityConfigOverwrites) {
final ConnectionType connectionType = connection.getConnectionType();
final Props result;
switch (connectionType) {
case AMQP_091:
result = RabbitMQClientActor.props(connection, commandForwarderActor, connectionActor, dittoHeaders,
connectivityConfigOverwrites);
break;
case AMQP_10:
result = AmqpClientActor.props(connection, commandForwarderActor, connectionActor, connectivityConfigOverwrites,
actorSystem, dittoHeaders);
break;
case MQTT:
result = HiveMqtt3ClientActor.props(connection, commandForwarderActor, connectionActor, dittoHeaders,
connectivityConfigOverwrites);
break;
case MQTT_5:
result = HiveMqtt5ClientActor.props(connection, commandForwarderActor, connectionActor, dittoHeaders,
connectivityConfigOverwrites);
break;
case KAFKA:
result = KafkaClientActor.props(connection, commandForwarderActor, connectionActor, dittoHeaders,
connectivityConfigOverwrites);
break;
case HTTP_PUSH:
result = HttpPushClientActor.props(connection, commandForwarderActor, connectionActor, dittoHeaders,
connectivityConfigOverwrites);
break;
default:
throw new IllegalArgumentException("ConnectionType <" + connectionType + "> is not supported.");
}
return result;
}
}