View Javadoc

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