Пример #1
0
  public void testPartnerLink() {
    // prepare persistent objects
    // partner link
    PartnerLinkDefinition partnerLink = new PartnerLinkDefinition();
    partnerLink.setName("pl");
    // process
    process.getGlobalScope().addPartnerLink(partnerLink);
    // replier
    replier.setPartnerLink(partnerLink);

    // save objects and load them back
    process = saveAndReload(process);
    replier = getReplier(process);

    // verify the retrieved objects
    assertEquals("pl", replier.getPartnerLink().getName());
  }
 protected void setUp() throws Exception {
   /* the bpel definition uses the jbpm configuration, so create a context before the definition
    * to avoid loading another configuration from the default resource */
   jbpmContext = jbpmConfiguration.createJbpmContext();
   // process and token
   BpelDefinition pd = new BpelDefinition();
   token = new ProcessInstance(pd).getRootToken();
   Scope scope = pd.getGlobalScope();
   // port type 1
   PortType portType1 = new PortTypeImpl();
   portType1.setQName(new QName("pt1"));
   // port type 2
   PortType portType2 = new PortTypeImpl();
   portType2.setQName(new QName("pt2"));
   // partner link type
   PartnerLinkType partnerLinkType = new PartnerLinkTypeImpl();
   partnerLinkType.setQName(new QName("plt"));
   // role 1
   Role role1 = partnerLinkType.createRole();
   role1.setName("r1");
   role1.setPortType(portType1);
   partnerLinkType.setFirstRole(role1);
   // role 2
   Role role2 = partnerLinkType.createRole();
   role2.setName("r2");
   role2.setPortType(portType2);
   partnerLinkType.setSecondRole(role2);
   // partner link
   PartnerLinkDefinition partnerLink = new PartnerLinkDefinition();
   partnerLink.setName("pl1");
   partnerLink.setPartnerLinkType(partnerLinkType);
   partnerLink.setMyRole(role1);
   partnerLink.setPartnerRole(role2);
   scope.addPartnerLink(partnerLink);
   // from
   from.setPartnerLink(partnerLink);
   // initialize scope
   scope.initScopeData(token);
   // provide a way to the partner link definition
   Empty activity = new Empty();
   scope.addNode(activity);
   token.setNode(activity);
 }
 public void setPartnerReference(EndpointReference partnerReference) {
   QName portTypeName = definition.getPartnerRole().getPortType().getQName();
   QName portTypeRef = partnerReference.getPortTypeName();
   // if there is no port type reference
   if (portTypeRef == null) {
     // take it from the partner link definition
     partnerReference.setPortTypeName(portTypeName);
   }
   // otherwise verify it matches the partner link definition
   else if (!portTypeRef.equals(portTypeName)) {
     throw new BpelException(
         "port type mismatch: expected=" + portTypeName + ", found=" + portTypeRef);
   }
   this.partnerReference = partnerReference;
 }
Пример #4
0
  public ReplyAction readReplyAction(Element replyElem, CompositeActivity parent) {
    ReplyAction replyAction = new ReplyAction();

    // partner link
    String partnerLinkName = replyElem.getAttribute(BpelConstants.ATTR_PARTNER_LINK);
    PartnerLinkDefinition partnerLink = parent.findPartnerLink(partnerLinkName);
    if (partnerLink == null) {
      bpelReader.getProblemHandler().add(new ParseProblem("partner link not found", replyElem));
      return replyAction;
    }
    replyAction.setPartnerLink(partnerLink);

    // port type
    Role myRole = partnerLink.getMyRole();
    // BPEL-181 detect absence of my role
    if (myRole == null) {
      bpelReader
          .getProblemHandler()
          .add(new ParseProblem("partner link does not indicate my role", replyElem));
      return replyAction;
    }
    PortType portType = bpelReader.getMessageActivityPortType(replyElem, partnerLink.getMyRole());

    // operation
    Operation operation = bpelReader.getMessageActivityOperation(replyElem, portType);
    if (operation.getStyle() != OperationType.REQUEST_RESPONSE) {
      bpelReader
          .getProblemHandler()
          .add(new ParseProblem("not a request/response operation", replyElem));
      return replyAction;
    }
    replyAction.setOperation(operation);

    // message exchange
    // BPEL-74: map the empty message exchange to null for compatibility with Oracle
    replyAction.setMessageExchange(
        XmlUtil.getAttribute(replyElem, BpelConstants.ATTR_MESSAGE_EXCHANGE));

    // fault name
    Message replyMessage;
    Attr faultNameAttr = replyElem.getAttributeNode(BpelConstants.ATTR_FAULT_NAME);
    if (faultNameAttr != null) {
      QName faultName = XmlUtil.getQNameValue(faultNameAttr);
      replyAction.setFaultName(faultName);

      Fault fault = operation.getFault(faultName.getLocalPart());
      if (fault == null) {
        bpelReader.getProblemHandler().add(new ParseProblem("fault not found", replyElem));
        return replyAction;
      }
      replyMessage = fault.getMessage();
    } else replyMessage = operation.getOutput().getMessage();

    // variable
    VariableDefinition variable =
        bpelReader.getMessageActivityVariable(
            replyElem, BpelConstants.ATTR_VARIABLE, parent, replyMessage);
    replyAction.setVariable(variable);

    // correlations
    Element correlationsElement =
        XmlUtil.getElement(replyElem, BpelConstants.NS_BPEL, BpelConstants.ELEM_CORRELATIONS);
    if (correlationsElement != null)
      replyAction.setCorrelations(
          bpelReader.readCorrelations(correlationsElement, parent, variable));

    return replyAction;
  }
Пример #5
0
  protected void setUp() throws Exception {
    // set up db stuff
    super.setUp();

    // create bpel definition
    BpelProcessDefinition processDefinition =
        new BpelProcessDefinition("testProcess", BpelConstants.NS_EXAMPLES);

    definition =
        WsdlUtil.getFactory().newWSDLReader().readWSDL("", WsdlConverterTest.transform(WSDL_TEXT));
    ImportDefinition importDefinition = processDefinition.getImportDefinition();
    importDefinition.addImport(WsdlUtil.createImport(definition));
    new BpelReader().registerPropertyAliases(importDefinition);

    // partner link type
    PartnerLinkType partnerLinkType =
        importDefinition.getPartnerLinkType(new QName(BpelConstants.NS_EXAMPLES, "plt"));

    // rpc partner link
    PartnerLinkDefinition rpcPartnerLink = new PartnerLinkDefinition();
    rpcPartnerLink.setName("rpcPl");
    rpcPartnerLink.setPartnerLinkType(partnerLinkType);
    rpcPartnerLink.setMyRole(partnerLinkType.getFirstRole());

    // doc partner link
    PartnerLinkDefinition docPartnerLink = new PartnerLinkDefinition();
    docPartnerLink.setName("docPl");
    docPartnerLink.setPartnerLinkType(partnerLinkType);
    docPartnerLink.setMyRole(partnerLinkType.getSecondRole());

    // global scope
    Scope globalScope = processDefinition.getGlobalScope();
    globalScope.addPartnerLink(rpcPartnerLink);
    globalScope.addPartnerLink(docPartnerLink);
    globalScope.setActivity(new Empty());

    // deploy process definition
    bpelGraphSession.deployProcessDefinition(processDefinition);
    // save generated plink id
    rpcPartnerLinkId = rpcPartnerLink.getId();
    docPartnerLinkId = docPartnerLink.getId();

    // create application descriptor
    DeploymentDescriptor deploymentDescriptor = new DeploymentDescriptor();
    deploymentDescriptor.setName(processDefinition.getName());

    InitialContext initialContext = new InitialContext();
    try {
      // link jms administered objects
      initialContext.rebind(
          IntegrationControl.CONNECTION_FACTORY_NAME, new LinkRef("ConnectionFactory"));
      initialContext.rebind("rpcPl", new LinkRef("queue/testQueue"));
      initialContext.rebind("docPl", new LinkRef("queue/testQueue"));

      // configure relation context
      integrationControl =
          JmsIntegrationServiceFactory.getConfigurationInstance(jbpmConfiguration)
              .getIntegrationControl(processDefinition);
      integrationControl.setDeploymentDescriptor(deploymentDescriptor);
      // bind port entries and lookup destinations
      IntegrationControlHelper.setUp(integrationControl, jbpmContext);

      // unlink jms administered objects
      initialContext.unbind(IntegrationControl.CONNECTION_FACTORY_NAME);
      initialContext.unbind("rpcPl");
      initialContext.unbind("docPl");
    } finally {
      initialContext.close();
    }
  }
 public String toString() {
   ToStringBuilder builder = new ToStringBuilder(this).append("name", definition.getName());
   if (partnerReference != null) builder.append("partnerReference", partnerReference);
   return builder.toString();
 }