Skip to content

Commit

Permalink
Fixes #1334
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarcand committed Oct 8, 2013
1 parent 0a21e3b commit 7bf996b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,14 @@ public interface ApplicationConfig {
* Value: org.atmosphere.interceptor.AtmosphereResourceLifecycleInterceptor.method
*/
String ATMOSPHERERESOURCE_INTERCEPTOR_METHOD = AtmosphereResourceLifecycleInterceptor.class.getName() + ".method";
/**
* The timeout, in second, for configuring the time an AtmosphereResource is suspended. Same as {@link AtmosphereResource#suspend(long, java.util.concurrent.TimeUnit)} when the {@link AtmosphereResourceLifecycleInterceptor}
* is used.
* <p>
* Default: "-1"<br>
* Value: org.atmosphere.interceptor.AtmosphereResourceLifecycleInterceptor.timeout
*/
String ATMOSPHERERESOURCE_INTERCEPTOR_TIMEOUT= AtmosphereResourceLifecycleInterceptor.class.getName() + ".timeout";
/**
* Disable au-discovery of pre-installed {@link AtmosphereInterceptor}s.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import static org.atmosphere.cpr.ApplicationConfig.ATMOSPHERERESOURCE_INTERCEPTOR_METHOD;
import static org.atmosphere.cpr.ApplicationConfig.ATMOSPHERERESOURCE_INTERCEPTOR_TIMEOUT;

/**
* <p>This {@link AtmosphereInterceptor} implementation automatically suspends the intercepted
Expand Down Expand Up @@ -58,6 +60,7 @@
public class AtmosphereResourceLifecycleInterceptor implements AtmosphereInterceptor {

private String method = "GET";
private Integer timeoutInSeconds = -1;
private static final Logger logger = LoggerFactory.getLogger(AtmosphereResourceLifecycleInterceptor.class);

@Override
Expand All @@ -66,6 +69,11 @@ public void configure(AtmosphereConfig config) {
if (s != null) {
method = s;
}

s = config.getInitParameter(ATMOSPHERERESOURCE_INTERCEPTOR_TIMEOUT);
if (s != null) {
timeoutInSeconds = Integer.valueOf(s);
}
}

/**
Expand Down Expand Up @@ -113,7 +121,7 @@ public void onBroadcast(AtmosphereResourceEvent event) {
break;
}
}
}).suspend();
}).suspend(timeoutInSeconds == -1 ? timeoutInSeconds : TimeUnit.MILLISECONDS.convert(timeoutInSeconds, TimeUnit.SECONDS);
}
}

Expand Down

1 comment on commit 7bf996b

@buildhive
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Atmosphere Framework » atmosphere #1471 FAILURE
Looks like this commit caused a build failure
(what's this?)

Please sign in to comment.