Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c65b6d269e494b5073fe0c12b2d8576fe48f3809 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*******************************************************************************
 * Copyright (c) 2008, 2009 Oracle. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0, which accompanies this distribution
 * and is available at http://www.eclipse.org/legal/epl-v10.html.
 * 
 * Contributors:
 *     Oracle - initial API and implementation
 ******************************************************************************/
package org.eclipse.jpt.core.internal;

import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.utility.Command;
import org.eclipse.jpt.utility.internal.synchronizers.CallbackSynchronousSynchronizer;
import org.eclipse.jpt.utility.synchronizers.CallbackSynchronizer;

/**
 * Adapt the "callback synchronizer" interface to the JPA project "updater"
 * interface.
 * <p>
 * This updater will "update" the JPA project immediately and not return until
 * the "update" and all resulting "updates" are complete. This implementation
 * should be used sparingly and for as short a time as possible, as it increases
 * the probability of deadlocks. A deadlock can occur when a JPA project is
 * updated from multiple threads and various resources are locked in varying
 * orders.
 */
public class SynchronousJpaProjectUpdater
	extends AbstractSynchronizerJpaProjectUpdater
{
	public SynchronousJpaProjectUpdater(JpaProject jpaProject) {
		super(jpaProject);
	}

	@Override
	protected CallbackSynchronizer buildSynchronizer() {
		return new CallbackSynchronousSynchronizer(this.buildCommand());
	}

	protected Command buildCommand() {
		return new Command() {
			public void execute() {
				SynchronousJpaProjectUpdater.this.jpaProject.update(new NullProgressMonitor());
			}
		};
	}

}

Back to the top