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