Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 8312 invoked from network); 10 Jul 2008 12:25:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Jul 2008 12:25:29 -0000 Received: (qmail 71734 invoked by uid 500); 10 Jul 2008 12:25:30 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 71703 invoked by uid 500); 10 Jul 2008 12:25:30 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 71692 invoked by uid 99); 10 Jul 2008 12:25:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jul 2008 05:25:30 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jul 2008 12:24:46 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1D3872388A11; Thu, 10 Jul 2008 05:25:09 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r675545 - /directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioConnectionJob.java Date: Thu, 10 Jul 2008 12:25:08 -0000 To: commits@directory.apache.org From: seelmann@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080710122509.1D3872388A11@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: seelmann Date: Thu Jul 10 05:25:08 2008 New Revision: 675545 URL: http://svn.apache.org/viewvc?rev=675545&view=rev Log: Fixed code if a job should be scheduled Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioConnectionJob.java Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioConnectionJob.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioConnectionJob.java?rev=675545&r1=675544&r2=675545&view=diff ============================================================================== --- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioConnectionJob.java (original) +++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioConnectionJob.java Thu Jul 10 05:25:08 2008 @@ -215,48 +215,41 @@ /** - * @see org.eclipse.core.runtime.jobs.Job#shouldSchedule() + * {@inheritDoc} */ public boolean shouldSchedule() { + // We don't schedule a job if the same type of runnable should run + // that works on the same entry as the current runnable. + Object[] myLockedObjects = runnable.getLockedObjects(); String[] myLockedObjectsIdentifiers = getLockIdentifiers( myLockedObjects ); - // TODO: read, write - Job[] jobs = getJobManager().find( null ); for ( int i = 0; i < jobs.length; i++ ) { Job job = jobs[i]; - - // if(job instanceof AbstractEclipseJob) { - if ( job.getClass() == this.getClass() && job != this ) + if ( job instanceof StudioConnectionJob ) { StudioConnectionJob otherJob = ( StudioConnectionJob ) job; - Object[] otherLockedObjects = otherJob.runnable.getLockedObjects(); - String[] otherLockedObjectIdentifiers = getLockIdentifiers( otherLockedObjects ); - - for ( int j = 0; j < otherLockedObjectIdentifiers.length; j++ ) + if ( this.runnable.getClass() == otherJob.runnable.getClass() && this.runnable != otherJob.runnable ) { - String other = otherLockedObjectIdentifiers[j]; - for ( int k = 0; k < myLockedObjectsIdentifiers.length; k++ ) - { - String my = myLockedObjectsIdentifiers[k]; + Object[] otherLockedObjects = otherJob.runnable.getLockedObjects(); + String[] otherLockedObjectIdentifiers = getLockIdentifiers( otherLockedObjects ); - //System.out.print( "other:" + other + ", my: " + my ); - if ( other.startsWith( my ) || my.startsWith( other ) ) - { - //System.out.println( ", shouldSchedule() = " + false ); - return false; - } - else + for ( int j = 0; j < otherLockedObjectIdentifiers.length; j++ ) + { + String other = otherLockedObjectIdentifiers[j]; + for ( int k = 0; k < myLockedObjectsIdentifiers.length; k++ ) { - //System.out.println(); + String my = myLockedObjectsIdentifiers[k]; + if ( other.startsWith( my ) || my.startsWith( other ) ) + { + return false; + } } - } } - } } return super.shouldSchedule();