blob: 7ff341b80e5a5726623aaad2d9f5c70873ac2093 (
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
|
/*****************************************************************************
* Copyright (c) 2013 CEA LIST and others.
*
* 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
*
* Contributors:
* CEA LIST - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.views.search.utils;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.views.search.scope.ScopeEntry;
/**
* A tracker of references to service registries used by {@linkplain ScopeEntry scope entries}, which automatically shuts them down
* when they are no longer needed.
*/
public interface IServiceRegistryTracker {
/**
* Queries whether I am still actively tracking service registries and able to handle requests to {@link IServiceRegistryTracker#track(Object, ServicesRegistry) track} or {@link #untrack(Object, ServicesRegistry) un-track} service
* registries.
*
* @return whether I am currently active
*/
boolean isActive();
/**
* <p>
* Adds a service registry for me to track. Multiple service registries may be tracked against one owner, but a service registry may only be tracked against at most one owner.
* </p>
* <p>
* Has no effect if this {@code serviceRegistry} is already tracked against this {@code owner}.
* </p>
*
* @param owner
* the owner of the {@code serviceRegistry}. I track references to this object; when it is no longer in use, the {@code serviceRegistry} is
* shut down.
*
* @param serviceRegistry
* a service registry to shut down when its {@code owner} is no longer in use
*
* @throws IllegalArgumentException
* if this {@code serviceRegistry} is already tracked against a different owner than the given {@code owner}
*
* @throws IllegalStateException
* if I am not {@link #isActive() active}
*
* @see #untrack(Object, ServicesRegistry)
* @see #isActive()
*/
void track(Object owner, ServicesRegistry serviceRegistry);
/**
* Stops tracking the given service registry. Has no effect if this {@code serviceRegistry} is not currently being {@linkplain #track(Object, ServicesRegistry) tracked} against this {@code owner}.
*
* @param owner
* the owner of the {@code serviceRegistry}
* @param serviceRegistry
* a service registry that I may be tracking against its {@code owner}
*
* @throws IllegalStateException
* if I am not {@link #isActive() active}
*/
void untrack(Object owner, ServicesRegistry serviceRegistry);
}
|