Beispiel #1
0
  public void addAEExtension(AEExtension ext) {
    Class<? extends AEExtension> clazz = ext.getClass();
    if (extensions.containsKey(clazz))
      throw new IllegalStateException("already contains AE Extension:" + clazz);

    ext.setApplicationEntity(this);
    extensions.put(clazz, ext);
  }
Beispiel #2
0
 private void reconfigureAEExtensions(ApplicationEntity from) {
   for (Iterator<Class<? extends AEExtension>> it = extensions.keySet().iterator();
       it.hasNext(); ) {
     if (!from.extensions.containsKey(it.next())) it.remove();
   }
   for (AEExtension src : from.extensions.values()) {
     Class<? extends AEExtension> clazz = src.getClass();
     AEExtension ext = extensions.get(clazz);
     if (ext == null)
       try {
         addAEExtension(ext = clazz.newInstance());
       } catch (Exception e) {
         throw new RuntimeException("Failed to instantiate " + clazz.getName(), e);
       }
     ext.reconfigure(src);
   }
 }
Beispiel #3
0
  public boolean removeAEExtension(AEExtension ext) {
    if (extensions.remove(ext.getClass()) == null) return false;

    ext.setApplicationEntity(null);
    return true;
  }