1 19 20 package org.netbeans.modules.j2ee.ejbcore.test; 21 22 import java.beans.PropertyChangeListener ; 23 import java.io.File ; 24 import java.io.IOException ; 25 import java.util.Iterator ; 26 import javax.swing.Icon ; 27 import javax.swing.event.ChangeListener ; 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 51 public final class ProjectImpl implements Project { 52 53 private final Lookup lookup; 54 private FileObject projectDirectory; 55 56 public ProjectImpl(String 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 type) { 81 return new SourceGroup[] { new SourceGroupImpl() }; 82 } 83 84 public void addChangeListener(ChangeListener listener) { 85 } 86 87 public void removeChangeListener(ChangeListener 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 getName() { 101 return "Sources"; 102 } 103 104 public String getDisplayName() { 105 return "Sources"; 106 } 107 108 public Icon 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 listener) { 117 } 118 119 public void removePropertyChangeListener(PropertyChangeListener listener) { 120 } 121 122 } 123 124 private static class J2eeModuleProviderImpl extends J2eeModuleProvider { 125 126 private final String moduleVersion; 127 128 public J2eeModuleProviderImpl(String 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 getDeploymentConfigurationFile(String name) { 141 return null; 142 } 143 144 public FileObject findDeploymentConfigurationFile(String name) { 145 return null; 146 } 147 148 public void setServerInstanceID(String severInstanceID) { 149 } 150 151 public String getServerInstanceID() { 152 return null; 153 } 154 155 public String getServerID() { 156 return null; 157 } 158 159 } 160 161 private static class J2eeModuleImpl implements J2eeModule { 162 163 private final String moduleVersion; 164 165 public J2eeModuleImpl(String moduleVersion) { 166 this.moduleVersion = moduleVersion; 167 } 168 169 public String getModuleVersion() { 170 return moduleVersion; 171 } 172 173 public Object getModuleType() { 174 return J2eeModule.EJB; 175 } 176 177 public String getUrl() { 178 return null; 179 } 180 181 public void setUrl(String url) { 182 } 183 184 public FileObject getArchive() throws IOException { 185 return null; 186 } 187 188 public Iterator getArchiveContents() throws IOException { 189 return null; 190 } 191 192 public FileObject getContentDirectory() throws IOException { 193 return null; 194 } 195 196 public BaseBean getDeploymentDescriptor(String 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 addEjbReference(EjbRef ref, FileObject referencingFile, String referencingClass, AntArtifact target) throws IOException { throw new UnsupportedOperationException ("Not supported yet."); 210 } 211 212 public String addEjbLocalReference(EjbLocalRef localRef, FileObject referencingFile, String referencingClass, AntArtifact target) throws IOException { 213 throw new UnsupportedOperationException ("Not supported yet."); 214 } 215 216 public String getServiceLocatorName() { 217 throw new UnsupportedOperationException ("Not supported yet."); 218 } 219 220 public void setServiceLocatorName(String serviceLocator) throws IOException { 221 throw new UnsupportedOperationException ("Not supported yet."); 222 } 223 224 public String addDestinationRef(MessageDestinationRef ref, FileObject referencingFile, String referencingClass) throws IOException { 225 throw new UnsupportedOperationException ("Not supported yet."); 226 } 227 228 public MessageDestinationRef createDestinationRef(String className) throws IOException { 229 throw new UnsupportedOperationException ("Not supported yet."); 230 } 231 232 public String addResourceRef(ResourceRef ref, FileObject referencingFile, String referencingClass) throws IOException { 233 return "testJndiName"; 234 } 235 236 public ResourceRef createResourceRef(String className) throws IOException { 237 ResourceRef resourceRef = new org.netbeans.modules.j2ee.dd.impl.ejb.model_3_0.ResourceRef(); 238 return resourceRef; 239 } 240 } 241 242 } | Popular Tags |