[jboss-cvs] JBossAS SVN: r99951 - in projects/jboss-osgi/projects/runtime/framework/trunk: src/main/java/org/jboss/osgi/framework/classloading and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 26 12:24:26 EST 2010
Author: thomas.diesler at jboss.com
Date: 2010-01-26 12:24:26 -0500 (Tue, 26 Jan 2010)
New Revision: 99951
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java
Log:
Remove fragment support in VFSClassLoaderPolicy
Promote VirtualFileInfo to top level
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-01-26 17:12:25 UTC (rev 99950)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-01-26 17:24:26 UTC (rev 99951)
@@ -47,7 +47,7 @@
<version.apache.felix.log>1.0.0</version.apache.felix.log>
<version.apache.felix.metatype>1.0.2</version.apache.felix.metatype>
<version.drools>5.0.1</version.drools>
- <version.jboss.classloading>2.0.9-SNAPSHOT</version.jboss.classloading>
+ <version.jboss.classloading>2.2.0-SNAPSHOT</version.jboss.classloading>
<version.jboss.deployers>2.2.0.Alpha1</version.jboss.deployers>
<version.jboss.kernel>2.2.0.Alpha2</version.jboss.kernel>
<version.jboss.osgi.apache.xerces>2.9.1.SP3</version.jboss.osgi.apache.xerces>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2010-01-26 17:12:25 UTC (rev 99950)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2010-01-26 17:24:26 UTC (rev 99951)
@@ -29,11 +29,14 @@
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.classloader.spi.NativeLibraryProvider;
import org.jboss.classloading.spi.dependency.Module;
import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy;
+import org.jboss.classloading.spi.vfs.policy.VirtualFileInfo;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
@@ -53,6 +56,9 @@
*/
public class OSGiClassLoaderPolicy extends VFSClassLoaderPolicy
{
+ /** The fragment roots */
+ private List<VirtualFile> fragments;
+
public OSGiClassLoaderPolicy(AbstractBundleState absBundleState, VirtualFile[] roots)
{
super(roots);
@@ -127,6 +133,76 @@
}
/**
+ * Attach a new fragment root to the policy.
+ * @param fragRoot The fragment root file
+ */
+ public void attachFragment(VirtualFile fragRoot)
+ {
+ if (fragRoot == null)
+ throw new IllegalArgumentException("Null fragment file");
+
+ if (fragments == null)
+ fragments = new CopyOnWriteArrayList<VirtualFile>();
+
+ fragments.add(fragRoot);
+ }
+
+ /**
+ * Detach a fragment root from the policy.
+ * @param fragRoot The fragment root file
+ * @return true if the fragment could be detached
+ */
+ public boolean detachFragment(VirtualFile fragRoot)
+ {
+ if (fragRoot == null)
+ throw new IllegalArgumentException("Null fragment file");
+
+ if (fragments == null)
+ return false;
+
+ return fragments.remove(fragRoot);
+ }
+
+ /**
+ * Get the array of attached fragment root files.
+ * @return The array of attached fragment root files or null.
+ */
+ public VirtualFile[] getFragmentRoots()
+ {
+ if (fragments == null)
+ return null;
+
+ VirtualFile[] retarr = new VirtualFile[fragments.size()];
+ fragments.toArray(retarr);
+ return retarr;
+ }
+
+ @Override
+ protected VirtualFileInfo findVirtualFileInfo(String path)
+ {
+ VirtualFileInfo result = super.findVirtualFileInfo(path);
+ if (result == null && fragments != null)
+ {
+ for (VirtualFile root : fragments)
+ {
+ try
+ {
+ VirtualFile file = root.getChild(path);
+ if (file != null)
+ {
+ result = new VirtualFileInfo(file, root);
+ return result;
+ }
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
* An implementation of NativeLibraryProvider that provides the native library file
* location from the bundle that contains the library.
*/
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java 2010-01-26 17:12:25 UTC (rev 99950)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java 2010-01-26 17:24:26 UTC (rev 99951)
@@ -25,7 +25,6 @@
import org.jboss.classloader.spi.ClassLoaderPolicy;
import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
@@ -34,6 +33,7 @@
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.osgi.framework.bundle.OSGiFragmentState;
+import org.jboss.osgi.framework.classloading.OSGiClassLoaderPolicy;
import org.osgi.framework.Bundle;
/**
@@ -89,7 +89,7 @@
OSGiFragmentState fragState = (OSGiFragmentState)absBundleState;
OSGiBundleState hostState = fragState.getFragmentHost();
DeploymentUnit hostUnit = hostState.getDeploymentUnit();
- VFSClassLoaderPolicy hostPolicy = (VFSClassLoaderPolicy)hostUnit.getAttachment(ClassLoaderPolicy.class);
+ OSGiClassLoaderPolicy hostPolicy = (OSGiClassLoaderPolicy)hostUnit.getAttachment(ClassLoaderPolicy.class);
hostPolicy.attachFragment(fragState.getRoot());
}
}
More information about the jboss-cvs-commits
mailing list