简体   繁体   中英

call method java from a maven project in eclipse

I have two maven projects "Bonita-engine"and "activity-engine". these projects are the code source of two BPM engine. My project is to find the common method of these two engine code sources.So I create an API Java to call this Java method. as these methods are on a different project I can not call this method. in fact, I added this two project to the library of my API Java but it doesn't work.

call method getDescription() from bonita-engine maven project

 * Copyright (C) 2015 BonitaSoft S.A.

package org.bonitasoft.engine.bpm.process.impl.internal;

import java.util.Date;

import org.bonitasoft.engine.bpm.internal.NamedElementImpl;
import org.bonitasoft.engine.bpm.process.ProcessInstance;

/**
 * @author Baptiste Mesta
 * @author Matthieu Chaffotte
 * @author Celine Souchet
 */
public class ProcessInstanceImpl extends NamedElementImpl implements ProcessInstance {

@Override
    public String getDescription() {
        return description;
    }
}

call method getDescription() from activiti-engine maven project

    package org.activiti.engine.impl.persistence.entity;

    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import org.activiti.engine.ProcessEngineConfiguration;
    import org.activiti.engine.impl.bpmn.data.IOSpecification;
    import org.activiti.engine.impl.context.Context;

    public class ProcessDefinitionEntityImpl extends AbstractEntity implements ProcessDefinitionEntity, Serializable {

 public ProcessInstanceImpl(final String name) {
        super(name);
    }

    public String getDescription() {
        return description;
      }
    }

API JAVA : call the common method from the two maven project

import org.activiti.bpmn.model.*;
import org.bonitasoft.engine.bpm.process.impl.internal.* ;
import org.bonitasoft.engine.bpm.*;
import java.util.*;
import java.util.Date;
import org.bonitasoft.engine.bpm.internal.*;
import org.bonitasoft.engine.bpm.process.* ;
public class apicommon {

    public  activitiProcess = new ProcessDefinitionEntityImpl() ;
    public String name;
    public  bonitaProcess = new ProcessInstanceImpl(name) ;
public enum bpm {
    activiti , bonita

}
    bpm chose ;


     public apicommon() {

     }
public String getProcessDescription() {
         if(chose==bpm.activiti){
               return  activitiProcess.getDescription() ;
           }else if(chose==bpm.bonita){
            return   bonitaProcess.getDescription();
           } 
        }

i import the package "org.bonitasoft.engine.bpm.process.impl.internal" and the package "org.activiti.engine.impl.persistence.entity" but i can not get access to ProcessInstanceImpl method and ProcessDefinitionEntityImpl method !

@sara, you have to add the 2 projects to the build path of the API java(api common).

  1. Right click on the (api common) java project => Build path => Configure Build Path
  2. Click on the projects tab
  3. Click Add button
  4. add your project1 (bonita) by checking the box next to it
  5. Again add project2 (activiti-engine) usign the same method
  6. Click Apply and OK to close the dialog.
  7. Now your imports should be working.

Edit:

You have not been clear about which import is the problem. More information is necessary to get to the root of the problem.

As regarding the import error, you can Ctrl + click the offending import. This will take you to a page Source Not Found and a button labelled Attach Source . Click the button to search for the location of what I am suspect is an external jar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM