Skip to main content
summaryrefslogtreecommitdiffstats
blob: d71929791d176e338f0f7dd524c30bc55a87246d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 * Copyright (c) 2017 Peak Solution GmbH
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package org.eclipse.mdm.api.base;

import java.util.Map;
import java.util.Optional;

import org.eclipse.mdm.api.base.adapter.ModelManager;
import org.eclipse.mdm.api.base.file.FileService;
import org.eclipse.mdm.api.base.model.BaseEntityFactory;
import org.eclipse.mdm.api.base.model.Entity;
import org.eclipse.mdm.api.base.notification.NotificationService;
import org.eclipse.mdm.api.base.query.QueryService;
import org.eclipse.mdm.api.base.search.SearchService;

/**
 * Base application context represents a connection/session to the underlying data store.
 * It provides access to managers and services.
 *
 * @param <S>
 *            Type of the connected entity factory.
 * @param <T>
 *            Type of the connected entity manager.
 * @since 1.0.0
 */
public interface BaseApplicationContext<S extends BaseEntityFactory, T extends BaseEntityManager> extends AutoCloseable {
	/**
	 * The returned service loads entities from the underlying data source.
	 *
	 * @return {@code Optional} is empty if no such service is available.
	 */
	default Optional<T> getEntityManager() {
		return Optional.empty();
	}
	
	/**
	 * The returned service creates new entities.
	 *
	 * @return {@code Optional} is empty if no such service is available.
	 */
	default Optional<S> getEntityFactory() {
		return Optional.empty();
	}

	/**
	 * The returned service provides access to the application model's meta data.
	 *
	 * @return {@code Optional} is empty if no such service is available.
	 * @see ModelManager
	 */
	default Optional<ModelManager> getModelManager() {
		return Optional.empty();
	}

	/**
	 * The returned service provides advanced search capabilities for supported
	 * entity types.
	 *
	 * @return {@code Optional} is empty if no such service is available.
	 * @see SearchService
	 */
	default Optional<SearchService> getSearchService() {
		return Optional.empty();
	}

	/**
	 * The returned service provides access to the low level query API.
	 *
	 * @return {@code Optional} is empty if no such service is available.
	 * @see QueryService
	 */
	default Optional<QueryService> getQueryService() {
		return Optional.empty();
	}
	
	/**
	 * The returned service allows to download linked files from the file
	 * storage.
	 *
	 * @return {@code Optional} is empty if no such service is available.
	 * @see FileService
	 */
	default Optional<FileService> getFileService() {
		return Optional.empty();
	}
	
	/**
	 * The returned service allows to register/unregister for events at a registration service.
	 *
	 * @return {@code Optional} is empty if no such service is available.
	 * @see NotificationService
	 */
	default Optional<NotificationService> getNotificationService() {
		return Optional.empty();
	}
	
	/**
	 * Returns a map with all configuration parameters, which where given to initialize this context.
	 * 
	 * @return map with configuration parameters
	 */
	Map<String, String> getParameters();
	
	/**
	 * Returns a string describing the type of the underlying API implementation.
	 * The exact content is up to the individual adapter and it is intended to be 
	 * interpreted by the client.
	 * 
	 * @return a string describing the type of the underlying API implementation.
	 */
	String getAdapterType();
	
	/**
	 * Closes the BaseContext.
	 * 
	 * This closes all underlying managers and services.
	 */
	void close() throws ConnectionException;
}

Back to the top