Skip to content

Commit 06efead

Browse files
authored
Merge pull request #27 from eclipse-researchlabs/messageBroker
add message broker as datasource
2 parents 3e1902c + 291469e commit 06efead

File tree

48 files changed

+1996
-748
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1996
-748
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ pom.xml.versionsBackup
1414

1515
#lucene
1616
# TODO: remove this ignore once monitoring folder has been moved
17-
monitoring
17+
context-monitoring/monitoring/
18+
smartclide-monitoring/monitoring/

context-core/src/main/java/de/atb/context/common/util/ApplicationScenario.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import de.atb.context.common.configuration.ApplicationScenarioConfiguration;
1818
import de.atb.context.common.configuration.IConfigurationBean;
1919
import de.atb.context.learning.models.IModelInitializer;
20+
import lombok.ToString;
2021
import org.slf4j.Logger;
2122
import org.slf4j.LoggerFactory;
2223

@@ -34,6 +35,7 @@
3435
*/
3536
@XmlAccessorType(XmlAccessType.FIELD)
3637
@XmlRootElement
38+
@ToString(exclude = {"logger", "initializer"})
3739
public class ApplicationScenario implements IModelInitializer {
3840
@XmlTransient
3941
private final Logger logger = LoggerFactory
@@ -166,12 +168,13 @@ public IModelInitializer getInitializer() {
166168
@SuppressWarnings("unchecked")
167169
protected boolean createConfigurationClass() {
168170
try {
169-
if (configurationClass == null) {
170-
final Class<? extends ApplicationScenarioConfiguration<?>> clazz = (Class<? extends ApplicationScenarioConfiguration<?>>) Class
171-
.forName(configurationClassName);
171+
// FIXME: temporary workaround
172+
if (configurationClass == null && configurationClassName != null) {
173+
final Class<? extends ApplicationScenarioConfiguration<?>> clazz =
174+
(Class<? extends ApplicationScenarioConfiguration<?>>) Class.forName(configurationClassName);
172175
configurationClass = clazz;
176+
return true;
173177
}
174-
return true;
175178
} catch (final ClassNotFoundException e) {
176179
logger.error(e.getMessage(), e);
177180
}

context-core/src/main/java/de/atb/context/services/manager/ServiceManager.java

+36-44
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
* @(#)ServiceManager.java
33
*
44
* $Id: ServiceManager.java 679 2016-11-24 18:29:04Z gsimoes $
5-
*
5+
*
66
* $Rev:: 679 $ last change revision
77
* $Date:: 2016-11-24 19:29:04#$ last change date
88
* $Author:: gsimoes $ last change author
9-
*
9+
*
1010
* Copyright 2011-15 Oliver Kotte. All rights reserved.
1111
*
1212
*/
@@ -27,6 +27,23 @@
2727
*/
2828

2929

30+
import java.lang.annotation.Annotation;
31+
import java.lang.reflect.Constructor;
32+
import java.lang.reflect.InvocationTargetException;
33+
import java.lang.reflect.Modifier;
34+
import java.net.MalformedURLException;
35+
import java.net.URL;
36+
import java.util.ArrayList;
37+
import java.util.List;
38+
39+
import javax.jws.WebService;
40+
import javax.xml.ws.BindingProvider;
41+
42+
import de.atb.context.modules.Deployer;
43+
import de.atb.context.services.SWServiceContainer;
44+
import de.atb.context.services.config.models.SWService;
45+
import de.atb.context.services.infrastructure.ServiceRegistryService;
46+
import de.atb.context.services.interfaces.IPrimitiveService;
3047
import lombok.Getter;
3148
import org.apache.cxf.endpoint.Client;
3249
import org.apache.cxf.endpoint.Server;
@@ -45,22 +62,6 @@
4562
import org.apache.cxf.ws.addressing.WSAddressingFeature;
4663
import org.slf4j.Logger;
4764
import org.slf4j.LoggerFactory;
48-
import de.atb.context.modules.Deployer;
49-
import de.atb.context.services.SWServiceContainer;
50-
import de.atb.context.services.config.models.SWService;
51-
import de.atb.context.services.infrastructure.ServiceRegistryService;
52-
import de.atb.context.services.interfaces.IPrimitiveService;
53-
54-
import javax.jws.WebService;
55-
import javax.xml.ws.BindingProvider;
56-
import java.lang.annotation.Annotation;
57-
import java.lang.reflect.Constructor;
58-
import java.lang.reflect.InvocationTargetException;
59-
import java.lang.reflect.Modifier;
60-
import java.net.MalformedURLException;
61-
import java.net.URL;
62-
import java.util.ArrayList;
63-
import java.util.List;
6465

6566
/**
6667
* ServiceManager
@@ -83,10 +84,8 @@ public class ServiceManager {
8384
private static Deployer deployer;
8485
@Getter
8586
private static de.atb.context.modules.Server server;
86-
//public static Notifier notifier;
8787

88-
private static final Logger logger = LoggerFactory
89-
.getLogger(ServiceManager.class);
88+
private static final Logger logger = LoggerFactory.getLogger(ServiceManager.class);
9089

9190
public static synchronized void shutdownServiceAndEngine(final Server server) {
9291
if (server != null) {
@@ -121,8 +120,9 @@ public static synchronized <T extends IPrimitiveService> Server registerWebservi
121120
: host;
122121

123122
String name = service.getName();
124-
name = (name.equals("null") || (name.trim().length() == 0)) ? getServiceNameFromClass(service
125-
.getServerClass()) : name;
123+
name = (name.equals("null") || (name.trim().length() == 0))
124+
? getServiceNameFromClass(service.getServerClass())
125+
: name;
126126

127127
return registerWebservice(host, port, name,
128128
createInstance(service.getServerClass()),
@@ -184,8 +184,7 @@ public static synchronized <T extends IPrimitiveService> Server registerWebservi
184184
public static synchronized <T extends IPrimitiveService> Server registerWebservice(
185185
final String host, final int port, final String serviceName, final T serviceBean,
186186
final Class<? extends T> serviceClass) {
187-
String address = String.format(SERVICE_PATTERN, host,
188-
Integer.valueOf(port), serviceName);
187+
String address = String.format(SERVICE_PATTERN, host, port, serviceName);
189188
logger.info("Trying to create Service '" + serviceName + "' at " + host
190189
+ ":" + port);
191190
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
@@ -212,8 +211,7 @@ public static synchronized <T extends IPrimitiveService> Server registerWebservi
212211
final Class<? extends T> serviceClass, final SWServiceContainer service) {
213212

214213
// WebService annotation = serviceClass.getAnnotation(WebService.class);
215-
String address = String.format(SERVICE_PATTERN, host,
216-
Integer.valueOf(port), serviceName);
214+
String address = String.format(SERVICE_PATTERN, host, port, serviceName);
217215
// String teste = annotation.wsdlLocation();
218216
logger.info("Trying to create Service '" + serviceName + "' at " + host
219217
+ ":" + port);
@@ -242,16 +240,13 @@ public static synchronized <T extends IPrimitiveService> Server registerWebservi
242240
@SuppressWarnings("unchecked")
243241
public static synchronized <T extends IPrimitiveService> T getWebservice(
244242
final SWServiceContainer service) {
245-
int port = service.getLocation().getPort() == -1 ? DEFAULT_SERVICE_PORT
246-
: service.getLocation().getPort();
243+
int port = service.getLocation().getPort() == -1 ? DEFAULT_SERVICE_PORT : service.getLocation().getPort();
247244

248245
String host = String.valueOf(service.getLocation().getHost());
249-
host = (host.equals("null") || (host.trim().length() == 0)) ? DEFAULT_SERVICE_HOST
250-
: host;
246+
host = (host.equals("null") || (host.trim().length() == 0)) ? DEFAULT_SERVICE_HOST : host;
251247

252248
String name = service.getName();
253-
name = (name.equals("null") || (name.trim().length() == 0)) ? getServiceNameFromClass(service
254-
.getProxyClass()) : name;
249+
name = (name.equals("null") || (name.trim().length() == 0)) ? getServiceNameFromClass(service.getProxyClass()) : name;
255250

256251
return (T) getWebservice(host, port, name, service.getProxyClass());
257252
}
@@ -288,32 +283,30 @@ public static synchronized <T extends IPrimitiveService> T getWebservice(
288283
public static synchronized <T extends IPrimitiveService> T getWebservice(
289284
final String host, final int port, final String serviceName,
290285
final Class<? extends T> serviceClass) {
291-
String address = String.format(SERVICE_PATTERN, host,
292-
Integer.valueOf(port), serviceName);
293-
logger.info("Trying to receive Service '" + serviceName + "' at "
294-
+ host + ":" + port);
286+
String address = String.format(SERVICE_PATTERN, host, port, serviceName);
287+
logger.info("Trying to receive Service '{}' at {}:{}", serviceName, host, port);
295288
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
296289
factory.getInInterceptors().add(new LoggingInInterceptor());
297290
factory.getOutInterceptors().add(new LoggingOutInterceptor());
298291
factory.setServiceClass(serviceClass);
299292
factory.setAddress(address);
300293
T service = (T) factory.create();
301-
logger.info("Received Service at '%s' at %s:%s", serviceName, address, port);
294+
logger.info("Received Service at '{}' at {}:{}", serviceName, address, port);
302295
setClientPolicies(service);
303296
return service;
304297
}
305298

306299
@SuppressWarnings("unchecked")
307300
public static synchronized <T extends IPrimitiveService> T getWebservice(
308301
final String address, final String serviceName, final Class<? extends T> serviceClass) {
309-
logger.info("Trying to receive Service '%s' at %s", serviceName, address);
302+
logger.info("Trying to receive Service '{}' at {}", serviceName, address);
310303
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
311304
factory.getInInterceptors().add(new LoggingInInterceptor());
312305
factory.getOutInterceptors().add(new LoggingOutInterceptor());
313306
factory.setServiceClass(serviceClass);
314307
factory.setAddress(address);
315308
T service = (T) factory.create();
316-
logger.info("Received Service '%s' at %s", serviceName, address);
309+
logger.info("Received Service '{}' at {}", serviceName, address);
317310
setClientPolicies(service);
318311
return service;
319312
}
@@ -332,7 +325,7 @@ public static synchronized Client getDynamicWebservice(final String wsdl_address
332325
@SuppressWarnings("unchecked")
333326
public static synchronized <T extends IPrimitiveService> T getWebserviceDecoupledMode(
334327
final String address, final String serviceName, final Class<? extends T> serviceClass) {
335-
logger.info("Trying to receive Service '%s' at %s", serviceName, address);
328+
logger.info("Trying to receive Service '{}' at {}", serviceName, address);
336329
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
337330
ClientFactoryBean cfb = factory.getClientFactoryBean();
338331
WSAddressingFeature wsAddressingFeature = new WSAddressingFeature();
@@ -346,8 +339,7 @@ public static synchronized <T extends IPrimitiveService> T getWebserviceDecouple
346339
"^[^\\w]+|[^\\w]+$", "");
347340
int responseAddressInt = Integer.parseInt(responseAddress) + 100;
348341

349-
String addressResponse = String.format(SERVICE_PATTERN, hostAddress,
350-
Integer.valueOf(responseAddressInt), serviceName);
342+
String addressResponse = String.format(SERVICE_PATTERN, hostAddress, responseAddressInt, serviceName);
351343

352344
factory.getInInterceptors().add(new LoggingInInterceptor());
353345
factory.getOutInterceptors().add(new LoggingOutInterceptor());
@@ -356,7 +348,7 @@ public static synchronized <T extends IPrimitiveService> T getWebserviceDecouple
356348
T service = (T) factory.create();
357349
((BindingProvider) service).getRequestContext().put(
358350
WS_ADDRESSING_REPLYTO, addressResponse);
359-
logger.info("Received Service '%s' at %s", serviceName, address);
351+
logger.info("Received Service '{}' at {}", serviceName, address);
360352
setClientPolicies(service);
361353
return service;
362354
}

context-extraction/src/main/java/de/atb/context/extraction/ContextContainerWrapper.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
* @(#)ContextContainerWrapper.java
33
*
44
* $Id: ContextContainerWrapper.java 647 2016-10-20 15:13:20Z scholze $
5-
*
5+
*
66
* $Rev:: 647 $ last change revision
77
* $Date:: 2016-10-20 17:13:20#$ last change date
88
* $Author:: scholze $ last change author
9-
*
9+
*
1010
* Copyright 2011-15 Sebastian Scholze (ATB). All rights reserved.
1111
*
1212
*/
@@ -43,16 +43,17 @@
4343

4444
/**
4545
* ContextContainerWrapper
46-
*
46+
*
4747
* @author scholze
4848
* @version $LastChangedRevision: 647 $
49-
*
49+
*
5050
*/
5151
@Setter
5252
@Getter
5353
public class ContextContainerWrapper {
5454

55-
protected ApplicationScenario applicationScenario = ApplicationScenario.getInstance(BusinessCase.getInstance("dummy",BusinessCase.NS_DUMMY_URL));
55+
protected ApplicationScenario applicationScenario =
56+
ApplicationScenario.getInstance(BusinessCase.getInstance(BusinessCase.NS_DUMMY_ID, BusinessCase.NS_DUMMY_URL));
5657
protected Boolean useReasoner = Boolean.FALSE;
5758
protected String identifier;
5859
protected String monitoringDataId;

context-monitoring/pom.xml

+5-27
Original file line numberDiff line numberDiff line change
@@ -59,38 +59,16 @@
5959
<version>1.1.1</version>
6060
</dependency>
6161

62-
<!-- KAFKA Dependencies -->
6362
<dependency>
64-
<groupId>org.springframework.kafka</groupId>
65-
<artifactId>spring-kafka</artifactId>
66-
</dependency>
67-
<dependency>
68-
<groupId>org.springframework.boot</groupId>
69-
<artifactId>spring-boot-starter-web</artifactId>
70-
<exclusions>
71-
<exclusion>
72-
<groupId>org.springframework.boot</groupId>
73-
<artifactId>spring-boot-starter-logging</artifactId>
74-
</exclusion>
75-
</exclusions>
63+
<groupId>com.rabbitmq</groupId>
64+
<artifactId>amqp-client</artifactId>
65+
<version>5.12.0</version>
7666
</dependency>
7767

78-
<!-- Test -->
79-
<dependency>
80-
<groupId>org.springframework.boot</groupId>
81-
<artifactId>spring-boot-starter-test</artifactId>
82-
<scope>test</scope>
83-
</dependency>
8468
<dependency>
85-
<groupId>org.junit.vintage</groupId>
86-
<artifactId>junit-vintage-engine</artifactId>
69+
<groupId>org.testcontainers</groupId>
70+
<artifactId>rabbitmq</artifactId>
8771
<scope>test</scope>
88-
<exclusions>
89-
<exclusion>
90-
<groupId>org.hamcrest</groupId>
91-
<artifactId>hamcrest-core</artifactId>
92-
</exclusion>
93-
</exclusions>
9472
</dependency>
9573
</dependencies>
9674
</project>

context-monitoring/src/main/java/de/atb/context/monitoring/MetaMonitor.java

+25-11
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,20 @@
1515
*/
1616

1717

18+
import java.lang.reflect.Constructor;
19+
import java.lang.reflect.InvocationTargetException;
20+
import java.lang.reflect.Modifier;
21+
1822
import de.atb.context.common.exceptions.ConfigurationException;
1923
import de.atb.context.monitoring.config.models.DataSource;
2024
import de.atb.context.monitoring.config.models.Interpreter;
2125
import de.atb.context.monitoring.config.models.Monitor;
2226
import de.atb.context.monitoring.index.Indexer;
27+
import de.atb.context.monitoring.models.IMonitoringDataModel;
2328
import de.atb.context.monitoring.monitors.ThreadedMonitor;
2429
import de.atb.context.services.wrapper.AmIMonitoringDataRepositoryServiceWrapper;
25-
import org.slf4j.LoggerFactory;
2630
import de.atb.context.tools.ontology.AmIMonitoringConfiguration;
27-
28-
import java.lang.reflect.Constructor;
29-
import java.lang.reflect.InvocationTargetException;
30-
import java.lang.reflect.Modifier;
31+
import org.slf4j.LoggerFactory;
3132

3233
/**
3334
* MetaMonitor
@@ -39,8 +40,13 @@
3940
public class MetaMonitor {
4041

4142
@SuppressWarnings("unchecked")
42-
public static <P, A> ThreadedMonitor<P, A> createThreadedMonitor(final Monitor monitor, final DataSource dataSource, final Interpreter interpreter,
43-
final Indexer indexer, final AmIMonitoringConfiguration configuration, AmIMonitoringDataRepositoryServiceWrapper amiRepository) throws ConfigurationException {
43+
public static <P, A extends IMonitoringDataModel<?, ?>> ThreadedMonitor<P, A> createThreadedMonitor(
44+
final Monitor monitor,
45+
final DataSource dataSource,
46+
final Interpreter interpreter,
47+
final Indexer indexer,
48+
final AmIMonitoringConfiguration configuration,
49+
final AmIMonitoringDataRepositoryServiceWrapper amiRepository) throws ConfigurationException {
4450
Class<?> factory;
4551
try {
4652
factory = Class.forName(dataSource.getMonitor());
@@ -52,10 +58,18 @@ public static <P, A> ThreadedMonitor<P, A> createThreadedMonitor(final Monitor m
5258

5359
if (!Modifier.isAbstract(modifier) && !Modifier.isInterface(modifier) && !Modifier.isStatic(modifier)) {
5460
try {
55-
Constructor<?> constructor = factory.getConstructor(DataSource.class, Interpreter.class, Monitor.class,
56-
Indexer.class, AmIMonitoringConfiguration.class);
57-
ThreadedMonitor<P, A> instance = (ThreadedMonitor<P, A>) constructor.newInstance(new Object[]{dataSource, interpreter,
58-
monitor, indexer, configuration});
61+
Constructor<?> constructor = factory.getConstructor(DataSource.class,
62+
Interpreter.class,
63+
Monitor.class,
64+
Indexer.class,
65+
AmIMonitoringConfiguration.class);
66+
ThreadedMonitor<P, A> instance = (ThreadedMonitor<P, A>) constructor.newInstance(new Object[]{
67+
dataSource,
68+
interpreter,
69+
monitor,
70+
indexer,
71+
configuration
72+
});
5973
instance.setAmiRepository(amiRepository);
6074
return instance;
6175
} catch (InstantiationException | InvocationTargetException | IllegalArgumentException | IllegalAccessException | NoSuchMethodException | SecurityException e) {

0 commit comments

Comments
 (0)