Package jbprocessor

Source Code of jbprocessor.BpelProcessor

package jbprocessor;

import java.util.Collections;
import java.util.List;

import jbprocess.JbprocessMappingBuilder;
import jbprocess.bpel.xpath.XpathFactory;
import jbprocess.bpel.xpath.impl.XpathFactoryImpl;
import spoon.processing.AbstractManualProcessor;
import spoon.processing.Property;
import spoon.processing.Severity;


@SuppressWarnings("unchecked")
public class BpelProcessor extends AbstractManualProcessor {
 
  @Property
  boolean outputFiles = true;
 
  @Property
  String mappingBuilderFactoryClass = "";
 
  @Property
  String projectName = "<default>";
 
  @Property
  String outputDirectory = ".\\output\\";
 
  List<JbprocessMappingBuilder> builders = Collections.EMPTY_LIST;
 
  public BpelProcessor(){
    if (mappingBuilderFactoryClass.equals(""))
      this.mappingBuilderFactoryClass = "jbprocessor.DefaultMappingFactory";
 
 
  @SuppressWarnings("unchecked")
  public void init(){

    getEnvironment().reportProgressMessage("JavaToBpel Spoon Processor.");   
    getEnvironment().reportProgressMessage("Preparing to Parse...");
    getEnvironment().reportProgressMessage("Parsing...");
   
    boolean status = false;
    try {
     
      Class factoryClass = Class.forName(mappingBuilderFactoryClass);
      if (factoryClass != null){
        BuilderFactoryProxy factory = new BuilderFactoryProxy(factoryClass);       
       
        builders = factory.getBuilders();
        fireStartEvent();
       
        XpathFactory xpathFactory = new XpathFactoryImpl();       
        BpelScanner bpelScanner = new BpelScanner(getFactory(),
            xpathFactory,
            builders);       
       
        getEnvironment().reportProgressMessage("Scanning...");
        bpelScanner.scan(getFactory().Package().getAllRoots());
        bpelScanner.write(factory.getOutputDirectory());
       
        status = true;
      }     
    } catch (Exception e){     
      System.out.println(e.getMessage());
      e.printStackTrace();
      getEnvironment().report(this, Severity.ERROR, null, "Exception during scanning.  Exception = " + e.getMessage());
      status = false;
    } finally{
      fireStopEvent(status);
    }
   
    getEnvironment().reportProgressMessage("Complete.");
  }
  public void process() {
    // needed this to compile ???
  }
 
  private void fireStartEvent(){
    try {
      for (JbprocessMappingBuilder builder : builders){
        builder.buildStart(projectName,outputDirectory);
      }     
    } catch(Exception e){
     
    }
  }
  private void fireStopEvent(boolean status){
    try {
      for (JbprocessMappingBuilder builder : builders){
        builder.buildComplete(status);
      }
    } catch(Exception e){
     
    }
  }
}
TOP

Related Classes of jbprocessor.BpelProcessor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.