ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r991872 - in /ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer: IvyProgressMonitor.java IvyResolveJob.java
Date Thu, 02 Sep 2010 09:23:09 GMT
Author: hibou
Date: Thu Sep  2 09:23:09 2010
New Revision: 991872

URL: http://svn.apache.org/viewvc?rev=991872&view=rev
Log:
extract the monitoring of Ivy work in porgress

Added:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyProgressMonitor.java
  (with props)
Modified:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java

Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyProgressMonitor.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyProgressMonitor.java?rev=991872&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyProgressMonitor.java
(added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyProgressMonitor.java
Thu Sep  2 09:23:09 2010
@@ -0,0 +1,57 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivyde.eclipse.cpcontainer;
+
+import org.apache.ivy.Ivy;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class IvyProgressMonitor {
+
+    private static final int WAIT_FOR_JOIN = 100;
+
+    /**
+     * Wait for the Ivy work to finish, or try to interrupt it if requested by the end user
via the
+     * progress monitor
+     * 
+     * @param ivy
+     *            the ivy to monitor
+     * @param monitor
+     *            the monitor coming from the end user
+     * @param resolverThread
+     *            the thread doing the Ivy work
+     * @return <code>true</code> if the work has been interrupted
+     */
+    public boolean wait(Ivy ivy, IProgressMonitor monitor, Thread resolverThread) {
+        while (true) {
+            try {
+                resolverThread.join(WAIT_FOR_JOIN);
+            } catch (InterruptedException e) {
+                ivy.interrupt(resolverThread);
+                return true;
+            }
+            if (!resolverThread.isAlive()) {
+                return false;
+            }
+            if (monitor != null && monitor.isCanceled()) {
+                ivy.interrupt(resolverThread);
+                return true;
+            }
+        }
+    }
+
+}

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyProgressMonitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyProgressMonitor.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyProgressMonitor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java?rev=991872&r1=991871&r2=991872&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
Thu Sep  2 09:23:09 2010
@@ -46,8 +46,6 @@ import org.eclipse.core.runtime.jobs.Job
  */
 public class IvyResolveJob extends Job {
 
-    private static final int WAIT_FOR_JOIN = 100;
-
     private final List resolveQueue = new ArrayList();
 
     public IvyResolveJob() {
@@ -217,21 +215,12 @@ public class IvyResolveJob extends Job {
         resolverThread.setName("IvyDE resolver thread");
 
         resolverThread.start();
-        while (true) {
-            try {
-                resolverThread.join(WAIT_FOR_JOIN);
-            } catch (InterruptedException e) {
-                ivy.interrupt(resolverThread);
-                return Status.CANCEL_STATUS;
-            }
-            if (status[0] != null || !resolverThread.isAlive()) {
-                break;
-            }
-            if (monitor.isCanceled()) {
-                ivy.interrupt(resolverThread);
-                return Status.CANCEL_STATUS;
-            }
+
+        IvyProgressMonitor ivyProgressMonitor = new IvyProgressMonitor();
+        if (ivyProgressMonitor.wait(ivy, monitor, resolverThread)) {
+            return Status.CANCEL_STATUS;
         }
+
         if (status[0] == Status.OK_STATUS) {
             request.getContainer().updateClasspathEntries(resolver.getClasspathEntries());
         }



Mime
View raw message