added PushStateDispatcher for production and development to WebResourceServlet

This commit is contained in:
Sebastian Sdorra
2018-08-23 11:48:42 +02:00
parent 9e8bd299f0
commit 0fc09f5c0d
10 changed files with 452 additions and 15 deletions

View File

@@ -0,0 +1,28 @@
package sonia.scm;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import javax.inject.Provider;
/**
* Injection Provider for the {@link PushStateDispatcher}. The provider will return a {@link ProxyPushStateDispatcher}
* if the system property {@code PushStateDispatcherProvider#PROPERTY_TARGET} is set to a proxy target url, otherwise
* a {@link ForwardingPushStateDispatcher} is used.
*
* @since 2.0.0
*/
public class PushStateDispatcherProvider implements Provider<PushStateDispatcher> {
@VisibleForTesting
static final String PROPERTY_TARGET = "sonia.scm.ui.proxy";
@Override
public PushStateDispatcher get() {
String target = System.getProperty(PROPERTY_TARGET);
if (Strings.isNullOrEmpty(target)) {
return new ForwardingPushStateDispatcher();
}
return new ProxyPushStateDispatcher(target);
}
}