Add option to build without start #90

Closed
andrewchen5678 opened this Issue Mar 8, 2013 · 3 comments

Comments

Projects
None yet
2 participants

There should be a way to build without actually starting the service, for the ApnsServiceBuilder.java, there should be a method which does build() without calling service.start() because sometimes we want to build the ApnsService without starting it right away.

public ApnsService build() {
    checkInitialization();
    ApnsService service;

    SSLSocketFactory sslFactory = sslContext.getSocketFactory();
    ApnsFeedbackConnection feedback = new ApnsFeedbackConnection(sslFactory, feedbackHost, feedbackPort, proxy);

    ApnsConnection conn = new ApnsConnectionImpl(sslFactory, gatewayHost, 
            gatewaPort, proxy, reconnectPolicy, 
            delegate, errorDetection, cacheLength, autoAdjustCacheLength);
    if (pooledMax != 1) {
        conn = new ApnsPooledConnection(conn, pooledMax, executor);
    }

    service = new ApnsServiceImpl(conn, feedback);

    if (isQueued) {
        service = new QueuedApnsService(service);
    }

    if (isBatched) {
        service = new BatchApnsService(conn, feedback, batchWaitTimeInSec, batchMaxWaitTimeInSec, batchThreadFactory);
    }

    service.start();

    return service;
}
Contributor

froh42 commented Mar 8, 2013

Hi @andrewchen5678 ,

please elaborate a bit on why you'd need that. I'm trying to understand how people use java-apns.

Sometime when I build a QueuedApnsService or some other ApnsService, I don't want to start them right away because I want to do some customization to it first.

Contributor

froh42 commented May 30, 2014

@andrewchen5678, if you're still interested in that feature feel free to supply a patch.

Currently I can on focus on getting the current feature set stable for a 1.0.0.

@froh42 froh42 closed this May 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment