Browse files

remove non-blocking support

  • Loading branch information...
1 parent bef8e19 commit a3415f40b967425945cc130d8a31d510d5b2748f @notnoop committed May 18, 2011
View
7 pom.xml
@@ -128,13 +128,6 @@
</dependency>
<dependency>
- <groupId>org.apache.mina</groupId>
- <artifactId>mina-core</artifactId>
- <version>2.0.0-RC1</version>
- <optional>true</optional>
- </dependency>
-
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
View
33 src/main/java/com/notnoop/apns/ApnsServiceBuilder.java
@@ -82,7 +82,6 @@
private ReconnectPolicy reconnectPolicy = ReconnectPolicy.Provided.NEVER.newObject();
private boolean isQueued = false;
- private boolean isNonBlocking = false;
private ApnsDelegate delegate = ApnsDelegate.EMPTY;
private Proxy proxy = null;
private boolean errorDetection = true;
@@ -345,20 +344,6 @@ public ApnsServiceBuilder asQueued() {
}
/**
- * Constructs non-blocking queues and sockets connections
- * to send the iPhone notifications.
- *
- * @deprecated this lacks many of the features that the library supports,
- * such as auto-reconnection upon failure.
- * @return this
- */
- @Deprecated
- public ApnsServiceBuilder asNonBlocking() {
- this.isNonBlocking = true;
- return this;
- }
-
- /**
* Sets the delegate of the service, that gets notified of the
* status of message delivery.
*
@@ -398,19 +383,15 @@ public ApnsService build() {
SSLSocketFactory sslFactory = sslContext.getSocketFactory();
ApnsFeedbackConnection feedback = new ApnsFeedbackConnection(sslFactory, feedbackHost, feedbackPort, proxy);
- if (isNonBlocking) {
- service = new MinaAdaptor(sslContext, gatewayHost, gatewaPort, feedback);
- } else {
- ApnsConnection conn = new ApnsConnectionImpl(sslFactory, gatewayHost, gatewaPort, proxy, reconnectPolicy, delegate, errorDetection);
- if (pooledMax != 1) {
- conn = new ApnsPooledConnection(conn, pooledMax, executor);
- }
+ ApnsConnection conn = new ApnsConnectionImpl(sslFactory, gatewayHost, gatewaPort, proxy, reconnectPolicy, delegate, errorDetection);
+ if (pooledMax != 1) {
+ conn = new ApnsPooledConnection(conn, pooledMax, executor);
+ }
- service = new ApnsServiceImpl(conn, feedback);
+ service = new ApnsServiceImpl(conn, feedback);
- if (isQueued) {
- service = new QueuedApnsService(service);
- }
+ if (isQueued) {
+ service = new QueuedApnsService(service);
}
service.start();
View
66 src/main/java/com/notnoop/apns/internal/MinaAdaptor.java
@@ -1,66 +0,0 @@
-package com.notnoop.apns.internal;
-
-import java.net.InetSocketAddress;
-
-import javax.net.ssl.SSLContext;
-
-import org.apache.mina.core.buffer.IoBuffer;
-import org.apache.mina.core.future.ConnectFuture;
-import org.apache.mina.core.service.IoHandlerAdapter;
-import org.apache.mina.filter.ssl.SslFilter;
-import org.apache.mina.transport.socket.nio.NioSocketConnector;
-
-import com.notnoop.apns.ApnsNotification;
-import com.notnoop.exceptions.NetworkIOException;
-
-public class MinaAdaptor extends AbstractApnsService {
- NioSocketConnector connector;
- ConnectFuture cf;
- private final String host;
- private final int port;
-
- public MinaAdaptor(SSLContext sslContext, String host, int port) {
- this(sslContext, host, port, null);
- }
-
- public MinaAdaptor(SSLContext sslContext, String host,
- int port, ApnsFeedbackConnection feedback) {
- super(feedback);
- this.host = host;
- this.port = port;
- this.connector = createNioSocketConnector(sslContext);
- }
-
- private NioSocketConnector createNioSocketConnector(SSLContext sslContext) {
- NioSocketConnector connector = new NioSocketConnector();
- connector.setConnectTimeoutMillis(30 * 1000L);
- connector.setHandler(new IoHandlerAdapter());
- SslFilter sslFilter = new SslFilter(sslContext);
- sslFilter.setUseClientMode(true);
- connector.getFilterChain().addLast("SSL", sslFilter);
- return connector;
- }
-
- @Override
- public void push(ApnsNotification message) {
- byte[] msg = message.marshall();
- IoBuffer buf = IoBuffer.allocate(msg.length);
- System.arraycopy(msg, 0, buf.array(), 0, msg.length);
- cf.getSession().write(buf);
- }
-
- public void start() {
- cf = connector.connect(new InetSocketAddress(host, port));
- cf.awaitUninterruptibly();
- }
-
- public void stop() {
- Utilities.sleep(1000);
- cf.getSession().close(false).awaitUninterruptibly(100000);
- connector.dispose();
- }
-
- public void testConnection() throws NetworkIOException {
- // TODO: Implement me in a bit
- }
-}

0 comments on commit a3415f4

Please sign in to comment.