Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b17d441148ee9e34c717d37377a170305ec1a923 (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
/*******************************************************************************
 * Copyright (c) 2011, 2013 Wind River Systems, Inc. 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:
 * Wind River Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.tcf.te.runtime.persistence.interfaces;

import java.io.IOException;

import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;

/**
 * Interface to be implemented by persistence delegates.
 */
public interface IPersistenceDelegate extends IExecutableExtension {

	/**
	 * Writes the given context to the given persistence container.
	 * If the container does not exist yet, the class needs to be given.
	 *
	 * @param context The context to persist. Must not be <code>null</code>.
	 * @param container The persistence container or class for a new one. Must not be <code>null</code>.
	 *
	 * @return The new or updated container instance.
	 */
	public Object write(Object context, Object container) throws IOException;

	/**
	 * Writes the given list of context objects to the given persistence container.
	 * If the container does not exist yet, the class needs to be given.
	 *
	 * @param context The list of contexts to persist. Must not be <code>null</code>.
	 * @param container The persistence container or class for a new one. Must not be <code>null</code>.
	 *
	 * @return The new or updated container instance.
	 */
	public Object writeList(Object[] context, Object container) throws IOException;

	/**
	 * Get the class or interface for the context.
	 *
	 * @param context The context to persist. Must not be <code>null</code>.
	 * @return The class or interface for the given context.
	 */
	public Class<?> getPersistedClass(Object context);

	/**
	 * Reads the context from the given persistence container.
	 * If the context does not exist yet, the class needs to be given.
	 *
	 * @param context The context to update or class for a new context or <code>null</code>.
	 * @param container The persistence container. Must not be <code>null</code>.
	 *
	 * @return The new or updated context instance.
	 */
	public Object read(Object context, Object container) throws IOException;

	/**
	 * Reads a list of context objects from the given persistence container.
	 *
	 * @param contextClass The class type of the context objects to read or <code>null</code>.
	 * @param container The persistence container. Must not be <code>null</code>.
	 *
	 * @return The list of context objects. Might be empty.
	 */
	public Object[] readList(Class<?> contextClass, Object container) throws IOException;

	/**
	 * Deletes the given context inside the container or the whole container.
	 *
	 * @param context The context to delete inside the storage or <code>null</code>.
	 * @param container The persistence container. Must not be <code>null</code>.
	 *
	 * @return <code>True</code> if the persistence context or the whole storage was successfully deleted;
	 *         <code>false</code> otherwise.
	 */
	public boolean delete(Object context, Object container) throws IOException;
}

Back to the top