KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbjar > CustomProviderCar


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.ejbjar;
21
22 import java.util.HashMap JavaDoc;
23 import org.netbeans.modules.j2ee.api.ejbjar.*;
24 import org.netbeans.modules.j2ee.spi.ejbjar.*;
25 import org.openide.filesystems.FileObject;
26
27 /** A dummy provider that things that any *.bar file belongs to its car module.
28  *
29  * @author Pavel Buzek
30  * @author Lukas Jungmann
31  */

32 public class CustomProviderCar implements CarProvider {
33     
34    private HashMap JavaDoc cache = new HashMap JavaDoc ();
35     
36     public CustomProviderCar () {
37     }
38     
39     public Car findCar (FileObject file) {
40         if (file.getExt ().equals ("bar")) {
41             Car em = (Car) cache.get (file.getParent ());
42             if (em == null) {
43                 em = CarFactory.createCar (new EM (file.getParent (), EjbProjectConstants.J2EE_14_LEVEL));
44                 cache.put (file.getParent (), em);
45             }
46             return em;
47         }
48         return null;
49     }
50     
51     private class EM implements CarImplementation {
52         FileObject root;
53         String JavaDoc ver;
54         
55         public EM (FileObject root, String JavaDoc ver) {
56             this.root = root;
57             this.ver = ver;
58         }
59         
60         public String JavaDoc getJ2eePlatformVersion () {
61             return ver;
62         }
63         
64         public FileObject getDeploymentDescriptor () {
65             return root.getFileObject ("conf/application-client.xml");
66         }
67         
68         public FileObject getMetaInf () {
69             return null;
70         }
71
72         public FileObject[] getJavaSources() {
73             return null;
74         }
75     }
76 }
77
Popular Tags