2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
41
package org.netbeans.modules.j2ee.api.ejbjar;
43
import org.netbeans.api.project.Project;
44
import org.netbeans.modules.j2ee.ejbjar.CarAccessor;
45
import org.netbeans.modules.j2ee.spi.ejbjar.CarImplementation;
46
import org.netbeans.modules.j2ee.spi.ejbjar.CarProvider;
47
import org.netbeans.modules.j2ee.spi.ejbjar.CarsInProject;
48
import org.openide.filesystems.FileObject;
49
import org.openide.util.Lookup;
52
* Car should be used to access properties of an Enterprise application client module.
54
* A client may obtain a Car instance using
55
* <code>Car.getCar(fileObject)</code> static method, for any
56
* FileObject in the application client module directory structure.
58
* <div class="nonnormative">
59
* Note that the particular directory structure for application client module
60
* is not guaranteed by this API.
65
* @author Lukas Jungmann
67
public final class Car {
68
private CarImplementation impl;
69
private static final Lookup.Result<CarProvider> implementations =
70
Lookup.getDefault().lookup(new Lookup.Template<CarProvider>(CarProvider.class));
73
CarAccessor.DEFAULT = new CarAccessor() {
74
public Car createCar(CarImplementation spiEjbJar) {
75
return new Car(spiEjbJar);
78
public CarImplementation getCarImplementation(Car wm) {
79
return wm == null ? null : wm.impl;
84
private Car (CarImplementation impl) {
86
throw new IllegalArgumentException ();
91
* Find the Car for given file or null if the file does not belong
92
* to any application client module.
94
public static Car getCar (FileObject f) {
96
throw new NullPointerException("Passed null to Car.getCar(FileObject)"); // NOI18N
98
for (CarProvider impl : implementations.allInstances()) {
99
Car wm = impl.findCar (f);
107
/** Find Car(s) for all application clients within a given project.
108
* @return an array of Car instance (empty array if no instance are found).
110
public static Car[] getCars (Project project) {
111
CarsInProject providers = project.getLookup().lookup(CarsInProject.class);
112
if (providers != null) {
113
Car jars [] = providers.getCars();
121
/** J2EE platform version - one of the constants
122
* defined in {@link org.netbeans.modules.j2ee.api.common.J2eeProjectConstants}.
123
* @return J2EE platform version
125
public String getJ2eePlatformVersion () {
126
return impl.getJ2eePlatformVersion();
129
/** Deployment descriptor (application-client.xml file) of the application client module.
131
public FileObject getDeploymentDescriptor () {
132
return impl.getDeploymentDescriptor();
135
/** Source roots associated with the Car module.
136
* <div class="nonnormative">
137
* Note that not all the java source roots in the project (e.g. in a freeform project)
138
* belong to the Car module.
141
public FileObject[] getJavaSources() {
142
return impl.getJavaSources();
147
public FileObject getMetaInf() {
148
return impl.getMetaInf();