在运行时生成 BPEL 的框架?

发布于 2024-10-19 15:43:07 字数 202 浏览 3 评论 0原文

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

我想它应该看起来像这样:

BPELProcessFactory.CreateProcess().addSequence

你知道吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三人与歌 2024-10-26 15:43:07

Eclipse BPEL 设计器 项目为 BPEL 2.0 提供了 EMF 模型。生成的代码可用于通过方便的 API 以编程方式创建 BPEL 代码。

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.

家住魔仙堡 2024-10-26 15:43:07

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

是的,这可以使用 BPEL 模型 来完成。

下面是一段生成非常简单的 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;
}

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

  • 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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文