Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 69193 Details for
Bug 179329
osgi generation failed with NPE
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Refactoring of previous patch to change provisional API to internal API
179329_refactored.patch (text/plain), 425.54 KB, created by
Balan Subramanian
on 2007-05-29 19:44:26 EDT
(
hide
)
Description:
Refactoring of previous patch to change provisional API to internal API
Filename:
MIME Type:
Creator:
Balan Subramanian
Created:
2007-05-29 19:44:26 EDT
Size:
425.54 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.wsdm.editor >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MrtMerge.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MrtMerge.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MrtMerge.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MrtMerge.java 13 Apr 2007 03:54:00 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,253 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Andrew Eberbach (aeberbac@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.io.ByteArrayOutputStream; >-import java.lang.reflect.InvocationTargetException; >-import java.util.ArrayList; >-import java.util.Collection; >-import java.util.Iterator; >-import java.util.List; >- >-import javax.wsdl.WSDLException; >-import javax.wsdl.factory.WSDLFactory; >-import javax.wsdl.xml.WSDLReader; >-import javax.wsdl.xml.WSDLWriter; >-import javax.xml.namespace.QName; >- >-import org.apache.muse.tools.generator.WsdlMerge; >-import org.apache.muse.util.xml.XmlUtils; >-import org.apache.muse.ws.addressing.soap.SoapFault; >-import org.apache.muse.ws.notification.WsnConstants; >-import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >-import org.apache.muse.ws.resource.metadata.WsrmdConstants; >-import org.apache.muse.ws.resource.metadata.impl.SimpleMetadataDescriptor; >-import org.apache.muse.ws.wsdl.WsdlUtils; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils; >-import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >-import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; >-import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >-import org.w3c.dom.Document; >-import org.w3c.dom.Element; >- >-/** >- * This class provides the utility method for merging the MRT to get the smashed WSDL and RMD documents. >- * >- */ >- >-public class MrtMerge >-{ >- private static WSDLReader _reader; >- private static WSDLWriter _writer; >- private static WSDLFactory _factory; >- >- /** >- * Creates the smashed WSDL file for representing the resource type >- * >- * @param mrtFile - >- * Manageable Resource Type file >- * @throws Exception - >- * Throws exception while getting WSDL files and also while >- * merging them >- */ >- public static Document createMergedWSDL(ManageableResourceType mrt, String address) >- throws Exception >- { >- checkReadersWriters(); >- >- List wsdlFiles = null; >- >- try >- { >- wsdlFiles = getWsdlFiles(mrt); >- } >- catch (Exception e) >- { >- throw new Exception(Messages.HOOKUP_WIZARD_ERROR_7, e); >- } >- >- String namespaceURI = mrt.getNamespace(); >- >- Document[] wsdlFragments = (Document[])wsdlFiles.toArray(new Document[wsdlFiles.size()]); >- javax.wsdl.Definition def = WsdlMerge.merge(namespaceURI, wsdlFragments, >- address); >- >- return _writer.getDocument(def); >- } >- >- private static void checkReadersWriters() throws InvocationTargetException >- { >- try >- { >- _factory = WSDLFactory.newInstance(); >- _reader = _factory.newWSDLReader(); >- _writer = _factory.newWSDLWriter(); >- } >- catch (WSDLException e) >- { >- throw new InvocationTargetException(new Exception( >- Messages.HOOKUP_WIZARD_ERROR_3, e)); >- } >- } >- >- /** >- * Given an MRT file return a list of <code>Definition</code> objects that >- * correspond to the WSDL files related to this MRT (that is, its >- * Capabilities). >- * >- * @param mrtFile >- * @return >- * @throws Exception >- */ >- private static List getWsdlFiles(ManageableResourceType mrt) >- throws Exception >- { >- //Get a list of all of the capabilities in this MRT >- //This should just be a list of URIs >- List capabilityList = mrt.getImplements(); >- >- //Here is our list of clean WSDL documents >- //we are returning >- ArrayList wsdls = new ArrayList(); >- >- //Use an EclipseEnvironment to do the resolution of paths >- EclipseEnvironment eclipseEnv = new EclipseEnvironment(); >- >- //Iterate over each capability and load it into a Definition >- for (Iterator i = capabilityList.iterator(); i.hasNext();) { >- String nextPath = i.next().toString(); >- >- Document document = WsdlUtils.createWSDL(eclipseEnv, nextPath, true); >- >- //clean up imports >- //see the actual functions to understand how >- //the removal is done >- Element cleanDocument = WsdlUtils.removeSchemaReferences(document.getDocumentElement()); >- cleanDocument = WsdlUtils.removeWsdlReferences(cleanDocument); >- >- wsdls.add(cleanDocument.getOwnerDocument()); >- } >- >- return wsdls; >- } >- >- /** >- * Creates the merged RMD file for representing the manageable resource type >- * >- * @param mrtFile - >- * Manageable Resource Type file >- * @throws Exception - >- * Throws exception while getting capabilities defined in MRT and also while >- * merging their RMDs >- */ >- public static MetadataDescriptor createMergedRMD(ManageableResourceType mrt) throws Exception >- { >- List rmds = new ArrayList(); >- Capability[] capabilities = MrtUtils.getCapabilities(mrt); >- List allTopicExpressions = new ArrayList(); >- for(int i=0;i<capabilities.length;i++) >- { >- CapabilityDefinition capabilityDef = (CapabilityDefinition)capabilities[i].getWsdlDefinition(); >- URI capabilityFileLocationURI = capabilityDef.getWSDLResourceProtocolURI(); >- String metadataDescriptorLocation = capabilityDef.getMetadataDescriptorLocation(); >- if(metadataDescriptorLocation == null || metadataDescriptorLocation.length() == 0) >- continue; >- URI rmdFileLocationURI = URI.createURI(capabilityFileLocationURI.trimSegments(1).toString()+ "/" + metadataDescriptorLocation); >- org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.DocumentRoot root = MetaDataUtils.getDocumentRoot(rmdFileLocationURI); >- ByteArrayOutputStream baos = MetaDataUtils.saveRMD(root, rmdFileLocationURI.toString(), null); >- String rmdXML = new String(baos.toByteArray()); >- Element definitionElement = (Element) XmlUtils.createDocument(rmdXML).getFirstChild(); >- Element metadataDescriptorElement = XmlUtils.getFirstElement(definitionElement); >- MetadataDescriptor rmdDescriptor = new SimpleMetadataDescriptor(metadataDescriptorElement); >- >- // Get all the topic expressions defined in different capabilities >- String[] topicExpressions = getTopicExpressions(rmdDescriptor); >- for(int j=0;j<topicExpressions.length;j++) >- { >- String prefix = topicExpressions[j].substring(0,topicExpressions[j].indexOf(':')); >- String namespace = (String)root.getXMLNSPrefixMap().get(prefix); >- String topicPath = topicExpressions[j].substring(topicExpressions[j].indexOf(':')+1); >- allTopicExpressions.add(new TopicExpression(namespace, topicPath)); >- } >- rmdDescriptor.removeProperty(WsnConstants.TOPIC_EXPRESSION_QNAME); >- >- rmds.add(rmdDescriptor); >- } >- MetadataDescriptor[] descriptors = (MetadataDescriptor[]) rmds.toArray(new MetadataDescriptor[rmds.size()]); >- QName qname = new QName(mrt.getNamespace(), "PortType"); >- // TODO Verify with Andrew that is it the way that MUSE creates the smashed wsdl by this name >- String name = mrt.getIdentifier()+".wsdl"; >- MetadataDescriptor mergedRMD = WsdlMerge.merge(name, qname, descriptors); >- TopicExpression[] topicExpressions = (TopicExpression[]) allTopicExpressions.toArray(new TopicExpression[allTopicExpressions.size()]); >- // Merge all the topic expressions defined in different capabilities >- mergeTopicExpressions(mergedRMD, topicExpressions); >- return mergedRMD; >- } >- >- private static String[] getTopicExpressions(MetadataDescriptor rmdDescriptor) throws SoapFault >- { >- if(rmdDescriptor.hasProperty(WsnConstants.TOPIC_EXPRESSION_QNAME)) >- { >- Collection collection = rmdDescriptor.getInitialValues(WsnConstants.TOPIC_EXPRESSION_QNAME, String.class); >- return (String[])collection.toArray(new String[collection.size()]); >- } >- return new String[0]; >- } >- >- private static void mergeTopicExpressions(MetadataDescriptor rmdDescriptor, TopicExpression[] topicExpressions) throws SoapFault >- { >- if(topicExpressions!=null && topicExpressions.length>0) >- { >- rmdDescriptor.addProperty(WsnConstants.TOPIC_EXPRESSION_QNAME, WsrmdConstants.READ_ONLY, WsrmdConstants.MUTABLE); >- List initValues = new ArrayList(); >- Document doc = XmlUtils.createDocument(); >- for(int i=0;i<topicExpressions.length;i++) >- { >- String namespace = topicExpressions[i].getTopicNamespace(); >- String topicPath = topicExpressions[i].getTopicPath(); >- String expression = "pfx:"+topicPath; >- Element propertyElement = XmlUtils.createElement(doc, WsnConstants.TOPIC_EXPRESSION_QNAME); >- propertyElement.setAttribute("xmlns:pfx", namespace); >- XmlUtils.setElementText(propertyElement, expression); >- initValues.add(propertyElement); >- } >- rmdDescriptor.setInitialValues(WsnConstants.TOPIC_EXPRESSION_QNAME, initValues); >- } >- } >-} >- >-class TopicExpression >-{ >- private String _topicNamespace; >- private String _topicPath; >- >- TopicExpression(String topicNamespace, String topicPath) >- { >- _topicNamespace = topicNamespace; >- _topicPath = topicPath; >- } >- >- String getTopicNamespace() >- { >- return _topicNamespace; >- } >- >- String getTopicPath() >- { >- return _topicPath; >- } >-} >- >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Axis2LicenseDialog.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Axis2LicenseDialog.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Axis2LicenseDialog.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Axis2LicenseDialog.java 23 Mar 2007 17:55:24 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,140 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.io.BufferedReader; >-import java.io.InputStreamReader; >-import java.net.URL; >- >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.browser.Browser; >-import org.eclipse.swt.events.SelectionAdapter; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.Button; >-import org.eclipse.swt.widgets.Display; >-import org.eclipse.swt.widgets.Shell; >-import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; >-import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >-import org.osgi.framework.Bundle; >- >-/** >- * This class is used to display the Axis-2 License. >- */ >-public class Axis2LicenseDialog >-{ >- private Shell _shell; >- >- private Browser _text; >- >- private Button _btnAgree; >- >- private Button _btnDecline; >- >- public static int AGREE = 0; >- >- public static int DECLINE = 1; >- >- private int _retInt = DECLINE; >- >- /** >- * Constructor of the class. It initialises the UI for >- * displaying the license >- */ >- public Axis2LicenseDialog() >- { >- initUI(); >- } >- >- private void initUI() >- { >- _shell = new Shell(Display.getCurrent(), SWT.CLOSE | SWT.SYSTEM_MODAL | SWT.APPLICATION_MODAL | SWT.RESIZE); >- _shell.setLayout(new GridLayout(2, true)); >- _shell.setText(Messages.AXIS2_LICENSE_LABEL); >- _shell.setSize(300, 300); >- >- _text = new Browser(_shell, SWT.BORDER | SWT.MULTI | SWT.WRAP); >- try >- { >- _text.setText(readLicence()); >- } >- catch (Throwable e) >- { >- WsdmToolingLog.logError(e.getMessage(), e); >- } >- >- _btnAgree = new Button(_shell, SWT.PUSH); >- _btnAgree.setText(Messages.LICENSE_AGREE_TEXT); >- _btnAgree.addSelectionListener(new SelectionAdapter() >- { >- public void widgetSelected(SelectionEvent se) >- { >- _retInt = AGREE; >- _shell.dispose(); >- } >- } >- ); >- >- _btnDecline = new Button(_shell, SWT.PUSH); >- _btnDecline.setText(Messages.LICENSE_DECLINE_TEXT); >- _btnDecline.addSelectionListener(new SelectionAdapter() >- { >- public void widgetSelected(SelectionEvent se) >- { >- _retInt = DECLINE; >- _shell.dispose(); >- } >- } >- ); >- >- GridData gd = new GridData(GridData.FILL_BOTH); >- gd.horizontalSpan = 2; >- _text.setLayoutData(gd); >- >- gd = new GridData(); >- gd.horizontalAlignment = SWT.RIGHT; >- _btnAgree.setLayoutData(gd); >- >- gd = new GridData(); >- gd.horizontalAlignment = SWT.LEFT; >- _btnDecline.setLayoutData(gd); >- } >- >- /** >- * Method to show the Dialog that displays the Liscense >- */ >- public int showWindow() >- { >- _shell.open(); >- while(!_shell.isDisposed()) >- { >- if(!Display.getCurrent().readAndDispatch()) >- Display.getCurrent().sleep(); >- } >- return _retInt; >- } >- >- private String readLicence() throws Throwable >- { >- Bundle bundle = Activator.INSTANCE.getPlugin().getBundle(); >- URL licenceURL = bundle.getEntry("licence/Licence.txt"); >- BufferedReader in = new BufferedReader(new InputStreamReader(licenceURL.openStream())); >- StringBuffer buffer = new StringBuffer(); >- String line = null; >- while ((line = in.readLine()) != null) >- buffer.append(line); >- return buffer.toString(); >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/CodeGenerationData.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/CodeGenerationData.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/CodeGenerationData.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/CodeGenerationData.java 7 May 2007 09:15:10 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,105 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: CodeGenerationData.java,v 1.2 2007/05/07 09:15:10 dnsmith Exp $ >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import org.apache.muse.tools.generator.analyzer.Analyzer; >-import org.apache.muse.tools.generator.projectizer.Projectizer; >-import org.apache.muse.tools.generator.synthesizer.Synthesizer; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IConfigurationElement; >- >-class CodeGenerationData { >- private Analyzer _analyzer; >- private Synthesizer _synthesizer; >- private Projectizer _projectizer; >- >- private int _servicePort; >- private String _servicePath; >- private String _container; >- private String _platform; >- >- public CodeGenerationData(IConfigurationElement[] elements) { >- for (int i = 0; i < elements.length; i++) >- { >- String name = elements[i].getName(); >- >- if(name.equals("description")) { >- extractDescription(elements[i]); >- } else if (name.equals("projectizer")) { >- extractProjectizer(elements[i]); >- } else if (name.equals("synthesizer")) { >- extractSynthesizer(elements[i]); >- } else if (name.equals("analyzer")) { >- extractAnalyzer(elements[i]); >- } >- } >- } >- >- private void extractDescription(IConfigurationElement configurationElement) { >- _container = configurationElement.getAttribute("container"); >- _platform = configurationElement.getAttribute("platform"); >- } >- >- private void extractProjectizer(IConfigurationElement configurationElement) { >- String port = configurationElement.getAttribute("servicePort"); >- if(port != null && port.length() != 0) { >- _servicePort = Integer.parseInt(port); >- } >- _servicePath = configurationElement.getAttribute("servicePath"); >- _projectizer = (Projectizer) createExecutable(configurationElement); >- } >- >- private void extractSynthesizer(IConfigurationElement configurationElement) { >- _synthesizer = (Synthesizer) createExecutable(configurationElement); >- } >- >- private void extractAnalyzer(IConfigurationElement configurationElement) { >- _analyzer = (Analyzer) createExecutable(configurationElement); >- } >- >- private Object createExecutable(IConfigurationElement configurationElement) { >- try { >- return configurationElement.createExecutableExtension("class"); >- } catch (CoreException e) { >- throw new RuntimeException(configurationElement.getAttribute("class")); >- } >- } >- >- public Analyzer getAnalyzer() { >- return _analyzer; >- } >- >- public Synthesizer getSynthesizer() { >- return _synthesizer; >- } >- >- public Projectizer getProjectizer() { >- return _projectizer; >- } >- >- public int getServicePort() { >- return _servicePort; >- } >- >- public String getServicePath() { >- return _servicePath; >- } >- >- public String getContainer() { >- return _container; >- } >- >- public String getPlatform() { >- return _platform; >- } >-} >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Generation.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Generation.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Generation.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Generation.java 1 May 2007 16:40:34 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,72 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Andrew Eberbach (aeberbac@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import org.eclipse.core.resources.IFile; >-import org.eclipse.jface.action.IAction; >-import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.jface.wizard.WizardDialog; >-import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >-import org.eclipse.ui.IObjectActionDelegate; >-import org.eclipse.ui.IWorkbenchPart; >- >-/** >- * Access point code from the code generation option in popup >- */ >-public class Generation implements IObjectActionDelegate >-{ >- >- private IWorkbenchPart _targetPart; >- >- private StructuredSelection _selection; >- >- /** >- * (non-Javadoc) >- * @see org.eclipse.ui.IObjectActionDelegate#run(org.eclipse.jface.action.IAction) >- */ >- public void run(IAction action) >- { >- IFile mrtFile = (IFile) _selection.getFirstElement(); >- MrtUtils.searchAndSaveMRTEditor(mrtFile); >- MRTCodeGenerationDelegate codeGenerationDelegate = new MRTCodeGenerationDelegate( >- mrtFile); >- >- NewProjectWizard npw = new NewProjectWizard(codeGenerationDelegate); >- WizardDialog wd = new WizardDialog(_targetPart.getSite().getShell(), >- npw); >- wd.open(); >- } >- >- /** >- * (non-Javadoc) >- * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) >- */ >- public void setActivePart(IAction action, IWorkbenchPart targetPart) >- { >- _targetPart = targetPart; >- } >- >- /** >- * (non-Javadoc) >- * @see org.eclipse.ui.IObjectActionDelegate#selectionChanged >- (org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) >- */ >- public void selectionChanged(IAction action, ISelection selection) >- { >- if (selection instanceof StructuredSelection) >- { >- _selection = (StructuredSelection) selection; >- } >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Axis2ServerLocationPage.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Axis2ServerLocationPage.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Axis2ServerLocationPage.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Axis2ServerLocationPage.java 19 Apr 2007 19:06:17 -0000 1.6 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,232 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.jface.wizard.WizardPage; >-import org.eclipse.osgi.util.TextProcessor; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.ModifyEvent; >-import org.eclipse.swt.events.ModifyListener; >-import org.eclipse.swt.events.SelectionAdapter; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.Button; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.DirectoryDialog; >-import org.eclipse.swt.widgets.Label; >-import org.eclipse.swt.widgets.Text; >-import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; >-import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; >-import org.eclipse.tptp.wsdm.tooling.preferences.internal.Axis2ServerLocationPreferencePage; >-import org.eclipse.tptp.wsdm.tooling.validation.util.internal.ValidationUtils; >- >-/** >- * This is Wizard Page to show the Axis2 server location details >- * >- */ >-public class Axis2ServerLocationPage extends WizardPage >-{ >- >- protected Text _serverNameField; >- private Button _browseButton; >- private Button _preferenceUpdate; >- private TargetedFileList[] _filesToCopy; >- >- private String userDefinedLocation =""; >- >- /** >- * Instantiates the class. >- */ >- public Axis2ServerLocationPage() >- { >- super("wizardPage"); >- setTitle(Messages.HOOKUP_WIZARD_TXT1); >- setDescription(Messages.HOOKUP_WIZARD_TXT2); >- } >- >- /** >- * Creates wizard controls. >- */ >- public void createControl(Composite parent) >- { >- Composite page = new Composite(parent, SWT.NULL); >- GridLayout layout = new GridLayout(1, false); >- page.setLayout(layout); >- createPageControls(page); >- //dialogChanged(); >- setControl(page); >- } >- >- private void createPageControls(Composite page) >- { >- Composite column = new Composite(page, SWT.NULL); >- GridLayout layout = new GridLayout(2, false); >- column.setLayout(layout); >- createServerLocationColumn(column); >- } >- >- private void createServerLocationColumn(Composite parent) >- { >- GridData data = new GridData(GridData.FILL_HORIZONTAL); >- data.horizontalSpan = 2; >- // new server location label >- Label serverLabel = new Label(parent, SWT.NONE); >- serverLabel.setText(Messages.CODE_GEN_AXIS2_LOCATION); >- serverLabel.setFont(parent.getFont()); >- serverLabel.setLayoutData(data); >- >- // server location entry field >- data = new GridData(GridData.FILL_HORIZONTAL); >- data.widthHint = 350; >- data.horizontalSpan = 1; >- _serverNameField = new Text(parent, SWT.BORDER); >- _serverNameField.setLayoutData(data); >- _serverNameField.setFont(parent.getFont()); >- _serverNameField.addModifyListener(new ModifyListener() >- { >- public void modifyText(ModifyEvent e) >- { >- boolean pageCompleted = true; >- userDefinedLocation = _serverNameField.getText(); >- String errorMsg = validateLocation(); >- if(errorMsg == null) >- { >- setErrorMessage(errorMsg); >- pageCompleted = true; >- } >- else >- { >- setErrorMessage(errorMsg); >- pageCompleted = false; >- } >- makePageComplete(pageCompleted); >- } >- }); >- >- // _serverNameField.setText(getPreferenceServerLocation()); >- >- // browse button >- _browseButton = new Button(parent, SWT.PUSH); >- _browseButton.setText(Messages.HOOKUP_WIZARD_TXT5); >- _browseButton.addSelectionListener(new SelectionAdapter() >- { >- public void widgetSelected(SelectionEvent event) >- { >- handleLocationBrowseButtonPressed(); >- } >- }); >- >- // server location entry field >- data = new GridData(GridData.FILL_HORIZONTAL); >- //data.widthHint = 350; >- data.horizontalSpan = 2; >- _preferenceUpdate = new Button(parent, SWT.CHECK); >- _preferenceUpdate.setText(Messages.CODE_GEN_UPDATE_PREF); >- _preferenceUpdate.setLayoutData(data); >- _preferenceUpdate.setFont(parent.getFont()); >- } >- >- protected String getPreferenceServerLocation() >- { >- IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); >- String location = store.getString(Axis2ServerLocationPreferencePage.SERVER_LOCATION_PREFERENCE_KEY).trim(); >- if(location != null && !location.equals("")) >- return location; >- return ""; >- } >- >- private void handleLocationBrowseButtonPressed() >- { >- >- String selectedDirectory = null; >- >- DirectoryDialog dialog = new DirectoryDialog(_serverNameField.getShell()); >- dialog.setMessage(Messages.CODE_GEN_DIR_LOCATION); >- //dialog.setFilterPath(dirName); >- selectedDirectory = dialog.open(); >- >- if (selectedDirectory != null) >- updateLocationField(selectedDirectory); >- >- } >- >- private void updateLocationField(String selectedPath) >- { >- _serverNameField.setText(TextProcessor.process(selectedPath)); >- } >- >- /** >- * Returns the server location. >- * @return >- */ >- public String getServerLocation() >- { >- return _serverNameField.getText(); >- } >- >- /** >- * Checks to see if Update Preferences checkbox is selected >- * @return >- */ >- public boolean isUpdatePreference() >- { >- return _preferenceUpdate.getSelection(); >- } >- >- private String validateLocation() >- { >- String serverHome = _serverNameField.getText(); >- >- ISoapServerDependency axisValidators[] = ValidationUtils.getAllAxisValidators(); >- for(int i = 0 ; i < axisValidators.length ; i++){ >- >- ISoapServerDependency axis2Dependency = (Axis2ServerDependency)axisValidators[i]; >- String errorMessage = axis2Dependency.validateSoapServerHome(serverHome); >- if(errorMessage!=null) >- return errorMessage; >- _filesToCopy = axis2Dependency.getFilesToCopy(); >- if(_filesToCopy == null) >- _filesToCopy = new TargetedFileList[0]; >- } >- return null; >- } >- >- /** >- * Returns the Axis2 files to copied to generated code >- * @return >- */ >- public TargetedFileList[] getAxis2FilesToCopy() >- { >- return _filesToCopy; >- } >- >- /** >- * Method to Set the Wizard page to complete state >- * @param validPage >- */ >- public synchronized void makePageComplete(boolean completePage) >- { >- if(completePage){ >- setPageComplete(true); >- } >- else >- setPageComplete(false); >- } >- >- protected String getUserDefinedLocation() >- { >- return userDefinedLocation; >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/EclipseEnvironment.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/EclipseEnvironment.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/EclipseEnvironment.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/EclipseEnvironment.java 8 May 2007 19:08:16 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,131 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.io.File; >-import java.io.InputStream; >-import java.net.URI; >-import java.net.URL; >-import java.net.URLConnection; >- >-import org.apache.muse.core.AbstractEnvironment; >-import org.apache.muse.util.xml.XmlUtils; >-import org.apache.muse.ws.addressing.EndpointReference; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.FileLocator; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >-import org.osgi.framework.Bundle; >-import org.w3c.dom.Document; >- >-public class EclipseEnvironment extends AbstractEnvironment >-{ >- >- public EndpointReference getDeploymentEPR() >- { >- // TODO Auto-generated method stub >- return null; >- } >- >- public File getRealDirectory() >- { >- // TODO Auto-generated method stub >- return null; >- } >- >- public Document getDocument(String path) >- { >- try >- { >- if(isHttpScheme(path)) >- { >- URLConnection conn = new URL(path).openConnection(); >- InputStream stream = conn.getInputStream(); >- return XmlUtils.createDocument(stream); >- } >- } >- catch(Exception e) >- { >- WsdmToolingLog.logError(e.getMessage(), e); >- } >- >- >- try >- { >- if (!isBuiltin(path)) >- { >- IFile wsdlFile = EclipseUtils.getIFile(ResourcesPlugin >- .getWorkspace().getRoot(), path); >- return XmlUtils.createDocument(wsdlFile.getLocation().toFile() >- .getAbsoluteFile()); >- } >- else >- { >- String substr = path.substring(path.indexOf("platform:/plugin/")+"platform:/plugin/".length()); >- String contributorPlugin = substr.substring(0,substr.indexOf('/')); >- String relativePath = substr.substring(substr.indexOf('/')+1); >- >- Bundle bundle = Platform.getBundle(contributorPlugin); >- return XmlUtils.createDocument(FileLocator.openStream(bundle, >- new Path(relativePath), false)); >- } >- } >- catch (Exception e) >- { >- WsdmToolingLog.logError(e.getMessage(), e); >- } >- return null; >- } >- >- /** >- * Utility method to see if the path is referring to something in the >- * plugins or in the workspace. >- * >- * @param path >- * A path to examine >- * @return true if the path starts with <code>"platform:/plugin"</code> >- */ >- private boolean isBuiltin(String path) >- { >- return path.startsWith("platform:/plugin"); >- } >- >- private boolean isHttpScheme(String path) >- { >- try{ >- URI uri = URI.create(path); >- String scheme = uri.getScheme(); >- if(scheme != null && uri.getScheme().equals("http")) >- return true; >- }catch(Exception e){ >- // nuthing to do, just return false >- } >- return false; >- } >- >- public String createRelativePath(String original, String relative) >- { >- >- // If the relative path starts with "platform:/" then it >- // is an absolute path, so just return it instead. >- if (relative.startsWith("platform:/")) >- { >- return relative; >- } >- >- return super.createRelativePath(original, relative); >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Axis2ServerDependency.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Axis2ServerDependency.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Axis2ServerDependency.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/Axis2ServerDependency.java 16 Mar 2007 18:16:58 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,158 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.io.File; >-import java.io.FileFilter; >-import java.util.LinkedList; >-import java.util.List; >- >-import org.eclipse.osgi.util.NLS; >-import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; >- >-/** >- * This class verifies the Axis2 Soap Library dependency. >- */ >- >-public class Axis2ServerDependency extends SoapServerDependency implements ISoapServerDependency >-{ >- private List _filesToCopy = new LinkedList(); >- >- /** >- * @see ISoapServerDependency#validateSoapServerHome(String) >- */ >- public String validateSoapServerHome(String serverHome) >- { >- if(serverHome == null || serverHome.length() == 0) >- return Messages.CODE_GEN_AXIS2_PROJECT_DIR; >- >- File serverHomeDir = new File(serverHome); >- if(!serverHomeDir.exists()){ >- return NLS.bind(Messages.CODE_GEN_AXIS2_LOCATION_ERROR_, serverHome); >- } >- >- TargetedFileList _jarFilesToCopy = new TargetedFileList("WEB-INF/lib/"); >- TargetedFileList _marFilesToCopy = new TargetedFileList("WEB-INF/modules/"); >- TargetedFileList _restFilesToCopy = new TargetedFileList("WEB-INF/"); >- >- String[] relativeFilePaths = (String[]) _requiredFiles.toArray(new String[_requiredFiles.size()]); >- for(int i=0;i<relativeFilePaths.length;i++) >- { >- String parentDirectory = getParentDirectory(relativeFilePaths[i]); >- if(parentDirectory == null) >- parentDirectory = serverHome; >- else >- parentDirectory = serverHome+File.separatorChar+parentDirectory; >- >- String fileExtension = getFileExtension(relativeFilePaths[i]); >- if(fileExtension == null) >- fileExtension = "*"; >- FileFilter filter = new CustomFileFilter(fileExtension); >- >- File parentDirectoryFile = new File(parentDirectory); >- if(!parentDirectoryFile.exists()) >- return NLS.bind(Messages.CODE_GEN_AXIS2_LOCATION_ERROR_, parentDirectory); >- >- File[] allFiles = parentDirectoryFile.listFiles(filter); >- String fileName = getFileName(relativeFilePaths[i]); >- File matchedFile = getMatchedPatternFile(allFiles, fileName); >- if(matchedFile == null) >- return NLS.bind(Messages.CODE_GEN_ERROR_INVALID_AXIS_FILE, serverHome+File.separatorChar+relativeFilePaths[i]); >- >- String absolutePath = matchedFile.getAbsolutePath(); >- if(absolutePath.endsWith("jar")) >- _jarFilesToCopy.add(absolutePath); >- else if(absolutePath.endsWith("mar")) >- _marFilesToCopy.add(absolutePath); >- else >- _restFilesToCopy.add(absolutePath); >- } >- >- _filesToCopy.add(_jarFilesToCopy); >- _filesToCopy.add(_marFilesToCopy); >- _filesToCopy.add(_restFilesToCopy); >- >- return null; >- } >- >- private String getParentDirectory(String relativePath) >- { >- if(relativePath.indexOf('/')==-1) >- return null; >- return relativePath.substring(0,relativePath.lastIndexOf('/')); >- } >- >- private String getFileExtension(String relativePath) >- { >- if(relativePath.indexOf('.')==-1) >- return null; >- return relativePath.substring(relativePath.lastIndexOf('.')+1); >- } >- >- private String getFileName(String relativePath) >- { >- if(relativePath.indexOf('/')==-1) >- { >- if(relativePath.indexOf('.')==-1) >- return relativePath; >- else >- return relativePath.substring(0,relativePath.lastIndexOf('.')); >- } >- else >- { >- String fileNameWithExtn = relativePath.substring(relativePath.lastIndexOf('/')+1); >- if(fileNameWithExtn.indexOf('.')==-1) >- return fileNameWithExtn; >- else >- return fileNameWithExtn.substring(0,fileNameWithExtn.lastIndexOf('.')); >- } >- } >- >- private File getMatchedPatternFile(File[] allFiles, String pattern) >- { >- String strippedPattern = pattern.indexOf("-*")==-1?pattern:pattern.substring(0,pattern.lastIndexOf("-*")); >- for(int i=0;i<allFiles.length;i++) >- { >- if(allFiles[i].getName().startsWith(strippedPattern)) >- return allFiles[i]; >- } >- return null; >- } >- >- /** >- * @see ISoapServerDependency#getFilesToCopy() >- */ >- public TargetedFileList[] getFilesToCopy() >- { >- return (TargetedFileList[])_filesToCopy.toArray(new TargetedFileList[_filesToCopy.size()]); >- } >-} >- >-class CustomFileFilter implements FileFilter >-{ >- String fileExtension; >- >- CustomFileFilter(String extension) >- { >- fileExtension = extension; >- } >- >- public boolean accept(File pathname) >- { >- if(!pathname.isFile()) >- return false; >- if(fileExtension.equals("*")) >- return true; >- return pathname.getName().endsWith(fileExtension); >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/BasicMrtInspector.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/BasicMrtInspector.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/BasicMrtInspector.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/BasicMrtInspector.java 13 Apr 2007 03:47:47 -0000 1.9 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,341 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.util.ArrayList; >-import java.util.Iterator; >-import java.util.List; >- >-import javax.wsdl.Definition; >- >-import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >-import org.apache.ws.muse.descriptor.DescriptorFactory; >-import org.apache.ws.muse.descriptor.DocumentRoot; >-import org.apache.ws.muse.descriptor.InitParamType; >-import org.apache.ws.muse.descriptor.InitialInstancesType; >-import org.apache.ws.muse.descriptor.ReferenceParametersType; >-import org.apache.ws.muse.descriptor.ResourceTypeType; >-import org.apache.ws.muse.descriptor.WsdlType; >-import org.apache.ws.muse.descriptor.impl.CapabilityTypeImpl; >-import org.apache.ws.muse.descriptor.impl.ResourceTypeTypeImpl; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IConfigurationElement; >-import org.eclipse.core.runtime.IExtension; >-import org.eclipse.core.runtime.IExtensionPoint; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.emf.common.util.EMap; >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >-import org.eclipse.tptp.wsdm.tooling.nls.messages.dde.internal.Messages; >-import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >- >-/** >- * This class analyzes the given manageable resource type and provide a resource >- * type for muse descriptor. >- */ >- >-public class BasicMrtInspector implements MrtInspector >-{ >- private DocumentRoot _root; >- >- private ResourceTypeType _resourceType; >- >- private ManageableResourceType _mrt; >- /** >- * Constructor of the class >- * @param mrt >- * @param root >- */ >- public BasicMrtInspector(ManageableResourceType mrt,DocumentRoot root) >- { >- _root = root; >- _mrt = mrt; >- } >- >- /** >- * Get the initial instance for this manageable resource type >- * @return InitialInstancesType - Array of the initial instances >- */ >- public InitialInstancesType[] getInitialInstances() >- { >- InitialInstancesType instance = DescriptorFactory.eINSTANCE >- .createInitialInstancesType(); >- ResourceTypeType rtClone = MRTCodeGenerationDelegate >- .cloneResourceType(_resourceType); >- instance.setResourceType(rtClone); >- ReferenceParametersType refParam = DescriptorFactory.eINSTANCE >- .createReferenceParametersType(); >- >- instance.setReferenceParameters(refParam); >- return new InitialInstancesType[] { instance }; >- } >- >- /** >- * Create a new descriptor resource type for the given manageable resource >- * type >- * @param mrtCapabilities >- * @return {@link ResourceTypeType} >- */ >- public ResourceTypeType inspect(Capability[] mrtCapabilities) >- { >- Mrt2DescriptorResourceType mrt2dd = new Mrt2DescriptorResourceType( >- _root, _mrt, mrtCapabilities); >- _resourceType = mrt2dd.getResourceTypeType(); >- return _resourceType; >- } >- >- public void setMrtParentDirectory(String mrtParentDir) >- { >- } >- >- public void persistArtifacts() >- { >- } >- >- public ManageableResourceType getExtraGeneratedMrt() >- { >- return null; >- } >- >- public String getExtraGeneratedMrtPersistanceLocation() >- { >- return null; >- } >- >- public void inspectMetadata(ManageableResourceType mrt, >- MetadataDescriptor rmd) >- { >- } >- >-} >- >-class Mrt2DescriptorResourceType >-{ >- private ManageableResourceType _mrt; >- >- private DocumentRoot _root; >- >- private Capability[] _mrtCapabilities; >- >- Mrt2DescriptorResourceType(DocumentRoot root, ManageableResourceType mrt) >- { >- this(root, mrt, null); >- } >- >- Mrt2DescriptorResourceType(DocumentRoot root, ManageableResourceType mrt, >- Capability[] mrtCapabilities) >- { >- _mrt = mrt; >- _root = root; >- if (mrtCapabilities == null) >- try >- { >- _mrtCapabilities = MrtUtils.getCapabilities(mrt); >- } >- catch (Exception e) >- { >- } >- else >- _mrtCapabilities = mrtCapabilities; >- } >- >- ResourceTypeType getResourceTypeType() >- { >- ResourceTypeTypeImpl rtd = (ResourceTypeTypeImpl) DescriptorFactory.eINSTANCE >- .createResourceTypeType(); >- rtd.setUseRouterPersistence(true); >- rtd.setContextPath("/" + _mrt.getIdentifier()); //$NON-NLS-1$ >- rtd >- .setJavaIdFactoryClass(WsdmConstants.MUSE_RESOURCE_ID_FACTORY_CLASS); //$NON-NLS-1$ >- rtd >- .setJavaResourceClass(WsdmConstants.MUSE_RESOURCE_CLASS); //$NON-NLS-1$ >- rtd.getCapability().addAll(getCapabilitiesFromMRT()); >- WsdlType wsdlType = DescriptorFactory.eINSTANCE.createWsdlType(); >- >- String mrtFileLocation = getMrtFileWorkspaceLocation(); >- if (mrtFileLocation == null) >- ; >- // TODO Log error not resolved location of given mrt >- else >- { >- String mrtFilePathWithoutExtn = mrtFileLocation.substring(0, >- mrtFileLocation.lastIndexOf('.')); >- wsdlType.setWsdlFile(mrtFilePathWithoutExtn + ".wsdl"); >- } >- >- String namespace = _mrt.getNamespace(); >- String prefix = getOrCreatePrefix(_root, namespace); >- String localPart = Messages.DU_PORT_TYPE_LOCAL_PART; // Only >- // "PortType" >- // should come >- // with the >- // //$NON-NLS-1$ >- // prefix. >- wsdlType.setWsdlPortType(prefix + ":" + localPart); >- >- rtd.setWsdl(wsdlType); >- >- // Fix for Bug 174792 Set "validate-wsrp-schema" to "false" for the dd file generated at the codegen from MRT >- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=174792 >- InitParamType noValidateParam = DescriptorFactory.eINSTANCE.createInitParamType(); >- noValidateParam.setParamName("validate-wsrp-schema"); >- noValidateParam.setParamValue("false"); >- rtd.getInitParam().add(noValidateParam); >- >- return rtd; >- } >- >- private static String getOrCreatePrefix(DocumentRoot root, String namespace) >- { >- String prefix = getPrefix(root, namespace); >- if (prefix != null) >- return prefix; >- String newPrefix = generateNewPrefix(root); >- root.getXMLNSPrefixMap().put(newPrefix, namespace); >- return newPrefix; >- } >- >- private static String generateNewPrefix(DocumentRoot root) >- { >- int count = 0; >- while (isPrefixExists(root, "pfx" + count)) //$NON-NLS-1$ >- count++; >- return "pfx" + count; //$NON-NLS-1$ >- } >- >- private static boolean isPrefixExists(DocumentRoot root, String prefix) >- { >- EMap map = root.getXMLNSPrefixMap(); >- Iterator keyIt = map.keySet().iterator(); >- while (keyIt.hasNext()) >- { >- String pfx = (String) keyIt.next(); >- if (pfx.equals(prefix)) >- return true; >- } >- return false; >- } >- >- private static String getPrefix(DocumentRoot root, String namespace) >- { >- if (root == null) >- return null; >- if (namespace == null) >- return null; >- EMap map = root.getXMLNSPrefixMap(); >- Iterator keyIt = map.keySet().iterator(); >- Iterator valuesIt = map.values().iterator(); >- while (valuesIt.hasNext()) >- { >- String ns = (String) valuesIt.next(); >- String prefix = (String) keyIt.next(); >- if (ns.equals(namespace)) >- return prefix; >- } >- return null; >- } >- >- private List getCapabilitiesFromMRT() >- { >- if (_mrt == null) >- return null; >- List capDataList = new ArrayList(); >- for (int i = 0; i < _mrtCapabilities.length; i++) >- { >- Capability capability = _mrtCapabilities[i]; >- String capNS = ""; //$NON-NLS-1$ >- Definition def = capability.getWsdlDefinition().getDefinition(); >- if (def != null) >- { >- capNS = capability.getWsdlDefinition().getNamespace( >- "capabilityURI"); >- if (capNS == null) >- capNS = capability.getNamespace(); >- >- } >- CapabilityTypeImpl ctype = (CapabilityTypeImpl) DescriptorFactory.eINSTANCE >- .createCapabilityType(); >- ctype.setCapabilityUri(capNS); >- String className = getJavaCapabilityClass(capNS); >- ctype.setJavaCapabilityClass(className); >- boolean isValid = validateCapability(capDataList, ctype); >- if (isValid) >- capDataList.add(ctype); >- } >- return capDataList; >- } >- >- private boolean validateCapability(List capDataList, >- CapabilityTypeImpl ctype) >- { >- if (capDataList == null || capDataList.size() == 0) >- { >- capDataList = new ArrayList(); >- return true; >- } >- for (int i = 0; i < capDataList.size(); i++) >- { >- CapabilityTypeImpl tmp = (CapabilityTypeImpl) capDataList.get(i); >- if (tmp.getCapabilityUri().trim().equals( >- ctype.getCapabilityUri().trim())) >- return false; >- } >- return true; >- } >- >- private String getMrtFileWorkspaceLocation() >- { >- try >- { >- IFile mrtFile = EclipseUtils.getIFile(_mrt.eResource().getURI() >- .toString()); >- return mrtFile.getFullPath().toString(); >- } >- catch (CoreException e) >- { >- WsdmToolingLog.logError(e.getLocalizedMessage(), e); >- } >- return null; >- } >- >- private String getJavaCapabilityClass(String uri) >- { >- String ns = "org.eclipse.tptp.wsdm.model"; >- IExtensionPoint iep = Platform.getExtensionRegistry() >- .getExtensionPoint(ns, "mrCapability"); >- if (iep != null) >- { >- IExtension[] extensions = iep.getExtensions(); >- for (int i = 0; i < extensions.length; i++) >- { >- IConfigurationElement[] ice = extensions[i] >- .getConfigurationElements(); >- for (int j = 0; j < ice.length; j++) >- { >- String capURI = ice[j].getAttribute("uri"); >- if (uri.equals(capURI)) >- { >- String className = ice[j] >- .getAttribute("implementingClass"); >- return (className == null) ? "" : className; >- } >- } >- } >- } >- return ""; >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/SoapServerDependency.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/SoapServerDependency.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/SoapServerDependency.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/SoapServerDependency.java 16 Mar 2007 18:04:37 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,51 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.util.ArrayList; >-import java.util.List; >- >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IConfigurationElement; >- >-/** >- * This class collects the relative paths of required Axis-2 files specified in extension point. >- * So if you are extending "axisValidator" extension point, you have to extend this class and implement >- * the interface ISoapServerDependency. >- */ >- >-public abstract class SoapServerDependency implements ISoapServerDependency >-{ >- >- protected List _requiredFiles = new ArrayList(); >- >- public void setInitializationData(IConfigurationElement config, >- String propertyName, Object data) throws CoreException >- { >- if(config.getName()!=null && config.getName().equals("axisValidator")) >- { >- IConfigurationElement requiredFileConfig = config.getChildren()[0]; >- IConfigurationElement[] relativePathConfig = requiredFileConfig.getChildren(); >- for(int i=0;i<relativePathConfig.length;i++) >- { >- if(relativePathConfig[i].getName()!=null && relativePathConfig[i].getName().equals("relativeFilePath")) >- { >- String value = relativePathConfig[i].getValue(); >- if(value!=null && !value.equals("null")) >- _requiredFiles.add(value); >- } >- } >- } >- } >- >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/ServiceGroupInspector.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/ServiceGroupInspector.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/ServiceGroupInspector.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/ServiceGroupInspector.java 13 Apr 2007 03:47:47 -0000 1.8 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,366 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.io.ByteArrayInputStream; >-import java.io.InputStream; >-import java.util.ArrayList; >-import java.util.HashMap; >-import java.util.List; >- >-import javax.xml.namespace.QName; >- >-import org.apache.muse.util.xml.XmlUtils; >-import org.apache.muse.ws.addressing.soap.SoapFault; >-import org.apache.muse.ws.resource.sg.WssgConstants; >-import org.apache.ws.muse.descriptor.CapabilityType; >-import org.apache.ws.muse.descriptor.DescriptorFactory; >-import org.apache.ws.muse.descriptor.DocumentRoot; >-import org.apache.ws.muse.descriptor.InitParamType; >-import org.apache.ws.muse.descriptor.InitialInstancesType; >-import org.apache.ws.muse.descriptor.ReferenceParametersType; >-import org.apache.ws.muse.descriptor.ResourceTypeType; >-import org.apache.ws.muse.descriptor.WsdlType; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.runtime.NullProgressMonitor; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.ecore.resource.ResourceSet; >-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >-import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.NewNameGenerator; >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceTypeFactory; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.MembershipContentRuleType; >-import org.eclipse.tptp.wsdm.tooling.util.internal.CustomMrtResourceFactoryImpl; >-import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >-import org.w3c.dom.Document; >-import org.w3c.dom.Element; >-/** >- * This class analyzes the given manageable resource type and provide an extra >- * resource type for muse descriptor (ServiceGroupEntry), if manageable >- * resource type contains the ServiceGroupCapability and ServiceGroupRegistration capability. >- */ >- >-public class ServiceGroupInspector implements MrtInspector >-{ >- >- private String _mrtParentDirName; >- >- private DocumentRoot _root; >- >- private ResourceTypeType _serviceGroupEntryResorceType; >- >- private ManageableResourceType _serviceGroupEntrymrt; >- >- private HashMap _prefixNamespaceMap; >- >- /** >- * Constructor for the ServiceGroupIspector class. >- * @param mrt >- * @param root >- */ >- >- public ServiceGroupInspector(ManageableResourceType mrt,DocumentRoot root) >- { >- _root = root; >- } >- >- /** >- * Analyzes the given manageable resource type for ServiceGroupCapability and >- * ServiceGroupRegistrationCapability and if the capabilities available then returns the muse >- * resource type for ServiceGroupEntry else returns the null. >- */ >- public ResourceTypeType inspect(Capability[] mrtCapabilities) >- { >- >- if(hasServiceGroupCapabilities(mrtCapabilities)) >- return createServiceGroupEntryResourceType(); >- return null; >- } >- >- private boolean hasServiceGroupCapabilities(Capability[] mrtCapabilities) >- { >- boolean hasServiceGroupCapability = false; >- >- boolean hasServiceGroupRegistration = false; >- >- for(int i =0;i<mrtCapabilities.length;i++) >- { >- if(mrtCapabilities[i].getNamespace().equals(WsdmConstants.SERVICE_GROUP_NS)) >- hasServiceGroupCapability = true; >- if(mrtCapabilities[i].getNamespace().equals(WsdmConstants.SERVICE_GROUP_REG_NS)) >- hasServiceGroupRegistration = true; >- } >- return hasServiceGroupCapability && hasServiceGroupRegistration; >- } >- >- /** >- * Returns the initial instances >- * @return InitialInstancesType[] >- */ >- public InitialInstancesType[] getInitialInstances() { >- >- InitialInstancesType instance = DescriptorFactory.eINSTANCE >- .createInitialInstancesType(); >- ResourceTypeType rtClone = MRTCodeGenerationDelegate >- .cloneResourceType(_serviceGroupEntryResorceType); >- instance.setResourceType(rtClone); >- ReferenceParametersType refParam = DescriptorFactory.eINSTANCE >- .createReferenceParametersType(); >- instance.setReferenceParameters(refParam); >- return new InitialInstancesType[] { instance }; >- >- } >- /** >- * Sets the parent directory >- * @param mrtParentDir >- */ >- public void setMrtParentDirectory(String mrtParentDir) { >- _mrtParentDirName = mrtParentDir; >- >- } >- >- private ResourceTypeType createServiceGroupEntryResourceType() >- { >- createServiceGroupEntryMrt(); >- _serviceGroupEntryResorceType = createServiceGroupEntryMuseResourceType(); >- return _serviceGroupEntryResorceType; >- } >- >- private void createServiceGroupEntryMrt() >- { >- org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.DocumentRoot documentRoot = ManageableResourceTypeFactory.eINSTANCE.createDocumentRoot(); >- _serviceGroupEntrymrt = ManageableResourceTypeFactory.eINSTANCE.createManageableResourceType(); >- documentRoot.setManageableResource(_serviceGroupEntrymrt); >- _serviceGroupEntrymrt.setIdentifier("ServiceGroupEntry"); >- _serviceGroupEntrymrt.setNamespace("http://docs.oasis-open.org/wsrf/sgw-2"); >- _serviceGroupEntrymrt.getImplements().add(WsdmConstants.MEX_CAPABILITY_LOCATION); >- _serviceGroupEntrymrt.getImplements().add(WsdmConstants.GET_CAPABILITY_LOCATION); >- _serviceGroupEntrymrt.getImplements().add(WsdmConstants.SET_CAPABILITY_LOCATION); >- _serviceGroupEntrymrt.getImplements().add(WsdmConstants.QUERY_CAPABILITY_LOCATION); >- _serviceGroupEntrymrt.getImplements().add(WsdmConstants.IMMIDIATE_RESOURCE_TERMINATION_CAPABILITY_LOCATION); >- _serviceGroupEntrymrt.getImplements().add(WsdmConstants.SCHEDULED_RESOURCE_TERMINATION_CAPABILITY_LOCATION); >- _serviceGroupEntrymrt.getImplements().add(WsdmConstants.SERVICE_GROUP_ENTRY_CAPABILITY_LOCATION); >- } >- >- private ResourceTypeType createServiceGroupEntryMuseResourceType() >- { >- ResourceTypeType resourceType = DescriptorFactory.eINSTANCE.createResourceTypeType(); >- resourceType.setContextPath("/ServiceGroupEntry"); >- resourceType.setJavaIdFactoryClass("org.apache.muse.core.routing.CounterResourceIdFactory"); >- resourceType.setJavaResourceClass("org.apache.muse.ws.resource.impl.SimpleWsResource"); >- >- WsdlType wsdlType = DescriptorFactory.eINSTANCE.createWsdlType(); >- wsdlType.setWsdlFile(_mrtParentDirName + "/" + "ServiceGroupEntry.wsdl"); >- _root.getXMLNSPrefixMap().put("wsrf-sge","http://docs.oasis-open.org/wsrf/sgw-2"); >- wsdlType.setWsdlPortType("wsrf-sge:PortType"); >- resourceType.setWsdl(wsdlType); >- >- CapabilityType metadataExchange = DescriptorFactory.eINSTANCE.createCapabilityType(); >- metadataExchange.setCapabilityUri(WsdmConstants.MEX_NS); >- metadataExchange.setJavaCapabilityClass(""); >- >- CapabilityType getCapability = DescriptorFactory.eINSTANCE.createCapabilityType(); >- getCapability.setCapabilityUri(WsdmConstants.GET_NS); >- getCapability.setJavaCapabilityClass(""); >- >- CapabilityType setCapability = DescriptorFactory.eINSTANCE.createCapabilityType(); >- setCapability.setCapabilityUri(WsdmConstants.SET_NS); >- setCapability.setJavaCapabilityClass(""); >- >- CapabilityType queryCapability = DescriptorFactory.eINSTANCE.createCapabilityType(); >- queryCapability.setCapabilityUri(WsdmConstants.QUERY_NS); >- queryCapability.setJavaCapabilityClass(""); >- >- CapabilityType immediateDestruction = DescriptorFactory.eINSTANCE.createCapabilityType(); >- immediateDestruction.setCapabilityUri(WsdmConstants.IMMIDIATE_TERM_NS); >- immediateDestruction.setJavaCapabilityClass(""); >- >- CapabilityType scheduledDestruction = DescriptorFactory.eINSTANCE.createCapabilityType(); >- scheduledDestruction.setCapabilityUri(WsdmConstants.SCHEDULDED_TERM_NS); >- scheduledDestruction.setJavaCapabilityClass(""); >- >- CapabilityType serviceGroupEntry = DescriptorFactory.eINSTANCE.createCapabilityType(); >- serviceGroupEntry.setCapabilityUri(WsdmConstants.SERVICE_GROUP_ENTRY_NS); >- serviceGroupEntry.setJavaCapabilityClass(""); >- >- InitParamType noValidateParam = DescriptorFactory.eINSTANCE .createInitParamType(); >- noValidateParam.setParamName("validate-wsrp-schema"); >- noValidateParam.setParamValue("false"); >- >- resourceType.getCapability().add(metadataExchange); >- resourceType.getCapability().add(getCapability); >- resourceType.getCapability().add(setCapability); >- resourceType.getCapability().add(queryCapability); >- resourceType.getCapability().add(immediateDestruction); >- resourceType.getCapability().add(scheduledDestruction); >- resourceType.getCapability().add(serviceGroupEntry); >- resourceType.getInitParam().add(noValidateParam); >- >- return resourceType; >- } >- >- private String getNamespace(String contentElement) >- { >- return contentElement.substring(1,contentElement.lastIndexOf('}')); >- } >- >- private void preparePrfixNamespaceMap(String contentElement) >- { >- if(!_prefixNamespaceMap.containsKey(contentElement)) >- { >- NewNameGenerator nameGenerator = new NewNameGenerator("pfx"); >- String prefix = nameGenerator.getNextName(); >- >- while (nameAlreadyExists(prefix)) >- { >- prefix = nameGenerator.getNextName(); >- } >- _prefixNamespaceMap.put(contentElement, prefix); >- } >- } >- >- private boolean nameAlreadyExists(String prefix) >- { >- if(_prefixNamespaceMap.containsValue(prefix)) >- return true; >- return false; >- } >- >- private String getLocalName(String namespace) >- { >- return namespace.substring(namespace.lastIndexOf('}')+1); >- } >- >- /** >- * This method will returns the extra generated ManageableResourceType object equivalent to ServiceGroupEntry. >- */ >- public ManageableResourceType getExtraGeneratedMrt() { >- >- return _serviceGroupEntrymrt; >- } >- >- /** >- * This method should return the persistance location for extra generated ManageableResourceType object equivalent to ServiceGroupEntry. >- */ >- public String getExtraGeneratedMrtPersistanceLocation() >- { >- return _mrtParentDirName + "/"+ "ServiceGroupEntry.mrt"; >- } >- /** >- * This method will persist the extra artifacts generated at the code generation time(ServiceGroupEntry). >- */ >- public void persistArtifacts() >- { >- try{ >- ResourceSet rs = new ResourceSetImpl(); >- rs.getResourceFactoryRegistry().getExtensionToFactoryMap() >- .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new CustomMrtResourceFactoryImpl()); >- String serviceGroupMrt = _mrtParentDirName + "/"+ "ServiceGroupEntry.mrt"; >- URI uri = URI.createPlatformResourceURI(serviceGroupMrt); >- byte[] rawNewMRT = MrtUtils.serializeMRT(_serviceGroupEntrymrt, rs, uri, true); >- InputStream stream = new ByteArrayInputStream(rawNewMRT); >- IFile subManagerMrtFile = EclipseUtils.getIFile(serviceGroupMrt); >- if (subManagerMrtFile.exists()) >- { >- subManagerMrtFile.setContents(stream, true, true, >- new NullProgressMonitor()); >- } >- else >- { >- subManagerMrtFile.create(stream, true, >- new NullProgressMonitor()); >- } >- stream.close(); >- } >- catch(Exception e) >- { >- e.printStackTrace(); >- } >- } >- >- /** >- * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given >- * merged RMD document for it by having the rules/relationships in it. >- */ >- public void inspectMetadata(ManageableResourceType mrt, >- org.apache.muse.ws.resource.metadata.MetadataDescriptor rmd) >- { >- >- _prefixNamespaceMap = new HashMap(); >- Capability[] mrtCapabilities = new Capability[0]; >- try >- { >- mrtCapabilities = MrtUtils.getCapabilities(mrt); >- } >- catch (Exception e) >- { >- WsdmToolingLog.logError(e.getMessage(), e); >- } >- >- if(hasServiceGroupCapabilities(mrtCapabilities)) >- { >- List membershipContentRule = mrt.getMembershipContentRule(); >- List initialValues = new ArrayList(); >- for(int i=0;i<membershipContentRule.size();i++) >- { >- MembershipContentRuleType rule = (MembershipContentRuleType) membershipContentRule.get(i); >- Element value = createMembershipContentRuleElement(rule); >- >- initialValues.add(value); >- } >- if(!initialValues.isEmpty()); >- try >- { >- rmd.setInitialValues(new QName(WssgConstants.NAMESPACE_URI,"MembershipContentRule"), initialValues); >- } >- catch (SoapFault e) >- { >- WsdmToolingLog.logError(e.getMessage(), e); >- } >- } >- } >- >- private Element createMembershipContentRuleElement(MembershipContentRuleType rule) >- { >- Document document = XmlUtils.createDocument(); >- Element membershipContentRuleElement = XmlUtils.createElement(document, new QName(WssgConstants.NAMESPACE_URI,"MembershipContentRule")); >- List contentElements = rule.getContentElements(); >- String contentElementAttribute=""; >- >- for(int i =0 ;i<contentElements.size();i++) >- { >- String contentElement = (String)contentElements.get(i); >- String tns = getNamespace(contentElement); >- String localName = getLocalName(contentElement); >- preparePrfixNamespaceMap(tns); >- >- if(contentElementAttribute.length() !=0) >- contentElementAttribute = contentElementAttribute + " " + (String)_prefixNamespaceMap.get(tns)+":"+ localName; >- else >- contentElementAttribute =(String)_prefixNamespaceMap.get(tns)+":"+ localName; >- String xmlns = "xmlns:" + _prefixNamespaceMap.get(tns); >- membershipContentRuleElement.setAttribute(xmlns,tns ); >- >- } >- membershipContentRuleElement.setAttribute("ContentElements",contentElementAttribute ); >- >- return membershipContentRuleElement; >- >- >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/NewProjectWizard.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/NewProjectWizard.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/NewProjectWizard.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/NewProjectWizard.java 27 Apr 2007 12:31:32 -0000 1.17 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,327 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.io.File; >-import java.lang.reflect.InvocationTargetException; >- >-import org.apache.muse.tools.generator.analyzer.Analyzer; >-import org.apache.muse.tools.generator.analyzer.SimpleAnalyzer; >-import org.apache.muse.tools.generator.projectizer.Projectizer; >-import org.apache.muse.tools.generator.synthesizer.ServerSynthesizer; >-import org.apache.muse.tools.generator.synthesizer.Synthesizer; >-import org.apache.muse.tools.generator.util.ConfigurationData; >-import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >-import org.eclipse.core.filesystem.URIUtil; >-import org.eclipse.core.resources.IWorkspaceRoot; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.ILog; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.SubProgressMonitor; >-import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; >-import org.eclipse.jface.operation.IRunnableWithProgress; >-import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.jface.wizard.Wizard; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; >-import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; >-import org.eclipse.tptp.wsdm.tooling.preferences.internal.Axis2ServerLocationPreferencePage; >-import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >-import org.eclipse.ui.INewWizard; >-import org.eclipse.ui.IWorkbench; >-import org.eclipse.ui.IWorkbenchPage; >-import org.eclipse.ui.PartInitException; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.part.ViewPart; >-import org.w3c.dom.Document; >- >-/** >- * This wizard accepts projectizer parameters, runtime environment and other >- * general parameters from the user so as to invoke Wsdl2Java >- */ >-public class NewProjectWizard extends Wizard implements INewWizard { >- >- private static ILog LOG = null; >- >- // We can't use internal classes, hence using view ID directly >- private static String TASK_VIEW_ID = "org.eclipse.ui.views.TaskList"; >- >- private static String PLUGIN_ID = "org.eclipse.tptp.wsdm.tooling.editor.mrt"; >- >- private GenerationOptionsPage _generationOptionsPage; >- >- private Axis2ServerLocationPage _axis2ServerLocationPage; >- >- private String _projectName; >- >- private boolean _overwrite; >- >- private boolean _shouldPersistArtifacts; >- >- private Projectizer _projectizer; >- >- private Synthesizer _synthesizer; >- >- private Analyzer _analyzer; >- >- private String _baseAddress; >- >- private CodeGenerationDelegate _codeGenerationDelegate; >- >- private Document[] _mergedWsdlDocuments; >- >- private MetadataDescriptor[] _mergedRMDs; >- >- private DescriptorHelper _helper; >- >- private String _serverLocation; >- >- private boolean _isAxis2Project; >- private boolean updatePreference; >- >- private String _projectLocation; >- >- private TargetedFileList[] _requiredAxis2Files; >- >- private boolean _licenseAccepted = false; >- >- /** >- * Class that creates the Code Generation Wizard to create new Project >- * >- * @param codeGenerationDelegate >- */ >- public NewProjectWizard(CodeGenerationDelegate codeGenerationDelegate) { >- setWindowTitle(Messages.HOOKUP_WIZARD_TXT7); >- setNeedsProgressMonitor(true); >- >- _codeGenerationDelegate = codeGenerationDelegate; >- } >- >- public void addPages() { >- _generationOptionsPage = new GenerationOptionsPage(); >- addPage(_generationOptionsPage); >- >- _axis2ServerLocationPage = new Axis2ServerLocationPage(); >- addPage(_axis2ServerLocationPage); >- >- // TODO AME why is this hardcoded here? why is it getting reloaded? >- Image imgTP = EclipseUtils.loadImage(PlatformUI.getWorkbench().getDisplay(), >- "icons/wizban/newEndpointProject_wiz.gif"); >- ImageDescriptor imgDescrTP = ExtendedImageRegistry.INSTANCE.getImageDescriptor(imgTP); >- setDefaultPageImageDescriptor(imgDescrTP); >- } >- >- private void popupAxis2LicenseDialog() { >- IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); >- String preferencesLocation = store.getString(Axis2ServerLocationPreferencePage.SERVER_LOCATION_PREFERENCE_KEY); >- if (!_serverLocation.equals(preferencesLocation)) { >- int result = new Axis2LicenseDialog().showWindow(); >- _licenseAccepted = (result == Axis2LicenseDialog.AGREE); >- } else >- _licenseAccepted = true; >- >- } >- >- private void performFinish(IProgressMonitor monitor) throws InvocationTargetException { >- try { >- monitor.beginTask(Messages.CODE_GEN_START, 7); >- >- if (_isAxis2Project) { >- try { >- // Step 1: Validate the server path >- monitor.subTask(Messages.CODE_GEN_VALIDATE_SLOCATION); >- // Step 2 : Update the Preferences, if needed >- if (updatePreference) { >- IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); >- store.setValue(Axis2ServerLocationPreferencePage.SERVER_LOCATION_PREFERENCE_KEY, >- _serverLocation); >- // Update the Lib and module location >- } >- _requiredAxis2Files = _axis2ServerLocationPage.getAxis2FilesToCopy(); >- } catch (Exception e) { >- throw new RuntimeException(e); >- } >- } >- try { >- monitor.subTask(Messages.CODE_GEN_STEP1); >- _helper = _codeGenerationDelegate.run(new SubProgressMonitor(monitor, 1)); >- >- monitor.worked(1); >- } catch (Exception e) { >- throw new RuntimeException(e); >- // TODO AME Why is this not defined? >- // throw new InvocationTargetException(new >- // Exception(Messages.HOOKUP_WIZARD_ERROR4, e)); >- } >- >- try { >- monitor.subTask(Messages.CODE_GEN_STEP2); >- _mergedWsdlDocuments = _helper.getWsdlDocuments(_baseAddress); >- _mergedRMDs = _helper.getMergedRMDs(); >- monitor.worked(1); >- } catch (Exception e) { >- e.printStackTrace(); >- throw new RuntimeException(e); >- } >- >- try { >- monitor.subTask(Messages.CODE_GEN_STEP3); >- runProjectizer(monitor); >- monitor.worked(1); >- } catch (Exception e) { >- throw new InvocationTargetException(new Exception(Messages.CODE_GEN_FAILED_ERROR_, e)); >- } >- >- if (_shouldPersistArtifacts) { >- monitor.subTask(Messages.CODE_GEN_STEP4); >- _codeGenerationDelegate.persistArtifacts(); >- monitor.worked(1); >- } >- } finally { >- monitor.done(); >- } >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.jface.wizard.Wizard#performFinish() >- */ >- public boolean performFinish() { >- _projectizer = _generationOptionsPage.getProjectizer(); >- _synthesizer = _generationOptionsPage.getSynthesizer(); >- _analyzer = _generationOptionsPage.getAnalyzer(); >- _overwrite = _generationOptionsPage.canOverwrite(); >- _shouldPersistArtifacts = _generationOptionsPage.shouldPersistArtifacts(); >- _projectName = _generationOptionsPage.getProjectName(); >- _baseAddress = _generationOptionsPage.getBaseAddress(); >- _isAxis2Project = _generationOptionsPage.isAxis2Project(); >- _projectName = _generationOptionsPage.getProjectName(); >- _projectLocation = _generationOptionsPage.getProjectLocation(); >- >- if (_isAxis2Project) { >- _serverLocation = _axis2ServerLocationPage.getServerLocation(); >- updatePreference = _axis2ServerLocationPage.isUpdatePreference(); >- popupAxis2LicenseDialog(); >- } >- >- IRunnableWithProgress runnable = new IRunnableWithProgress() { >- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >- if (!_isAxis2Project || _licenseAccepted) >- performFinish(monitor); >- } >- }; >- >- _generationOptionsPage.saveCombo(); >- >- try { >- getContainer().run(true, false, runnable); >- openTasksView(); >- >- return true; >- } catch (Exception e) { >- e.printStackTrace(); >- handle(Messages.CODE_GEN_FAILED_ERROR_, e); >- } >- >- return false; >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, >- * org.eclipse.jface.viewers.IStructuredSelection) >- */ >- public void init(IWorkbench workbench, IStructuredSelection selection) { >- // do nothing >- } >- >- private void runProjectizer(IProgressMonitor monitor) throws Exception { >- ConfigurationData data = new ConfigurationData(); >- >- data.addParameter(EclipseConfigurationData.AXIS2_FILES, _requiredAxis2Files); >- >- data.addParameter(ConfigurationData.DESCRIPTOR_DOCUMENT, _helper.getDescriptorDocument()); >- data.addParameter(EclipseConfigurationData.ADDITIONAL_JARS, _helper.getJarFiles()); >- data.addParameter(EclipseConfigurationData.INSTANCES, _helper.getInstances()); >- data.addParameter(EclipseConfigurationData.PROJECT_NAME, _projectName); >- data.addParameter(ConfigurationData.OVERWRITE, Boolean.valueOf(_overwrite)); >- data.addParameter(EclipseConfigurationData.PROJECT_LOCATION, _projectLocation); >- data.addParameter(ConfigurationData.WSDL_DOCUMENT_LIST, _mergedWsdlDocuments); >- data.addParameter(ConfigurationData.METADATA_DESCRIPTOR_LIST, _mergedRMDs); >- data.addParameter(ConfigurationData.GENERATE_CUSTOM_HEADERS, Boolean.FALSE); >- >- // check if the analyzer is null, if it is then default to the >- // SimpleAnalyzer >- if (_analyzer == null) { >- _analyzer = new SimpleAnalyzer(); >- } >- >- // check if the synthesizer is null, if it is then default to the >- // ServerSynthesizer >- if (_synthesizer == null) { >- _synthesizer = new ServerSynthesizer(); >- } >- >- // Below, we make a new SubProgressMonitor for >- // each codegeneration component since we can't reuse the progress >- // monitor >- >- data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR, new SubProgressMonitor(monitor, 1)); >- >- monitor.subTask(Messages.CODE_GEN_SUBTASK1); >- data = _analyzer.analyze(data); >- monitor.worked(1); >- >- data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR, new SubProgressMonitor(monitor, 1)); >- >- monitor.subTask(Messages.CODE_GEN_SUBTASK2); >- data = _synthesizer.synthesize(data); >- monitor.worked(1); >- >- data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR, new SubProgressMonitor(monitor, 1)); >- >- monitor.subTask(Messages.CODE_GEN_SUBTASK3); >- _projectizer.projectize(data); >- monitor.worked(1); >- } >- >- private void handle(String message, Exception e) { >- _generationOptionsPage.setErrorMessage(message); >- _axis2ServerLocationPage.setErrorMessage(message); >- >- WsdmToolingLog.log(IStatus.ERROR, IStatus.OK, message, e); >- } >- >- private void openTasksView() { >- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); >- ViewPart view = (ViewPart) page.findView(TASK_VIEW_ID); >- >- // If the page isn't showing then show it >- if (view == null) { >- try { >- page.showView(TASK_VIEW_ID); >- } catch (PartInitException e) { >- WsdmToolingLog.logError(e.getMessage(), e); >- } >- }else{ >- page.activate(view); >- } >- } >- >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MrtInspector.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MrtInspector.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MrtInspector.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MrtInspector.java 13 Apr 2007 03:47:47 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,69 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Andrew Eberbach (aeberbac@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >-import org.apache.ws.muse.descriptor.InitialInstancesType; >-import org.apache.ws.muse.descriptor.ResourceTypeType; >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >- >-/** >- * This interface is created for some cases where we expect some extra resource >- * type to be added to the muse descriptor based on the capability that >- * manageable resource type holds. For example if someone includes the >- * Notification producer capability in his manageable resource type, then muse >- * runtime requires the Subscription Manager as one of the resource type >- * described in muse descriptor file. >- */ >-public interface MrtInspector >-{ >- public static String WSDL_NAMESPACE = "http://schemas.xmlsoap.org/wsdl/"; >- >- /** >- * Analyzes the given manageable resource type capabilities and then returns the muse >- * resource type for some extra generated artifact else returns the null. >- */ >- ResourceTypeType inspect(Capability[] mrtCapabilities); >- >- /** >- * This method should set the parent directory for extra generated artifact. >- */ >- void setMrtParentDirectory(String mrtParentDir); >- >- /** >- * Returns initial instances for extra generated artifact. >- */ >- InitialInstancesType[] getInitialInstances(); >- >- /** >- * This method will persist the extra artifacts generated at codegen time. >- */ >- void persistArtifacts(); >- >- /** >- * This method will returns the extra ManageableResourceType object generated at codegen time. >- */ >- ManageableResourceType getExtraGeneratedMrt(); >- >- /** >- * This method should return the persistance location for extra generated ManageableResourceType object. >- */ >- String getExtraGeneratedMrtPersistanceLocation(); >- >- /** >- * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given >- * merged RMD document for it by having the rules/relationships in it. >- */ >- void inspectMetadata(ManageableResourceType mrt, MetadataDescriptor rmd); >-} >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/EclipseConfigurationData.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/EclipseConfigurationData.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/EclipseConfigurationData.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/EclipseConfigurationData.java 25 Apr 2007 18:36:03 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,22 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-public class EclipseConfigurationData >-{ >- public static final String ADDITIONAL_JARS = "jars"; >- public static final String INSTANCES = "instances"; >- public static final String PROGRESS_MONITOR = "progress_monitor"; >- public static final String AXIS2_FILES = "axis2_files"; >- public static final String PROJECT_LOCATION = "location"; >- public static final String PROJECT_NAME = "project_name"; >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/RelationshipInspector.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/RelationshipInspector.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/RelationshipInspector.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/RelationshipInspector.java 26 Apr 2007 22:18:17 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,405 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.io.ByteArrayInputStream; >-import java.io.IOException; >-import java.io.InputStream; >-import java.util.ArrayList; >-import java.util.Iterator; >-import java.util.List; >- >-import javax.wsdl.Operation; >-import javax.xml.namespace.QName; >- >-import org.apache.muse.util.xml.XmlUtils; >-import org.apache.muse.ws.addressing.WsaConstants; >-import org.apache.muse.ws.addressing.soap.SoapFault; >-import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >-import org.apache.ws.muse.descriptor.CapabilityType; >-import org.apache.ws.muse.descriptor.DescriptorFactory; >-import org.apache.ws.muse.descriptor.DocumentRoot; >-import org.apache.ws.muse.descriptor.InitParamType; >-import org.apache.ws.muse.descriptor.InitialInstancesType; >-import org.apache.ws.muse.descriptor.ReferenceParametersType; >-import org.apache.ws.muse.descriptor.ResourceTypeType; >-import org.apache.ws.muse.descriptor.WsdlType; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.NullProgressMonitor; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.ecore.resource.ResourceSet; >-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >-import org.eclipse.emf.ecore.util.FeatureMap; >-import org.eclipse.emf.ecore.util.BasicExtendedMetaData.EStructuralFeatureExtendedMetaData; >-import org.eclipse.emf.ecore.xml.type.AnyType; >-import org.eclipse.tptp.wsdm.tooling.editor.mrt.relationship.internal.RelationshipUtils; >-import org.eclipse.tptp.wsdm.tooling.model.addressing.AttributedURIType; >-import org.eclipse.tptp.wsdm.tooling.model.addressing.EndpointReferenceType; >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceTypeFactory; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.Relationship; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.RelationshipParticipantType; >-import org.eclipse.tptp.wsdm.tooling.util.internal.CustomMrtResourceFactoryImpl; >-import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >-import org.w3c.dom.Document; >-import org.w3c.dom.Element; >-import org.w3c.dom.Text; >- >-public class RelationshipInspector implements MrtInspector >-{ >- >- private String _mrtParentDirName; >- >- private DocumentRoot _root; >- >- private ResourceTypeType _relationshipResourceType; >- >- private ManageableResourceType _relationshipResourceMRT; >- >- /** >- * Constructor of the class >- * @param root >- */ >- public RelationshipInspector(DocumentRoot root) >- { >- _root = root; >- } >- >- public ManageableResourceType getExtraGeneratedMrt() >- { >- return _relationshipResourceMRT; >- } >- >- public String getExtraGeneratedMrtPersistanceLocation() >- { >- return _mrtParentDirName+"/RelationshipResource.mrt"; >- } >- >- public InitialInstancesType[] getInitialInstances() >- { >- InitialInstancesType instance = DescriptorFactory.eINSTANCE >- .createInitialInstancesType(); >- ResourceTypeType rtClone = MRTCodeGenerationDelegate >- .cloneResourceType(_relationshipResourceType); >- instance.setResourceType(rtClone); >- ReferenceParametersType refParam = DescriptorFactory.eINSTANCE >- .createReferenceParametersType(); >- instance.setReferenceParameters(refParam); >- return new InitialInstancesType[] { instance }; >- } >- >- public ResourceTypeType inspect(Capability[] mrtCapabilities) >- { >- for (int i = 0; i < mrtCapabilities.length; i++) >- { >- if (hasRelationshipCapability(mrtCapabilities[i])) >- return createRelationshipResourceType(); >- } >- return null; >- } >- >- private ResourceTypeType createRelationshipResourceType() >- { >- createRelationshipResourceMrt(); >- _relationshipResourceType = createRelationshipResourceMuseType(); >- return _relationshipResourceType; >- } >- >- private void createRelationshipResourceMrt() >- { >- org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.DocumentRoot documentRoot = ManageableResourceTypeFactory.eINSTANCE.createDocumentRoot(); >- _relationshipResourceMRT = ManageableResourceTypeFactory.eINSTANCE >- .createManageableResourceType(); >- documentRoot.setManageableResource(_relationshipResourceMRT); >- _relationshipResourceMRT.setIdentifier("RelationshipResource"); >- _relationshipResourceMRT >- .setNamespace("http://docs.oasis-open.org/wsdm/muws2-2.xsd/RelationshipResource"); >- _relationshipResourceMRT >- .getImplements() >- .add(WsdmConstants.MEX_CAPABILITY_LOCATION); >- _relationshipResourceMRT >- .getImplements() >- .add(WsdmConstants.GET_CAPABILITY_LOCATION); >- _relationshipResourceMRT >- .getImplements() >- .add(WsdmConstants.SET_CAPABILITY_LOCATION); >- _relationshipResourceMRT >- .getImplements() >- .add(WsdmConstants.QUERY_CAPABILITY_LOCATION); >- _relationshipResourceMRT >- .getImplements() >- .add(WsdmConstants.RELATIONSHIP_RESOURCE_CAPABILITY_LOCATION); >- } >- >- private ResourceTypeType createRelationshipResourceMuseType() >- { >- ResourceTypeType resourceType = DescriptorFactory.eINSTANCE >- .createResourceTypeType(); >- resourceType.setContextPath("/RelationshipResource"); >- resourceType >- .setJavaIdFactoryClass(WsdmConstants.MUSE_RESOURCE_ID_FACTORY_CLASS); >- resourceType >- .setJavaResourceClass(WsdmConstants.MUSE_RESOURCE_CLASS); >- >- WsdlType wsdlType = DescriptorFactory.eINSTANCE.createWsdlType(); >- wsdlType.setWsdlFile(_mrtParentDirName + "/" >- + "RelationshipResource.wsdl"); >- _root.getXMLNSPrefixMap().put("rel", >- "http://docs.oasis-open.org/wsdm/muws2-2.xsd/RelationshipResource"); >- wsdlType.setWsdlPortType("rel:PortType"); >- resourceType.setWsdl(wsdlType); >- >- CapabilityType metadataExchange = DescriptorFactory.eINSTANCE >- .createCapabilityType(); >- metadataExchange >- .setCapabilityUri("http://schemas.xmlsoap.org/ws/2004/09/mex"); >- metadataExchange.setJavaCapabilityClass(""); >- >- CapabilityType getCapability = DescriptorFactory.eINSTANCE >- .createCapabilityType(); >- getCapability >- .setCapabilityUri("http://docs.oasis-open.org/wsrf/rpw-2/Get"); >- getCapability.setJavaCapabilityClass(""); >- >- CapabilityType setCapability = DescriptorFactory.eINSTANCE >- .createCapabilityType(); >- setCapability >- .setCapabilityUri("http://docs.oasis-open.org/wsrf/rpw-2/Set"); >- setCapability.setJavaCapabilityClass(""); >- >- CapabilityType queryCapability = DescriptorFactory.eINSTANCE >- .createCapabilityType(); >- queryCapability >- .setCapabilityUri("http://docs.oasis-open.org/wsrf/rpw-2/Query"); >- queryCapability.setJavaCapabilityClass(""); >- >- CapabilityType relationshipResource = DescriptorFactory.eINSTANCE >- .createCapabilityType(); >- relationshipResource >- .setCapabilityUri("http://docs.oasis-open.org/wsdm/muws/capabilities/RelationshipResource"); >- relationshipResource >- .setJavaCapabilityClass(""); >- >- InitParamType noValidateParam = DescriptorFactory.eINSTANCE >- .createInitParamType(); >- noValidateParam.setParamName("validate-wsrp-schema"); >- noValidateParam.setParamValue("false"); >- >- resourceType.getCapability().add(metadataExchange); >- resourceType.getCapability().add(getCapability); >- resourceType.getCapability().add(setCapability); >- resourceType.getCapability().add(queryCapability); >- resourceType.getCapability().add(relationshipResource); >- >- resourceType.getInitParam().add(noValidateParam); >- >- return resourceType; >- } >- >- private boolean hasRelationshipCapability(Capability capability) >- { >- boolean hasRelationshipNS = "http://docs.oasis-open.org/wsdm/muws2-2.xsd".equals(capability.getNamespace()); >- String capabilityURI = capability.getWsdlDefinition().getNamespace("capabilityURI"); >- boolean hasRelationshipURI = "http://docs.oasis-open.org/wsdm/muws/capabilities/Relationships".equals(capabilityURI); >- boolean hasRelationshipName = capability.getName().equals("Relationships"); >- Operation[] operations = capability.getWsdlDefinition().getOperations(); >- if (operations == null || operations.length < 1) >- return false; >- boolean hasQueryRelationshipsOp = WsdlUtils.getOperationName(operations[0]) >- .equals("QueryRelationshipsByType"); >- return hasRelationshipNS && hasRelationshipURI && hasRelationshipName && hasQueryRelationshipsOp; >- } >- >- public void persistArtifacts() >- { >- ResourceSet rs = new ResourceSetImpl(); >- rs.getResourceFactoryRegistry().getExtensionToFactoryMap() >- .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new CustomMrtResourceFactoryImpl()); >- byte[] rawNewMRT = MrtUtils.serializeMRT(_relationshipResourceMRT, rs, URI >- .createURI("dummy.xml"), true); >- InputStream stream = new ByteArrayInputStream(rawNewMRT); >- >- try >- { >- String relationshipResourceMrt = _mrtParentDirName + "/" >- + "RelationshipResource.mrt"; >- IFile relationshipResourceMrtFile = EclipseUtils.getIFile(relationshipResourceMrt); >- if (relationshipResourceMrtFile.exists()) >- { >- relationshipResourceMrtFile.setContents(stream, true, true, >- new NullProgressMonitor()); >- } >- else >- { >- relationshipResourceMrtFile.create(stream, true, >- new NullProgressMonitor()); >- } >- try >- { >- stream.close(); >- } >- catch (IOException e) >- { >- WsdmToolingLog.logError(e.getMessage(), e); >- } >- } >- catch (CoreException e) >- { >- WsdmToolingLog.logError(e.getMessage(), e); >- } >- } >- >- public void setMrtParentDirectory(String mrtParentDir) >- { >- _mrtParentDirName = mrtParentDir; >- } >- >- /** >- * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given >- * merged RMD document for it by having the rules/relationships in it. >- */ >- public void inspectMetadata(ManageableResourceType mrt, MetadataDescriptor rmd) >- { >- boolean hasRelationshipCapability = false; >- Capability[] mrtCapabilities = new Capability[0]; >- try >- { >- mrtCapabilities = MrtUtils.getCapabilities(mrt); >- } >- catch (Exception e) >- { >- WsdmToolingLog.logError(e.getMessage(), e); >- } >- for (int i = 0; i < mrtCapabilities.length; i++) >- { >- if (hasRelationshipCapability(mrtCapabilities[i])) >- { >- hasRelationshipCapability = true; >- break; >- } >- } >- if(hasRelationshipCapability) >- { >- List relationships = mrt.getRelationshipDefinitions(); >- List initialValues = new ArrayList(); >- for(int i=0;i<relationships.size();i++) >- { >- Relationship relationship = (Relationship) relationships.get(i); >- Element value = createRelationshipElement(relationship); >- initialValues.add(value); >- } >- if(!initialValues.isEmpty()); >- try >- { >- rmd.setInitialValues(new QName(WsdmConstants.MUWS_P2_NS,"Relationship"), initialValues); >- } >- catch (SoapFault e) >- { >- WsdmToolingLog.logError(e.getMessage(), e); >- } >- } >- } >- >- private Element createRelationshipElement(Relationship relationship) >- { >- Document document = XmlUtils.createDocument(); >- Element relationshipElement = XmlUtils.createElement(document, new QName(WsdmConstants.MUWS_P2_NS,"Relationship")); >- >- Element nameElement = XmlUtils.createElement(document, new QName(WsdmConstants.MUWS_P2_NS,"Name")); >- Text name = document.createTextNode(relationship.getName()); >- nameElement.appendChild(name); >- relationshipElement.appendChild(nameElement); >- >- Element typeElement = XmlUtils.createElement(document, new QName(WsdmConstants.MUWS_P2_NS,"Type")); >- QName typeQName = RelationshipUtils.getRelationshipType(relationship); >- Element element = XmlUtils.createElement(document, typeQName); >- typeElement.appendChild(element); >- relationshipElement.appendChild(typeElement); >- >- List participants = relationship.getParticipant(); >- for(int i=0;i<participants.size();i++) >- { >- RelationshipParticipantType participant = (RelationshipParticipantType) participants.get(i); >- Element participantElement = createParticipantElement(participant, document); >- relationshipElement.appendChild(participantElement); >- } >- return relationshipElement; >- } >- >- private Element createParticipantElement(RelationshipParticipantType participant, Document document) >- { >- Element participantElement = XmlUtils.createElement(document,new QName(WsdmConstants.MUWS_P2_NS,"Participant")); >- >- // Create epr element >- Element manageabilityEprElement = XmlUtils.createElement(document, new QName(WsdmConstants.MUWS_P1_NS,"ManageabilityEndpointReference")); >- EndpointReferenceType epr = (EndpointReferenceType) participant.getManageabilityEndpointReference().get(0); >- AttributedURIType uri = epr.getAddress(); >- Element addressElement = XmlUtils.createElement(document, new QName("http://www.w3.org/2005/08/addressing", "Address")); >- Text address = document.createTextNode(uri.getValue()); >- addressElement.appendChild(address); >- manageabilityEprElement.appendChild(addressElement); >- participantElement.appendChild(manageabilityEprElement); >- >- // Create reference parameter element >- Element referenceParameterElement = XmlUtils.createElement(document, WsaConstants.PARAMETERS_QNAME); >- manageabilityEprElement.appendChild(referenceParameterElement); >- org.eclipse.tptp.wsdm.tooling.model.addressing.ReferenceParametersType refParams = epr.getReferenceParameters(); >- FeatureMap fm = refParams.getAny(); >- Iterator it = fm.iterator(); >- while (it.hasNext()) >- { >- Object obj = it.next(); >- if(obj instanceof EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry) >- { >- EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry containmentEntry = (EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry)obj; >- EStructuralFeatureExtendedMetaData metadata = ((EStructuralFeatureImpl)containmentEntry.getEStructuralFeature()).getExtendedMetaData(); >- String namespace = metadata.getNamespace(); >- String name = metadata.getName(); >- String value = ""; >- Object containmentEntryValue = containmentEntry.getValue(); >- if(containmentEntryValue instanceof AnyType) >- { >- AnyType anyType = (AnyType) containmentEntryValue; >- value = (String) anyType.getMixed().valueListIterator().next(); >- } >- Element paramElement = XmlUtils.createElement(document, new QName(namespace, name)); >- XmlUtils.setElementText(paramElement, value); >- referenceParameterElement.appendChild(paramElement); >- } >- } >- >- // Create resource id element >- Element resourceIdElement = XmlUtils.createElement(document, new QName(WsdmConstants.MUWS_P1_NS,"ResourceId")); >- Text resourceId = document.createTextNode(participant.getResourceId()); >- resourceIdElement.appendChild(resourceId); >- participantElement.appendChild(resourceIdElement); >- >- // Create role element >- Element roleElement = XmlUtils.createElement(document, new QName(WsdmConstants.MUWS_P2_NS,"Role")); >- Text role = document.createTextNode(participant.getRole()); >- roleElement.appendChild(role); >- participantElement.appendChild(roleElement); >- >- return participantElement; >- } >- >- >- >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/ISoapServerDependency.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/ISoapServerDependency.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/ISoapServerDependency.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/ISoapServerDependency.java 16 Mar 2007 18:04:37 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,44 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import org.eclipse.core.runtime.IExecutableExtension; >- >-/** >- * Interface to represent Soap Library dependency used in Tooling codegeneration. >- */ >- >-public interface ISoapServerDependency extends IExecutableExtension >-{ >- /** >- * Returns null if the given Server Home has all the required soap jar files. >- */ >- String validateSoapServerHome(String serverHome); >- >- /** >- * Returns the absolute path of all the required soap jar files. >- */ >- TargetedFileList[] getFilesToCopy(); >- >- /** >- * Returns the absolute path of the lib folder. >- */ >-// String getServerLibLocation(String serverName); >- >- /** >- * Returns the absolute path of the modules folder. >- */ >-// String getServerModulesLocation(String serverName); >- >- >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/CodeGenerationDelegate.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/CodeGenerationDelegate.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/CodeGenerationDelegate.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/CodeGenerationDelegate.java 13 Apr 2007 03:47:47 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,51 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Andrew Eberbach (aeberbac@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >-import org.eclipse.core.runtime.SubProgressMonitor; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >- >-/** >- * This class acts as a way to capture doing WSDL resolution (which could >- * include WSDL manipulation like merging) so that it can be done later on, or >- * on another thread since this would be time-consuming. >- */ >-public interface CodeGenerationDelegate >-{ >- >- /** >- * Do any work related to code generation. This kind of work is passed to >- * this delegate so that it can be run in a separate thread. This can take a >- * (optional) progress monitor which can be used to report progress done in >- * this task. The method returns a DescriptorHelper which aggregates all of >- * the work that was done. >- * >- * @param progressMonitor >- * A progress monitor to show the progress done during this task. >- * >- * @throws Exception >- */ >- DescriptorHelper run(SubProgressMonitor progressMonitor) throws Exception; >- >- /** >- * Persist the extra artifacts generated during codegeneration such as SubscriptionManager.mrt etc. >- */ >- void persistArtifacts(); >- >- /** >- * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given >- * merged RMD document for it by having the rules/relationships in it. >- */ >- void inspectMetadata(ManageableResourceType mrt, MetadataDescriptor metadata); >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MrtPreProcessor.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MrtPreProcessor.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MrtPreProcessor.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MrtPreProcessor.java 13 Apr 2007 03:47:47 -0000 1.7 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,250 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Andrew Eberbach (aeberbac@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.util.ArrayList; >-import java.util.HashMap; >-import java.util.Iterator; >-import java.util.LinkedList; >-import java.util.List; >-import java.util.Map; >- >-import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >-import org.apache.ws.muse.descriptor.DocumentRoot; >-import org.apache.ws.muse.descriptor.InitialInstancesType; >-import org.apache.ws.muse.descriptor.MuseType; >-import org.apache.ws.muse.descriptor.ResourceTypeType; >-import org.apache.ws.muse.descriptor.RootType; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.tptp.wsdm.tooling.editor.dde.util.internal.DdeUtil; >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >-import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >- >-/** >- * This class analyzes the given ManageableResourceType object and check whether it needs >- * any other extra ManageableResourceType object such as SubscriptionManager based on the capabilities >- * available in given ManagableResourceType. >- */ >- >-public class MrtPreProcessor >-{ >- private ManageableResourceType _mrt; >- private DocumentRoot _ddRoot; >- private IFile _mrtFile; >- private List _generatedResourceTypes = new LinkedList(); >- private List _initialInstancesList = new LinkedList(); >- private List _contributedInspectors = new LinkedList(); >- private Map _mrtObjectMap = new HashMap(); >- private List _allInspectors = new LinkedList(); >- >- /** >- * Creates instance of this class. >- * >- * @param mrt >- * Given MRT to analyze. >- * >- * @param ddRoot >- * Given Descriptor file document root, can be null. >- */ >- public MrtPreProcessor(ManageableResourceType mrt, DocumentRoot ddRoot) >- { >- _mrt = mrt; >- if(ddRoot == null) >- ddRoot = DdeUtil.createInitialDDModel(); >- _ddRoot = ddRoot; >- String mrtLocation = _mrt.eResource().getURI().toString(); >- try >- { >- _mrtFile = EclipseUtils.getIFile(mrtLocation); >- } >- catch (CoreException e) >- { >- e.printStackTrace(); >- } >- } >- >- /** >- * Creates instance of this class. >- * >- * @param mrt >- * Given MRT to analyze. >- */ >- public MrtPreProcessor(ManageableResourceType mrt) >- { >- this(mrt,null); >- } >- >- /** >- * Returns the modified Descriptor document root. >- */ >- public DocumentRoot getDDDocumentRoot() >- { >- return _ddRoot; >- } >- >- /** >- * Analyzes the given MRT file for extra required artifacts. >- */ >- public void preProcess() >- { >- if(_ddRoot!=null) >- { >- RootType root = _ddRoot.getRoot(); >- MuseType muse = root.getMuse(); >- ResourceTypeType[] resourceTypes = process(); >- for (int i = 0; i < resourceTypes.length; i++) >- muse.getResourceType().add(resourceTypes[i]); >- >- // Create initial instances >- >- InitialInstancesType[] instances = getInitialInstances(); >- for (int i = 0; i < instances.length; i++) >- root.getInitialInstances().add(instances[i]); >- } >- } >- >- private boolean hasResourceTypeInDD(ResourceTypeType givenResourceType) >- { >- if(_ddRoot!=null) >- { >- if(_ddRoot.getRoot()!=null) >- { >- if(_ddRoot.getRoot().getMuse()!=null) >- { >- MuseType muse = _ddRoot.getRoot().getMuse(); >- List resourceTypes = muse.getResourceType(); >- if(resourceTypes!=null) >- { >- for(int i=0;i<resourceTypes.size();i++) >- { >- ResourceTypeType resourceType = (ResourceTypeType)resourceTypes.get(i); >- boolean equalContextPath = givenResourceType.getContextPath().equals(resourceType.getContextPath()); >- boolean equalWsdlFile = givenResourceType.getWsdl().getWsdlFile().equals(resourceType.getWsdl().getWsdlFile()); >- boolean equalWsdlPortType = givenResourceType.getWsdl().getWsdlPortType().equals(resourceType.getWsdl().getWsdlPortType()); >- if(equalContextPath && equalWsdlFile && equalWsdlPortType) >- return true; >- } >- } >- } >- } >- } >- return false; >- } >- >- /** >- * This method processes the given manageable resource type to check whether >- * we need any extra resource type in muse descriptor file such as >- * Subscription manager etc. It will returns all the proper ResourceTypeType >- * objects. So it will return atleast one ResourceTypeType object that >- * represents the given manageable resource type. >- */ >- private ResourceTypeType[] process() >- { >- Capability[] mrtCapabilities = new Capability[0]; >- try >- { >- mrtCapabilities = MrtUtils.getCapabilities(_mrt); >- } >- catch (Exception e) >- { >- } >- // Analyze the given manageable resource type for Subscription manager >- // etc. >- // If needed add the extra resource type for Subscription manager >- List inspectors = getAllMrtInspectors(); >- for (int i = 0; i < inspectors.size(); i++) >- { >- MrtInspector inspector = (MrtInspector) inspectors.get(i); >- inspector.setMrtParentDirectory(_mrtFile.getParent().getFullPath() >- .toString()); >- ResourceTypeType resourceType = inspector.inspect(mrtCapabilities); >- if (resourceType != null) >- { >- if(!hasResourceTypeInDD(resourceType)) >- { >- _generatedResourceTypes.add(resourceType); >- InitialInstancesType[] instances = inspector >- .getInitialInstances(); >- for (int j = 0; j < instances.length; j++) >- _initialInstancesList.add(instances[j]); >- if(inspector.getExtraGeneratedMrt()!=null) >- _mrtObjectMap.put(inspector.getExtraGeneratedMrtPersistanceLocation(), inspector.getExtraGeneratedMrt()); >- _contributedInspectors.add(inspector); >- } >- } >- _allInspectors.add(inspector); >- } >- return (ResourceTypeType[]) _generatedResourceTypes >- .toArray(new ResourceTypeType[_generatedResourceTypes.size()]); >- } >- >- private List getAllMrtInspectors() >- { >- List inspectors = new ArrayList(); >- inspectors.add(new BasicMrtInspector(_mrt, _ddRoot)); >- // We don't analyze MRT for SubscriptionManager >- // As it is already handled in MUSE-2.1 >- //inspectors.add(new SubscriptionManagerInspector(_ddRoot)); >- inspectors.add(new ServiceGroupInspector(_mrt, _ddRoot)); >- inspectors.add(new RelationshipInspector(_ddRoot)); >- return inspectors; >- } >- >- /** >- * Returns the initial instances >- * @return IntialInstancesType[] >- */ >- private InitialInstancesType[] getInitialInstances() >- { >- return (InitialInstancesType[]) _initialInstancesList >- .toArray(new InitialInstancesType[_initialInstancesList.size()]); >- } >- >- /** >- * Returns the map. >- * Key will be the persisted location of MRT and >- * value will be the ManageableREsourceType object. >- */ >- public Map getMrtObjectMap() >- { >- return _mrtObjectMap; >- } >- >- /** >- * This method will persist the extra artifacts generated at codegen time. >- */ >- public void persistArtifacts() >- { >- for(int i=0;i<_contributedInspectors.size();i++) >- { >- MrtInspector inspector = (MrtInspector)_contributedInspectors.get(i); >- inspector.persistArtifacts(); >- } >- } >- >- /** >- * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given >- * merged RMD document for it by having the rules/relationships in it. >- */ >- public void inspectMetadata(ManageableResourceType mrt, MetadataDescriptor rmd) >- { >- for(Iterator iter = _allInspectors.iterator();iter.hasNext();) >- { >- MrtInspector inspector = (MrtInspector) iter.next(); >- inspector.inspectMetadata(mrt, rmd); >- } >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MRTCodeGenerationDelegate.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MRTCodeGenerationDelegate.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MRTCodeGenerationDelegate.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MRTCodeGenerationDelegate.java 13 Apr 2007 03:47:47 -0000 1.8 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,156 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Andrew Eberbach (aeberbac@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.io.ByteArrayInputStream; >-import java.io.ByteArrayOutputStream; >-import java.io.IOException; >-import java.util.HashMap; >-import java.util.Map; >- >-import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >-import org.apache.ws.muse.descriptor.DescriptorFactory; >-import org.apache.ws.muse.descriptor.DocumentRoot; >-import org.apache.ws.muse.descriptor.ResourceTypeType; >-import org.apache.ws.muse.descriptor.WsdlType; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.SubProgressMonitor; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.ecore.resource.ResourceSet; >-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >-import org.eclipse.tptp.wsdm.tooling.editor.dde.util.internal.DdeUtil; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >-import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.MyDescriptorResourceFactoryImpl; >- >-/** >- * This class acts as a way during the Code Generation of MRT to capture doing WSDL >- * resolution so that it can be done later on, or on >- * another thread since this would be time-consuming. >- */ >-public class MRTCodeGenerationDelegate implements CodeGenerationDelegate >-{ >- private ManageableResourceType _mrt; >- private MrtPreProcessor _mrtPreProcessor; >- private String _ddFilePath; >- private IFile _mrtFile; >- private DocumentRoot _ddRoot; >- >- /** >- * Constructor of the class >- * @param mrtFile >- */ >- public MRTCodeGenerationDelegate(IFile mrtFile) >- { >- _mrtFile = mrtFile; >- URI mrtURI = URI.createPlatformResourceURI(mrtFile.getFullPath() >- .toString()); >- _mrt = MrtUtils.loadMRT(mrtURI); >- _mrtPreProcessor = new MrtPreProcessor(_mrt); >- } >- >- /** >- * Creates the DD file. >- * The method returns a DescriptorHelper which >- * aggregates all of the work that was done. >- * >- * @param progressMonitor A progress monitor to >- * show the progress done during this >- * task. >- * @throws Exception >- */ >- public DescriptorHelper run(SubProgressMonitor progressMonitor) >- throws Exception >- { >- byte[] serializedDD = createDD(); >- Map mrtObjectMap = _mrtPreProcessor.getMrtObjectMap(); >- return new DescriptorHelper(this, new ByteArrayInputStream(serializedDD), mrtObjectMap, false); >- } >- >- private byte[] createDD() >- { >- _mrtPreProcessor.preProcess(); >- _ddRoot = _mrtPreProcessor.getDDDocumentRoot(); >- ResourceSet resourceSet = new ResourceSetImpl(); >- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() >- .put(Resource.Factory.Registry.DEFAULT_EXTENSION, >- new MyDescriptorResourceFactoryImpl()); >- URI uri = URI.createURI("dummy.xml"); >- Resource resource = resourceSet.createResource(uri); >- resource.getContents().add(_ddRoot); >- Map map = new HashMap(); >- ByteArrayOutputStream baos = new ByteArrayOutputStream(); >- try >- { >- resource.save(baos, map); >- } >- catch (IOException e) >- { >- e.printStackTrace(); >- } >- return baos.toByteArray(); >- } >- >- private String createDDFilePath() >- { >- IPath ddIPath = _mrtFile.getFullPath().removeFileExtension() >- .addFileExtension("dd"); >- return ddIPath.toString(); >- } >- >- /** >- * Create and return a new instance of given ResourceTypeType. Only >- * ContextPath, JavaIdFactoryClass, JavaResourceClass and WsdlType fields >- * have been copied. >- */ >- public static ResourceTypeType cloneResourceType(ResourceTypeType rt) >- { >- ResourceTypeType clone = DescriptorFactory.eINSTANCE >- .createResourceTypeType(); >- clone.setContextPath(rt.getContextPath()); >- clone.setJavaIdFactoryClass(rt.getJavaIdFactoryClass()); >- clone.setJavaResourceClass(rt.getJavaResourceClass()); >- WsdlType wClone = DescriptorFactory.eINSTANCE.createWsdlType(); >- wClone.setWsdlFile(rt.getWsdl().getWsdlFile()); >- wClone.setWsdlPortType(rt.getWsdl().getWsdlPortType()); >- clone.setWsdl(wClone); >- return clone; >- } >- >- /** >- * This method will persist the extra artifacts generated at codegen time. >- */ >- public void persistArtifacts() >- { >- _mrtPreProcessor.persistArtifacts(); >- persistDDFile(); >- } >- >- private void persistDDFile() >- { >- _ddFilePath = createDDFilePath(); >- DdeUtil.serializeDescriptorRoot(_ddRoot, URI.createPlatformResourceURI(_ddFilePath)); >- } >- >- /** >- * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given >- * merged RMD document for it by having the rules/relationships in it. >- */ >- public void inspectMetadata(ManageableResourceType mrt, >- MetadataDescriptor metadata) >- { >- _mrtPreProcessor.inspectMetadata(mrt, metadata); >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/SubscriptionManagerInspector.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/SubscriptionManagerInspector.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/SubscriptionManagerInspector.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/SubscriptionManagerInspector.java 13 Apr 2007 03:47:47 -0000 1.6 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,334 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.io.ByteArrayInputStream; >-import java.io.IOException; >-import java.io.InputStream; >- >-import javax.wsdl.Operation; >- >-import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >-import org.apache.ws.muse.descriptor.CapabilityType; >-import org.apache.ws.muse.descriptor.DescriptorFactory; >-import org.apache.ws.muse.descriptor.DocumentRoot; >-import org.apache.ws.muse.descriptor.InitParamType; >-import org.apache.ws.muse.descriptor.InitialInstancesType; >-import org.apache.ws.muse.descriptor.ReferenceParametersType; >-import org.apache.ws.muse.descriptor.ResourceTypeType; >-import org.apache.ws.muse.descriptor.WsdlType; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.NullProgressMonitor; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.ecore.resource.ResourceSet; >-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceTypeFactory; >-import org.eclipse.tptp.wsdm.tooling.util.internal.CustomMrtResourceFactoryImpl; >-import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >- >-/** >- * This class analyzes the given manageable resource type and provide an extra >- * resource type for muse descriptor (SubscriptionManager), if manageable >- * resource type contains the NotificationProducer capability. >- */ >-public class SubscriptionManagerInspector implements MrtInspector >-{ >- >- private String _mrtParentDirName; >- >- private DocumentRoot _root; >- >- private ResourceTypeType _subManagerResourceType; >- >- private ManageableResourceType _subManagerMRT; >- /** >- * Constructor of the class >- * @param root >- */ >- public SubscriptionManagerInspector(DocumentRoot root) >- { >- _root = root; >- } >- >- /** >- * Analyzes the given manageable resource type for NotificationProducer >- * capability, and if the capability available then returns the muse >- * resource type for SubscriptionManager else returns the null. >- */ >- public ResourceTypeType inspect(Capability[] mrtCapabilities) >- { >- for (int i = 0; i < mrtCapabilities.length; i++) >- { >- if (isNotificationProducerCapability(mrtCapabilities[i])) >- return createSubscriptionManagerResourceType(); >- } >- return null; >- } >- >- private ResourceTypeType createSubscriptionManagerResourceType() >- { >- createSubManagerMrt(); >- _subManagerResourceType = createSubManagerMuseResourceType(); >- return _subManagerResourceType; >- } >- >- private void createSubManagerMrt() >- { >- org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.DocumentRoot documentRoot = ManageableResourceTypeFactory.eINSTANCE.createDocumentRoot(); >- _subManagerMRT = ManageableResourceTypeFactory.eINSTANCE >- .createManageableResourceType(); >- documentRoot.setManageableResource(_subManagerMRT); >- _subManagerMRT.setIdentifier("SubscriptionManager"); >- _subManagerMRT >- .setNamespace("http://docs.oasis-open.org/wsn/b-2/SubscriptionManager"); >- _subManagerMRT >- .getImplements() >- .add(WsdmConstants.IDENTITY_CAPABILITY_LOCATION); >- _subManagerMRT >- .getImplements() >- .add(WsdmConstants.MANAGEABLITY_CAPABILITY_LOCATION); >- _subManagerMRT >- .getImplements() >- .add(WsdmConstants.MEX_CAPABILITY_LOCATION); >- _subManagerMRT >- .getImplements() >- .add(WsdmConstants.GET_CAPABILITY_LOCATION); >- _subManagerMRT >- .getImplements() >- .add(WsdmConstants.SET_CAPABILITY_LOCATION); >- _subManagerMRT >- .getImplements() >- .add(WsdmConstants.QUERY_CAPABILITY_LOCATION); >- _subManagerMRT >- .getImplements() >- .add(WsdmConstants.IMMIDIATE_RESOURCE_TERMINATION_CAPABILITY_LOCATION); >- _subManagerMRT >- .getImplements() >- .add(WsdmConstants.SCHEDULED_RESOURCE_TERMINATION_CAPABILITY_LOCATION); >- _subManagerMRT >- .getImplements() >- .add(WsdmConstants.SUBSCRIPTION_MANAGER_CAPABILITY_LOCATION); >- } >- >- private ResourceTypeType createSubManagerMuseResourceType() >- { >- ResourceTypeType resourceType = DescriptorFactory.eINSTANCE >- .createResourceTypeType(); >- resourceType.setContextPath("/SubscriptionManager"); >- resourceType >- .setJavaIdFactoryClass(WsdmConstants.MUSE_RESOURCE_ID_FACTORY_CLASS); >- resourceType >- .setJavaResourceClass(WsdmConstants.MUSE_RESOURCE_CLASS); >- >- WsdlType wsdlType = DescriptorFactory.eINSTANCE.createWsdlType(); >- wsdlType.setWsdlFile(_mrtParentDirName + "/" >- + "SubscriptionManager.wsdl"); >- _root.getXMLNSPrefixMap().put("wsn", >- "http://docs.oasis-open.org/wsn/b-2/SubscriptionManager"); >- wsdlType.setWsdlPortType("wsn:PortType"); >- resourceType.setWsdl(wsdlType); >- >- CapabilityType identity = DescriptorFactory.eINSTANCE >- .createCapabilityType(); >- identity >- .setCapabilityUri("http://docs.oasis-open.org/wsdm/muws/capabilities/Identity"); >- identity.setJavaCapabilityClass(""); >- >- CapabilityType manageabilityCharacteristics = DescriptorFactory.eINSTANCE >- .createCapabilityType(); >- manageabilityCharacteristics >- .setCapabilityUri("http://docs.oasis-open.org/wsdm/muws/capabilities/ManageabilityCharacteristics"); >- manageabilityCharacteristics.setJavaCapabilityClass(""); >- >- CapabilityType metadataExchange = DescriptorFactory.eINSTANCE >- .createCapabilityType(); >- metadataExchange >- .setCapabilityUri("http://schemas.xmlsoap.org/ws/2004/09/mex"); >- metadataExchange.setJavaCapabilityClass(""); >- >- CapabilityType getCapability = DescriptorFactory.eINSTANCE >- .createCapabilityType(); >- getCapability >- .setCapabilityUri("http://docs.oasis-open.org/wsrf/rpw-2/Get"); >- getCapability.setJavaCapabilityClass(""); >- >- CapabilityType setCapability = DescriptorFactory.eINSTANCE >- .createCapabilityType(); >- setCapability >- .setCapabilityUri("http://docs.oasis-open.org/wsrf/rpw-2/Set"); >- setCapability.setJavaCapabilityClass(""); >- >- CapabilityType queryCapability = DescriptorFactory.eINSTANCE >- .createCapabilityType(); >- queryCapability >- .setCapabilityUri("http://docs.oasis-open.org/wsrf/rpw-2/Query"); >- queryCapability.setJavaCapabilityClass(""); >- >- CapabilityType immediateDestruction = DescriptorFactory.eINSTANCE >- .createCapabilityType(); >- immediateDestruction >- .setCapabilityUri("http://docs.oasis-open.org/wsrf/rlw-2/ImmediateResourceTermination"); >- immediateDestruction >- .setJavaCapabilityClass("org.apache.muse.ws.resource.lifetime.impl.SimpleImmediateTermination"); >- >- CapabilityType scheduledDestruction = DescriptorFactory.eINSTANCE >- .createCapabilityType(); >- scheduledDestruction >- .setCapabilityUri("http://docs.oasis-open.org/wsrf/rlw-2/ScheduledResourceTermination"); >- scheduledDestruction >- .setJavaCapabilityClass("org.apache.muse.ws.resource.lifetime.impl.SimpleScheduledTermination"); >- >- CapabilityType subscriptionManager = DescriptorFactory.eINSTANCE >- .createCapabilityType(); >- subscriptionManager >- .setCapabilityUri("http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager"); >- subscriptionManager >- .setJavaCapabilityClass("org.apache.muse.ws.notification.impl.SimpleSubscriptionManager"); >- >- InitParamType noValidateParam = DescriptorFactory.eINSTANCE >- .createInitParamType(); >- noValidateParam.setParamName("validate-wsrp-schema"); >- noValidateParam.setParamValue("false"); >- >- resourceType.getCapability().add(identity); >- resourceType.getCapability().add(manageabilityCharacteristics); >- resourceType.getCapability().add(metadataExchange); >- resourceType.getCapability().add(getCapability); >- resourceType.getCapability().add(setCapability); >- resourceType.getCapability().add(queryCapability); >- resourceType.getCapability().add(immediateDestruction); >- resourceType.getCapability().add(scheduledDestruction); >- resourceType.getCapability().add(subscriptionManager); >- >- resourceType.getInitParam().add(noValidateParam); >- >- return resourceType; >- } >- >- private boolean isNotificationProducerCapability(Capability capability) >- { >- boolean isNpNS = capability.getNamespace().equals( >- "http://docs.oasis-open.org/wsn/bw-2"); >- boolean isNpName = capability.getName().equals("NotificationProducer"); >- Operation[] operations = capability.getWsdlDefinition().getOperations(); >- if (operations == null || operations.length < 2) >- return false; >- boolean isSubscribeOp = WsdlUtils.getOperationName(operations[0]) >- .equals("Subscribe"); >- boolean isGetCurrentMessageOp = WsdlUtils.getOperationName( >- operations[1]).equals("GetCurrentMessage"); >- return isNpNS && isNpName && isSubscribeOp && isGetCurrentMessageOp; >- } >- >- /** >- * Sets the parent directory >- * @param mrtParentDir >- */ >- public void setMrtParentDirectory(String mrtParentDir) >- { >- _mrtParentDirName = mrtParentDir; >- } >- /** >- * Returns the initial instances >- * @return InitialInstancesType[] >- */ >- public InitialInstancesType[] getInitialInstances() >- { >- InitialInstancesType instance = DescriptorFactory.eINSTANCE >- .createInitialInstancesType(); >- ResourceTypeType rtClone = MRTCodeGenerationDelegate >- .cloneResourceType(_subManagerResourceType); >- instance.setResourceType(rtClone); >- ReferenceParametersType refParam = DescriptorFactory.eINSTANCE >- .createReferenceParametersType(); >- instance.setReferenceParameters(refParam); >- return new InitialInstancesType[] { instance }; >- } >- >- /** >- * This method will persist the extra artifacts generated at codegen time (SubscriptionManager.mrt file). >- */ >- public void persistArtifacts() >- { >- ResourceSet rs = new ResourceSetImpl(); >- rs.getResourceFactoryRegistry().getExtensionToFactoryMap() >- .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new CustomMrtResourceFactoryImpl()); >- byte[] rawNewMRT = MrtUtils.serializeMRT(_subManagerMRT, rs, URI >- .createURI("dummy.xml"), true); >- InputStream stream = new ByteArrayInputStream(rawNewMRT); >- >- try >- { >- String subManagerMrt = _mrtParentDirName + "/" >- + "SubscriptionManager.mrt"; >- IFile subManagerMrtFile = EclipseUtils.getIFile(subManagerMrt); >- if (subManagerMrtFile.exists()) >- { >- subManagerMrtFile.setContents(stream, true, true, >- new NullProgressMonitor()); >- } >- else >- { >- subManagerMrtFile.create(stream, true, >- new NullProgressMonitor()); >- } >- try >- { >- stream.close(); >- } >- catch (IOException e) >- { >- WsdmToolingLog.logError(e.getMessage(), e); >- } >- } >- catch (CoreException e) >- { >- WsdmToolingLog.logError(e.getMessage(), e); >- } >- } >- >- /** >- * This method will returns the extra generated ManageableResourceType object equivalent to SubscriptionManager. >- */ >- public ManageableResourceType getExtraGeneratedMrt() >- { >- return _subManagerMRT; >- } >- >- /** >- * This method should return the persistance location for extra generated ManageableResourceType object equivalent to SubscriptionManager. >- */ >- public String getExtraGeneratedMrtPersistanceLocation() >- { >- return _mrtParentDirName+"/SubscriptionManager.mrt"; >- } >- >- /** >- * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given >- * merged RMD document for it by having the rules/relationships in it. >- */ >- public void inspectMetadata(ManageableResourceType mrt, >- MetadataDescriptor rmd) >- { >- } >- >- >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/DescriptorHelper.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/DescriptorHelper.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/DescriptorHelper.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/DescriptorHelper.java 13 Apr 2007 04:20:48 -0000 1.12 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,588 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Andrew Eberbach (aeberbac@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.io.File; >-import java.io.FileInputStream; >-import java.io.IOException; >-import java.io.InputStream; >-import java.net.URL; >-import java.util.ArrayList; >-import java.util.Arrays; >-import java.util.HashMap; >-import java.util.LinkedList; >-import java.util.List; >-import java.util.Map; >- >-import javax.xml.namespace.QName; >- >-import org.apache.muse.core.descriptor.DescriptorConstants; >-import org.apache.muse.util.xml.XmlUtils; >-import org.apache.muse.ws.addressing.WsaConstants; >-import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IWorkspace; >-import org.eclipse.core.resources.IWorkspaceRoot; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.FileLocator; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >-import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >-import org.w3c.dom.Document; >-import org.w3c.dom.Element; >-import org.w3c.dom.NamedNodeMap; >-import org.w3c.dom.Node; >- >-/** >- * A class that takes some of the pain out of working with the deployment >- * descriptor. Note, there's no EMF in this approach, just plain old XML. >- */ >-public class DescriptorHelper >-{ >- >- /** >- * File Extension of MRT files >- */ >- private static final String MRT_EXTN = ".mrt"; >- >- /** >- * Element name constants >- */ >- public static final QName ADDITIONAL_JARS_QNAME = new QName( >- DescriptorConstants.NAMESPACE_URI, "additional-jars"); >- public static final QName JAR_PATH_QNAME = new QName( >- DescriptorConstants.NAMESPACE_URI, "jar-path"); >- public static final QName INITIAL_INSTANCES_QNAME = new QName( >- DescriptorConstants.NAMESPACE_URI, "initial-instances"); >- public static final QName REFERENCE_PARAMETERS_QNAME = new QName( >- DescriptorConstants.NAMESPACE_URI, "referenceParameters"); >- >- /** >- * Constant for empty files >- */ >- private static final File[] EMPTY_FILES = new File[0]; >- >- /** >- * Constant for empty instances. >- */ >- private static final Object[][] EMPTY_INSTANCES = new Object[0][0]; >- >- /** >- * Constant for the xmlns prefix on namespace binding declarations >- */ >- private static final Object XMLNS_PREFIX = "xmlns"; >- >- /** >- * The descriptor document we pull out of the <code>Root</code> element >- */ >- private Document _descriptorDocument; >- >- /** >- * A list of jar files that we pull out of the >- * <code>Root/additional-jars</code> element >- */ >- private File[] _jarFiles; >- >- /** >- * A list of instances which is really just a n by 2 list of arrays. The >- * sub-arrays have the instance-path (<code>String</code>) as the first >- * element and the reference parameters (<code>Element</code>) as the >- * second element. This is tacky, but otherwise I'd be making a pretty >- * useless "Pair" class. >- */ >- private Object[][] _instances; >- >- private IFile ddIFile; >- >- /** >- * Descriptor file stores the MRT file reference in Wsdl-File element. >- * When we do the codegeneration we generate some extra MRTs such as SubscriptionManager, >- * so we pass the map of these MRTs to this class. >- * Key will be the persisted location of MRT and value will be the ManageableREsourceType object. >- */ >- private Map _mrtObjectMap = new HashMap(); >- >- private CodeGenerationDelegate _codeGenerationDelegate = null; >- >- /** >- * A do-something constructor. Take a file, if that file is null, then load >- * up a default template. Otherwise load up the file and pull out the >- * instances, descriptor and additional jars. For the null file case, there >- * will be no instances of additional-jars, hence the constants defined >- * above. >- * >- * @param file - The file to analyze, can be null. >- * @throws Exception - If anything goes wrong. >- */ >- public DescriptorHelper(CodeGenerationDelegate codeGenerationDelegate, IFile descriptorFile) throws Exception >- { >- this(codeGenerationDelegate, new File(descriptorFile.getLocation().toString())); >- ddIFile = descriptorFile; >- } >- >- /** >- * A do-something constructor. Take a file, if that file is null, then load >- * up a default template. Otherwise load up the file and pull out the >- * instances, descriptor and additional jars. For the null file case, there >- * will be no instances of additional-jars, hence the constants defined >- * above. >- * >- * @param file - The file to analyze, can be null. >- * @throws Exception - If anything goes wrong. >- */ >- public DescriptorHelper(CodeGenerationDelegate codeGenerationDelegate, File file) throws Exception >- { >- this(codeGenerationDelegate, new FileInputStream(file), null); >- } >- >- /** >- * A do-something constructor. Take a inputstream, if that inputstream is null, then load >- * up a default template. Otherwise load up the inputstream and pull out the >- * instances, descriptor and additional jars. For the null inputstream case, there >- * will be no instances of additional-jars, hence the constants defined >- * above. >- * >- * @param inputstream - The inputstream to analyze, can be null. >- * @param mrtObjectMap - The map of MRTLocation-MRTObject pair, can be null. >- * @throws Exception - If anything goes wrong. >- */ >- public DescriptorHelper(CodeGenerationDelegate codeGenerationDelegate, InputStream inputStream, Map mrtObjectMap, boolean extractExtraInfo) throws Exception >- { >- if(mrtObjectMap!=null) >- _mrtObjectMap = mrtObjectMap; >- _codeGenerationDelegate = codeGenerationDelegate; >- >- Document rootDocument = XmlUtils.createDocument(inputStream); >- >- _descriptorDocument = extractDescriptorDocument(rootDocument); >- >- if(extractExtraInfo) { >- _instances = extractInstances(rootDocument); >- _jarFiles = extractJarFiles(rootDocument); >- } else { >- _instances = null; >- _jarFiles = null; >- } >- // Add Muse tools.jar >- if(_jarFiles == null) >- _jarFiles = new File[0]; >- String toolsJarLocation = getMuseToolsJarLocation(); >- if(toolsJarLocation == null) >- return; >- List jars = Arrays.asList(_jarFiles); >- List allJars = new ArrayList(); >- allJars.addAll(jars); >- allJars.add(new File(toolsJarLocation)); >- _jarFiles = (File[])allJars.toArray(new File[allJars.size()]); >- } >- >- public DescriptorHelper(CodeGenerationDelegate codeGenerationDelegate, InputStream inputStream, Map mrtObjectMap) throws Exception { >- this(codeGenerationDelegate, inputStream, mrtObjectMap, true); >- } >- >- /** >- * Extract the instances from the initial-instances element. >- * >- * TODO this needs to be updated when the initial instances element actually >- * works. >- * >- * @param rootDocument >- * @return >- */ >- private Object[][] extractInstances(Document rootDocument) >- { >- Element[] initialInstancesElements = XmlUtils.findInSubTree( >- rootDocument.getDocumentElement(), INITIAL_INSTANCES_QNAME); >- if (initialInstancesElements.length == 0) >- { >- return EMPTY_INSTANCES; >- } >- >- // sorry about this, maybe someday java will have a Pair type >- Object[][] instances = new Object[initialInstancesElements.length][2]; >- >- for (int i = 0; i < initialInstancesElements.length; i++) >- { >- Element contextElement = XmlUtils.findFirstInSubTree( >- initialInstancesElements[i], >- DescriptorConstants.CONTEXT_PATH_QNAME); >- instances[i][0] = XmlUtils.extractText(contextElement); >- Element instancesElement = XmlUtils.findFirstInSubTree( >- initialInstancesElements[i], REFERENCE_PARAMETERS_QNAME); >- >- Element referenceParametersElement = XmlUtils.createElement(WsaConstants.PARAMETERS_QNAME); >- >- Element[] referenceParameters = XmlUtils.getAllElements(instancesElement); >- Document owner = referenceParametersElement.getOwnerDocument(); >- for(int j=0; j < referenceParameters.length; j++) { >- referenceParametersElement.appendChild(owner.importNode(referenceParameters[j], true)); >- } >- instances[i][1] = referenceParametersElement; >- } >- >- return instances; >- } >- >- /** >- * Extract the jars from the additional jars element. Just read through each >- * element, take the text content (which should be an absolute path) and put >- * it into a <code>File</code> object. Returns a list of these >- * <code>File</code>s. >- * >- * @param rootDocument >- * The <code>Root</code> element-containing >- * <code>Document</code> >- * >- * @return A list of <code>File</code>s for each path found under >- * additional-jars >- */ >- private File[] extractJarFiles(Document rootDocument) >- { >- Element additionalJarsElement = XmlUtils.findFirstInSubTree( >- rootDocument.getDocumentElement(), ADDITIONAL_JARS_QNAME); >- if (additionalJarsElement == null) >- { >- return EMPTY_FILES; >- } >- >- Element[] jarPaths = XmlUtils.findInSubTree(additionalJarsElement, >- JAR_PATH_QNAME); >- if (jarPaths.length == 0) >- { >- return EMPTY_FILES; >- } >- >- File[] files = new File[jarPaths.length]; >- >- for (int i = 0; i < jarPaths.length; i++) >- { >- files[i] = new File(XmlUtils.extractText(jarPaths[i])); >- } >- return files; >- } >- >- private String getMuseToolsJarLocation() >- { >- URL url = FileLocator.find(org.apache.muse.tools.Activator.getDefault().getBundle(), new Path("runtime/tools.jar"), null); >- try >- { >- url = FileLocator.resolve(url); >- return url.getFile(); >- } >- catch (IOException ioe) >- { >- WsdmToolingLog.logError(ioe.getMessage(), ioe); >- } >- return null; >- } >- >- /** >- * Get the Muse descriptor out of the document. Just looks for the >- * <code>DescriptorConstants.MUSE_QNAME</code> QName. >- * >- * @param rootDocument >- * The <code>Root</code> element-containing >- * <code>Document</code> >- * @return The new <code>Document</code> that has as its document element >- * the muse descriptor >- */ >- private Document extractDescriptorDocument(Document rootDocument) >- { >- Element museElement = XmlUtils.findFirstInSubTree(rootDocument >- .getDocumentElement(), DescriptorConstants.MUSE_QNAME); >- Document descriptorDocument = XmlUtils.createDocument(); >- descriptorDocument.appendChild(descriptorDocument.importNode( >- museElement, true)); >- >- copyNamespacePrefixes(rootDocument.getDocumentElement(), >- descriptorDocument.getDocumentElement()); >- >- museElement = XmlUtils.getElement(descriptorDocument,DescriptorConstants.MUSE_QNAME); >- adjustCustomSerializers(museElement); >- >- return descriptorDocument; >- } >- >- /** >- * Given a source <code>Element</code> and a destination >- * <code>Element</code> copy all of the namespace prefixese from the >- * source to the destination. This is really horrid because of DOM's API >- * being what it is and we treat the declarations as attributes. Yes, we do >- * check to make sure we don't do double prefix declarations. >- * >- * TODO this should go into a namespace utility class, I've had to write >- * this in about 3 places now. >- * >- * @param source >- * The source <code>Element</code> >- * @param destination >- * The destination <code>Element</code> >- */ >- private void copyNamespacePrefixes(Element source, Element destination) >- { >- NamedNodeMap attributes = source.getAttributes(); >- int size = attributes.getLength(); >- for (int i = 0; i < size; i++) >- { >- Node nextAttribute = attributes.item(i); >- String prefix = nextAttribute.getPrefix(); >- >- if (prefix == null || !prefix.equals(XMLNS_PREFIX)) >- { >- continue; >- } >- >- if (destination.hasAttribute(nextAttribute.getNodeName())) >- { >- continue; >- } >- >- destination.setAttribute(nextAttribute.getNodeName(), nextAttribute >- .getNodeValue()); >- } >- } >- >- /** >- * Descriptor editor stores the xsd-serializer-type for custom-serializer as >- * >- * <custom-serializer> >- * <xsd-serializer-type>{http://www.eclipse.org/TP}StateType</xsd-serializer-type> >- * <custom-serializer> >- * >- * We have to convert the QName to prefix:localpart format so we adjust this part as >- * >- * <custom-serializer> >- * <xsd-serializer-type xmlns:pfx="http://www.eclipse.org/TP">pfx:StateType</xsd-serializer-type> >- * <custom-serializer> >- * >- */ >- private void adjustCustomSerializers(Element museElement) >- { >- Element[] serializerElements = XmlUtils.getElements(museElement, DescriptorConstants.CUSTOM_SERIALIZER_QNAME); >- for(int i=0;i<serializerElements.length;i++) >- { >- // TODO Replace the QName with MUSE constant in MUSE 2.2 >- Element xsdSerializerElement = XmlUtils.getElement(serializerElements[i], new QName(DescriptorConstants.NAMESPACE_URI,"xsd-serializable-type")); >- String qNameAsString = XmlUtils.extractText(xsdSerializerElement); >- if(qNameAsString!=null && !qNameAsString.equals("")) >- { >- try >- { >- QName qname = QName.valueOf(qNameAsString); >- String namespace = qname.getNamespaceURI(); >- String localPart = qname.getLocalPart(); >- if(namespace.equals("")) >- break; >- xsdSerializerElement.setAttribute("pfx", namespace); >- XmlUtils.setElementText(xsdSerializerElement, "pfx:"+localPart); >- } >- catch(IllegalArgumentException e) >- { >- WsdmToolingLog.logError(e.getMessage(), e); >- } >- } >- } >- } >- >- /** >- * Returns the Descriptor document >- * @return Document >- */ >- public Document getDescriptorDocument() >- { >- return _descriptorDocument; >- } >- /** >- * Returns the Jar files >- * @return File[] >- */ >- public File[] getJarFiles() >- { >- return _jarFiles; >- } >- >- /** >- * Returns the instances >- * @return Object[][] >- */ >- public Object[][] getInstances() >- { >- return _instances; >- } >- >- /** >- * Go through the parsed Muse descriptor associated with this object and >- * find all of the MRT files referenced therein. For each MRT file use >- * <code>WsdlMerge</code> to merge the MRT's WSDL into a consolidate WSDL. >- * Return the Muse Descriptor document-order list of the WSDL files. >- * The passed map will contain the MRT file location as key and MRT object as value. >- * So first search the map for MRT if not found then load the MRT from location. >- * >- * @return A list of merged WSDL files as gathered from the deployment >- * descriptor >- * >- * @see org.eclipse.tptp.wsdm.tooling.wizard.mrt.internal.WsdlResolverDelegate#getWsdlDocuments() >- */ >- public Document[] getWsdlDocuments(String baseAddress) >- { >- Element[] resourceTypes = XmlUtils.findInSubTree(_descriptorDocument >- .getDocumentElement(), DescriptorConstants.RESOURCE_TYPE_QNAME); >- int mrtCount = resourceTypes.length; >- Document[] mergedWSDLs = new Document[mrtCount]; >- >- for (int i = 0; i < mrtCount; i++) >- { >- Element wsdlFileElement = XmlUtils.findFirstInSubTree( >- resourceTypes[i], DescriptorConstants.WSDL_FILE_QNAME); >- >- String wsdlPath = XmlUtils.extractText(wsdlFileElement); >- String mrtPath = getMRTPathFromWSDLPath(wsdlPath); >- ManageableResourceType mrt = null; >- String serviceAddress = null; >- if(_mrtObjectMap!=null && _mrtObjectMap.containsKey(mrtPath)) >- { >- mrt = (ManageableResourceType) _mrtObjectMap.get(mrtPath); >- serviceAddress = baseAddress+"/"+mrt.getIdentifier(); >- } >- else >- { >- IWorkspace workspace = ResourcesPlugin.getWorkspace(); >- IWorkspaceRoot root = workspace.getRoot(); >- IPath mrtFilePath = root.findMember(mrtPath).getFullPath(); >- URI uri = URI.createFileURI(mrtFilePath.toString()); >- mrt = MrtUtils.loadMRT(uri); >- serviceAddress = makeServiceAddress(baseAddress, mrtFilePath); >- } >- if(mrt!=null) >- { >- try >- { >- mergedWSDLs[i] = MrtMerge.createMergedWSDL(mrt, serviceAddress); >- } >- catch (Exception e) >- { >- e.printStackTrace(); >- // TODO AME add externalized message >- throw new RuntimeException(e); >- } >- } >- else >- { >- // TODO AME add externalized message >- throw new RuntimeException(); >- } >- } >- return mergedWSDLs; >- } >- >- /** >- * Given a base address add the service name. This is done by getting the >- * name of the MRT file and stripping off the file extension. >- * >- * @param baseAddress >- * Base address >- * @param file >- * MRT file to use >- * @return the combined address >- */ >- private String makeServiceAddress(String baseAddress, IPath file) >- { >- String fileName = file.toFile().getName(); >- fileName = fileName.substring(0, fileName.lastIndexOf(".")); >- return baseAddress + "/" + fileName; >- } >- >- private String getMRTPathFromWSDLPath(String fileName) >- { >- return fileName.substring(0, fileName.lastIndexOf(".")) + MRT_EXTN; >- } >- >- /** >- * Adds the additional jar files to Descriptor file. >- * >- * @param serverLocation >- * Parent directory of Axis2-lib folder. >- * >- * @param axis2files >- * Axis2 jar files path. >- */ >- public void addAdditionalJars(String serverLocation, String[] axis2files) >- { >- List additionalJarFiles = new LinkedList(); >- if(_jarFiles!=null) >- additionalJarFiles.addAll(Arrays.asList(_jarFiles)); >- for(int i = 0 ; i < axis2files.length ; i++ ) >- additionalJarFiles.add(new File(serverLocation + File.separator + axis2files[i])); >- _jarFiles = (File[]) additionalJarFiles.toArray(new File[additionalJarFiles.size()]); >- } >- >- /** >- * Go through the parsed Muse descriptor associated with this object and >- * find all of the MRT files referenced therein. For each MRT file create >- * a merged RMD document. >- * >- * @return A list of merged RMD documents as gathered from the deployment >- * descriptor >- * >- */ >- public MetadataDescriptor[] getMergedRMDs() >- { >- Element[] resourceTypes = XmlUtils.findInSubTree(_descriptorDocument >- .getDocumentElement(), DescriptorConstants.RESOURCE_TYPE_QNAME); >- int mrtCount = resourceTypes.length; >- MetadataDescriptor[] mergedRMDs = new MetadataDescriptor[mrtCount]; >- >- for (int i = 0; i < mrtCount; i++) >- { >- Element wsdlFileElement = XmlUtils.findFirstInSubTree( >- resourceTypes[i], DescriptorConstants.WSDL_FILE_QNAME); >- >- String wsdlPath = XmlUtils.extractText(wsdlFileElement); >- String mrtPath = getMRTPathFromWSDLPath(wsdlPath); >- ManageableResourceType mrt = null; >- String serviceAddress = null; >- if(_mrtObjectMap!=null && _mrtObjectMap.containsKey(mrtPath)) >- { >- mrt = (ManageableResourceType) _mrtObjectMap.get(mrtPath); >- } >- else >- { >- IWorkspace workspace = ResourcesPlugin.getWorkspace(); >- IWorkspaceRoot root = workspace.getRoot(); >- IPath mrtFilePath = root.findMember(mrtPath).getFullPath(); >- URI uri = URI.createFileURI(mrtFilePath.toString()); >- mrt = MrtUtils.loadMRT(uri); >- } >- if(mrt!=null) >- { >- try >- { >- mergedRMDs[i] = MrtMerge.createMergedRMD(mrt); >- _codeGenerationDelegate.inspectMetadata(mrt, mergedRMDs[i]); >- } >- catch (Exception e) >- { >- throw new RuntimeException(e); >- } >- } >- else >- { >- throw new RuntimeException(); >- } >- } >- return mergedRMDs; >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/TargetedFileList.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/TargetedFileList.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/TargetedFileList.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/TargetedFileList.java 23 Mar 2007 03:54:29 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,41 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.util.ArrayList; >- >-public class TargetedFileList { >- private String _relativePath; // path relative to webcontent folder >- private ArrayList _absoluteFilePaths; >- >- public TargetedFileList(String relativePath){ >- _relativePath = relativePath; >- _absoluteFilePaths = new ArrayList(); >- } >- >- public void add(String absolutePath){ >- if(absolutePath!=null && !absolutePath.trim().equals("")){ >- _absoluteFilePaths.add(absolutePath); >- } >- } >- >- public String[] getFiles(){ >- if(_absoluteFilePaths==null) return new String[]{}; >- return (String[]) _absoluteFilePaths.toArray(new String[]{}); >- } >- >- public String getRelativePath(){ >- return _relativePath; >- } >- >- >-} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/GenerationOptionsPage.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/GenerationOptionsPage.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/GenerationOptionsPage.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/GenerationOptionsPage.java 1 May 2007 16:40:34 -0000 1.11 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,674 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.util.HashMap; >-import java.util.Iterator; >-import java.util.Map; >-import java.util.prefs.Preferences; >- >-import org.apache.muse.tools.generator.analyzer.Analyzer; >-import org.apache.muse.tools.generator.projectizer.Projectizer; >-import org.apache.muse.tools.generator.synthesizer.Synthesizer; >-import org.eclipse.core.filesystem.URIUtil; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IWorkspace; >-import org.eclipse.core.resources.IWorkspaceRoot; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.IConfigurationElement; >-import org.eclipse.core.runtime.IExtension; >-import org.eclipse.core.runtime.IExtensionPoint; >-import org.eclipse.core.runtime.IExtensionRegistry; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.jface.dialogs.DialogPage; >-import org.eclipse.jface.util.Util; >-import org.eclipse.jface.wizard.WizardPage; >-import org.eclipse.osgi.util.TextProcessor; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.ModifyEvent; >-import org.eclipse.swt.events.ModifyListener; >-import org.eclipse.swt.events.SelectionAdapter; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.Button; >-import org.eclipse.swt.widgets.Combo; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.DirectoryDialog; >-import org.eclipse.swt.widgets.Event; >-import org.eclipse.swt.widgets.Group; >-import org.eclipse.swt.widgets.Label; >-import org.eclipse.swt.widgets.Listener; >-import org.eclipse.swt.widgets.Text; >-import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; >-import org.eclipse.tptp.wsdm.tooling.editor.mrt.relationship.dialog.internal.MemoryComboBox; >-import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; >-import org.eclipse.tptp.wsdm.tooling.util.internal.Validation; >- >-/** >- * This wizard enables the use to specify the projectizer options and also the >- * runtime environment and general options >- */ >-public class GenerationOptionsPage extends WizardPage >-{ >- private static final String PROJECT_MEMORY_COMBO_ID = "project_memory_combo"; >- >- private static final String EXT_PT = "codeGeneration"; >- >- private Button _overwriteButton; >- >- private Combo _projectNameField; >- >- private String _userPath = Util.ZERO_LENGTH_STRING;// IDEResourceInfoUtils.EMPTY_STRING; >- >- private Button _useDefaultsButton; >- >- private Label _locationLabel; >- >- private Text _locationPathField; >- >- private Button _browseButton; >- >- private IProject _existingProject; >- >- private Combo _projectizerCombo; >- >- private Button _persistExtraArtifactsButton; >- >- private Map _platformContainerMap = new HashMap(); >- >- private Combo _containerCombo; >- >- private Label _containerLabel; >- >- public GenerationOptionsPage() { >- super("wizardPage"); >- setTitle(Messages.HOOKUP_WIZARD_TXT1); >- setDescription(Messages.HOOKUP_WIZARD_TXT2); >- >- loadExtensionData(); >- } >- >- private void loadExtensionData() { >- IExtensionRegistry er = Platform.getExtensionRegistry(); >- IExtensionPoint ep = er.getExtensionPoint(Activator.PLUGIN_ID, EXT_PT); >- IExtension[] extensions = ep.getExtensions(); >- >- for (int i = 0; i < extensions.length; i++) { >- IConfigurationElement[] elements = extensions[i].getConfigurationElements(); >- CodeGenerationData codeGenData = new CodeGenerationData(elements); >- updatePlatformContainerMap(codeGenData); >- } >- } >- >- private void updatePlatformContainerMap(CodeGenerationData codeGenData) { >- Map containerCodeGenDataMap = (Map) _platformContainerMap.get(codeGenData.getPlatform()); >- if(containerCodeGenDataMap == null) { >- // >- // handles the case of proxy which doesn't have a container >- // >- if(codeGenData.getContainer() == null) { >- containerCodeGenDataMap = new SingleValueMap(); >- } else { >- containerCodeGenDataMap = new HashMap(); >- } >- >- _platformContainerMap.put(codeGenData.getPlatform(), containerCodeGenDataMap); >- } >- >- // >- // if the platform was null then it means we're using a >- // singlevaluemap which doesn't look at the key ever >- // >- containerCodeGenDataMap.put(codeGenData.getContainer(), codeGenData); >- } >- >- public void createControl(Composite parent) { >- setControl(doLayout(parent)); >- dialogChanged(); >- } >- >- private Composite doLayout(Composite parent) { >- Composite container = new Composite(parent, SWT.NULL); >- container.setLayout(new GridLayout(2, false)); >- >- GridData data = new GridData(); >- data.horizontalAlignment = SWT.FILL; >- data.grabExcessHorizontalSpace = true; >- container.setLayoutData(data); >- >- createProjectInput(container); >- >- Composite composite = createProjectTypeGroup(container); >- >- data = new GridData(); >- data.grabExcessHorizontalSpace = true; >- data.horizontalAlignment = SWT.FILL; >- data.horizontalSpan = 2; >- composite.setLayoutData(data); >- >- composite = createProjectOptionsGroup(container); >- >- data = new GridData(); >- data.grabExcessHorizontalSpace = true; >- data.horizontalAlignment = SWT.FILL; >- data.horizontalSpan = 2; >- composite.setLayoutData(data); >- return container; >- } >- >- private void createProjectInput(Composite parent) { >- Label projectNameLabel = new Label(parent, SWT.NONE); >- projectNameLabel.setText(Messages.HOOKUP_WIZARD_TXT4); >- >- GridData data = new GridData(); >- data.horizontalAlignment = SWT.FILL; >- data.grabExcessHorizontalSpace = false; >- projectNameLabel.setLayoutData(data); >- >- _projectNameField = MemoryComboBox.createMemoryComboBox(parent, Preferences.userNodeForPackage(GenerationOptionsPage.class), PROJECT_MEMORY_COMBO_ID); >- >- data = new GridData(); >- data.horizontalAlignment = SWT.FILL; >- data.grabExcessHorizontalSpace = true; >- _projectNameField.setLayoutData(data); >- >- _projectNameField.addListener(SWT.Modify, nameModifyListener); >- } >- >- private Group createProjectTypeGroup(Composite parent) { >- Group page = new Group(parent, SWT.SHADOW_IN); >- page.setText("Code Generation Options"); >- page.setLayout(new GridLayout(2, false)); >- >- Label platformLabel = new Label(page, SWT.NONE); >- platformLabel.setText("Platform:");//TODO AME >- _projectizerCombo = makePlatformCombo(page); >- >- _containerLabel = new Label(page, SWT.NONE); >- _containerLabel.setText("Container:");//TODO AME >- _containerLabel.setEnabled(false); >- >- _containerCombo = makeContainerCombo(page); >- >- return page; >- } >- >- private Group createProjectOptionsGroup(Composite parent) { >- Group group = new Group(parent, SWT.SHADOW_IN); >- group.setText("Project Options"); >- group.setLayout(new GridLayout(3, false)); >- >- _useDefaultsButton = createDefaultsButton(group); >- >- GridData buttonData = new GridData(); >- buttonData.horizontalSpan = 3; >- _useDefaultsButton.setLayoutData(buttonData); >- >- createUserEntryArea(group, true); >- createCheckboxes(group); >- >- return group; >- } >- >- private Button createDefaultsButton(Composite parent) { >- Button button = new Button(parent, SWT.CHECK | SWT.RIGHT); >- button.setText(Messages.CODE_GEN_DEFAULT_LOCATION);// IDEWorkbenchMessages.ProjectLocationSelectionDialog_useDefaultLabel); >- button.setSelection(true); >- >- button.addSelectionListener(new SelectionAdapter() >- { >- public void widgetSelected(SelectionEvent e) >- { >- boolean useDefaults = _useDefaultsButton.getSelection(); >- >- if (!useDefaults) >- { >- _userPath = _locationPathField.getText(); >- _locationPathField.setText(TextProcessor >- .process(getDefaultPathDisplayString())); >- } >- else >- { >- _locationPathField >- .setText(TextProcessor.process(_userPath)); >- } >- setUserAreaEnabled(!useDefaults); >- } >- }); >- >- return button; >- } >- >- private void createCheckboxes(Composite parent) { >- GridData data = null; >- >- _overwriteButton = makeButton(parent, Messages.HOOKUP_WIZARD_TXT3, SWT.CHECK); >- >- data = new GridData(); >- data.horizontalSpan = 2; >- _overwriteButton.setLayoutData(data); >- >- _persistExtraArtifactsButton = makeButton(parent, Messages.HOOKUP_WIZARD_PERSIST, SWT.CHECK); >- >- data = new GridData(); >- data.horizontalSpan = 2; >- _persistExtraArtifactsButton.setLayoutData(data); >- } >- >- private Combo makeContainerCombo(Group page) { >- Combo combo = new Combo(page, SWT.BORDER | SWT.READ_ONLY); >- combo.setEnabled(false); >- >- return combo; >- } >- >- private Combo makePlatformCombo(Group page) >- { >- Combo combo = new Combo(page, SWT.BORDER | SWT.READ_ONLY); >- for(Iterator i=_platformContainerMap.keySet().iterator(); i.hasNext();) { >- combo.add(i.next().toString()); >- } >- combo.select(0); >- combo.addListener(SWT.Modify, comboChangeListener); >- >- return combo; >- } >- >- private void setUserAreaEnabled(boolean enabled) >- { >- _locationLabel.setEnabled(enabled); >- _locationPathField.setEnabled(enabled); >- _browseButton.setEnabled(enabled); >- } >- >- private void createUserEntryArea(Composite composite, boolean defaultEnabled) >- { >- GridData data = null; >- >- // location label >- _locationLabel = new Label(composite, SWT.NONE); >- _locationLabel.setText(Messages.HOOKUP_WIZARD_TXT6); >- >- // project location entry field >- _locationPathField = new Text(composite, SWT.BORDER); >- data = new GridData(GridData.FILL_HORIZONTAL); >- _locationPathField.setLayoutData(data); >- >- // browse button >- _browseButton = new Button(composite, SWT.PUSH); >- _browseButton.setText(Messages.HOOKUP_WIZARD_TXT5); >- _browseButton.addSelectionListener(new SelectionAdapter() >- { >- public void widgetSelected(SelectionEvent event) >- { >- handleLocationBrowseButtonPressed(); >- } >- }); >- >- if (defaultEnabled) >- { >- _locationPathField.setText(TextProcessor >- .process(getDefaultPathDisplayString())); >- } >- else >- { >- if (_existingProject == null) >- { >- _locationPathField.setText(Util.ZERO_LENGTH_STRING);// IDEResourceInfoUtils.EMPTY_STRING); >- } >- else >- { >- _locationPathField.setText(TextProcessor >- .process(_existingProject.getLocation().toString())); >- } >- } >- >- _locationPathField.addModifyListener(new ModifyListener() >- { >- public void modifyText(ModifyEvent e) >- { >- setErrorMessage(checkValidLocation()); >- } >- }); >- >- setUserAreaEnabled(false); >- } >- >- public boolean isDefault() >- { >- return _useDefaultsButton.getSelection(); >- } >- >- public String getProjectLocation() >- { >- if(isDefault()) { >- return null; >- } >- >- String projectLocation = _locationPathField.getText(); >- return projectLocation.length() == 0?null:projectLocation; >- } >- >- public String checkValidLocation() >- { >- >- if (isDefault()) >- { >- return null; >- } >- >- String newPath = getProjectLocation(); >- if (newPath == null) >- { >- return Messages.CODE_GEN_LOCATION_ERROR_; >- } >- >- if (_existingProject == null) >- { >- IPath projectPath = new Path(newPath); >- if (Platform.getLocation().isPrefixOf(projectPath)) >- { >- return Messages.NEW_PROJECT_CREATION_PAGE_DEFAULT_LOCATION_ERROR_; >- } >- >- } >- else >- { >- >- IStatus locationStatus = _existingProject.getWorkspace() >- .validateProjectLocationURI(_existingProject, URIUtil.toURI(newPath)); >- >- if (!locationStatus.isOK()) >- { >- return locationStatus.getMessage(); >- } >- >- java.net.URI projectPath = _existingProject.getLocationURI(); >- if (projectPath != null && URIUtil.equals(projectPath, URIUtil.toURI(newPath))) >- { >- return Messages.CODE_GEN_LOCATION_ERROR_; >- } >- } >- >- return null; >- } >- >- private String getDefaultPathDisplayString() >- { >- >- java.net.URI defaultURI = null; >- if (_existingProject != null) >- { >- defaultURI = _existingProject.getLocationURI(); >- } >- >- // Handle files specially. Assume a file if there is no project to query >- if (defaultURI == null || defaultURI.getScheme().equals("file")) >- { >- return Platform.getLocation().append(_projectNameField.getText()) >- .toString(); >- } >- return defaultURI.toString(); >- >- } >- >- private String getPathFromLocationField() >- { >- java.net.URI fieldURI; >- try >- { >- fieldURI = new java.net.URI(_locationPathField.getText()); >- } >- catch (java.net.URISyntaxException e) >- { >- return _locationPathField.getText(); >- } >- return fieldURI.getPath(); >- } >- >- private void updateLocationField(String selectedPath) >- { >- _locationPathField.setText(TextProcessor.process(selectedPath)); >- } >- >- private void handleLocationBrowseButtonPressed() >- { >- >- String selectedDirectory = null; >- String dirName = getPathFromLocationField(); >- >- DirectoryDialog dialog = new DirectoryDialog(_locationPathField >- .getShell()); >- dialog.setMessage(Messages.CODE_GEN_DIR_LOCATION);// IDEWorkbenchMessages.ProjectLocationSelectionDialog_directoryLabel); >- dialog.setFilterPath(dirName); >- selectedDirectory = dialog.open(); >- >- if (selectedDirectory != null) >- updateLocationField(selectedDirectory); >- } >- >- private Listener nameModifyListener = new Listener() >- { >- public void handleEvent(Event e) >- { >- setLocationForSelection(); >- dialogChanged(); >- } >- }; >- >- private Listener comboChangeListener = new Listener() { >- public void handleEvent(Event e) { >- String platform = _projectizerCombo.getText(); >- >- Map containerCodeGenDataMap = (Map) _platformContainerMap.get(platform); >- _containerCombo.removeAll(); >- >- boolean hasContainers = containerCodeGenDataMap.size() != 0; >- >- if(hasContainers) { >- for(Iterator i=containerCodeGenDataMap.keySet().iterator(); i.hasNext();) { >- _containerCombo.add(i.next().toString()); >- } >- _containerCombo.select(0); >- } >- >- _containerCombo.setEnabled(hasContainers); >- _containerLabel.setEnabled(hasContainers); >- >- dialogChanged(); >- } >- }; >- >- void setLocationForSelection() >- { >-// _locationArea.updateProjectName(getProjectNameFieldValue()); >- } >- >- protected void dialogChanged() >- { >- if(true) return; >- String prjName = getProjectName(); >- >- if (prjName.length() == 0) >- { >- updateStatus(Messages.HOOKUP_WIZARD_ERROR_1); >- return; >- } >- >- IWorkspace workspace = ResourcesPlugin.getWorkspace(); >- IWorkspaceRoot root = workspace.getRoot(); >- >- IProject project = root.getProject(prjName); >- >- if (project != null && project.exists()) >- { >- updateStatus(Messages.PROJECT_EXISTS_WARN_, DialogPage.WARNING); >- return; >- } >- >- if (!Validation.isQName(prjName)) >- { >- updateStatus(Messages.HOOKUP_WIZARD_ERROR_2); >- return; >- } >- >- canFlipToNextPage(); >- >- updateStatus(null, DialogPage.NONE); >- } >- >- private void updateStatus(String message) >- { >- updateStatus(message, DialogPage.ERROR); >- } >- >- private void updateStatus(String message, int type) >- { >- setMessage(message, type); >- setPageComplete(type != DialogPage.ERROR); >- } >- >- private Button makeButton(Composite parent, String title, int style) >- { >- Button b = new Button(parent, style); >- b.setText(title); >- return b; >- } >- >- public boolean shouldPersistArtifacts() >- { >- return _persistExtraArtifactsButton.isEnabled(); >- } >- >- /** >- * Return the value of the output project >- * @return String >- */ >- public String getProjectName() >- { >- return _projectNameField.getText(); >- } >- >- /** >- * Returns if Overwrite button is enabled >- * @return boolean >- */ >- public boolean canOverwrite() >- { >- return _overwriteButton.getSelection(); >- } >- >- public CodeGenerationData getSelectedData() { >- String platform = _projectizerCombo.getText(); >- Map containerCodeGenDataMap = (Map) _platformContainerMap.get(platform); >- String container = _containerCombo.getText(); >- return (CodeGenerationData) containerCodeGenDataMap.get(container); >- } >- >- /** >- * Return the projectizer >- * @return {@link Projectizer} >- */ >- public Projectizer getProjectizer() >- { >- return getSelectedData().getProjectizer(); >- } >- >- /** >- * Return the synthesizer >- * @return {@link Synthesizer} >- */ >- public Synthesizer getSynthesizer() >- { >- return getSelectedData().getSynthesizer(); >- } >- >- /** >- * Return the analyzer >- * @return {@link Analyzer} >- */ >- public Analyzer getAnalyzer() >- { >- return getSelectedData().getAnalyzer(); >- } >- >- /** >- * Returns the base address >- * >- * @return String >- */ >- public String getBaseAddress() >- { >- String baseAddress = "http://localhost"; >- >- int port = getSelectedData().getServicePort(); >- if (port != 0) >- { >- baseAddress += ":" + port; >- } >- >- baseAddress += "/" + getProjectName(); >- >- String servicePath = getSelectedData().getServicePath(); >- >- if (servicePath != null) >- { >- baseAddress += servicePath; >- } >- >- return baseAddress; >- } >- >- /** >- * Checks to see if the Next Page can be enabled or not. >- */ >- public boolean canFlipToNextPage(){ >- return true; >-// Axis2ServerLocationPage nextPage = (Axis2ServerLocationPage)this.getNextPage(); >-// if(isPageComplete() && isAxis2Project()) >-// { >-// nextPage.makePageComplete(false); >-// String userLocation = nextPage.getUserDefinedLocation(); >-// if(userLocation != null && userLocation.trim().length() > 0) >-// { >-// nextPage._serverNameField.setText(userLocation); >-// }else >-// { >-// nextPage._serverNameField.setText(nextPage.getPreferenceServerLocation()); >-// } >-// >-// return true; >-// } >-// >-// nextPage.makePageComplete(true); >-// >-// return false; >- } >- >- /** >- * Returns whether the new Project to be created is a Axis2 project >- * @return >- */ >- public boolean isAxis2Project(){ >- String container = getSelectedData().getContainer(); >- return container != null && container.equals("Axis2"); >- } >- >- public void saveCombo() { >- MemoryComboBox.save(_projectNameField, PROJECT_MEMORY_COMBO_ID, Preferences.userNodeForPackage(GenerationOptionsPage.class)); >- } >-} >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/SingleValueMap.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/SingleValueMap.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/SingleValueMap.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/SingleValueMap.java 1 May 2007 16:40:34 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,36 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Andrew Eberbach (aeberbac@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; >- >-import java.util.AbstractMap; >-import java.util.HashSet; >-import java.util.Set; >- >-public class SingleValueMap extends AbstractMap { >- Object _value; >- Set _entrySet = new HashSet(); >- >- public Object get(Object key) { >- return _value; >- } >- >- public Object put(Object key, Object value) { >- Object oldValue = _value; >- _value = value; >- return oldValue; >- } >- >- public Set entrySet() { >- return _entrySet; >- } >-} >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/META-INF/MANIFEST.MF,v >retrieving revision 1.10 >diff -u -r1.10 MANIFEST.MF >--- META-INF/MANIFEST.MF 23 Mar 2007 22:46:52 -0000 1.10 >+++ META-INF/MANIFEST.MF 29 May 2007 23:40:24 -0000 >@@ -24,7 +24,7 @@ > Bundle-Vendor: %providerName > Bundle-RequiredExecutionEnvironment: J2SE-1.4 > Export-Package: org.eclipse.tptp.wsdm.tooling.codegen.dd.internal;x-friends:="org.eclipse.tptp.wsdm.editor.test", >- org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional, >+ org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal;x-internal:=true, > org.eclipse.tptp.wsdm.tooling.dialog.provisional;x-friends:="org.eclipse.tptp.wsdm.editor.test", > org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal;x-friends:="org.eclipse.tptp.wsdm.editor.test", > org.eclipse.tptp.wsdm.tooling.editor.capability.command.overview.internal;x-friends:="org.eclipse.tptp.wsdm.editor.test", >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/plugin.xml,v >retrieving revision 1.15 >diff -u -r1.15 plugin.xml >--- plugin.xml 27 Apr 2007 22:56:26 -0000 1.15 >+++ plugin.xml 29 May 2007 23:40:24 -0000 >@@ -72,7 +72,7 @@ > name="Axis2 Validator" > point="org.eclipse.tptp.wsdm.editor.axisValidator"> > <axisValidator >- validator="org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.Axis2ServerDependency"> >+ validator="org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.Axis2ServerDependency"> > <requiredFiles> > <relativeFilePath>lib/annogen-*.jar</relativeFilePath> > <relativeFilePath>lib/axiom-api-*.jar</relativeFilePath> >@@ -192,7 +192,7 @@ > enablesFor="1" > label="%Generate_Java_Code_Action" > icon="icons/obj16/mrt_obj.gif" >- class="org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.Generation" >+ class="org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.Generation" > id="org.eclipse.tptp.wsdm.tooling.codegen.mrt.action"/> > </objectContribution> > >Index: src/org/eclipse/tptp/wsdm/tooling/nls/messages/mrt/internal/messages.properties >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/nls/messages/mrt/internal/messages.properties,v >retrieving revision 1.19 >diff -u -r1.19 messages.properties >--- src/org/eclipse/tptp/wsdm/tooling/nls/messages/mrt/internal/messages.properties 27 Apr 2007 22:58:07 -0000 1.19 >+++ src/org/eclipse/tptp/wsdm/tooling/nls/messages/mrt/internal/messages.properties 29 May 2007 23:40:27 -0000 >@@ -32,7 +32,7 @@ > SYSTEM_CAPS_ERROR_2 = IWAT0646E Access Denied > HOOKUP_WIZARD_TXT1 = Deployment target and generation options > HOOKUP_WIZARD_TXT2 = This wizard creates code for touchpoint >-HOOKUP_WIZARD_TXT3 = Overwrite files if necessary >+HOOKUP_WIZARD_TXT3 = Overwrite files > HOOKUP_WIZARD_PERSIST = Persist generated artifacts > HOOKUP_WIZARD_TXT4 = Output project > HOOKUP_WIZARD_TXT5 = Browse... >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/Generation.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/Generation.java,v >retrieving revision 1.2 >diff -u -r1.2 Generation.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/Generation.java 28 Feb 2007 05:31:53 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/Generation.java 29 May 2007 23:40:25 -0000 >@@ -18,7 +18,7 @@ > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.StructuredSelection; > import org.eclipse.jface.wizard.WizardDialog; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.NewProjectWizard; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.NewProjectWizard; > import org.eclipse.ui.IObjectActionDelegate; > import org.eclipse.ui.IWorkbenchPart; > >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/DDCodeGenerationDelegate.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/DDCodeGenerationDelegate.java,v >retrieving revision 1.8 >diff -u -r1.8 DDCodeGenerationDelegate.java >--- src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/DDCodeGenerationDelegate.java 13 Apr 2007 03:47:47 -0000 1.8 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/DDCodeGenerationDelegate.java 29 May 2007 23:40:25 -0000 >@@ -31,9 +31,9 @@ > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.emf.ecore.resource.ResourceSet; > import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.CodeGenerationDelegate; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.DescriptorHelper; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.MrtPreProcessor; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.CodeGenerationDelegate; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.DescriptorHelper; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.MrtPreProcessor; > import org.eclipse.tptp.wsdm.tooling.editor.dde.util.internal.DdeUtil; > import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; > import org.eclipse.tptp.wsdm.tooling.util.internal.MyDescriptorResourceFactoryImpl; >Index: src/org/eclipse/tptp/wsdm/tooling/validation/util/internal/ValidationUtils.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/validation/util/internal/ValidationUtils.java,v >retrieving revision 1.3 >diff -u -r1.3 ValidationUtils.java >--- src/org/eclipse/tptp/wsdm/tooling/validation/util/internal/ValidationUtils.java 28 Feb 2007 06:04:22 -0000 1.3 >+++ src/org/eclipse/tptp/wsdm/tooling/validation/util/internal/ValidationUtils.java 29 May 2007 23:40:27 -0000 >@@ -20,7 +20,7 @@ > import org.eclipse.core.runtime.IExtensionPoint; > import org.eclipse.core.runtime.IExtensionRegistry; > import org.eclipse.core.runtime.Platform; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.ISoapServerDependency; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.ISoapServerDependency; > import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; > import org.eclipse.tptp.wsdm.tooling.nls.messages.validation.internal.Messages; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >Index: src/org/eclipse/tptp/wsdm/tooling/preferences/internal/Axis2ServerLocationPreferencePage.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/preferences/internal/Axis2ServerLocationPreferencePage.java,v >retrieving revision 1.2 >diff -u -r1.2 Axis2ServerLocationPreferencePage.java >--- src/org/eclipse/tptp/wsdm/tooling/preferences/internal/Axis2ServerLocationPreferencePage.java 16 Mar 2007 18:04:37 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/preferences/internal/Axis2ServerLocationPreferencePage.java 29 May 2007 23:40:27 -0000 >@@ -27,7 +27,7 @@ > import org.eclipse.swt.widgets.DirectoryDialog; > import org.eclipse.swt.widgets.Label; > import org.eclipse.swt.widgets.Text; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.Axis2LicenseDialog; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.Axis2LicenseDialog; > import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; > import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; > import org.eclipse.ui.IWorkbench; >Index: src/org/eclipse/tptp/wsdm/tooling/editor/dde/util/internal/DdeUtil.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/dde/util/internal/DdeUtil.java,v >retrieving revision 1.9 >diff -u -r1.9 DdeUtil.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/dde/util/internal/DdeUtil.java 27 Apr 2007 22:56:26 -0000 1.9 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/dde/util/internal/DdeUtil.java 29 May 2007 23:40:25 -0000 >@@ -68,7 +68,7 @@ > import org.eclipse.swt.widgets.Table; > import org.eclipse.swt.widgets.TableItem; > import org.eclipse.swt.widgets.Text; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.Generation; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.Generation; > import org.eclipse.tptp.wsdm.tooling.editor.dde.internal.DescriptorEditor; > import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; > import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportWSDLOperationCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportWSDLOperationCommand.java,v >retrieving revision 1.4 >diff -u -r1.4 ImportWSDLOperationCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportWSDLOperationCommand.java 26 Apr 2007 11:54:01 -0000 1.4 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportWSDLOperationCommand.java 29 May 2007 23:40:25 -0000 >@@ -32,7 +32,7 @@ > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.emf.common.util.URI; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.EclipseEnvironment; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.EclipseEnvironment; > import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; >Index: schema/axisValidator.exsd >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/schema/axisValidator.exsd,v >retrieving revision 1.3 >diff -u -r1.3 axisValidator.exsd >--- schema/axisValidator.exsd 23 Mar 2007 17:55:24 -0000 1.3 >+++ schema/axisValidator.exsd 29 May 2007 23:40:24 -0000 >@@ -55,10 +55,10 @@ > <attribute name="validator" type="string" use="required"> > <annotation> > <documentation> >- Specify the class that validates the Axis Server Location. Specified class should extend "org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.SoapServerDependency" class and should implement the interface "org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.ISoapServerDependency". >+ Specify the class that validates the Axis Server Location. Specified class should extend "org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.SoapServerDependency" class and should implement the interface "org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.ISoapServerDependency". > </documentation> > <appInfo> >- <meta.attribute kind="java" basedOn="org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.SoapServerDependency:org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.ISoapServerDependency"/> >+ <meta.attribute kind="java" basedOn="org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.SoapServerDependency:org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.ISoapServerDependency"/> > </appInfo> > </annotation> > </attribute> >@@ -105,7 +105,7 @@ > name="Axis2 Validator" > point="org.eclipse.tptp.wsdm.editor.axisValidator"> > <axisValidator >- validator="org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.Axis2ServerDependency"> >+ validator="org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.Axis2ServerDependency"> > <requiredFiles> > <relativeFilePath>lib/annogen-*.jar</relativeFilePath> > <relativeFilePath>lib/axiom-api-*.jar</relativeFilePath> >@@ -123,7 +123,7 @@ > <meta.section type="apiInfo"/> > </appInfo> > <documentation> >- Provided validator class must implement the "org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.ISoapServerDependency" interface. >+ Provided validator class must implement the "org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.ISoapServerDependency" interface. > </documentation> > </annotation> > >@@ -132,7 +132,7 @@ > <meta.section type="implementation"/> > </appInfo> > <documentation> >- Provided validator class can extend the "org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.SoapServerDependency" class to get the required files specified in extension point. >+ Provided validator class can extend the "org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.SoapServerDependency" class to get the required files specified in extension point. > </documentation> > </annotation> > >Index: src/org/eclipse/tptp/wsdm/tooling/editor/mrt/internal/GenerateDDTemplateAction.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/mrt/internal/GenerateDDTemplateAction.java,v >retrieving revision 1.2 >diff -u -r1.2 GenerateDDTemplateAction.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/mrt/internal/GenerateDDTemplateAction.java 23 Mar 2007 17:55:24 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/mrt/internal/GenerateDDTemplateAction.java 29 May 2007 23:40:25 -0000 >@@ -25,8 +25,8 @@ > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.BasicMrtInspector; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.MrtInspector; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.BasicMrtInspector; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.MrtInspector; > import org.eclipse.tptp.wsdm.tooling.editor.dde.util.internal.DdeUtil; > import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.INewNameGenerator; > import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.namegenerator.NewIFileNameGenerator; >Index: src/org/eclipse/tptp/wsdm/tooling/editor/mrt/internal/MrtPrototypeForm.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/mrt/internal/MrtPrototypeForm.java,v >retrieving revision 1.23 >diff -u -r1.23 MrtPrototypeForm.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/mrt/internal/MrtPrototypeForm.java 26 Apr 2007 19:02:43 -0000 1.23 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/mrt/internal/MrtPrototypeForm.java 29 May 2007 23:40:27 -0000 >@@ -53,8 +53,8 @@ > import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.Shell; > import org.eclipse.swt.widgets.Text; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.MRTCodeGenerationDelegate; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.NewProjectWizard; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.MRTCodeGenerationDelegate; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.NewProjectWizard; > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityEditor; > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityStorage; > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityStorageEditorInput; >Index: src/org/eclipse/tptp/wsdm/tooling/util/internal/WsdlUtils.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/util/internal/WsdlUtils.java,v >retrieving revision 1.6 >diff -u -r1.6 WsdlUtils.java >--- src/org/eclipse/tptp/wsdm/tooling/util/internal/WsdlUtils.java 4 May 2007 18:17:11 -0000 1.6 >+++ src/org/eclipse/tptp/wsdm/tooling/util/internal/WsdlUtils.java 29 May 2007 23:40:27 -0000 >@@ -39,7 +39,7 @@ > import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.emf.common.util.URI; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.EclipseEnvironment; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.EclipseEnvironment; > import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages; > import org.eclipse.xsd.XSDComplexTypeDefinition; >Index: src/org/eclipse/tptp/wsdm/tooling/util/internal/IFile2Capability.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/util/internal/IFile2Capability.java,v >retrieving revision 1.5 >diff -u -r1.5 IFile2Capability.java >--- src/org/eclipse/tptp/wsdm/tooling/util/internal/IFile2Capability.java 16 Mar 2007 18:00:24 -0000 1.5 >+++ src/org/eclipse/tptp/wsdm/tooling/util/internal/IFile2Capability.java 29 May 2007 23:40:27 -0000 >@@ -18,7 +18,7 @@ > > import org.eclipse.core.resources.IFile; > import org.eclipse.emf.common.util.URI; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.EclipseEnvironment; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.EclipseEnvironment; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; > import org.w3c.dom.Document; > import org.w3c.dom.Element; >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MrtMerge.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MrtMerge.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MrtMerge.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MrtMerge.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,253 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Andrew Eberbach (aeberbac@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.io.ByteArrayOutputStream; >+import java.lang.reflect.InvocationTargetException; >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.Iterator; >+import java.util.List; >+ >+import javax.wsdl.WSDLException; >+import javax.wsdl.factory.WSDLFactory; >+import javax.wsdl.xml.WSDLReader; >+import javax.wsdl.xml.WSDLWriter; >+import javax.xml.namespace.QName; >+ >+import org.apache.muse.tools.generator.WsdlMerge; >+import org.apache.muse.util.xml.XmlUtils; >+import org.apache.muse.ws.addressing.soap.SoapFault; >+import org.apache.muse.ws.notification.WsnConstants; >+import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >+import org.apache.muse.ws.resource.metadata.WsrmdConstants; >+import org.apache.muse.ws.resource.metadata.impl.SimpleMetadataDescriptor; >+import org.apache.muse.ws.wsdl.WsdlUtils; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils; >+import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; >+import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; >+ >+/** >+ * This class provides the utility method for merging the MRT to get the smashed WSDL and RMD documents. >+ * >+ */ >+ >+public class MrtMerge >+{ >+ private static WSDLReader _reader; >+ private static WSDLWriter _writer; >+ private static WSDLFactory _factory; >+ >+ /** >+ * Creates the smashed WSDL file for representing the resource type >+ * >+ * @param mrtFile - >+ * Manageable Resource Type file >+ * @throws Exception - >+ * Throws exception while getting WSDL files and also while >+ * merging them >+ */ >+ public static Document createMergedWSDL(ManageableResourceType mrt, String address) >+ throws Exception >+ { >+ checkReadersWriters(); >+ >+ List wsdlFiles = null; >+ >+ try >+ { >+ wsdlFiles = getWsdlFiles(mrt); >+ } >+ catch (Exception e) >+ { >+ throw new Exception(Messages.HOOKUP_WIZARD_ERROR_7, e); >+ } >+ >+ String namespaceURI = mrt.getNamespace(); >+ >+ Document[] wsdlFragments = (Document[])wsdlFiles.toArray(new Document[wsdlFiles.size()]); >+ javax.wsdl.Definition def = WsdlMerge.merge(namespaceURI, wsdlFragments, >+ address); >+ >+ return _writer.getDocument(def); >+ } >+ >+ private static void checkReadersWriters() throws InvocationTargetException >+ { >+ try >+ { >+ _factory = WSDLFactory.newInstance(); >+ _reader = _factory.newWSDLReader(); >+ _writer = _factory.newWSDLWriter(); >+ } >+ catch (WSDLException e) >+ { >+ throw new InvocationTargetException(new Exception( >+ Messages.HOOKUP_WIZARD_ERROR_3, e)); >+ } >+ } >+ >+ /** >+ * Given an MRT file return a list of <code>Definition</code> objects that >+ * correspond to the WSDL files related to this MRT (that is, its >+ * Capabilities). >+ * >+ * @param mrtFile >+ * @return >+ * @throws Exception >+ */ >+ private static List getWsdlFiles(ManageableResourceType mrt) >+ throws Exception >+ { >+ //Get a list of all of the capabilities in this MRT >+ //This should just be a list of URIs >+ List capabilityList = mrt.getImplements(); >+ >+ //Here is our list of clean WSDL documents >+ //we are returning >+ ArrayList wsdls = new ArrayList(); >+ >+ //Use an EclipseEnvironment to do the resolution of paths >+ EclipseEnvironment eclipseEnv = new EclipseEnvironment(); >+ >+ //Iterate over each capability and load it into a Definition >+ for (Iterator i = capabilityList.iterator(); i.hasNext();) { >+ String nextPath = i.next().toString(); >+ >+ Document document = WsdlUtils.createWSDL(eclipseEnv, nextPath, true); >+ >+ //clean up imports >+ //see the actual functions to understand how >+ //the removal is done >+ Element cleanDocument = WsdlUtils.removeSchemaReferences(document.getDocumentElement()); >+ cleanDocument = WsdlUtils.removeWsdlReferences(cleanDocument); >+ >+ wsdls.add(cleanDocument.getOwnerDocument()); >+ } >+ >+ return wsdls; >+ } >+ >+ /** >+ * Creates the merged RMD file for representing the manageable resource type >+ * >+ * @param mrtFile - >+ * Manageable Resource Type file >+ * @throws Exception - >+ * Throws exception while getting capabilities defined in MRT and also while >+ * merging their RMDs >+ */ >+ public static MetadataDescriptor createMergedRMD(ManageableResourceType mrt) throws Exception >+ { >+ List rmds = new ArrayList(); >+ Capability[] capabilities = MrtUtils.getCapabilities(mrt); >+ List allTopicExpressions = new ArrayList(); >+ for(int i=0;i<capabilities.length;i++) >+ { >+ CapabilityDefinition capabilityDef = (CapabilityDefinition)capabilities[i].getWsdlDefinition(); >+ URI capabilityFileLocationURI = capabilityDef.getWSDLResourceProtocolURI(); >+ String metadataDescriptorLocation = capabilityDef.getMetadataDescriptorLocation(); >+ if(metadataDescriptorLocation == null || metadataDescriptorLocation.length() == 0) >+ continue; >+ URI rmdFileLocationURI = URI.createURI(capabilityFileLocationURI.trimSegments(1).toString()+ "/" + metadataDescriptorLocation); >+ org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.DocumentRoot root = MetaDataUtils.getDocumentRoot(rmdFileLocationURI); >+ ByteArrayOutputStream baos = MetaDataUtils.saveRMD(root, rmdFileLocationURI.toString(), null); >+ String rmdXML = new String(baos.toByteArray()); >+ Element definitionElement = (Element) XmlUtils.createDocument(rmdXML).getFirstChild(); >+ Element metadataDescriptorElement = XmlUtils.getFirstElement(definitionElement); >+ MetadataDescriptor rmdDescriptor = new SimpleMetadataDescriptor(metadataDescriptorElement); >+ >+ // Get all the topic expressions defined in different capabilities >+ String[] topicExpressions = getTopicExpressions(rmdDescriptor); >+ for(int j=0;j<topicExpressions.length;j++) >+ { >+ String prefix = topicExpressions[j].substring(0,topicExpressions[j].indexOf(':')); >+ String namespace = (String)root.getXMLNSPrefixMap().get(prefix); >+ String topicPath = topicExpressions[j].substring(topicExpressions[j].indexOf(':')+1); >+ allTopicExpressions.add(new TopicExpression(namespace, topicPath)); >+ } >+ rmdDescriptor.removeProperty(WsnConstants.TOPIC_EXPRESSION_QNAME); >+ >+ rmds.add(rmdDescriptor); >+ } >+ MetadataDescriptor[] descriptors = (MetadataDescriptor[]) rmds.toArray(new MetadataDescriptor[rmds.size()]); >+ QName qname = new QName(mrt.getNamespace(), "PortType"); >+ // TODO Verify with Andrew that is it the way that MUSE creates the smashed wsdl by this name >+ String name = mrt.getIdentifier()+".wsdl"; >+ MetadataDescriptor mergedRMD = WsdlMerge.merge(name, qname, descriptors); >+ TopicExpression[] topicExpressions = (TopicExpression[]) allTopicExpressions.toArray(new TopicExpression[allTopicExpressions.size()]); >+ // Merge all the topic expressions defined in different capabilities >+ mergeTopicExpressions(mergedRMD, topicExpressions); >+ return mergedRMD; >+ } >+ >+ private static String[] getTopicExpressions(MetadataDescriptor rmdDescriptor) throws SoapFault >+ { >+ if(rmdDescriptor.hasProperty(WsnConstants.TOPIC_EXPRESSION_QNAME)) >+ { >+ Collection collection = rmdDescriptor.getInitialValues(WsnConstants.TOPIC_EXPRESSION_QNAME, String.class); >+ return (String[])collection.toArray(new String[collection.size()]); >+ } >+ return new String[0]; >+ } >+ >+ private static void mergeTopicExpressions(MetadataDescriptor rmdDescriptor, TopicExpression[] topicExpressions) throws SoapFault >+ { >+ if(topicExpressions!=null && topicExpressions.length>0) >+ { >+ rmdDescriptor.addProperty(WsnConstants.TOPIC_EXPRESSION_QNAME, WsrmdConstants.READ_ONLY, WsrmdConstants.MUTABLE); >+ List initValues = new ArrayList(); >+ Document doc = XmlUtils.createDocument(); >+ for(int i=0;i<topicExpressions.length;i++) >+ { >+ String namespace = topicExpressions[i].getTopicNamespace(); >+ String topicPath = topicExpressions[i].getTopicPath(); >+ String expression = "pfx:"+topicPath; >+ Element propertyElement = XmlUtils.createElement(doc, WsnConstants.TOPIC_EXPRESSION_QNAME); >+ propertyElement.setAttribute("xmlns:pfx", namespace); >+ XmlUtils.setElementText(propertyElement, expression); >+ initValues.add(propertyElement); >+ } >+ rmdDescriptor.setInitialValues(WsnConstants.TOPIC_EXPRESSION_QNAME, initValues); >+ } >+ } >+} >+ >+class TopicExpression >+{ >+ private String _topicNamespace; >+ private String _topicPath; >+ >+ TopicExpression(String topicNamespace, String topicPath) >+ { >+ _topicNamespace = topicNamespace; >+ _topicPath = topicPath; >+ } >+ >+ String getTopicNamespace() >+ { >+ return _topicNamespace; >+ } >+ >+ String getTopicPath() >+ { >+ return _topicPath; >+ } >+} >+ >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/Axis2LicenseDialog.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/Axis2LicenseDialog.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/Axis2LicenseDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/Axis2LicenseDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,140 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.io.BufferedReader; >+import java.io.InputStreamReader; >+import java.net.URL; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.browser.Browser; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >+import org.osgi.framework.Bundle; >+ >+/** >+ * This class is used to display the Axis-2 License. >+ */ >+public class Axis2LicenseDialog >+{ >+ private Shell _shell; >+ >+ private Browser _text; >+ >+ private Button _btnAgree; >+ >+ private Button _btnDecline; >+ >+ public static int AGREE = 0; >+ >+ public static int DECLINE = 1; >+ >+ private int _retInt = DECLINE; >+ >+ /** >+ * Constructor of the class. It initialises the UI for >+ * displaying the license >+ */ >+ public Axis2LicenseDialog() >+ { >+ initUI(); >+ } >+ >+ private void initUI() >+ { >+ _shell = new Shell(Display.getCurrent(), SWT.CLOSE | SWT.SYSTEM_MODAL | SWT.APPLICATION_MODAL | SWT.RESIZE); >+ _shell.setLayout(new GridLayout(2, true)); >+ _shell.setText(Messages.AXIS2_LICENSE_LABEL); >+ _shell.setSize(300, 300); >+ >+ _text = new Browser(_shell, SWT.BORDER | SWT.MULTI | SWT.WRAP); >+ try >+ { >+ _text.setText(readLicence()); >+ } >+ catch (Throwable e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ >+ _btnAgree = new Button(_shell, SWT.PUSH); >+ _btnAgree.setText(Messages.LICENSE_AGREE_TEXT); >+ _btnAgree.addSelectionListener(new SelectionAdapter() >+ { >+ public void widgetSelected(SelectionEvent se) >+ { >+ _retInt = AGREE; >+ _shell.dispose(); >+ } >+ } >+ ); >+ >+ _btnDecline = new Button(_shell, SWT.PUSH); >+ _btnDecline.setText(Messages.LICENSE_DECLINE_TEXT); >+ _btnDecline.addSelectionListener(new SelectionAdapter() >+ { >+ public void widgetSelected(SelectionEvent se) >+ { >+ _retInt = DECLINE; >+ _shell.dispose(); >+ } >+ } >+ ); >+ >+ GridData gd = new GridData(GridData.FILL_BOTH); >+ gd.horizontalSpan = 2; >+ _text.setLayoutData(gd); >+ >+ gd = new GridData(); >+ gd.horizontalAlignment = SWT.RIGHT; >+ _btnAgree.setLayoutData(gd); >+ >+ gd = new GridData(); >+ gd.horizontalAlignment = SWT.LEFT; >+ _btnDecline.setLayoutData(gd); >+ } >+ >+ /** >+ * Method to show the Dialog that displays the Liscense >+ */ >+ public int showWindow() >+ { >+ _shell.open(); >+ while(!_shell.isDisposed()) >+ { >+ if(!Display.getCurrent().readAndDispatch()) >+ Display.getCurrent().sleep(); >+ } >+ return _retInt; >+ } >+ >+ private String readLicence() throws Throwable >+ { >+ Bundle bundle = Activator.INSTANCE.getPlugin().getBundle(); >+ URL licenceURL = bundle.getEntry("licence/Licence.txt"); >+ BufferedReader in = new BufferedReader(new InputStreamReader(licenceURL.openStream())); >+ StringBuffer buffer = new StringBuffer(); >+ String line = null; >+ while ((line = in.readLine()) != null) >+ buffer.append(line); >+ return buffer.toString(); >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/SubscriptionManagerInspector.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/SubscriptionManagerInspector.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/SubscriptionManagerInspector.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/SubscriptionManagerInspector.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,334 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.io.ByteArrayInputStream; >+import java.io.IOException; >+import java.io.InputStream; >+ >+import javax.wsdl.Operation; >+ >+import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >+import org.apache.ws.muse.descriptor.CapabilityType; >+import org.apache.ws.muse.descriptor.DescriptorFactory; >+import org.apache.ws.muse.descriptor.DocumentRoot; >+import org.apache.ws.muse.descriptor.InitParamType; >+import org.apache.ws.muse.descriptor.InitialInstancesType; >+import org.apache.ws.muse.descriptor.ReferenceParametersType; >+import org.apache.ws.muse.descriptor.ResourceTypeType; >+import org.apache.ws.muse.descriptor.WsdlType; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.resource.ResourceSet; >+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceTypeFactory; >+import org.eclipse.tptp.wsdm.tooling.util.internal.CustomMrtResourceFactoryImpl; >+import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >+ >+/** >+ * This class analyzes the given manageable resource type and provide an extra >+ * resource type for muse descriptor (SubscriptionManager), if manageable >+ * resource type contains the NotificationProducer capability. >+ */ >+public class SubscriptionManagerInspector implements MrtInspector >+{ >+ >+ private String _mrtParentDirName; >+ >+ private DocumentRoot _root; >+ >+ private ResourceTypeType _subManagerResourceType; >+ >+ private ManageableResourceType _subManagerMRT; >+ /** >+ * Constructor of the class >+ * @param root >+ */ >+ public SubscriptionManagerInspector(DocumentRoot root) >+ { >+ _root = root; >+ } >+ >+ /** >+ * Analyzes the given manageable resource type for NotificationProducer >+ * capability, and if the capability available then returns the muse >+ * resource type for SubscriptionManager else returns the null. >+ */ >+ public ResourceTypeType inspect(Capability[] mrtCapabilities) >+ { >+ for (int i = 0; i < mrtCapabilities.length; i++) >+ { >+ if (isNotificationProducerCapability(mrtCapabilities[i])) >+ return createSubscriptionManagerResourceType(); >+ } >+ return null; >+ } >+ >+ private ResourceTypeType createSubscriptionManagerResourceType() >+ { >+ createSubManagerMrt(); >+ _subManagerResourceType = createSubManagerMuseResourceType(); >+ return _subManagerResourceType; >+ } >+ >+ private void createSubManagerMrt() >+ { >+ org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.DocumentRoot documentRoot = ManageableResourceTypeFactory.eINSTANCE.createDocumentRoot(); >+ _subManagerMRT = ManageableResourceTypeFactory.eINSTANCE >+ .createManageableResourceType(); >+ documentRoot.setManageableResource(_subManagerMRT); >+ _subManagerMRT.setIdentifier("SubscriptionManager"); >+ _subManagerMRT >+ .setNamespace("http://docs.oasis-open.org/wsn/b-2/SubscriptionManager"); >+ _subManagerMRT >+ .getImplements() >+ .add(WsdmConstants.IDENTITY_CAPABILITY_LOCATION); >+ _subManagerMRT >+ .getImplements() >+ .add(WsdmConstants.MANAGEABLITY_CAPABILITY_LOCATION); >+ _subManagerMRT >+ .getImplements() >+ .add(WsdmConstants.MEX_CAPABILITY_LOCATION); >+ _subManagerMRT >+ .getImplements() >+ .add(WsdmConstants.GET_CAPABILITY_LOCATION); >+ _subManagerMRT >+ .getImplements() >+ .add(WsdmConstants.SET_CAPABILITY_LOCATION); >+ _subManagerMRT >+ .getImplements() >+ .add(WsdmConstants.QUERY_CAPABILITY_LOCATION); >+ _subManagerMRT >+ .getImplements() >+ .add(WsdmConstants.IMMIDIATE_RESOURCE_TERMINATION_CAPABILITY_LOCATION); >+ _subManagerMRT >+ .getImplements() >+ .add(WsdmConstants.SCHEDULED_RESOURCE_TERMINATION_CAPABILITY_LOCATION); >+ _subManagerMRT >+ .getImplements() >+ .add(WsdmConstants.SUBSCRIPTION_MANAGER_CAPABILITY_LOCATION); >+ } >+ >+ private ResourceTypeType createSubManagerMuseResourceType() >+ { >+ ResourceTypeType resourceType = DescriptorFactory.eINSTANCE >+ .createResourceTypeType(); >+ resourceType.setContextPath("/SubscriptionManager"); >+ resourceType >+ .setJavaIdFactoryClass(WsdmConstants.MUSE_RESOURCE_ID_FACTORY_CLASS); >+ resourceType >+ .setJavaResourceClass(WsdmConstants.MUSE_RESOURCE_CLASS); >+ >+ WsdlType wsdlType = DescriptorFactory.eINSTANCE.createWsdlType(); >+ wsdlType.setWsdlFile(_mrtParentDirName + "/" >+ + "SubscriptionManager.wsdl"); >+ _root.getXMLNSPrefixMap().put("wsn", >+ "http://docs.oasis-open.org/wsn/b-2/SubscriptionManager"); >+ wsdlType.setWsdlPortType("wsn:PortType"); >+ resourceType.setWsdl(wsdlType); >+ >+ CapabilityType identity = DescriptorFactory.eINSTANCE >+ .createCapabilityType(); >+ identity >+ .setCapabilityUri("http://docs.oasis-open.org/wsdm/muws/capabilities/Identity"); >+ identity.setJavaCapabilityClass(""); >+ >+ CapabilityType manageabilityCharacteristics = DescriptorFactory.eINSTANCE >+ .createCapabilityType(); >+ manageabilityCharacteristics >+ .setCapabilityUri("http://docs.oasis-open.org/wsdm/muws/capabilities/ManageabilityCharacteristics"); >+ manageabilityCharacteristics.setJavaCapabilityClass(""); >+ >+ CapabilityType metadataExchange = DescriptorFactory.eINSTANCE >+ .createCapabilityType(); >+ metadataExchange >+ .setCapabilityUri("http://schemas.xmlsoap.org/ws/2004/09/mex"); >+ metadataExchange.setJavaCapabilityClass(""); >+ >+ CapabilityType getCapability = DescriptorFactory.eINSTANCE >+ .createCapabilityType(); >+ getCapability >+ .setCapabilityUri("http://docs.oasis-open.org/wsrf/rpw-2/Get"); >+ getCapability.setJavaCapabilityClass(""); >+ >+ CapabilityType setCapability = DescriptorFactory.eINSTANCE >+ .createCapabilityType(); >+ setCapability >+ .setCapabilityUri("http://docs.oasis-open.org/wsrf/rpw-2/Set"); >+ setCapability.setJavaCapabilityClass(""); >+ >+ CapabilityType queryCapability = DescriptorFactory.eINSTANCE >+ .createCapabilityType(); >+ queryCapability >+ .setCapabilityUri("http://docs.oasis-open.org/wsrf/rpw-2/Query"); >+ queryCapability.setJavaCapabilityClass(""); >+ >+ CapabilityType immediateDestruction = DescriptorFactory.eINSTANCE >+ .createCapabilityType(); >+ immediateDestruction >+ .setCapabilityUri("http://docs.oasis-open.org/wsrf/rlw-2/ImmediateResourceTermination"); >+ immediateDestruction >+ .setJavaCapabilityClass("org.apache.muse.ws.resource.lifetime.impl.SimpleImmediateTermination"); >+ >+ CapabilityType scheduledDestruction = DescriptorFactory.eINSTANCE >+ .createCapabilityType(); >+ scheduledDestruction >+ .setCapabilityUri("http://docs.oasis-open.org/wsrf/rlw-2/ScheduledResourceTermination"); >+ scheduledDestruction >+ .setJavaCapabilityClass("org.apache.muse.ws.resource.lifetime.impl.SimpleScheduledTermination"); >+ >+ CapabilityType subscriptionManager = DescriptorFactory.eINSTANCE >+ .createCapabilityType(); >+ subscriptionManager >+ .setCapabilityUri("http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager"); >+ subscriptionManager >+ .setJavaCapabilityClass("org.apache.muse.ws.notification.impl.SimpleSubscriptionManager"); >+ >+ InitParamType noValidateParam = DescriptorFactory.eINSTANCE >+ .createInitParamType(); >+ noValidateParam.setParamName("validate-wsrp-schema"); >+ noValidateParam.setParamValue("false"); >+ >+ resourceType.getCapability().add(identity); >+ resourceType.getCapability().add(manageabilityCharacteristics); >+ resourceType.getCapability().add(metadataExchange); >+ resourceType.getCapability().add(getCapability); >+ resourceType.getCapability().add(setCapability); >+ resourceType.getCapability().add(queryCapability); >+ resourceType.getCapability().add(immediateDestruction); >+ resourceType.getCapability().add(scheduledDestruction); >+ resourceType.getCapability().add(subscriptionManager); >+ >+ resourceType.getInitParam().add(noValidateParam); >+ >+ return resourceType; >+ } >+ >+ private boolean isNotificationProducerCapability(Capability capability) >+ { >+ boolean isNpNS = capability.getNamespace().equals( >+ "http://docs.oasis-open.org/wsn/bw-2"); >+ boolean isNpName = capability.getName().equals("NotificationProducer"); >+ Operation[] operations = capability.getWsdlDefinition().getOperations(); >+ if (operations == null || operations.length < 2) >+ return false; >+ boolean isSubscribeOp = WsdlUtils.getOperationName(operations[0]) >+ .equals("Subscribe"); >+ boolean isGetCurrentMessageOp = WsdlUtils.getOperationName( >+ operations[1]).equals("GetCurrentMessage"); >+ return isNpNS && isNpName && isSubscribeOp && isGetCurrentMessageOp; >+ } >+ >+ /** >+ * Sets the parent directory >+ * @param mrtParentDir >+ */ >+ public void setMrtParentDirectory(String mrtParentDir) >+ { >+ _mrtParentDirName = mrtParentDir; >+ } >+ /** >+ * Returns the initial instances >+ * @return InitialInstancesType[] >+ */ >+ public InitialInstancesType[] getInitialInstances() >+ { >+ InitialInstancesType instance = DescriptorFactory.eINSTANCE >+ .createInitialInstancesType(); >+ ResourceTypeType rtClone = MRTCodeGenerationDelegate >+ .cloneResourceType(_subManagerResourceType); >+ instance.setResourceType(rtClone); >+ ReferenceParametersType refParam = DescriptorFactory.eINSTANCE >+ .createReferenceParametersType(); >+ instance.setReferenceParameters(refParam); >+ return new InitialInstancesType[] { instance }; >+ } >+ >+ /** >+ * This method will persist the extra artifacts generated at codegen time (SubscriptionManager.mrt file). >+ */ >+ public void persistArtifacts() >+ { >+ ResourceSet rs = new ResourceSetImpl(); >+ rs.getResourceFactoryRegistry().getExtensionToFactoryMap() >+ .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new CustomMrtResourceFactoryImpl()); >+ byte[] rawNewMRT = MrtUtils.serializeMRT(_subManagerMRT, rs, URI >+ .createURI("dummy.xml"), true); >+ InputStream stream = new ByteArrayInputStream(rawNewMRT); >+ >+ try >+ { >+ String subManagerMrt = _mrtParentDirName + "/" >+ + "SubscriptionManager.mrt"; >+ IFile subManagerMrtFile = EclipseUtils.getIFile(subManagerMrt); >+ if (subManagerMrtFile.exists()) >+ { >+ subManagerMrtFile.setContents(stream, true, true, >+ new NullProgressMonitor()); >+ } >+ else >+ { >+ subManagerMrtFile.create(stream, true, >+ new NullProgressMonitor()); >+ } >+ try >+ { >+ stream.close(); >+ } >+ catch (IOException e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ } >+ catch (CoreException e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ } >+ >+ /** >+ * This method will returns the extra generated ManageableResourceType object equivalent to SubscriptionManager. >+ */ >+ public ManageableResourceType getExtraGeneratedMrt() >+ { >+ return _subManagerMRT; >+ } >+ >+ /** >+ * This method should return the persistance location for extra generated ManageableResourceType object equivalent to SubscriptionManager. >+ */ >+ public String getExtraGeneratedMrtPersistanceLocation() >+ { >+ return _mrtParentDirName+"/SubscriptionManager.mrt"; >+ } >+ >+ /** >+ * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given >+ * merged RMD document for it by having the rules/relationships in it. >+ */ >+ public void inspectMetadata(ManageableResourceType mrt, >+ MetadataDescriptor rmd) >+ { >+ } >+ >+ >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/RelationshipInspector.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/RelationshipInspector.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/RelationshipInspector.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/RelationshipInspector.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,405 @@ >+/******************************************************************************* >+ * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.io.ByteArrayInputStream; >+import java.io.IOException; >+import java.io.InputStream; >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import javax.wsdl.Operation; >+import javax.xml.namespace.QName; >+ >+import org.apache.muse.util.xml.XmlUtils; >+import org.apache.muse.ws.addressing.WsaConstants; >+import org.apache.muse.ws.addressing.soap.SoapFault; >+import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >+import org.apache.ws.muse.descriptor.CapabilityType; >+import org.apache.ws.muse.descriptor.DescriptorFactory; >+import org.apache.ws.muse.descriptor.DocumentRoot; >+import org.apache.ws.muse.descriptor.InitParamType; >+import org.apache.ws.muse.descriptor.InitialInstancesType; >+import org.apache.ws.muse.descriptor.ReferenceParametersType; >+import org.apache.ws.muse.descriptor.ResourceTypeType; >+import org.apache.ws.muse.descriptor.WsdlType; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.resource.ResourceSet; >+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >+import org.eclipse.emf.ecore.util.FeatureMap; >+import org.eclipse.emf.ecore.util.BasicExtendedMetaData.EStructuralFeatureExtendedMetaData; >+import org.eclipse.emf.ecore.xml.type.AnyType; >+import org.eclipse.tptp.wsdm.tooling.editor.mrt.relationship.internal.RelationshipUtils; >+import org.eclipse.tptp.wsdm.tooling.model.addressing.AttributedURIType; >+import org.eclipse.tptp.wsdm.tooling.model.addressing.EndpointReferenceType; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceTypeFactory; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.Relationship; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.RelationshipParticipantType; >+import org.eclipse.tptp.wsdm.tooling.util.internal.CustomMrtResourceFactoryImpl; >+import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; >+import org.w3c.dom.Text; >+ >+public class RelationshipInspector implements MrtInspector >+{ >+ >+ private String _mrtParentDirName; >+ >+ private DocumentRoot _root; >+ >+ private ResourceTypeType _relationshipResourceType; >+ >+ private ManageableResourceType _relationshipResourceMRT; >+ >+ /** >+ * Constructor of the class >+ * @param root >+ */ >+ public RelationshipInspector(DocumentRoot root) >+ { >+ _root = root; >+ } >+ >+ public ManageableResourceType getExtraGeneratedMrt() >+ { >+ return _relationshipResourceMRT; >+ } >+ >+ public String getExtraGeneratedMrtPersistanceLocation() >+ { >+ return _mrtParentDirName+"/RelationshipResource.mrt"; >+ } >+ >+ public InitialInstancesType[] getInitialInstances() >+ { >+ InitialInstancesType instance = DescriptorFactory.eINSTANCE >+ .createInitialInstancesType(); >+ ResourceTypeType rtClone = MRTCodeGenerationDelegate >+ .cloneResourceType(_relationshipResourceType); >+ instance.setResourceType(rtClone); >+ ReferenceParametersType refParam = DescriptorFactory.eINSTANCE >+ .createReferenceParametersType(); >+ instance.setReferenceParameters(refParam); >+ return new InitialInstancesType[] { instance }; >+ } >+ >+ public ResourceTypeType inspect(Capability[] mrtCapabilities) >+ { >+ for (int i = 0; i < mrtCapabilities.length; i++) >+ { >+ if (hasRelationshipCapability(mrtCapabilities[i])) >+ return createRelationshipResourceType(); >+ } >+ return null; >+ } >+ >+ private ResourceTypeType createRelationshipResourceType() >+ { >+ createRelationshipResourceMrt(); >+ _relationshipResourceType = createRelationshipResourceMuseType(); >+ return _relationshipResourceType; >+ } >+ >+ private void createRelationshipResourceMrt() >+ { >+ org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.DocumentRoot documentRoot = ManageableResourceTypeFactory.eINSTANCE.createDocumentRoot(); >+ _relationshipResourceMRT = ManageableResourceTypeFactory.eINSTANCE >+ .createManageableResourceType(); >+ documentRoot.setManageableResource(_relationshipResourceMRT); >+ _relationshipResourceMRT.setIdentifier("RelationshipResource"); >+ _relationshipResourceMRT >+ .setNamespace("http://docs.oasis-open.org/wsdm/muws2-2.xsd/RelationshipResource"); >+ _relationshipResourceMRT >+ .getImplements() >+ .add(WsdmConstants.MEX_CAPABILITY_LOCATION); >+ _relationshipResourceMRT >+ .getImplements() >+ .add(WsdmConstants.GET_CAPABILITY_LOCATION); >+ _relationshipResourceMRT >+ .getImplements() >+ .add(WsdmConstants.SET_CAPABILITY_LOCATION); >+ _relationshipResourceMRT >+ .getImplements() >+ .add(WsdmConstants.QUERY_CAPABILITY_LOCATION); >+ _relationshipResourceMRT >+ .getImplements() >+ .add(WsdmConstants.RELATIONSHIP_RESOURCE_CAPABILITY_LOCATION); >+ } >+ >+ private ResourceTypeType createRelationshipResourceMuseType() >+ { >+ ResourceTypeType resourceType = DescriptorFactory.eINSTANCE >+ .createResourceTypeType(); >+ resourceType.setContextPath("/RelationshipResource"); >+ resourceType >+ .setJavaIdFactoryClass(WsdmConstants.MUSE_RESOURCE_ID_FACTORY_CLASS); >+ resourceType >+ .setJavaResourceClass(WsdmConstants.MUSE_RESOURCE_CLASS); >+ >+ WsdlType wsdlType = DescriptorFactory.eINSTANCE.createWsdlType(); >+ wsdlType.setWsdlFile(_mrtParentDirName + "/" >+ + "RelationshipResource.wsdl"); >+ _root.getXMLNSPrefixMap().put("rel", >+ "http://docs.oasis-open.org/wsdm/muws2-2.xsd/RelationshipResource"); >+ wsdlType.setWsdlPortType("rel:PortType"); >+ resourceType.setWsdl(wsdlType); >+ >+ CapabilityType metadataExchange = DescriptorFactory.eINSTANCE >+ .createCapabilityType(); >+ metadataExchange >+ .setCapabilityUri("http://schemas.xmlsoap.org/ws/2004/09/mex"); >+ metadataExchange.setJavaCapabilityClass(""); >+ >+ CapabilityType getCapability = DescriptorFactory.eINSTANCE >+ .createCapabilityType(); >+ getCapability >+ .setCapabilityUri("http://docs.oasis-open.org/wsrf/rpw-2/Get"); >+ getCapability.setJavaCapabilityClass(""); >+ >+ CapabilityType setCapability = DescriptorFactory.eINSTANCE >+ .createCapabilityType(); >+ setCapability >+ .setCapabilityUri("http://docs.oasis-open.org/wsrf/rpw-2/Set"); >+ setCapability.setJavaCapabilityClass(""); >+ >+ CapabilityType queryCapability = DescriptorFactory.eINSTANCE >+ .createCapabilityType(); >+ queryCapability >+ .setCapabilityUri("http://docs.oasis-open.org/wsrf/rpw-2/Query"); >+ queryCapability.setJavaCapabilityClass(""); >+ >+ CapabilityType relationshipResource = DescriptorFactory.eINSTANCE >+ .createCapabilityType(); >+ relationshipResource >+ .setCapabilityUri("http://docs.oasis-open.org/wsdm/muws/capabilities/RelationshipResource"); >+ relationshipResource >+ .setJavaCapabilityClass(""); >+ >+ InitParamType noValidateParam = DescriptorFactory.eINSTANCE >+ .createInitParamType(); >+ noValidateParam.setParamName("validate-wsrp-schema"); >+ noValidateParam.setParamValue("false"); >+ >+ resourceType.getCapability().add(metadataExchange); >+ resourceType.getCapability().add(getCapability); >+ resourceType.getCapability().add(setCapability); >+ resourceType.getCapability().add(queryCapability); >+ resourceType.getCapability().add(relationshipResource); >+ >+ resourceType.getInitParam().add(noValidateParam); >+ >+ return resourceType; >+ } >+ >+ private boolean hasRelationshipCapability(Capability capability) >+ { >+ boolean hasRelationshipNS = "http://docs.oasis-open.org/wsdm/muws2-2.xsd".equals(capability.getNamespace()); >+ String capabilityURI = capability.getWsdlDefinition().getNamespace("capabilityURI"); >+ boolean hasRelationshipURI = "http://docs.oasis-open.org/wsdm/muws/capabilities/Relationships".equals(capabilityURI); >+ boolean hasRelationshipName = capability.getName().equals("Relationships"); >+ Operation[] operations = capability.getWsdlDefinition().getOperations(); >+ if (operations == null || operations.length < 1) >+ return false; >+ boolean hasQueryRelationshipsOp = WsdlUtils.getOperationName(operations[0]) >+ .equals("QueryRelationshipsByType"); >+ return hasRelationshipNS && hasRelationshipURI && hasRelationshipName && hasQueryRelationshipsOp; >+ } >+ >+ public void persistArtifacts() >+ { >+ ResourceSet rs = new ResourceSetImpl(); >+ rs.getResourceFactoryRegistry().getExtensionToFactoryMap() >+ .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new CustomMrtResourceFactoryImpl()); >+ byte[] rawNewMRT = MrtUtils.serializeMRT(_relationshipResourceMRT, rs, URI >+ .createURI("dummy.xml"), true); >+ InputStream stream = new ByteArrayInputStream(rawNewMRT); >+ >+ try >+ { >+ String relationshipResourceMrt = _mrtParentDirName + "/" >+ + "RelationshipResource.mrt"; >+ IFile relationshipResourceMrtFile = EclipseUtils.getIFile(relationshipResourceMrt); >+ if (relationshipResourceMrtFile.exists()) >+ { >+ relationshipResourceMrtFile.setContents(stream, true, true, >+ new NullProgressMonitor()); >+ } >+ else >+ { >+ relationshipResourceMrtFile.create(stream, true, >+ new NullProgressMonitor()); >+ } >+ try >+ { >+ stream.close(); >+ } >+ catch (IOException e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ } >+ catch (CoreException e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ } >+ >+ public void setMrtParentDirectory(String mrtParentDir) >+ { >+ _mrtParentDirName = mrtParentDir; >+ } >+ >+ /** >+ * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given >+ * merged RMD document for it by having the rules/relationships in it. >+ */ >+ public void inspectMetadata(ManageableResourceType mrt, MetadataDescriptor rmd) >+ { >+ boolean hasRelationshipCapability = false; >+ Capability[] mrtCapabilities = new Capability[0]; >+ try >+ { >+ mrtCapabilities = MrtUtils.getCapabilities(mrt); >+ } >+ catch (Exception e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ for (int i = 0; i < mrtCapabilities.length; i++) >+ { >+ if (hasRelationshipCapability(mrtCapabilities[i])) >+ { >+ hasRelationshipCapability = true; >+ break; >+ } >+ } >+ if(hasRelationshipCapability) >+ { >+ List relationships = mrt.getRelationshipDefinitions(); >+ List initialValues = new ArrayList(); >+ for(int i=0;i<relationships.size();i++) >+ { >+ Relationship relationship = (Relationship) relationships.get(i); >+ Element value = createRelationshipElement(relationship); >+ initialValues.add(value); >+ } >+ if(!initialValues.isEmpty()); >+ try >+ { >+ rmd.setInitialValues(new QName(WsdmConstants.MUWS_P2_NS,"Relationship"), initialValues); >+ } >+ catch (SoapFault e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ } >+ } >+ >+ private Element createRelationshipElement(Relationship relationship) >+ { >+ Document document = XmlUtils.createDocument(); >+ Element relationshipElement = XmlUtils.createElement(document, new QName(WsdmConstants.MUWS_P2_NS,"Relationship")); >+ >+ Element nameElement = XmlUtils.createElement(document, new QName(WsdmConstants.MUWS_P2_NS,"Name")); >+ Text name = document.createTextNode(relationship.getName()); >+ nameElement.appendChild(name); >+ relationshipElement.appendChild(nameElement); >+ >+ Element typeElement = XmlUtils.createElement(document, new QName(WsdmConstants.MUWS_P2_NS,"Type")); >+ QName typeQName = RelationshipUtils.getRelationshipType(relationship); >+ Element element = XmlUtils.createElement(document, typeQName); >+ typeElement.appendChild(element); >+ relationshipElement.appendChild(typeElement); >+ >+ List participants = relationship.getParticipant(); >+ for(int i=0;i<participants.size();i++) >+ { >+ RelationshipParticipantType participant = (RelationshipParticipantType) participants.get(i); >+ Element participantElement = createParticipantElement(participant, document); >+ relationshipElement.appendChild(participantElement); >+ } >+ return relationshipElement; >+ } >+ >+ private Element createParticipantElement(RelationshipParticipantType participant, Document document) >+ { >+ Element participantElement = XmlUtils.createElement(document,new QName(WsdmConstants.MUWS_P2_NS,"Participant")); >+ >+ // Create epr element >+ Element manageabilityEprElement = XmlUtils.createElement(document, new QName(WsdmConstants.MUWS_P1_NS,"ManageabilityEndpointReference")); >+ EndpointReferenceType epr = (EndpointReferenceType) participant.getManageabilityEndpointReference().get(0); >+ AttributedURIType uri = epr.getAddress(); >+ Element addressElement = XmlUtils.createElement(document, new QName("http://www.w3.org/2005/08/addressing", "Address")); >+ Text address = document.createTextNode(uri.getValue()); >+ addressElement.appendChild(address); >+ manageabilityEprElement.appendChild(addressElement); >+ participantElement.appendChild(manageabilityEprElement); >+ >+ // Create reference parameter element >+ Element referenceParameterElement = XmlUtils.createElement(document, WsaConstants.PARAMETERS_QNAME); >+ manageabilityEprElement.appendChild(referenceParameterElement); >+ org.eclipse.tptp.wsdm.tooling.model.addressing.ReferenceParametersType refParams = epr.getReferenceParameters(); >+ FeatureMap fm = refParams.getAny(); >+ Iterator it = fm.iterator(); >+ while (it.hasNext()) >+ { >+ Object obj = it.next(); >+ if(obj instanceof EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry) >+ { >+ EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry containmentEntry = (EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry)obj; >+ EStructuralFeatureExtendedMetaData metadata = ((EStructuralFeatureImpl)containmentEntry.getEStructuralFeature()).getExtendedMetaData(); >+ String namespace = metadata.getNamespace(); >+ String name = metadata.getName(); >+ String value = ""; >+ Object containmentEntryValue = containmentEntry.getValue(); >+ if(containmentEntryValue instanceof AnyType) >+ { >+ AnyType anyType = (AnyType) containmentEntryValue; >+ value = (String) anyType.getMixed().valueListIterator().next(); >+ } >+ Element paramElement = XmlUtils.createElement(document, new QName(namespace, name)); >+ XmlUtils.setElementText(paramElement, value); >+ referenceParameterElement.appendChild(paramElement); >+ } >+ } >+ >+ // Create resource id element >+ Element resourceIdElement = XmlUtils.createElement(document, new QName(WsdmConstants.MUWS_P1_NS,"ResourceId")); >+ Text resourceId = document.createTextNode(participant.getResourceId()); >+ resourceIdElement.appendChild(resourceId); >+ participantElement.appendChild(resourceIdElement); >+ >+ // Create role element >+ Element roleElement = XmlUtils.createElement(document, new QName(WsdmConstants.MUWS_P2_NS,"Role")); >+ Text role = document.createTextNode(participant.getRole()); >+ roleElement.appendChild(role); >+ participantElement.appendChild(roleElement); >+ >+ return participantElement; >+ } >+ >+ >+ >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/SoapServerDependency.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/SoapServerDependency.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/SoapServerDependency.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/SoapServerDependency.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+ >+/** >+ * This class collects the relative paths of required Axis-2 files specified in extension point. >+ * So if you are extending "axisValidator" extension point, you have to extend this class and implement >+ * the interface ISoapServerDependency. >+ */ >+ >+public abstract class SoapServerDependency implements ISoapServerDependency >+{ >+ >+ protected List _requiredFiles = new ArrayList(); >+ >+ public void setInitializationData(IConfigurationElement config, >+ String propertyName, Object data) throws CoreException >+ { >+ if(config.getName()!=null && config.getName().equals("axisValidator")) >+ { >+ IConfigurationElement requiredFileConfig = config.getChildren()[0]; >+ IConfigurationElement[] relativePathConfig = requiredFileConfig.getChildren(); >+ for(int i=0;i<relativePathConfig.length;i++) >+ { >+ if(relativePathConfig[i].getName()!=null && relativePathConfig[i].getName().equals("relativeFilePath")) >+ { >+ String value = relativePathConfig[i].getValue(); >+ if(value!=null && !value.equals("null")) >+ _requiredFiles.add(value); >+ } >+ } >+ } >+ } >+ >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/SingleValueMap.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/SingleValueMap.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/SingleValueMap.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/SingleValueMap.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,36 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Andrew Eberbach (aeberbac@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.util.AbstractMap; >+import java.util.HashSet; >+import java.util.Set; >+ >+public class SingleValueMap extends AbstractMap { >+ Object _value; >+ Set _entrySet = new HashSet(); >+ >+ public Object get(Object key) { >+ return _value; >+ } >+ >+ public Object put(Object key, Object value) { >+ Object oldValue = _value; >+ _value = value; >+ return oldValue; >+ } >+ >+ public Set entrySet() { >+ return _entrySet; >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/BasicMrtInspector.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/BasicMrtInspector.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/BasicMrtInspector.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/BasicMrtInspector.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,341 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import javax.wsdl.Definition; >+ >+import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >+import org.apache.ws.muse.descriptor.DescriptorFactory; >+import org.apache.ws.muse.descriptor.DocumentRoot; >+import org.apache.ws.muse.descriptor.InitParamType; >+import org.apache.ws.muse.descriptor.InitialInstancesType; >+import org.apache.ws.muse.descriptor.ReferenceParametersType; >+import org.apache.ws.muse.descriptor.ResourceTypeType; >+import org.apache.ws.muse.descriptor.WsdlType; >+import org.apache.ws.muse.descriptor.impl.CapabilityTypeImpl; >+import org.apache.ws.muse.descriptor.impl.ResourceTypeTypeImpl; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtension; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.emf.common.util.EMap; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.dde.internal.Messages; >+import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >+ >+/** >+ * This class analyzes the given manageable resource type and provide a resource >+ * type for muse descriptor. >+ */ >+ >+public class BasicMrtInspector implements MrtInspector >+{ >+ private DocumentRoot _root; >+ >+ private ResourceTypeType _resourceType; >+ >+ private ManageableResourceType _mrt; >+ /** >+ * Constructor of the class >+ * @param mrt >+ * @param root >+ */ >+ public BasicMrtInspector(ManageableResourceType mrt,DocumentRoot root) >+ { >+ _root = root; >+ _mrt = mrt; >+ } >+ >+ /** >+ * Get the initial instance for this manageable resource type >+ * @return InitialInstancesType - Array of the initial instances >+ */ >+ public InitialInstancesType[] getInitialInstances() >+ { >+ InitialInstancesType instance = DescriptorFactory.eINSTANCE >+ .createInitialInstancesType(); >+ ResourceTypeType rtClone = MRTCodeGenerationDelegate >+ .cloneResourceType(_resourceType); >+ instance.setResourceType(rtClone); >+ ReferenceParametersType refParam = DescriptorFactory.eINSTANCE >+ .createReferenceParametersType(); >+ >+ instance.setReferenceParameters(refParam); >+ return new InitialInstancesType[] { instance }; >+ } >+ >+ /** >+ * Create a new descriptor resource type for the given manageable resource >+ * type >+ * @param mrtCapabilities >+ * @return {@link ResourceTypeType} >+ */ >+ public ResourceTypeType inspect(Capability[] mrtCapabilities) >+ { >+ Mrt2DescriptorResourceType mrt2dd = new Mrt2DescriptorResourceType( >+ _root, _mrt, mrtCapabilities); >+ _resourceType = mrt2dd.getResourceTypeType(); >+ return _resourceType; >+ } >+ >+ public void setMrtParentDirectory(String mrtParentDir) >+ { >+ } >+ >+ public void persistArtifacts() >+ { >+ } >+ >+ public ManageableResourceType getExtraGeneratedMrt() >+ { >+ return null; >+ } >+ >+ public String getExtraGeneratedMrtPersistanceLocation() >+ { >+ return null; >+ } >+ >+ public void inspectMetadata(ManageableResourceType mrt, >+ MetadataDescriptor rmd) >+ { >+ } >+ >+} >+ >+class Mrt2DescriptorResourceType >+{ >+ private ManageableResourceType _mrt; >+ >+ private DocumentRoot _root; >+ >+ private Capability[] _mrtCapabilities; >+ >+ Mrt2DescriptorResourceType(DocumentRoot root, ManageableResourceType mrt) >+ { >+ this(root, mrt, null); >+ } >+ >+ Mrt2DescriptorResourceType(DocumentRoot root, ManageableResourceType mrt, >+ Capability[] mrtCapabilities) >+ { >+ _mrt = mrt; >+ _root = root; >+ if (mrtCapabilities == null) >+ try >+ { >+ _mrtCapabilities = MrtUtils.getCapabilities(mrt); >+ } >+ catch (Exception e) >+ { >+ } >+ else >+ _mrtCapabilities = mrtCapabilities; >+ } >+ >+ ResourceTypeType getResourceTypeType() >+ { >+ ResourceTypeTypeImpl rtd = (ResourceTypeTypeImpl) DescriptorFactory.eINSTANCE >+ .createResourceTypeType(); >+ rtd.setUseRouterPersistence(true); >+ rtd.setContextPath("/" + _mrt.getIdentifier()); //$NON-NLS-1$ >+ rtd >+ .setJavaIdFactoryClass(WsdmConstants.MUSE_RESOURCE_ID_FACTORY_CLASS); //$NON-NLS-1$ >+ rtd >+ .setJavaResourceClass(WsdmConstants.MUSE_RESOURCE_CLASS); //$NON-NLS-1$ >+ rtd.getCapability().addAll(getCapabilitiesFromMRT()); >+ WsdlType wsdlType = DescriptorFactory.eINSTANCE.createWsdlType(); >+ >+ String mrtFileLocation = getMrtFileWorkspaceLocation(); >+ if (mrtFileLocation == null) >+ ; >+ // TODO Log error not resolved location of given mrt >+ else >+ { >+ String mrtFilePathWithoutExtn = mrtFileLocation.substring(0, >+ mrtFileLocation.lastIndexOf('.')); >+ wsdlType.setWsdlFile(mrtFilePathWithoutExtn + ".wsdl"); >+ } >+ >+ String namespace = _mrt.getNamespace(); >+ String prefix = getOrCreatePrefix(_root, namespace); >+ String localPart = Messages.DU_PORT_TYPE_LOCAL_PART; // Only >+ // "PortType" >+ // should come >+ // with the >+ // //$NON-NLS-1$ >+ // prefix. >+ wsdlType.setWsdlPortType(prefix + ":" + localPart); >+ >+ rtd.setWsdl(wsdlType); >+ >+ // Fix for Bug 174792 Set "validate-wsrp-schema" to "false" for the dd file generated at the codegen from MRT >+ // http://bugs.eclipse.org/bugs/show_bug.cgi?id=174792 >+ InitParamType noValidateParam = DescriptorFactory.eINSTANCE.createInitParamType(); >+ noValidateParam.setParamName("validate-wsrp-schema"); >+ noValidateParam.setParamValue("false"); >+ rtd.getInitParam().add(noValidateParam); >+ >+ return rtd; >+ } >+ >+ private static String getOrCreatePrefix(DocumentRoot root, String namespace) >+ { >+ String prefix = getPrefix(root, namespace); >+ if (prefix != null) >+ return prefix; >+ String newPrefix = generateNewPrefix(root); >+ root.getXMLNSPrefixMap().put(newPrefix, namespace); >+ return newPrefix; >+ } >+ >+ private static String generateNewPrefix(DocumentRoot root) >+ { >+ int count = 0; >+ while (isPrefixExists(root, "pfx" + count)) //$NON-NLS-1$ >+ count++; >+ return "pfx" + count; //$NON-NLS-1$ >+ } >+ >+ private static boolean isPrefixExists(DocumentRoot root, String prefix) >+ { >+ EMap map = root.getXMLNSPrefixMap(); >+ Iterator keyIt = map.keySet().iterator(); >+ while (keyIt.hasNext()) >+ { >+ String pfx = (String) keyIt.next(); >+ if (pfx.equals(prefix)) >+ return true; >+ } >+ return false; >+ } >+ >+ private static String getPrefix(DocumentRoot root, String namespace) >+ { >+ if (root == null) >+ return null; >+ if (namespace == null) >+ return null; >+ EMap map = root.getXMLNSPrefixMap(); >+ Iterator keyIt = map.keySet().iterator(); >+ Iterator valuesIt = map.values().iterator(); >+ while (valuesIt.hasNext()) >+ { >+ String ns = (String) valuesIt.next(); >+ String prefix = (String) keyIt.next(); >+ if (ns.equals(namespace)) >+ return prefix; >+ } >+ return null; >+ } >+ >+ private List getCapabilitiesFromMRT() >+ { >+ if (_mrt == null) >+ return null; >+ List capDataList = new ArrayList(); >+ for (int i = 0; i < _mrtCapabilities.length; i++) >+ { >+ Capability capability = _mrtCapabilities[i]; >+ String capNS = ""; //$NON-NLS-1$ >+ Definition def = capability.getWsdlDefinition().getDefinition(); >+ if (def != null) >+ { >+ capNS = capability.getWsdlDefinition().getNamespace( >+ "capabilityURI"); >+ if (capNS == null) >+ capNS = capability.getNamespace(); >+ >+ } >+ CapabilityTypeImpl ctype = (CapabilityTypeImpl) DescriptorFactory.eINSTANCE >+ .createCapabilityType(); >+ ctype.setCapabilityUri(capNS); >+ String className = getJavaCapabilityClass(capNS); >+ ctype.setJavaCapabilityClass(className); >+ boolean isValid = validateCapability(capDataList, ctype); >+ if (isValid) >+ capDataList.add(ctype); >+ } >+ return capDataList; >+ } >+ >+ private boolean validateCapability(List capDataList, >+ CapabilityTypeImpl ctype) >+ { >+ if (capDataList == null || capDataList.size() == 0) >+ { >+ capDataList = new ArrayList(); >+ return true; >+ } >+ for (int i = 0; i < capDataList.size(); i++) >+ { >+ CapabilityTypeImpl tmp = (CapabilityTypeImpl) capDataList.get(i); >+ if (tmp.getCapabilityUri().trim().equals( >+ ctype.getCapabilityUri().trim())) >+ return false; >+ } >+ return true; >+ } >+ >+ private String getMrtFileWorkspaceLocation() >+ { >+ try >+ { >+ IFile mrtFile = EclipseUtils.getIFile(_mrt.eResource().getURI() >+ .toString()); >+ return mrtFile.getFullPath().toString(); >+ } >+ catch (CoreException e) >+ { >+ WsdmToolingLog.logError(e.getLocalizedMessage(), e); >+ } >+ return null; >+ } >+ >+ private String getJavaCapabilityClass(String uri) >+ { >+ String ns = "org.eclipse.tptp.wsdm.model"; >+ IExtensionPoint iep = Platform.getExtensionRegistry() >+ .getExtensionPoint(ns, "mrCapability"); >+ if (iep != null) >+ { >+ IExtension[] extensions = iep.getExtensions(); >+ for (int i = 0; i < extensions.length; i++) >+ { >+ IConfigurationElement[] ice = extensions[i] >+ .getConfigurationElements(); >+ for (int j = 0; j < ice.length; j++) >+ { >+ String capURI = ice[j].getAttribute("uri"); >+ if (uri.equals(capURI)) >+ { >+ String className = ice[j] >+ .getAttribute("implementingClass"); >+ return (className == null) ? "" : className; >+ } >+ } >+ } >+ } >+ return ""; >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/TargetedFileList.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/TargetedFileList.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/TargetedFileList.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/TargetedFileList.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.util.ArrayList; >+ >+public class TargetedFileList { >+ private String _relativePath; // path relative to webcontent folder >+ private ArrayList _absoluteFilePaths; >+ >+ public TargetedFileList(String relativePath){ >+ _relativePath = relativePath; >+ _absoluteFilePaths = new ArrayList(); >+ } >+ >+ public void add(String absolutePath){ >+ if(absolutePath!=null && !absolutePath.trim().equals("")){ >+ _absoluteFilePaths.add(absolutePath); >+ } >+ } >+ >+ public String[] getFiles(){ >+ if(_absoluteFilePaths==null) return new String[]{}; >+ return (String[]) _absoluteFilePaths.toArray(new String[]{}); >+ } >+ >+ public String getRelativePath(){ >+ return _relativePath; >+ } >+ >+ >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/ServiceGroupInspector.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/ServiceGroupInspector.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/ServiceGroupInspector.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/ServiceGroupInspector.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,366 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.io.ByteArrayInputStream; >+import java.io.InputStream; >+import java.util.ArrayList; >+import java.util.HashMap; >+import java.util.List; >+ >+import javax.xml.namespace.QName; >+ >+import org.apache.muse.util.xml.XmlUtils; >+import org.apache.muse.ws.addressing.soap.SoapFault; >+import org.apache.muse.ws.resource.sg.WssgConstants; >+import org.apache.ws.muse.descriptor.CapabilityType; >+import org.apache.ws.muse.descriptor.DescriptorFactory; >+import org.apache.ws.muse.descriptor.DocumentRoot; >+import org.apache.ws.muse.descriptor.InitParamType; >+import org.apache.ws.muse.descriptor.InitialInstancesType; >+import org.apache.ws.muse.descriptor.ReferenceParametersType; >+import org.apache.ws.muse.descriptor.ResourceTypeType; >+import org.apache.ws.muse.descriptor.WsdlType; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.resource.ResourceSet; >+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >+import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.NewNameGenerator; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceTypeFactory; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.MembershipContentRuleType; >+import org.eclipse.tptp.wsdm.tooling.util.internal.CustomMrtResourceFactoryImpl; >+import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; >+/** >+ * This class analyzes the given manageable resource type and provide an extra >+ * resource type for muse descriptor (ServiceGroupEntry), if manageable >+ * resource type contains the ServiceGroupCapability and ServiceGroupRegistration capability. >+ */ >+ >+public class ServiceGroupInspector implements MrtInspector >+{ >+ >+ private String _mrtParentDirName; >+ >+ private DocumentRoot _root; >+ >+ private ResourceTypeType _serviceGroupEntryResorceType; >+ >+ private ManageableResourceType _serviceGroupEntrymrt; >+ >+ private HashMap _prefixNamespaceMap; >+ >+ /** >+ * Constructor for the ServiceGroupIspector class. >+ * @param mrt >+ * @param root >+ */ >+ >+ public ServiceGroupInspector(ManageableResourceType mrt,DocumentRoot root) >+ { >+ _root = root; >+ } >+ >+ /** >+ * Analyzes the given manageable resource type for ServiceGroupCapability and >+ * ServiceGroupRegistrationCapability and if the capabilities available then returns the muse >+ * resource type for ServiceGroupEntry else returns the null. >+ */ >+ public ResourceTypeType inspect(Capability[] mrtCapabilities) >+ { >+ >+ if(hasServiceGroupCapabilities(mrtCapabilities)) >+ return createServiceGroupEntryResourceType(); >+ return null; >+ } >+ >+ private boolean hasServiceGroupCapabilities(Capability[] mrtCapabilities) >+ { >+ boolean hasServiceGroupCapability = false; >+ >+ boolean hasServiceGroupRegistration = false; >+ >+ for(int i =0;i<mrtCapabilities.length;i++) >+ { >+ if(mrtCapabilities[i].getNamespace().equals(WsdmConstants.SERVICE_GROUP_NS)) >+ hasServiceGroupCapability = true; >+ if(mrtCapabilities[i].getNamespace().equals(WsdmConstants.SERVICE_GROUP_REG_NS)) >+ hasServiceGroupRegistration = true; >+ } >+ return hasServiceGroupCapability && hasServiceGroupRegistration; >+ } >+ >+ /** >+ * Returns the initial instances >+ * @return InitialInstancesType[] >+ */ >+ public InitialInstancesType[] getInitialInstances() { >+ >+ InitialInstancesType instance = DescriptorFactory.eINSTANCE >+ .createInitialInstancesType(); >+ ResourceTypeType rtClone = MRTCodeGenerationDelegate >+ .cloneResourceType(_serviceGroupEntryResorceType); >+ instance.setResourceType(rtClone); >+ ReferenceParametersType refParam = DescriptorFactory.eINSTANCE >+ .createReferenceParametersType(); >+ instance.setReferenceParameters(refParam); >+ return new InitialInstancesType[] { instance }; >+ >+ } >+ /** >+ * Sets the parent directory >+ * @param mrtParentDir >+ */ >+ public void setMrtParentDirectory(String mrtParentDir) { >+ _mrtParentDirName = mrtParentDir; >+ >+ } >+ >+ private ResourceTypeType createServiceGroupEntryResourceType() >+ { >+ createServiceGroupEntryMrt(); >+ _serviceGroupEntryResorceType = createServiceGroupEntryMuseResourceType(); >+ return _serviceGroupEntryResorceType; >+ } >+ >+ private void createServiceGroupEntryMrt() >+ { >+ org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.DocumentRoot documentRoot = ManageableResourceTypeFactory.eINSTANCE.createDocumentRoot(); >+ _serviceGroupEntrymrt = ManageableResourceTypeFactory.eINSTANCE.createManageableResourceType(); >+ documentRoot.setManageableResource(_serviceGroupEntrymrt); >+ _serviceGroupEntrymrt.setIdentifier("ServiceGroupEntry"); >+ _serviceGroupEntrymrt.setNamespace("http://docs.oasis-open.org/wsrf/sgw-2"); >+ _serviceGroupEntrymrt.getImplements().add(WsdmConstants.MEX_CAPABILITY_LOCATION); >+ _serviceGroupEntrymrt.getImplements().add(WsdmConstants.GET_CAPABILITY_LOCATION); >+ _serviceGroupEntrymrt.getImplements().add(WsdmConstants.SET_CAPABILITY_LOCATION); >+ _serviceGroupEntrymrt.getImplements().add(WsdmConstants.QUERY_CAPABILITY_LOCATION); >+ _serviceGroupEntrymrt.getImplements().add(WsdmConstants.IMMIDIATE_RESOURCE_TERMINATION_CAPABILITY_LOCATION); >+ _serviceGroupEntrymrt.getImplements().add(WsdmConstants.SCHEDULED_RESOURCE_TERMINATION_CAPABILITY_LOCATION); >+ _serviceGroupEntrymrt.getImplements().add(WsdmConstants.SERVICE_GROUP_ENTRY_CAPABILITY_LOCATION); >+ } >+ >+ private ResourceTypeType createServiceGroupEntryMuseResourceType() >+ { >+ ResourceTypeType resourceType = DescriptorFactory.eINSTANCE.createResourceTypeType(); >+ resourceType.setContextPath("/ServiceGroupEntry"); >+ resourceType.setJavaIdFactoryClass("org.apache.muse.core.routing.CounterResourceIdFactory"); >+ resourceType.setJavaResourceClass("org.apache.muse.ws.resource.impl.SimpleWsResource"); >+ >+ WsdlType wsdlType = DescriptorFactory.eINSTANCE.createWsdlType(); >+ wsdlType.setWsdlFile(_mrtParentDirName + "/" + "ServiceGroupEntry.wsdl"); >+ _root.getXMLNSPrefixMap().put("wsrf-sge","http://docs.oasis-open.org/wsrf/sgw-2"); >+ wsdlType.setWsdlPortType("wsrf-sge:PortType"); >+ resourceType.setWsdl(wsdlType); >+ >+ CapabilityType metadataExchange = DescriptorFactory.eINSTANCE.createCapabilityType(); >+ metadataExchange.setCapabilityUri(WsdmConstants.MEX_NS); >+ metadataExchange.setJavaCapabilityClass(""); >+ >+ CapabilityType getCapability = DescriptorFactory.eINSTANCE.createCapabilityType(); >+ getCapability.setCapabilityUri(WsdmConstants.GET_NS); >+ getCapability.setJavaCapabilityClass(""); >+ >+ CapabilityType setCapability = DescriptorFactory.eINSTANCE.createCapabilityType(); >+ setCapability.setCapabilityUri(WsdmConstants.SET_NS); >+ setCapability.setJavaCapabilityClass(""); >+ >+ CapabilityType queryCapability = DescriptorFactory.eINSTANCE.createCapabilityType(); >+ queryCapability.setCapabilityUri(WsdmConstants.QUERY_NS); >+ queryCapability.setJavaCapabilityClass(""); >+ >+ CapabilityType immediateDestruction = DescriptorFactory.eINSTANCE.createCapabilityType(); >+ immediateDestruction.setCapabilityUri(WsdmConstants.IMMIDIATE_TERM_NS); >+ immediateDestruction.setJavaCapabilityClass(""); >+ >+ CapabilityType scheduledDestruction = DescriptorFactory.eINSTANCE.createCapabilityType(); >+ scheduledDestruction.setCapabilityUri(WsdmConstants.SCHEDULDED_TERM_NS); >+ scheduledDestruction.setJavaCapabilityClass(""); >+ >+ CapabilityType serviceGroupEntry = DescriptorFactory.eINSTANCE.createCapabilityType(); >+ serviceGroupEntry.setCapabilityUri(WsdmConstants.SERVICE_GROUP_ENTRY_NS); >+ serviceGroupEntry.setJavaCapabilityClass(""); >+ >+ InitParamType noValidateParam = DescriptorFactory.eINSTANCE .createInitParamType(); >+ noValidateParam.setParamName("validate-wsrp-schema"); >+ noValidateParam.setParamValue("false"); >+ >+ resourceType.getCapability().add(metadataExchange); >+ resourceType.getCapability().add(getCapability); >+ resourceType.getCapability().add(setCapability); >+ resourceType.getCapability().add(queryCapability); >+ resourceType.getCapability().add(immediateDestruction); >+ resourceType.getCapability().add(scheduledDestruction); >+ resourceType.getCapability().add(serviceGroupEntry); >+ resourceType.getInitParam().add(noValidateParam); >+ >+ return resourceType; >+ } >+ >+ private String getNamespace(String contentElement) >+ { >+ return contentElement.substring(1,contentElement.lastIndexOf('}')); >+ } >+ >+ private void preparePrfixNamespaceMap(String contentElement) >+ { >+ if(!_prefixNamespaceMap.containsKey(contentElement)) >+ { >+ NewNameGenerator nameGenerator = new NewNameGenerator("pfx"); >+ String prefix = nameGenerator.getNextName(); >+ >+ while (nameAlreadyExists(prefix)) >+ { >+ prefix = nameGenerator.getNextName(); >+ } >+ _prefixNamespaceMap.put(contentElement, prefix); >+ } >+ } >+ >+ private boolean nameAlreadyExists(String prefix) >+ { >+ if(_prefixNamespaceMap.containsValue(prefix)) >+ return true; >+ return false; >+ } >+ >+ private String getLocalName(String namespace) >+ { >+ return namespace.substring(namespace.lastIndexOf('}')+1); >+ } >+ >+ /** >+ * This method will returns the extra generated ManageableResourceType object equivalent to ServiceGroupEntry. >+ */ >+ public ManageableResourceType getExtraGeneratedMrt() { >+ >+ return _serviceGroupEntrymrt; >+ } >+ >+ /** >+ * This method should return the persistance location for extra generated ManageableResourceType object equivalent to ServiceGroupEntry. >+ */ >+ public String getExtraGeneratedMrtPersistanceLocation() >+ { >+ return _mrtParentDirName + "/"+ "ServiceGroupEntry.mrt"; >+ } >+ /** >+ * This method will persist the extra artifacts generated at the code generation time(ServiceGroupEntry). >+ */ >+ public void persistArtifacts() >+ { >+ try{ >+ ResourceSet rs = new ResourceSetImpl(); >+ rs.getResourceFactoryRegistry().getExtensionToFactoryMap() >+ .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new CustomMrtResourceFactoryImpl()); >+ String serviceGroupMrt = _mrtParentDirName + "/"+ "ServiceGroupEntry.mrt"; >+ URI uri = URI.createPlatformResourceURI(serviceGroupMrt); >+ byte[] rawNewMRT = MrtUtils.serializeMRT(_serviceGroupEntrymrt, rs, uri, true); >+ InputStream stream = new ByteArrayInputStream(rawNewMRT); >+ IFile subManagerMrtFile = EclipseUtils.getIFile(serviceGroupMrt); >+ if (subManagerMrtFile.exists()) >+ { >+ subManagerMrtFile.setContents(stream, true, true, >+ new NullProgressMonitor()); >+ } >+ else >+ { >+ subManagerMrtFile.create(stream, true, >+ new NullProgressMonitor()); >+ } >+ stream.close(); >+ } >+ catch(Exception e) >+ { >+ e.printStackTrace(); >+ } >+ } >+ >+ /** >+ * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given >+ * merged RMD document for it by having the rules/relationships in it. >+ */ >+ public void inspectMetadata(ManageableResourceType mrt, >+ org.apache.muse.ws.resource.metadata.MetadataDescriptor rmd) >+ { >+ >+ _prefixNamespaceMap = new HashMap(); >+ Capability[] mrtCapabilities = new Capability[0]; >+ try >+ { >+ mrtCapabilities = MrtUtils.getCapabilities(mrt); >+ } >+ catch (Exception e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ >+ if(hasServiceGroupCapabilities(mrtCapabilities)) >+ { >+ List membershipContentRule = mrt.getMembershipContentRule(); >+ List initialValues = new ArrayList(); >+ for(int i=0;i<membershipContentRule.size();i++) >+ { >+ MembershipContentRuleType rule = (MembershipContentRuleType) membershipContentRule.get(i); >+ Element value = createMembershipContentRuleElement(rule); >+ >+ initialValues.add(value); >+ } >+ if(!initialValues.isEmpty()); >+ try >+ { >+ rmd.setInitialValues(new QName(WssgConstants.NAMESPACE_URI,"MembershipContentRule"), initialValues); >+ } >+ catch (SoapFault e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ } >+ } >+ >+ private Element createMembershipContentRuleElement(MembershipContentRuleType rule) >+ { >+ Document document = XmlUtils.createDocument(); >+ Element membershipContentRuleElement = XmlUtils.createElement(document, new QName(WssgConstants.NAMESPACE_URI,"MembershipContentRule")); >+ List contentElements = rule.getContentElements(); >+ String contentElementAttribute=""; >+ >+ for(int i =0 ;i<contentElements.size();i++) >+ { >+ String contentElement = (String)contentElements.get(i); >+ String tns = getNamespace(contentElement); >+ String localName = getLocalName(contentElement); >+ preparePrfixNamespaceMap(tns); >+ >+ if(contentElementAttribute.length() !=0) >+ contentElementAttribute = contentElementAttribute + " " + (String)_prefixNamespaceMap.get(tns)+":"+ localName; >+ else >+ contentElementAttribute =(String)_prefixNamespaceMap.get(tns)+":"+ localName; >+ String xmlns = "xmlns:" + _prefixNamespaceMap.get(tns); >+ membershipContentRuleElement.setAttribute(xmlns,tns ); >+ >+ } >+ membershipContentRuleElement.setAttribute("ContentElements",contentElementAttribute ); >+ >+ return membershipContentRuleElement; >+ >+ >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/Generation.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/Generation.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/Generation.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/Generation.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,72 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Andrew Eberbach (aeberbac@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.wizard.WizardDialog; >+import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >+import org.eclipse.ui.IObjectActionDelegate; >+import org.eclipse.ui.IWorkbenchPart; >+ >+/** >+ * Access point code from the code generation option in popup >+ */ >+public class Generation implements IObjectActionDelegate >+{ >+ >+ private IWorkbenchPart _targetPart; >+ >+ private StructuredSelection _selection; >+ >+ /** >+ * (non-Javadoc) >+ * @see org.eclipse.ui.IObjectActionDelegate#run(org.eclipse.jface.action.IAction) >+ */ >+ public void run(IAction action) >+ { >+ IFile mrtFile = (IFile) _selection.getFirstElement(); >+ MrtUtils.searchAndSaveMRTEditor(mrtFile); >+ MRTCodeGenerationDelegate codeGenerationDelegate = new MRTCodeGenerationDelegate( >+ mrtFile); >+ >+ NewProjectWizard npw = new NewProjectWizard(codeGenerationDelegate); >+ WizardDialog wd = new WizardDialog(_targetPart.getSite().getShell(), >+ npw); >+ wd.open(); >+ } >+ >+ /** >+ * (non-Javadoc) >+ * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) >+ */ >+ public void setActivePart(IAction action, IWorkbenchPart targetPart) >+ { >+ _targetPart = targetPart; >+ } >+ >+ /** >+ * (non-Javadoc) >+ * @see org.eclipse.ui.IObjectActionDelegate#selectionChanged >+ (org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) >+ */ >+ public void selectionChanged(IAction action, ISelection selection) >+ { >+ if (selection instanceof StructuredSelection) >+ { >+ _selection = (StructuredSelection) selection; >+ } >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MrtPreProcessor.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MrtPreProcessor.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MrtPreProcessor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MrtPreProcessor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,250 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Andrew Eberbach (aeberbac@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.util.ArrayList; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+import java.util.Map; >+ >+import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >+import org.apache.ws.muse.descriptor.DocumentRoot; >+import org.apache.ws.muse.descriptor.InitialInstancesType; >+import org.apache.ws.muse.descriptor.MuseType; >+import org.apache.ws.muse.descriptor.ResourceTypeType; >+import org.apache.ws.muse.descriptor.RootType; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.tptp.wsdm.tooling.editor.dde.util.internal.DdeUtil; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >+import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >+ >+/** >+ * This class analyzes the given ManageableResourceType object and check whether it needs >+ * any other extra ManageableResourceType object such as SubscriptionManager based on the capabilities >+ * available in given ManagableResourceType. >+ */ >+ >+public class MrtPreProcessor >+{ >+ private ManageableResourceType _mrt; >+ private DocumentRoot _ddRoot; >+ private IFile _mrtFile; >+ private List _generatedResourceTypes = new LinkedList(); >+ private List _initialInstancesList = new LinkedList(); >+ private List _contributedInspectors = new LinkedList(); >+ private Map _mrtObjectMap = new HashMap(); >+ private List _allInspectors = new LinkedList(); >+ >+ /** >+ * Creates instance of this class. >+ * >+ * @param mrt >+ * Given MRT to analyze. >+ * >+ * @param ddRoot >+ * Given Descriptor file document root, can be null. >+ */ >+ public MrtPreProcessor(ManageableResourceType mrt, DocumentRoot ddRoot) >+ { >+ _mrt = mrt; >+ if(ddRoot == null) >+ ddRoot = DdeUtil.createInitialDDModel(); >+ _ddRoot = ddRoot; >+ String mrtLocation = _mrt.eResource().getURI().toString(); >+ try >+ { >+ _mrtFile = EclipseUtils.getIFile(mrtLocation); >+ } >+ catch (CoreException e) >+ { >+ e.printStackTrace(); >+ } >+ } >+ >+ /** >+ * Creates instance of this class. >+ * >+ * @param mrt >+ * Given MRT to analyze. >+ */ >+ public MrtPreProcessor(ManageableResourceType mrt) >+ { >+ this(mrt,null); >+ } >+ >+ /** >+ * Returns the modified Descriptor document root. >+ */ >+ public DocumentRoot getDDDocumentRoot() >+ { >+ return _ddRoot; >+ } >+ >+ /** >+ * Analyzes the given MRT file for extra required artifacts. >+ */ >+ public void preProcess() >+ { >+ if(_ddRoot!=null) >+ { >+ RootType root = _ddRoot.getRoot(); >+ MuseType muse = root.getMuse(); >+ ResourceTypeType[] resourceTypes = process(); >+ for (int i = 0; i < resourceTypes.length; i++) >+ muse.getResourceType().add(resourceTypes[i]); >+ >+ // Create initial instances >+ >+ InitialInstancesType[] instances = getInitialInstances(); >+ for (int i = 0; i < instances.length; i++) >+ root.getInitialInstances().add(instances[i]); >+ } >+ } >+ >+ private boolean hasResourceTypeInDD(ResourceTypeType givenResourceType) >+ { >+ if(_ddRoot!=null) >+ { >+ if(_ddRoot.getRoot()!=null) >+ { >+ if(_ddRoot.getRoot().getMuse()!=null) >+ { >+ MuseType muse = _ddRoot.getRoot().getMuse(); >+ List resourceTypes = muse.getResourceType(); >+ if(resourceTypes!=null) >+ { >+ for(int i=0;i<resourceTypes.size();i++) >+ { >+ ResourceTypeType resourceType = (ResourceTypeType)resourceTypes.get(i); >+ boolean equalContextPath = givenResourceType.getContextPath().equals(resourceType.getContextPath()); >+ boolean equalWsdlFile = givenResourceType.getWsdl().getWsdlFile().equals(resourceType.getWsdl().getWsdlFile()); >+ boolean equalWsdlPortType = givenResourceType.getWsdl().getWsdlPortType().equals(resourceType.getWsdl().getWsdlPortType()); >+ if(equalContextPath && equalWsdlFile && equalWsdlPortType) >+ return true; >+ } >+ } >+ } >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * This method processes the given manageable resource type to check whether >+ * we need any extra resource type in muse descriptor file such as >+ * Subscription manager etc. It will returns all the proper ResourceTypeType >+ * objects. So it will return atleast one ResourceTypeType object that >+ * represents the given manageable resource type. >+ */ >+ private ResourceTypeType[] process() >+ { >+ Capability[] mrtCapabilities = new Capability[0]; >+ try >+ { >+ mrtCapabilities = MrtUtils.getCapabilities(_mrt); >+ } >+ catch (Exception e) >+ { >+ } >+ // Analyze the given manageable resource type for Subscription manager >+ // etc. >+ // If needed add the extra resource type for Subscription manager >+ List inspectors = getAllMrtInspectors(); >+ for (int i = 0; i < inspectors.size(); i++) >+ { >+ MrtInspector inspector = (MrtInspector) inspectors.get(i); >+ inspector.setMrtParentDirectory(_mrtFile.getParent().getFullPath() >+ .toString()); >+ ResourceTypeType resourceType = inspector.inspect(mrtCapabilities); >+ if (resourceType != null) >+ { >+ if(!hasResourceTypeInDD(resourceType)) >+ { >+ _generatedResourceTypes.add(resourceType); >+ InitialInstancesType[] instances = inspector >+ .getInitialInstances(); >+ for (int j = 0; j < instances.length; j++) >+ _initialInstancesList.add(instances[j]); >+ if(inspector.getExtraGeneratedMrt()!=null) >+ _mrtObjectMap.put(inspector.getExtraGeneratedMrtPersistanceLocation(), inspector.getExtraGeneratedMrt()); >+ _contributedInspectors.add(inspector); >+ } >+ } >+ _allInspectors.add(inspector); >+ } >+ return (ResourceTypeType[]) _generatedResourceTypes >+ .toArray(new ResourceTypeType[_generatedResourceTypes.size()]); >+ } >+ >+ private List getAllMrtInspectors() >+ { >+ List inspectors = new ArrayList(); >+ inspectors.add(new BasicMrtInspector(_mrt, _ddRoot)); >+ // We don't analyze MRT for SubscriptionManager >+ // As it is already handled in MUSE-2.1 >+ //inspectors.add(new SubscriptionManagerInspector(_ddRoot)); >+ inspectors.add(new ServiceGroupInspector(_mrt, _ddRoot)); >+ inspectors.add(new RelationshipInspector(_ddRoot)); >+ return inspectors; >+ } >+ >+ /** >+ * Returns the initial instances >+ * @return IntialInstancesType[] >+ */ >+ private InitialInstancesType[] getInitialInstances() >+ { >+ return (InitialInstancesType[]) _initialInstancesList >+ .toArray(new InitialInstancesType[_initialInstancesList.size()]); >+ } >+ >+ /** >+ * Returns the map. >+ * Key will be the persisted location of MRT and >+ * value will be the ManageableREsourceType object. >+ */ >+ public Map getMrtObjectMap() >+ { >+ return _mrtObjectMap; >+ } >+ >+ /** >+ * This method will persist the extra artifacts generated at codegen time. >+ */ >+ public void persistArtifacts() >+ { >+ for(int i=0;i<_contributedInspectors.size();i++) >+ { >+ MrtInspector inspector = (MrtInspector)_contributedInspectors.get(i); >+ inspector.persistArtifacts(); >+ } >+ } >+ >+ /** >+ * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given >+ * merged RMD document for it by having the rules/relationships in it. >+ */ >+ public void inspectMetadata(ManageableResourceType mrt, MetadataDescriptor rmd) >+ { >+ for(Iterator iter = _allInspectors.iterator();iter.hasNext();) >+ { >+ MrtInspector inspector = (MrtInspector) iter.next(); >+ inspector.inspectMetadata(mrt, rmd); >+ } >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MrtInspector.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MrtInspector.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MrtInspector.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MrtInspector.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,69 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Andrew Eberbach (aeberbac@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >+import org.apache.ws.muse.descriptor.InitialInstancesType; >+import org.apache.ws.muse.descriptor.ResourceTypeType; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >+ >+/** >+ * This interface is created for some cases where we expect some extra resource >+ * type to be added to the muse descriptor based on the capability that >+ * manageable resource type holds. For example if someone includes the >+ * Notification producer capability in his manageable resource type, then muse >+ * runtime requires the Subscription Manager as one of the resource type >+ * described in muse descriptor file. >+ */ >+public interface MrtInspector >+{ >+ public static String WSDL_NAMESPACE = "http://schemas.xmlsoap.org/wsdl/"; >+ >+ /** >+ * Analyzes the given manageable resource type capabilities and then returns the muse >+ * resource type for some extra generated artifact else returns the null. >+ */ >+ ResourceTypeType inspect(Capability[] mrtCapabilities); >+ >+ /** >+ * This method should set the parent directory for extra generated artifact. >+ */ >+ void setMrtParentDirectory(String mrtParentDir); >+ >+ /** >+ * Returns initial instances for extra generated artifact. >+ */ >+ InitialInstancesType[] getInitialInstances(); >+ >+ /** >+ * This method will persist the extra artifacts generated at codegen time. >+ */ >+ void persistArtifacts(); >+ >+ /** >+ * This method will returns the extra ManageableResourceType object generated at codegen time. >+ */ >+ ManageableResourceType getExtraGeneratedMrt(); >+ >+ /** >+ * This method should return the persistance location for extra generated ManageableResourceType object. >+ */ >+ String getExtraGeneratedMrtPersistanceLocation(); >+ >+ /** >+ * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given >+ * merged RMD document for it by having the rules/relationships in it. >+ */ >+ void inspectMetadata(ManageableResourceType mrt, MetadataDescriptor rmd); >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/GenerationOptionsPage.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/GenerationOptionsPage.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/GenerationOptionsPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/GenerationOptionsPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,691 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.Map; >+import java.util.prefs.Preferences; >+ >+import org.apache.muse.tools.generator.analyzer.Analyzer; >+import org.apache.muse.tools.generator.projectizer.Projectizer; >+import org.apache.muse.tools.generator.synthesizer.Synthesizer; >+import org.eclipse.core.filesystem.URIUtil; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IWorkspace; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtension; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.dialogs.DialogPage; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.util.Util; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.osgi.util.TextProcessor; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Combo; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.DirectoryDialog; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Group; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Listener; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; >+import org.eclipse.tptp.wsdm.tooling.editor.mrt.relationship.dialog.internal.MemoryComboBox; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; >+import org.eclipse.tptp.wsdm.tooling.preferences.internal.Axis2ServerLocationPreferencePage; >+import org.eclipse.tptp.wsdm.tooling.util.internal.Validation; >+import org.eclipse.tptp.wsdm.tooling.validation.util.internal.ValidationUtils; >+ >+/** >+ * This wizard enables the use to specify the projectizer options and also the >+ * runtime environment and general options >+ */ >+public class GenerationOptionsPage extends WizardPage >+{ >+ private static final String PROJECT_MEMORY_COMBO_ID = "project_memory_combo"; >+ >+ private static final String EXT_PT = "codeGeneration"; >+ >+ private Button _overwriteButton; >+ >+ private Combo _projectNameField; >+ >+ private String _userPath = Util.ZERO_LENGTH_STRING;// IDEResourceInfoUtils.EMPTY_STRING; >+ >+ private Button _useDefaultsButton; >+ >+ private Label _locationLabel; >+ >+ private Text _locationPathField; >+ >+ private Button _browseButton; >+ >+ private IProject _existingProject; >+ >+ private Combo _projectizerCombo; >+ >+ private Button _persistExtraArtifactsButton; >+ >+ private Map _platformContainerMap = new HashMap(); >+ >+ private Combo _containerCombo; >+ >+ private Label _containerLabel; >+ >+ private Listener _containerComboListener = new Listener() { >+ >+ public void handleEvent(Event event) { >+ dialogChanged(); >+ } >+ >+ }; >+ >+ public GenerationOptionsPage() { >+ super("wizardPage"); >+ setTitle(Messages.HOOKUP_WIZARD_TXT1); >+ setDescription(Messages.HOOKUP_WIZARD_TXT2); >+ >+ loadExtensionData(); >+ setPageComplete(false); >+ } >+ >+ private void loadExtensionData() { >+ IExtensionRegistry er = Platform.getExtensionRegistry(); >+ IExtensionPoint ep = er.getExtensionPoint(Activator.PLUGIN_ID, EXT_PT); >+ IExtension[] extensions = ep.getExtensions(); >+ >+ for (int i = 0; i < extensions.length; i++) { >+ IConfigurationElement[] elements = extensions[i].getConfigurationElements(); >+ CodeGenerationData codeGenData = new CodeGenerationData(elements); >+ updatePlatformContainerMap(codeGenData); >+ } >+ } >+ >+ private void updatePlatformContainerMap(CodeGenerationData codeGenData) { >+ Map containerCodeGenDataMap = (Map) _platformContainerMap.get(codeGenData.getPlatform()); >+ if(containerCodeGenDataMap == null) { >+ // >+ // handles the case of proxy which doesn't have a container >+ // >+ if(codeGenData.getContainer() == null) { >+ containerCodeGenDataMap = new SingleValueMap(); >+ } else { >+ containerCodeGenDataMap = new HashMap(); >+ } >+ >+ _platformContainerMap.put(codeGenData.getPlatform(), containerCodeGenDataMap); >+ } >+ >+ // >+ // if the platform was null then it means we're using a >+ // singlevaluemap which doesn't look at the key ever >+ // >+ containerCodeGenDataMap.put(codeGenData.getContainer(), codeGenData); >+ } >+ >+ public void createControl(Composite parent) { >+ setControl(doLayout(parent)); >+ } >+ >+ private Composite doLayout(Composite parent) { >+ Composite container = new Composite(parent, SWT.NULL); >+ container.setLayout(new GridLayout(2, false)); >+ >+ GridData data = new GridData(); >+ data.horizontalAlignment = SWT.FILL; >+ data.grabExcessHorizontalSpace = true; >+ container.setLayoutData(data); >+ >+ createProjectInput(container); >+ >+ Composite composite = createProjectTypeGroup(container); >+ >+ data = new GridData(); >+ data.grabExcessHorizontalSpace = true; >+ data.horizontalAlignment = SWT.FILL; >+ data.horizontalSpan = 2; >+ composite.setLayoutData(data); >+ >+ composite = createProjectOptionsGroup(container); >+ >+ data = new GridData(); >+ data.grabExcessHorizontalSpace = true; >+ data.horizontalAlignment = SWT.FILL; >+ data.horizontalSpan = 2; >+ composite.setLayoutData(data); >+ return container; >+ } >+ >+ private void createProjectInput(Composite parent) { >+ Label projectNameLabel = new Label(parent, SWT.NONE); >+ projectNameLabel.setText(Messages.HOOKUP_WIZARD_TXT4); >+ >+ GridData data = new GridData(); >+ data.horizontalAlignment = SWT.FILL; >+ data.grabExcessHorizontalSpace = false; >+ projectNameLabel.setLayoutData(data); >+ >+ _projectNameField = MemoryComboBox.createMemoryComboBox(parent, Preferences.userNodeForPackage(GenerationOptionsPage.class), PROJECT_MEMORY_COMBO_ID); >+ >+ data = new GridData(); >+ data.horizontalAlignment = SWT.FILL; >+ data.grabExcessHorizontalSpace = true; >+ _projectNameField.setLayoutData(data); >+ >+ _projectNameField.addListener(SWT.Modify, nameModifyListener); >+ } >+ >+ private Group createProjectTypeGroup(Composite parent) { >+ Group page = new Group(parent, SWT.SHADOW_IN); >+ page.setText("Code Generation Options"); >+ page.setLayout(new GridLayout(2, false)); >+ >+ Label platformLabel = new Label(page, SWT.NONE); >+ platformLabel.setText("Platform:");//TODO AME >+ _projectizerCombo = makePlatformCombo(page); >+ >+ _containerLabel = new Label(page, SWT.NONE); >+ _containerLabel.setText("Container:");//TODO AME >+ _containerLabel.setEnabled(false); >+ >+ _containerCombo = makeContainerCombo(page); >+ >+ return page; >+ } >+ >+ private Group createProjectOptionsGroup(Composite parent) { >+ Group group = new Group(parent, SWT.SHADOW_IN); >+ group.setText("Project Options"); >+ group.setLayout(new GridLayout(3, false)); >+ >+ _useDefaultsButton = createDefaultsButton(group); >+ >+ GridData buttonData = new GridData(); >+ buttonData.horizontalSpan = 3; >+ _useDefaultsButton.setLayoutData(buttonData); >+ >+ createUserEntryArea(group, true); >+ createCheckboxes(group); >+ >+ return group; >+ } >+ >+ private Button createDefaultsButton(Composite parent) { >+ Button button = new Button(parent, SWT.CHECK | SWT.RIGHT); >+ button.setText(Messages.CODE_GEN_DEFAULT_LOCATION);// IDEWorkbenchMessages.ProjectLocationSelectionDialog_useDefaultLabel); >+ button.setSelection(true); >+ >+ button.addSelectionListener(new SelectionAdapter() >+ { >+ public void widgetSelected(SelectionEvent e) >+ { >+ boolean useDefaults = _useDefaultsButton.getSelection(); >+ >+ if (!useDefaults) >+ { >+ _userPath = _locationPathField.getText(); >+ _locationPathField.setText(TextProcessor >+ .process(getDefaultPathDisplayString())); >+ } >+ else >+ { >+ _locationPathField >+ .setText(TextProcessor.process(_userPath)); >+ } >+ setUserAreaEnabled(!useDefaults); >+ } >+ }); >+ >+ return button; >+ } >+ >+ private void createCheckboxes(Composite parent) { >+ GridData data = null; >+ >+ _overwriteButton = makeButton(parent, Messages.HOOKUP_WIZARD_TXT3, SWT.CHECK); >+ >+ data = new GridData(); >+ data.horizontalSpan = 2; >+ _overwriteButton.setLayoutData(data); >+ >+ _persistExtraArtifactsButton = makeButton(parent, Messages.HOOKUP_WIZARD_PERSIST, SWT.CHECK); >+ >+ data = new GridData(); >+ data.horizontalSpan = 2; >+ _persistExtraArtifactsButton.setLayoutData(data); >+ } >+ >+ private Combo makeContainerCombo(Group page) { >+ Combo combo = new Combo(page, SWT.BORDER | SWT.READ_ONLY); >+ combo.setEnabled(false); >+ >+ combo.addListener(SWT.Modify, _containerComboListener); >+ return combo; >+ } >+ >+ private Combo makePlatformCombo(Group page) >+ { >+ Combo combo = new Combo(page, SWT.BORDER | SWT.READ_ONLY); >+ for(Iterator i=_platformContainerMap.keySet().iterator(); i.hasNext();) { >+ combo.add(i.next().toString()); >+ } >+ combo.select(0); >+ combo.addListener(SWT.Modify, comboChangeListener); >+ >+ return combo; >+ } >+ >+ private void setUserAreaEnabled(boolean enabled) >+ { >+ _locationLabel.setEnabled(enabled); >+ _locationPathField.setEnabled(enabled); >+ _browseButton.setEnabled(enabled); >+ } >+ >+ private void createUserEntryArea(Composite composite, boolean defaultEnabled) >+ { >+ GridData data = null; >+ >+ // location label >+ _locationLabel = new Label(composite, SWT.NONE); >+ _locationLabel.setText(Messages.HOOKUP_WIZARD_TXT6); >+ >+ // project location entry field >+ _locationPathField = new Text(composite, SWT.BORDER); >+ data = new GridData(GridData.FILL_HORIZONTAL); >+ _locationPathField.setLayoutData(data); >+ >+ // browse button >+ _browseButton = new Button(composite, SWT.PUSH); >+ _browseButton.setText(Messages.HOOKUP_WIZARD_TXT5); >+ _browseButton.addSelectionListener(new SelectionAdapter() >+ { >+ public void widgetSelected(SelectionEvent event) >+ { >+ handleLocationBrowseButtonPressed(); >+ } >+ }); >+ >+ if (defaultEnabled) >+ { >+ _locationPathField.setText(TextProcessor >+ .process(getDefaultPathDisplayString())); >+ } >+ else >+ { >+ if (_existingProject == null) >+ { >+ _locationPathField.setText(Util.ZERO_LENGTH_STRING);// IDEResourceInfoUtils.EMPTY_STRING); >+ } >+ else >+ { >+ _locationPathField.setText(TextProcessor >+ .process(_existingProject.getLocation().toString())); >+ } >+ } >+ >+ _locationPathField.addModifyListener(new ModifyListener() >+ { >+ public void modifyText(ModifyEvent e) >+ { >+ setErrorMessage(checkValidLocation()); >+ } >+ }); >+ >+ setUserAreaEnabled(false); >+ } >+ >+ public boolean isDefault() >+ { >+ return _useDefaultsButton.getSelection(); >+ } >+ >+ public String getProjectLocation() >+ { >+ if(isDefault()) { >+ return null; >+ } >+ >+ String projectLocation = _locationPathField.getText(); >+ return projectLocation.length() == 0?null:projectLocation; >+ } >+ >+ public String checkValidLocation() >+ { >+ >+ if (isDefault()) >+ { >+ return null; >+ } >+ >+ String newPath = getProjectLocation(); >+ if (newPath == null) >+ { >+ return Messages.CODE_GEN_LOCATION_ERROR_; >+ } >+ >+ if (_existingProject == null) >+ { >+ IPath projectPath = new Path(newPath); >+ if (Platform.getLocation().isPrefixOf(projectPath)) >+ { >+ return Messages.NEW_PROJECT_CREATION_PAGE_DEFAULT_LOCATION_ERROR_; >+ } >+ >+ } >+ else >+ { >+ >+ IStatus locationStatus = _existingProject.getWorkspace() >+ .validateProjectLocationURI(_existingProject, URIUtil.toURI(newPath)); >+ >+ if (!locationStatus.isOK()) >+ { >+ return locationStatus.getMessage(); >+ } >+ >+ java.net.URI projectPath = _existingProject.getLocationURI(); >+ if (projectPath != null && URIUtil.equals(projectPath, URIUtil.toURI(newPath))) >+ { >+ return Messages.CODE_GEN_LOCATION_ERROR_; >+ } >+ } >+ >+ return null; >+ } >+ >+ private String getDefaultPathDisplayString() >+ { >+ >+ java.net.URI defaultURI = null; >+ if (_existingProject != null) >+ { >+ defaultURI = _existingProject.getLocationURI(); >+ } >+ >+ // Handle files specially. Assume a file if there is no project to query >+ if (defaultURI == null || defaultURI.getScheme().equals("file")) >+ { >+ return Platform.getLocation().append(_projectNameField.getText()) >+ .toString(); >+ } >+ return defaultURI.toString(); >+ >+ } >+ >+ private String getPathFromLocationField() >+ { >+ java.net.URI fieldURI; >+ try >+ { >+ fieldURI = new java.net.URI(_locationPathField.getText()); >+ } >+ catch (java.net.URISyntaxException e) >+ { >+ return _locationPathField.getText(); >+ } >+ return fieldURI.getPath(); >+ } >+ >+ private void updateLocationField(String selectedPath) >+ { >+ _locationPathField.setText(TextProcessor.process(selectedPath)); >+ } >+ >+ private void handleLocationBrowseButtonPressed() >+ { >+ >+ String selectedDirectory = null; >+ String dirName = getPathFromLocationField(); >+ >+ DirectoryDialog dialog = new DirectoryDialog(_locationPathField >+ .getShell()); >+ dialog.setMessage(Messages.CODE_GEN_DIR_LOCATION);// IDEWorkbenchMessages.ProjectLocationSelectionDialog_directoryLabel); >+ dialog.setFilterPath(dirName); >+ selectedDirectory = dialog.open(); >+ >+ if (selectedDirectory != null) >+ updateLocationField(selectedDirectory); >+ } >+ >+ private Listener nameModifyListener = new Listener() >+ { >+ public void handleEvent(Event e) >+ { >+ dialogChanged(); >+ } >+ }; >+ >+ private Listener comboChangeListener = new Listener() { >+ public void handleEvent(Event e) { >+ String platform = _projectizerCombo.getText(); >+ >+ Map containerCodeGenDataMap = (Map) _platformContainerMap.get(platform); >+ _containerCombo.removeListener(SWT.Modify, _containerComboListener); >+ _containerCombo.removeAll(); >+ >+ boolean hasContainers = containerCodeGenDataMap.size() != 0; >+ >+ if(hasContainers) { >+ for(Iterator i=containerCodeGenDataMap.keySet().iterator(); i.hasNext();) { >+ _containerCombo.add(i.next().toString()); >+ } >+ _containerCombo.select(0); >+ } >+ >+ _containerCombo.addListener(SWT.Modify, _containerComboListener); >+ _containerCombo.setEnabled(hasContainers); >+ _containerLabel.setEnabled(hasContainers); >+ >+ dialogChanged(); >+ } >+ }; >+ >+ private TargetedFileList[] _filesToCopy; >+ >+ protected void dialogChanged() >+ { >+ String prjName = getProjectName(); >+ >+ if (prjName.length() == 0) >+ { >+ updateStatus(Messages.HOOKUP_WIZARD_ERROR_1); >+ return; >+ } >+ >+ IWorkspace workspace = ResourcesPlugin.getWorkspace(); >+ IWorkspaceRoot root = workspace.getRoot(); >+ >+ IProject project = root.getProject(prjName); >+ >+ if (project != null && project.exists()) >+ { >+ updateStatus(Messages.PROJECT_EXISTS_WARN_, DialogPage.WARNING); >+ return; >+ } >+ >+ if (!Validation.isQName(prjName)) >+ { >+ updateStatus(Messages.HOOKUP_WIZARD_ERROR_2); >+ return; >+ } >+ >+ updateStatus(null, DialogPage.NONE); >+ } >+ >+ private void updateStatus(String message) >+ { >+ updateStatus(message, DialogPage.ERROR); >+ } >+ >+ private void updateStatus(String message, int type) >+ { >+ setMessage(message, type); >+ setPageComplete(type != DialogPage.ERROR); >+ } >+ >+ private Button makeButton(Composite parent, String title, int style) >+ { >+ Button b = new Button(parent, style); >+ b.setText(title); >+ return b; >+ } >+ >+ public boolean shouldPersistArtifacts() >+ { >+ return _persistExtraArtifactsButton.getSelection(); >+ } >+ >+ /** >+ * Return the value of the output project >+ * @return String >+ */ >+ public String getProjectName() >+ { >+ return _projectNameField.getText(); >+ } >+ >+ /** >+ * Returns if Overwrite button is enabled >+ * @return boolean >+ */ >+ public boolean canOverwrite() >+ { >+ return _overwriteButton.getSelection(); >+ } >+ >+ public CodeGenerationData getSelectedData() { >+ String platform = _projectizerCombo.getText(); >+ Map containerCodeGenDataMap = (Map) _platformContainerMap.get(platform); >+ String container = _containerCombo.getText(); >+ return (CodeGenerationData) containerCodeGenDataMap.get(container); >+ } >+ >+ /** >+ * Return the projectizer >+ * @return {@link Projectizer} >+ */ >+ public Projectizer getProjectizer() >+ { >+ return getSelectedData().getProjectizer(); >+ } >+ >+ /** >+ * Return the synthesizer >+ * @return {@link Synthesizer} >+ */ >+ public Synthesizer getSynthesizer() >+ { >+ return getSelectedData().getSynthesizer(); >+ } >+ >+ /** >+ * Return the analyzer >+ * @return {@link Analyzer} >+ */ >+ public Analyzer getAnalyzer() >+ { >+ return getSelectedData().getAnalyzer(); >+ } >+ >+ /** >+ * Returns the base address >+ * >+ * @return String >+ */ >+ public String getBaseAddress() >+ { >+ String baseAddress = "http://localhost"; >+ >+ int port = getSelectedData().getServicePort(); >+ if (port != 0) >+ { >+ baseAddress += ":" + port; >+ } >+ >+ baseAddress += "/" + getProjectName(); >+ >+ String servicePath = getSelectedData().getServicePath(); >+ >+ if (servicePath != null) >+ { >+ baseAddress += servicePath; >+ } >+ >+ return baseAddress; >+ } >+ >+ public boolean canFlipToNextPage() { >+ return isPageComplete() && isAxis2Project(); >+ } >+ public boolean isAxis2Project(){ >+ String container = getSelectedData().getContainer(); >+ return container != null && container.equals("Axis2"); >+ } >+ >+ public void saveCombo() { >+ MemoryComboBox.save(_projectNameField, PROJECT_MEMORY_COMBO_ID, Preferences.userNodeForPackage(GenerationOptionsPage.class)); >+ } >+ >+ private String validateLocation() >+ { >+ String serverHome = getPreferenceServerLocation(); >+ >+ ISoapServerDependency axisValidators[] = ValidationUtils.getAllAxisValidators(); >+ for(int i = 0 ; i < axisValidators.length ; i++){ >+ >+ ISoapServerDependency axis2Dependency = (Axis2ServerDependency)axisValidators[i]; >+ String errorMessage = axis2Dependency.validateSoapServerHome(serverHome); >+ if(errorMessage!=null) >+ return errorMessage; >+ _filesToCopy = axis2Dependency.getFilesToCopy(); >+ if(_filesToCopy == null) >+ _filesToCopy = new TargetedFileList[0]; >+ } >+ return null; >+ } >+ >+ /** >+ * Returns the Axis2 files to copied to generated code >+ * @return >+ */ >+ public TargetedFileList[] getAxis2FilesToCopy() >+ { >+ validateLocation(); >+ return _filesToCopy; >+ } >+ >+ protected String getPreferenceServerLocation() >+ { >+ IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); >+ String location = store.getString(Axis2ServerLocationPreferencePage.SERVER_LOCATION_PREFERENCE_KEY).trim(); >+ if(location != null && !location.equals("")) >+ return location; >+ return ""; >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/Axis2ServerDependency.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/Axis2ServerDependency.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/Axis2ServerDependency.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/Axis2ServerDependency.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,158 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.io.File; >+import java.io.FileFilter; >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; >+ >+/** >+ * This class verifies the Axis2 Soap Library dependency. >+ */ >+ >+public class Axis2ServerDependency extends SoapServerDependency implements ISoapServerDependency >+{ >+ private List _filesToCopy = new LinkedList(); >+ >+ /** >+ * @see ISoapServerDependency#validateSoapServerHome(String) >+ */ >+ public String validateSoapServerHome(String serverHome) >+ { >+ if(serverHome == null || serverHome.length() == 0) >+ return Messages.CODE_GEN_AXIS2_PROJECT_DIR; >+ >+ File serverHomeDir = new File(serverHome); >+ if(!serverHomeDir.exists()){ >+ return NLS.bind(Messages.CODE_GEN_AXIS2_LOCATION_ERROR_, serverHome); >+ } >+ >+ TargetedFileList _jarFilesToCopy = new TargetedFileList("WEB-INF/lib/"); >+ TargetedFileList _marFilesToCopy = new TargetedFileList("WEB-INF/modules/"); >+ TargetedFileList _restFilesToCopy = new TargetedFileList("WEB-INF/"); >+ >+ String[] relativeFilePaths = (String[]) _requiredFiles.toArray(new String[_requiredFiles.size()]); >+ for(int i=0;i<relativeFilePaths.length;i++) >+ { >+ String parentDirectory = getParentDirectory(relativeFilePaths[i]); >+ if(parentDirectory == null) >+ parentDirectory = serverHome; >+ else >+ parentDirectory = serverHome+File.separatorChar+parentDirectory; >+ >+ String fileExtension = getFileExtension(relativeFilePaths[i]); >+ if(fileExtension == null) >+ fileExtension = "*"; >+ FileFilter filter = new CustomFileFilter(fileExtension); >+ >+ File parentDirectoryFile = new File(parentDirectory); >+ if(!parentDirectoryFile.exists()) >+ return NLS.bind(Messages.CODE_GEN_AXIS2_LOCATION_ERROR_, parentDirectory); >+ >+ File[] allFiles = parentDirectoryFile.listFiles(filter); >+ String fileName = getFileName(relativeFilePaths[i]); >+ File matchedFile = getMatchedPatternFile(allFiles, fileName); >+ if(matchedFile == null) >+ return NLS.bind(Messages.CODE_GEN_ERROR_INVALID_AXIS_FILE, serverHome+File.separatorChar+relativeFilePaths[i]); >+ >+ String absolutePath = matchedFile.getAbsolutePath(); >+ if(absolutePath.endsWith("jar")) >+ _jarFilesToCopy.add(absolutePath); >+ else if(absolutePath.endsWith("mar")) >+ _marFilesToCopy.add(absolutePath); >+ else >+ _restFilesToCopy.add(absolutePath); >+ } >+ >+ _filesToCopy.add(_jarFilesToCopy); >+ _filesToCopy.add(_marFilesToCopy); >+ _filesToCopy.add(_restFilesToCopy); >+ >+ return null; >+ } >+ >+ private String getParentDirectory(String relativePath) >+ { >+ if(relativePath.indexOf('/')==-1) >+ return null; >+ return relativePath.substring(0,relativePath.lastIndexOf('/')); >+ } >+ >+ private String getFileExtension(String relativePath) >+ { >+ if(relativePath.indexOf('.')==-1) >+ return null; >+ return relativePath.substring(relativePath.lastIndexOf('.')+1); >+ } >+ >+ private String getFileName(String relativePath) >+ { >+ if(relativePath.indexOf('/')==-1) >+ { >+ if(relativePath.indexOf('.')==-1) >+ return relativePath; >+ else >+ return relativePath.substring(0,relativePath.lastIndexOf('.')); >+ } >+ else >+ { >+ String fileNameWithExtn = relativePath.substring(relativePath.lastIndexOf('/')+1); >+ if(fileNameWithExtn.indexOf('.')==-1) >+ return fileNameWithExtn; >+ else >+ return fileNameWithExtn.substring(0,fileNameWithExtn.lastIndexOf('.')); >+ } >+ } >+ >+ private File getMatchedPatternFile(File[] allFiles, String pattern) >+ { >+ String strippedPattern = pattern.indexOf("-*")==-1?pattern:pattern.substring(0,pattern.lastIndexOf("-*")); >+ for(int i=0;i<allFiles.length;i++) >+ { >+ if(allFiles[i].getName().startsWith(strippedPattern)) >+ return allFiles[i]; >+ } >+ return null; >+ } >+ >+ /** >+ * @see ISoapServerDependency#getFilesToCopy() >+ */ >+ public TargetedFileList[] getFilesToCopy() >+ { >+ return (TargetedFileList[])_filesToCopy.toArray(new TargetedFileList[_filesToCopy.size()]); >+ } >+} >+ >+class CustomFileFilter implements FileFilter >+{ >+ String fileExtension; >+ >+ CustomFileFilter(String extension) >+ { >+ fileExtension = extension; >+ } >+ >+ public boolean accept(File pathname) >+ { >+ if(!pathname.isFile()) >+ return false; >+ if(fileExtension.equals("*")) >+ return true; >+ return pathname.getName().endsWith(fileExtension); >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/EclipseConfigurationData.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/EclipseConfigurationData.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/EclipseConfigurationData.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/EclipseConfigurationData.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+public class EclipseConfigurationData >+{ >+ public static final String ADDITIONAL_JARS = "jars"; >+ public static final String INSTANCES = "instances"; >+ public static final String PROGRESS_MONITOR = "progress_monitor"; >+ public static final String AXIS2_FILES = "axis2_files"; >+ public static final String PROJECT_LOCATION = "location"; >+ public static final String PROJECT_NAME = "project_name"; >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MRTCodeGenerationDelegate.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MRTCodeGenerationDelegate.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MRTCodeGenerationDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MRTCodeGenerationDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,156 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Andrew Eberbach (aeberbac@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.io.ByteArrayInputStream; >+import java.io.ByteArrayOutputStream; >+import java.io.IOException; >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >+import org.apache.ws.muse.descriptor.DescriptorFactory; >+import org.apache.ws.muse.descriptor.DocumentRoot; >+import org.apache.ws.muse.descriptor.ResourceTypeType; >+import org.apache.ws.muse.descriptor.WsdlType; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.resource.ResourceSet; >+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >+import org.eclipse.tptp.wsdm.tooling.editor.dde.util.internal.DdeUtil; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >+import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.MyDescriptorResourceFactoryImpl; >+ >+/** >+ * This class acts as a way during the Code Generation of MRT to capture doing WSDL >+ * resolution so that it can be done later on, or on >+ * another thread since this would be time-consuming. >+ */ >+public class MRTCodeGenerationDelegate implements CodeGenerationDelegate >+{ >+ private ManageableResourceType _mrt; >+ private MrtPreProcessor _mrtPreProcessor; >+ private String _ddFilePath; >+ private IFile _mrtFile; >+ private DocumentRoot _ddRoot; >+ >+ /** >+ * Constructor of the class >+ * @param mrtFile >+ */ >+ public MRTCodeGenerationDelegate(IFile mrtFile) >+ { >+ _mrtFile = mrtFile; >+ URI mrtURI = URI.createPlatformResourceURI(mrtFile.getFullPath() >+ .toString()); >+ _mrt = MrtUtils.loadMRT(mrtURI); >+ _mrtPreProcessor = new MrtPreProcessor(_mrt); >+ } >+ >+ /** >+ * Creates the DD file. >+ * The method returns a DescriptorHelper which >+ * aggregates all of the work that was done. >+ * >+ * @param progressMonitor A progress monitor to >+ * show the progress done during this >+ * task. >+ * @throws Exception >+ */ >+ public DescriptorHelper run(SubProgressMonitor progressMonitor) >+ throws Exception >+ { >+ byte[] serializedDD = createDD(); >+ Map mrtObjectMap = _mrtPreProcessor.getMrtObjectMap(); >+ return new DescriptorHelper(this, new ByteArrayInputStream(serializedDD), mrtObjectMap, false); >+ } >+ >+ private byte[] createDD() >+ { >+ _mrtPreProcessor.preProcess(); >+ _ddRoot = _mrtPreProcessor.getDDDocumentRoot(); >+ ResourceSet resourceSet = new ResourceSetImpl(); >+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() >+ .put(Resource.Factory.Registry.DEFAULT_EXTENSION, >+ new MyDescriptorResourceFactoryImpl()); >+ URI uri = URI.createURI("dummy.xml"); >+ Resource resource = resourceSet.createResource(uri); >+ resource.getContents().add(_ddRoot); >+ Map map = new HashMap(); >+ ByteArrayOutputStream baos = new ByteArrayOutputStream(); >+ try >+ { >+ resource.save(baos, map); >+ } >+ catch (IOException e) >+ { >+ e.printStackTrace(); >+ } >+ return baos.toByteArray(); >+ } >+ >+ private String createDDFilePath() >+ { >+ IPath ddIPath = _mrtFile.getFullPath().removeFileExtension() >+ .addFileExtension("dd"); >+ return ddIPath.toString(); >+ } >+ >+ /** >+ * Create and return a new instance of given ResourceTypeType. Only >+ * ContextPath, JavaIdFactoryClass, JavaResourceClass and WsdlType fields >+ * have been copied. >+ */ >+ public static ResourceTypeType cloneResourceType(ResourceTypeType rt) >+ { >+ ResourceTypeType clone = DescriptorFactory.eINSTANCE >+ .createResourceTypeType(); >+ clone.setContextPath(rt.getContextPath()); >+ clone.setJavaIdFactoryClass(rt.getJavaIdFactoryClass()); >+ clone.setJavaResourceClass(rt.getJavaResourceClass()); >+ WsdlType wClone = DescriptorFactory.eINSTANCE.createWsdlType(); >+ wClone.setWsdlFile(rt.getWsdl().getWsdlFile()); >+ wClone.setWsdlPortType(rt.getWsdl().getWsdlPortType()); >+ clone.setWsdl(wClone); >+ return clone; >+ } >+ >+ /** >+ * This method will persist the extra artifacts generated at codegen time. >+ */ >+ public void persistArtifacts() >+ { >+ _mrtPreProcessor.persistArtifacts(); >+ persistDDFile(); >+ } >+ >+ private void persistDDFile() >+ { >+ _ddFilePath = createDDFilePath(); >+ DdeUtil.serializeDescriptorRoot(_ddRoot, URI.createPlatformResourceURI(_ddFilePath)); >+ } >+ >+ /** >+ * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given >+ * merged RMD document for it by having the rules/relationships in it. >+ */ >+ public void inspectMetadata(ManageableResourceType mrt, >+ MetadataDescriptor metadata) >+ { >+ _mrtPreProcessor.inspectMetadata(mrt, metadata); >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/NewProjectWizard.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/NewProjectWizard.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/NewProjectWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/NewProjectWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,320 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.io.File; >+import java.lang.reflect.InvocationTargetException; >+ >+import org.apache.muse.tools.generator.analyzer.Analyzer; >+import org.apache.muse.tools.generator.analyzer.SimpleAnalyzer; >+import org.apache.muse.tools.generator.projectizer.Projectizer; >+import org.apache.muse.tools.generator.synthesizer.ServerSynthesizer; >+import org.apache.muse.tools.generator.synthesizer.Synthesizer; >+import org.apache.muse.tools.generator.util.ConfigurationData; >+import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >+import org.eclipse.core.filesystem.URIUtil; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.ILog; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; >+import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.wizard.Wizard; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; >+import org.eclipse.tptp.wsdm.tooling.preferences.internal.Axis2ServerLocationPreferencePage; >+import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >+import org.eclipse.ui.INewWizard; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.part.ViewPart; >+import org.w3c.dom.Document; >+ >+/** >+ * This wizard accepts projectizer parameters, runtime environment and other >+ * general parameters from the user so as to invoke Wsdl2Java >+ */ >+public class NewProjectWizard extends Wizard implements INewWizard { >+ >+ private static ILog LOG = null; >+ >+ // We can't use internal classes, hence using view ID directly >+ private static String TASK_VIEW_ID = "org.eclipse.ui.views.TaskList"; >+ >+ private static String PLUGIN_ID = "org.eclipse.tptp.wsdm.tooling.editor.mrt"; >+ >+ private GenerationOptionsPage _generationOptionsPage; >+ >+ private String _projectName; >+ >+ private boolean _overwrite; >+ >+ private boolean _shouldPersistArtifacts; >+ >+ private Projectizer _projectizer; >+ >+ private Synthesizer _synthesizer; >+ >+ private Analyzer _analyzer; >+ >+ private String _baseAddress; >+ >+ private CodeGenerationDelegate _codeGenerationDelegate; >+ >+ private Document[] _mergedWsdlDocuments; >+ >+ private MetadataDescriptor[] _mergedRMDs; >+ >+ private DescriptorHelper _helper; >+ >+ private String _serverLocation; >+ >+ private boolean _isAxis2Project; >+ private boolean updatePreference; >+ >+ private String _projectLocation; >+ >+ private TargetedFileList[] _requiredAxis2Files; >+ >+ private boolean _licenseAccepted = false; >+ >+ /** >+ * Class that creates the Code Generation Wizard to create new Project >+ * >+ * @param codeGenerationDelegate >+ */ >+ public NewProjectWizard(CodeGenerationDelegate codeGenerationDelegate) { >+ setWindowTitle(Messages.HOOKUP_WIZARD_TXT7); >+ setNeedsProgressMonitor(true); >+ >+ _codeGenerationDelegate = codeGenerationDelegate; >+ } >+ >+ public void addPages() { >+ _generationOptionsPage = new GenerationOptionsPage(); >+ addPage(_generationOptionsPage); >+ >+ // TODO AME why is this hardcoded here? why is it getting reloaded? >+ Image imgTP = EclipseUtils.loadImage(PlatformUI.getWorkbench().getDisplay(), >+ "icons/wizban/newEndpointProject_wiz.gif"); >+ ImageDescriptor imgDescrTP = ExtendedImageRegistry.INSTANCE.getImageDescriptor(imgTP); >+ setDefaultPageImageDescriptor(imgDescrTP); >+ } >+ >+ private void popupAxis2LicenseDialog() { >+ IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); >+ String preferencesLocation = store.getString(Axis2ServerLocationPreferencePage.SERVER_LOCATION_PREFERENCE_KEY); >+ if (!_serverLocation.equals(preferencesLocation)) { >+ int result = new Axis2LicenseDialog().showWindow(); >+ _licenseAccepted = (result == Axis2LicenseDialog.AGREE); >+ } else >+ _licenseAccepted = true; >+ >+ } >+ >+ private void performFinish(IProgressMonitor monitor) throws InvocationTargetException { >+ try { >+ monitor.beginTask(Messages.CODE_GEN_START, 7); >+ >+ if (_isAxis2Project) { >+ try { >+ // Step 1: Validate the server path >+ monitor.subTask(Messages.CODE_GEN_VALIDATE_SLOCATION); >+ // Step 2 : Update the Preferences, if needed >+ if (updatePreference) { >+ IPreferenceStore store = Activator.getPlugin().getPreferenceStore(); >+ store.setValue(Axis2ServerLocationPreferencePage.SERVER_LOCATION_PREFERENCE_KEY, >+ _serverLocation); >+ // Update the Lib and module location >+ } >+ _requiredAxis2Files = _generationOptionsPage.getAxis2FilesToCopy(); >+ } catch (Exception e) { >+ throw new RuntimeException(e); >+ } >+ } >+ try { >+ monitor.subTask(Messages.CODE_GEN_STEP1); >+ _helper = _codeGenerationDelegate.run(new SubProgressMonitor(monitor, 1)); >+ >+ monitor.worked(1); >+ } catch (Exception e) { >+ throw new RuntimeException(e); >+ // TODO AME Why is this not defined? >+ // throw new InvocationTargetException(new >+ // Exception(Messages.HOOKUP_WIZARD_ERROR4, e)); >+ } >+ >+ try { >+ monitor.subTask(Messages.CODE_GEN_STEP2); >+ _mergedWsdlDocuments = _helper.getWsdlDocuments(_baseAddress); >+ _mergedRMDs = _helper.getMergedRMDs(); >+ monitor.worked(1); >+ } catch (Exception e) { >+ e.printStackTrace(); >+ throw new RuntimeException(e); >+ } >+ >+ try { >+ monitor.subTask(Messages.CODE_GEN_STEP3); >+ runProjectizer(monitor); >+ monitor.worked(1); >+ } catch (Exception e) { >+ throw new InvocationTargetException(new Exception(Messages.CODE_GEN_FAILED_ERROR_, e)); >+ } >+ >+ if (_shouldPersistArtifacts) { >+ monitor.subTask(Messages.CODE_GEN_STEP4); >+ _codeGenerationDelegate.persistArtifacts(); >+ monitor.worked(1); >+ } >+ } finally { >+ monitor.done(); >+ } >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.wizard.Wizard#performFinish() >+ */ >+ public boolean performFinish() { >+ _projectizer = _generationOptionsPage.getProjectizer(); >+ _synthesizer = _generationOptionsPage.getSynthesizer(); >+ _analyzer = _generationOptionsPage.getAnalyzer(); >+ _overwrite = _generationOptionsPage.canOverwrite(); >+ _shouldPersistArtifacts = _generationOptionsPage.shouldPersistArtifacts(); >+ _projectName = _generationOptionsPage.getProjectName(); >+ _baseAddress = _generationOptionsPage.getBaseAddress(); >+ _isAxis2Project = _generationOptionsPage.isAxis2Project(); >+ _projectName = _generationOptionsPage.getProjectName(); >+ _projectLocation = _generationOptionsPage.getProjectLocation(); >+ >+ if (_isAxis2Project) { >+ _serverLocation = _generationOptionsPage.getPreferenceServerLocation(); >+ } >+ >+ IRunnableWithProgress runnable = new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >+ performFinish(monitor); >+ } >+ }; >+ >+ _generationOptionsPage.saveCombo(); >+ >+ try { >+ getContainer().run(true, false, runnable); >+ openTasksView(); >+ >+ return true; >+ } catch (Exception e) { >+ e.printStackTrace(); >+ handle(Messages.CODE_GEN_FAILED_ERROR_, e); >+ } >+ >+ return false; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, >+ * org.eclipse.jface.viewers.IStructuredSelection) >+ */ >+ public void init(IWorkbench workbench, IStructuredSelection selection) { >+ // do nothing >+ } >+ >+ private void runProjectizer(IProgressMonitor monitor) throws Exception { >+ ConfigurationData data = new ConfigurationData(); >+ >+ data.addParameter(EclipseConfigurationData.AXIS2_FILES, _requiredAxis2Files); >+ >+ data.addParameter(ConfigurationData.DESCRIPTOR_DOCUMENT, _helper.getDescriptorDocument()); >+ data.addParameter(EclipseConfigurationData.ADDITIONAL_JARS, _helper.getJarFiles()); >+ data.addParameter(EclipseConfigurationData.INSTANCES, _helper.getInstances()); >+ data.addParameter(EclipseConfigurationData.PROJECT_NAME, _projectName); >+ data.addParameter(ConfigurationData.OVERWRITE, Boolean.valueOf(_overwrite)); >+ data.addParameter(EclipseConfigurationData.PROJECT_LOCATION, _projectLocation); >+ data.addParameter(ConfigurationData.WSDL_DOCUMENT_LIST, _mergedWsdlDocuments); >+ data.addParameter(ConfigurationData.METADATA_DESCRIPTOR_LIST, _mergedRMDs); >+ data.addParameter(ConfigurationData.GENERATE_CUSTOM_HEADERS, Boolean.FALSE); >+ >+ // check if the analyzer is null, if it is then default to the >+ // SimpleAnalyzer >+ if (_analyzer == null) { >+ _analyzer = new SimpleAnalyzer(); >+ } >+ >+ // check if the synthesizer is null, if it is then default to the >+ // ServerSynthesizer >+ if (_synthesizer == null) { >+ _synthesizer = new ServerSynthesizer(); >+ } >+ >+ // Below, we make a new SubProgressMonitor for >+ // each codegeneration component since we can't reuse the progress >+ // monitor >+ >+ data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR, new SubProgressMonitor(monitor, 1)); >+ >+ monitor.subTask(Messages.CODE_GEN_SUBTASK1); >+ data = _analyzer.analyze(data); >+ monitor.worked(1); >+ >+ data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR, new SubProgressMonitor(monitor, 1)); >+ >+ monitor.subTask(Messages.CODE_GEN_SUBTASK2); >+ data = _synthesizer.synthesize(data); >+ monitor.worked(1); >+ >+ data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR, new SubProgressMonitor(monitor, 1)); >+ >+ monitor.subTask(Messages.CODE_GEN_SUBTASK3); >+ _projectizer.projectize(data); >+ monitor.worked(1); >+ } >+ >+ private void handle(String message, Exception e) { >+ _generationOptionsPage.setErrorMessage(message); >+ WsdmToolingLog.log(IStatus.ERROR, IStatus.OK, message, e); >+ } >+ >+ private void openTasksView() { >+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); >+ ViewPart view = (ViewPart) page.findView(TASK_VIEW_ID); >+ >+ // If the page isn't showing then show it >+ if (view == null) { >+ try { >+ page.showView(TASK_VIEW_ID); >+ } catch (PartInitException e) { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ }else{ >+ page.activate(view); >+ } >+ } >+ >+ public boolean canFinish() { >+ return _generationOptionsPage.isPageComplete(); >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/ISoapServerDependency.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/ISoapServerDependency.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/ISoapServerDependency.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/ISoapServerDependency.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,44 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import org.eclipse.core.runtime.IExecutableExtension; >+ >+/** >+ * Interface to represent Soap Library dependency used in Tooling codegeneration. >+ */ >+ >+public interface ISoapServerDependency extends IExecutableExtension >+{ >+ /** >+ * Returns null if the given Server Home has all the required soap jar files. >+ */ >+ String validateSoapServerHome(String serverHome); >+ >+ /** >+ * Returns the absolute path of all the required soap jar files. >+ */ >+ TargetedFileList[] getFilesToCopy(); >+ >+ /** >+ * Returns the absolute path of the lib folder. >+ */ >+// String getServerLibLocation(String serverName); >+ >+ /** >+ * Returns the absolute path of the modules folder. >+ */ >+// String getServerModulesLocation(String serverName); >+ >+ >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/CodeGenerationDelegate.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/CodeGenerationDelegate.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/CodeGenerationDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/CodeGenerationDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Andrew Eberbach (aeberbac@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >+ >+/** >+ * This class acts as a way to capture doing WSDL resolution (which could >+ * include WSDL manipulation like merging) so that it can be done later on, or >+ * on another thread since this would be time-consuming. >+ */ >+public interface CodeGenerationDelegate >+{ >+ >+ /** >+ * Do any work related to code generation. This kind of work is passed to >+ * this delegate so that it can be run in a separate thread. This can take a >+ * (optional) progress monitor which can be used to report progress done in >+ * this task. The method returns a DescriptorHelper which aggregates all of >+ * the work that was done. >+ * >+ * @param progressMonitor >+ * A progress monitor to show the progress done during this task. >+ * >+ * @throws Exception >+ */ >+ DescriptorHelper run(SubProgressMonitor progressMonitor) throws Exception; >+ >+ /** >+ * Persist the extra artifacts generated during codegeneration such as SubscriptionManager.mrt etc. >+ */ >+ void persistArtifacts(); >+ >+ /** >+ * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given >+ * merged RMD document for it by having the rules/relationships in it. >+ */ >+ void inspectMetadata(ManageableResourceType mrt, MetadataDescriptor metadata); >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/CodeGenerationData.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/CodeGenerationData.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/CodeGenerationData.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/CodeGenerationData.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,105 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: CodeGenerationData.java,v 1.2 2007/05/07 09:15:10 dnsmith Exp $ >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import org.apache.muse.tools.generator.analyzer.Analyzer; >+import org.apache.muse.tools.generator.projectizer.Projectizer; >+import org.apache.muse.tools.generator.synthesizer.Synthesizer; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+ >+class CodeGenerationData { >+ private Analyzer _analyzer; >+ private Synthesizer _synthesizer; >+ private Projectizer _projectizer; >+ >+ private int _servicePort; >+ private String _servicePath; >+ private String _container; >+ private String _platform; >+ >+ public CodeGenerationData(IConfigurationElement[] elements) { >+ for (int i = 0; i < elements.length; i++) >+ { >+ String name = elements[i].getName(); >+ >+ if(name.equals("description")) { >+ extractDescription(elements[i]); >+ } else if (name.equals("projectizer")) { >+ extractProjectizer(elements[i]); >+ } else if (name.equals("synthesizer")) { >+ extractSynthesizer(elements[i]); >+ } else if (name.equals("analyzer")) { >+ extractAnalyzer(elements[i]); >+ } >+ } >+ } >+ >+ private void extractDescription(IConfigurationElement configurationElement) { >+ _container = configurationElement.getAttribute("container"); >+ _platform = configurationElement.getAttribute("platform"); >+ } >+ >+ private void extractProjectizer(IConfigurationElement configurationElement) { >+ String port = configurationElement.getAttribute("servicePort"); >+ if(port != null && port.length() != 0) { >+ _servicePort = Integer.parseInt(port); >+ } >+ _servicePath = configurationElement.getAttribute("servicePath"); >+ _projectizer = (Projectizer) createExecutable(configurationElement); >+ } >+ >+ private void extractSynthesizer(IConfigurationElement configurationElement) { >+ _synthesizer = (Synthesizer) createExecutable(configurationElement); >+ } >+ >+ private void extractAnalyzer(IConfigurationElement configurationElement) { >+ _analyzer = (Analyzer) createExecutable(configurationElement); >+ } >+ >+ private Object createExecutable(IConfigurationElement configurationElement) { >+ try { >+ return configurationElement.createExecutableExtension("class"); >+ } catch (CoreException e) { >+ throw new RuntimeException(configurationElement.getAttribute("class")); >+ } >+ } >+ >+ public Analyzer getAnalyzer() { >+ return _analyzer; >+ } >+ >+ public Synthesizer getSynthesizer() { >+ return _synthesizer; >+ } >+ >+ public Projectizer getProjectizer() { >+ return _projectizer; >+ } >+ >+ public int getServicePort() { >+ return _servicePort; >+ } >+ >+ public String getServicePath() { >+ return _servicePath; >+ } >+ >+ public String getContainer() { >+ return _container; >+ } >+ >+ public String getPlatform() { >+ return _platform; >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/DescriptorHelper.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/DescriptorHelper.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/DescriptorHelper.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/DescriptorHelper.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,588 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Andrew Eberbach (aeberbac@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.io.File; >+import java.io.FileInputStream; >+import java.io.IOException; >+import java.io.InputStream; >+import java.net.URL; >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.HashMap; >+import java.util.LinkedList; >+import java.util.List; >+import java.util.Map; >+ >+import javax.xml.namespace.QName; >+ >+import org.apache.muse.core.descriptor.DescriptorConstants; >+import org.apache.muse.util.xml.XmlUtils; >+import org.apache.muse.ws.addressing.WsaConstants; >+import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IWorkspace; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.FileLocator; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >+import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; >+import org.w3c.dom.NamedNodeMap; >+import org.w3c.dom.Node; >+ >+/** >+ * A class that takes some of the pain out of working with the deployment >+ * descriptor. Note, there's no EMF in this approach, just plain old XML. >+ */ >+public class DescriptorHelper >+{ >+ >+ /** >+ * File Extension of MRT files >+ */ >+ private static final String MRT_EXTN = ".mrt"; >+ >+ /** >+ * Element name constants >+ */ >+ public static final QName ADDITIONAL_JARS_QNAME = new QName( >+ DescriptorConstants.NAMESPACE_URI, "additional-jars"); >+ public static final QName JAR_PATH_QNAME = new QName( >+ DescriptorConstants.NAMESPACE_URI, "jar-path"); >+ public static final QName INITIAL_INSTANCES_QNAME = new QName( >+ DescriptorConstants.NAMESPACE_URI, "initial-instances"); >+ public static final QName REFERENCE_PARAMETERS_QNAME = new QName( >+ DescriptorConstants.NAMESPACE_URI, "referenceParameters"); >+ >+ /** >+ * Constant for empty files >+ */ >+ private static final File[] EMPTY_FILES = new File[0]; >+ >+ /** >+ * Constant for empty instances. >+ */ >+ private static final Object[][] EMPTY_INSTANCES = new Object[0][0]; >+ >+ /** >+ * Constant for the xmlns prefix on namespace binding declarations >+ */ >+ private static final Object XMLNS_PREFIX = "xmlns"; >+ >+ /** >+ * The descriptor document we pull out of the <code>Root</code> element >+ */ >+ private Document _descriptorDocument; >+ >+ /** >+ * A list of jar files that we pull out of the >+ * <code>Root/additional-jars</code> element >+ */ >+ private File[] _jarFiles; >+ >+ /** >+ * A list of instances which is really just a n by 2 list of arrays. The >+ * sub-arrays have the instance-path (<code>String</code>) as the first >+ * element and the reference parameters (<code>Element</code>) as the >+ * second element. This is tacky, but otherwise I'd be making a pretty >+ * useless "Pair" class. >+ */ >+ private Object[][] _instances; >+ >+ private IFile ddIFile; >+ >+ /** >+ * Descriptor file stores the MRT file reference in Wsdl-File element. >+ * When we do the codegeneration we generate some extra MRTs such as SubscriptionManager, >+ * so we pass the map of these MRTs to this class. >+ * Key will be the persisted location of MRT and value will be the ManageableREsourceType object. >+ */ >+ private Map _mrtObjectMap = new HashMap(); >+ >+ private CodeGenerationDelegate _codeGenerationDelegate = null; >+ >+ /** >+ * A do-something constructor. Take a file, if that file is null, then load >+ * up a default template. Otherwise load up the file and pull out the >+ * instances, descriptor and additional jars. For the null file case, there >+ * will be no instances of additional-jars, hence the constants defined >+ * above. >+ * >+ * @param file - The file to analyze, can be null. >+ * @throws Exception - If anything goes wrong. >+ */ >+ public DescriptorHelper(CodeGenerationDelegate codeGenerationDelegate, IFile descriptorFile) throws Exception >+ { >+ this(codeGenerationDelegate, new File(descriptorFile.getLocation().toString())); >+ ddIFile = descriptorFile; >+ } >+ >+ /** >+ * A do-something constructor. Take a file, if that file is null, then load >+ * up a default template. Otherwise load up the file and pull out the >+ * instances, descriptor and additional jars. For the null file case, there >+ * will be no instances of additional-jars, hence the constants defined >+ * above. >+ * >+ * @param file - The file to analyze, can be null. >+ * @throws Exception - If anything goes wrong. >+ */ >+ public DescriptorHelper(CodeGenerationDelegate codeGenerationDelegate, File file) throws Exception >+ { >+ this(codeGenerationDelegate, new FileInputStream(file), null); >+ } >+ >+ /** >+ * A do-something constructor. Take a inputstream, if that inputstream is null, then load >+ * up a default template. Otherwise load up the inputstream and pull out the >+ * instances, descriptor and additional jars. For the null inputstream case, there >+ * will be no instances of additional-jars, hence the constants defined >+ * above. >+ * >+ * @param inputstream - The inputstream to analyze, can be null. >+ * @param mrtObjectMap - The map of MRTLocation-MRTObject pair, can be null. >+ * @throws Exception - If anything goes wrong. >+ */ >+ public DescriptorHelper(CodeGenerationDelegate codeGenerationDelegate, InputStream inputStream, Map mrtObjectMap, boolean extractExtraInfo) throws Exception >+ { >+ if(mrtObjectMap!=null) >+ _mrtObjectMap = mrtObjectMap; >+ _codeGenerationDelegate = codeGenerationDelegate; >+ >+ Document rootDocument = XmlUtils.createDocument(inputStream); >+ >+ _descriptorDocument = extractDescriptorDocument(rootDocument); >+ >+ if(extractExtraInfo) { >+ _instances = extractInstances(rootDocument); >+ _jarFiles = extractJarFiles(rootDocument); >+ } else { >+ _instances = null; >+ _jarFiles = null; >+ } >+ // Add Muse tools.jar >+ if(_jarFiles == null) >+ _jarFiles = new File[0]; >+ String toolsJarLocation = getMuseToolsJarLocation(); >+ if(toolsJarLocation == null) >+ return; >+ List jars = Arrays.asList(_jarFiles); >+ List allJars = new ArrayList(); >+ allJars.addAll(jars); >+ allJars.add(new File(toolsJarLocation)); >+ _jarFiles = (File[])allJars.toArray(new File[allJars.size()]); >+ } >+ >+ public DescriptorHelper(CodeGenerationDelegate codeGenerationDelegate, InputStream inputStream, Map mrtObjectMap) throws Exception { >+ this(codeGenerationDelegate, inputStream, mrtObjectMap, true); >+ } >+ >+ /** >+ * Extract the instances from the initial-instances element. >+ * >+ * TODO this needs to be updated when the initial instances element actually >+ * works. >+ * >+ * @param rootDocument >+ * @return >+ */ >+ private Object[][] extractInstances(Document rootDocument) >+ { >+ Element[] initialInstancesElements = XmlUtils.findInSubTree( >+ rootDocument.getDocumentElement(), INITIAL_INSTANCES_QNAME); >+ if (initialInstancesElements.length == 0) >+ { >+ return EMPTY_INSTANCES; >+ } >+ >+ // sorry about this, maybe someday java will have a Pair type >+ Object[][] instances = new Object[initialInstancesElements.length][2]; >+ >+ for (int i = 0; i < initialInstancesElements.length; i++) >+ { >+ Element contextElement = XmlUtils.findFirstInSubTree( >+ initialInstancesElements[i], >+ DescriptorConstants.CONTEXT_PATH_QNAME); >+ instances[i][0] = XmlUtils.extractText(contextElement); >+ Element instancesElement = XmlUtils.findFirstInSubTree( >+ initialInstancesElements[i], REFERENCE_PARAMETERS_QNAME); >+ >+ Element referenceParametersElement = XmlUtils.createElement(WsaConstants.PARAMETERS_QNAME); >+ >+ Element[] referenceParameters = XmlUtils.getAllElements(instancesElement); >+ Document owner = referenceParametersElement.getOwnerDocument(); >+ for(int j=0; j < referenceParameters.length; j++) { >+ referenceParametersElement.appendChild(owner.importNode(referenceParameters[j], true)); >+ } >+ instances[i][1] = referenceParametersElement; >+ } >+ >+ return instances; >+ } >+ >+ /** >+ * Extract the jars from the additional jars element. Just read through each >+ * element, take the text content (which should be an absolute path) and put >+ * it into a <code>File</code> object. Returns a list of these >+ * <code>File</code>s. >+ * >+ * @param rootDocument >+ * The <code>Root</code> element-containing >+ * <code>Document</code> >+ * >+ * @return A list of <code>File</code>s for each path found under >+ * additional-jars >+ */ >+ private File[] extractJarFiles(Document rootDocument) >+ { >+ Element additionalJarsElement = XmlUtils.findFirstInSubTree( >+ rootDocument.getDocumentElement(), ADDITIONAL_JARS_QNAME); >+ if (additionalJarsElement == null) >+ { >+ return EMPTY_FILES; >+ } >+ >+ Element[] jarPaths = XmlUtils.findInSubTree(additionalJarsElement, >+ JAR_PATH_QNAME); >+ if (jarPaths.length == 0) >+ { >+ return EMPTY_FILES; >+ } >+ >+ File[] files = new File[jarPaths.length]; >+ >+ for (int i = 0; i < jarPaths.length; i++) >+ { >+ files[i] = new File(XmlUtils.extractText(jarPaths[i])); >+ } >+ return files; >+ } >+ >+ private String getMuseToolsJarLocation() >+ { >+ URL url = FileLocator.find(org.apache.muse.tools.Activator.getDefault().getBundle(), new Path("runtime/tools.jar"), null); >+ try >+ { >+ url = FileLocator.resolve(url); >+ return url.getFile(); >+ } >+ catch (IOException ioe) >+ { >+ WsdmToolingLog.logError(ioe.getMessage(), ioe); >+ } >+ return null; >+ } >+ >+ /** >+ * Get the Muse descriptor out of the document. Just looks for the >+ * <code>DescriptorConstants.MUSE_QNAME</code> QName. >+ * >+ * @param rootDocument >+ * The <code>Root</code> element-containing >+ * <code>Document</code> >+ * @return The new <code>Document</code> that has as its document element >+ * the muse descriptor >+ */ >+ private Document extractDescriptorDocument(Document rootDocument) >+ { >+ Element museElement = XmlUtils.findFirstInSubTree(rootDocument >+ .getDocumentElement(), DescriptorConstants.MUSE_QNAME); >+ Document descriptorDocument = XmlUtils.createDocument(); >+ descriptorDocument.appendChild(descriptorDocument.importNode( >+ museElement, true)); >+ >+ copyNamespacePrefixes(rootDocument.getDocumentElement(), >+ descriptorDocument.getDocumentElement()); >+ >+ museElement = XmlUtils.getElement(descriptorDocument,DescriptorConstants.MUSE_QNAME); >+ adjustCustomSerializers(museElement); >+ >+ return descriptorDocument; >+ } >+ >+ /** >+ * Given a source <code>Element</code> and a destination >+ * <code>Element</code> copy all of the namespace prefixese from the >+ * source to the destination. This is really horrid because of DOM's API >+ * being what it is and we treat the declarations as attributes. Yes, we do >+ * check to make sure we don't do double prefix declarations. >+ * >+ * TODO this should go into a namespace utility class, I've had to write >+ * this in about 3 places now. >+ * >+ * @param source >+ * The source <code>Element</code> >+ * @param destination >+ * The destination <code>Element</code> >+ */ >+ private void copyNamespacePrefixes(Element source, Element destination) >+ { >+ NamedNodeMap attributes = source.getAttributes(); >+ int size = attributes.getLength(); >+ for (int i = 0; i < size; i++) >+ { >+ Node nextAttribute = attributes.item(i); >+ String prefix = nextAttribute.getPrefix(); >+ >+ if (prefix == null || !prefix.equals(XMLNS_PREFIX)) >+ { >+ continue; >+ } >+ >+ if (destination.hasAttribute(nextAttribute.getNodeName())) >+ { >+ continue; >+ } >+ >+ destination.setAttribute(nextAttribute.getNodeName(), nextAttribute >+ .getNodeValue()); >+ } >+ } >+ >+ /** >+ * Descriptor editor stores the xsd-serializer-type for custom-serializer as >+ * >+ * <custom-serializer> >+ * <xsd-serializer-type>{http://www.eclipse.org/TP}StateType</xsd-serializer-type> >+ * <custom-serializer> >+ * >+ * We have to convert the QName to prefix:localpart format so we adjust this part as >+ * >+ * <custom-serializer> >+ * <xsd-serializer-type xmlns:pfx="http://www.eclipse.org/TP">pfx:StateType</xsd-serializer-type> >+ * <custom-serializer> >+ * >+ */ >+ private void adjustCustomSerializers(Element museElement) >+ { >+ Element[] serializerElements = XmlUtils.getElements(museElement, DescriptorConstants.CUSTOM_SERIALIZER_QNAME); >+ for(int i=0;i<serializerElements.length;i++) >+ { >+ // TODO Replace the QName with MUSE constant in MUSE 2.2 >+ Element xsdSerializerElement = XmlUtils.getElement(serializerElements[i], new QName(DescriptorConstants.NAMESPACE_URI,"xsd-serializable-type")); >+ String qNameAsString = XmlUtils.extractText(xsdSerializerElement); >+ if(qNameAsString!=null && !qNameAsString.equals("")) >+ { >+ try >+ { >+ QName qname = QName.valueOf(qNameAsString); >+ String namespace = qname.getNamespaceURI(); >+ String localPart = qname.getLocalPart(); >+ if(namespace.equals("")) >+ break; >+ xsdSerializerElement.setAttribute("pfx", namespace); >+ XmlUtils.setElementText(xsdSerializerElement, "pfx:"+localPart); >+ } >+ catch(IllegalArgumentException e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ } >+ } >+ } >+ >+ /** >+ * Returns the Descriptor document >+ * @return Document >+ */ >+ public Document getDescriptorDocument() >+ { >+ return _descriptorDocument; >+ } >+ /** >+ * Returns the Jar files >+ * @return File[] >+ */ >+ public File[] getJarFiles() >+ { >+ return _jarFiles; >+ } >+ >+ /** >+ * Returns the instances >+ * @return Object[][] >+ */ >+ public Object[][] getInstances() >+ { >+ return _instances; >+ } >+ >+ /** >+ * Go through the parsed Muse descriptor associated with this object and >+ * find all of the MRT files referenced therein. For each MRT file use >+ * <code>WsdlMerge</code> to merge the MRT's WSDL into a consolidate WSDL. >+ * Return the Muse Descriptor document-order list of the WSDL files. >+ * The passed map will contain the MRT file location as key and MRT object as value. >+ * So first search the map for MRT if not found then load the MRT from location. >+ * >+ * @return A list of merged WSDL files as gathered from the deployment >+ * descriptor >+ * >+ * @see org.eclipse.tptp.wsdm.tooling.wizard.mrt.internal.WsdlResolverDelegate#getWsdlDocuments() >+ */ >+ public Document[] getWsdlDocuments(String baseAddress) >+ { >+ Element[] resourceTypes = XmlUtils.findInSubTree(_descriptorDocument >+ .getDocumentElement(), DescriptorConstants.RESOURCE_TYPE_QNAME); >+ int mrtCount = resourceTypes.length; >+ Document[] mergedWSDLs = new Document[mrtCount]; >+ >+ for (int i = 0; i < mrtCount; i++) >+ { >+ Element wsdlFileElement = XmlUtils.findFirstInSubTree( >+ resourceTypes[i], DescriptorConstants.WSDL_FILE_QNAME); >+ >+ String wsdlPath = XmlUtils.extractText(wsdlFileElement); >+ String mrtPath = getMRTPathFromWSDLPath(wsdlPath); >+ ManageableResourceType mrt = null; >+ String serviceAddress = null; >+ if(_mrtObjectMap!=null && _mrtObjectMap.containsKey(mrtPath)) >+ { >+ mrt = (ManageableResourceType) _mrtObjectMap.get(mrtPath); >+ serviceAddress = baseAddress+"/"+mrt.getIdentifier(); >+ } >+ else >+ { >+ IWorkspace workspace = ResourcesPlugin.getWorkspace(); >+ IWorkspaceRoot root = workspace.getRoot(); >+ IPath mrtFilePath = root.findMember(mrtPath).getFullPath(); >+ URI uri = URI.createFileURI(mrtFilePath.toString()); >+ mrt = MrtUtils.loadMRT(uri); >+ serviceAddress = makeServiceAddress(baseAddress, mrtFilePath); >+ } >+ if(mrt!=null) >+ { >+ try >+ { >+ mergedWSDLs[i] = MrtMerge.createMergedWSDL(mrt, serviceAddress); >+ } >+ catch (Exception e) >+ { >+ e.printStackTrace(); >+ // TODO AME add externalized message >+ throw new RuntimeException(e); >+ } >+ } >+ else >+ { >+ // TODO AME add externalized message >+ throw new RuntimeException(); >+ } >+ } >+ return mergedWSDLs; >+ } >+ >+ /** >+ * Given a base address add the service name. This is done by getting the >+ * name of the MRT file and stripping off the file extension. >+ * >+ * @param baseAddress >+ * Base address >+ * @param file >+ * MRT file to use >+ * @return the combined address >+ */ >+ private String makeServiceAddress(String baseAddress, IPath file) >+ { >+ String fileName = file.toFile().getName(); >+ fileName = fileName.substring(0, fileName.lastIndexOf(".")); >+ return baseAddress + "/" + fileName; >+ } >+ >+ private String getMRTPathFromWSDLPath(String fileName) >+ { >+ return fileName.substring(0, fileName.lastIndexOf(".")) + MRT_EXTN; >+ } >+ >+ /** >+ * Adds the additional jar files to Descriptor file. >+ * >+ * @param serverLocation >+ * Parent directory of Axis2-lib folder. >+ * >+ * @param axis2files >+ * Axis2 jar files path. >+ */ >+ public void addAdditionalJars(String serverLocation, String[] axis2files) >+ { >+ List additionalJarFiles = new LinkedList(); >+ if(_jarFiles!=null) >+ additionalJarFiles.addAll(Arrays.asList(_jarFiles)); >+ for(int i = 0 ; i < axis2files.length ; i++ ) >+ additionalJarFiles.add(new File(serverLocation + File.separator + axis2files[i])); >+ _jarFiles = (File[]) additionalJarFiles.toArray(new File[additionalJarFiles.size()]); >+ } >+ >+ /** >+ * Go through the parsed Muse descriptor associated with this object and >+ * find all of the MRT files referenced therein. For each MRT file create >+ * a merged RMD document. >+ * >+ * @return A list of merged RMD documents as gathered from the deployment >+ * descriptor >+ * >+ */ >+ public MetadataDescriptor[] getMergedRMDs() >+ { >+ Element[] resourceTypes = XmlUtils.findInSubTree(_descriptorDocument >+ .getDocumentElement(), DescriptorConstants.RESOURCE_TYPE_QNAME); >+ int mrtCount = resourceTypes.length; >+ MetadataDescriptor[] mergedRMDs = new MetadataDescriptor[mrtCount]; >+ >+ for (int i = 0; i < mrtCount; i++) >+ { >+ Element wsdlFileElement = XmlUtils.findFirstInSubTree( >+ resourceTypes[i], DescriptorConstants.WSDL_FILE_QNAME); >+ >+ String wsdlPath = XmlUtils.extractText(wsdlFileElement); >+ String mrtPath = getMRTPathFromWSDLPath(wsdlPath); >+ ManageableResourceType mrt = null; >+ String serviceAddress = null; >+ if(_mrtObjectMap!=null && _mrtObjectMap.containsKey(mrtPath)) >+ { >+ mrt = (ManageableResourceType) _mrtObjectMap.get(mrtPath); >+ } >+ else >+ { >+ IWorkspace workspace = ResourcesPlugin.getWorkspace(); >+ IWorkspaceRoot root = workspace.getRoot(); >+ IPath mrtFilePath = root.findMember(mrtPath).getFullPath(); >+ URI uri = URI.createFileURI(mrtFilePath.toString()); >+ mrt = MrtUtils.loadMRT(uri); >+ } >+ if(mrt!=null) >+ { >+ try >+ { >+ mergedRMDs[i] = MrtMerge.createMergedRMD(mrt); >+ _codeGenerationDelegate.inspectMetadata(mrt, mergedRMDs[i]); >+ } >+ catch (Exception e) >+ { >+ throw new RuntimeException(e); >+ } >+ } >+ else >+ { >+ throw new RuntimeException(); >+ } >+ } >+ return mergedRMDs; >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/EclipseEnvironment.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/EclipseEnvironment.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/EclipseEnvironment.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/EclipseEnvironment.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,131 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal; >+ >+import java.io.File; >+import java.io.InputStream; >+import java.net.URI; >+import java.net.URL; >+import java.net.URLConnection; >+ >+import org.apache.muse.core.AbstractEnvironment; >+import org.apache.muse.util.xml.XmlUtils; >+import org.apache.muse.ws.addressing.EndpointReference; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.FileLocator; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >+import org.osgi.framework.Bundle; >+import org.w3c.dom.Document; >+ >+public class EclipseEnvironment extends AbstractEnvironment >+{ >+ >+ public EndpointReference getDeploymentEPR() >+ { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public File getRealDirectory() >+ { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public Document getDocument(String path) >+ { >+ try >+ { >+ if(isHttpScheme(path)) >+ { >+ URLConnection conn = new URL(path).openConnection(); >+ InputStream stream = conn.getInputStream(); >+ return XmlUtils.createDocument(stream); >+ } >+ } >+ catch(Exception e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ >+ >+ try >+ { >+ if (!isBuiltin(path)) >+ { >+ IFile wsdlFile = EclipseUtils.getIFile(ResourcesPlugin >+ .getWorkspace().getRoot(), path); >+ return XmlUtils.createDocument(wsdlFile.getLocation().toFile() >+ .getAbsoluteFile()); >+ } >+ else >+ { >+ String substr = path.substring(path.indexOf("platform:/plugin/")+"platform:/plugin/".length()); >+ String contributorPlugin = substr.substring(0,substr.indexOf('/')); >+ String relativePath = substr.substring(substr.indexOf('/')+1); >+ >+ Bundle bundle = Platform.getBundle(contributorPlugin); >+ return XmlUtils.createDocument(FileLocator.openStream(bundle, >+ new Path(relativePath), false)); >+ } >+ } >+ catch (Exception e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ return null; >+ } >+ >+ /** >+ * Utility method to see if the path is referring to something in the >+ * plugins or in the workspace. >+ * >+ * @param path >+ * A path to examine >+ * @return true if the path starts with <code>"platform:/plugin"</code> >+ */ >+ private boolean isBuiltin(String path) >+ { >+ return path.startsWith("platform:/plugin"); >+ } >+ >+ private boolean isHttpScheme(String path) >+ { >+ try{ >+ URI uri = URI.create(path); >+ String scheme = uri.getScheme(); >+ if(scheme != null && uri.getScheme().equals("http")) >+ return true; >+ }catch(Exception e){ >+ // nuthing to do, just return false >+ } >+ return false; >+ } >+ >+ public String createRelativePath(String original, String relative) >+ { >+ >+ // If the relative path starts with "platform:/" then it >+ // is an absolute path, so just return it instead. >+ if (relative.startsWith("platform:/")) >+ { >+ return relative; >+ } >+ >+ return super.createRelativePath(original, relative); >+ } >+} >#P org.eclipse.tptp.wsdm.tooling.codegeneration >Index: src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseProxyProjectizer.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.codegeneration/src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseProxyProjectizer.java,v >retrieving revision 1.8 >diff -u -r1.8 EclipseProxyProjectizer.java >--- src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseProxyProjectizer.java 25 Apr 2007 18:35:55 -0000 1.8 >+++ src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseProxyProjectizer.java 29 May 2007 23:40:31 -0000 >@@ -22,7 +22,7 @@ > import org.apache.muse.util.FileUtils; > import org.eclipse.core.runtime.FileLocator; > import org.eclipse.core.runtime.Platform; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.EclipseConfigurationData; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.EclipseConfigurationData; > import org.eclipse.tptp.wsdm.tooling.internal.util.JavaProjectHelper; > > >Index: src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseOsgiMiniProjectizer.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseOsgiMiniProjectizer.java >diff -N src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseOsgiMiniProjectizer.java >--- src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseOsgiMiniProjectizer.java 7 May 2007 09:15:19 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,19 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: EclipseOsgiMiniProjectizer.java,v 1.2 2007/05/07 09:15:19 dnsmith Exp $ >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.tptp.wsdm.tooling.internal.projectizer; >- >-import org.apache.muse.tools.generator.projectizer.OsgiMiniProjectizer; >- >-public class EclipseOsgiMiniProjectizer extends OsgiMiniProjectizer { >- >-} >Index: src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseOsgiProjectizer.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.codegeneration/src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseOsgiProjectizer.java,v >retrieving revision 1.17 >diff -u -r1.17 EclipseOsgiProjectizer.java >--- src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseOsgiProjectizer.java 25 Apr 2007 18:35:55 -0000 1.17 >+++ src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseOsgiProjectizer.java 29 May 2007 23:40:31 -0000 >@@ -29,7 +29,7 @@ > import org.apache.muse.util.FileUtils; > import org.apache.muse.ws.resource.metadata.MetadataDescriptor; > import org.apache.muse.ws.wsdl.WsdlUtils; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.EclipseConfigurationData; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.EclipseConfigurationData; > import org.eclipse.tptp.wsdm.tooling.internal.util.PluginProjectHelper; > import org.w3c.dom.Document; > import org.w3c.dom.Element; >@@ -49,8 +49,6 @@ > private File[] _additionalJars; > private Object[][] _instances; > >- private int _resourceCounter = 0; >- > private String _projectLocation; > > private String _projectName; >@@ -60,21 +58,26 @@ > > loadParameters(data); > >- PluginProjectHelper helper = createProject(_projectLocation, _projectName); >- >+ PluginProjectHelper helper = createProject(_projectLocation, _projectName); > _targetDirectory = helper.getProjectDirectory(); >- >- File descriptorFile = new File(_targetDirectory, EclipseOsgiProjectizerConstants.MUSE_DESCRIPTOR_FILE); >- >+ > File javaSourceDir = new File(_targetDirectory, OsgiProjectizerConstants.JAVA_SRC_DIR); >+ > createJavaSources(javaSourceDir, _filesMaps); >- >- File wsdldir = new File(_targetDirectory, OsgiProjectizerConstants.WSDL_DIR); >- >+ createArtifacts(javaSourceDir); >+ >+ helper.refreshProject(); >+ } >+ >+ protected void createArtifacts(File javaSourceDir) throws Exception { > createActivatorFile(javaSourceDir, EclipseOsgiProjectizerConstants.ACTIVATOR_FILE_RESOURCE); > > File routerEntriesDir = new File(_targetDirectory,OsgiProjectizerConstants.ROUTER_ENTRIES_DIR); > >+ File descriptorFile = new File(_targetDirectory, EclipseOsgiProjectizerConstants.MUSE_DESCRIPTOR_FILE); >+ >+ File wsdldir = new File(_targetDirectory, OsgiProjectizerConstants.WSDL_DIR); >+ > createManifest(_targetDirectory, EclipseOsgiProjectizerConstants.OSGI_MANIFEST_FILE_RESOURCE, EclipseOsgiProjectizerConstants.OSGI_MANIFEST_FILE); > > for(int i=0; i < _capabilitiesList.length; i++) { >@@ -94,17 +97,21 @@ > } > > createBuildProperties(_targetDirectory, EclipseOsgiProjectizerConstants.BUILD_PROPERTIES_FILE_RESOURCE, EclipseOsgiProjectizerConstants.BUILD_PROPERTIES_FILE); >- >- helper.refreshProject(); >+ } >+ >+ protected void loadParameters(ConfigurationData data) { >+ super.loadParameters(data); >+ _additionalJars = (File[])data.getParameter(EclipseConfigurationData.ADDITIONAL_JARS); >+ _instances = (Object[][])data.getParameter(EclipseConfigurationData.INSTANCES); >+ _projectName = (String)data.getParameter(EclipseConfigurationData.PROJECT_NAME); >+ _projectLocation = (String)data.getParameter(EclipseConfigurationData.PROJECT_LOCATION); > } > > protected void createRouterEntries(File routerEntriesDir, Object[][] instances) > throws Exception { >- >- routerEntriesDir.mkdirs(); >- >- for(int i=0; i < _instances.length; i++) { >- Object[] instancePair = _instances[i]; >+ >+ for(int i=0; i < instances.length; i++) { >+ Object[] instancePair = instances[i]; > > // > //This is really tacky, but it's the only real way to do this >@@ -117,22 +124,21 @@ > Element instanceElement = (Element) instancePair[1]; > > File serviceDir = new File(routerEntriesDir, resourcePathName); >- File routerEntryFile = new File(serviceDir, getResourceFileName()); >+ File routerEntryFile = new File(serviceDir, getResourceFileName(i)); > > writeToFileCheck(instanceElement, routerEntryFile); > } > } > >- protected String getResourceFileName() { >- return Axis2ProjectizerConstants.RESOURCE_FILE.replaceFirst(PLACE_HOLDER, String.valueOf(_resourceCounter++)); >- } >- >- protected void loadParameters(ConfigurationData data) { >- super.loadParameters(data); >- _additionalJars = (File[])data.getParameter(EclipseConfigurationData.ADDITIONAL_JARS); >- _instances = (Object[][])data.getParameter(EclipseConfigurationData.INSTANCES); >- _projectName = (String)data.getParameter(EclipseConfigurationData.PROJECT_NAME); >- _projectLocation = (String)data.getParameter(EclipseConfigurationData.PROJECT_LOCATION); >+ /** >+ * Get the name of a resource-instance file with the appropriate counter. This is >+ * really just a string-replace of the PLACE_HOLDER value with the given counter >+ * >+ * @param counter The number to use in the string replace >+ * @return The string with PLACE_HOLDER replaced by the string value of counter >+ */ >+ protected String getResourceFileName(int counter) { >+ return Axis2ProjectizerConstants.RESOURCE_FILE.replaceFirst(PLACE_HOLDER, String.valueOf(counter)); > } > > protected void createManifest(File baseTargetDir, String manifestFileResource, String manifestFileName) throws Exception { >@@ -140,7 +146,7 @@ > > String packageName = getSymbolicName().toString(); > >- Object[] filler = { getSymbolicName(), packageName + "." + EclipseOsgiProjectizerConstants.ACTIVATOR_CLASSNAME, getSymbolicName()}; >+ Object[] filler = { getSymbolicName(), makeActivatorName(packageName), getSymbolicName()}; > String newManifest = loadString(manifestTemplateIS, filler); > > newManifest = addAdditionalJars(newManifest); >@@ -149,6 +155,10 @@ > writeToFileCheck(newManifest, manifestFile); > } > >+ protected String makeActivatorName(String packageName) { >+ return packageName + "." + EclipseOsgiProjectizerConstants.ACTIVATOR_CLASSNAME; >+ } >+ > private String addAdditionalJars(String newManifest) throws IOException { > ByteArrayInputStream bais = new ByteArrayInputStream(newManifest.getBytes()); > Manifest manifest = null; >Index: src/org/eclipse/tptp/wsdm/tooling/internal/util/JavaProjectHelper.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.codegeneration/src/org/eclipse/tptp/wsdm/tooling/internal/util/JavaProjectHelper.java,v >retrieving revision 1.4 >diff -u -r1.4 JavaProjectHelper.java >--- src/org/eclipse/tptp/wsdm/tooling/internal/util/JavaProjectHelper.java 25 Apr 2007 18:35:55 -0000 1.4 >+++ src/org/eclipse/tptp/wsdm/tooling/internal/util/JavaProjectHelper.java 29 May 2007 23:40:31 -0000 >@@ -25,19 +25,24 @@ > import org.eclipse.jdt.core.JavaCore; > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.launching.JavaRuntime; >-import org.eclipse.tptp.wsdm.tooling.provisional.util.ProjectHelper; > > public class JavaProjectHelper extends ProjectHelper { > > IProject _project = null; > >- public JavaProjectHelper(String location, String projectName) throws Exception { >- _project = getProject(location, projectName); >- addNature(JavaCore.NATURE_ID); >+ public JavaProjectHelper(String location, String projectName, String natureId) throws Exception { >+ if(natureId == null) { >+ natureId = JavaCore.NATURE_ID; >+ } >+ _project = getProject(location, projectName, natureId, true); > initializeClasspath(); > } >+ >+ public JavaProjectHelper(String location, String projectName) throws Exception { >+ this(location, projectName, JavaCore.NATURE_ID); >+ } > >- private void initializeClasspath() throws JavaModelException { >+ protected void initializeClasspath() throws JavaModelException { > IJavaProject javaProj = JavaCore.create(_project); > javaProj.setRawClasspath(new IClasspathEntry[] {}, null); > addClasspathEntry(JavaRuntime.getDefaultJREContainerEntry()); >Index: src/org/eclipse/tptp/wsdm/tooling/internal/util/PluginProjectHelper.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.codegeneration/src/org/eclipse/tptp/wsdm/tooling/internal/util/PluginProjectHelper.java,v >retrieving revision 1.3 >diff -u -r1.3 PluginProjectHelper.java >--- src/org/eclipse/tptp/wsdm/tooling/internal/util/PluginProjectHelper.java 26 Apr 2007 22:18:08 -0000 1.3 >+++ src/org/eclipse/tptp/wsdm/tooling/internal/util/PluginProjectHelper.java 29 May 2007 23:40:31 -0000 >@@ -21,8 +21,8 @@ > private static final String PLUGIN_NATURE = "org.eclipse.pde.PluginNature"; //$NON-NLS-1$ > > public PluginProjectHelper(String projectLocation, String projectName) throws Exception { >- super(projectLocation, projectName); >- addNature(PLUGIN_NATURE); >+ super(projectLocation, projectName, JavaCore.NATURE_ID); >+ initializeClasspath(); > IClasspathEntry cpe = JavaCore.newContainerEntry(Path.fromOSString("org.eclipse.pde.core.requiredPlugins")); //$NON-NLS-1$ > addClasspathEntry(cpe); > } >Index: src/org/eclipse/tptp/wsdm/tooling/provisional/util/ProjectHelper.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/provisional/util/ProjectHelper.java >diff -N src/org/eclipse/tptp/wsdm/tooling/provisional/util/ProjectHelper.java >--- src/org/eclipse/tptp/wsdm/tooling/provisional/util/ProjectHelper.java 25 Apr 2007 18:35:55 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,76 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.provisional.util; >- >-import java.net.URI; >- >-import org.eclipse.core.filesystem.URIUtil; >-import org.eclipse.core.resources.ICommand; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IProjectDescription; >-import org.eclipse.core.resources.IWorkspace; >-import org.eclipse.core.resources.IWorkspaceRoot; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.CoreException; >- >-public abstract class ProjectHelper { >- >- protected IProject getProject(String location, String name) throws CoreException { >- IWorkspace workspace = ResourcesPlugin.getWorkspace(); >- IWorkspaceRoot root = workspace.getRoot(); >- >- IProjectDescription desc= workspace.newProjectDescription(name); >- >- URI projectURI = location==null?null:URIUtil.toURI(location); >- desc.setLocationURI(projectURI); >- >- IProject project = root.getProject(name); >- >- if(project != null) { >- project.create(desc, null); >- project.open(null); >- } >- >- return project; >- } >- >- public void addNature(String natureId) throws CoreException { >- IProject project = getProject(); >- IProjectDescription description = project.getDescription(); >- String[] natures = description.getNatureIds(); >- String[] newNatures = new String[natures.length + 1]; >- System.arraycopy(natures, 0, newNatures, 0, natures.length); >- newNatures[natures.length] = natureId; >- description.setNatureIds(newNatures); >- project.setDescription(description, null); >- } >- >- public void refreshProject() throws Exception { >- getProject().refreshLocal(IFile.DEPTH_INFINITE, null); >- } >- >- public void addBuilder(String builder) throws CoreException { >- IProjectDescription desc = getProject().getDescription(); >- ICommand command = desc.newCommand(); >- command.setBuilderName(builder); >- ICommand[] commands = desc.getBuildSpec(); >- ICommand[] nc = new ICommand[commands.length + 1]; >- System.arraycopy(commands, 0, nc, 0, commands.length); >- nc[commands.length] = command; >- desc.setBuildSpec(nc); >- getProject().setDescription(desc, null); >- } >- >- public abstract IProject getProject(); >-} >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.codegeneration/plugin.xml,v >retrieving revision 1.10 >diff -u -r1.10 plugin.xml >--- plugin.xml 1 May 2007 16:40:31 -0000 1.10 >+++ plugin.xml 29 May 2007 23:40:31 -0000 >@@ -24,4 +24,17 @@ > servicePath="/" > servicePort="80"/> > </extension> >+ <extension >+ point="org.eclipse.tptp.wsdm.editor.codeGeneration"> >+ <description >+ container="Mini" >+ platform="OSGi"> >+ </description> >+ <projectizer >+ class="org.eclipse.tptp.wsdm.tooling.internal.projectizer.EclipseOsgiProjectizer" >+ name="OSGi mini" >+ servicePath="/" >+ servicePort="80"> >+ </projectizer> >+ </extension> > </plugin> >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.codegeneration/META-INF/MANIFEST.MF,v >retrieving revision 1.16 >diff -u -r1.16 MANIFEST.MF >--- META-INF/MANIFEST.MF 25 Apr 2007 18:35:55 -0000 1.16 >+++ META-INF/MANIFEST.MF 29 May 2007 23:40:31 -0000 >@@ -21,4 +21,4 @@ > Bundle-ClassPath: .,runtime/code-generation.jar > Bundle-Vendor: %plugin.provider > Bundle-RequiredExecutionEnvironment: J2SE-1.4 >-Export-Package: org.eclipse.tptp.wsdm.tooling.provisional.util >+Export-Package: org.eclipse.tptp.wsdm.tooling.internal.util;x-friends:="org.eclipse.tptp.wsdm.tooling.codegeneration.j2ee" >Index: src/org/eclipse/tptp/wsdm/tooling/internal/util/ProgressMonitorHelper.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/internal/util/ProgressMonitorHelper.java >diff -N src/org/eclipse/tptp/wsdm/tooling/internal/util/ProgressMonitorHelper.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/internal/util/ProgressMonitorHelper.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,34 @@ >+package org.eclipse.tptp.wsdm.tooling.internal.util; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+ >+public class ProgressMonitorHelper { >+ >+ private IProgressMonitor _monitor; >+ >+ public ProgressMonitorHelper(IProgressMonitor monitor) { >+ _monitor = monitor; >+ } >+ >+ public void finishProgressMonitor() { >+ if (_monitor != null) { >+ _monitor.done(); >+ } >+ } >+ >+ public void recordProgress(int i) { >+ if (_monitor != null) { >+ _monitor.worked(1); >+ } >+ } >+ >+ public void startProgressMonitor(int i) { >+ if(_monitor != null) { >+ _monitor.beginTask("Running Projectizer", i); >+ } >+ } >+ >+ public void recordProgress() { >+ recordProgress(1); >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/internal/util/ProjectHelper.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/internal/util/ProjectHelper.java >diff -N src/org/eclipse/tptp/wsdm/tooling/internal/util/ProjectHelper.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/internal/util/ProjectHelper.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,83 @@ >+/******************************************************************************* >+ * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.internal.util; >+ >+import java.io.File; >+import java.net.URI; >+import java.net.URL; >+ >+import org.eclipse.core.filesystem.URIUtil; >+import org.eclipse.core.resources.ICommand; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IProjectDescription; >+import org.eclipse.core.resources.IWorkspace; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+ >+public abstract class ProjectHelper { >+ >+ protected IProject getProject(String location, String name, String natureId, boolean create) throws CoreException { >+ IWorkspace workspace = ResourcesPlugin.getWorkspace(); >+ IWorkspaceRoot root = workspace.getRoot(); >+ >+ IProjectDescription desc= workspace.newProjectDescription(name); >+ >+ URI projectURI = location==null?null:URIUtil.toURI(location); >+ desc.setLocationURI(projectURI); >+ >+ if(natureId != null) { >+ addNature(natureId, desc); >+ } >+ >+ IProject project = root.getProject(name); >+ >+ if(create && project != null) { >+ project.create(desc, null); >+ project.open(null); >+ } >+ >+ return project; >+ } >+ >+ private void addNature(String natureId, IProjectDescription description) throws CoreException { >+ String[] natures = description.getNatureIds(); >+ String[] newNatures = new String[natures.length + 1]; >+ System.arraycopy(natures, 0, newNatures, 0, natures.length); >+ newNatures[natures.length] = natureId; >+ description.setNatureIds(newNatures); >+ } >+ >+ public void refreshProject() throws Exception { >+ getProject().refreshLocal(IFile.DEPTH_INFINITE, null); >+ } >+ >+ public void addBuilder(String builder) throws CoreException { >+ IProjectDescription desc = getProject().getDescription(); >+ ICommand command = desc.newCommand(); >+ command.setBuilderName(builder); >+ ICommand[] commands = desc.getBuildSpec(); >+ ICommand[] nc = new ICommand[commands.length + 1]; >+ System.arraycopy(commands, 0, nc, 0, commands.length); >+ nc[commands.length] = command; >+ desc.setBuildSpec(nc); >+ getProject().setDescription(desc, null); >+ } >+ >+ public static File toFile(URL url) { >+ return new File(url.getFile()); >+ } >+ >+ public abstract IProject getProject(); >+} >#P org.eclipse.tptp.wsdm.tooling.codegeneration.j2ee >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.codegeneration.j2ee/plugin.xml,v >retrieving revision 1.2 >diff -u -r1.2 plugin.xml >--- plugin.xml 1 May 2007 16:40:37 -0000 1.2 >+++ plugin.xml 29 May 2007 23:40:32 -0000 >@@ -7,7 +7,7 @@ > container="Axis2" > platform="J2EE"/> > <projectizer >- class="org.eclipse.tptp.wsdm.tooling.internal.projectizer.EclipseAxis2Projectizer" >+ class="org.eclipse.tptp.wsdm.tooling.internal.projectizer.EclipseJ2EEAxis2Projectizer" > name="Axis2 J2EE" > servicePath="/services" > servicePort="8080"/> >@@ -16,4 +16,16 @@ > point="org.eclipse.ui.startup"> > <startup class="org.eclipse.tptp.wsdm.tooling.internal.codegeneration.Activator"/> > </extension> >+ <extension >+ point="org.eclipse.tptp.wsdm.editor.codeGeneration"> >+ <description >+ container="Mini" >+ platform="J2EE"> >+ </description> >+ <projectizer >+ class="org.eclipse.tptp.wsdm.tooling.internal.projectizer.EclipseJ2EEMiniProjectizer" >+ name="J2EE Mini" >+ servicePort="8080"> >+ </projectizer> >+ </extension> > </plugin> >Index: src/org/eclipse/tptp/wsdm/tooling/internal/util/WebProjectHelper.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.codegeneration.j2ee/src/org/eclipse/tptp/wsdm/tooling/internal/util/WebProjectHelper.java,v >retrieving revision 1.2 >diff -u -r1.2 WebProjectHelper.java >--- src/org/eclipse/tptp/wsdm/tooling/internal/util/WebProjectHelper.java 25 Apr 2007 18:35:58 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/internal/util/WebProjectHelper.java 29 May 2007 23:40:32 -0000 >@@ -14,20 +14,12 @@ > > > import java.io.File; >-import java.net.URI; > >-import org.eclipse.core.filesystem.URIUtil; > import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.IWorkspaceRoot; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.NullProgressMonitor; >-import org.eclipse.core.runtime.Path; > import org.eclipse.jst.common.project.facet.IJavaFacetInstallDataModelProperties; > import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants; > import org.eclipse.jst.j2ee.web.project.facet.IWebFacetInstallDataModelProperties; >-import org.eclipse.tptp.wsdm.tooling.provisional.util.ProjectHelper; > import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; > import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; > import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap; >@@ -40,7 +32,7 @@ > private IProject _project; > > public WebProjectHelper(String name, String location, String binDir, String sourceDir) throws Exception { >- _project = getProject(location, name); >+ _project = getProject(location, name, null, false); > > IDataModel dataModel = DataModelFactory.createDataModel(IWebFacetInstallDataModelProperties.class); > dataModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, name); >@@ -61,7 +53,7 @@ > return _project; > } > >- public void setSuspendValidation(boolean shouldSuspend) { >+ public void setSuspendValidation(boolean shouldSuspend) { > ValidatorManager.getManager().suspendValidation(getProject(), shouldSuspend); > } > >Index: src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseAxis2Projectizer.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseAxis2Projectizer.java >diff -N src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseAxis2Projectizer.java >--- src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseAxis2Projectizer.java 25 Apr 2007 18:35:59 -0000 1.6 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,272 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.internal.projectizer; >- >- >-import java.io.File; >-import java.io.FileNotFoundException; >-import java.net.URL; >-import java.util.Map; >- >-import org.apache.muse.tools.generator.projectizer.Axis2ProjectizerConstants; >-import org.apache.muse.tools.generator.projectizer.J2EEAxis2Projectizer; >-import org.apache.muse.tools.generator.util.ConfigurationData; >-import org.apache.muse.tools.generator.util.ServicesDescriptorHelper; >-import org.apache.muse.util.FileUtils; >-import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >-import org.apache.muse.ws.wsdl.WsdlUtils; >-import org.eclipse.core.runtime.FileLocator; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.EclipseConfigurationData; >-import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.TargetedFileList; >-import org.eclipse.tptp.wsdm.tooling.internal.codegeneration.Activator; >-import org.eclipse.tptp.wsdm.tooling.internal.util.WebProjectHelper; >-import org.w3c.dom.Document; >-import org.w3c.dom.Element; >- >-/** >- * Construct the projectizer for code generation >- */ >-public class EclipseAxis2Projectizer extends J2EEAxis2Projectizer { >- >- private static final String[] LIB_BUNDLE_IDS = { >- "org.apache.muse.api", //$NON-NLS-1$ >- "org.apache.muse.impl", //$NON-NLS-1$ >- "org.apache.muse.core", //$NON-NLS-1$ >- "org.apache.muse.tools", //$NON-NLS-1$ >- "org.apache.muse.utils" //$NON-NLS-1$ >- }; >- >- private static final String[] MODULE_BUNDLE_IDS = { >- "org.apache.muse.tools", //$NON-NLS-1$ >- }; >- >- private File[] _additionalJars; >- private Object[][] _instances; >- private IProgressMonitor _progressMonitor; >- private TargetedFileList[] _filesToCopy; >- >- private int _resourceCounter = 0; >- >- private String _projectName; >- >- private String _projectLocation; >- >- public void projectize(ConfigurationData configuration) throws Exception { >- >- ConfigurationData.checkConfiguration(this, configuration); >- >- try { >- >- loadParameters(configuration); >- >- startProgressMonitor(_progressMonitor, 10); >- >- WebProjectHelper helper = createProject(); >- >- _targetDirectory = helper.getProjectDirectory(); >- >- recordProgress(_progressMonitor, 1); >- >- helper.setSuspendValidation(true); >- >- File webContentDir = copyTemplate(_targetDirectory); >- recordProgress(_progressMonitor, 1); >- >- File descriptorFile = new File( >- webContentDir, >- Axis2ProjectizerConstants.DESCRIPTOR_FILE); >- >- File javaSourceDir = new File( >- _targetDirectory, >- Axis2ProjectizerConstants.JAVA_SRC_DIR); >- >- createJavaSources(javaSourceDir, _filesMaps); >- recordProgress(_progressMonitor, 1); >- >- File wsdldir = new File( >- webContentDir, >- Axis2ProjectizerConstants.WSDL_DIR); >- >- File routerEntriesDir = new File(webContentDir,Axis2ProjectizerConstants.ROUTER_ENTRIES_DIR); >- >- ServicesDescriptorHelper servicesHelper = new ServicesDescriptorHelper(); >- >- createBuildFile(_targetDirectory, EclipseAxis2ProjectizerConstants.BUILD_FILE_RESOURCE, EclipseAxis2ProjectizerConstants.BUILD_FILE); >- recordProgress(_progressMonitor, 1); >- >- for(int i=0; i < _capabilitiesList.length; i++) { >- Map capabilities = _capabilitiesList[i]; >- Document wsdl = _wsdls[i]; >- createDescriptor(_descriptor, wsdl, descriptorFile, capabilities, Axis2ProjectizerConstants.WSDL_RELATIVE_PATH, i); >- MetadataDescriptor rmd = _metadatas[i]; >- createRMDFile(rmd, wsdl, wsdldir); >- createWSDLFile(wsdl, wsdldir); >- if(_instances == null) { >- createRouterEntries(routerEntriesDir, WsdlUtils.getServiceName(wsdl.getDocumentElement()), _capabilitiesList[i]); >- } >- updateServicesDescriptor(servicesHelper, wsdl, capabilities); >- } >- >- if(_instances != null) { >- createRouterEntries(routerEntriesDir, _instances); >- } >- recordProgress(_progressMonitor, 4); >- >- File servicesFile = new File(webContentDir, Axis2ProjectizerConstants.SERVICES_FILE); >- createServicesDescriptor(servicesHelper, servicesFile); >- recordProgress(_progressMonitor, 1); >- >- helper.refreshProject(); >- recordProgress(_progressMonitor, 1); >- >- helper.setSuspendValidation(false); >- } finally { >- finishProgressMonitor(_progressMonitor); >- } >- } >- >- private void finishProgressMonitor(IProgressMonitor monitor) { >- if(monitor != null) { >- monitor.done(); >- } >- } >- >- private void recordProgress(IProgressMonitor monitor, int i) { >- if(monitor != null) { >- monitor.worked(1); >- } >- } >- >- private void startProgressMonitor(IProgressMonitor monitor, int i) { >- if(monitor != null) { >- monitor.beginTask("Running Projectizer", 9); >- } >- } >- >- protected void loadParameters(ConfigurationData data) { >- super.loadParameters(data); >- >- _additionalJars = (File[])data.getParameter(EclipseConfigurationData.ADDITIONAL_JARS); >- _instances = (Object[][])data.getParameter(EclipseConfigurationData.INSTANCES); >- _progressMonitor = (IProgressMonitor)data.getParameter(EclipseConfigurationData.PROGRESS_MONITOR); >- _filesToCopy = (TargetedFileList[])data.getParameter(EclipseConfigurationData.AXIS2_FILES); >- _projectName = (String)data.getParameter(EclipseConfigurationData.PROJECT_NAME); >- _projectLocation = (String)data.getParameter(EclipseConfigurationData.PROJECT_LOCATION); >- } >- >- private WebProjectHelper createProject() throws Exception { >- WebProjectHelper helper = new WebProjectHelper(_projectName, _projectLocation, EclipseAxis2ProjectizerConstants.JAVA_BIN_DIR, Axis2ProjectizerConstants.JAVA_SRC_DIR); >- >- return helper; >- } >- >- protected void createRouterEntries(File routerEntriesDir,Object[][] instances) throws Exception { >- routerEntriesDir.mkdirs(); >- >- for (int i = 0; i < _instances.length; i++) { >- Object[] instancePair = _instances[i]; >- >- // >- // This is really tacky, but it's the only real way to do this >- // since there are no pairs. The File use is to get the last element >- // of the path in a nice, non-hack way. >- // >- String path = (String) instancePair[0]; >- String resourcePathName = new File(path).getName(); >- >- Element instanceElement = (Element) instancePair[1]; >- >- File serviceDir = new File(routerEntriesDir, resourcePathName); >- File routerEntryFile = new File(serviceDir, getResourceFileName()); >- >- writeToFileCheck(instanceElement, routerEntryFile); >- } >- } >- >- protected String getResourceFileName() { >- return Axis2ProjectizerConstants.RESOURCE_FILE.replaceFirst(PLACE_HOLDER, String.valueOf(_resourceCounter++)); >- } >- >- protected File copyTemplate(File destination) throws Exception { >- URL url = Platform.getBundle(Activator.PLUGIN_ID).getEntry(EclipseAxis2ProjectizerConstants.WEBCONTENT_DIR_RESOURCE); >- url = FileLocator.toFileURL(url); >- >- File source = toFile(url); >- FileUtils.copyDirectory(source, destination); >- >- File webContentDir = new File(destination, source.getName()); >- File webContentDestination = new File(webContentDir, "WEB-INF"); //$NON-NLS-1$ >- >- for (int i=0; i < LIB_BUNDLE_IDS.length; i++) { >- url = Platform.getBundle(LIB_BUNDLE_IDS[i]).getEntry(EclipseAxis2ProjectizerConstants.PROJECT_LIB_DIR_RESOURCE); >- url = FileLocator.toFileURL(url); >- >- File libSource = toFile(url); >- FileUtils.copyDirectory(libSource, webContentDestination); >- } >- >- for (int i=0; i < MODULE_BUNDLE_IDS.length; i++) { >- url = Platform.getBundle(MODULE_BUNDLE_IDS[i]).getEntry(EclipseAxis2ProjectizerConstants.PROJECT_MODULE_DIR_RESOURCE); >- url = FileLocator.toFileURL(url); >- >- File libSource = toFile(url); >- FileUtils.copyDirectory(libSource, webContentDestination); >- } >- >- // >- //TODO: Hack to copy axis2-platform >- //this should be done in some cleaner way >- // >- >- url = Platform.getBundle(MODULE_BUNDLE_IDS[0]).getEntry("/lib/muse-platform-axis2-2.2.0.jar"); >- url = FileLocator.toFileURL(url); >- >- File libSource = toFile(url); >- FileUtils.copyFile(libSource, webContentDestination); >- >- File libDestination = new File(webContentDestination, "lib"); >- >- if(_additionalJars != null) { >- for (int i=0; i < _additionalJars.length; i++) { >- if(!_additionalJars[i].exists()) { >- throw new FileNotFoundException(_additionalJars[i].getAbsolutePath()); >- } >- >- FileUtils.copyFile(_additionalJars[i], libDestination); >- } >- } >- >- for (int i=0; i < _filesToCopy.length; i++) { >- String dest = _filesToCopy[i].getRelativePath(); >- File destDir = new File(webContentDir, dest); >- String[] files = _filesToCopy[i].getFiles(); >- >- for (int j=0; j < files.length; j++) { >- File file = new File(files[j]); >- if(!file.exists()) { >- throw new FileNotFoundException(file.getAbsolutePath()); >- } >- >- FileUtils.copyFile(file, destDir); >- } >- } >- >- return webContentDir; >- } >- private File toFile(URL url) throws Exception{ >- >- return new File(url.getFile()); >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseAxis2ProjectizerConstants.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseAxis2ProjectizerConstants.java >diff -N src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseAxis2ProjectizerConstants.java >--- src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseAxis2ProjectizerConstants.java 16 Mar 2007 15:53:15 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,34 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.internal.projectizer; >- >- >-public interface EclipseAxis2ProjectizerConstants { >- >- String RESOURCES_DIR = "/resources/axis2/"; //$NON-NLS-1$ >- >- String BUILD_FILE_RESOURCE = RESOURCES_DIR + "build.xml"; //$NON-NLS-1$ >- >- String BUILD_FILE = "build.xml"; //$NON-NLS-1$ >- >- String LAUNCH_FILE_RESOURCE = RESOURCES_DIR + ".externalToolBuilders/jarBuilder.launch"; //$NON-NLS-1$ >- >- String WEBCONTENT_DIR_RESOURCE = RESOURCES_DIR + "WebContent"; //$NON-NLS-1$ >- >- String PROJECT_LIB_DIR_RESOURCE = "/lib"; //$NON-NLS-1$ >- >- String PROJECT_MODULE_DIR_RESOURCE = "/modules"; //$NON-NLS-1$ >- >- String JAVA_BIN_DIR = "bin"; //$NON-NLS-1$ >- >-} >Index: src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEMiniProjectizer.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.codegeneration.j2ee/src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEMiniProjectizer.java,v >retrieving revision 1.1 >diff -u -r1.1 EclipseJ2EEMiniProjectizer.java >--- src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEMiniProjectizer.java 1 May 2007 16:40:38 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEMiniProjectizer.java 29 May 2007 23:40:32 -0000 >@@ -1,7 +1,292 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Andrew Eberbach (aeberbac@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ > package org.eclipse.tptp.wsdm.tooling.internal.projectizer; > >+import java.io.File; >+import java.io.FileNotFoundException; >+import java.io.InputStream; >+import java.net.URL; >+import java.util.Map; >+ > import org.apache.muse.tools.generator.projectizer.J2EEMiniProjectizer; >+import org.apache.muse.tools.generator.util.ConfigurationData; >+import org.apache.muse.util.FileUtils; >+import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >+import org.apache.muse.ws.wsdl.WsdlUtils; >+import org.eclipse.core.runtime.FileLocator; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.EclipseConfigurationData; >+import org.eclipse.tptp.wsdm.tooling.internal.util.ProgressMonitorHelper; >+import org.eclipse.tptp.wsdm.tooling.internal.util.ProjectHelper; >+import org.eclipse.tptp.wsdm.tooling.internal.util.WebProjectHelper; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; > > public class EclipseJ2EEMiniProjectizer extends J2EEMiniProjectizer { >+ private static final String[] LIB_BUNDLE_IDS = { >+ "org.apache.muse.api", //$NON-NLS-1$ >+ "org.apache.muse.impl", //$NON-NLS-1$ >+ "org.apache.muse.core", //$NON-NLS-1$ >+ "org.apache.muse.tools", //$NON-NLS-1$ >+ "org.apache.muse.utils" //$NON-NLS-1$ >+ }; >+ >+ private static final String CONTAINER_BUNDLE = "org.apache.muse.tools";//$NON-NLS-1$ >+ private static final String CONTAINER_RESOURCE = "/containers/muse-platform-mini-2.2.0.jar";//$NON-NLS-1$ >+ >+ private String _projectName; >+ private String _projectLocation; >+ private File[] _additionalJars; >+ private Object[][] _instances; >+ private ProgressMonitorHelper _progressMonitorHelper; >+ >+ public void projectize(ConfigurationData configuration) throws Exception { >+ ConfigurationData.checkConfiguration(this, configuration); >+ loadParameters(configuration); >+ ProgressMonitorHelper progressHelper = getProgressMonitor(); >+ progressHelper.startProgressMonitor(6); >+ >+ try { >+ WebProjectHelper helper = createProjectHelper(); >+ >+ helper.setSuspendValidation(true); >+ >+ createJavaSources(helper, progressHelper); >+ createArtifacts(helper, progressHelper); >+ createLibraries(helper, progressHelper); >+ >+ helper.refreshProject(); >+ helper.setSuspendValidation(false); >+ } finally { >+ progressHelper.finishProgressMonitor(); >+ } >+ } >+ >+ protected void createLibraries(WebProjectHelper helper, ProgressMonitorHelper progressHelper) throws Exception { >+ copyLibrariesFromBundles(helper, LIB_BUNDLE_IDS); >+ progressHelper.recordProgress(); >+ >+ copyAdditionalJars(helper); >+ progressHelper.recordProgress(); >+ >+ copyContainer(helper); >+ progressHelper.recordProgress(); >+ } >+ >+ protected void copyContainer(WebProjectHelper helper) throws Exception { >+ File webInfLibDir = new File(helper.getProjectDirectory(), EclipseJ2EEMiniProjectizerConstants.WEBINFLIB_DIR); >+ URL url = Platform.getBundle(CONTAINER_BUNDLE).getEntry(CONTAINER_RESOURCE); >+ url = FileLocator.toFileURL(url); >+ >+ File libSource = ProjectHelper.toFile(url); >+ FileUtils.copy(libSource, webInfLibDir); >+ } >+ >+ protected void copyAdditionalJars(WebProjectHelper helper) throws Exception { >+ File webInfLibDir = new File(helper.getProjectDirectory(), EclipseJ2EEMiniProjectizerConstants.WEBINFLIB_DIR); >+ >+ File[] additionalJars = getAdditionalJars(); >+ >+ if(additionalJars != null) { >+ for (int i=0; i < additionalJars.length; i++) { >+ if(!additionalJars[i].exists()) { >+ throw new FileNotFoundException(additionalJars[i].getAbsolutePath()); >+ } >+ >+ FileUtils.copyFile(additionalJars[i], webInfLibDir); >+ } >+ } >+ } >+ >+ protected void copyLibrariesFromBundles(WebProjectHelper helper, String[] libBundleIds) throws Exception { >+ URL url = null; >+ File webInfDir = new File(helper.getProjectDirectory(), EclipseJ2EEMiniProjectizerConstants.WEBINF_DIR); >+ >+ for (int i=0; i < libBundleIds.length; i++) { >+ url = Platform.getBundle(libBundleIds[i]).getEntry(EclipseJ2EEMiniProjectizerConstants.PROJECT_LIB_DIR_RESOURCE); >+ url = FileLocator.toFileURL(url); >+ >+ File libSource = ProjectHelper.toFile(url); >+ FileUtils.copyDirectory(libSource, webInfDir); >+ } >+ } >+ >+ protected WebProjectHelper createProjectHelper() throws Exception { >+ return new WebProjectHelper( >+ getProjectName(), >+ getProjectLocation(), >+ EclipseJ2EEMiniProjectizerConstants.JAVA_BIN_DIR, >+ EclipseJ2EEMiniProjectizerConstants.JAVA_SRC_DIR); >+ } >+ >+ protected void createJavaSources(WebProjectHelper helper, ProgressMonitorHelper progressHelper) throws Exception { >+ File javaSourceDir = new File( >+ helper.getProjectDirectory(), >+ EclipseJ2EEMiniProjectizerConstants.JAVA_SRC_DIR); >+ >+ createJavaSources(javaSourceDir, getFilesMaps()); >+ progressHelper.recordProgress(); >+ } >+ >+ protected void createArtifacts(WebProjectHelper helper, ProgressMonitorHelper progressHelper) throws Exception { >+ File descriptorFile = new File( >+ helper.getProjectDirectory(), >+ EclipseJ2EEMiniProjectizerConstants.DESCRIPTOR_FILE); >+ >+ File wsdldir = new File( >+ helper.getProjectDirectory(), >+ EclipseJ2EEMiniProjectizerConstants.WSDL_DIR); >+ >+ File routerEntriesDir = new File( >+ helper.getProjectDirectory(), >+ EclipseJ2EEMiniProjectizerConstants.ROUTER_ENTRIES_DIR); >+ >+ for(int i=0; i < getNumCapabilityMaps(); i++) { >+ Map capabilities = getCapabilityMap(i); >+ MetadataDescriptor rmd = getMetadata(i); >+ Document wsdl = getWsdl(i); >+ >+ createDescriptor(getDescriptor(), >+ wsdl, >+ descriptorFile, >+ capabilities, >+ EclipseJ2EEMiniProjectizerConstants.WSDL_RELATIVE_PATH, >+ i); >+ >+ createRMDFile(rmd, wsdl, wsdldir); >+ createWSDLFile(wsdl, wsdldir); >+ >+ if(getInstances() == null) { >+ createRouterEntries(routerEntriesDir, WsdlUtils.getServiceName(wsdl.getDocumentElement()), _capabilitiesList[i]); >+ } >+ } >+ >+ progressHelper.recordProgress(); >+ >+ if(getInstances() != null) { >+ createRouterEntries(routerEntriesDir, getInstances()); >+ } >+ >+ createWebDescriptor(helper); >+ createBuildFile(helper.getProjectDirectory(), >+ EclipseJ2EEMiniProjectizerConstants.BUILD_FILE_RESOURCE, >+ EclipseJ2EEMiniProjectizerConstants.BUILD_FILE); >+ >+ progressHelper.recordProgress(); >+ } >+ >+ protected void createBuildFile(File baseTargetDir, String buildFileResource, String buildFile) throws Exception { >+ InputStream buildTemplate = FileUtils.loadFromContext(this.getClass(),buildFileResource); >+ File build = new File(baseTargetDir, buildFile); >+ copyStreamCheck(buildTemplate, build); >+ } >+ >+ protected void createWebDescriptor(WebProjectHelper helper) throws Exception { >+ File webInfDir = new File(helper.getProjectDirectory(),EclipseJ2EEMiniProjectizerConstants.WEBINF_DIR); >+ File descriptorFile = new File(webInfDir, EclipseJ2EEMiniProjectizerConstants.WEBXML_FILE); >+ if(!descriptorFile.delete()) { >+ throw new Exception(); >+ } >+ createFileFromResource(webInfDir, >+ EclipseJ2EEMiniProjectizerConstants.WEBXML_RESOURCE, >+ EclipseJ2EEMiniProjectizerConstants.WEBXML_FILE); >+ } >+ >+ protected Map getCapabilityMap(int index) { >+ return _capabilitiesList[index]; >+ } >+ >+ protected void createRouterEntries(File routerEntriesDir,Object[][] instances) throws Exception { >+ routerEntriesDir.mkdirs(); >+ >+ for (int i = 0; i < getInstances().length; i++) { >+ Object[] instancePair = getInstances()[i]; >+ >+ // >+ // This is really tacky, but it's the only real way to do this >+ // since there are no pairs. The File use is to get the last element >+ // of the path in a nice, non-hack way. >+ // >+ String path = (String) instancePair[0]; >+ String resourcePathName = new File(path).getName(); >+ >+ Element instanceElement = (Element) instancePair[1]; >+ >+ File serviceDir = new File(routerEntriesDir, resourcePathName); >+ File routerEntryFile = new File(serviceDir, getResourceFileName(i)); >+ >+ writeToFileCheck(instanceElement, routerEntryFile); >+ } >+ } >+ >+ /** >+ * Get the name of a resource-instance file with the appropriate counter. This is >+ * really just a string-replace of the PLACE_HOLDER value with the given counter >+ * >+ * @param counter The number to use in the string replace >+ * @return The string with PLACE_HOLDER replaced by the string value of counter >+ */ >+ protected String getResourceFileName(int counter) { >+ return EclipseJ2EEMiniProjectizerConstants.RESOURCE_FILE.replaceFirst(PLACE_HOLDER, String.valueOf(counter)); >+ } >+ >+ protected void loadParameters(ConfigurationData data) { >+ super.loadParameters(data); >+ >+ _additionalJars = (File[]) data.getParameter(EclipseConfigurationData.ADDITIONAL_JARS); >+ _instances = (Object[][]) data.getParameter(EclipseConfigurationData.INSTANCES); >+ _progressMonitorHelper = new ProgressMonitorHelper((IProgressMonitor) data.getParameter(EclipseConfigurationData.PROGRESS_MONITOR)); >+ _projectName = (String) data.getParameter(EclipseConfigurationData.PROJECT_NAME); >+ _projectLocation = (String) data.getParameter(EclipseConfigurationData.PROJECT_LOCATION); >+ } >+ >+ protected File[] getAdditionalJars() { >+ return _additionalJars; >+ } >+ >+ protected Map[] getFilesMaps() { >+ return _filesMaps; >+ } >+ >+ protected String getProjectLocation() { >+ return _projectLocation; >+ } >+ >+ protected String getProjectName() { >+ return _projectName; >+ } >+ >+ protected ProgressMonitorHelper getProgressMonitor() { >+ return _progressMonitorHelper; >+ } >+ >+ protected Object[][] getInstances() { >+ return _instances; >+ } >+ >+ protected Document getDescriptor() { >+ return _descriptor; >+ } >+ >+ protected int getNumCapabilityMaps() { >+ return _capabilitiesList.length; >+ } >+ >+ protected Document getWsdl(int index) { >+ return _wsdls[index]; >+ } > >+ protected MetadataDescriptor getMetadata(int index) { >+ return _metadatas[index]; >+ } > } >Index: src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEMiniProjectizerConstants.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEMiniProjectizerConstants.java >diff -N src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEMiniProjectizerConstants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEMiniProjectizerConstants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,36 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Andrew Eberbach (aeberbac@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.tptp.wsdm.tooling.internal.projectizer; >+ >+public interface EclipseJ2EEMiniProjectizerConstants { >+ >+ String RESOURCE_FILE = "resource-instance-XXX.xml";//$NON-NLS-1$ >+ String WSDL_RELATIVE_PATH = "/wsdl/";//$NON-NLS-1$ >+ >+ String JAVA_SRC_DIR = "JavaSource/";//$NON-NLS-1$ >+ String WEBCONTENT_DIR = "WebContent/";//$NON-NLS-1$ >+ String WEBINF_DIR = WEBCONTENT_DIR + "WEB-INF/";//$NON-NLS-1$ >+ >+ String JAVA_BIN_DIR = "/bin";//$NON-NLS-1$ >+ String JAVA_CLASSES_DIR = WEBINF_DIR + "classes/";//$NON-NLS-1$ >+ String DESCRIPTOR_FILE = JAVA_CLASSES_DIR + "muse.xml";//$NON-NLS-1$ >+ String WSDL_DIR = JAVA_CLASSES_DIR + "wsdl/";//$NON-NLS-1$ >+ String ROUTER_ENTRIES_DIR = JAVA_CLASSES_DIR + "router-entries/";//$NON-NLS-1$ >+ >+ String RESOURCES_DIR = "/resources/mini/";//$NON-NLS-1$ >+ String WEBXML_RESOURCE = RESOURCES_DIR + "web.xml";//$NON-NLS-1$ >+ String WEBXML_FILE = "web.xml";//$NON-NLS-1$ >+ String PROJECT_LIB_DIR_RESOURCE = "/lib/";//$NON-NLS-1$ >+ String WEBINFLIB_DIR = WEBINF_DIR + "lib/";//$NON-NLS-1$ >+ String BUILD_FILE_RESOURCE = RESOURCES_DIR + "build.xml"; //$NON-NLS-1$; >+ String BUILD_FILE = "build.xml"; >+} >Index: src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEAxis2Projectizer.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEAxis2Projectizer.java >diff -N src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEAxis2Projectizer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEAxis2Projectizer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,251 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.internal.projectizer; >+ >+ >+import java.io.File; >+import java.io.FileNotFoundException; >+import java.net.URL; >+import java.util.Map; >+ >+import org.apache.muse.tools.generator.projectizer.Axis2ProjectizerConstants; >+import org.apache.muse.tools.generator.projectizer.J2EEAxis2Projectizer; >+import org.apache.muse.tools.generator.util.ConfigurationData; >+import org.apache.muse.tools.generator.util.ServicesDescriptorHelper; >+import org.apache.muse.util.FileUtils; >+import org.apache.muse.ws.resource.metadata.MetadataDescriptor; >+import org.apache.muse.ws.wsdl.WsdlUtils; >+import org.eclipse.core.runtime.FileLocator; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.EclipseConfigurationData; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.TargetedFileList; >+import org.eclipse.tptp.wsdm.tooling.internal.codegeneration.Activator; >+import org.eclipse.tptp.wsdm.tooling.internal.util.ProgressMonitorHelper; >+import org.eclipse.tptp.wsdm.tooling.internal.util.ProjectHelper; >+import org.eclipse.tptp.wsdm.tooling.internal.util.WebProjectHelper; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; >+ >+/** >+ * Construct the projectizer for code generation >+ */ >+public class EclipseJ2EEAxis2Projectizer extends J2EEAxis2Projectizer { >+ >+ >+ private static final String CONTAINER_BUNDLE = "org.apache.muse.tools";//$NON-NLS-1$ >+ private static final String CONTAINER_RESOURCE = "/containers/muse-platform-axis2-2.2.0.jar";//$NON-NLS-1$ >+ >+ >+ private static final String[] LIB_BUNDLE_IDS = { >+ "org.apache.muse.api", //$NON-NLS-1$ >+ "org.apache.muse.impl", //$NON-NLS-1$ >+ "org.apache.muse.core", //$NON-NLS-1$ >+ "org.apache.muse.tools", //$NON-NLS-1$ >+ "org.apache.muse.utils" //$NON-NLS-1$ >+ }; >+ >+ private static final String[] MODULE_BUNDLE_IDS = { >+ "org.apache.muse.tools", //$NON-NLS-1$ >+ }; >+ >+ private File[] _additionalJars; >+ private Object[][] _instances; >+ private IProgressMonitor _progressMonitor; >+ private TargetedFileList[] _filesToCopy; >+ >+ private int _resourceCounter = 0; >+ >+ private String _projectName; >+ >+ private String _projectLocation; >+ >+ public void projectize(ConfigurationData configuration) throws Exception { >+ >+ ConfigurationData.checkConfiguration(this, configuration); >+ loadParameters(configuration); >+ ProgressMonitorHelper progressHelper = new ProgressMonitorHelper(_progressMonitor); >+ try { >+ >+ progressHelper.startProgressMonitor(10); >+ >+ WebProjectHelper helper = createProject(); >+ >+ _targetDirectory = helper.getProjectDirectory(); >+ >+ progressHelper.recordProgress(); >+ >+ helper.setSuspendValidation(true); >+ >+ File webContentDir = copyTemplate(_targetDirectory); >+ progressHelper.recordProgress(); >+ >+ File descriptorFile = new File( >+ webContentDir, >+ Axis2ProjectizerConstants.DESCRIPTOR_FILE); >+ >+ File javaSourceDir = new File( >+ _targetDirectory, >+ Axis2ProjectizerConstants.JAVA_SRC_DIR); >+ >+ createJavaSources(javaSourceDir, _filesMaps); >+ progressHelper.recordProgress(); >+ >+ File wsdldir = new File( >+ webContentDir, >+ Axis2ProjectizerConstants.WSDL_DIR); >+ >+ File routerEntriesDir = new File(webContentDir,Axis2ProjectizerConstants.ROUTER_ENTRIES_DIR); >+ >+ ServicesDescriptorHelper servicesHelper = new ServicesDescriptorHelper(); >+ >+ createBuildFile(_targetDirectory, EclipseJ2EEAxis2ProjectizerConstants.BUILD_FILE_RESOURCE, EclipseJ2EEAxis2ProjectizerConstants.BUILD_FILE); >+ progressHelper.recordProgress(); >+ >+ for(int i=0; i < _capabilitiesList.length; i++) { >+ Map capabilities = _capabilitiesList[i]; >+ Document wsdl = _wsdls[i]; >+ createDescriptor(_descriptor, wsdl, descriptorFile, capabilities, Axis2ProjectizerConstants.WSDL_RELATIVE_PATH, i); >+ MetadataDescriptor rmd = _metadatas[i]; >+ createRMDFile(rmd, wsdl, wsdldir); >+ createWSDLFile(wsdl, wsdldir); >+ if(_instances == null) { >+ createRouterEntries(routerEntriesDir, WsdlUtils.getServiceName(wsdl.getDocumentElement()), _capabilitiesList[i]); >+ } >+ updateServicesDescriptor(servicesHelper, wsdl, capabilities); >+ } >+ >+ if(_instances != null) { >+ createRouterEntries(routerEntriesDir, _instances); >+ } >+ progressHelper.recordProgress(4); >+ >+ File servicesFile = new File(webContentDir, Axis2ProjectizerConstants.SERVICES_FILE); >+ createServicesDescriptor(servicesHelper, servicesFile); >+ progressHelper.recordProgress(); >+ >+ helper.refreshProject(); >+ progressHelper.recordProgress(); >+ >+ helper.setSuspendValidation(false); >+ } finally { >+ progressHelper.finishProgressMonitor(); >+ } >+ } >+ >+ protected void loadParameters(ConfigurationData data) { >+ super.loadParameters(data); >+ >+ _additionalJars = (File[])data.getParameter(EclipseConfigurationData.ADDITIONAL_JARS); >+ _instances = (Object[][])data.getParameter(EclipseConfigurationData.INSTANCES); >+ _progressMonitor = (IProgressMonitor)data.getParameter(EclipseConfigurationData.PROGRESS_MONITOR); >+ _filesToCopy = (TargetedFileList[])data.getParameter(EclipseConfigurationData.AXIS2_FILES); >+ _projectName = (String)data.getParameter(EclipseConfigurationData.PROJECT_NAME); >+ _projectLocation = (String)data.getParameter(EclipseConfigurationData.PROJECT_LOCATION); >+ } >+ >+ private WebProjectHelper createProject() throws Exception { >+ WebProjectHelper helper = new WebProjectHelper(_projectName, _projectLocation, EclipseJ2EEAxis2ProjectizerConstants.JAVA_BIN_DIR, Axis2ProjectizerConstants.JAVA_SRC_DIR); >+ >+ return helper; >+ } >+ >+ protected void createRouterEntries(File routerEntriesDir,Object[][] instances) throws Exception { >+ routerEntriesDir.mkdirs(); >+ >+ for (int i = 0; i < _instances.length; i++) { >+ Object[] instancePair = _instances[i]; >+ >+ // >+ // This is really tacky, but it's the only real way to do this >+ // since there are no pairs. The File use is to get the last element >+ // of the path in a nice, non-hack way. >+ // >+ String path = (String) instancePair[0]; >+ String resourcePathName = new File(path).getName(); >+ >+ Element instanceElement = (Element) instancePair[1]; >+ >+ File serviceDir = new File(routerEntriesDir, resourcePathName); >+ File routerEntryFile = new File(serviceDir, getResourceFileName()); >+ >+ writeToFileCheck(instanceElement, routerEntryFile); >+ } >+ } >+ >+ protected String getResourceFileName() { >+ return Axis2ProjectizerConstants.RESOURCE_FILE.replaceFirst(PLACE_HOLDER, String.valueOf(_resourceCounter++)); >+ } >+ >+ protected File copyTemplate(File destination) throws Exception { >+ URL url = Platform.getBundle(Activator.PLUGIN_ID).getEntry(EclipseJ2EEAxis2ProjectizerConstants.WEBCONTENT_DIR_RESOURCE); >+ url = FileLocator.toFileURL(url); >+ >+ File source = ProjectHelper.toFile(url); >+ FileUtils.copyDirectory(source, destination); >+ >+ File webContentDir = new File(destination, source.getName()); >+ File webContentDestination = new File(webContentDir, "WEB-INF"); //$NON-NLS-1$ >+ >+ for (int i=0; i < LIB_BUNDLE_IDS.length; i++) { >+ url = Platform.getBundle(LIB_BUNDLE_IDS[i]).getEntry(EclipseJ2EEAxis2ProjectizerConstants.PROJECT_LIB_DIR_RESOURCE); >+ url = FileLocator.toFileURL(url); >+ >+ File libSource = ProjectHelper.toFile(url); >+ FileUtils.copyDirectory(libSource, webContentDestination); >+ } >+ >+ for (int i=0; i < MODULE_BUNDLE_IDS.length; i++) { >+ url = Platform.getBundle(MODULE_BUNDLE_IDS[i]).getEntry(EclipseJ2EEAxis2ProjectizerConstants.PROJECT_MODULE_DIR_RESOURCE); >+ url = FileLocator.toFileURL(url); >+ >+ File libSource = ProjectHelper.toFile(url); >+ FileUtils.copyDirectory(libSource, webContentDestination); >+ } >+ >+ File libDestination = new File(webContentDestination, "lib"); >+ >+ url = Platform.getBundle(CONTAINER_BUNDLE).getEntry(CONTAINER_RESOURCE); >+ url = FileLocator.toFileURL(url); >+ >+ File libSource = ProjectHelper.toFile(url); >+ FileUtils.copy(libSource, libDestination); >+ >+ if(_additionalJars != null) { >+ for (int i=0; i < _additionalJars.length; i++) { >+ if(!_additionalJars[i].exists()) { >+ throw new FileNotFoundException(_additionalJars[i].getAbsolutePath()); >+ } >+ >+ FileUtils.copyFile(_additionalJars[i], libDestination); >+ } >+ } >+ >+ for (int i=0; i < _filesToCopy.length; i++) { >+ String dest = _filesToCopy[i].getRelativePath(); >+ File destDir = new File(webContentDir, dest); >+ String[] files = _filesToCopy[i].getFiles(); >+ >+ for (int j=0; j < files.length; j++) { >+ File file = new File(files[j]); >+ if(!file.exists()) { >+ throw new FileNotFoundException(file.getAbsolutePath()); >+ } >+ >+ FileUtils.copyFile(file, destDir); >+ } >+ } >+ >+ return webContentDir; >+ } >+} >Index: resources/mini/build.xml >=================================================================== >RCS file: resources/mini/build.xml >diff -N resources/mini/build.xml >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ resources/mini/build.xml 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,10 @@ >+<?xml version="1.0"?> >+<project name="project" default="default"> >+ <target name="default"> >+ <jar destfile="${basedir}/WebContent/WEB-INF/lib/capability.jar"> >+ <fileset dir="bin"> >+ <include name="**/*.class"/> >+ </fileset> >+ </jar> >+ </target> >+</project> >Index: resources/mini/web.xml >=================================================================== >RCS file: resources/mini/web.xml >diff -N resources/mini/web.xml >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ resources/mini/web.xml 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,13 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<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"> >+ <display-name>Apache Muse Servlet</display-name> >+ <servlet> >+ <display-name>Apache Muse Servlet</display-name> >+ <servlet-name>ApacheMuseServlet</servlet-name> >+ <servlet-class>org.apache.muse.core.platform.mini.MiniServlet</servlet-class> >+ </servlet> >+ <servlet-mapping> >+ <servlet-name>ApacheMuseServlet</servlet-name> >+ <url-pattern>/*</url-pattern> >+ </servlet-mapping> >+</web-app> >Index: src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEAxis2ProjectizerConstants.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEAxis2ProjectizerConstants.java >diff -N src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEAxis2ProjectizerConstants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/internal/projectizer/EclipseJ2EEAxis2ProjectizerConstants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,34 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.internal.projectizer; >+ >+ >+public interface EclipseJ2EEAxis2ProjectizerConstants { >+ >+ String RESOURCES_DIR = "/resources/axis2/"; //$NON-NLS-1$ >+ >+ String BUILD_FILE_RESOURCE = RESOURCES_DIR + "build.xml"; //$NON-NLS-1$ >+ >+ String BUILD_FILE = "build.xml"; //$NON-NLS-1$ >+ >+ String LAUNCH_FILE_RESOURCE = RESOURCES_DIR + ".externalToolBuilders/jarBuilder.launch"; //$NON-NLS-1$ >+ >+ String WEBCONTENT_DIR_RESOURCE = RESOURCES_DIR + "WebContent"; //$NON-NLS-1$ >+ >+ String PROJECT_LIB_DIR_RESOURCE = "/lib"; //$NON-NLS-1$ >+ >+ String PROJECT_MODULE_DIR_RESOURCE = "/modules"; //$NON-NLS-1$ >+ >+ String JAVA_BIN_DIR = "bin"; //$NON-NLS-1$ >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 179329
:
61985
|
68705
|
69193
|
69345