Lines 10-30
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jst.j2ee.internal.deployables; |
11 |
package org.eclipse.jst.j2ee.internal.deployables; |
12 |
|
12 |
|
|
|
13 |
import java.io.File; |
13 |
import java.net.URL; |
14 |
import java.net.URL; |
14 |
import java.util.ArrayList; |
15 |
import java.util.ArrayList; |
15 |
import java.util.Arrays; |
16 |
import java.util.Arrays; |
16 |
import java.util.List; |
17 |
import java.util.List; |
17 |
import java.util.Properties; |
18 |
import java.util.Properties; |
18 |
|
19 |
|
|
|
20 |
import org.eclipse.core.commands.operations.IUndoableOperation; |
19 |
import org.eclipse.core.resources.IContainer; |
21 |
import org.eclipse.core.resources.IContainer; |
20 |
import org.eclipse.core.resources.IFile; |
22 |
import org.eclipse.core.resources.IFile; |
21 |
import org.eclipse.core.resources.IProject; |
23 |
import org.eclipse.core.resources.IProject; |
|
|
24 |
import org.eclipse.core.resources.IResource; |
25 |
import org.eclipse.core.resources.IWorkspaceRoot; |
26 |
import org.eclipse.core.resources.ResourcesPlugin; |
22 |
import org.eclipse.core.runtime.CoreException; |
27 |
import org.eclipse.core.runtime.CoreException; |
23 |
import org.eclipse.core.runtime.IPath; |
28 |
import org.eclipse.core.runtime.IPath; |
24 |
import org.eclipse.core.runtime.Path; |
29 |
import org.eclipse.core.runtime.Path; |
|
|
30 |
import org.eclipse.jdt.core.IClasspathAttribute; |
31 |
import org.eclipse.jdt.core.IClasspathEntry; |
25 |
import org.eclipse.jdt.core.IJavaProject; |
32 |
import org.eclipse.jdt.core.IJavaProject; |
26 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
33 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
|
|
34 |
import org.eclipse.jdt.core.JavaModelException; |
27 |
import org.eclipse.jem.workbench.utility.JemProjectUtilities; |
35 |
import org.eclipse.jem.workbench.utility.JemProjectUtilities; |
|
|
36 |
import org.eclipse.jst.j2ee.application.internal.operations.ClasspathElement; |
28 |
import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; |
37 |
import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; |
29 |
import org.eclipse.jst.j2ee.ejb.EJBJar; |
38 |
import org.eclipse.jst.j2ee.ejb.EJBJar; |
30 |
import org.eclipse.jst.j2ee.internal.EjbModuleExtensionHelper; |
39 |
import org.eclipse.jst.j2ee.internal.EjbModuleExtensionHelper; |
Lines 46-51
Link Here
|
46 |
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; |
55 |
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; |
47 |
import org.eclipse.wst.common.componentcore.resources.IVirtualReference; |
56 |
import org.eclipse.wst.common.componentcore.resources.IVirtualReference; |
48 |
import org.eclipse.wst.server.core.IModule; |
57 |
import org.eclipse.wst.server.core.IModule; |
|
|
58 |
import org.eclipse.wst.server.core.ServerUtil; |
59 |
import org.eclipse.wst.server.core.internal.Module; |
60 |
import org.eclipse.wst.server.core.internal.ModuleFactory; |
61 |
import org.eclipse.wst.server.core.internal.ModuleFile; |
49 |
import org.eclipse.wst.server.core.internal.ModuleFolder; |
62 |
import org.eclipse.wst.server.core.internal.ModuleFolder; |
50 |
import org.eclipse.wst.server.core.model.IModuleFolder; |
63 |
import org.eclipse.wst.server.core.model.IModuleFolder; |
51 |
import org.eclipse.wst.server.core.model.IModuleResource; |
64 |
import org.eclipse.wst.server.core.model.IModuleResource; |
Lines 147-152
Link Here
|
147 |
members.addAll(consumableMembers); |
160 |
members.addAll(consumableMembers); |
148 |
} |
161 |
} |
149 |
|
162 |
|
|
|
163 |
if (J2EEProjectUtilities.isDynamicWebProject(getProject()) || J2EEProjectUtilities.isEARProject(getProject())) { |
164 |
IJavaProject proj = JemProjectUtilities.getJavaProject(getProject()); |
165 |
if (proj != null) { |
166 |
IClasspathEntry[] classpathEntries = proj.getResolvedClasspath(true); |
167 |
for (int i = 0; i < classpathEntries.length; i++) { |
168 |
IClasspathEntry classpathEntry = classpathEntries[i]; |
169 |
if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY |
170 |
&& classpathEntry.getContentKind() == IPackageFragmentRoot.K_BINARY |
171 |
&& isDeployable(classpathEntry)) { |
172 |
IPath archivePath = classpathEntry.getPath(); |
173 |
File extFile = archivePath.toFile(); |
174 |
if (extFile.exists()) { |
175 |
IPath placementPath = Path.EMPTY; |
176 |
if (J2EEProjectUtilities.isDynamicWebProject(getProject())) { |
177 |
placementPath = new Path("WEB-INF/lib"); |
178 |
} |
179 |
ModuleFile mf = new ModuleFile(extFile, extFile.getName(), placementPath); |
180 |
IModuleResource moduleParent = getExistingModuleResource(members, mf.getModuleRelativePath()); |
181 |
|
182 |
if (moduleParent != null && moduleParent instanceof ModuleFolder) |
183 |
addMembersToModuleFolder((ModuleFolder)moduleParent, new IModuleResource[]{mf}); |
184 |
else { |
185 |
if (mf.getModuleRelativePath().isEmpty()) |
186 |
members.add(mf); |
187 |
else { |
188 |
if (moduleParent == null) |
189 |
moduleParent = ensureParentExists(mf.getModuleRelativePath(), (IContainer)vc.getRootFolder().getUnderlyingResource()); |
190 |
addMembersToModuleFolder((ModuleFolder)moduleParent, new IModuleResource[] {mf}); |
191 |
} |
192 |
} |
193 |
} |
194 |
} |
195 |
} |
196 |
} |
197 |
} |
198 |
|
150 |
IModuleResource[] mr = new IModuleResource[members.size()]; |
199 |
IModuleResource[] mr = new IModuleResource[members.size()]; |
151 |
members.toArray(mr); |
200 |
members.toArray(mr); |
152 |
return mr; |
201 |
return mr; |
Lines 284-290
Link Here
|
284 |
if (module != null && J2EEProjectUtilities.isUtilityProject(module.getProject())) { |
333 |
if (module != null && J2EEProjectUtilities.isUtilityProject(module.getProject())) { |
285 |
IVirtualComponent webComp = ComponentCore.createComponent(component.getProject()); |
334 |
IVirtualComponent webComp = ComponentCore.createComponent(component.getProject()); |
286 |
IVirtualReference reference = webComp.getReference(module.getProject().getName()); |
335 |
IVirtualReference reference = webComp.getReference(module.getProject().getName()); |
287 |
aURI = ComponentUtilities.getDeployUriOfUtilComponent(reference); |
336 |
if (reference != null) { |
|
|
337 |
aURI = ComponentUtilities.getDeployUriOfUtilComponent(reference); |
338 |
} else { |
339 |
aURI = "WEB-INF/lib/" + module.getProject().getName() + ".jar"; |
340 |
} |
288 |
}else{ |
341 |
}else{ |
289 |
aURI = component.getDeployedName()+IJ2EEModuleConstants.WAR_EXT; |
342 |
aURI = component.getDeployedName()+IJ2EEModuleConstants.WAR_EXT; |
290 |
} |
343 |
} |
Lines 411-414
Link Here
|
411 |
} |
464 |
} |
412 |
return consumableMembers; |
465 |
return consumableMembers; |
413 |
} |
466 |
} |
|
|
467 |
|
468 |
public IModule[] getModules() { |
469 |
List modules = new ArrayList(Arrays.asList(super.getModules())); |
470 |
|
471 |
if (J2EEProjectUtilities.isDynamicWebProject(getProject()) || J2EEProjectUtilities.isEARProject(getProject())) { |
472 |
IJavaProject proj = JemProjectUtilities.getJavaProject(getProject()); |
473 |
if (proj != null) { |
474 |
IClasspathEntry[] classpathEntries = new IClasspathEntry[0]; |
475 |
try { |
476 |
classpathEntries = proj.getResolvedClasspath(true); |
477 |
for (int i = 0; i < classpathEntries.length; i++) { |
478 |
IClasspathEntry classpathEntry = classpathEntries[i]; |
479 |
if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_PROJECT |
480 |
&& isDeployable(classpathEntry)) { |
481 |
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); |
482 |
IProject project = (IProject) root.findMember(classpathEntry.getPath()); |
483 |
if (!project.hasNature(IModuleConstants.MODULE_NATURE_ID)) { |
484 |
IUndoableOperation op = J2EEProjectUtilities.createFlexJavaProjectForProjectOperation(project); |
485 |
op.execute(null, null); |
486 |
} |
487 |
|
488 |
IModule module = ServerUtil.getModule(project); |
489 |
if (!modules.contains(module)) { |
490 |
modules.add(module); |
491 |
} |
492 |
} |
493 |
} |
494 |
} catch (Exception e) { |
495 |
// TODO: handle exception. Throwing it as I don't know what the standard is here, or even how to log it |
496 |
throw new RuntimeException(e); |
497 |
} |
498 |
} |
499 |
} |
500 |
|
501 |
IModule[] childModules = new IModule[modules.size()]; |
502 |
return (IModule[]) modules.toArray(childModules); |
503 |
} |
504 |
|
505 |
private IModule buildInMemoryModule(IProject project) { |
506 |
// Add the necessary nature |
507 |
|
508 |
// Get the correct factory - this may not be necessary given we are adding the nature? |
509 |
Module thisModule = (Module) getModule(); |
510 |
J2EEDeployableFactory fact = (J2EEDeployableFactory) thisModule.getModuleFactory().getDelegate(null); |
511 |
return fact.createModule(project); |
512 |
} |
513 |
|
514 |
|
515 |
private boolean isDeployable(IClasspathEntry classpathEntry) { |
516 |
IClasspathAttribute[] attrs = classpathEntry.getExtraAttributes(); |
517 |
boolean deploy = false; |
518 |
for (int j = 0; j < attrs.length; j++) { |
519 |
IClasspathAttribute attribute = attrs[j]; |
520 |
if (attribute.getName().equals("org.eclipse.jst.j2ee.deployableArtifact") && attribute.getValue().equalsIgnoreCase("true")) { |
521 |
deploy = true; |
522 |
break; |
523 |
} |
524 |
} |
525 |
return deploy; |
526 |
} |
414 |
} |
527 |
} |