[JBoss OSGi Development] - Handling of Bundle-ClassPath
by thomas.diesler@jboss.com
The Bundle-ClassPath is now handles in OSGiClassLoaderFactory like this
| public ClassLoaderPolicy createClassLoaderPolicy()
| {
| VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
| OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
| VirtualFile[] roots = getClassLoaderPolicyRoots(bundleState, vfsUnit);
| return new OSGiClassLoaderPolicy(bundleState, roots);
| }
|
| private VirtualFile[] getClassLoaderPolicyRoots(OSGiBundleState bundleState, VFSDeploymentUnit vfsUnit)
| {
| VirtualFile root = vfsUnit.getRoot();
|
| // If there is no Bundle-ClassPath in the manifest, simply use the root
| List<String> bundleClassPath = bundleState.getOSGiMetaData().getBundleClassPath();
| if (bundleClassPath == null)
| {
| return new VirtualFile[] { root };
| }
|
| log.debug("Bundle-ClassPath: " + bundleClassPath);
|
| // Add a vfs root for every Bundle-ClassPath element
| List<VirtualFile> rootsList = new ArrayList<VirtualFile>();
| for (String path : bundleClassPath)
| {
| if (path.equals("."))
| {
| rootsList.add(root);
| }
| else
| {
| try
| {
| VirtualFile child = root.getChild(path);
| rootsList.add(child);
| }
| catch (IOException ex)
| {
| throw new IllegalArgumentException("Cannot find class path '" + path + "' in: " + root);
| }
| }
| }
|
| VirtualFile[] rootsArray = new VirtualFile[rootsList.size()];
| rootsList.toArray(rootsArray);
|
| return rootsArray;
| }
|
Note, I create a policy root entry for every bundle class path token.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4259229#4259229
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4259229