[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[bpel-dev] Problem with missing INamespaceMap
|
Hello,
i am extending BPEL Designer with additional Items in the
palette. The idea is, that the user can create predefined activities
this way.
An example:
There is an Icon in the palette called
"Magic Invoke". When the user drags it into an process, a new Invoke
will be created, with all attributes set (Partner Link, Operation,
Input, Output).
A more complex example would be to create a sequence containing many
more predefined activities. This way the user can create predefined
process fragments with just one click.
My approach of implementing this was following the tutorial from Benjamin Höhensteiger (
http://www.eclipse.org/bpel/users/howto/extension.php).
To create the predefined Invoke i extended the createInstance() Method
of my UIObjectFactory. It creates a new invoke, gives it a name and
adds it as a child to the Extension Activity (see below for code).
Setting the attributes and creating variables was not possible at
this point, because there is no access to the process. So i hooked into
the serializer for my Extension Activity and created all the missing
stuff there. You find the code below (method marshall() in class
EMF2DOM).
In short i did the following:
- create a new import for the WSDL of the invoked WebService and add it to the process
- get elements like partnerlinktype, porttype,... from the WSDL
- create variables and partner link
- add them to my invoke and to the process
The
problem occurs, when my serializer invokes the serializer for my (just
new created) child elements. The serializier for my invoke tries to
convert the Qname of the PortType to string. When doing this, it tries
to get the INamespaceMap of the invoke. It seems, that there is no
INamespaceMap attached to.
You find the stacktrace below.
Any idea, why there is no INamespaceMap attached? How can i attach one? Or am i doing the wrong things in the wrong place?
I
don't want to modify the BPEL Designer Code itself. This is the reason,
why i chose using the Extension Activity as container for my predefined
activities.
Thanks for help
Karolina
public class ExtensionSampleUIObjectFactory extends AbstractUIObjectFactory
implements IExtensionUIObjectFactory {
@Override
public EObject createInstance() {
EObject result = super.createInstance();
if (result instanceof SampleStructuredActivity) {
SampleStructuredActivity ssa = (SampleStructuredActivity) result;
Invoke myInvoke = BPELFactory.eINSTANCE.createInvoke();
myInvoke.setName("My generated Invoke");
ssa.setActivity(myInvoke);
}
return result;
}
}
public class EMF2DOM implements BPELActivitySerializer {
@Override
public void marshall(QName elementType, Activity activity, Node parentNode,
Process process, BPELWriter bpelWriter) {
Document document = parentNode.getOwnerDocument();
/*
* SampleStructuredActivity
*/
if (activity instanceof SampleStructuredActivity) {
SampleStructuredActivity ssa = (SampleStructuredActivity)activity;
// Import WSDL of invoked WebService, assuming WSDL file is already in project folder
Import wsdlImport = BPELFactory.eINSTANCE.createImport();
wsdlImport.setImportType(WSDLConstants.WSDL_NAMESPACE_URI);
wsdlImport.setLocation("Receive_Reply_01Artifacts.wsdl");
wsdlImport.setNamespace("Receive_Reply_01");
process.getImports().add(wsdlImport);
// Get Elements from WSDL (PortType, Operation, Role, Message, PartnerLinkType...)
PortType myPortType = (PortType)BPELUtils.lookup(activity, new QName("Receive_Reply_01","Receive_Reply_01"), null, WSDLUtil.WSDL_PORT_TYPE);
Operation myOperation = null;
for (Object o : myPortType.getOperations()) {
if(((Operation)o).getName().equals("process")) {
myOperation = (Operation)o;
}
}
Message myInputMessage = (Message)BPELUtils.lookup(activity, new QName("Receive_Reply_01","Receive_Reply_01RequestMessage"), null, WSDLUtil.WSDL_MESSAGE);
Message myOutputMessage = (Message)BPELUtils.lookup(activity, new QName("Receive_Reply_01","Receive_Reply_01ResponseMessage"), null, WSDLUtil.WSDL_MESSAGE);
PartnerLinkType myPartnerLinkType = (PartnerLinkType)BPELUtils.lookup(activity, new QName("Receive_Reply_01","Receive_Reply_01"), null, WSDLUtil.BPEL_PARTNER_LINK_TYPE);
Role myRole = null;
for (Role r : myPartnerLinkType.getRole()) {
if (r.getName().equals("Receive_Reply_01Provider")) {
myRole = r;
}
}
// Create input and output variables for Invoke
Variable myInputVariable = BPELFactory.eINSTANCE.createVariable();
myInputVariable.setName("Invoke1_Input");
myInputVariable.setMessageType(myInputMessage);
Variable myOutputVariable = BPELFactory.eINSTANCE.createVariable();
myOutputVariable.setName("Invoke1_Output");
myOutputVariable.setMessageType(myOutputMessage);
// Add variables to process
if (process.getVariables() == null) {
process.setVariables(BPELFactory.eINSTANCE.createVariables());
}
process.getVariables().getChildren().add(myInputVariable);
process.getVariables().getChildren().add(myOutputVariable);
// Create PartnerLink for Invoke
PartnerLink myPartnerLink = BPELFactory.eINSTANCE.createPartnerLink();
myPartnerLink.setName("Invoke1_PartnerLink");
myPartnerLink.setPartnerRole(myRole);
myPartnerLink.setPartnerLinkType(myPartnerLinkType);
// Add PartnerLink to process
if (process.getPartnerLinks() == null) {
process.setPartnerLinks(BPELFactory.eINSTANCE.createPartnerLinks());
}
process.getPartnerLinks().getChildren().add(myPartnerLink);
// Get Invoke and set Attributes
Invoke myInvoke = (Invoke)ssa.getActivity();
myInvoke.setInputVariable(myInputVariable);
myInvoke.setOutputVariable(myOutputVariable);
myInvoke.setPartnerLink(myPartnerLink);
myInvoke.setPortType(myPortType);
myInvoke.setOperation(myOperation);
// register the namespace
String nsPrefix = ModelPackage.eINSTANCE.getNsPrefix();
String nsURI = ModelPackage.eINSTANCE.getNsURI();
INamespaceMap<String, String> nsMap = BPELUtils.getNamespaceMap(process);
nsMap.put(nsPrefix, nsURI);
// create a new DOM element for our Activity
Element activityElement = document.createElementNS(elementType.getNamespaceURI(),
"sampleStructuredActivity");
activityElement.setPrefix(nsPrefix);
// handle child activity
Activity childActivity = ((SampleStructuredActivity) activity).getActivity();
if (childActivity != null) {
activityElement.appendChild(bpelWriter.activity2XML(childActivity));
}
// insert the DOM element into the DOM tree
parentNode.appendChild(activityElement);
} else {
System.out.println("Cannot handle this kind of Activity");
}
}
}
!ENTRY org.eclipse.ui 4 0 2009-08-06 18:59:21.555
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.IllegalStateException: INamespaceMap cannot be attached to an eObject
at org.eclipse.bpel.model.util.BPELUtils.getNamespaceMap(BPELUtils.java:260)
at org.eclipse.bpel.model.resource.BPELWriter.qNameToString(BPELWriter.java:2456)
at org.eclipse.bpel.model.resource.BPELWriter.invoke2XML(BPELWriter.java:1360)
at org.eclipse.bpel.model.resource.BPELWriter.activity2XML(BPELWriter.java:1068)
at org.eclipse.bpel.model.util.ElementFactory$MyBPELWriter.activity2XML(ElementFactory.java:94)
at model.impl.EMF2DOM.marshall(EMF2DOM.java:125)
at org.eclipse.bpel.model.resource.BPELWriter.extensionActivity2XML(BPELWriter.java:1339)
at org.eclipse.bpel.model.resource.BPELWriter.activity2XML(BPELWriter.java:1108)
at org.eclipse.bpel.model.util.ElementFactory$MyBPELWriter.activity2XML(ElementFactory.java:94)
at org.eclipse.bpel.model.util.ElementFactory.createElement(ElementFactory.java:360)
at org.eclipse.bpel.model.util.ReconciliationHelper.adoptChild(ReconciliationHelper.java:726)
at org.eclipse.bpel.model.impl.SequenceImpl.adoptContent(SequenceImpl.java:165)
at org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl.eNotify(WSDLElementImpl.java:392)
at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:255)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:362)
at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:672)
at org.eclipse.bpel.ui.adapters.delegates.ReferenceContainer.addChild(ReferenceContainer.java:102)
at org.eclipse.bpel.ui.adapters.delegates.ReferenceContainer.addChild(ReferenceContainer.java:1)
at org.eclipse.bpel.ui.adapters.ContainerActivityAdapter.addChild(ContainerActivityAdapter.java:37)
at org.eclipse.bpel.ui.commands.InsertInContainerCommand.doExecute(InsertInContainerCommand.java:76)
at org.eclipse.bpel.ui.commands.CompoundCommand.doExecute(CompoundCommand.java:52)
at org.eclipse.bpel.ui.commands.util.AutoUndoCommand.execute(AutoUndoCommand.java:108)
at org.eclipse.bpel.common.ui.editmodel.EditModelCommandStack.execute(EditModelCommandStack.java:123)
at org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTool.java:399)
at org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(AbstractTool.java:411)
at org.eclipse.gef.tools.CreationTool.performCreation(CreationTool.java:254)
at org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTool.java:178)
at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java:1064)
at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:263)
at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseReleased(DomainEventDispatcher.java:374)
at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(LightweightSystem.java:538)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:207)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)