在运行时生成BPEL的框架?

时间:2011-03-02 10:41:21

标签: runtime bpel

我需要在运行时生成BPEL XML代码。我现在能做到的唯一方法是使用DOM API“裸手”创建XML文档。但必须有一个框架可以简化这种工作,并结合某种对象模型。

我想它看起来应该是这样的:

BPELProcessFactory.CreateProcess().addSequence

你知道吗?

2 个答案:

答案 0 :(得分:2)

Eclipse BPEL designer项目为BPEL 2.0提供EMF模型。生成的代码可用于以编程方式使用方便的API创建BPEL代码。

答案 1 :(得分:0)

万一有人偶然发现了这一点。

是的,可以使用BPEL Model

来完成

以下是生成一个非常简单的BPEL文件的示例代码:

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;
}

依赖项要求您从eclipse安装目录中的 plugins 文件夹中将以下jar添加到项目的构建路径中:

  
      
  • org.eclipse.bpel.model _ *。罐
  •   
  • org.eclipse.wst.wsdl _ *。罐
  •   
  • org.eclipse.emf.common _ *。罐
  •   
  • org.eclipse.emf.ecore _ *。罐
  •   
  • org.eclipse.emf.ecore.xmi _ *。罐
  •   
  • javax.wsdl _ *。罐
  •   
  • org.apache.xerces _ *。罐
  •   
  • org.eclipse.bpel.common.model _ *。罐
  •   
  • IBM模式组件Java _ *。罐
  •   
  • org.eclipse.core.resources _ *。罐
  •   
  • org.eclipse.osgi _ *。罐
  •   
  • org.eclipse.core.runtime _ *。罐
  •   
  • org.eclipse.equinox.common _ *。罐
  •   
  • org.eclipse.core.jobs _ *。罐
  •   
  • org.eclipse.core.runtime.compatibility _ *。罐
  •