Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [bpel-dev] generate the .bpel file from an EMF model

Thank you for your reply I used the code example you give me
to generate a    .bpel file as shown in the following example

 

public static void main(String[] args) {

 

         Process process = null;

 

         try {

 

             // Register the XMI resource factory for the .bpel extension

             Resource.Factory.Registry reg =

Resource.Factory.Registry.INSTANCE;

             Map<String, Object> m = reg.getExtensionToFactoryMap();

             m.put("bpel", new BPELResourceFactoryImpl());//difference avec XMIResourceFactoryImpl() et XMLResourceFactoryImpl()

 

              //create resource

              URI uri =

URI.createFileURI("//myBPEL2.bpel");

 

              ResourceSet rSet = new ResourceSetImpl();

               Resource bpelResource = rSet.createResource(uri);

 

               //create/populate process

               process = BPELFactory.eINSTANCE.createProcess();

               process.setName("myBPEL");

               Sequence mySeq = BPELFactory.eINSTANCE.createSequence();

               mySeq.setName("mainSequence");

               process.setActivity(mySeq);

 

               //save resource

               bpelResource.getContents().add(process);

               bpelResource.save(null);

         }

 

         catch (Exception e) {

               e.printStackTrace();

         }

     }

 

}

 

 

 

 

But if i use the BPELResourceFactoryImpl as the extension parser for .bpel files

I have the following exception

java.lang.IllegalStateException: INamespaceMap cannot be attached to an eObject

      at org.eclipse.bpel.model.util.BPELUtils.getNamespaceMap(BPELUtils.java:261)

      at org.eclipse.bpel.model.resource.BPELResourceImpl.doSave(BPELResourceImpl.java:88)

      at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1406)

      at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:993)

      at bpelgen.Test.main(Test.java:49)

 

 

 

 

 

 And if I use the XMLResourceFactoryImpl as the extension parser for .bpel files it generate .bpel file but with rang namespace

 

<?xml version="1.0" encoding="ASCII"?>

<bpws:Process xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable" name="myBPEL">

  <activity xsi:type="bpws:Sequence" name="mainSequence"/>

</bpws:Process>

 

 

-------------------------------------------

 

 

<activity xsi:type="bpws:Sequence" name="mainSequence"/>

 

instead of

<bpws:Sequence name="mainSequence"/>


 

 

 

 

so could you tel me if I have to use the XMLResourceFactoryImpl or the BPELResourceFactoryImpl  and in the secend case how can I resolve the INamespaceMap cannot be attached to an eObject exception

 

 regards,



On Wed, May 19, 2010 at 4:02 PM, Simon D Moser <SMOSER@xxxxxxxxxx> wrote:
Again, I don't think you can use our BPELWriter for this. The way this
works today is the following:

The BPELReader uses a regular DOM parser to populate the EMF in-memory
model. The BPEL Editor then works on the in-memory model, and then on save,
the in-memory model gets translated back to a DOM tree which is serialized
as XML again. As such, both the BPELReader and the BPELWriter assume
certain knowlegde about the XML that they consume/provide. If you created
your own model (even if its an instance of the BPEL ecore), those
assumptions might not be true anymore, certainly not in the case where you
pass in an XMI file. Thus, you'd need to write your "own" BPELWriter (or
extend our BPELWriter / BPELReader) such that your Reader/Writer is able to
understand both XMI and your eCore (and potentially more, e.g. Your own
BPELResource that probably already exists).

In case you can go with our BPEL model, below is little sample code that
creates a simple .bpel File:

     protected Process createBPEL(){

           Process process = null;

           try {
                 //create resource
                 URI uri = URI.createPlatformResourceURI
("/myProject/myBPEL.bpel", false);
                 ResourceSet rSet = new ResourceSetImpl();
                 bpelResource = rSet.createResource(uri);

                 process = BPELFactory.eINSTANCE.createProcess();
                 process.setName("myBPEL");
                 Sequence mySeq = BPELFactory.eINSTANCE.createSequence();
                 mySeq.setName("mainSequence");
                 process.setActivity(mySeq);

                 bpelResource.getContents().add(process);
                 bpelResource.save(null);
           }

           catch (Exception e) {
                 e.printStackTrace();
           }

           return process;
     }

Note that you have to have a project called "myProject" in your workspace
in order to make this run. Note also that I don't call the writer
explicitly, but only do save() on the EMFResource (which is a
BPELResource). This triggers the writer under the covers.





Mit freundlichen Grüßen / Kind regards


Simon Moser

WebSphere BPM Architecture - Team Lead BPEL, BSM & Selector Editors
IBM Software Group, Application and Integration Middleware Software
Business Process Solutions Development 1
-------------------------------------------------------------------------------------------------------------------------------------------
IBM Deutschland
Schoenaicher Str. 220
71032 Boeblingen
Phone: +49-7031-16-4304
Fax: +49-7031-16-4890
E-Mail: smoser@xxxxxxxxxx
-------------------------------------------------------------------------------------------------------------------------------------------
IBM Deutschland Research & Development GmbH / Vorsitzender des
Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht
Stuttgart, HRB 243294




 From:       aymen saied <med.aymen.saied@xxxxxxxxx>

 To:         "BPEL Designer project developer discussions." <bpel-dev@xxxxxxxxxxx>

 Date:       19.05.2010 15:36

 Subject:    Re: [bpel-dev] generate the .bpel file from an EMF model

 Sent by:    bpel-dev-bounces@xxxxxxxxxxx






Hi,


I have created my own EMF model it's an instance of the bpel.ecore Met
model (the instance can be an xmi or an xml file)


and I want to generate the ( .bpel) file from this EMF model so I need to
use the BPEL Writer


am i assuming it right and if so could you give Some sample code on how to
generate a .bpel file from an existing own EMF model


regards,




On Wed, May 19, 2010 at 2:47 PM, Simon D Moser <SMOSER@xxxxxxxxxx> wrote:
     BPEL Reader and BPEL Writer most certainly don't work with an XMI
     file.
     Where do you have that XMI from ? Did you create your own EMF model ?

     Currently, the BPEL Reader and BPEL Writer populate/serialise to/from
     an
     EMF model that exists (org.eclipse.bpel.model). However, the inout
     and
     output must always be standard BPEL 2.0 XML syntax, not XMI. I don't
     think
     you can use the BPEL model for what you are trying to achieve (but I
     admit,
     I havent fully understood what you are trying to do).

     Mit freundlichen Grüßen / Kind regards

     Simon Moser

     WebSphere BPM Architecture - Team Lead BPEL, BSM & Selector Editors
     IBM Software Group, Application and Integration Middleware Software
     Business Process Solutions Development 1
     -------------------------------------------------------------------------------------------------------------------------------------------

     IBM Deutschland
     Schoenaicher Str. 220
     71032 Boeblingen
     Phone: +49-7031-16-4304
     Fax: +49-7031-16-4890
     E-Mail: smoser@xxxxxxxxxx
     -------------------------------------------------------------------------------------------------------------------------------------------

     IBM Deutschland Research & Development GmbH / Vorsitzender des
     Aufsichtsrats: Martin Jetter
     Geschäftsführung: Dirk Wittkopp
     Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht
     Stuttgart, HRB 243294




      From:       aymen saied <med.aymen.saied@xxxxxxxxx>

      To:         bpel-dev@xxxxxxxxxxx

      Date:       19.05.2010 11:15

      Subject:    [bpel-dev] generate the .bpel file from an EMF model

      Sent by:    bpel-dev-bounces@xxxxxxxxxxx






     Hi,





     I want to generate the .bpel file  (myBpel.bpel) from an EMF model
     (myProcess.xmi) already created


      I tried to roam around the classes like BPELWriter, BPELFactoryImpl,
     BPELResourceImpl etc...





     What I am trying to do is to load the Process form the xmi file (EMF
     model)
     and I then want to use write(BPELResource, OutputStream) method to to
     generate the .bpel





     first am i assuming it right and second could you give me example for
     loading process from xmi fil and generating .bpel file








     regards,_______________________________________________
     bpel-dev mailing list
     bpel-dev@xxxxxxxxxxx
     https://dev.eclipse.org/mailman/listinfo/bpel-dev







     _______________________________________________
     bpel-dev mailing list
     bpel-dev@xxxxxxxxxxx
     https://dev.eclipse.org/mailman/listinfo/bpel-dev
_______________________________________________
bpel-dev mailing list
bpel-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/bpel-dev



_______________________________________________
bpel-dev mailing list
bpel-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/bpel-dev


Back to the top