add mirror url application
diff --git a/plugins/org.eclipse.wtp.releng.tools/plugin.properties b/plugins/org.eclipse.wtp.releng.tools/plugin.properties
index 8240f46..6252714 100644
--- a/plugins/org.eclipse.wtp.releng.tools/plugin.properties
+++ b/plugins/org.eclipse.wtp.releng.tools/plugin.properties
@@ -1,4 +1,3 @@
 # properties file for org.eclipse.wtp.releng.tools
-Bundle-Name.0 = Tools
-extension.name = Add Mirror URL
-extension.name.0 = %extension.name
\ No newline at end of file
+Bundle-Name.0 = Releng Tools
+application.name = Add Mirror URL
\ No newline at end of file
diff --git a/plugins/org.eclipse.wtp.releng.tools/plugin.xml b/plugins/org.eclipse.wtp.releng.tools/plugin.xml
index 5cadc5f..6503059 100644
--- a/plugins/org.eclipse.wtp.releng.tools/plugin.xml
+++ b/plugins/org.eclipse.wtp.releng.tools/plugin.xml
@@ -38,14 +38,14 @@
     </extension>
     <extension
         id="addmirrorurl"
-        name="Add Mirror URL"
+        name="%application.name"
         point="org.eclipse.core.runtime.applications">
         <application
             cardinality="singleton-global"
-            thread="main"
+            thread="any"
             visible="true">
             <run
-                class="org.eclipse.wtp.releng.tools.AddMirrorURL">
+                class="org.eclipse.wtp.releng.tools.AddMirrorURLApplication">
             </run>
 
         </application>
diff --git a/plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/AddMirrorURL.java b/plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/AddMirrorURL.java
index 7feec50..c4a14fd 100644
--- a/plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/AddMirrorURL.java
+++ b/plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/AddMirrorURL.java
@@ -4,8 +4,6 @@
 import java.net.URISyntaxException;
 
 import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.app.IApplication;
-import org.eclipse.equinox.app.IApplicationContext;
 import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepositoryFactory;
 import org.eclipse.equinox.p2.core.ProvisionException;
 import org.eclipse.equinox.p2.publisher.IPublisherAction;
@@ -14,21 +12,16 @@
 import org.eclipse.equinox.p2.publisher.PublisherInfo;
 import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
 
-public class AddMirrorURL implements IApplication {
+public class AddMirrorURL {
 
     private String repositoryDirectory;
     private String mirrorURLString;
 
-    public Object start(IApplicationContext context) throws Exception {
+    public void rewriteMirrorURL() throws ProvisionException, URISyntaxException {
         IPublisherInfo info = createPublisherInfo();
         IPublisherAction[] actions = createActions();
         Publisher publisher = new Publisher(info);
         publisher.publish(actions, new NullProgressMonitor());
-        return null;
-    }
-
-    public void stop() {
-
     }
 
     private IPublisherInfo createPublisherInfo() throws ProvisionException, URISyntaxException {
@@ -36,13 +29,13 @@
 
         String repoURI = "file:/" + getRepositoryDirectory();
         SimpleArtifactRepositoryFactory simpleArtifactRepositoryFactory = new SimpleArtifactRepositoryFactory();
-        // at least from workspace, NPE is thrown during "reload" first time
-        // ran ... even though it works correctly?
+        // at least from workspace, NPE is thrown during "reload" if the
+        // property is indeed changed (different from what it was)
         IArtifactRepository artifactRepository = simpleArtifactRepositoryFactory.load(new URI(repoURI), 0, null);
         if (artifactRepository != null) {
             artifactRepository.setProperty("p2.mirrorURL", getMirrorURLString());
             result.setArtifactRepository(artifactRepository);
-            result.setArtifactOptions(IPublisherInfo.A_PUBLISH | IPublisherInfo.A_INDEX);
+            result.setArtifactOptions(IPublisherInfo.A_OVERWRITE);
         }
         return result;
     }
diff --git a/plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/AddMirrorURLApplication.java b/plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/AddMirrorURLApplication.java
new file mode 100644
index 0000000..7910c9d
--- /dev/null
+++ b/plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/AddMirrorURLApplication.java
@@ -0,0 +1,30 @@
+package org.eclipse.wtp.releng.tools;
+
+import java.net.URISyntaxException;
+
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+import org.eclipse.equinox.p2.core.ProvisionException;
+
+public class AddMirrorURLApplication implements IApplication {
+
+    public Object start(IApplicationContext context) throws Exception {
+        Object result = null;
+        try {
+            new AddMirrorURL().rewriteMirrorURL();
+            result = IApplication.EXIT_OK;
+        }
+        catch (ProvisionException e) {
+            result = e.getMessage();
+        }
+        catch (URISyntaxException e) {
+            result = e.getMessage();
+        }
+        return result;
+    }
+
+    public void stop() {
+
+    }
+
+}