]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.project/src/org/simantics/project/IProject.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.project / src / org / simantics / project / IProject.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.project;
13
14 import org.simantics.db.Resource;
15 import org.simantics.db.Session;
16 import org.simantics.project.exception.ProjectException;
17 import org.simantics.project.features.IProjectFeature;
18 import org.simantics.utils.Container;
19 import org.simantics.utils.datastructures.disposable.IDisposable;
20 import org.simantics.utils.datastructures.hints.IHintContext;
21
22 /**
23  * <ul>
24  * <li>A project is always related to a single database session.</li>
25  * <li>Disposing an IProject shall release all temporarily allocated resources, but it shall not remove anything that will prevent the project from being reloaded</li>
26  * <li>Features only configure/deconfigure this IProject by adding/removing things from the IHintContext</li>
27  * <li>A feature should only perform a single task</li>
28  * <li>Features should be easily composable into new features</li>
29  * <li>Life-cycle handlers that perform project-specific (de)initialization tasks, can be added to projects</li>
30  * </ul>
31  * 
32  * @author Tuukka Lehtonen
33  */
34 public interface IProject extends IDisposable, IHintContext, Container<Resource> {
35
36     /**
37      * @return the session this project is related to.
38      */
39     Session getSession();
40
41     /**
42      * @return the features used with this <code>IProject</code>. Depending on
43      *         whether the the project is activated or not, the features will be
44      *         either configured or unconfigured.
45      * @see #activate()
46      * @see #deactivate()
47      */
48     IProjectFeature[] getFeatures();
49
50     /**
51      * Activates the project.
52      * 
53      * <p>
54      * This implies invoking all {@link IProjectFeature#configure()} handlers
55      * that are attached to this project. The invocation order is the same as in
56      * which {@link #getFeatures()} returns the features. If the project has
57      * already been activated, this should be a null operation.
58      * </p>
59      * <p>
60      * This method may only be invoked outside of any transaction. This allows
61      * the {@link IProjectFeature} handlers to perform arbitrary read and/or
62      * write requests into the database.
63      * </p>
64      */
65     void activate() throws ProjectException;
66
67     /**
68      * Deactivates the project.
69      * 
70      * <p>
71      * A deactivated project can be activated again later, as long as it isn't
72      * disposed.
73      * </p>
74      * 
75      * <p>
76      * This implies invoking all {@link IProjectFeature#deconfigure()} handlers
77      * that are attached to this project. The invocation order is the reverse of
78      * the activation order. If the project is already inactive, this should be
79      * a null operation.
80      * </p>
81      * 
82      * <p>
83      * Project disposal also implies deactivation.
84      * </p>
85      */
86     void deactivate() throws ProjectException;
87
88 }