通过将用户实例作为参数传递来调用方法

时间:2016-08-22 07:51:00

标签: java spring

我试图通过将用户实例作为参数传递来调用方法,但是我不知道我错了什么,因为它没有被调用,但是当我传递单个对象属性时,它是工作正常。我正在尝试从getCurrentProfitAndLoss()块调用方法try

public Double getCurrentProfitAndLoss(){
    Double currentProfitAndLoss = null;
    Userr user = ((OptionsUser)SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserr();
    //user = Userr.findUserr(user.getId());
    HomePageService homePageService = homePageServiceFactory.getObject();
    System.out.println("homePageService object  created" + user.toString());
    try {
        currentProfitAndLoss = homePageService.getCurrentProfitAndLoss(user);
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
    return currentProfitAndLoss;
}

应该调用此类,但不会调用它。但是,当我将user.getId()作为参数传递时,它工作正常。

    import com.uforic.optionstrader.domain.Userr;

    @Component(value = "HomePageService")
    @Scope(value = "prototype")
    public class HomePageService {
    public Double getCurrentProfitAndLoss(Userr user) {
        System.out.println("iside HOmepageService" + user);
        Double currentProfitPercPA =     StrategyExitReport.findCurrentProfitAndLossById(user);
        System.out.println("iside currentProfitPercPA" + currentProfitPercPA);
        return currentProfitPercPA;
    }
/**
     * Returns currentProfitPercPA.
     * @return
     */
}

0 个答案:

没有答案