You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2008/05/09 17:59:02 UTC

svn commit: r654863 - /felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryAdminImpl.java

Author: rickhall
Date: Fri May  9 08:59:02 2008
New Revision: 654863

URL: http://svn.apache.org/viewvc?rev=654863&view=rev
Log:
Move repository URL list initialization later to avoid added the default
repository URL if it is not desired. (FELIX-485)

Modified:
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryAdminImpl.java

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryAdminImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryAdminImpl.java?rev=654863&r1=654862&r2=654863&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryAdminImpl.java (original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryAdminImpl.java Fri May  9 08:59:02 2008
@@ -43,40 +43,6 @@
     public RepositoryAdminImpl(BundleContext context)
     {
         m_context = context;
-
-        // Get repository URLs.
-        String urlStr = m_context.getProperty(REPOSITORY_URL_PROP);
-        if (urlStr != null)
-        {
-            StringTokenizer st = new StringTokenizer(urlStr);
-            if (st.countTokens() > 0)
-            {
-                while (st.hasMoreTokens())
-                {
-                    try
-                    {
-                        m_urlList.add(new URL(st.nextToken()));
-                    }
-                    catch (MalformedURLException ex)
-                    {
-                        System.err.println("RepositoryAdminImpl: " + ex);
-                    }
-                }
-            }
-        }
-
-        // Use the default URL if none were specified.
-        if (m_urlList.size() == 0)
-        {
-            try
-            {
-                m_urlList.add(new URL(DEFAULT_REPOSITORY_URL));
-            }
-            catch (MalformedURLException ex)
-            {
-                System.err.println("RepositoryAdminImpl: " + ex);
-            }
-        }
     }
 
     public synchronized Repository addRepository(URL url) throws Exception
@@ -121,7 +87,6 @@
         {
             initialize();
         }
-
         return new ResolverImpl(m_context, this);
     }
 
@@ -168,6 +133,45 @@
     private void initialize()
     {
         m_initialized = true;
+
+        // Initialize the repository URL list if it is currently empty.
+        if (m_urlList.size() == 0)
+        {
+            // First check the repository URL config property.
+            String urlStr = m_context.getProperty(REPOSITORY_URL_PROP);
+            if (urlStr != null)
+            {
+                StringTokenizer st = new StringTokenizer(urlStr);
+                if (st.countTokens() > 0)
+                {
+                    while (st.hasMoreTokens())
+                    {
+                        try
+                        {
+                            m_urlList.add(new URL(st.nextToken()));
+                        }
+                        catch (MalformedURLException ex)
+                        {
+                            System.err.println("RepositoryAdminImpl: " + ex);
+                        }
+                    }
+                }
+            }
+
+            // If no repository URLs are specified, then use the default one.
+            if (m_urlList.size() == 0)
+            {
+                try
+                {
+                    m_urlList.add(new URL(DEFAULT_REPOSITORY_URL));
+                }
+                catch (MalformedURLException ex)
+                {
+                    System.err.println("RepositoryAdminImpl: " + ex);
+                }
+            }
+        }
+
         m_repoMap.clear();
 
         for (int i = 0; i < m_urlList.size(); i++)