Use a connection factory instead of a connection builder.
[xudocci.git] / src / main / java / net / pterodactylus / irc / DefaultConnectionFactory.java
diff --git a/src/main/java/net/pterodactylus/irc/DefaultConnectionFactory.java b/src/main/java/net/pterodactylus/irc/DefaultConnectionFactory.java
new file mode 100644 (file)
index 0000000..6a37394
--- /dev/null
@@ -0,0 +1,25 @@
+package net.pterodactylus.irc;
+
+import javax.net.SocketFactory;
+
+import com.google.common.eventbus.EventBus;
+
+/**
+ * Default {@link ConnectionFactory} implementation that uses plain sockets to create connections.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class DefaultConnectionFactory implements ConnectionFactory {
+
+       private final EventBus eventBus;
+
+       public DefaultConnectionFactory(EventBus eventBus) {
+               this.eventBus = eventBus;
+       }
+
+       @Override
+       public Connection createConnection(String hostname, int port) {
+               return new Connection(eventBus, SocketFactory.getDefault(), hostname, port);
+       }
+
+}