嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
随着对外开发政策的不断扩展,国与国之间的商品贸易越来越普遍,对于港口集装箱物流商品的处理也变得越来越紧张和复杂,港口集装箱物流货物存运设备应急调度管理系统是集商品信息,车辆调度,仓库调度,人员调度为一体的综合应急调度管理系统,通过合理的调度安排,使原本复杂的调度工作变得越来越简单,高效,智能,节能。
package common.exception;
public class MotorCarException extends Exception {
public MotorCarException() {
super();
// TODO Auto-generated constructor stub
}
public MotorCarException(String message, Throwable cause) {
super(message, cause);
// TODO Auto-generated constructor stub
}
public MotorCarException(String message) {
super(message);
// TODO Auto-generated constructor stub
}
public MotorCarException(Throwable cause) {
super(cause);
// TODO Auto-generated constructor stub
}
}
package common.exception;
public class UserException extends Exception {
public UserException() {
super();
// TODO Auto-generated constructor stub
}
public UserException(String message, Throwable cause) {
super(message, cause);
// TODO Auto-generated constructor stub
}
public UserException(String message) {
super(message);
// TODO Auto-generated constructor stub
}
public UserException(Throwable cause) {
super(cause);
// TODO Auto-generated constructor stub
}
}
package common.transaction;
import org.hibernate.Session;
import common.util.HibernateSessionFactory;
public class HibernateTransaction implements Transaction {
private org.hibernate.Transaction transaction;
public void beginTransaction() {
Session session = HibernateSessionFactory.getSession();
transaction = session.beginTransaction();
}
public void commit() {
if (transaction != null)
transaction.commit();
}
public void rollback() {
if (transaction != null)
transaction.rollback();
}
}
package common.transaction;
public interface Transaction {
void beginTransaction();
void commit();
void rollback();
}
package common.util;
import service.IMotorCarService;
import service.IUserService;
import service.impl.MotorCarServiceImpl;
import service.impl.UserServiceImpl;
import dao.IMotorCarDao;
import dao.IUserDao;
import dao.impl.MotorCarDaoImpl;
import dao.impl.UserDaoImpl;
public class BeanFactory {
private static IUserDao userDao;
private static IUserService userService;
private static IMotorCarDao motorcarDao;
private static IMotorCarService motorcarService;
public static Object getBean(String beanName) {
if (beanName.equals("userDao")) {
userDao = getUserDao();
return userDao;
}
if (beanName.equals("userService")) {
userService = getUserService();
return userService;
}
if (beanName.equals("motorcarDao")) {
motorcarDao = getMotorCarDao();
return motorcarDao;
}
if (beanName.equals("motorcarService")) {
motorcarService = getMotorCarService();
return motorcarService;
}
return null;
}
synchronized private static IUserDao getUserDao() {
if (userDao == null)
userDao = new UserDaoImpl();
return userDao;
}
synchronized private static IUserService getUserService() {
if (userService == null)
userService = new UserServiceImpl();
return userService;
}
synchronized private static IMotorCarDao getMotorCarDao() {
if (motorcarDao == null)
motorcarDao = new MotorCarDaoImpl();
return motorcarDao;
}
synchronized private static IMotorCarService getMotorCarService() {
if (motorcarService == null)
motorcarService = new MotorCarServiceImpl();
return motorcarService;
}
}
package common.util;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
/**
* Configures and provides access to Hibernate sessions, tied to the
* current thread of execution. Follows the Thread Local Session
* pattern, see {@link http://hibernate.org/42.html }.
*/
public class HibernateSessionFactory {
/**
* Location of hibernate.cfg.xml file.
* Location should be on the classpath as Hibernate uses
* #resourceAsStream style lookup for its configuration file.
* The default classpath location of the hibernate config file is
* in the default package. Use #setConfigFile() to update
* the location of the configuration file for the current session.
*/
private static String CONFIG_FILE_LOCATION = "/common/util/hibernate.cfg.xml";
private static final ThreadLocal<Session> threadLocal = new ThreadLocal<Session>();
private static Configuration configuration = new Configuration();
private static org.hibernate.SessionFactory sessionFactory;
private static String configFile = CONFIG_FILE_LOCATION;
static {
try {
configuration.configure(configFile);
sessionFactory = configuration.buildSessionFactory();
} catch (Exception e) {
System.err
.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
private HibernateSessionFactory() {
}
/**
* Returns the ThreadLocal Session instance. Lazy initialize
* the <code>SessionFactory</code> if needed.
*
* @return Session
* @throws HibernateException
*/
public static Session getSession() throws HibernateException {
Session session = (Session) threadLocal.get();
if (session == null || !session.isOpen()) {
if (sessionFactory == null) {
rebuildSessionFactory();
}
session = (sessionFactory != null) ? sessionFactory.openSession()
: null;
threadLocal.set(session);
}
return session;
}
/**
* Rebuild hibernate session factory
*
*/
public static void rebuildSessionFactory() {
try {
System.out.println(" ");
configuration.configure(configFile);
System.out.println("*****************");
sessionFactory = configuration.buildSessionFactory();
} catch (Exception e) {
System.err
.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}