org.arrow.service.WorkflowDeployment.java Source code

Java tutorial

Introduction

Here is the source code for org.arrow.service.WorkflowDeployment.java

Source

/*
 * Copyright 2014 Christian Weber
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.arrow.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.arrow.model.process.Definitions;
import org.arrow.parser.xml.bpmn.BpmnParser;
import org.arrow.parser.xml.bpmn.XStreamBpmnParser;
import org.arrow.runtime.service.RepositoryService;

import java.io.InputStream;

/**
 * This class can be used to deploy a bpmn business process.
 *
 * @since 1.0.0
 * @author christian.weber
 */
@Component
public class WorkflowDeployment {

    @Autowired
    private RepositoryService repositoryService;

    public void deploy(String path, Class<?> testClass) {
        BpmnParser driver = new XStreamBpmnParser();
        InputStream stream = testClass.getResourceAsStream(path);
        Definitions definitions = driver.parse(stream);

        repositoryService.deploy(definitions);
    }

}