View Javadoc
1   package org.andromda.core.repository;
2   
3   import org.andromda.core.common.ClassUtils;
4   import org.andromda.core.namespace.BaseNamespaceComponent;
5   
6   /**
7    * Represents the repository namespace component.  This is what
8    * configures a repository instance.
9    *
10   * @author Chad Brandon
11   */
12  public class Repository
13      extends BaseNamespaceComponent
14  {
15      /**
16       * Stores the repository facade implementation.
17       */
18      private RepositoryFacade implementation = null;
19  
20      /**
21       * Sets the implementation class name.
22       *
23       * @param implementationClass the implementation class.
24       */
25      public void setImplementationClass(final String implementationClass)
26      {
27          final Class type = ClassUtils.loadClass(implementationClass);
28          if (!RepositoryFacade.class.isAssignableFrom(type))
29          {
30              throw new RepositoryException(
31                  "Implementation '" + implementationClass + "' must be an instance of '" +
32                  RepositoryFacade.class.getName() + '\'');
33          }
34          implementation = (RepositoryFacade)ClassUtils.newInstance(type);
35      }
36  
37      /**
38       * Gets the repository implementation.
39       *
40       * @return the repository implementation.
41       */
42      public RepositoryFacade getImplementation()
43      {
44          return this.implementation;
45      }
46  }