Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 330894 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jst/common/jdt/internal/javalite/JavaLiteUtilities.java (+1 lines)
Lines 148-153 Link Here
148
									containers.add(outputContainer);
148
									containers.add(outputContainer);
149
								}
149
								}
150
								break;
150
								break;
151
							default:
151
							}
152
							}
152
						}
153
						}
153
					}
154
					}
(-)archiveops/org/eclipse/jst/j2ee/internal/archive/operations/JavaEEComponentExportOperation.java (-32 / +47 lines)
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
}
(-)j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java (-19 / +15 lines)
Lines 12-17 Link Here
12
12
13
import java.net.URL;
13
import java.net.URL;
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Arrays;
15
import java.util.List;
16
import java.util.List;
16
import java.util.Properties;
17
import java.util.Properties;
17
18
Lines 22-33 Link Here
22
import org.eclipse.core.runtime.Path;
23
import org.eclipse.core.runtime.Path;
23
import org.eclipse.jdt.core.IJavaProject;
24
import org.eclipse.jdt.core.IJavaProject;
24
import org.eclipse.jem.workbench.utility.JemProjectUtilities;
25
import org.eclipse.jem.workbench.utility.JemProjectUtilities;
25
import org.eclipse.jst.common.internal.modulecore.AddClasspathFoldersParticipant;
26
import org.eclipse.jst.common.internal.modulecore.AddClasspathLibReferencesParticipant;
27
import org.eclipse.jst.common.internal.modulecore.AddMappedOutputFoldersParticipant;
28
import org.eclipse.jst.common.internal.modulecore.IgnoreJavaInSourceFolderParticipant;
29
import org.eclipse.jst.common.internal.modulecore.ReplaceManifestExportParticipant;
30
import org.eclipse.jst.common.internal.modulecore.SingleRootExportParticipant;
31
import org.eclipse.jst.common.internal.modulecore.SingleRootUtil;
26
import org.eclipse.jst.common.internal.modulecore.SingleRootUtil;
32
import org.eclipse.jst.common.jdt.internal.javalite.JavaLiteUtilities;
27
import org.eclipse.jst.common.jdt.internal.javalite.JavaLiteUtilities;
33
import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit;
28
import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit;
Lines 36-42 Link Here
36
import org.eclipse.jst.j2ee.internal.IEJBModelExtenderManager;
31
import org.eclipse.jst.j2ee.internal.IEJBModelExtenderManager;
37
import org.eclipse.jst.j2ee.internal.J2EEConstants;
32
import org.eclipse.jst.j2ee.internal.J2EEConstants;
38
import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyEnablement;
33
import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyEnablement;
39
import org.eclipse.jst.j2ee.internal.common.exportmodel.JEEHeirarchyExportParticipant;
40
import org.eclipse.jst.j2ee.internal.common.exportmodel.JavaEESingleRootCallback;
34
import org.eclipse.jst.j2ee.internal.common.exportmodel.JavaEESingleRootCallback;
41
import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
35
import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
42
import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
36
import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
Lines 50-56 Link Here
50
import org.eclipse.wst.common.componentcore.ArtifactEdit;
44
import org.eclipse.wst.common.componentcore.ArtifactEdit;
51
import org.eclipse.wst.common.componentcore.ComponentCore;
45
import org.eclipse.wst.common.componentcore.ComponentCore;
52
import org.eclipse.wst.common.componentcore.internal.flat.IChildModuleReference;
46
import org.eclipse.wst.common.componentcore.internal.flat.IChildModuleReference;
53
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
54
import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities;
47
import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities;
55
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
48
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
56
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
49
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
Lines 100-119 Link Here
100
	}
93
	}
101
	
94
	
102
	@Override
95
	@Override
103
	protected IFlattenParticipant[] getParticipants() {
96
	public String[] getDefaultFlattenParticipantIDs() {
104
		List<IFlattenParticipant> participants = new ArrayList<IFlattenParticipant>();
97
		String[] defaultParticipants = new String[]{
98
				JEEFlattenParticipantProvider.JEESingleRootParticipant,
99
				JEEFlattenParticipantProvider.JEEHeirarchyExportParticipant,
100
				JEEFlattenParticipantProvider.AddClasspathLibReferencesParticipant,
101
				JEEFlattenParticipantProvider.AddClasspathFoldersParticipant,
102
				JEEFlattenParticipantProvider.AddMappedOutputFoldersParticipant,
103
				JEEFlattenParticipantProvider.IgnoreJavaInSourceFolderParticipant
104
		};
105
		
105
		
106
		participants.add(new SingleRootExportParticipant(new JavaEESingleRootCallback()));
106
		// When will this be deprecated / removed? 
107
		participants.add(new JEEHeirarchyExportParticipant());
107
		ArrayList<String> vals = new ArrayList<String>();
108
		participants.add(new AddClasspathLibReferencesParticipant());
108
		vals.addAll(Arrays.asList(defaultParticipants));
109
		participants.add(new AddClasspathFoldersParticipant());
110
		participants.add(new AddMappedOutputFoldersParticipant());
111
		participants.add(new IgnoreJavaInSourceFolderParticipant());
112
		if (ClasspathDependencyEnablement.isAllowClasspathComponentDependency()) {
109
		if (ClasspathDependencyEnablement.isAllowClasspathComponentDependency()) {
113
			participants.add(new ReplaceManifestExportParticipant(new Path(J2EEConstants.MANIFEST_URI)));
110
			vals.add(JEEFlattenParticipantProvider.JEEReplaceManifestExportParticipant);
114
		}
111
		}
115
		
112
		return vals.toArray(new String[vals.size()]);
116
		return participants.toArray(new IFlattenParticipant[participants.size()]);
117
	}
113
	}
118
    
114
    
119
    @Override
115
    @Override
(-)j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/JEEFlattenParticipantProvider.java (+88 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jst.j2ee.internal.deployables;
12
13
import java.util.Properties;
14
15
import org.eclipse.core.runtime.Path;
16
import org.eclipse.jst.common.internal.modulecore.AddClasspathFoldersParticipant;
17
import org.eclipse.jst.common.internal.modulecore.AddClasspathLibReferencesParticipant;
18
import org.eclipse.jst.common.internal.modulecore.AddMappedOutputFoldersParticipant;
19
import org.eclipse.jst.common.internal.modulecore.IgnoreJavaInSourceFolderParticipant;
20
import org.eclipse.jst.common.internal.modulecore.ReplaceManifestExportParticipant;
21
import org.eclipse.jst.common.internal.modulecore.SingleRootExportParticipant;
22
import org.eclipse.jst.j2ee.internal.J2EEConstants;
23
import org.eclipse.jst.j2ee.internal.common.exportmodel.JEEHeirarchyExportParticipant;
24
import org.eclipse.jst.j2ee.internal.common.exportmodel.JavaEESingleRootCallback;
25
import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
26
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
27
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipantProvider;
28
import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel;
29
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
30
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
31
32
public class JEEFlattenParticipantProvider implements
33
		IFlattenParticipantProvider {
34
35
	/*
36
	 * The following are all internal to jeetools and are not API,
37
	 * though may at some point be saved in a settings file in a list 
38
	 * format. if the user decides to customize their list of participants,
39
	 * they may add or remove items to the list in the .settings file
40
	 */
41
	public static final String JEESingleRootParticipant = "JEESingleRootParticipant"; //$NON-NLS-1$
42
	public static final String JEEHeirarchyExportParticipant = "JEEHeirarchyExportParticipant"; //$NON-NLS-1$
43
	public static final String AddClasspathLibReferencesParticipant = "AddClasspathLibReferencesParticipant"; //$NON-NLS-1$
44
	public static final String AddClasspathFoldersParticipant = "AddClasspathFoldersParticipant"; //$NON-NLS-1$
45
	public static final String AddMappedOutputFoldersParticipant = "AddMappedOutputFoldersParticipant"; //$NON-NLS-1$
46
	public static final String IgnoreJavaInSourceFolderParticipant = "IgnoreJavaInSourceFolderParticipant"; //$NON-NLS-1$
47
	public static final String JEEReplaceManifestExportParticipant = "JEEReplaceManifestExportParticipant"; //$NON-NLS-1$
48
	
49
	
50
	public static final String PARTICIPANT_FOR_EXPORT = "exportParticipants"; //$NON-NLS-1$
51
	public static final String FILTERED = "AddMappedOutputFoldersParticipant.FILTERED"; //$NON-NLS-1$
52
	
53
	
54
	public IFlattenParticipant findParticipant(String id, Properties props) {
55
		boolean forExport = props != null && props.get(PARTICIPANT_FOR_EXPORT) != null && 
56
				((Boolean)props.get(PARTICIPANT_FOR_EXPORT)).booleanValue();
57
		
58
		if( JEESingleRootParticipant.equals(id))
59
			return forExport ? null : new SingleRootExportParticipant(new JavaEESingleRootCallback());
60
		if( JEEHeirarchyExportParticipant.equals(id))
61
			return forExport ? createExportHierarchyParticipant() : new JEEHeirarchyExportParticipant();
62
		if( AddClasspathLibReferencesParticipant.equals(id))
63
			return new AddClasspathLibReferencesParticipant();
64
		if( AddClasspathFoldersParticipant.equals(id))
65
			return new AddClasspathFoldersParticipant();
66
		if( AddMappedOutputFoldersParticipant.equals(id)) {
67
			String[] filter = props == null ? null  : (String[]) props.get(FILTERED);
68
			filter = filter == null ? new String[0] : filter;
69
			return new AddMappedOutputFoldersParticipant(filter);
70
		} if( IgnoreJavaInSourceFolderParticipant.equals(id))
71
			return forExport ? null : new IgnoreJavaInSourceFolderParticipant();
72
		if( JEEReplaceManifestExportParticipant.equals(id))
73
			return new ReplaceManifestExportParticipant(new Path(J2EEConstants.MANIFEST_URI));
74
		return null;
75
	}
76
77
	protected IFlattenParticipant createExportHierarchyParticipant() {
78
		return new AbstractFlattenParticipant() {
79
			@Override
80
			public boolean isChildModule(IVirtualComponent rootComponent, IVirtualReference reference, FlatComponentTaskModel dataModel) {
81
				if (!reference.getReferencedComponent().isBinary()) {
82
					return true;
83
				}
84
				return false;
85
			}
86
		};
87
	}
88
}
(-)plugin.xml (+7 lines)
Lines 859-862 Link Here
859
          class="org.eclipse.jst.j2ee.internal.modulecore.util.JEEManifestDiscerner">
859
          class="org.eclipse.jst.j2ee.internal.modulecore.util.JEEManifestDiscerner">
860
    </discerner>
860
    </discerner>
861
 </extension>
861
 </extension>
862
 <extension
863
       point="org.eclipse.wst.common.modulecore.flattenParticipantProvider">
864
    <flattenParticipantProvider
865
          class="org.eclipse.jst.j2ee.internal.deployables.JEEFlattenParticipantProvider"
866
          weight="10">
867
    </flattenParticipantProvider>
868
 </extension>
862
</plugin>
869
</plugin>
(-)j2ee-tests/org/eclipse/jst/j2ee/classpath/tests/AllTests.java (-1 / +1 lines)
Lines 20-26 Link Here
20
        
20
        
21
        suite.setName("All Classpath Dependency Tests");
21
        suite.setName("All Classpath Dependency Tests");
22
        suite.addTest(ClasspathDependencyCreationTests.suite());
22
        suite.addTest(ClasspathDependencyCreationTests.suite());
23
        //suite.addTest(ClasspathDependencyValidationTests.suite());
23
//        //suite.addTest(ClasspathDependencyValidationTests.suite());
24
        suite.addTest(ClasspathDependencyEARTests.suite());
24
        suite.addTest(ClasspathDependencyEARTests.suite());
25
        suite.addTest(ClasspathDependencyWebTests.suite());
25
        suite.addTest(ClasspathDependencyWebTests.suite());
26
        
26
        
(-)modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/FlattenParticipantModel.java (+128 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Red Hat and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Red Hat - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.common.componentcore.internal.flat;
12
13
import java.util.ArrayList;
14
import java.util.Collections;
15
import java.util.Comparator;
16
import java.util.Properties;
17
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IConfigurationElement;
20
import org.eclipse.core.runtime.IExtensionRegistry;
21
import org.eclipse.core.runtime.Platform;
22
import org.eclipse.wst.common.componentcore.internal.ModulecorePlugin;
23
24
/**
25
 * A class to load and keep track of all IFlattenParticipantProviders, 
26
 * and also to assist in locating IFlattenParticipants of a specific ID. 
27
 */
28
public class FlattenParticipantModel {
29
	
30
	private static FlattenParticipantModel model;
31
	public static FlattenParticipantModel getDefault() {
32
		if( model == null )
33
			model = new FlattenParticipantModel();
34
		return model;
35
	}
36
	
37
	private ArrayList<FlattenParticipantProviderWrapper> providers;
38
	public FlattenParticipantModel() {
39
		
40
	}
41
	
42
	public IFlattenParticipant getParticipant(String id) {
43
		return getParticipant(id, null);
44
	}
45
46
	public IFlattenParticipant getParticipant(String id, Properties properties) {
47
		IFlattenParticipantProvider[] providers = getProviders();
48
		IFlattenParticipant result = null;
49
		for( int i = 0; i < providers.length; i++ ) {
50
			result = providers[i].findParticipant(id, properties);
51
			if( result != null )
52
				return result;
53
		}
54
		return null;
55
	}
56
	
57
	protected IFlattenParticipantProvider[] getProviders() {
58
		if( providers == null )
59
			loadProviders();
60
		return providers.toArray(new IFlattenParticipantProvider[providers.size()]);
61
	}
62
	
63
	protected void loadProviders() {
64
		ArrayList<FlattenParticipantProviderWrapper> tmp = new ArrayList<FlattenParticipantProviderWrapper>();
65
		IExtensionRegistry registry = Platform.getExtensionRegistry();
66
		IConfigurationElement[] cf = registry.getConfigurationElementsFor(ModulecorePlugin.PLUGIN_ID, "flattenParticipantProvider"); //$NON-NLS-1$
67
		String id = null;
68
		for( int j = 0; j < cf.length; j++ ) {
69
			tmp.add(getWrapper(cf[j]));
70
		}
71
		
72
		// Sort
73
		Collections.sort(tmp, new Comparator<FlattenParticipantProviderWrapper>() {
74
			public int compare(FlattenParticipantProviderWrapper o1,
75
					FlattenParticipantProviderWrapper o2) {
76
				if( o1 == null && o2 == null )
77
					return 0;
78
				if( o1 == null )
79
					return 1;
80
				if( o2 == null )
81
					return -1;
82
				return o2.getWeight() - o1.getWeight();
83
			}
84
		});
85
		
86
		providers = tmp;
87
	}
88
	
89
	private FlattenParticipantProviderWrapper getWrapper(IConfigurationElement element) {
90
		return new FlattenParticipantProviderWrapper(element);
91
	}
92
	
93
	private static class FlattenParticipantProviderWrapper implements IFlattenParticipantProvider {
94
		private IConfigurationElement cf;
95
		private int weight;
96
		private IFlattenParticipantProvider delegate;
97
		public FlattenParticipantProviderWrapper(IConfigurationElement element) {
98
			this.cf = element;
99
			System.out.println(element.getAttribute("class"));
100
			String s = element.getAttribute("weight");
101
			try {
102
				weight = Integer.parseInt(s);
103
			} catch(NumberFormatException nfe ) {
104
				// TODO trace / log? Maybe not necessary. Use default weight
105
				weight = 0; // default weight
106
			}
107
		}
108
		
109
		public int getWeight() {
110
			return weight;
111
		}
112
		
113
		public IFlattenParticipant findParticipant(String id, Properties props) {
114
			if( delegate == null )
115
				loadDelegate();
116
			return delegate == null ? null : delegate.findParticipant(id, props);
117
		}
118
		
119
		private void loadDelegate() {
120
			try {
121
				delegate = (IFlattenParticipantProvider) cf.createExecutableExtension("class");
122
			} catch(CoreException ce ) {
123
				// TODO where to do the logging?
124
			}
125
		}
126
	}
127
	
128
}
(-)modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/IFlattenParticipantProvider.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Red Hat and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Red Hat - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.common.componentcore.internal.flat;
12
13
import java.util.Properties;
14
15
public interface IFlattenParticipantProvider {
16
	
17
	/**
18
	 * If this provider can find a participant for this specific
19
	 * id, it should do so now. Otherwise, return null. 
20
	 * 
21
	 * @param id A flatten participant id
22
	 * @param properties A list of properties to assist
23
	 * @return
24
	 */
25
	public IFlattenParticipant findParticipant(String id, Properties properties);
26
}
(-)plugin.xml (+1 lines)
Lines 56-61 Link Here
56
    <extension-point id="componentimpl" name="componentimpl" schema="schema/componentimpl.exsd"/>
56
    <extension-point id="componentimpl" name="componentimpl" schema="schema/componentimpl.exsd"/>
57
	<extension-point id="resourceFactories" name="Resource Factory Association (Internal)" schema="schema/resourceFactories.exsd"/>
57
	<extension-point id="resourceFactories" name="Resource Factory Association (Internal)" schema="schema/resourceFactories.exsd"/>
58
 <extension-point id="referenceResolver" name="referenceResolver" schema="schema/referenceResolver.exsd"/>
58
 <extension-point id="referenceResolver" name="referenceResolver" schema="schema/referenceResolver.exsd"/>
59
 <extension-point id="flattenParticipantProvider" name="flattenParticipantProvider" schema="schema/flattenParticipantProvider.exsd"/>
59
	
60
	
60
	<!-- Contribute a URIResolverExtension for flexible projects -->
61
	<!-- Contribute a URIResolverExtension for flexible projects -->
61
	<extension point="org.eclipse.wst.common.uriresolver.resolverExtensions">
62
	<extension point="org.eclipse.wst.common.uriresolver.resolverExtensions">
(-)schema/flattenParticipantProvider.exsd (+109 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.wst.common.modulecore" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.wst.common.modulecore" id="flattenParticipant" name="flattenParticipant"/>
7
      </appInfo>
8
      <documentation>
9
         [Enter description of this extension point.]
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <annotation>
15
         <appInfo>
16
            <meta.element />
17
         </appInfo>
18
      </annotation>
19
      <complexType>
20
         <sequence>
21
            <element ref="flattenParticipantProvider" minOccurs="1" maxOccurs="unbounded"/>
22
         </sequence>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appInfo>
43
                  <meta.attribute translatable="true"/>
44
               </appInfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49
50
   <element name="flattenParticipantProvider">
51
      <complexType>
52
         <attribute name="class" type="string" use="required">
53
            <annotation>
54
               <documentation>
55
                  The implementation class for this participant provider. The class must have a 0-argument constructor.
56
               </documentation>
57
               <appInfo>
58
                  <meta.attribute kind="java" basedOn=":org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipantProvider"/>
59
               </appInfo>
60
            </annotation>
61
         </attribute>
62
         <attribute name="weight" type="string">
63
            <annotation>
64
               <documentation>
65
                  A weight for this provider. Providers will be sorted by their weight and polled individually  in order for a specific key. If the provider can find or create that flatten participant, it should return it.
66
               </documentation>
67
            </annotation>
68
         </attribute>
69
      </complexType>
70
   </element>
71
72
   <annotation>
73
      <appInfo>
74
         <meta.section type="since"/>
75
      </appInfo>
76
      <documentation>
77
         [Enter the first release in which this extension point appears.]
78
      </documentation>
79
   </annotation>
80
81
   <annotation>
82
      <appInfo>
83
         <meta.section type="examples"/>
84
      </appInfo>
85
      <documentation>
86
         [Enter extension point usage example here.]
87
      </documentation>
88
   </annotation>
89
90
   <annotation>
91
      <appInfo>
92
         <meta.section type="apiinfo"/>
93
      </appInfo>
94
      <documentation>
95
         [Enter API information here.]
96
      </documentation>
97
   </annotation>
98
99
   <annotation>
100
      <appInfo>
101
         <meta.section type="implementation"/>
102
      </appInfo>
103
      <documentation>
104
         [Enter information about supplied implementation of this extension point.]
105
      </documentation>
106
   </annotation>
107
108
109
</schema>
(-)commontests/org/eclipse/wst/common/tests/flatten/ExampleFlattenParticipantProvider.java (+24 lines)
Added Link Here
1
package org.eclipse.wst.common.tests.flatten;
2
3
import java.util.Properties;
4
5
import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
6
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
7
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipantProvider;
8
9
public class ExampleFlattenParticipantProvider implements
10
		IFlattenParticipantProvider {
11
12
	public static final String DUMMY_PARTICIPANT = "example1";
13
	public IFlattenParticipant findParticipant(String id, Properties props) {
14
		if( DUMMY_PARTICIPANT.equals(id)) {
15
			return new DummyFlattenParticipant();
16
		}
17
		return null;
18
	}
19
	
20
	public static class DummyFlattenParticipant extends AbstractFlattenParticipant {
21
		
22
	}
23
24
}
(-)commontests/org/eclipse/wst/common/tests/flatten/ExampleFlattenParticipantProvider2.java (+29 lines)
Added Link Here
1
package org.eclipse.wst.common.tests.flatten;
2
3
import java.util.Properties;
4
5
import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
6
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
7
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipantProvider;
8
9
public class ExampleFlattenParticipantProvider2 implements
10
		IFlattenParticipantProvider {
11
12
	public static final String DUMMY_PARTICIPANT = "example2";
13
	
14
	public static final String COMMON_KEY = "common";
15
	public IFlattenParticipant findParticipant(String id, Properties props) {
16
		if( DUMMY_PARTICIPANT.equals(id)) {
17
			return new Dummy2FlattenParticipant();
18
		}
19
		if( COMMON_KEY.equals(id))
20
			return new Dummy2FlattenParticipant();
21
		
22
		return null;
23
	}
24
	
25
	public static class Dummy2FlattenParticipant extends AbstractFlattenParticipant {
26
		
27
	}
28
29
}
(-)commontests/org/eclipse/wst/common/tests/flatten/ExampleFlattenParticipantProvider3.java (+26 lines)
Added Link Here
1
package org.eclipse.wst.common.tests.flatten;
2
3
import java.util.Properties;
4
5
import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
6
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
7
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipantProvider;
8
9
public class ExampleFlattenParticipantProvider3 implements
10
		IFlattenParticipantProvider {
11
12
	public static final String DUMMY_PARTICIPANT = "example3";
13
	public static final String COMMON_KEY = ExampleFlattenParticipantProvider2.COMMON_KEY;
14
	public IFlattenParticipant findParticipant(String id, Properties props) {
15
		if( DUMMY_PARTICIPANT.equals(id))
16
			return new Dummy3FlattenParticipant();
17
		if( COMMON_KEY.equals(id))
18
			return new Dummy3FlattenParticipant();
19
		return null;
20
	}
21
	
22
	public static class Dummy3FlattenParticipant extends AbstractFlattenParticipant {
23
		
24
	}
25
26
}
(-)commontests/org/eclipse/wst/common/tests/flatten/FlattenParticipantProviderTest.java (+61 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.common.tests.flatten;
12
13
import junit.framework.TestCase;
14
15
import org.eclipse.wst.common.componentcore.internal.flat.FlattenParticipantModel;
16
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
17
18
19
public class FlattenParticipantProviderTest extends TestCase {
20
21
    public FlattenParticipantProviderTest(String name) {
22
        super(name);
23
    }
24
25
    public void testNotFoundParticipantFound() {
26
    	assertNull(searchModel("NOT FOUND"));
27
    }
28
29
    public void testExample1ParticipantFound() {
30
    	IFlattenParticipant fp = searchModel(ExampleFlattenParticipantProvider.DUMMY_PARTICIPANT);
31
    	assertNotNull(fp);
32
    	assertTrue(fp.getClass().getName().endsWith("DummyFlattenParticipant"));
33
    }
34
35
    public void testExample2ParticipantFound() {
36
    	IFlattenParticipant fp = searchModel(ExampleFlattenParticipantProvider2.DUMMY_PARTICIPANT);
37
    	assertNotNull(fp);
38
    	assertTrue(fp.getClass().getName().endsWith("Dummy2FlattenParticipant"));
39
    }
40
41
    public void testExample3ParticipantFound() {
42
    	IFlattenParticipant fp = searchModel(ExampleFlattenParticipantProvider3.DUMMY_PARTICIPANT);
43
    	assertNotNull(fp);
44
    	assertTrue(fp.getClass().getName().endsWith("Dummy3FlattenParticipant"));
45
    }
46
47
    /**
48
     * This test ensures that the weighting is done properly.
49
     * providers with a higher weight should be consulted first.
50
     * Weight 10 should be asked before weight 0
51
     */
52
    public void testCommonParticipantFound() {
53
    	IFlattenParticipant fp = searchModel(ExampleFlattenParticipantProvider2.COMMON_KEY);
54
    	assertNotNull(fp);
55
    	assertTrue(fp.getClass().getName().endsWith("Dummy3FlattenParticipant"));
56
    }
57
58
    private IFlattenParticipant searchModel(String id) {
59
    	return FlattenParticipantModel.getDefault().getParticipant(id);
60
    }
61
}
(-)plugin.xml (+14 lines)
Lines 105-110 Link Here
105
      <operationExtension
105
      <operationExtension
106
            id="org.eclipse.wst.common.frameworks.datamodel.tests.extended.H"/>
106
            id="org.eclipse.wst.common.frameworks.datamodel.tests.extended.H"/>
107
   </extension>
107
   </extension>
108
  <extension
109
        point="org.eclipse.wst.common.modulecore.flattenParticipantProvider">
110
     <flattenParticipantProvider
111
           class="org.eclipse.wst.common.tests.flatten.ExampleFlattenParticipantProvider"
112
           weight="5">
113
     </flattenParticipantProvider>
114
     <flattenParticipantProvider
115
           class="org.eclipse.wst.common.tests.flatten.ExampleFlattenParticipantProvider2">
116
     </flattenParticipantProvider>
117
     <flattenParticipantProvider
118
           class="org.eclipse.wst.common.tests.flatten.ExampleFlattenParticipantProvider3"
119
           weight="10">
120
     </flattenParticipantProvider>
121
  </extension>
108
   
122
   
109
   
123
   
110
   <!-- Uncomment the below hook to test specific operation extension ids when needed -->
124
   <!-- Uncomment the below hook to test specific operation extension ids when needed -->
(-)static_web_project/org/eclipse/wst/web/internal/deployables/FlatComponentDeployable.java (-5 / +85 lines)
Lines 26-31 Link Here
26
import org.eclipse.wst.common.componentcore.ComponentCore;
26
import org.eclipse.wst.common.componentcore.ComponentCore;
27
import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent;
27
import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent;
28
import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel;
28
import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel;
29
import org.eclipse.wst.common.componentcore.internal.flat.FlattenParticipantModel;
29
import org.eclipse.wst.common.componentcore.internal.flat.IChildModuleReference;
30
import org.eclipse.wst.common.componentcore.internal.flat.IChildModuleReference;
30
import org.eclipse.wst.common.componentcore.internal.flat.IFlatFile;
31
import org.eclipse.wst.common.componentcore.internal.flat.IFlatFile;
31
import org.eclipse.wst.common.componentcore.internal.flat.IFlatFolder;
32
import org.eclipse.wst.common.componentcore.internal.flat.IFlatFolder;
Lines 46-53 Link Here
46
import org.eclipse.wst.server.core.util.ModuleFile;
47
import org.eclipse.wst.server.core.util.ModuleFile;
47
import org.eclipse.wst.server.core.util.ProjectModule;
48
import org.eclipse.wst.server.core.util.ProjectModule;
48
49
49
public abstract class FlatComponentDeployable extends ProjectModule {
50
public abstract class FlatComponentDeployable extends ProjectModule implements IFlatDeployable {
50
51
52
	public static final String FLATTEN_PARTICIPANTS = "org.eclipse.wst.web.deployables.flatten.participants"; //$NON-NLS-1$
53
	private static final String FLATTEN_PARTICIPANTS_DELIM = ","; //$NON-NLS-1$
54
	
51
	/*
55
	/*
52
	 * Register an adapt IModule to IVirtualComponent 
56
	 * Register an adapt IModule to IVirtualComponent 
53
	 */
57
	 */
Lines 65-71 Link Here
65
						IVirtualComponent virtualComponent = deployable.getComponent();
69
						IVirtualComponent virtualComponent = deployable.getComponent();
66
						return virtualComponent;
70
						return virtualComponent;
67
					}
71
					}
68
				}
72
 				}
69
				return null;
73
				return null;
70
			}
74
			}
71
		}, IModule.class);
75
		}, IModule.class);
Lines 129-137 Link Here
129
	 * 
133
	 * 
130
	 * @return
134
	 * @return
131
	 */
135
	 */
132
	protected IFlattenParticipant[] getParticipants() {
136
	public IFlattenParticipant[] getParticipants() {
133
		return new IFlattenParticipant[]{
137
		String[] ids = getParticipantIds();
134
		};
138
		return getFlattenParticipants(ids);
139
	}
140
141
	public String[] getParticipantIds() {
142
		// If file exists, load from file
143
		String participants = component.getMetaProperties().getProperty(FLATTEN_PARTICIPANTS);
144
		// else, get the default ones
145
		String[] split = participants == null ? getDefaultFlattenParticipantIDs() : participants.split(FLATTEN_PARTICIPANTS_DELIM); 
146
		for( int i = 0; i < split.length; i++ ) {
147
			split[i] = split[i].trim();
148
		}
149
		return split;
150
	}
151
152
	protected IFlattenParticipant[] getFlattenParticipants(String[] ids) {
153
		ArrayList<IFlattenParticipant> participants = new ArrayList<IFlattenParticipant>();
154
		IFlattenParticipant tmp;
155
		for( int i = 0; i < ids.length; i++ ) {
156
			tmp = FlattenParticipantModel.getDefault().getParticipant(ids[i]);
157
			if( tmp != null )
158
				participants.add(tmp);
159
			else {
160
				// Log? This is an error somehow
161
			}
162
		}
163
		return participants.toArray(new IFlattenParticipant[participants.size()]);
164
	}
165
	
166
	
167
	public void addFlattenParticipant(String id, int position) {
168
		String participants = component.getMetaProperties().getProperty(FLATTEN_PARTICIPANTS);
169
		String[] split = participants == null ? getDefaultFlattenParticipantIDs() : participants.split(","); //$NON-NLS-1$
170
		ArrayList<String> asList = new ArrayList<String>();
171
		asList.addAll(Arrays.asList(split));
172
		if( !asList.contains(id)) {
173
			if( position < asList.size())
174
				asList.add(position, id);
175
			else
176
				asList.add(id);
177
		}
178
		String asString = implode(asList.toArray(new String[asList.size()]), FLATTEN_PARTICIPANTS_DELIM);
179
		component.setMetaProperty(FLATTEN_PARTICIPANTS, asString);
180
	}
181
182
	private String implode(String[] array, String delim) {
183
		String retval;
184
		if (array.length==0) {
185
			retval = ""; //$NON-NLS-1$
186
		} else {
187
			StringBuffer sb = new StringBuffer();
188
			sb.append(array[0]);
189
			for (int i=1;i<array.length;i++) {
190
				sb.append(delim);
191
				sb.append(array[i]);
192
			}
193
			retval = sb.toString();
194
		}
195
		return retval;
196
	}
197
	
198
	public void removeFlattenParticipant(String id) {
199
		String participants = component.getMetaProperties().getProperty(FLATTEN_PARTICIPANTS);
200
		String[] split = participants == null ? getDefaultFlattenParticipantIDs() : participants.split(","); //$NON-NLS-1$
201
		ArrayList<String> asList = new ArrayList<String>();
202
		asList.addAll(Arrays.asList(split));
203
		asList.remove(id);
204
		String asString = implode(asList.toArray(new String[asList.size()]), FLATTEN_PARTICIPANTS_DELIM);
205
		component.setMetaProperty(FLATTEN_PARTICIPANTS, asString);
206
	}
207
208
	
209
	/**
210
	 * Get a list of participant keys that are default for this project type
211
	 * @return
212
	 */
213
	public String[] getDefaultFlattenParticipantIDs() {
214
		return new String[0];
135
	}
215
	}
136
	
216
	
137
	public boolean isBinary() {
217
	public boolean isBinary() {
(-)static_web_project/org/eclipse/wst/web/internal/deployables/IFlatDeployable.java (+56 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Red Hat and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Red Hat - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.web.internal.deployables;
12
13
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
14
15
public interface IFlatDeployable {
16
	/**
17
	 * Get a list of current flatten participants for this deployable
18
	 * @return
19
	 */
20
	public IFlattenParticipant[] getParticipants();
21
22
	/**
23
	 * Get a list of current flatten participant id's for this deployable
24
	 * @return
25
	 */
26
	public String[] getParticipantIds();
27
28
	/**
29
	 * Get a list of default flatten participants involved
30
	 * for this module type
31
	 * 
32
	 * @return
33
	 */
34
	public String[] getDefaultFlattenParticipantIDs();
35
	
36
	/**
37
	 * Add the flatten participant of the given id
38
	 * and persist it in the project settings.
39
	 * 
40
	 * @param id
41
	 * @param position
42
	 * @return
43
	 */
44
	public void addFlattenParticipant(String id, int position);
45
	
46
	/**
47
	 * Remove the flatten participant of the given id
48
	 * and persist it in the project settings.
49
	 * 
50
	 * @param id
51
	 * @return
52
	 */
53
	public void removeFlattenParticipant(String id);
54
	
55
56
}

Return to bug 330894