All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gw.lang.reflect.FragmentCache Maven / Gradle / Ivy

There is a newer version: 1.18.2
Show newest version
/*
 * Copyright 2014 Guidewire Software, Inc.
 */

package gw.lang.reflect;

import gw.lang.reflect.gs.IGosuFragment;
import gw.util.cache.WeakFqnCache;

public class FragmentCache implements ITypeLoaderListener {
  private static FragmentCache INSTANCE;
  private WeakFqnCache _fragmentsByName = new WeakFqnCache();

  public static FragmentCache instance() {
    if (INSTANCE == null) {
      INSTANCE = new FragmentCache();
    }
    return INSTANCE;
  }

  public FragmentCache() {
    TypeSystem.addTypeLoaderListenerAsWeakRef(this);
  }

  public IGosuFragment get(String strFullyQualifiedName) {
    return _fragmentsByName.get(strFullyQualifiedName);
  }

  public void addFragment(IGosuFragment fragment) {
    _fragmentsByName.add(fragment.getName(), fragment);
  }

  @Override
  public void refreshedTypes(RefreshRequest request) {
    _fragmentsByName.remove(request.types);
  }

  @Override
  public void refreshed() {
    _fragmentsByName.clear();
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy