Framework for generating BPEL in runtime?

谁说我不能喝 提交于 2019-12-10 18:09:21

问题


I need to generate BPEL XML code in runtime. The only way I can do it now is to create XML document with "bare hands" using DOM API. But there must be a framework that could ease such work incorporating some kind of object model.

I guess it should look something like this:

BPELProcessFactory.CreateProcess().addSequence

Do you know any?


回答1:


The Eclipse BPEL designer project provides an EMF model for BPEL 2.0. The generated code can be used to programmatically create BPEL code with a convenient API.




回答2:


In case anyone stumbles upon this.

Yes this can be done using the BPEL Model.

Here is a sample piece of code which generates a quite trivial BPEL file:

public Process createBPEL()
{
    Process process = null;
    BPELFactory factory = BPELFactory.eINSTANCE;

    try
    {
        ResourceSet rSet = new ResourceSetImpl();
        rSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
                .put("bpel", new BPELResourceFactoryImpl());
        File file = new File("myfile.bpel");
        file.createNewFile();
        String filePath = file.getAbsolutePath();
        System.out.println(filePath);
        AdapterRegistry.INSTANCE.registerAdapterFactory( BPELPackage.eINSTANCE, BasicBPELAdapterFactory.INSTANCE );
        Resource resource = rSet.createResource(URI.createFileURI(filePath));

        process = factory.createProcess();
        process.setName("FirstBPEL");
        Sequence seq = factory.createSequence();
        seq.setName("MainSequence");

        Receive recieve = factory.createReceive();
        PortType portType = new PortTypeProxy(URI.createURI("http://baseuri"), new QName("qname"));
        Operation operation = new OperationProxy(URI.createURI("http://localhost"), portType , "operation_name");
        recieve.setOperation(operation);

        Invoke invoke = factory.createInvoke();
        invoke.setOperation(operation);


        While whiles = factory.createWhile();
        If if_st = factory.createIf();

        List<Activity> activs = new ArrayList<Activity>();

        activs.add(recieve);
        activs.add(invoke);
        activs.add(if_st);
        activs.add(whiles);


        seq.getActivities().addAll(activs);

        process.setActivity(seq);

        resource.getContents().add(process);

        Map<String,String> map = new HashMap<String, String>();
        map.put("bpel", "http://docs.oasis-open.org/wsbpel/2.0/process/executable");
        map.put("xsd", "http://www.w3.org/2001/XMLSchema");

        resource.save(map);
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }

    return process;
}

The dependencies require that you add the following jars to the project's build path from the plugins folder in eclipse installation directory:

  • org.eclipse.bpel.model_*.jar
  • org.eclipse.wst.wsdl_*.jar
  • org.eclipse.emf.common_*.jar
  • org.eclipse.emf.ecore_*.jar
  • org.eclipse.emf.ecore.xmi_*.jar
  • javax.wsdl_*.jar
  • org.apache.xerces_*.jar
  • org.eclipse.bpel.common.model_*.jar
  • org.eclipse.xsd_*.jar
  • org.eclipse.core.resources_*.jar
  • org.eclipse.osgi_*.jar
  • org.eclipse.core.runtime_*.jar
  • org.eclipse.equinox.common_*.jar
  • org.eclipse.core.jobs_*.jar
  • org.eclipse.core.runtime.compatibility_*.jar


来源:https://stackoverflow.com/questions/5166287/framework-for-generating-bpel-in-runtime

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!