---
title: "我新闻发布系统和实验室设备管理系统截图"
author: "oak2008"
date: "2007-11-22T19:11:05Z"
tags: []
categories: ["互联网"]
slug: "untitled"
draft: false
lastmod: "2012-06-07T01:46:19Z"
id: 142771
url: "https://oak2008.iteye.com/blog/142771"
---

<u>1.新闻发布系统截图---JSF+EJB3.0</u>
![](http://hiphotos.baidu.com/kennylin2008/pic/item/f123241b092c39e3ae513345.jpg)
![](http://photo.store.qq.com/http_imgload.cgi?/rurl2=25a6d507727c86f1b61c930cadd6760da7b9ae25c991d4ef07e3da7c5eb1de658184dff9602f73d02d940e56cf76de805f2193a81218e7ad4f9f024d07dd403d4d5ecc768d65719d1fd2bbb8729240698b9f761a)
![](http://photo.store.qq.com/http_imgload.cgi?/rurl2=8c90dda1511f6040faf6bb98cc893d04a352e46c0c39169c1e7cddad254fdfdb1539f64131c11ebe508fa89fd4b458bb23232b6a73bca4721d2bc8dec4573b4e797cc6954cc1f3547e53ab5fb8492bd5e774f858)
2.实验室设备管理系统---JSF(Tomahawk)+Spring2.0+Hibernate3.2
![](http://photo.store.qq.com/http_imgload.cgi?/rurl2=74627c4b70e23d99d1e92207645b37139535214572f5806f25ae249aca0c835660a96b3bd8ebb115e9f0de34ac314d936f97455b170fe22050bf84fbdac33a995ce9c4a847c2e1528603365053f0cb887942adc9)

![](http://photo.store.qq.com/http_imgload.cgi?/rurl2=ca8eed43dd45427418c84772b9e6143d4e179406e51b2549e055ed73b46caa7216c9fdf3669f3ea73efc792fc04e7e47e55e56b445067f274d998c912e4c5d484091ea483b638c8c68b6acade2c73aed30f0e859)
![](http://photo.store.qq.com/http_imgload.cgi?/rurl2=7274cf4ca216cc2beaca21d0d3da73dcffc589c2c32cc106a2591bd1dd464438e8b6d566d95da469df70bd6af7083963603b7cd56fbf520b8812ee52d64208d674918e7797903094f626a3ff1dd11520ce718130)
![](http://photo.store.qq.com/http_imgload.cgi?/rurl2=537836532c33b660a99d9882168fe153c7714923fd9f411f014a213bdf9b9e91c5ddf409959c2c590ed59772668b3b64e04f1775d1f4cbf8b5b7c4085c952a511d435491e78a9ebe0557a4b21494c41270c13d83)
![](http://photo.store.qq.com/http_imgload.cgi?/rurl2=2b15df886d6993a8010c7b55291c5eeb9b52e185722acaeaed4faad48600f70161787ee26a14ab70b8b77cb8f58f68b2f3c4a816b516855c4753c925528622986156b12739bbb3196a99f089098e9236b71a18fe)
![](http://photo.store.qq.com/http_imgload.cgi?/rurl2=300a7bff9159e93c348d218cb75f1d9bdf8144496a45622d20c80a96fbfa69356ac3a0be2f1696e8d3c6e3a30263d2419d716610f4c93664151652cfb73cf2aff2684603367b5c4a3d97236ee3034a0e893b0a56)

我设计的部分超类:
/*
 * EntityManagerDAOImpl.java
 *
 * Created on 2007年10月6日, 下午2:29
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.dgut.lab.model.dao.impl;

import java.sql.SQLException;
import java.util.List;
import org.dgut.lab.model.dao.EntityManagerDAO;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.HibernateTemplate;

/**
 *
 * @author LinChunyu
 */
public class EntityManagerDAOImpl implements EntityManagerDAO{
    private HibernateTemplate hibernateTemplate;
    /** Creates a new instance of EntityManagerDAOImpl */
    public EntityManagerDAOImpl() {
    }
    
    public void delete(Object persistentInstance) {
        hibernateTemplate.delete(persistentInstance);
    }
    
    public Object findById(Class cl,int id) {
        
        return  hibernateTemplate.get(cl, id);
        
    }
    
    public Object merge(Object detachedInstance) {
        return   hibernateTemplate.merge(detachedInstance);
    }
    
    public void persist(Object transientInstance) {
        hibernateTemplate.persist(transientInstance);
    }
    
    public List execute(final String qry,final Object p) {
        
        List list=(List)hibernateTemplate.execute(new HibernateCallback(){
            
            public Object doInHibernate(Session session)
            throws HibernateException, SQLException {
                List list = null;
                Query q = session.createQuery(qry);
                
                if(p!=null){
                    for (int i = 0; i < p.length; i++) {
                        q.setParameter(i, p*);
                    }
                }
                
                return list = q.list();
            }
            
        });
        return list;
    }
    
    public List execute(final String qry,final Object p,final int batchSize,final int firstItem) {
        
        List list=(List)hibernateTemplate.execute(new HibernateCallback(){
            
            public Object doInHibernate(Session session)
            throws HibernateException, SQLException {
                List list = null;
                Query q = session.createQuery(qry);
                if(p!=null){
                    for (int i = 0; i < p.length; i++) {
                        q.setParameter(i, p*);
                    }
                }
                q.setMaxResults(batchSize);
                q.setFirstResult(firstItem);
                return list = q.list();
            }
            
        });
        return list;
    }
    public void setSessionFactory(SessionFactory sessionFactory) {
        this.hibernateTemplate = new HibernateTemplate(sessionFactory);
    }
    
}



package org.dgut.lab.view.controller;


import java.util.Locale;
import java.util.ResourceBundle;
import java.util.logging.Logger;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

import org.dgut.lab.model.servicelocator.ServiceLocator;

public class BaseController {
    
    protected ServiceLocator serviceLocator;
    
    protected final Logger log = Logger.getLogger(this.getClass().getName());
    
    private int command=0;
    
    protected int pageNo=1;
    
    protected long itemCount;
    
    protected int totalPage;
    
    protected int batchSize=4;
    
    public BaseController() {
        
    }
    
    public void init() {
        
    }
    
    public void setServiceLocator(ServiceLocator newServiceLocator) {
        this.serviceLocator = newServiceLocator;
        init();
    }
    
    public static void addErrorMessage(String msg1) {
        String msg=getMessageString(msg1);
        FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR,
                msg, msg);
        FacesContext fc = FacesContext.getCurrentInstance();
        fc.addMessage(null, facesMsg);
    }
    
    public static void addSuccessMessage(String msg1) {
        String msg=getMessageString(msg1);
        FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO,
                msg, msg);
        FacesContext fc = FacesContext.getCurrentInstance();
        fc.addMessage("successInfo", facesMsg);
    }
    public  static String getMessageString(String name) {
        String str = "";
        FacesContext facesContext = FacesContext.getCurrentInstance();
        String bundleName = facesContext.getApplication().getMessageBundle();
        if (bundleName != null) {
            Locale locale = facesContext.getViewRoot().getLocale();
            /*ResourceBundle bundle = ResourceBundle.getBundle(bundleName,
                    locale, getCurrentClassLoader(params));*/
            
            ResourceBundle bundle = ResourceBundle.getBundle(bundleName,
                    locale);
            
            /*ResourceBundle bundle = ResourceBundle.getBundle(bundleName,
                    locale, getCurrentClassLoader(params));*/
            str = bundle.getString(name);
        }
        return str;
    }
    
    private static ClassLoader getCurrentClassLoader(Object params) {
        return params.getClass().getClassLoader();
    }
    
    public long getItemCount() {
        return this.itemCount;
    }
    
    public int getPageNo() {
        return pageNo;
    }
    
    public int getTotalPage() {
        long totalPage1 = getItemCount() % 20 == 0 ? getItemCount() /batchSize
                : getItemCount() / batchSize + 1;
        totalPage=Integer.parseInt(String.valueOf(totalPage1));
        return this.totalPage;
    }
    
    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }
    
    public void setItemCount(long itemCount) {
        this.itemCount = itemCount;
    }

    public int getCommand() {
        return command;
    }

    public void setCommand(int command) {
        this.command = command;
    }
}

Spring配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
    
    <!-- ****************** DataSource ********************* -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
        <property name="driverClass">
            <value>com.mysql.jdbc.Driver</value>
        </property>
        <property name="jdbcUrl">
            <value>jdbc:mysql://localhost:3306/devicemanage</value>
        </property>
        <property name="user">
            <value>root</value>
        </property>
        <property name="password">
            <value>123456</value>
        </property>
        <property name="initialPoolSize"><value>10</value></property>
        <property name="minPoolSize"><value>5</value></property>
        <property name="maxPoolSize"><value>30</value></property>
        <property name="acquireIncrement"><value>5</value></property>
        <property name="maxIdleTime"><value>10</value></property>
        <property name="maxStatements"><value>0</value></property>
    </bean>
    
    <!-- ****************** SessionFactory ********************* -->
    <bean id="sessionFactory"
          class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.MySQLDialect
                </prop>
                <prop key="hibernate.show_sql">
                    true
                </prop>
            </props>
        </property>
        <property name="mappingResources">
            <list>
                <value>org/dgut/lab/model/entity/Voucher.hbm.xml</value>
                <value>org/dgut/lab/model/entity/Device.hbm.xml</value>
                <value>org/dgut/lab/model/entity/User.hbm.xml</value>
                <value>org/dgut/lab/model/entity/VoucherDevice.hbm.xml</value>
                <value>org/dgut/lab/model/entity/ManageLog.hbm.xml</value>
                <value>org/dgut/lab/model/entity/Country.hbm.xml</value>
                <value>org/dgut/lab/model/entity/PowerList.hbm.xml</value>
            </list>
        </property>
    </bean>
    
    <!-- ****************** Transaction ********************* -->
    <bean id="txManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    
    <!--  -->
    <tx:advice id="txAdvice" transaction-manager="txManager">
        <tx:attributes>
            <!-- all methods starting with 'get' are read-only -->
            <tx:method name="get*" read-only="true" />
            <!-- other methods use the default transaction settings (see below) -->
            <tx:method name="*" />
        </tx:attributes>
    </tx:advice>
    
    <aop:config>
        <aop:pointcut id="fooServiceOperation"
                      expression="execution(* org.dgut.lab.model.service.*Service.*(..))" />
        <aop:advisor advice-ref="txAdvice"
                     pointcut-ref="fooServiceOperation" />
        
    </aop:config>
    
    <!-- ****************** Service Locator ********************* -->
    <bean id="serviceLocator"
          class="org.dgut.lab.model.servicelocator.ServiceLocatorImpl">
        
        <property name="userService">
            <ref bean="userService" />
        </property>
        
        <property name="loanService">
            <ref bean="loanService" />
        </property>
        
        <property name="deviceService">
            <ref bean="deviceService" />
        </property>
        
    </bean>
    
    <!-- ****************** DAO ********************* -->


    <bean id="entityManagerDAO"
          class="org.dgut.lab.model.dao.impl.EntityManagerDAOImpl">
        <property name="sessionFactory">
            <ref bean="sessionFactory" />
        </property>
    </bean>
    
    <!-- ****************** Service ********************* -->
   
   
    <bean id="deviceService"
          class="org.dgut.lab.model.service.impl.DeviceServiceImpl">
        <property name="entityManagerDAO">
            <ref bean="entityManagerDAO" />
        </property>
    </bean>
    
    <bean id="loanService"
          class="org.dgut.lab.model.service.impl.LoanServiceImpl">
        <property name="entityManagerDAO">
            <ref bean="entityManagerDAO" />
        </property>
    </bean>
    <bean id="userService"
          class="org.dgut.lab.model.service.impl.UserServiceImpl">
        <property name="entityManagerDAO">
            <ref bean="entityManagerDAO" />
        </property>
    </bean>
 </beans>

3.数据库查询分析处理器---RMI+JDBC+Swing
![](http://photo.store.qq.com/http_imgload.cgi?/rurl2=d1c2f68b4aa4625f61a04530cfc023bc3764e0497660311e4a14426b96b39585d5187d9c95ef852e680d0a0f857075076c17fb5e29af11689a033e9b42310690dfa7e0c3cd78d6dc29220f6f0f53bcb9a8d94e3b)