blob: 34d03270a343c10491db8e7ab5de27e97df27e73 (
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
|
/*******************************************************************************
* Copyright (c) 2009, 2010 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.equinox.events;
/**
* Defines constants for memory event handlers. A memory event handler implements
* the <code>org.osgi.service.event.EventHandler</code> interface as specified by the OSGi
* Event Admin Service Specification.
* <p>
* For example, the following handler is registered to handle critical memory
* events:
* <pre>
* BundleContext context = getContext();
* EventHandler handler = getHandler();
* Hashtable ht = new Hashtable();
* ht.put(EventConstants.EVENT_TOPIC, MemoryEventConstants.TOPIC_CRITICAL);
* context.registerService(EventHandler.class.getName(), handler, ht);
* </pre>
* There is no policy implemented for sending memory events in Equinox or
* Eclipse by default. Another bundle must implement the policy that determines
* when to send memory events. This policy must use the Event Admin Service
* to fire memory events to the registered handlers.
* </p>
* @since 3.6
*/
public final class MemoryEventConstants {
private MemoryEventConstants() {
// prevent construction.
}
/**
* The base topic that all memory events use.
*/
public static final String TOPIC_BASE = "org/eclipse/equinox/events/MemoryEvent/"; //$NON-NLS-1$
/**
* A memory event topic for normal memory events.
* Indicates memory is running low at the lowest severity.
* Listeners are requested to release caches that can easily be recomputed.
* The Java VM is not seriously in trouble, but process size is getting higher than
* is deemed acceptable.
*/
public static final String TOPIC_NORMAL = TOPIC_BASE + "NORMAL"; //$NON-NLS-1$
/**
* A memory event topic for serious memory events.
* Indicates memory is running low at medium severity.
* Listeners are requested to release complex intermediate models
* (.e.g. intermediate build results).
* Memory is getting low and may cause operating system level stress, such as swapping.
*/
public static final String TOPIC_SERIOUS = TOPIC_BASE + "SERIOUS"; //$NON-NLS-1$
/**
* A memory event topic for critical memory events.
* Indicates memory is running low at highest severity.
* Listeners are requested to do what ever is possible to free memory.
* Things like free in memory caches, close editors and perspectives,
* close database connections, etc.
* Restoring these resources and caches constitutes lots of work, but
* memory is so low that drastic measures are required.
*/
public static final String TOPIC_CRITICAL = TOPIC_BASE + "CRITICAL"; //$NON-NLS-1$
/**
* A memory event topic for all memory events.
*/
public static final String TOPIC_ALL = TOPIC_BASE + "*"; //$NON-NLS-1$
}
|