⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 studentserviceimpl.java

📁 Spring in Action 源码
💻 JAVA
字号:
package com.springinaction.training.service;import java.util.HashSet;import net.sf.acegisecurity.context.ContextHolder;import net.sf.acegisecurity.context.SecureContext;import org.apache.log4j.Logger;import com.springinaction.training.dao.*;import com.springinaction.training.model.*;public class StudentServiceImpl implements StudentService {  Logger LOGGER = Logger.getLogger(StudentServiceImpl.class);    private StudentDao studentDao;  public StudentServiceImpl(StudentDao dao) {    studentDao = dao;  }  public Student getStudent(String login) {    return studentDao.findById(login);  }  public void registerStudent(Student student) {    HashSet authorities = new HashSet();    authorities.add(new Authority("ROLE_STUDENT"));    authorities.add(new Authority("ROLE_USER"));    student.setAuthorities(authorities);    studentDao.create(student);  }  public java.util.Set getCompletedCourses(Student student) {    return studentDao.getCompletedCourses(student);  }    /*   * TODO - This could be used more generically for Instructors as well.   * But since it's only used for Students right now and because it would   * be silly to create a UserService for this simple method, we'll just   * put it here for now.   */  public String getCurrentUserId() {    return ((SecureContext)ContextHolder.getContext()).getAuthentication().getPrincipal().toString();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -