/**
* ClassName: EmployeeService.java
* Author: qiujy
* CreateTime: Feb 20, 2008
*
* Copyright 2007-2008 ++YONG All rights reserved.
* EMail: qjyong@gmail.com
*/
package com.service;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.dao.StudentDao;
import com.entity.Student;
import com.vo.StudentVO;
public class StudentService {
private StudentDao studentDao;
public StudentService() {
try {
Properties props = new Properties();
// 设置Jboss服务器的JNDI驱动的类名
props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
// 设置Jboss服务器提供命名服务的URL
props.setProperty(Context.PROVIDER_URL, "localhost:1099");
InitialContext ctx = new InitialContext(props);
// looking up SessionBean
studentDao = (StudentDao) ctx.lookup("StudentDaoImpl/remote");
} catch (NamingException e) {
e.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void add(StudentVO student){
studentDao.persist(student.getPO());
}
public void delete(StudentVO student){
studentDao.delete(student.getPO());
}
public void update(StudentVO student){
studentDao.update(student.getPO());
}
public List<StudentVO> findAllStudent(){
List<StudentVO> result = new ArrayList<StudentVO>();
List<Student> list = studentDao.findAllStudent();
int size = list == null ? 0 : list.size();
for (int i = 0; i < size; i++) {
result.add(new StudentVO(list.get(i)));
}
return result;
}
public StudentVO findStudent(Integer id){
Student stu = studentDao.findStudent(id);
return (stu == null ? null : new StudentVO(stu));
}
}
jsf+ejb3.0(对学生实现了增删改查)
5星 · 超过95%的资源 需积分: 9 121 浏览量
2008-10-29
15:31:04
上传
评论 1
收藏 20KB RAR 举报
web_net
- 粉丝: 4
- 资源: 21
最新资源
- yolov5,SSD 可能使用到的一些代码
- 基于c51单片机+DS1302+DHT11温湿度模块+LCD1602显示的万年历硬件原理图+BOM+软件程源码序+仿真图.zip
- NSGA2的MATLAB代码
- Messagepassingtest_GCN_DGL.py
- Sh,Docker 运维好帮手,一招通过 sh 脚本批量快速启动和重启多个Docker 容器
- PCF2123.pdf
- 打开注册表操作.doc
- Windows 常见运行运行库32+64
- WMJUL8iC.html
- 基于3KW光伏并网单相逆变器设计(TMS320F28035控制板+显示板+STM32F103功率板)硬件(原理图+PCB)工程
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页