KickJava   Java API By Example, From Geeks To Geeks.

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


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.Car;
24 import org.netbeans.modules.j2ee.api.ejbjar.Ear;
25 import org.netbeans.modules.j2ee.api.ejbjar.EjbJar;
26 import org.netbeans.modules.j2ee.api.ejbjar.EjbProjectConstants;
27 import org.netbeans.modules.j2ee.spi.ejbjar.CarFactory;
28 import org.netbeans.modules.j2ee.spi.ejbjar.EarImplementation;
29 import org.netbeans.modules.j2ee.spi.ejbjar.EarProvider;
30 import org.netbeans.modules.j2ee.spi.ejbjar.EjbJarFactory;
31 import org.openide.filesystems.FileObject;
32 import org.netbeans.modules.web.api.webmodule.WebModule;
33
34 /** A dummy provider that things that any *.foo file belongs to its web module.
35  *
36  * @author Pavel Buzek
37  */

38 public class CustomProviderEar implements EarProvider {
39
40     private HashMap JavaDoc cache = new HashMap JavaDoc ();
41
42     public CustomProviderEar () {
43     }
44
45     public Ear findEar (FileObject file) {
46         if (file.getExt ().equals ("foo")) {
47             Ear em = (Ear) cache.get (file.getParent ());
48             if (em == null) {
49                 em = EjbJarFactory.createEar (new EM (file.getParent (), EjbProjectConstants.J2EE_14_LEVEL));
50                 cache.put (file.getParent (), em);
51             }
52             return em;
53         }
54         if (file.getExt ().equals ("bar")) {
55             Ear em = (Ear) cache.get (file.getParent ());
56             if (em == null) {
57                 em = CarFactory.createEar (new EM (file.getParent (), EjbProjectConstants.J2EE_14_LEVEL));
58                 cache.put (file.getParent (), em);
59             }
60             return em;
61         }
62         return null;
63     }
64     
65     private class EM implements EarImplementation {
66         FileObject root;
67         String JavaDoc ver;
68         
69         public EM (FileObject root, String JavaDoc ver) {
70             this.root = root;
71             this.ver = ver;
72         }
73         
74         public String JavaDoc getJ2eePlatformVersion () {
75             return ver;
76         }
77         
78         public FileObject getDeploymentDescriptor () {
79             return root.getFileObject ("conf/application.xml");
80         }
81         
82         public FileObject getMetaInf () {
83             return null;
84         }
85         
86         public void addEjbJarModule(EjbJar module) {
87             
88         }
89         public void addWebModule(WebModule module) {
90             
91         }
92         public void addCarModule(Car module) {
93             
94         }
95     }
96 }
97
Popular Tags