| Create BPEL Process from java program [message #559779] |
Sat, 18 September 2010 06:43  |
lamine Messages: 4 Registered: September 2010 |
Junior Member |
|
|
I want to create a BPEL process from java program, using eclipse BPEL API,
I use this code :
BPELPackageImpl.init();
BPELPackage.eINSTANCE.eClass();
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("bpel", new BPELResourceFactoryImpl());
URI uri = URI.createURI("examples/myFirstProcess.bpel");
ResourceSet resSet = new ResourceSetImpl();
Resource resource = resSet.createResource(uri) ;
BPELResourceImpl bpelResImp = (BPELResourceImpl) resource;
BPELFactory factory = BPELFactory.eINSTANCE;
process = factory.createProcess();
process.setName("xxxxx");
Sequence mySeq = BPELFactory.eINSTANCE.createSequence();
mySeq.setName("mainSequence");
Invoke myInv = BPELFactory.eINSTANCE.createInvoke();
process.setActivity(mySeq);
bpelResImp.getContents().add(process);
bpelResImp.save(null);
when I execute this program this exception is occured in this statement : " bpelResImp.save(null);":
java.lang.IllegalStateException: INamespaceMap cannot be attached to an eObject
at org.eclipse.bpel.model.util.BPELUtils.getNamespaceMap(BPELUt ils.java:260)
at org.eclipse.bpel.model.resource.BPELResourceImpl.doSave(BPEL ResourceImpl.java:88)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1406)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:993)
at ws.gen.BPELGenerator.createProc(BPELGreator.java:245)
at ws.gen.BPELGenerator.main(BPELCreator.java:268)
any help please?
|
|
|
|
| Re: Create BPEL Process from java program [message #658243 is a reply to message #658169] |
Mon, 07 March 2011 09:57   |
|
Hi Kamrad,
The BPEL EMF model that's used in the editor is not really meant to be used to serialized/deserialize XML. The way the editor does its serialization is through a DOM that is used as the model for the "Source" tab in the editor. Take a look at the BPELWriter class to see how the BPEL XML is created - there are methods for each of the BPEL activities and other stuff which create the DOM elements.
You might be able to adapt the writer for your own use. I think what you'd need to do is first construct the EMF model for the BPEL process that you want, then create a DOM and use the BPELWriter to serialize into that DOM (don't forget to add the appropriate namespaces!)
If you do get this to work, please let me know - I think it would be really useful to add this to the BPEL Designer as a public API.
Thanks in advance!
Bob
|
|
|
|
| Re: Create BPEL Process from java program [message #659887 is a reply to message #659808] |
Tue, 15 March 2011 17:59   |
|
Well, yes...as long as the output is valid BPEL and all of the imports are resolved you should be able to deploy the whole lot. You can either zip the entire bpel content folder and copy it to your Ode runtime directory, or you can recreate the folder and files structure there.
You will also need a deployment descriptor (deploy.xml) which defines the processes and their interfaces. All of this is in org.eclipse.bpel.apache.ode.deloy.model and .ui
|
|
|
|
|
|
Re: Create BPEL Process from java program [message #1045039 is a reply to message #559779] |
Fri, 19 April 2013 13:27   |
Luca Pino Messages: 1 Registered: April 2013 |
Junior Member |
|
|
Just add
AdapterRegistry.INSTANCE.registerAdapterFactory( BPELPackage.eINSTANCE, BasicBPELAdapterFactory.INSTANCE );
before the creation of the resource to get rid of the error
java.lang.IllegalStateException: INamespaceMap cannot be attached to an eObject
(took quite a while to solve this, hope it will be useful to others!)
edit: also it might be the case to mention this in the BPEL Model page - http://www.eclipse.org/bpel/developers/model.php
under the Reading and Writing BPEL Files, as I saw a lot of people struggling with this in the forum and mailing list.
[Updated on: Sat, 20 April 2013 08:47] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02423 seconds