1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.project;
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;
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>
32 * @author Tuukka Lehtonen
34 public interface IProject extends IDisposable, IHintContext, Container<Resource> {
37 * @return the session this project is related to.
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.
48 IProjectFeature[] getFeatures();
51 * Activates the project.
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.
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.
65 void activate() throws ProjectException;
68 * Deactivates the project.
71 * A deactivated project can be activated again later, as long as it isn't
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
83 * Project disposal also implies deactivation.
86 void deactivate() throws ProjectException;