Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [bpel-dev] Using BPELReader Class

Hi Damien,

**assuming ** your file is in your eclipse runtime workspace, this can be
done much, much simpler :

      IPath path = new Path(
"/home/damien/Workspaces/BPEL/org.example.loadbpel/bpel/ldiplom.bpel");
      IFile bpelFile = ResourcesPlugin.getWorkspace().getRoot().getFile
(path);
      loadBPEL(bpelFile);).


      protected Process loadBPEL(IFile bpelFile) {

            ResourceSet fResourceSet = new BPELResourceSetImpl();

            IPath fullProcessPath = bpelFile.getFullPath();
            URI uri = URI.createPlatformResourceURI
(fullProcessPath.toString(), false);
            bpelResource = fResourceSet.getResource(uri, true);

            EcorePackage instance = EcorePackage.eINSTANCE;
            instance.eAdapters();

            try {
                  bpelResource.load(Collections.EMPTY_MAP);
                  EList<EObject> contents = bpelResource.getContents();
                  if (!contents.isEmpty()) {
                        return (Process) contents.get(0);
                  }
            } catch (Exception e) {
                  e.printStackTrace();
            }

            return null;

      }


The path might not be correct in my example - it might be that you must
only specify the path starting from your workspace root instead of having
the full path - give it a try.
Alternatively, *if* you want to launch whatever you are doing using a
right-click menu on the bpel process, let me know, I can send you a sample
plug-in for that, too.

Mit freundlichen Grüßen / Kind regards

Simon Daniel Moser

Team Lead BPEL Editor - Websphere Integration Developer (WID)
IBM Software Group, Application and Integration Middleware Software
Business Process Solutions Development 1
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       
  Phone:            +49-7031-16-4304           IBM Deutschland                      (Embedded
                                                                                  image moved
                                                                                     to file:
                                                                                pic32214.gif)
                                                                       
  Fax:              +49-7031-16-4890           Schoenaicher Str. 220   
                                                                       
  E-Mail:           smoser@xxxxxxxxxx          71032 Boeblingen        
                                                                       
                                               Germany                 
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       
  IBM Deutschland                                                      
  Research &                                                           
  Development                                                          
  GmbH /                                                               
  Vorsitzender des                                                     
  Aufsichtsrats:                                                       
  Martin Jetter                                                        
  Geschäftsführung:                                                
  Erich Baier                                                          
  Sitz der                                                             
  Gesellschaft:                                                        
  Böblingen /                                                        
  Registergericht:                                                     
  Amtsgericht                                                          
  Stuttgart, HRB                                                       
  243294                                                               
                                                                       




                                                                       
  From:       Damien Thivolle <damien.thivolle@xxxxxxxx>               
                                                                       
  To:         "BPEL Designer project developer discussions." <bpel-dev@xxxxxxxxxxx>
                                                                       
  Date:       06/17/2009 06:35 PM                                      
                                                                       
  Subject:    [bpel-dev] Using BPELReader Class                        
                                                                       
  Sent by:    bpel-dev-bounces@xxxxxxxxxxx                             
                                                                       





Hello,

I have been trying to use the BPELReader class to read a .bpel file and
obtain the BPEL process it defines, using the getProcess() method from
that class.

Unfortunately, I haven't been able to make it work yet.

I am using the following code. I took most of it from some test cases I
found and I have to admit, I don't really know what I am doing :)


File inputFile = new
File
("/home/damien/Workspaces/BPEL/org.example.loadbpel/bpel/ldiplom.bpel");

ResourceSet fResourceSet;

// Create the Quasi-Eclipse environment ...
AdapterRegistry.INSTANCE.registerAdapterFactory( new
org.eclipse.bpel.validator.factory.AdapterFactory() );
AdapterRegistry.INSTANCE.registerAdapterFactory( BPELPackage.eINSTANCE,
BasicBPELAdapterFactory.INSTANCE );

//      Create a resource set.
fResourceSet = new BPELResourceSetImpl();

// Register the resource factories for .bpel, .wsdl, and .xsd resources.
//   - bpel reads BPEL resources (our model)

fResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
   "bpel", new BPELResourceFactoryImpl()
);

fResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
   "wsdl", new WSDLResourceFactoryImpl()
);
//   - wsdl reads WSDL resources (from wst project)

// WSDL also needs to know about the extensions to WSDl that we provide,
namely
// partner links, variable properties, etc.
// We need to register them someplace here ...

fResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
   "xsd", new XSDResourceFactoryImpl()
);
//   - xsd reads WSDL resources (from wst project)


fResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
   "fnmeta", new FMResourceFactoryImpl ()
);

// Register the real model query interface, that knows about EMF world
as well.
ModelQueryImpl.register( new ModelQuery() );

// The function library is late bound. When eclipse is running, this
information
/ / is registered via the plugin's descriptor. On its own, we have to do
it another way.

FunctionLibrary.INSTANCE.registerLoader( new
ClasspathFunctionRegistryLoader (fResourceSet) );

// To have a valid logger
BPELPlugin foo = new BPELPlugin();
BPELPlugin.Implementation impl = new BPELPlugin.Implementation();
//
//Step 1. Read the BPEL process using the Model API.
BPELReader reader = new BPELReader();

reader.read(inputFile, fResourceSet );
Process process = reader.getProcess();





Unfortunately, when I run this, it returns a null process and when
looking into it, the parsing ends with the following error message
"Fatal Error in
file:/home/damien/Workspaces/BPEL/org.example.loadbpel/bpel/ldiplom.bpel
[778:21] XML document structures must start and end within the same
entity."

That surprises me since I can open this file without any problem using
the BPEL Eclipse project.

Does anyone have any idea what I am doing wrong?

I would like to be able to manipulate the "process" of my BPEL file.

Many thanks in advance,

--
Damien Thivolle                   |     INRIA Rhone-Alpes / VASY
PHD Student                       |     655, Avenue de l'Europe
damien.thivolle@xxxxxxxx          |     Montbonnot
http://www.inrialpes.fr/vasy      |     38 334 Saint Ismier Cedex France
_______________________________________________
bpel-dev mailing list
bpel-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/bpel-dev

Attachment: pic32214.gif
Description: GIF image


Back to the top