Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349456 - Remove type from extension point for custom controls
Summary: Remove type from extension point for custom controls
Status: CLOSED FIXED
Alias: None
Product: ECP
Classification: Modeling
Component: Common (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 0.8.9   Edit
Assignee: Jonas Helming CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-15 11:10 EDT by Harald Stangl CLA
Modified: 2012-01-23 17:15 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Stangl CLA 2011-06-15 11:10:32 EDT
The extension point for custom controls should not allow to define a type, as setting this to a custom type leads to a ClassNotFoundException. Type checking can be made in the "canRender" implementation.
Comment 1 Nikolay Kasyanov CLA 2011-09-14 07:41:44 EDT
Or, ECP can load class by name using more complicated way than Class.forName, which doesn't work, because Editor plugin doesn't import user plugins (packages), so It can't "see" class.
Comment 2 Jonas Helming CLA 2011-09-14 07:44:46 EDT
that is correct, the type should be removed
Comment 3 Jonas Helming CLA 2011-09-14 14:32:24 EDT
fixed in master
Comment 4 Jonas Helming CLA 2011-09-14 14:32:41 EDT
what would be this "more complicated way"
Comment 5 Nikolay Kasyanov CLA 2011-09-14 15:27:18 EDT
something like this:
Bundle b = Activator.getDefault().getBundle();

ServiceReference<PackageAdmin> sr = b.getBundleContext().getServiceReference(PackageAdmin.class);
PackageAdmin pa = b.getBundleContext().getService(sr);

String typeName = e.getAttribute("type");
String packageName = forClass.substring(0, forClass.lastIndexOf("."));
ExportedPackage pkg = pa.getExportedPackage(packageName);
Bundle neededBundle = pkg.getExportingBundle();
Class<?> cls = neededBundle.loadClass(typeName);

I'm not OSGi expert, maybe there is more right way to load class from bundle (because PackageAdmin service is obsolete in OSGi), about which ecp editor bundle doesn't know.
Comment 6 Jonas Helming CLA 2011-09-15 04:13:21 EDT
Thanks for this hint, that looks interesting. I actually thought it trough. The only reason to offer the type attribute is to allow a filtering of widgets in a declaritive way. We have another filter mechnism in the canrender method. I do not think this is really performance critical, so it might also be sufficient to just remove the type attribute. This makes the API simpler. What do you think?