GEF,EMF,RCP,Eclipse"s plugin的几个问题(1) PackageNotFound Exception
GEF,EMF,RCP,Eclipse"s plugin的几个问题(1) PackageNotFound Exception Exception :
PackageNotFound
Reasons :
EMF package 没有注册,
Solution :
需要在配置文件中增加类似代码:
<extension point='org.eclipse.emf.ecore.generated_package'>
<package
uri = 'http:///com/companyname/projectname/modulename/model.ecore'
class = 'com.companyname.projectname.modulename.model.ModelPackage' />
</extension>
如果是在其它的部分调用EMF代码,可以在resource.load之前增加类似代码:
//-->
ModelPackage modelInstance = ModelPackage.eINSTANCE;
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map m = reg.getExtensionToFactoryMap();
m.put('*', new XMIResourceFactoryImpl());
ResourceSet rsSet = new ResourceSetImpl();
rsSet.setResourceFactoryRegistry(reg);
//<--
...
resource.load
load model