geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1308406 - in /geronimo/server/branches/3.0-beta: framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/ framework/modules/geronimo-ker...
Date Mon, 02 Apr 2012 15:58:26 GMT
Author: xuhaihong
Date: Mon Apr  2 15:58:25 2012
New Revision: 1308406

URL: http://svn.apache.org/viewvc?rev=1308406&view=rev
Log:
GERONIMO-6313 Use the same reference:file format

Modified:
    geronimo/server/branches/3.0-beta/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
    geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/DependencyManager.java
    geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/Configuration.java
    geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
    geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/BundleUtil.java
    geronimo/server/branches/3.0-beta/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/Bootstrapper.java
    geronimo/server/branches/3.0-beta/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java
    geronimo/server/branches/3.0-beta/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java
    geronimo/server/branches/3.0-beta/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/GeronimoApplication.java
    geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java

Modified: geronimo/server/branches/3.0-beta/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java?rev=1308406&r1=1308405&r2=1308406&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
(original)
+++ geronimo/server/branches/3.0-beta/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
Mon Apr  2 15:58:25 2012
@@ -68,6 +68,7 @@ import org.apache.geronimo.kernel.reposi
 import org.apache.geronimo.kernel.repository.Dependency;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.kernel.util.BundleUtil;
 import org.apache.geronimo.system.plugin.model.ArtifactType;
 import org.apache.geronimo.system.plugin.model.DependencyType;
 import org.apache.geronimo.system.plugin.model.PluginArtifactType;
@@ -198,7 +199,7 @@ public class DeploymentContext {
             ConfigurationData configurationData = new ConfigurationData(moduleType, null,
childConfigurationDatas, environment, baseDir, inPlaceConfigurationDir, naming);
             createTempManifest();
             createPluginMetadata();
-            String location = "reference:" + getConfigurationDir().toURI().toURL();
+            String location = BundleUtil.toReferenceFileLocation(getConfigurationDir());
             tempBundle = bundleContext.installBundle(location);
             if (BundleUtils.canStart(tempBundle)) {
                 tempBundle.start(Bundle.START_TRANSIENT);

Modified: geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/DependencyManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/DependencyManager.java?rev=1308406&r1=1308405&r2=1308406&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/DependencyManager.java
(original)
+++ geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/DependencyManager.java
Mon Apr  2 15:58:25 2012
@@ -17,10 +17,10 @@
 
 package org.apache.geronimo.kernel;
 
-import org.apache.geronimo.gbean.AbstractName;
-
 import java.util.Set;
 
+import org.apache.geronimo.gbean.AbstractName;
+
 /**
  * DependencyManager is the record keeper of the dependencies in Geronimo.  The DependencyManager
  * does not enforce any dependencies, it is simply a place where components can register
their intent
@@ -66,7 +66,7 @@ public interface DependencyManager {
      * @param child the dependent component
      * @param parents the set of components the child is depending on
      */
-    public void addDependencies(AbstractName child, Set parents);
+    public void addDependencies(AbstractName child, Set<AbstractName> parents);
 
     /**
      * Gets the set of parents that the child is depending on
@@ -74,7 +74,7 @@ public interface DependencyManager {
      * @param child the dependent component
      * @return a collection containing all of the components the child depends on; will never
be null
      */
-    public Set getParents(AbstractName child);
+    public Set<AbstractName> getParents(AbstractName child);
 
     /**
      * Gets all of the MBeans that have a dependency on the specified startParent.
@@ -82,6 +82,6 @@ public interface DependencyManager {
      * @param parent the component the returned childen set depend on
      * @return a collection containing all of the components that depend on the parent; will
never be null
      */
-    public Set getChildren(AbstractName parent);
+    public Set<AbstractName> getChildren(AbstractName parent);
 
 }

Modified: geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/Configuration.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/Configuration.java?rev=1308406&r1=1308405&r2=1308406&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/Configuration.java
(original)
+++ geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/Configuration.java
Mon Apr  2 15:58:25 2012
@@ -18,6 +18,7 @@
 package org.apache.geronimo.kernel.config;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -44,6 +45,7 @@ import org.apache.geronimo.kernel.Naming
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.repository.MissingDependencyException;
+import org.apache.geronimo.kernel.util.BundleUtil;
 import org.apache.xbean.osgi.bundle.util.DelegatingBundle;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -274,16 +276,18 @@ public class Configuration implements GB
         }
         try {
             File file = configurationResolver.resolve(configurationId);
-            return "reference:file://" + file.getAbsolutePath();
+            return BundleUtil.toReferenceFileLocation(file);
         } catch (MissingDependencyException e) {
             return null;
+        } catch (IOException e) {
+            return null;
         }
     }
     
     private static Bundle getBundleByLocation(BundleContext bundleContext, String location)
{
         for (Bundle bundle: bundleContext.getBundles()) {
             if (location.equals(bundle.getLocation())) {
-               return bundle;
+                return bundle;               
             }
         }
         return null;

Modified: geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java?rev=1308406&r1=1308405&r2=1308406&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
(original)
+++ geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
Mon Apr  2 15:58:25 2012
@@ -42,6 +42,7 @@ import org.apache.geronimo.kernel.reposi
 import org.apache.geronimo.kernel.repository.MissingDependencyException;
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.kernel.repository.Version;
+import org.apache.geronimo.kernel.util.BundleUtil;
 import org.apache.xbean.osgi.bundle.util.BundleUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -624,7 +625,7 @@ public class SimpleConfigurationManager 
         monitor.reading(configurationId);
         for (Repository repo : repositories) {
             if (repo.contains(configurationId)) {
-                return "reference:file://" + repo.getLocation(configurationId).getAbsolutePath();
+                return BundleUtil.toReferenceFileLocation(repo.getLocation(configurationId));
             }
         }
         NoSuchConfigException exception = new NoSuchConfigException(configurationId);

Modified: geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/BundleUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/BundleUtil.java?rev=1308406&r1=1308405&r2=1308406&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/BundleUtil.java
(original)
+++ geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/BundleUtil.java
Mon Apr  2 15:58:25 2012
@@ -35,7 +35,11 @@ public class BundleUtil {
 
     public final static String EBA_GROUP_ID = "application";
 
-    public final static String REFERENCE_FILE_PREFIX = "reference:file://";
+    public final static String REFERENCE_SCHEME = "reference:";
+    
+    public final static String FILE_SCHEMA = "file:";
+    
+    public final static String REFERENCE_FILE_SCHEMA = "reference:file:";
 
     public static String getVersion(org.osgi.framework.Version version) {
         String str = version.getMajor() + "." + version.getMinor() + "." + version.getMicro();
@@ -64,8 +68,8 @@ public class BundleUtil {
      * @return
      */
     public static File toFile(String url) {
-        if (url.startsWith(REFERENCE_FILE_PREFIX)) {
-            File file = new File(url.substring(REFERENCE_FILE_PREFIX.length()));
+        if (url.startsWith(REFERENCE_FILE_SCHEMA)) {
+            File file = new File(url.substring(REFERENCE_FILE_SCHEMA.length()));
             if (file.exists()) {
                 return file;
             }
@@ -74,6 +78,9 @@ public class BundleUtil {
     }
     
     public static String toReferenceFileLocation(File file) throws IOException {
-        return REFERENCE_FILE_PREFIX + file.getCanonicalPath();
+        if (!file.exists()) {
+            throw new IOException("file not exist " + file.getAbsolutePath());
+        }
+        return REFERENCE_SCHEME + file.toURI();
     }
 }

Modified: geronimo/server/branches/3.0-beta/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/Bootstrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/Bootstrapper.java?rev=1308406&r1=1308405&r2=1308406&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/Bootstrapper.java
(original)
+++ geronimo/server/branches/3.0-beta/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/Bootstrapper.java
Mon Apr  2 15:58:25 2012
@@ -126,7 +126,7 @@ public class Bootstrapper extends Framew
     }
     
     private String toReferenceFileLocation(File file) throws IOException {
-        return "reference:file://" + file.getCanonicalPath();
+        return "reference:" + file.toURI().toString();
     }
     
     private static File getBundleLocation(List<File> bundleDirs, String[] parts) {

Modified: geronimo/server/branches/3.0-beta/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java?rev=1308406&r1=1308405&r2=1308406&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java
(original)
+++ geronimo/server/branches/3.0-beta/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java
Mon Apr  2 15:58:25 2012
@@ -436,7 +436,7 @@ public class FrameworkLauncher {
     }
 
     private String toReferenceFileLocation(File file) throws IOException {
-        return "reference:file://" + file.getCanonicalPath();
+        return "reference:" + file.toURI().toString();
     }
 
     private static File findFile(List<File> bundleDirs, String name) {

Modified: geronimo/server/branches/3.0-beta/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java?rev=1308406&r1=1308405&r2=1308406&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java
(original)
+++ geronimo/server/branches/3.0-beta/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java
Mon Apr  2 15:58:25 2012
@@ -213,14 +213,15 @@ public class DependencyManager implement
             }
             return new Artifact(artifactFragments[0], artifactFragments[1], artifactFragments.length
> 2 ? artifactFragments[2] : "",
                     artifactFragments.length > 3 && artifactFragments[3].length()
> 0 ? artifactFragments[3] : "jar");
-        } else if(installationLocation.startsWith("reference:file://")) {
+        } else if(installationLocation.startsWith(BundleUtil.REFERENCE_SCHEME)) {
+            log.info("reference:file checking");
             //TODO a better way for this ???
-            installationLocation = installationLocation.substring("reference:file://".length());
+            String bundleFilePath = BundleUtil.toFile(installationLocation).getAbsolutePath();
           
             for (Repository repo : repositories) {
                 if (repo instanceof AbstractRepository) {
                     File rootFile = ((AbstractRepository) repo).getRootFile();
-                    if (installationLocation.startsWith(rootFile.getAbsolutePath())) {
-                        String artifactString = installationLocation.substring(rootFile.getAbsolutePath().length());
+                    if (bundleFilePath.startsWith(rootFile.getAbsolutePath())) {
+                        String artifactString = bundleFilePath.substring(rootFile.getAbsolutePath().length());
                         if (artifactString.startsWith(File.separator)) {
                             artifactString = artifactString.substring(File.separator.length());
                         }
@@ -299,6 +300,7 @@ public class DependencyManager implement
         } else {
             artifact = pluginArtifactType.getModuleId().toArtifact();
         }
+        log.info(bundle.getLocation() + " ---> " + artifact);
         if (artifact != null) {
             artifactBundleMap.put(artifact, bundle);
             bundleIdArtifactMap.put(bundle.getBundleId(), artifact);

Modified: geronimo/server/branches/3.0-beta/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/GeronimoApplication.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/GeronimoApplication.java?rev=1308406&r1=1308405&r2=1308406&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/GeronimoApplication.java
(original)
+++ geronimo/server/branches/3.0-beta/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/GeronimoApplication.java
Mon Apr  2 15:58:25 2012
@@ -117,7 +117,7 @@ public class GeronimoApplication impleme
             }
             BundleManifest bm = BundleManifest.fromBundle(file);
             if (bm != null && bm.isValid()) {
-                bundleInfo.add(new SimpleBundleInfo(applicationFactory, bm, "reference:file://"
+ file.getCanonicalPath()));
+                bundleInfo.add(new SimpleBundleInfo(applicationFactory, bm, BundleUtil.toReferenceFileLocation(file)));
             }
         }
     }

Modified: geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java?rev=1308406&r1=1308405&r2=1308406&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
(original)
+++ geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
Mon Apr  2 15:58:25 2012
@@ -514,10 +514,9 @@ public class GeronimoStandardContext ext
     }
 
     protected DirContext createDirContext(TomcatContext tomcatContext) throws DeploymentException
{
-        String location = bundle.getLocation();
-        if (location.startsWith("reference:file://")) {
-            location = location.substring("reference:file://".length());
-            File applicationRoot = tomcatContext.getModulePath() == null ? new File(location)
: new File(location + File.separator + tomcatContext.getModulePath());
+        File bundleFileRoot = BundleUtil.toFile(bundle);
+        if (bundleFileRoot != null) {
+            File applicationRoot = tomcatContext.getModulePath() == null ? bundleFileRoot
: new File(bundleFileRoot, tomcatContext.getModulePath());
             if (applicationRoot.exists() && applicationRoot.isDirectory()) {
                 return createFileDirContext(tomcatContext, applicationRoot);
             }



Mime
View raw message