try // this case handles the old style EMF pattern
{
Class javaClass = getPackageClass(factoryClass, packageName);
Field field = javaClass.getField("eINSTANCE");
EPackageImpl pkg = (EPackageImpl)field.get(null);
EPackage.Registry.INSTANCE.put(pkg.getNsURI(), pkg);
}
catch (Exception e1)
{
packageName = factoryClass.getName().replaceFirst("Factory$", "Package");
try // this case handles the EMF -noInterfaces generator pattern
{
Class javaClass = getPackageClass(factoryClass, packageName);
Field field = javaClass.getField("eINSTANCE");
EPackageImpl pkg = (EPackageImpl)field.get(null);
EPackage.Registry.INSTANCE.put(pkg.getNsURI(), pkg);
}
catch (Exception e2)
{
try // this case handles the default (was -noEMF) generator pattern
{
Field field = factoryClass.getField("INSTANCE");
EPackageImpl pkg = (EPackageImpl)field.get(null);
EPackage.Registry.INSTANCE.put(pkg.getNsURI(), pkg);
// TODO -- decide if we should block global initialization of Factories with the new register method.
}
catch (Exception e3)
{
e3.printStackTrace();