--- /dev/null
+package mir.media;
+
+import java.lang.reflect.*;
+import java.lang.*;
+
+import mir.entity.Entity;
+import mir.storage.Database;
+
+/**
+ * helper class to resolve media handlers using reflection
+ *
+ * @author mh
+ * @version 2002
+ */
+
+public final class MediaHelper {
+
+ static String _classPrefix = "mir.media.MediaHandler";
+
+ public static MirMedia getHandler( Entity mediaType )
+ throws MirMediaException {
+
+ MirMedia mediaHandler;
+ String handlerName = mediaType.getValue("classname");
+ try {
+ Class handlerClass = Class.forName(_classPrefix+handlerName);
+ return mediaHandler = (MirMedia)handlerClass.newInstance();
+ } catch (Exception e) {
+ throw new MirMediaException ("getHandler -- error in reflection "
+ +e.toString());
+ }
+ }
+
+ public static Database getStorage(Entity mediaType, String classPrefix)
+ throws MirMediaException {
+
+ Database mediaStorage;
+ String storageName = mediaType.getValue("tablename");
+ try {
+ Class storageClass = Class.forName(classPrefix+storageName);
+ Method m = storageClass.getMethod("getInstance", null);
+ return mediaStorage = (Database)m.invoke(null, null);
+ } catch (Exception e) {
+ throw new MirMediaException ("getStorage -- error in reflection "
+ +e.toString());
+ }
+ }
+
+}
+
+
+