KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbcore > test > ProjectImpl


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.ejbcore.test;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.io.File JavaDoc;
24 import java.io.IOException JavaDoc;
25 import java.util.Iterator JavaDoc;
26 import javax.swing.Icon JavaDoc;
27 import javax.swing.event.ChangeListener JavaDoc;
28 import org.netbeans.api.project.Project;
29 import org.netbeans.api.project.SourceGroup;
30 import org.netbeans.api.project.Sources;
31 import org.netbeans.api.project.ant.AntArtifact;
32 import org.netbeans.modules.j2ee.api.ejbjar.EnterpriseReferenceContainer;
33 import org.netbeans.modules.j2ee.dd.api.common.EjbLocalRef;
34 import org.netbeans.modules.j2ee.dd.api.common.EjbRef;
35 import org.netbeans.modules.j2ee.dd.api.common.MessageDestinationRef;
36 import org.netbeans.modules.j2ee.dd.api.common.ResourceRef;
37 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
38 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule.VersionListener;
39 import org.netbeans.modules.j2ee.deployment.devmodules.api.ModuleChangeReporter;
40 import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
41 import org.netbeans.modules.schema2beans.BaseBean;
42 import org.openide.filesystems.FileObject;
43 import org.openide.filesystems.FileUtil;
44 import org.openide.util.Lookup;
45 import org.openide.util.lookup.Lookups;
46
47 /**
48  *
49  * @author Martin Adamek
50  */

51 public final class ProjectImpl implements Project {
52     
53     private final Lookup lookup;
54     private FileObject projectDirectory;
55     
56     public ProjectImpl(String JavaDoc moduleVersion) {
57         lookup = Lookups.fixed(
58                 new J2eeModuleProviderImpl(moduleVersion),
59                 new SourcesImpl(),
60                 new EnterpriseReferenceContainerImpl()
61                 );
62     }
63     
64     public FileObject getProjectDirectory() {
65         return projectDirectory;
66     }
67     
68     public Lookup getLookup() {
69         return lookup;
70     }
71     
72     public void setProjectDirectory(FileObject fileObject) {
73         this.projectDirectory = fileObject;
74     }
75     
76     private class SourcesImpl implements Sources {
77         
78         public SourcesImpl() {}
79         
80         public SourceGroup[] getSourceGroups(String JavaDoc type) {
81             return new SourceGroup[] { new SourceGroupImpl() };
82         }
83         
84         public void addChangeListener(ChangeListener JavaDoc listener) {
85         }
86         
87         public void removeChangeListener(ChangeListener JavaDoc listener) {
88         }
89         
90     }
91     
92     private class SourceGroupImpl implements SourceGroup {
93         
94         public SourceGroupImpl() {}
95         
96         public FileObject getRootFolder() {
97             return projectDirectory.getFileObject("src").getFileObject("java");
98         }
99         
100         public String JavaDoc getName() {
101             return "Sources";
102         }
103         
104         public String JavaDoc getDisplayName() {
105             return "Sources";
106         }
107         
108         public Icon JavaDoc getIcon(boolean opened) {
109             return null;
110         }
111         
112         public boolean contains(FileObject file) {
113             return FileUtil.isParentOf(projectDirectory, file);
114         }
115         
116         public void addPropertyChangeListener(PropertyChangeListener JavaDoc listener) {
117         }
118         
119         public void removePropertyChangeListener(PropertyChangeListener JavaDoc listener) {
120         }
121         
122     }
123     
124     private static class J2eeModuleProviderImpl extends J2eeModuleProvider {
125         
126         private final String JavaDoc moduleVersion;
127
128         public J2eeModuleProviderImpl(String JavaDoc moduleVersion) {
129             this.moduleVersion = moduleVersion;
130         }
131         
132         public J2eeModule getJ2eeModule() {
133             return new J2eeModuleImpl(moduleVersion);
134         }
135         
136         public ModuleChangeReporter getModuleChangeReporter() {
137             return null;
138         }
139         
140         public File JavaDoc getDeploymentConfigurationFile(String JavaDoc name) {
141             return null;
142         }
143         
144         public FileObject findDeploymentConfigurationFile(String JavaDoc name) {
145             return null;
146         }
147         
148         public void setServerInstanceID(String JavaDoc severInstanceID) {
149         }
150         
151         public String JavaDoc getServerInstanceID() {
152             return null;
153         }
154         
155         public String JavaDoc getServerID() {
156             return null;
157         }
158         
159     }
160     
161     private static class J2eeModuleImpl implements J2eeModule {
162         
163         private final String JavaDoc moduleVersion;
164         
165         public J2eeModuleImpl(String JavaDoc moduleVersion) {
166             this.moduleVersion = moduleVersion;
167         }
168         
169         public String JavaDoc getModuleVersion() {
170             return moduleVersion;
171         }
172         
173         public Object JavaDoc getModuleType() {
174             return J2eeModule.EJB;
175         }
176         
177         public String JavaDoc getUrl() {
178             return null;
179         }
180         
181         public void setUrl(String JavaDoc url) {
182         }
183         
184         public FileObject getArchive() throws IOException JavaDoc {
185             return null;
186         }
187         
188         public Iterator JavaDoc getArchiveContents() throws IOException JavaDoc {
189             return null;
190         }
191         
192         public FileObject getContentDirectory() throws IOException JavaDoc {
193             return null;
194         }
195         
196         public BaseBean getDeploymentDescriptor(String JavaDoc location) {
197             return null;
198         }
199         
200         public void addVersionListener(VersionListener listener) {
201         }
202         
203         public void removeVersionListener(VersionListener listener) {
204         }
205     }
206     
207     private static class EnterpriseReferenceContainerImpl implements EnterpriseReferenceContainer {
208     
209         public String JavaDoc addEjbReference(EjbRef ref, FileObject referencingFile, String JavaDoc referencingClass, AntArtifact target) throws IOException JavaDoc { throw new UnsupportedOperationException JavaDoc("Not supported yet.");
210         }
211
212         public String JavaDoc addEjbLocalReference(EjbLocalRef localRef, FileObject referencingFile, String JavaDoc referencingClass, AntArtifact target) throws IOException JavaDoc {
213             throw new UnsupportedOperationException JavaDoc("Not supported yet.");
214         }
215
216         public String JavaDoc getServiceLocatorName() {
217             throw new UnsupportedOperationException JavaDoc("Not supported yet.");
218         }
219
220         public void setServiceLocatorName(String JavaDoc serviceLocator) throws IOException JavaDoc {
221             throw new UnsupportedOperationException JavaDoc("Not supported yet.");
222         }
223
224         public String JavaDoc addDestinationRef(MessageDestinationRef ref, FileObject referencingFile, String JavaDoc referencingClass) throws IOException JavaDoc {
225             throw new UnsupportedOperationException JavaDoc("Not supported yet.");
226         }
227
228         public MessageDestinationRef createDestinationRef(String JavaDoc className) throws IOException JavaDoc {
229             throw new UnsupportedOperationException JavaDoc("Not supported yet.");
230         }
231
232         public String JavaDoc addResourceRef(ResourceRef ref, FileObject referencingFile, String JavaDoc referencingClass) throws IOException JavaDoc {
233             return "testJndiName";
234         }
235
236         public ResourceRef createResourceRef(String JavaDoc className) throws IOException JavaDoc {
237             ResourceRef resourceRef = new org.netbeans.modules.j2ee.dd.impl.ejb.model_3_0.ResourceRef();
238             return resourceRef;
239         }
240 }
241     
242 }
Popular Tags