|
Lines 13-34
Link Here
|
| 13 |
import java.io.OutputStream; |
13 |
import java.io.OutputStream; |
| 14 |
import java.util.ArrayList; |
14 |
import java.util.ArrayList; |
| 15 |
import java.util.List; |
15 |
import java.util.List; |
|
|
16 |
import java.util.Properties; |
| 16 |
|
17 |
|
| 17 |
import org.eclipse.core.runtime.Path; |
18 |
import org.eclipse.core.resources.IProject; |
| 18 |
import org.eclipse.jst.common.internal.modulecore.AddClasspathFoldersParticipant; |
19 |
import org.eclipse.core.resources.ResourcesPlugin; |
| 19 |
import org.eclipse.jst.common.internal.modulecore.AddClasspathLibReferencesParticipant; |
20 |
import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentExportDataModelProperties; |
| 20 |
import org.eclipse.jst.common.internal.modulecore.AddMappedOutputFoldersParticipant; |
|
|
| 21 |
import org.eclipse.jst.common.internal.modulecore.ReplaceManifestExportParticipant; |
| 22 |
import org.eclipse.jst.j2ee.internal.J2EEConstants; |
| 23 |
import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyEnablement; |
| 24 |
import org.eclipse.jst.j2ee.internal.common.exportmodel.JavaEEComponentExportCallback; |
21 |
import org.eclipse.jst.j2ee.internal.common.exportmodel.JavaEEComponentExportCallback; |
| 25 |
import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant; |
22 |
import org.eclipse.jst.j2ee.internal.deployables.JEEFlattenParticipantProvider; |
| 26 |
import org.eclipse.wst.common.componentcore.internal.flat.FilterResourceParticipant; |
23 |
import org.eclipse.wst.common.componentcore.internal.flat.FlattenParticipantModel; |
| 27 |
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant; |
24 |
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant; |
| 28 |
import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel; |
|
|
| 29 |
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; |
25 |
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; |
| 30 |
import org.eclipse.wst.common.componentcore.resources.IVirtualReference; |
|
|
| 31 |
import org.eclipse.wst.common.frameworks.datamodel.IDataModel; |
26 |
import org.eclipse.wst.common.frameworks.datamodel.IDataModel; |
|
|
27 |
import org.eclipse.wst.server.core.IModule; |
| 28 |
import org.eclipse.wst.server.core.ServerUtil; |
| 29 |
import org.eclipse.wst.web.internal.deployables.IFlatDeployable; |
| 32 |
|
30 |
|
| 33 |
public class JavaEEComponentExportOperation extends ComponentExportOperation { |
31 |
public class JavaEEComponentExportOperation extends ComponentExportOperation { |
| 34 |
|
32 |
|
|
Lines 41-78
Link Here
|
| 41 |
} |
39 |
} |
| 42 |
|
40 |
|
| 43 |
@Override |
41 |
@Override |
| 44 |
protected List<IFlattenParticipant> getParticipants() { |
42 |
protected List<IFlattenParticipant> getParticipants() { |
| 45 |
List<IFlattenParticipant> participants = new ArrayList<IFlattenParticipant>(); |
43 |
String[] moduleParticipants = getModuleParticipants(); |
|
|
44 |
|
| 45 |
// Load from the model |
| 46 |
String[] filteredExtensions = getFilteredExtensions(); |
46 |
String[] filteredExtensions = getFilteredExtensions(); |
|
|
47 |
|
| 48 |
Properties props = new Properties(); |
| 49 |
props.put(JEEFlattenParticipantProvider.FILTERED, filteredExtensions); |
| 50 |
props.put(JEEFlattenParticipantProvider.PARTICIPANT_FOR_EXPORT, true); |
| 47 |
|
51 |
|
| 48 |
participants.add(createHierarchyParticipant()); |
52 |
ArrayList<IFlattenParticipant> participants = new ArrayList<IFlattenParticipant>(); |
| 49 |
participants.add(new AddMappedOutputFoldersParticipant(filteredExtensions)); |
53 |
IFlattenParticipant tmp; |
| 50 |
participants.add(FilterResourceParticipant.createSuffixFilterParticipant(filteredExtensions)); |
54 |
for( int i = 0; i < moduleParticipants.length; i++ ) { |
| 51 |
participants.add(new AddClasspathLibReferencesParticipant()); |
55 |
tmp = FlattenParticipantModel.getDefault().getParticipant(moduleParticipants[i], props); |
| 52 |
participants.add(new AddClasspathFoldersParticipant()); |
56 |
// A null participant is not an error. It simply means that participant provider has chosen to |
| 53 |
if (ClasspathDependencyEnablement.isAllowClasspathComponentDependency()) { |
57 |
// do nothing given the properties passed in, in this case, export |
| 54 |
participants.add(new ReplaceManifestExportParticipant(new Path(J2EEConstants.MANIFEST_URI))); |
58 |
if( tmp != null ) |
|
|
59 |
participants.add(tmp); |
| 55 |
} |
60 |
} |
| 56 |
|
|
|
| 57 |
return participants; |
61 |
return participants; |
| 58 |
} |
62 |
} |
| 59 |
|
63 |
|
| 60 |
protected IFlattenParticipant createHierarchyParticipant() { |
64 |
protected String[] getModuleParticipants() { |
| 61 |
return new AbstractFlattenParticipant() { |
65 |
IVirtualComponent vc = (IVirtualComponent)model.getProperty(IJ2EEComponentExportDataModelProperties.COMPONENT); |
| 62 |
@Override |
66 |
if( vc != null ) { |
| 63 |
public boolean isChildModule(IVirtualComponent rootComponent, IVirtualReference reference, FlatComponentTaskModel dataModel) { |
67 |
String p = (String) model.getProperty(IJ2EEComponentExportDataModelProperties.PROJECT_NAME); |
| 64 |
if (!reference.getReferencedComponent().isBinary()) { |
68 |
IProject p2 = p == null ? null : ResourcesPlugin.getWorkspace().getRoot().getProject(p); |
| 65 |
return true; |
69 |
if( p2 == null ) |
|
|
70 |
p2 = vc.getProject(); |
| 71 |
if( p2 != null && p2.isAccessible() ) { |
| 72 |
IModule[] projectMods = ServerUtil.getModules(p2); |
| 73 |
for( int i = 0; i < projectMods.length; i++ ) { |
| 74 |
IVirtualComponent tmp = (IVirtualComponent)projectMods[i].loadAdapter(IVirtualComponent.class, null); |
| 75 |
if( tmp.equals(vc)) { |
| 76 |
IModule mod = projectMods[i]; |
| 77 |
IFlatDeployable o9 = (IFlatDeployable) mod.loadAdapter(IFlatDeployable.class, null); |
| 78 |
if( o9 != null ) { |
| 79 |
return o9.getParticipantIds(); |
| 80 |
} |
| 81 |
} |
| 66 |
} |
82 |
} |
| 67 |
return false; |
|
|
| 68 |
} |
83 |
} |
| 69 |
}; |
84 |
} |
|
|
85 |
return null; |
| 70 |
} |
86 |
} |
| 71 |
|
87 |
|
|
|
88 |
|
| 72 |
@Override |
89 |
@Override |
| 73 |
protected FlatComponentArchiver createFlatComponentArchiver(OutputStream out) { |
90 |
protected FlatComponentArchiver createFlatComponentArchiver(OutputStream out) { |
| 74 |
return new FlatComponentArchiver(getComponent(), out, getParticipants(), new JavaEEComponentExportCallback(isExportSource())); |
91 |
return new FlatComponentArchiver(getComponent(), out, getParticipants(), new JavaEEComponentExportCallback(isExportSource())); |
| 75 |
} |
92 |
} |
| 76 |
|
|
|
| 77 |
|
| 78 |
} |
93 |
} |