1 package org.andromda.core.repository;
2
3 import java.io.InputStream;
4 import org.andromda.core.metafacade.ModelAccessFacade;
5
6 /**
7 * An interface for objects responsible for being a repository into which an object model can be loaded.
8 * <p>
9 * AndroMDA does code generation from an object model. There must exist a repository in which the model can be loaded.
10 * The repository must be able to load the object model given a URL. Any repository that supports this API can be used
11 * by AndroMDA. </p>
12 *
13 * @author <A HREF="http://www.amowers.com">Anthony Mowers </A>
14 * @author Chad Brandon
15 */
16 public interface RepositoryFacade
17 {
18 /**
19 * Opens and initialize the repository.
20 */
21 public void open();
22
23 /**
24 * Closes the repository and reclaims all resources.
25 */
26 public void close();
27
28 /**
29 * <p>
30 * Reads the object model into the repository from one or more model URIs. If uris is
31 * <strong>null </strong> or zero length, then an empty model will be created in the repository
32 * and can be retrieved from {@link #getModel()}.
33 * </p>
34 *
35 * @param uris a list of modelUrls from which to load each URL of the model.
36 * @param moduleSearchPath a list of paths from which to search for module models (i.e. models that can be referenced from
37 * within other models).
38 */
39 public void readModel(
40 String[] uris,
41 String[] moduleSearchPath);
42
43 /**
44 * Reads the object model into the repository from the given model streams. If the streams is
45 * <strong>null </strong> then an empty model will be created in the repository and can be retrieved from {@link #getModel()}.
46 *
47 * @param streams a list of InputStream instances containing a model.
48 * @param uris a list of URIs from which each stream in the <code>streams</code> parameter was loaded (note that the size
49 * and order of this list must match the order of the streams list).
50 * @param moduleSearchPath a list of paths from which to search for module models (i.e. models that can be referenced from
51 * within other models).
52 */
53 public void readModel(
54 InputStream[] streams,
55 String[] uris,
56 String[] moduleSearchPath);
57
58 /**
59 * Writes the given <code>model</code> to the specified <code>outputLocation</code>.
60 *
61 * @param model the <code>model</code> to write.
62 * @param outputLocation the location to write the model file.
63 * @param version the <code>version</code> of the model to be written (i.e. could be XMI version if the
64 * repository writes XMI files).
65 * @param encoding the encoding of the file to be written.
66 */
67 public void writeModel(
68 Object model,
69 String outputLocation,
70 String version,
71 String encoding);
72
73 /**
74 * Writes the given <code>model</code> to the specified <code>outputLocation</code> using the default encoding
75 * provided by the model writer.
76 *
77 * @param model the <code>model</code> to write.
78 * @param outputLocation the location to write the model file.
79 * @param version the <code>version</code> of the model to be written (i.e. could be XMI version if the
80 * repository writes XMI files).
81 */
82 public void writeModel(
83 Object model,
84 String outputLocation,
85 String version);
86
87 /**
88 * Returns the facade as the given <code>type</code> for the top-level model object from the repository. This model object
89 * contains all models <code>read</code> into the repository. If the type is not specified, the default model access
90 * facade will be used.
91 *
92 * @return the model value (or <code>null</code> if no models exist in the repository).
93 */
94 public ModelAccessFacade getModel();
95
96 /**
97 * Clears the repository of any model(s)
98 * (without shutting it down).
99 */
100 public void clear();
101 }