Skip to main content
summaryrefslogtreecommitdiffstats
blob: 131586a743c514b9811c4de788c85a2fdb6d3837 (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
/*******************************************************************************
 *  Copyright (c) 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.context.persistence;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.core.resource.persistence.XmlJarFileRef;

/**
 * Context JAR file reference (from the persistence unit)
 */
public class GenericJarFileRef 
	extends AbstractJarFileRef
{
	// **************** construction/initialization ****************************
	
	public GenericJarFileRef(PersistenceUnit parent, XmlJarFileRef xmlJarFileRef) {
		super(parent, xmlJarFileRef);
	}
	
	
	// **************** overrides **********************************************
	
	@Override
	protected IPath[] resolveDeploymentJarFilePath(IPath jarFilePath) {
		IProject project = getJpaProject().getProject();
		IPath rootPath = JptCorePlugin.getJarDeploymentRootPath(project);
		
		if (JptCorePlugin.projectHasWebFacet(project)) {
			return new IPath[] {
				// first path assumes form "../lib/other.jar"
				rootPath.append(jarFilePath.removeFirstSegments(1)),
				// second path assumes form of first, without ".." ("lib/other.jar")
				rootPath.append(jarFilePath)
			};
		}
		else {
			return new IPath[] {
				rootPath.append(jarFilePath)
			};
		}
	}
}

Back to the top