aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/GlobalChannelFactory.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-03-29 14:22:18 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2013-03-29 14:22:18 +1300
commitf5233acc2078564aceadc9fe72e5a0998b2e04a3 (patch)
tree41d91aded6ec9ac9c26d866fcebe87c49cdf4d28 /src/org/traccar/GlobalChannelFactory.java
parent1fe18b404796c47e0eec31b4a40c9e4087e997b9 (diff)
downloadtrackermap-server-f5233acc2078564aceadc9fe72e5a0998b2e04a3.tar.gz
trackermap-server-f5233acc2078564aceadc9fe72e5a0998b2e04a3.tar.bz2
trackermap-server-f5233acc2078564aceadc9fe72e5a0998b2e04a3.zip
Fix UDP servers
Diffstat (limited to 'src/org/traccar/GlobalChannelFactory.java')
-rw-r--r--src/org/traccar/GlobalChannelFactory.java35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/org/traccar/GlobalChannelFactory.java b/src/org/traccar/GlobalChannelFactory.java
index 489207e39..7d2f3cbb6 100644
--- a/src/org/traccar/GlobalChannelFactory.java
+++ b/src/org/traccar/GlobalChannelFactory.java
@@ -17,29 +17,38 @@ package org.traccar;
import java.util.concurrent.Executors;
import org.jboss.netty.channel.ChannelFactory;
+import org.jboss.netty.channel.socket.DatagramChannelFactory;
+import org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
-/**
- * Channel factory
- */
public class GlobalChannelFactory {
- private static ChannelFactory instance = null;
+ private static ChannelFactory channelFactory = null;
+ private static DatagramChannelFactory datagramChannelFactory = null;
- private GlobalChannelFactory() {
- }
-
public static void release() {
- if (instance != null) {
- instance.releaseExternalResources();
+ if (channelFactory != null) {
+ channelFactory.releaseExternalResources();
+ }
+ if (datagramChannelFactory != null) {
+ datagramChannelFactory.releaseExternalResources();
}
- instance = null;
+ channelFactory = null;
+ datagramChannelFactory = null;
}
public static ChannelFactory getFactory() {
- if(instance == null) {
- instance = new NioServerSocketChannelFactory();
+ if (channelFactory == null) {
+ channelFactory = new NioServerSocketChannelFactory();
}
- return instance;
+ return channelFactory;
}
+
+ public static DatagramChannelFactory getDatagramFactory() {
+ if (datagramChannelFactory == null) {
+ datagramChannelFactory = new NioDatagramChannelFactory();
+ }
+ return datagramChannelFactory;
+ }
+
}