svn commit: r12904 - trunk/src/model/src/org/argouml/model/Model.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: mvw
Date: 2007-06-24 05:54:35-0700
New Revision: 12904

Modified:
   trunk/src/model/src/org/argouml/model/Model.java

Log:
Shorten the Main.main() method. 

There is no reason the org.argouml.application package should know about a ModelImplementation; 

now it is just a string we hand to the org.argouml.model subsystem.

Modified: trunk/src/model/src/org/argouml/model/Model.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model/src/org/argouml/model/Model.java?view=diff&rev=12904&p1=trunk/src/model/src/org/argouml/model/Model.java&p2=trunk/src/model/src/org/argouml/model/Model.java&r1=12903&r2=12904
==============================================================================
--- trunk/src/model/src/org/argouml/model/Model.java	(original)
+++ trunk/src/model/src/org/argouml/model/Model.java	2007-06-24 05:54:35-0700
@@ -491,6 +491,37 @@
     }
 
     /**
+     * Initialise the model repository, based on 
+     * the name of a ModelImplementation class. <p>
+     * 
+     * The name shall include the path, 
+     * e.g. "org.argouml.model.mdr.MDRModelImplementation".
+     * 
+     * @param modelName class name of the model implementation
+     * @return null if initialised correctly, the error otherwise
+     */
+    public static Throwable initialise(String modelName) {
+        ModelImplementation newImplementation = null;
+        try {
+            Class implType = Class.forName(modelName);
+            newImplementation = (ModelImplementation) implType.newInstance();
+        } catch (ClassNotFoundException e) {
+            return e;
+        } catch (NoClassDefFoundError e) {
+            return e;
+        } catch (InstantiationException e) {
+            return e;
+        } catch (IllegalAccessException e) {
+            return e;
+        }
+        if (newImplementation == null) {
+            return new Throwable();
+        }
+        Model.setImplementation(newImplementation);
+        return null;
+    }
+
+    /**
      * @return <code>true</code> if the Model subsystem is correctly initiated.
      */
     public static boolean isInitiated() {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.