示例#1
0
 private Object getInstance(Value entity) {
   Object instance = instances.get(entity);
   if (instance != null) return instance;
   Value implementation = null;
   for (Value impl :
       graph.values(entity, Values.iri("http://purl.org/openapp/server/implementation")))
     if ("http://purl.org/openapp/server/javaFQName".equals(impl.getType())) implementation = impl;
   try {
     if (implementation == null) {
       instance = new Object();
     } else {
       logger.info("Instantiating " + implementation.getString());
       instance = Class.forName(implementation.getString()).newInstance();
     }
     instances.put(entity, instance);
     entities.put(instance, entity);
     if (entity == applicationEntity) applicationInstance = instance;
     if (instance instanceof Bindable) ((Bindable) instance).bind(this);
     return instance;
   } catch (Exception e) {
     throw new Error("Error instantiating " + implementation.getString(), e);
   }
 }