Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 84cf995d980d5a3468de6ad9d4c0a9c101b0f7a6 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*******************************************************************************
 * Copyright (c) 2012, 2013 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.jpa.core.internal;

import org.eclipse.core.resources.IWorkspace;
import org.eclipse.jpt.common.core.JptWorkspace;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.jpa.core.JpaWorkspace;
import org.eclipse.jpt.jpa.core.internal.platform.InternalJpaPlatformManager;
import org.eclipse.jpt.jpa.db.ConnectionProfileFactory;

public class InternalJpaWorkspace
	implements JpaWorkspace
{
	private final IWorkspace workspace;

	private final JptWorkspace jptWorkspace;
	private final InternalJpaPlatformManager jpaPlatformManager;
	private final InternalJpaProjectManager jpaProjectManager;
	private final ConnectionProfileFactory connectionProfileFactory;


	/**
	 * Internal: Called <em>only</em> by the
	 * {@link org.eclipse.jpt.jpa.core.internal.plugin.JptJpaCorePlugin#buildJpaWorkspace(IWorkspace)
	 * Dali JPA plug-in}.
	 */
	public InternalJpaWorkspace(IWorkspace workspace) {
		super();
		this.workspace = workspace;
		this.jptWorkspace = this.buildJptWorkspace();
		this.jpaPlatformManager = this.buildJpaPlatformManager();
		this.jpaProjectManager = this.buildJpaProjectManager();
		this.connectionProfileFactory = this.buildConnectionProfileFactory();
	}


	// ********** Dali workspace **********

	public JptWorkspace getJptWorkspace() {
		return this.jptWorkspace;
	}

	private JptWorkspace buildJptWorkspace() {
		return (JptWorkspace) this.workspace.getAdapter(JptWorkspace.class);
	}


	// ********** JPA platform manager **********

	public InternalJpaPlatformManager getJpaPlatformManager() {
		return this.jpaPlatformManager;
	}

	private InternalJpaPlatformManager buildJpaPlatformManager() {
		return new InternalJpaPlatformManager(this);
	}


	// ********** JPA project manager **********

	public InternalJpaProjectManager getJpaProjectManager() {
		return this.jpaProjectManager;
	}

	private InternalJpaProjectManager buildJpaProjectManager() {
		return new InternalJpaProjectManager(this);
	}


	// ********** connection profile factory **********

	public ConnectionProfileFactory getConnectionProfileFactory() {
		return this.connectionProfileFactory;
	}

	private ConnectionProfileFactory buildConnectionProfileFactory() {
		return (ConnectionProfileFactory) this.workspace.getAdapter(ConnectionProfileFactory.class);
	}


	// ********** misc **********

	public IWorkspace getWorkspace() {
		return this.workspace;
	}

	/**
	 * Internal: Called <em>only</em> by the
	 * {@link JpaPreferenceInitializer#initializeDefaultPreferences()
	 * JPA preferences initializer}.
	 */
	void initializeDefaultPreferences() {
		this.getJpaPlatformManager().initializeDefaultPreferences();
	}

	/**
	 * Internal: Called <em>only</em> by the
	 * {@link org.eclipse.jpt.jpa.core.internal.plugin.JptJpaCorePlugin#stop(org.osgi.framework.BundleContext)
	 * Dali plug-in}.
	 * <p>
	 * This will suspend the current thread until all the JPA projects are
	 * disposed etc.
	 */
	public void dispose() {
		this.jpaProjectManager.dispose();
	}

	@Override
	public String toString() {
		return ObjectTools.toString(this, this.workspace);
	}
}

Back to the top