From e9b22c8134ef21efeaefc235070439e4a30495e6 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Mon, 3 Oct 2016 11:39:05 +0200 Subject: Dirty workaround to DI hostile legacy code --- .../main/java/com/yahoo/feedapi/FeedContext.java | 25 +++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'vespaclient-core/src') diff --git a/vespaclient-core/src/main/java/com/yahoo/feedapi/FeedContext.java b/vespaclient-core/src/main/java/com/yahoo/feedapi/FeedContext.java index c08d70b02f4..885e28b63a5 100755 --- a/vespaclient-core/src/main/java/com/yahoo/feedapi/FeedContext.java +++ b/vespaclient-core/src/main/java/com/yahoo/feedapi/FeedContext.java @@ -11,6 +11,7 @@ import com.yahoo.clientmetrics.ClientMetrics; import com.yahoo.vespaclient.ClusterList; import com.yahoo.vespaclient.config.FeederConfig; +import javax.naming.OperationNotSupportedException; import java.util.Map; import java.util.TreeMap; @@ -100,11 +101,25 @@ public class FeedContext { try { if (instance == null) { MessagePropertyProcessor proc = new MessagePropertyProcessor(feederConfig, loadTypeConfig); - MessageBusSessionFactory mbusFactory = new MessageBusSessionFactory(proc, documentmanagerConfig, slobroksConfig); - instance = new FeedContext(proc, - mbusFactory, - mbusFactory.getAccess().getDocumentTypeManager(), - new ClusterList(clusterListConfig), metric); + + if (System.getProperty("vespa.local", "false").equals("true")) { + // Use injected configs when running from Application. This means we cannot reconfigure + MessageBusSessionFactory mbusFactory = new MessageBusSessionFactory(proc, documentmanagerConfig, slobroksConfig); + instance = new FeedContext(proc, + mbusFactory, + mbusFactory.getAccess().getDocumentTypeManager(), + new ClusterList(clusterListConfig), metric); + } + else { + // Don't send configs to messagebus to make it self-subscribe instead as this instance + // survives reconfig :-/ + // This code will die soon ... + MessageBusSessionFactory mbusFactory = new MessageBusSessionFactory(proc, null, null); + instance = new FeedContext(proc, + mbusFactory, + mbusFactory.getAccess().getDocumentTypeManager(), + new ClusterList("client"), metric); + } } else { instance.getPropertyProcessor().configure(feederConfig, loadTypeConfig); } -- cgit v1.2.3