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 179329 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/tptp/wsdm/tooling/provisional/util/ProjectHelper.java (-8 / +15 lines)
Lines 12-18 Link Here
12
12
13
package org.eclipse.tptp.wsdm.tooling.provisional.util;
13
package org.eclipse.tptp.wsdm.tooling.provisional.util;
14
14
15
import java.io.File;
15
import java.net.URI;
16
import java.net.URI;
17
import java.net.URL;
16
18
17
import org.eclipse.core.filesystem.URIUtil;
19
import org.eclipse.core.filesystem.URIUtil;
18
import org.eclipse.core.resources.ICommand;
20
import org.eclipse.core.resources.ICommand;
Lines 25-32 Link Here
25
import org.eclipse.core.runtime.CoreException;
27
import org.eclipse.core.runtime.CoreException;
26
28
27
public abstract class ProjectHelper {
29
public abstract class ProjectHelper {
28
30
	
29
	protected IProject getProject(String location, String name) throws CoreException {
31
	protected IProject getProject(String location, String name, String natureId, boolean create) throws CoreException {
30
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
32
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
31
		IWorkspaceRoot root = workspace.getRoot();	
33
		IWorkspaceRoot root = workspace.getRoot();	
32
34
Lines 35-43 Link Here
35
		URI projectURI = location==null?null:URIUtil.toURI(location);
37
		URI projectURI = location==null?null:URIUtil.toURI(location);
36
		desc.setLocationURI(projectURI);
38
		desc.setLocationURI(projectURI);
37
		
39
		
40
		if(natureId != null) {
41
			addNature(natureId, desc);
42
		}
43
		
38
		IProject project = root.getProject(name);
44
		IProject project = root.getProject(name);
39
		
45
		
40
		if(project != null) {
46
		if(create && project != null) {
41
			project.create(desc, null);
47
			project.create(desc, null);
42
			project.open(null);
48
			project.open(null);
43
		}
49
		}
Lines 45-59 Link Here
45
		return project;
51
		return project;
46
	}
52
	}
47
	
53
	
48
	public void addNature(String natureId) throws CoreException {		
54
	private void addNature(String natureId, IProjectDescription description) throws CoreException {		
49
		IProject project = getProject();
50
		IProjectDescription description = project.getDescription();
51
		String[] natures = description.getNatureIds();
55
		String[] natures = description.getNatureIds();
52
		String[] newNatures = new String[natures.length + 1];
56
		String[] newNatures = new String[natures.length + 1];
53
		System.arraycopy(natures, 0, newNatures, 0, natures.length);
57
		System.arraycopy(natures, 0, newNatures, 0, natures.length);
54
		newNatures[natures.length] = natureId;
58
		newNatures[natures.length] = natureId;
55
		description.setNatureIds(newNatures);
59
		description.setNatureIds(newNatures);		
56
		project.setDescription(description, null);
57
	}
60
	}
58
	
61
	
59
	public void refreshProject() throws Exception {
62
	public void refreshProject() throws Exception {
Lines 72-76 Link Here
72
		getProject().setDescription(desc, null);
75
		getProject().setDescription(desc, null);
73
	}
76
	}
74
	
77
	
78
	public static File toFile(URL url) {
79
		return new File(url.getFile());
80
	}
81
	
75
	public abstract IProject getProject();
82
	public abstract IProject getProject();
76
}
83
}
(-)src/org/eclipse/tptp/wsdm/tooling/internal/util/PluginProjectHelper.java (-2 / +2 lines)
Lines 21-28 Link Here
21
	private static final String PLUGIN_NATURE = "org.eclipse.pde.PluginNature"; //$NON-NLS-1$
21
	private static final String PLUGIN_NATURE = "org.eclipse.pde.PluginNature"; //$NON-NLS-1$
22
22
23
	public PluginProjectHelper(String projectLocation, String projectName) throws Exception {
23
	public PluginProjectHelper(String projectLocation, String projectName) throws Exception {
24
		super(projectLocation, projectName);
24
		super(projectLocation, projectName, JavaCore.NATURE_ID);		
25
		addNature(PLUGIN_NATURE);
25
		initializeClasspath();
26
		IClasspathEntry cpe = JavaCore.newContainerEntry(Path.fromOSString("org.eclipse.pde.core.requiredPlugins")); //$NON-NLS-1$
26
		IClasspathEntry cpe = JavaCore.newContainerEntry(Path.fromOSString("org.eclipse.pde.core.requiredPlugins")); //$NON-NLS-1$
27
		addClasspathEntry(cpe);
27
		addClasspathEntry(cpe);
28
	}
28
	}
(-)src/org/eclipse/tptp/wsdm/tooling/internal/util/JavaProjectHelper.java (-4 / +10 lines)
Lines 31-43 Link Here
31
31
32
	IProject _project = null;
32
	IProject _project = null;
33
33
34
	public JavaProjectHelper(String location, String projectName) throws Exception {
34
	public JavaProjectHelper(String location, String projectName, String natureId) throws Exception {
35
		_project = getProject(location, projectName);
35
		if(natureId == null) {
36
		addNature(JavaCore.NATURE_ID);
36
			natureId = JavaCore.NATURE_ID;
37
		}
38
		_project = getProject(location, projectName, natureId, true);		
37
		initializeClasspath();
39
		initializeClasspath();
38
	}
40
	}
41
	
42
	public JavaProjectHelper(String location, String projectName) throws Exception {
43
		this(location, projectName, JavaCore.NATURE_ID);
44
	}
39
45
40
	private void initializeClasspath() throws JavaModelException {
46
	protected void initializeClasspath() throws JavaModelException {
41
		IJavaProject javaProj = JavaCore.create(_project);
47
		IJavaProject javaProj = JavaCore.create(_project);
42
		javaProj.setRawClasspath(new IClasspathEntry[] {}, null);
48
		javaProj.setRawClasspath(new IClasspathEntry[] {}, null);
43
		addClasspathEntry(JavaRuntime.getDefaultJREContainerEntry());
49
		addClasspathEntry(JavaRuntime.getDefaultJREContainerEntry());
(-)src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseOsgiMiniProjectizer.java (-19 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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
 * $Id: EclipseOsgiMiniProjectizer.java,v 1.2 2007/05/07 09:15:19 dnsmith Exp $
8
 * 
9
 * Contributors:
10
 * 	Balan Subramanian (bsubram@us.ibm.com)
11
 *     IBM Corporation - initial API and implementation
12
 *******************************************************************************/
13
package org.eclipse.tptp.wsdm.tooling.internal.projectizer;
14
15
import org.apache.muse.tools.generator.projectizer.OsgiMiniProjectizer;
16
17
public class EclipseOsgiMiniProjectizer extends OsgiMiniProjectizer {
18
19
}
(-)src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseOsgiProjectizer.java (-29 / +39 lines)
Lines 49-56 Link Here
49
	private File[] _additionalJars;
49
	private File[] _additionalJars;
50
	private Object[][] _instances;
50
	private Object[][] _instances;
51
51
52
	private int _resourceCounter = 0;
53
54
	private String _projectLocation;
52
	private String _projectLocation;
55
53
56
	private String _projectName;
54
	private String _projectName;
Lines 60-80 Link Here
60
		
58
		
61
		loadParameters(data);		
59
		loadParameters(data);		
62
		
60
		
63
		PluginProjectHelper helper = createProject(_projectLocation, _projectName);
61
		PluginProjectHelper helper = createProject(_projectLocation, _projectName);		
64
		
65
		_targetDirectory = helper.getProjectDirectory();
62
		_targetDirectory = helper.getProjectDirectory();
66
63
		
67
		File descriptorFile = new File(_targetDirectory, EclipseOsgiProjectizerConstants.MUSE_DESCRIPTOR_FILE);
68
				
69
		File javaSourceDir = new File(_targetDirectory, OsgiProjectizerConstants.JAVA_SRC_DIR);
64
		File javaSourceDir = new File(_targetDirectory, OsgiProjectizerConstants.JAVA_SRC_DIR);
65
				
70
		createJavaSources(javaSourceDir, _filesMaps);
66
		createJavaSources(javaSourceDir, _filesMaps);
71
67
		createArtifacts(javaSourceDir);						
72
		File wsdldir = new File(_targetDirectory, OsgiProjectizerConstants.WSDL_DIR);
68
						
73
		
69
		helper.refreshProject();
70
	}
71
	
72
	protected void createArtifacts(File javaSourceDir) throws Exception {
74
		createActivatorFile(javaSourceDir, EclipseOsgiProjectizerConstants.ACTIVATOR_FILE_RESOURCE);
73
		createActivatorFile(javaSourceDir, EclipseOsgiProjectizerConstants.ACTIVATOR_FILE_RESOURCE);
75
		
74
		
76
		File routerEntriesDir = new File(_targetDirectory,OsgiProjectizerConstants.ROUTER_ENTRIES_DIR);
75
		File routerEntriesDir = new File(_targetDirectory,OsgiProjectizerConstants.ROUTER_ENTRIES_DIR);
77
		
76
		
77
		File descriptorFile = new File(_targetDirectory, EclipseOsgiProjectizerConstants.MUSE_DESCRIPTOR_FILE);
78
		
79
		File wsdldir = new File(_targetDirectory, OsgiProjectizerConstants.WSDL_DIR);
80
		
78
		createManifest(_targetDirectory, EclipseOsgiProjectizerConstants.OSGI_MANIFEST_FILE_RESOURCE, EclipseOsgiProjectizerConstants.OSGI_MANIFEST_FILE);				
81
		createManifest(_targetDirectory, EclipseOsgiProjectizerConstants.OSGI_MANIFEST_FILE_RESOURCE, EclipseOsgiProjectizerConstants.OSGI_MANIFEST_FILE);				
79
		
82
		
80
		for(int i=0; i < _capabilitiesList.length; i++) {
83
		for(int i=0; i < _capabilitiesList.length; i++) {
Lines 94-110 Link Here
94
		}
97
		}
95
		
98
		
96
		createBuildProperties(_targetDirectory, EclipseOsgiProjectizerConstants.BUILD_PROPERTIES_FILE_RESOURCE, EclipseOsgiProjectizerConstants.BUILD_PROPERTIES_FILE);
99
		createBuildProperties(_targetDirectory, EclipseOsgiProjectizerConstants.BUILD_PROPERTIES_FILE_RESOURCE, EclipseOsgiProjectizerConstants.BUILD_PROPERTIES_FILE);
97
		
100
	}
98
		helper.refreshProject();
101
	
102
	protected void loadParameters(ConfigurationData data) {
103
		super.loadParameters(data);
104
		_additionalJars = (File[])data.getParameter(EclipseConfigurationData.ADDITIONAL_JARS);
105
		_instances = (Object[][])data.getParameter(EclipseConfigurationData.INSTANCES);
106
		_projectName = (String)data.getParameter(EclipseConfigurationData.PROJECT_NAME);
107
		_projectLocation = (String)data.getParameter(EclipseConfigurationData.PROJECT_LOCATION);
99
	}
108
	}
100
		
109
		
101
	protected void createRouterEntries(File routerEntriesDir, Object[][] instances)
110
	protected void createRouterEntries(File routerEntriesDir, Object[][] instances)
102
			throws Exception {
111
			throws Exception {
103
		
112
			
104
		routerEntriesDir.mkdirs();
113
		for(int i=0; i < instances.length; i++) {
105
		
114
			Object[] instancePair = instances[i];
106
		for(int i=0; i < _instances.length; i++) {
107
			Object[] instancePair = _instances[i];
108
			
115
			
109
			//
116
			//
110
			//This is really tacky, but it's the only real way to do this
117
			//This is really tacky, but it's the only real way to do this
Lines 117-138 Link Here
117
			Element instanceElement = (Element) instancePair[1];
124
			Element instanceElement = (Element) instancePair[1];
118
			
125
			
119
			File serviceDir = new File(routerEntriesDir, resourcePathName);				
126
			File serviceDir = new File(routerEntriesDir, resourcePathName);				
120
			File routerEntryFile = new File(serviceDir, getResourceFileName());
127
			File routerEntryFile = new File(serviceDir, getResourceFileName(i));
121
			
128
			
122
			writeToFileCheck(instanceElement, routerEntryFile);				
129
			writeToFileCheck(instanceElement, routerEntryFile);				
123
		}
130
		}
124
	}
131
	}
125
	
132
	
126
	protected String getResourceFileName() {
133
	/**
127
		return Axis2ProjectizerConstants.RESOURCE_FILE.replaceFirst(PLACE_HOLDER, String.valueOf(_resourceCounter++));
134
	 * Get the name of a resource-instance file with the appropriate counter. This is 
128
	}
135
	 * really just a string-replace of the PLACE_HOLDER value with the given counter
129
136
	 * 
130
	protected void loadParameters(ConfigurationData data) {
137
	 * @param counter	The number to use in the string replace
131
		super.loadParameters(data);
138
	 * @return 			The string with PLACE_HOLDER replaced by the string value of counter
132
		_additionalJars = (File[])data.getParameter(EclipseConfigurationData.ADDITIONAL_JARS);
139
	 */
133
		_instances = (Object[][])data.getParameter(EclipseConfigurationData.INSTANCES);
140
	protected String getResourceFileName(int counter) {
134
		_projectName = (String)data.getParameter(EclipseConfigurationData.PROJECT_NAME);
141
		return Axis2ProjectizerConstants.RESOURCE_FILE.replaceFirst(PLACE_HOLDER, String.valueOf(counter));
135
		_projectLocation = (String)data.getParameter(EclipseConfigurationData.PROJECT_LOCATION);
136
	}
142
	}
137
143
138
	protected void createManifest(File baseTargetDir, String manifestFileResource, String manifestFileName) throws Exception {
144
	protected void createManifest(File baseTargetDir, String manifestFileResource, String manifestFileName) throws Exception {
Lines 140-146 Link Here
140
		
146
		
141
		String packageName = getSymbolicName().toString();
147
		String packageName = getSymbolicName().toString();
142
		
148
		
143
		Object[] filler = { getSymbolicName(), packageName + "." + EclipseOsgiProjectizerConstants.ACTIVATOR_CLASSNAME, getSymbolicName()};
149
		Object[] filler = { getSymbolicName(), makeActivatorName(packageName), getSymbolicName()};
144
		String newManifest = loadString(manifestTemplateIS, filler);
150
		String newManifest = loadString(manifestTemplateIS, filler);
145
		
151
		
146
		newManifest = addAdditionalJars(newManifest);
152
		newManifest = addAdditionalJars(newManifest);
Lines 149-154 Link Here
149
		writeToFileCheck(newManifest, manifestFile);
155
		writeToFileCheck(newManifest, manifestFile);
150
	}
156
	}
151
	
157
	
158
	protected String makeActivatorName(String packageName) {
159
		return packageName + "." + EclipseOsgiProjectizerConstants.ACTIVATOR_CLASSNAME;
160
	}
161
152
	private String addAdditionalJars(String newManifest) throws IOException {
162
	private String addAdditionalJars(String newManifest) throws IOException {
153
		ByteArrayInputStream bais = new ByteArrayInputStream(newManifest.getBytes());
163
		ByteArrayInputStream bais = new ByteArrayInputStream(newManifest.getBytes());
154
		Manifest manifest = null;			
164
		Manifest manifest = null;			
(-)plugin.xml (+13 lines)
Lines 24-27 Link Here
24
            servicePath="/"
24
            servicePath="/"
25
            servicePort="80"/>
25
            servicePort="80"/>
26
   </extension>
26
   </extension>
27
   <extension
28
         point="org.eclipse.tptp.wsdm.editor.codeGeneration">
29
      <description
30
            container="Mini"
31
            platform="OSGi">
32
      </description>
33
      <projectizer
34
            class="org.eclipse.tptp.wsdm.tooling.internal.projectizer.EclipseOsgiProjectizer"
35
            name="OSGi mini"
36
            servicePath="/"
37
            servicePort="80">
38
      </projectizer>
39
   </extension>
27
</plugin>
40
</plugin>
(-)src/org/eclipse/tptp/wsdm/tooling/provisional/util/ProgressMonitorHelper.java (+34 lines)
Added Link Here
1
package org.eclipse.tptp.wsdm.tooling.provisional.util;
2
3
import org.eclipse.core.runtime.IProgressMonitor;
4
5
public class ProgressMonitorHelper {
6
	
7
	private IProgressMonitor _monitor;
8
9
	public ProgressMonitorHelper(IProgressMonitor monitor) {
10
		_monitor = monitor;
11
	}
12
	
13
	public void finishProgressMonitor() {
14
		if (_monitor != null) {
15
			_monitor.done();
16
		}
17
	}
18
19
	public void recordProgress(int i) {
20
		if (_monitor != null) {
21
			_monitor.worked(1);
22
		}
23
	}
24
25
	public void startProgressMonitor(int i) {
26
		if(_monitor != null) {
27
			_monitor.beginTask("Running Projectizer", i);
28
		}
29
	}
30
31
	public void recordProgress() {
32
		recordProgress(1);
33
	}
34
}
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/GenerationOptionsPage.java (-42 / +59 lines)
Lines 34-39 Link Here
34
import org.eclipse.core.runtime.Path;
34
import org.eclipse.core.runtime.Path;
35
import org.eclipse.core.runtime.Platform;
35
import org.eclipse.core.runtime.Platform;
36
import org.eclipse.jface.dialogs.DialogPage;
36
import org.eclipse.jface.dialogs.DialogPage;
37
import org.eclipse.jface.preference.IPreferenceStore;
37
import org.eclipse.jface.util.Util;
38
import org.eclipse.jface.util.Util;
38
import org.eclipse.jface.wizard.WizardPage;
39
import org.eclipse.jface.wizard.WizardPage;
39
import org.eclipse.osgi.util.TextProcessor;
40
import org.eclipse.osgi.util.TextProcessor;
Lines 56-62 Link Here
56
import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator;
57
import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator;
57
import org.eclipse.tptp.wsdm.tooling.editor.mrt.relationship.dialog.internal.MemoryComboBox;
58
import org.eclipse.tptp.wsdm.tooling.editor.mrt.relationship.dialog.internal.MemoryComboBox;
58
import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages;
59
import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages;
60
import org.eclipse.tptp.wsdm.tooling.preferences.internal.Axis2ServerLocationPreferencePage;
59
import org.eclipse.tptp.wsdm.tooling.util.internal.Validation;
61
import org.eclipse.tptp.wsdm.tooling.util.internal.Validation;
62
import org.eclipse.tptp.wsdm.tooling.validation.util.internal.ValidationUtils;
60
63
61
/**
64
/**
62
 * This wizard enables the use to specify the projectizer options and also the
65
 * This wizard enables the use to specify the projectizer options and also the
Lines 94-105 Link Here
94
97
95
	private Label _containerLabel;
98
	private Label _containerLabel;
96
99
100
	private Listener _containerComboListener = new Listener() {
101
102
		public void handleEvent(Event event) {
103
			dialogChanged();
104
		}
105
		
106
	};
107
97
	public GenerationOptionsPage() {
108
	public GenerationOptionsPage() {
98
		super("wizardPage");
109
		super("wizardPage");
99
		setTitle(Messages.HOOKUP_WIZARD_TXT1);
110
		setTitle(Messages.HOOKUP_WIZARD_TXT1);
100
		setDescription(Messages.HOOKUP_WIZARD_TXT2);
111
		setDescription(Messages.HOOKUP_WIZARD_TXT2);
101
		
112
		
102
		loadExtensionData();
113
		loadExtensionData();
114
		setPageComplete(false);
103
	}
115
	}
104
	
116
	
105
	private void loadExtensionData() {
117
	private void loadExtensionData() {
Lines 109-115 Link Here
109
121
110
		for (int i = 0; i < extensions.length; i++) {	
122
		for (int i = 0; i < extensions.length; i++) {	
111
			IConfigurationElement[] elements = extensions[i].getConfigurationElements();			
123
			IConfigurationElement[] elements = extensions[i].getConfigurationElements();			
112
			CodeGenerationData codeGenData = new CodeGenerationData(elements);				
124
			CodeGenerationData codeGenData = new CodeGenerationData(elements);
113
			updatePlatformContainerMap(codeGenData);	
125
			updatePlatformContainerMap(codeGenData);	
114
		}
126
		}
115
	}
127
	}
Lines 138-144 Link Here
138
150
139
	public void createControl(Composite parent) {
151
	public void createControl(Composite parent) {
140
		setControl(doLayout(parent));
152
		setControl(doLayout(parent));
141
		dialogChanged();
142
	}
153
	}
143
154
144
	private Composite doLayout(Composite parent) {
155
	private Composite doLayout(Composite parent) {
Lines 273-278 Link Here
273
		Combo combo = new Combo(page, SWT.BORDER | SWT.READ_ONLY);
284
		Combo combo = new Combo(page, SWT.BORDER | SWT.READ_ONLY);
274
		combo.setEnabled(false);	
285
		combo.setEnabled(false);	
275
		
286
		
287
		combo.addListener(SWT.Modify, _containerComboListener);
276
		return combo;
288
		return combo;
277
	}
289
	}
278
290
Lines 465-471 Link Here
465
	{
477
	{
466
		public void handleEvent(Event e)
478
		public void handleEvent(Event e)
467
		{
479
		{
468
			setLocationForSelection();
469
			dialogChanged();
480
			dialogChanged();
470
		}
481
		}
471
	};
482
	};
Lines 475-480 Link Here
475
			String platform = _projectizerCombo.getText();
486
			String platform = _projectizerCombo.getText();
476
			
487
			
477
			Map containerCodeGenDataMap = (Map) _platformContainerMap.get(platform);
488
			Map containerCodeGenDataMap = (Map) _platformContainerMap.get(platform);
489
			_containerCombo.removeListener(SWT.Modify, _containerComboListener);
478
			_containerCombo.removeAll();
490
			_containerCombo.removeAll();
479
			
491
			
480
			boolean hasContainers = containerCodeGenDataMap.size() != 0;
492
			boolean hasContainers = containerCodeGenDataMap.size() != 0;
Lines 486-506 Link Here
486
				_containerCombo.select(0);
498
				_containerCombo.select(0);
487
			}
499
			}
488
			
500
			
501
			_containerCombo.addListener(SWT.Modify, _containerComboListener);
489
			_containerCombo.setEnabled(hasContainers);
502
			_containerCombo.setEnabled(hasContainers);
490
			_containerLabel.setEnabled(hasContainers);
503
			_containerLabel.setEnabled(hasContainers);
491
504
492
		   	dialogChanged();
505
		   	dialogChanged();
493
		}
506
		}
494
	};
507
	};
495
	
496
	void setLocationForSelection()
497
	{
498
//		 _locationArea.updateProjectName(getProjectNameFieldValue());
499
	}
500
508
509
	private TargetedFileList[] _filesToCopy;
510
	
501
	protected void dialogChanged()
511
	protected void dialogChanged()
502
	{
512
	{
503
		if(true) return;
504
		String prjName = getProjectName();
513
		String prjName = getProjectName();
505
514
506
		if (prjName.length() == 0)
515
		if (prjName.length() == 0)
Lines 526-533 Link Here
526
			return;
535
			return;
527
		}
536
		}
528
		
537
		
529
		canFlipToNextPage();
530
		
531
		updateStatus(null, DialogPage.NONE);
538
		updateStatus(null, DialogPage.NONE);
532
	}
539
	}
533
540
Lines 551-557 Link Here
551
558
552
	public boolean shouldPersistArtifacts()
559
	public boolean shouldPersistArtifacts()
553
	{
560
	{
554
		return _persistExtraArtifactsButton.isEnabled();
561
		return _persistExtraArtifactsButton.getSelection();
555
	}
562
	}
556
563
557
	/**
564
	/**
Lines 632-668 Link Here
632
		
639
		
633
		return baseAddress;
640
		return baseAddress;
634
	}
641
	}
635
	
636
	/**
637
	 * Checks to see if the Next Page can be enabled or not.
638
	 */
639
	public boolean canFlipToNextPage(){
640
		return true;
641
//		Axis2ServerLocationPage nextPage = (Axis2ServerLocationPage)this.getNextPage();
642
//		if(isPageComplete() && isAxis2Project())
643
//		{			
644
//			nextPage.makePageComplete(false);
645
//			String userLocation = nextPage.getUserDefinedLocation();
646
//			if(userLocation != null && userLocation.trim().length() > 0)
647
//			{
648
//				nextPage._serverNameField.setText(userLocation);
649
//			}else
650
//			{
651
//				nextPage._serverNameField.setText(nextPage.getPreferenceServerLocation());
652
//			}
653
//
654
//			return true;
655
//		}
656
//		
657
//		nextPage.makePageComplete(true);
658
//		
659
//		return false;
660
	}
661
642
662
	/**
643
	public boolean canFlipToNextPage() {
663
	 * Returns whether the new Project to be created is a Axis2 project
644
		return isPageComplete() && isAxis2Project();
664
	 * @return
645
	}
665
	 */
666
	public boolean isAxis2Project(){
646
	public boolean isAxis2Project(){
667
		String container = getSelectedData().getContainer();
647
		String container = getSelectedData().getContainer();
668
		return container != null && container.equals("Axis2");
648
		return container != null && container.equals("Axis2");
Lines 671-674 Link Here
671
	public void saveCombo() {
651
	public void saveCombo() {
672
		MemoryComboBox.save(_projectNameField, PROJECT_MEMORY_COMBO_ID, Preferences.userNodeForPackage(GenerationOptionsPage.class));
652
		MemoryComboBox.save(_projectNameField, PROJECT_MEMORY_COMBO_ID, Preferences.userNodeForPackage(GenerationOptionsPage.class));
673
	}
653
	}
654
	
655
	private String validateLocation()
656
	{
657
		String serverHome = getPreferenceServerLocation();
658
		
659
		ISoapServerDependency axisValidators[] = ValidationUtils.getAllAxisValidators();
660
		for(int i = 0 ; i < axisValidators.length ; i++){
661
			
662
			ISoapServerDependency axis2Dependency = (Axis2ServerDependency)axisValidators[i];
663
			String errorMessage = axis2Dependency.validateSoapServerHome(serverHome);
664
			if(errorMessage!=null)
665
				return errorMessage;
666
			_filesToCopy = axis2Dependency.getFilesToCopy();
667
			if(_filesToCopy == null)
668
				_filesToCopy = new TargetedFileList[0];
669
		}
670
		return null;		
671
	}
672
	
673
	/**
674
	 * Returns the Axis2 files to copied to generated code
675
	 * @return
676
	 */
677
	public TargetedFileList[] getAxis2FilesToCopy()
678
	{
679
		validateLocation();
680
		return _filesToCopy;
681
	}
682
	
683
	protected String getPreferenceServerLocation() 
684
	{
685
		IPreferenceStore store = Activator.getPlugin().getPreferenceStore();
686
		String location = store.getString(Axis2ServerLocationPreferencePage.SERVER_LOCATION_PREFERENCE_KEY).trim();
687
		if(location != null && !location.equals(""))
688
			return location;
689
		return "";
690
	}
674
}
691
}
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/NewProjectWizard.java (-15 / +8 lines)
Lines 64-71 Link Here
64
64
65
	private GenerationOptionsPage _generationOptionsPage;
65
	private GenerationOptionsPage _generationOptionsPage;
66
66
67
	private Axis2ServerLocationPage _axis2ServerLocationPage;
68
69
	private String _projectName;
67
	private String _projectName;
70
68
71
	private boolean _overwrite;
69
	private boolean _overwrite;
Lines 115-123 Link Here
115
		_generationOptionsPage = new GenerationOptionsPage();
113
		_generationOptionsPage = new GenerationOptionsPage();
116
		addPage(_generationOptionsPage);
114
		addPage(_generationOptionsPage);
117
115
118
		_axis2ServerLocationPage = new Axis2ServerLocationPage();
119
		addPage(_axis2ServerLocationPage);
120
121
		// TODO AME why is this hardcoded here? why is it getting reloaded?
116
		// TODO AME why is this hardcoded here? why is it getting reloaded?
122
		Image imgTP = EclipseUtils.loadImage(PlatformUI.getWorkbench().getDisplay(),
117
		Image imgTP = EclipseUtils.loadImage(PlatformUI.getWorkbench().getDisplay(),
123
				"icons/wizban/newEndpointProject_wiz.gif");
118
				"icons/wizban/newEndpointProject_wiz.gif");
Lines 151-157 Link Here
151
								_serverLocation);
146
								_serverLocation);
152
						// Update the Lib and module location
147
						// Update the Lib and module location
153
					}
148
					}
154
					_requiredAxis2Files = _axis2ServerLocationPage.getAxis2FilesToCopy();
149
					_requiredAxis2Files = _generationOptionsPage.getAxis2FilesToCopy();
155
				} catch (Exception e) {
150
				} catch (Exception e) {
156
					throw new RuntimeException(e);
151
					throw new RuntimeException(e);
157
				}
152
				}
Lines 214-228 Link Here
214
		_projectLocation = _generationOptionsPage.getProjectLocation();
209
		_projectLocation = _generationOptionsPage.getProjectLocation();
215
210
216
		if (_isAxis2Project) {
211
		if (_isAxis2Project) {
217
			_serverLocation = _axis2ServerLocationPage.getServerLocation();
212
			_serverLocation = _generationOptionsPage.getPreferenceServerLocation();
218
			updatePreference = _axis2ServerLocationPage.isUpdatePreference();
219
			popupAxis2LicenseDialog();
220
		}
213
		}
221
214
222
		IRunnableWithProgress runnable = new IRunnableWithProgress() {
215
		IRunnableWithProgress runnable = new IRunnableWithProgress() {
223
			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
216
			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
224
				if (!_isAxis2Project || _licenseAccepted)
217
				performFinish(monitor);
225
					performFinish(monitor);
226
			}
218
			}
227
		};
219
		};
228
		
220
		
Lines 303-313 Link Here
303
295
304
	private void handle(String message, Exception e) {
296
	private void handle(String message, Exception e) {
305
		_generationOptionsPage.setErrorMessage(message);
297
		_generationOptionsPage.setErrorMessage(message);
306
		_axis2ServerLocationPage.setErrorMessage(message);
307
308
		WsdmToolingLog.log(IStatus.ERROR, IStatus.OK, message, e);
298
		WsdmToolingLog.log(IStatus.ERROR, IStatus.OK, message, e);
309
	}
299
	}
310
300
	
311
	private void openTasksView() {
301
	private void openTasksView() {
312
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
302
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
313
		ViewPart view = (ViewPart) page.findView(TASK_VIEW_ID);
303
		ViewPart view = (ViewPart) page.findView(TASK_VIEW_ID);
Lines 323-327 Link Here
323
			page.activate(view);
313
			page.activate(view);
324
		}
314
		}
325
	}
315
	}
326
316
	
317
	public boolean canFinish() {
318
		return _generationOptionsPage.isPageComplete();
319
	}
327
}
320
}
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Axis2ServerLocationPage.java (-232 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional;
14
15
import org.eclipse.jface.preference.IPreferenceStore;
16
import org.eclipse.jface.wizard.WizardPage;
17
import org.eclipse.osgi.util.TextProcessor;
18
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.events.ModifyEvent;
20
import org.eclipse.swt.events.ModifyListener;
21
import org.eclipse.swt.events.SelectionAdapter;
22
import org.eclipse.swt.events.SelectionEvent;
23
import org.eclipse.swt.layout.GridData;
24
import org.eclipse.swt.layout.GridLayout;
25
import org.eclipse.swt.widgets.Button;
26
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.DirectoryDialog;
28
import org.eclipse.swt.widgets.Label;
29
import org.eclipse.swt.widgets.Text;
30
import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator;
31
import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages;
32
import org.eclipse.tptp.wsdm.tooling.preferences.internal.Axis2ServerLocationPreferencePage;
33
import org.eclipse.tptp.wsdm.tooling.validation.util.internal.ValidationUtils;
34
35
/**
36
 * This is Wizard Page to show the Axis2 server location details
37
 *
38
 */
39
public class Axis2ServerLocationPage extends WizardPage
40
{
41
	
42
	protected Text _serverNameField;
43
	private Button _browseButton;
44
	private Button _preferenceUpdate;
45
	private TargetedFileList[] _filesToCopy;
46
	
47
	private String userDefinedLocation ="";
48
	
49
	/**
50
	 * Instantiates the class.
51
	 */
52
	public Axis2ServerLocationPage() 
53
	{
54
		super("wizardPage");
55
		setTitle(Messages.HOOKUP_WIZARD_TXT1);
56
		setDescription(Messages.HOOKUP_WIZARD_TXT2);
57
	}
58
59
	/**
60
	 *  Creates wizard controls.
61
	 */
62
	public void createControl(Composite parent) 
63
	{
64
		Composite page = new Composite(parent, SWT.NULL);
65
		GridLayout layout = new GridLayout(1, false);
66
		page.setLayout(layout);
67
		createPageControls(page);
68
		//dialogChanged();
69
		setControl(page);
70
	}
71
72
	private void createPageControls(Composite page) 
73
	{
74
		Composite column = new Composite(page, SWT.NULL);
75
		GridLayout layout = new GridLayout(2, false);
76
		column.setLayout(layout);
77
		createServerLocationColumn(column);
78
	}
79
80
	private void createServerLocationColumn(Composite parent) 
81
	{
82
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
83
		data.horizontalSpan = 2;
84
        // new server location label
85
        Label serverLabel = new Label(parent, SWT.NONE);
86
        serverLabel.setText(Messages.CODE_GEN_AXIS2_LOCATION);
87
        serverLabel.setFont(parent.getFont());
88
        serverLabel.setLayoutData(data);
89
90
		// server location entry field
91
        data = new GridData(GridData.FILL_HORIZONTAL);
92
        data.widthHint = 350;
93
        data.horizontalSpan = 1;
94
        _serverNameField = new Text(parent, SWT.BORDER);
95
        _serverNameField.setLayoutData(data);
96
        _serverNameField.setFont(parent.getFont());
97
        _serverNameField.addModifyListener(new ModifyListener()
98
		{
99
			public void modifyText(ModifyEvent e)
100
			{
101
				boolean pageCompleted = true;
102
				userDefinedLocation = _serverNameField.getText();
103
				String errorMsg = validateLocation(); 
104
				if(errorMsg == null)
105
				{
106
					setErrorMessage(errorMsg);
107
					pageCompleted = true;
108
				}
109
				else
110
				{
111
					setErrorMessage(errorMsg);
112
					pageCompleted = false;
113
				}
114
				makePageComplete(pageCompleted);
115
			}
116
		});
117
        
118
    //    _serverNameField.setText(getPreferenceServerLocation());
119
120
        // browse button
121
		_browseButton = new Button(parent, SWT.PUSH);
122
		_browseButton.setText(Messages.HOOKUP_WIZARD_TXT5);
123
		_browseButton.addSelectionListener(new SelectionAdapter() 
124
		{
125
			public void widgetSelected(SelectionEvent event) 
126
			{
127
				handleLocationBrowseButtonPressed();
128
			}
129
		});
130
		
131
		// server location entry field
132
        data = new GridData(GridData.FILL_HORIZONTAL);
133
        //data.widthHint = 350;
134
        data.horizontalSpan = 2;
135
        _preferenceUpdate = new Button(parent, SWT.CHECK);
136
        _preferenceUpdate.setText(Messages.CODE_GEN_UPDATE_PREF);
137
        _preferenceUpdate.setLayoutData(data);
138
        _preferenceUpdate.setFont(parent.getFont());		
139
	}
140
	
141
	protected String getPreferenceServerLocation() 
142
	{
143
		IPreferenceStore store = Activator.getPlugin().getPreferenceStore();
144
		String location = store.getString(Axis2ServerLocationPreferencePage.SERVER_LOCATION_PREFERENCE_KEY).trim();
145
		if(location != null && !location.equals(""))
146
			return location;
147
		return "";
148
	}
149
150
	private void handleLocationBrowseButtonPressed() 
151
	{
152
153
		String selectedDirectory = null;
154
155
		DirectoryDialog dialog = new DirectoryDialog(_serverNameField.getShell());
156
		dialog.setMessage(Messages.CODE_GEN_DIR_LOCATION);
157
		//dialog.setFilterPath(dirName);
158
		selectedDirectory = dialog.open();
159
		
160
		if (selectedDirectory != null)
161
			updateLocationField(selectedDirectory);
162
163
	}
164
	
165
	private void updateLocationField(String selectedPath) 
166
	{
167
		_serverNameField.setText(TextProcessor.process(selectedPath));
168
	}
169
170
	/**
171
	 * Returns the server location.
172
	 * @return
173
	 */
174
	public String getServerLocation() 
175
	{
176
		return _serverNameField.getText();
177
	}
178
179
	/**
180
	 * Checks to see if Update Preferences checkbox is selected
181
	 * @return
182
	 */
183
	public boolean isUpdatePreference()
184
	{
185
		return _preferenceUpdate.getSelection();
186
	}
187
	
188
	private String validateLocation()
189
	{
190
		String serverHome = _serverNameField.getText();
191
		
192
		ISoapServerDependency axisValidators[] = ValidationUtils.getAllAxisValidators();
193
		for(int i = 0 ; i < axisValidators.length ; i++){
194
			
195
			ISoapServerDependency axis2Dependency = (Axis2ServerDependency)axisValidators[i];
196
			String errorMessage = axis2Dependency.validateSoapServerHome(serverHome);
197
			if(errorMessage!=null)
198
				return errorMessage;
199
			_filesToCopy = axis2Dependency.getFilesToCopy();
200
			if(_filesToCopy == null)
201
				_filesToCopy = new TargetedFileList[0];
202
		}
203
		return null;		
204
	}
205
	
206
	/**
207
	 * Returns the Axis2 files to copied to generated code
208
	 * @return
209
	 */
210
	public TargetedFileList[] getAxis2FilesToCopy()
211
	{
212
		return _filesToCopy;
213
	}
214
215
	/**
216
	 * Method to Set the Wizard page to complete state
217
	 * @param validPage 
218
	 */
219
	public synchronized void makePageComplete(boolean completePage)
220
	{
221
		if(completePage){
222
			setPageComplete(true);
223
		}
224
		else
225
			setPageComplete(false);		
226
	}
227
	
228
	protected String getUserDefinedLocation()
229
	{
230
		return userDefinedLocation;
231
	}
232
}
(-)src/org/eclipse/tptp/wsdm/tooling/nls/messages/mrt/internal/messages.properties (-1 / +1 lines)
Lines 32-38 Link Here
32
SYSTEM_CAPS_ERROR_2 = IWAT0646E Access Denied
32
SYSTEM_CAPS_ERROR_2 = IWAT0646E Access Denied
33
HOOKUP_WIZARD_TXT1 = Deployment target and generation options
33
HOOKUP_WIZARD_TXT1 = Deployment target and generation options
34
HOOKUP_WIZARD_TXT2 = This wizard creates code for touchpoint
34
HOOKUP_WIZARD_TXT2 = This wizard creates code for touchpoint
35
HOOKUP_WIZARD_TXT3 = Overwrite files if necessary
35
HOOKUP_WIZARD_TXT3 = Overwrite files
36
HOOKUP_WIZARD_PERSIST = Persist generated artifacts
36
HOOKUP_WIZARD_PERSIST = Persist generated artifacts
37
HOOKUP_WIZARD_TXT4 = Output project
37
HOOKUP_WIZARD_TXT4 = Output project
38
HOOKUP_WIZARD_TXT5 = Browse...
38
HOOKUP_WIZARD_TXT5 = Browse...
(-)src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEMiniProjectizer.java (+285 lines)
Lines 1-7 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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
 * 	Andrew Eberbach (aeberbac@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
1
package org.eclipse.tptp.wsdm.tooling.internal.projectizer;
12
package org.eclipse.tptp.wsdm.tooling.internal.projectizer;
2
13
14
import java.io.File;
15
import java.io.FileNotFoundException;
16
import java.io.InputStream;
17
import java.net.URL;
18
import java.util.Map;
19
3
import org.apache.muse.tools.generator.projectizer.J2EEMiniProjectizer;
20
import org.apache.muse.tools.generator.projectizer.J2EEMiniProjectizer;
21
import org.apache.muse.tools.generator.util.ConfigurationData;
22
import org.apache.muse.util.FileUtils;
23
import org.apache.muse.ws.resource.metadata.MetadataDescriptor;
24
import org.apache.muse.ws.wsdl.WsdlUtils;
25
import org.eclipse.core.runtime.FileLocator;
26
import org.eclipse.core.runtime.IProgressMonitor;
27
import org.eclipse.core.runtime.Platform;
28
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.EclipseConfigurationData;
29
import org.eclipse.tptp.wsdm.tooling.internal.util.WebProjectHelper;
30
import org.eclipse.tptp.wsdm.tooling.provisional.util.ProgressMonitorHelper;
31
import org.eclipse.tptp.wsdm.tooling.provisional.util.ProjectHelper;
32
import org.w3c.dom.Document;
33
import org.w3c.dom.Element;
4
34
5
public class EclipseJ2EEMiniProjectizer extends J2EEMiniProjectizer {
35
public class EclipseJ2EEMiniProjectizer extends J2EEMiniProjectizer {
36
	private static final String[] LIB_BUNDLE_IDS = { 
37
		"org.apache.muse.api", //$NON-NLS-1$
38
		"org.apache.muse.impl", //$NON-NLS-1$
39
		"org.apache.muse.core", //$NON-NLS-1$
40
		"org.apache.muse.tools", //$NON-NLS-1$
41
		"org.apache.muse.utils" //$NON-NLS-1$
42
		};
43
	
44
	private static final String CONTAINER_BUNDLE = "org.apache.muse.tools";//$NON-NLS-1$
45
	private static final String CONTAINER_RESOURCE = "/containers/muse-platform-mini-2.2.0.jar";//$NON-NLS-1$
46
		
47
	private String _projectName;
48
	private String _projectLocation;
49
	private File[] _additionalJars;
50
	private Object[][] _instances;
51
	private ProgressMonitorHelper _progressMonitorHelper;
52
53
	public void projectize(ConfigurationData configuration) throws Exception {
54
		ConfigurationData.checkConfiguration(this, configuration);
55
		loadParameters(configuration);		 
56
		ProgressMonitorHelper progressHelper = getProgressMonitor();
57
		progressHelper.startProgressMonitor(6);
58
		
59
		try {			
60
			WebProjectHelper helper = createProjectHelper();
61
			
62
			helper.setSuspendValidation(true);
63
				
64
			createJavaSources(helper, progressHelper);		
65
			createArtifacts(helper, progressHelper);
66
			createLibraries(helper, progressHelper);
67
						
68
			helper.refreshProject();
69
			helper.setSuspendValidation(false);			
70
		} finally {
71
			progressHelper.finishProgressMonitor();
72
		}
73
	}
74
75
	protected void createLibraries(WebProjectHelper helper, ProgressMonitorHelper progressHelper) throws Exception {		
76
		copyLibrariesFromBundles(helper, LIB_BUNDLE_IDS);
77
		progressHelper.recordProgress();
78
		
79
		copyAdditionalJars(helper);
80
		progressHelper.recordProgress();
81
		
82
		copyContainer(helper);
83
		progressHelper.recordProgress();
84
	}
85
86
	protected void copyContainer(WebProjectHelper helper) throws Exception {
87
		File webInfLibDir = new File(helper.getProjectDirectory(), EclipseJ2EEMiniProjectizerConstants.WEBINFLIB_DIR);
88
		URL url = Platform.getBundle(CONTAINER_BUNDLE).getEntry(CONTAINER_RESOURCE);
89
		url = FileLocator.toFileURL(url);
90
		
91
		File libSource = ProjectHelper.toFile(url);			
92
		FileUtils.copy(libSource, webInfLibDir);
93
	}
94
95
	protected void copyAdditionalJars(WebProjectHelper helper) throws Exception {
96
		File webInfLibDir = new File(helper.getProjectDirectory(), EclipseJ2EEMiniProjectizerConstants.WEBINFLIB_DIR);
97
		
98
		File[] additionalJars = getAdditionalJars();
99
		
100
		if(additionalJars != null) {
101
			for (int i=0; i < additionalJars.length; i++) {
102
				if(!additionalJars[i].exists()) {
103
					throw new FileNotFoundException(additionalJars[i].getAbsolutePath());
104
				}
105
				
106
				FileUtils.copyFile(additionalJars[i], webInfLibDir);
107
			}
108
		}
109
	}
110
111
	protected void copyLibrariesFromBundles(WebProjectHelper helper, String[] libBundleIds) throws Exception {
112
		URL url = null;
113
		File webInfDir = new File(helper.getProjectDirectory(), EclipseJ2EEMiniProjectizerConstants.WEBINF_DIR);
114
		
115
		for (int i=0; i < libBundleIds.length; i++) {		
116
			url = Platform.getBundle(libBundleIds[i]).getEntry(EclipseJ2EEMiniProjectizerConstants.PROJECT_LIB_DIR_RESOURCE);
117
			url = FileLocator.toFileURL(url);
118
	
119
			File libSource = ProjectHelper.toFile(url);			
120
			FileUtils.copyDirectory(libSource, webInfDir);
121
		}
122
	}
123
124
	protected WebProjectHelper createProjectHelper() throws Exception {
125
		return new WebProjectHelper(
126
				getProjectName(), 
127
				getProjectLocation(), 
128
				EclipseJ2EEMiniProjectizerConstants.JAVA_BIN_DIR, 
129
				EclipseJ2EEMiniProjectizerConstants.JAVA_SRC_DIR);
130
	}
131
132
	protected void createJavaSources(WebProjectHelper helper, ProgressMonitorHelper progressHelper) throws Exception {
133
		File javaSourceDir = new File(
134
				helper.getProjectDirectory(), 
135
				EclipseJ2EEMiniProjectizerConstants.JAVA_SRC_DIR);
136
		
137
		createJavaSources(javaSourceDir, getFilesMaps());	
138
		progressHelper.recordProgress();
139
	}
140
141
	protected void createArtifacts(WebProjectHelper helper, ProgressMonitorHelper progressHelper) throws Exception {				
142
		File descriptorFile = new File(
143
				helper.getProjectDirectory(), 
144
				EclipseJ2EEMiniProjectizerConstants.DESCRIPTOR_FILE);
145
		
146
		File wsdldir = new File(
147
				helper.getProjectDirectory(), 
148
				EclipseJ2EEMiniProjectizerConstants.WSDL_DIR);
149
		
150
		File routerEntriesDir = new File(
151
				helper.getProjectDirectory(),
152
				EclipseJ2EEMiniProjectizerConstants.ROUTER_ENTRIES_DIR);
153
		
154
		for(int i=0; i < getNumCapabilityMaps(); i++) {
155
			Map capabilities = getCapabilityMap(i);
156
			MetadataDescriptor rmd = getMetadata(i);
157
			Document wsdl = getWsdl(i);
158
			
159
			createDescriptor(getDescriptor(), 
160
					wsdl, 
161
					descriptorFile, 
162
					capabilities, 
163
					EclipseJ2EEMiniProjectizerConstants.WSDL_RELATIVE_PATH, 
164
					i);					
165
		
166
			createRMDFile(rmd, wsdl, wsdldir);
167
			createWSDLFile(wsdl, wsdldir);
168
			
169
			if(getInstances() == null) {
170
				createRouterEntries(routerEntriesDir, WsdlUtils.getServiceName(wsdl.getDocumentElement()), _capabilitiesList[i]);
171
			}
172
		}		
173
		
174
		progressHelper.recordProgress();
175
					
176
		if(getInstances() != null) {
177
			createRouterEntries(routerEntriesDir, getInstances());
178
		}
179
				
180
		createWebDescriptor(helper);
181
		createBuildFile(helper.getProjectDirectory(), 
182
				EclipseJ2EEMiniProjectizerConstants.BUILD_FILE_RESOURCE, 
183
				EclipseJ2EEMiniProjectizerConstants.BUILD_FILE);
184
		
185
		progressHelper.recordProgress();
186
	}
187
188
	protected void createBuildFile(File baseTargetDir, String buildFileResource, String buildFile) throws Exception {
189
		InputStream buildTemplate = FileUtils.loadFromContext(this.getClass(),buildFileResource);
190
		File build = new File(baseTargetDir, buildFile);
191
		copyStreamCheck(buildTemplate, build);			
192
	}
193
	
194
	protected void createWebDescriptor(WebProjectHelper helper) throws Exception {
195
		File webInfDir =  new File(helper.getProjectDirectory(),EclipseJ2EEMiniProjectizerConstants.WEBINF_DIR);
196
		File descriptorFile = new File(webInfDir, EclipseJ2EEMiniProjectizerConstants.WEBXML_FILE);
197
		if(!descriptorFile.delete()) {
198
			throw new Exception();
199
		}
200
		createFileFromResource(webInfDir, 
201
				EclipseJ2EEMiniProjectizerConstants.WEBXML_RESOURCE, 
202
				EclipseJ2EEMiniProjectizerConstants.WEBXML_FILE);
203
	}
204
205
	protected Map getCapabilityMap(int index) {
206
		return _capabilitiesList[index];
207
	}
208
209
	protected void createRouterEntries(File routerEntriesDir,Object[][] instances) throws Exception {
210
		routerEntriesDir.mkdirs();
211
		
212
		for (int i = 0; i < getInstances().length; i++) {
213
			Object[] instancePair = getInstances()[i];
214
215
			//
216
			// This is really tacky, but it's the only real way to do this
217
			// since there are no pairs. The File use is to get the last element
218
			// of the path in a nice, non-hack way.
219
			//
220
			String path = (String) instancePair[0];
221
			String resourcePathName = new File(path).getName();
222
223
			Element instanceElement = (Element) instancePair[1];
224
225
			File serviceDir = new File(routerEntriesDir, resourcePathName);
226
			File routerEntryFile = new File(serviceDir, getResourceFileName(i));
227
228
			writeToFileCheck(instanceElement, routerEntryFile);
229
		}
230
	}
231
	
232
	/**
233
	 * Get the name of a resource-instance file with the appropriate counter. This is 
234
	 * really just a string-replace of the PLACE_HOLDER value with the given counter
235
	 * 
236
	 * @param counter	The number to use in the string replace
237
	 * @return 			The string with PLACE_HOLDER replaced by the string value of counter
238
	 */
239
	protected String getResourceFileName(int counter) {
240
		return EclipseJ2EEMiniProjectizerConstants.RESOURCE_FILE.replaceFirst(PLACE_HOLDER, String.valueOf(counter));
241
	}
242
243
	protected void loadParameters(ConfigurationData data) {
244
		super.loadParameters(data);
245
246
		_additionalJars = (File[]) data.getParameter(EclipseConfigurationData.ADDITIONAL_JARS);
247
		_instances = (Object[][]) data.getParameter(EclipseConfigurationData.INSTANCES);
248
		_progressMonitorHelper = new ProgressMonitorHelper((IProgressMonitor) data.getParameter(EclipseConfigurationData.PROGRESS_MONITOR));
249
		_projectName = (String) data.getParameter(EclipseConfigurationData.PROJECT_NAME);
250
		_projectLocation = (String) data.getParameter(EclipseConfigurationData.PROJECT_LOCATION);
251
	}
252
253
	protected File[] getAdditionalJars() {
254
		return _additionalJars;
255
	}
256
	
257
	protected Map[] getFilesMaps() {
258
		return _filesMaps;
259
	}
260
	
261
	protected String getProjectLocation() {
262
		return _projectLocation;
263
	}
264
265
	protected String getProjectName() {
266
		return _projectName;
267
	}
268
		
269
	protected ProgressMonitorHelper getProgressMonitor() {
270
		return _progressMonitorHelper;
271
	}
272
	
273
	protected Object[][] getInstances() {
274
		return _instances;
275
	}
276
	
277
	protected Document getDescriptor() {
278
		return _descriptor;
279
	}
280
281
	protected int getNumCapabilityMaps() {
282
		return _capabilitiesList.length;
283
	}
284
285
	protected Document getWsdl(int index) {
286
		return _wsdls[index];
287
	}
6
288
289
	protected MetadataDescriptor getMetadata(int index) {
290
		return _metadatas[index];
291
	}
7
}
292
}
(-)src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseAxis2Projectizer.java (-272 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.internal.projectizer;
14
15
16
import java.io.File;
17
import java.io.FileNotFoundException;
18
import java.net.URL;
19
import java.util.Map;
20
21
import org.apache.muse.tools.generator.projectizer.Axis2ProjectizerConstants;
22
import org.apache.muse.tools.generator.projectizer.J2EEAxis2Projectizer;
23
import org.apache.muse.tools.generator.util.ConfigurationData;
24
import org.apache.muse.tools.generator.util.ServicesDescriptorHelper;
25
import org.apache.muse.util.FileUtils;
26
import org.apache.muse.ws.resource.metadata.MetadataDescriptor;
27
import org.apache.muse.ws.wsdl.WsdlUtils;
28
import org.eclipse.core.runtime.FileLocator;
29
import org.eclipse.core.runtime.IProgressMonitor;
30
import org.eclipse.core.runtime.Platform;
31
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.EclipseConfigurationData;
32
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.TargetedFileList;
33
import org.eclipse.tptp.wsdm.tooling.internal.codegeneration.Activator;
34
import org.eclipse.tptp.wsdm.tooling.internal.util.WebProjectHelper;
35
import org.w3c.dom.Document;
36
import org.w3c.dom.Element;
37
38
/**
39
 * Construct the projectizer for code generation
40
 */
41
public class EclipseAxis2Projectizer extends J2EEAxis2Projectizer {
42
	
43
	private static final String[] LIB_BUNDLE_IDS = { 
44
		"org.apache.muse.api", //$NON-NLS-1$
45
		"org.apache.muse.impl", //$NON-NLS-1$
46
		"org.apache.muse.core", //$NON-NLS-1$
47
		"org.apache.muse.tools", //$NON-NLS-1$
48
		"org.apache.muse.utils" //$NON-NLS-1$
49
		};
50
	
51
	private static final String[] MODULE_BUNDLE_IDS = { 
52
		"org.apache.muse.tools", //$NON-NLS-1$
53
		};
54
	
55
	private File[] _additionalJars;
56
	private Object[][] _instances;
57
	private IProgressMonitor _progressMonitor;
58
	private TargetedFileList[] _filesToCopy;
59
60
	private int _resourceCounter = 0;
61
62
	private String _projectName;
63
64
	private String _projectLocation;
65
	
66
	public void projectize(ConfigurationData configuration) throws Exception {
67
		
68
		ConfigurationData.checkConfiguration(this, configuration);
69
				
70
		try {
71
			
72
		loadParameters(configuration);
73
74
		startProgressMonitor(_progressMonitor, 10);
75
76
		WebProjectHelper helper = createProject();
77
		
78
		_targetDirectory = helper.getProjectDirectory();		
79
		
80
		recordProgress(_progressMonitor, 1);
81
		
82
		helper.setSuspendValidation(true);
83
84
		File webContentDir = copyTemplate(_targetDirectory);
85
		recordProgress(_progressMonitor, 1);
86
						
87
		File descriptorFile = new File(
88
				webContentDir, 
89
				Axis2ProjectizerConstants.DESCRIPTOR_FILE);
90
		
91
		File javaSourceDir = new File(
92
				_targetDirectory, 
93
				Axis2ProjectizerConstants.JAVA_SRC_DIR);
94
		
95
		createJavaSources(javaSourceDir, _filesMaps);
96
		recordProgress(_progressMonitor, 1);
97
		
98
		File wsdldir = new File(
99
				webContentDir, 
100
				Axis2ProjectizerConstants.WSDL_DIR);
101
102
		File routerEntriesDir = new File(webContentDir,Axis2ProjectizerConstants.ROUTER_ENTRIES_DIR);
103
		
104
		ServicesDescriptorHelper servicesHelper = new ServicesDescriptorHelper();
105
				
106
		createBuildFile(_targetDirectory, EclipseAxis2ProjectizerConstants.BUILD_FILE_RESOURCE, EclipseAxis2ProjectizerConstants.BUILD_FILE);
107
		recordProgress(_progressMonitor, 1);
108
		
109
		for(int i=0; i < _capabilitiesList.length; i++) {
110
			Map capabilities = _capabilitiesList[i];
111
			Document wsdl = _wsdls[i];
112
			createDescriptor(_descriptor, wsdl, descriptorFile, capabilities, Axis2ProjectizerConstants.WSDL_RELATIVE_PATH, i);						
113
			MetadataDescriptor rmd = _metadatas[i];
114
			createRMDFile(rmd, wsdl, wsdldir);
115
			createWSDLFile(wsdl, wsdldir);
116
			if(_instances == null) {
117
				createRouterEntries(routerEntriesDir, WsdlUtils.getServiceName(wsdl.getDocumentElement()), _capabilitiesList[i]);
118
			}
119
			updateServicesDescriptor(servicesHelper, wsdl, capabilities);
120
		}		
121
					
122
		if(_instances != null) {
123
			createRouterEntries(routerEntriesDir, _instances);
124
		}
125
		recordProgress(_progressMonitor, 4);
126
		
127
		File servicesFile = new File(webContentDir, Axis2ProjectizerConstants.SERVICES_FILE);
128
		createServicesDescriptor(servicesHelper, servicesFile);
129
		recordProgress(_progressMonitor, 1);
130
		
131
		helper.refreshProject();
132
		recordProgress(_progressMonitor, 1);
133
		
134
		helper.setSuspendValidation(false);
135
		} finally {
136
			finishProgressMonitor(_progressMonitor);
137
		}
138
	}
139
		
140
	private void finishProgressMonitor(IProgressMonitor monitor) {
141
		if(monitor != null) {
142
			monitor.done();
143
		}
144
	}
145
146
	private void recordProgress(IProgressMonitor monitor, int i) {
147
		if(monitor != null) {
148
			monitor.worked(1);
149
		}
150
	}
151
152
	private void startProgressMonitor(IProgressMonitor monitor, int i) {
153
		if(monitor != null) {
154
			monitor.beginTask("Running Projectizer", 9);
155
		}
156
	}
157
158
	protected void loadParameters(ConfigurationData data) {
159
		super.loadParameters(data);
160
		
161
		_additionalJars = (File[])data.getParameter(EclipseConfigurationData.ADDITIONAL_JARS);
162
		_instances = (Object[][])data.getParameter(EclipseConfigurationData.INSTANCES);	
163
		_progressMonitor = (IProgressMonitor)data.getParameter(EclipseConfigurationData.PROGRESS_MONITOR);
164
		_filesToCopy = (TargetedFileList[])data.getParameter(EclipseConfigurationData.AXIS2_FILES);
165
		_projectName = (String)data.getParameter(EclipseConfigurationData.PROJECT_NAME);
166
		_projectLocation = (String)data.getParameter(EclipseConfigurationData.PROJECT_LOCATION);		
167
	}
168
169
	private WebProjectHelper createProject() throws Exception {
170
		WebProjectHelper helper = new WebProjectHelper(_projectName, _projectLocation, EclipseAxis2ProjectizerConstants.JAVA_BIN_DIR, Axis2ProjectizerConstants.JAVA_SRC_DIR);
171
		
172
		return helper;
173
	}
174
	
175
	protected void createRouterEntries(File routerEntriesDir,Object[][] instances) throws Exception {
176
		routerEntriesDir.mkdirs();
177
		
178
		for (int i = 0; i < _instances.length; i++) {
179
			Object[] instancePair = _instances[i];
180
181
			//
182
			// This is really tacky, but it's the only real way to do this
183
			// since there are no pairs. The File use is to get the last element
184
			// of the path in a nice, non-hack way.
185
			//
186
			String path = (String) instancePair[0];
187
			String resourcePathName = new File(path).getName();
188
189
			Element instanceElement = (Element) instancePair[1];
190
191
			File serviceDir = new File(routerEntriesDir, resourcePathName);
192
			File routerEntryFile = new File(serviceDir, getResourceFileName());
193
194
			writeToFileCheck(instanceElement, routerEntryFile);
195
		}
196
	}
197
	
198
	protected String getResourceFileName() {
199
		return Axis2ProjectizerConstants.RESOURCE_FILE.replaceFirst(PLACE_HOLDER, String.valueOf(_resourceCounter++));
200
	}
201
	
202
	protected File copyTemplate(File destination) throws Exception {	
203
		URL url = Platform.getBundle(Activator.PLUGIN_ID).getEntry(EclipseAxis2ProjectizerConstants.WEBCONTENT_DIR_RESOURCE);
204
		url = FileLocator.toFileURL(url);
205
		
206
		File source = toFile(url);
207
		FileUtils.copyDirectory(source, destination);
208
		
209
		File webContentDir = new File(destination, source.getName());
210
		File webContentDestination = new File(webContentDir, "WEB-INF"); //$NON-NLS-1$
211
		
212
		for (int i=0; i < LIB_BUNDLE_IDS.length; i++) {		
213
			url = Platform.getBundle(LIB_BUNDLE_IDS[i]).getEntry(EclipseAxis2ProjectizerConstants.PROJECT_LIB_DIR_RESOURCE);
214
			url = FileLocator.toFileURL(url);
215
	
216
			File libSource = toFile(url);			
217
			FileUtils.copyDirectory(libSource, webContentDestination);
218
		}
219
		
220
		for (int i=0; i < MODULE_BUNDLE_IDS.length; i++) {		
221
			url = Platform.getBundle(MODULE_BUNDLE_IDS[i]).getEntry(EclipseAxis2ProjectizerConstants.PROJECT_MODULE_DIR_RESOURCE);
222
			url = FileLocator.toFileURL(url);
223
	
224
			File libSource = toFile(url);			
225
			FileUtils.copyDirectory(libSource, webContentDestination);
226
		}
227
		
228
		//
229
		//TODO: Hack to copy axis2-platform
230
		//this should be done in some cleaner way
231
		//
232
		
233
		url = Platform.getBundle(MODULE_BUNDLE_IDS[0]).getEntry("/lib/muse-platform-axis2-2.2.0.jar");
234
		url = FileLocator.toFileURL(url);
235
236
		File libSource = toFile(url);			
237
		FileUtils.copyFile(libSource, webContentDestination);
238
		
239
		File libDestination = new File(webContentDestination, "lib");
240
		
241
		if(_additionalJars != null) {
242
			for (int i=0; i < _additionalJars.length; i++) {
243
				if(!_additionalJars[i].exists()) {
244
					throw new FileNotFoundException(_additionalJars[i].getAbsolutePath());
245
				}
246
				
247
				FileUtils.copyFile(_additionalJars[i], libDestination);
248
			}
249
		}
250
		
251
		for (int i=0; i < _filesToCopy.length; i++) {
252
			String dest = _filesToCopy[i].getRelativePath();
253
			File destDir = new File(webContentDir, dest);
254
			String[] files = _filesToCopy[i].getFiles();
255
			
256
			for (int j=0; j < files.length; j++) {
257
				File file = new File(files[j]);
258
				if(!file.exists()) {
259
					throw new FileNotFoundException(file.getAbsolutePath());
260
				}
261
				
262
				FileUtils.copyFile(file, destDir);
263
			}
264
		}
265
266
		return webContentDir;	
267
	}
268
	private File toFile(URL url) throws Exception{
269
270
		return new File(url.getFile());
271
	}
272
}
(-)src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseAxis2ProjectizerConstants.java (-34 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.internal.projectizer;
14
15
16
public interface EclipseAxis2ProjectizerConstants {
17
	
18
	String RESOURCES_DIR = "/resources/axis2/"; //$NON-NLS-1$
19
	
20
	String BUILD_FILE_RESOURCE = RESOURCES_DIR + "build.xml"; //$NON-NLS-1$
21
	
22
	String BUILD_FILE = "build.xml"; //$NON-NLS-1$
23
24
	String LAUNCH_FILE_RESOURCE = RESOURCES_DIR + ".externalToolBuilders/jarBuilder.launch"; //$NON-NLS-1$
25
26
	String WEBCONTENT_DIR_RESOURCE = RESOURCES_DIR + "WebContent"; //$NON-NLS-1$
27
28
	String PROJECT_LIB_DIR_RESOURCE = "/lib"; //$NON-NLS-1$
29
	
30
	String PROJECT_MODULE_DIR_RESOURCE = "/modules"; //$NON-NLS-1$
31
32
	String JAVA_BIN_DIR = "bin"; //$NON-NLS-1$
33
34
}
(-)src/org/eclipse/tptp/wsdm/tooling/internal/util/WebProjectHelper.java (-9 / +2 lines)
Lines 14-29 Link Here
14
14
15
15
16
import java.io.File;
16
import java.io.File;
17
import java.net.URI;
18
17
19
import org.eclipse.core.filesystem.URIUtil;
20
import org.eclipse.core.resources.IProject;
18
import org.eclipse.core.resources.IProject;
21
import org.eclipse.core.resources.IResource;
22
import org.eclipse.core.resources.IWorkspaceRoot;
23
import org.eclipse.core.resources.ResourcesPlugin;
24
import org.eclipse.core.runtime.IPath;
25
import org.eclipse.core.runtime.NullProgressMonitor;
19
import org.eclipse.core.runtime.NullProgressMonitor;
26
import org.eclipse.core.runtime.Path;
27
import org.eclipse.jst.common.project.facet.IJavaFacetInstallDataModelProperties;
20
import org.eclipse.jst.common.project.facet.IJavaFacetInstallDataModelProperties;
28
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
21
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
29
import org.eclipse.jst.j2ee.web.project.facet.IWebFacetInstallDataModelProperties;
22
import org.eclipse.jst.j2ee.web.project.facet.IWebFacetInstallDataModelProperties;
Lines 40-46 Link Here
40
	private IProject _project;
33
	private IProject _project;
41
34
42
	public WebProjectHelper(String name, String location, String binDir, String sourceDir) throws Exception {
35
	public WebProjectHelper(String name, String location, String binDir, String sourceDir) throws Exception {
43
		_project = getProject(location, name);
36
		_project = getProject(location, name, null, false);
44
		
37
		
45
		IDataModel dataModel = DataModelFactory.createDataModel(IWebFacetInstallDataModelProperties.class);   
38
		IDataModel dataModel = DataModelFactory.createDataModel(IWebFacetInstallDataModelProperties.class);   
46
		dataModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, name);     
39
		dataModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, name);     
Lines 61-67 Link Here
61
		return _project;
54
		return _project;
62
	}
55
	}
63
56
64
	public void setSuspendValidation(boolean shouldSuspend) {		
57
	public void setSuspendValidation(boolean shouldSuspend) {
65
		ValidatorManager.getManager().suspendValidation(getProject(), shouldSuspend);
58
		ValidatorManager.getManager().suspendValidation(getProject(), shouldSuspend);
66
	}
59
	}
67
	
60
	
(-)plugin.xml (-1 / +13 lines)
Lines 7-13 Link Here
7
            container="Axis2"
7
            container="Axis2"
8
            platform="J2EE"/>
8
            platform="J2EE"/>
9
      <projectizer
9
      <projectizer
10
            class="org.eclipse.tptp.wsdm.tooling.internal.projectizer.EclipseAxis2Projectizer"
10
            class="org.eclipse.tptp.wsdm.tooling.internal.projectizer.EclipseJ2EEAxis2Projectizer"
11
            name="Axis2 J2EE"
11
            name="Axis2 J2EE"
12
            servicePath="/services"
12
            servicePath="/services"
13
            servicePort="8080"/>
13
            servicePort="8080"/>
Lines 16-19 Link Here
16
         point="org.eclipse.ui.startup">
16
         point="org.eclipse.ui.startup">
17
      <startup class="org.eclipse.tptp.wsdm.tooling.internal.codegeneration.Activator"/>
17
      <startup class="org.eclipse.tptp.wsdm.tooling.internal.codegeneration.Activator"/>
18
   </extension>
18
   </extension>
19
   <extension
20
         point="org.eclipse.tptp.wsdm.editor.codeGeneration">
21
      <description
22
            container="Mini"
23
            platform="J2EE">
24
      </description>
25
      <projectizer
26
            class="org.eclipse.tptp.wsdm.tooling.internal.projectizer.EclipseJ2EEMiniProjectizer"
27
            name="J2EE Mini"
28
            servicePort="8080">
29
      </projectizer>
30
   </extension>
19
</plugin>
31
</plugin>
(-)resources/mini/build.xml (+10 lines)
Added Link Here
1
<?xml version="1.0"?>
2
<project name="project" default="default">
3
    <target name="default">
4
    	<jar destfile="${basedir}/WebContent/WEB-INF/lib/capability.jar">
5
    		<fileset dir="bin">
6
    			<include name="**/*.class"/>
7
    		</fileset>
8
    	</jar>
9
    </target>
10
</project>
(-)src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEAxis2Projectizer.java (+251 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.internal.projectizer;
14
15
16
import java.io.File;
17
import java.io.FileNotFoundException;
18
import java.net.URL;
19
import java.util.Map;
20
21
import org.apache.muse.tools.generator.projectizer.Axis2ProjectizerConstants;
22
import org.apache.muse.tools.generator.projectizer.J2EEAxis2Projectizer;
23
import org.apache.muse.tools.generator.util.ConfigurationData;
24
import org.apache.muse.tools.generator.util.ServicesDescriptorHelper;
25
import org.apache.muse.util.FileUtils;
26
import org.apache.muse.ws.resource.metadata.MetadataDescriptor;
27
import org.apache.muse.ws.wsdl.WsdlUtils;
28
import org.eclipse.core.runtime.FileLocator;
29
import org.eclipse.core.runtime.IProgressMonitor;
30
import org.eclipse.core.runtime.Platform;
31
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.EclipseConfigurationData;
32
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.TargetedFileList;
33
import org.eclipse.tptp.wsdm.tooling.internal.codegeneration.Activator;
34
import org.eclipse.tptp.wsdm.tooling.internal.util.WebProjectHelper;
35
import org.eclipse.tptp.wsdm.tooling.provisional.util.ProgressMonitorHelper;
36
import org.eclipse.tptp.wsdm.tooling.provisional.util.ProjectHelper;
37
import org.w3c.dom.Document;
38
import org.w3c.dom.Element;
39
40
/**
41
 * Construct the projectizer for code generation
42
 */
43
public class EclipseJ2EEAxis2Projectizer extends J2EEAxis2Projectizer {
44
	
45
	
46
	private static final String CONTAINER_BUNDLE = "org.apache.muse.tools";//$NON-NLS-1$
47
	private static final String CONTAINER_RESOURCE = "/containers/muse-platform-axis2-2.2.0.jar";//$NON-NLS-1$
48
		
49
	
50
	private static final String[] LIB_BUNDLE_IDS = { 
51
		"org.apache.muse.api", //$NON-NLS-1$
52
		"org.apache.muse.impl", //$NON-NLS-1$
53
		"org.apache.muse.core", //$NON-NLS-1$
54
		"org.apache.muse.tools", //$NON-NLS-1$
55
		"org.apache.muse.utils" //$NON-NLS-1$
56
		};
57
	
58
	private static final String[] MODULE_BUNDLE_IDS = { 
59
		"org.apache.muse.tools", //$NON-NLS-1$
60
		};
61
	
62
	private File[] _additionalJars;
63
	private Object[][] _instances;
64
	private IProgressMonitor _progressMonitor;
65
	private TargetedFileList[] _filesToCopy;
66
67
	private int _resourceCounter = 0;
68
69
	private String _projectName;
70
71
	private String _projectLocation;
72
	
73
	public void projectize(ConfigurationData configuration) throws Exception {
74
		
75
		ConfigurationData.checkConfiguration(this, configuration);
76
		loadParameters(configuration);
77
		ProgressMonitorHelper progressHelper = new ProgressMonitorHelper(_progressMonitor);	
78
		try {
79
			
80
		progressHelper.startProgressMonitor(10);
81
82
		WebProjectHelper helper = createProject();
83
		
84
		_targetDirectory = helper.getProjectDirectory();		
85
		
86
		progressHelper.recordProgress();
87
		
88
		helper.setSuspendValidation(true);
89
90
		File webContentDir = copyTemplate(_targetDirectory);
91
		progressHelper.recordProgress();
92
						
93
		File descriptorFile = new File(
94
				webContentDir, 
95
				Axis2ProjectizerConstants.DESCRIPTOR_FILE);
96
		
97
		File javaSourceDir = new File(
98
				_targetDirectory, 
99
				Axis2ProjectizerConstants.JAVA_SRC_DIR);
100
		
101
		createJavaSources(javaSourceDir, _filesMaps);
102
		progressHelper.recordProgress();
103
		
104
		File wsdldir = new File(
105
				webContentDir, 
106
				Axis2ProjectizerConstants.WSDL_DIR);
107
108
		File routerEntriesDir = new File(webContentDir,Axis2ProjectizerConstants.ROUTER_ENTRIES_DIR);
109
		
110
		ServicesDescriptorHelper servicesHelper = new ServicesDescriptorHelper();
111
				
112
		createBuildFile(_targetDirectory, EclipseJ2EEAxis2ProjectizerConstants.BUILD_FILE_RESOURCE, EclipseJ2EEAxis2ProjectizerConstants.BUILD_FILE);
113
		progressHelper.recordProgress();
114
		
115
		for(int i=0; i < _capabilitiesList.length; i++) {
116
			Map capabilities = _capabilitiesList[i];
117
			Document wsdl = _wsdls[i];
118
			createDescriptor(_descriptor, wsdl, descriptorFile, capabilities, Axis2ProjectizerConstants.WSDL_RELATIVE_PATH, i);						
119
			MetadataDescriptor rmd = _metadatas[i];
120
			createRMDFile(rmd, wsdl, wsdldir);
121
			createWSDLFile(wsdl, wsdldir);
122
			if(_instances == null) {
123
				createRouterEntries(routerEntriesDir, WsdlUtils.getServiceName(wsdl.getDocumentElement()), _capabilitiesList[i]);
124
			}
125
			updateServicesDescriptor(servicesHelper, wsdl, capabilities);
126
		}		
127
					
128
		if(_instances != null) {
129
			createRouterEntries(routerEntriesDir, _instances);
130
		}
131
		progressHelper.recordProgress(4);
132
		
133
		File servicesFile = new File(webContentDir, Axis2ProjectizerConstants.SERVICES_FILE);
134
		createServicesDescriptor(servicesHelper, servicesFile);
135
		progressHelper.recordProgress();
136
		
137
		helper.refreshProject();
138
		progressHelper.recordProgress();
139
		
140
		helper.setSuspendValidation(false);
141
		} finally {
142
			progressHelper.finishProgressMonitor();
143
		}
144
	}	
145
146
	protected void loadParameters(ConfigurationData data) {
147
		super.loadParameters(data);
148
		
149
		_additionalJars = (File[])data.getParameter(EclipseConfigurationData.ADDITIONAL_JARS);
150
		_instances = (Object[][])data.getParameter(EclipseConfigurationData.INSTANCES);	
151
		_progressMonitor = (IProgressMonitor)data.getParameter(EclipseConfigurationData.PROGRESS_MONITOR);
152
		_filesToCopy = (TargetedFileList[])data.getParameter(EclipseConfigurationData.AXIS2_FILES);
153
		_projectName = (String)data.getParameter(EclipseConfigurationData.PROJECT_NAME);
154
		_projectLocation = (String)data.getParameter(EclipseConfigurationData.PROJECT_LOCATION);		
155
	}
156
157
	private WebProjectHelper createProject() throws Exception {
158
		WebProjectHelper helper = new WebProjectHelper(_projectName, _projectLocation, EclipseJ2EEAxis2ProjectizerConstants.JAVA_BIN_DIR, Axis2ProjectizerConstants.JAVA_SRC_DIR);
159
		
160
		return helper;
161
	}
162
	
163
	protected void createRouterEntries(File routerEntriesDir,Object[][] instances) throws Exception {
164
		routerEntriesDir.mkdirs();
165
		
166
		for (int i = 0; i < _instances.length; i++) {
167
			Object[] instancePair = _instances[i];
168
169
			//
170
			// This is really tacky, but it's the only real way to do this
171
			// since there are no pairs. The File use is to get the last element
172
			// of the path in a nice, non-hack way.
173
			//
174
			String path = (String) instancePair[0];
175
			String resourcePathName = new File(path).getName();
176
177
			Element instanceElement = (Element) instancePair[1];
178
179
			File serviceDir = new File(routerEntriesDir, resourcePathName);
180
			File routerEntryFile = new File(serviceDir, getResourceFileName());
181
182
			writeToFileCheck(instanceElement, routerEntryFile);
183
		}
184
	}
185
	
186
	protected String getResourceFileName() {
187
		return Axis2ProjectizerConstants.RESOURCE_FILE.replaceFirst(PLACE_HOLDER, String.valueOf(_resourceCounter++));
188
	}
189
	
190
	protected File copyTemplate(File destination) throws Exception {	
191
		URL url = Platform.getBundle(Activator.PLUGIN_ID).getEntry(EclipseJ2EEAxis2ProjectizerConstants.WEBCONTENT_DIR_RESOURCE);
192
		url = FileLocator.toFileURL(url);
193
		
194
		File source = ProjectHelper.toFile(url);
195
		FileUtils.copyDirectory(source, destination);
196
		
197
		File webContentDir = new File(destination, source.getName());
198
		File webContentDestination = new File(webContentDir, "WEB-INF"); //$NON-NLS-1$
199
		
200
		for (int i=0; i < LIB_BUNDLE_IDS.length; i++) {		
201
			url = Platform.getBundle(LIB_BUNDLE_IDS[i]).getEntry(EclipseJ2EEAxis2ProjectizerConstants.PROJECT_LIB_DIR_RESOURCE);
202
			url = FileLocator.toFileURL(url);
203
	
204
			File libSource = ProjectHelper.toFile(url);			
205
			FileUtils.copyDirectory(libSource, webContentDestination);
206
		}
207
		
208
		for (int i=0; i < MODULE_BUNDLE_IDS.length; i++) {		
209
			url = Platform.getBundle(MODULE_BUNDLE_IDS[i]).getEntry(EclipseJ2EEAxis2ProjectizerConstants.PROJECT_MODULE_DIR_RESOURCE);
210
			url = FileLocator.toFileURL(url);
211
	
212
			File libSource = ProjectHelper.toFile(url);			
213
			FileUtils.copyDirectory(libSource, webContentDestination);
214
		}
215
				
216
		File libDestination = new File(webContentDestination, "lib");
217
		
218
		url = Platform.getBundle(CONTAINER_BUNDLE).getEntry(CONTAINER_RESOURCE);
219
		url = FileLocator.toFileURL(url);
220
		
221
		File libSource = ProjectHelper.toFile(url);			
222
		FileUtils.copy(libSource, libDestination);		
223
		
224
		if(_additionalJars != null) {
225
			for (int i=0; i < _additionalJars.length; i++) {
226
				if(!_additionalJars[i].exists()) {
227
					throw new FileNotFoundException(_additionalJars[i].getAbsolutePath());
228
				}
229
				
230
				FileUtils.copyFile(_additionalJars[i], libDestination);
231
			}
232
		}
233
		
234
		for (int i=0; i < _filesToCopy.length; i++) {
235
			String dest = _filesToCopy[i].getRelativePath();
236
			File destDir = new File(webContentDir, dest);
237
			String[] files = _filesToCopy[i].getFiles();
238
			
239
			for (int j=0; j < files.length; j++) {
240
				File file = new File(files[j]);
241
				if(!file.exists()) {
242
					throw new FileNotFoundException(file.getAbsolutePath());
243
				}
244
				
245
				FileUtils.copyFile(file, destDir);
246
			}
247
		}
248
249
		return webContentDir;	
250
	}
251
}
(-)src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEAxis2ProjectizerConstants.java (+34 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.internal.projectizer;
14
15
16
public interface EclipseJ2EEAxis2ProjectizerConstants {
17
	
18
	String RESOURCES_DIR = "/resources/axis2/"; //$NON-NLS-1$
19
	
20
	String BUILD_FILE_RESOURCE = RESOURCES_DIR + "build.xml"; //$NON-NLS-1$
21
	
22
	String BUILD_FILE = "build.xml"; //$NON-NLS-1$
23
24
	String LAUNCH_FILE_RESOURCE = RESOURCES_DIR + ".externalToolBuilders/jarBuilder.launch"; //$NON-NLS-1$
25
26
	String WEBCONTENT_DIR_RESOURCE = RESOURCES_DIR + "WebContent"; //$NON-NLS-1$
27
28
	String PROJECT_LIB_DIR_RESOURCE = "/lib"; //$NON-NLS-1$
29
	
30
	String PROJECT_MODULE_DIR_RESOURCE = "/modules"; //$NON-NLS-1$
31
32
	String JAVA_BIN_DIR = "bin"; //$NON-NLS-1$
33
34
}
(-)resources/mini/web.xml (+13 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
3
	<display-name>Apache Muse Servlet</display-name>
4
	<servlet>
5
		<display-name>Apache Muse Servlet</display-name>
6
		<servlet-name>ApacheMuseServlet</servlet-name>
7
		<servlet-class>org.apache.muse.core.platform.mini.MiniServlet</servlet-class>
8
	</servlet>
9
	<servlet-mapping>
10
		<servlet-name>ApacheMuseServlet</servlet-name>
11
		<url-pattern>/*</url-pattern>
12
	</servlet-mapping>
13
</web-app>
(-)src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEMiniProjectizerConstants.java (+36 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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
 * 	Andrew Eberbach (aeberbac@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
package org.eclipse.tptp.wsdm.tooling.internal.projectizer;
13
14
public interface EclipseJ2EEMiniProjectizerConstants {
15
16
	String RESOURCE_FILE = "resource-instance-XXX.xml";//$NON-NLS-1$
17
	String WSDL_RELATIVE_PATH = "/wsdl/";//$NON-NLS-1$
18
	
19
	String JAVA_SRC_DIR = "JavaSource/";//$NON-NLS-1$
20
	String WEBCONTENT_DIR = "WebContent/";//$NON-NLS-1$
21
	String WEBINF_DIR = WEBCONTENT_DIR + "WEB-INF/";//$NON-NLS-1$
22
	
23
	String JAVA_BIN_DIR = "/bin";//$NON-NLS-1$
24
	String JAVA_CLASSES_DIR = WEBINF_DIR + "classes/";//$NON-NLS-1$
25
	String DESCRIPTOR_FILE = JAVA_CLASSES_DIR + "muse.xml";//$NON-NLS-1$			
26
	String WSDL_DIR = JAVA_CLASSES_DIR + "wsdl/";//$NON-NLS-1$
27
	String ROUTER_ENTRIES_DIR = JAVA_CLASSES_DIR + "router-entries/";//$NON-NLS-1$
28
	
29
	String RESOURCES_DIR = "/resources/mini/";//$NON-NLS-1$
30
	String WEBXML_RESOURCE = RESOURCES_DIR + "web.xml";//$NON-NLS-1$
31
	String WEBXML_FILE = "web.xml";//$NON-NLS-1$
32
	String PROJECT_LIB_DIR_RESOURCE = "/lib/";//$NON-NLS-1$
33
	String WEBINFLIB_DIR = WEBINF_DIR + "lib/";//$NON-NLS-1$
34
	String BUILD_FILE_RESOURCE = RESOURCES_DIR + "build.xml"; //$NON-NLS-1$;
35
	String BUILD_FILE = "build.xml";
36
}

Return to bug 179329