modulemanagerimpl.java

来自「《JSP网站开发典型模块与实例精讲》一书光盘源码」· Java 代码 · 共 109 行

JAVA
109
字号
package org.appfuse.service.impl;

import java.util.List;
import org.appfuse.service.*;
import org.appfuse.dao.ModuleDAO;
import org.appfuse.model.Module;
import org.appfuse.util.exception.*;

public class ModuleManagerImpl
    extends BaseManager
    implements ModuleManager {
    private ModuleDAO dao;

    /**
     * Set the DAO for communication with the data layer.
     *
     * @param dao
     */
    public void setModuleDAO(ModuleDAO dao) {
        this.dao = dao;
    }

    /**
     * @see org.appfuse.service.UserManager#getUser(java.lang.String)
     */
    public Module getModule(int moduleid) throws AppSystemException,
        AppBusinessException {
        Module module = null;
        try {
            module = dao.getModule(moduleid);
        }
        catch (Exception e) {
            log.error("获取模块信息失败!", e);
            throw new AppBusinessException(e.getMessage(), e,
                                           ExceptionConstants.SYS_GENERAL_ERR);
        }
        return module;
    }

    /**
     * @see org.appfuse.service.UserManager#getUsers(org.appfuse.model.User)
     */
    public List getModules(Module module) throws AppSystemException,
        AppBusinessException {
        List list = null;
        try {
            list = dao.getModules(module);
        }
        catch (Exception e) {
            log.error("获取模块列表失败!", e);
            throw new AppBusinessException(e.getMessage(), e,
                                           ExceptionConstants.SYS_GENERAL_ERR);
        }
        return list;
    }

    /**
     * @see org.appfuse.service.UserManager#saveUser(org.appfuse.model.User)
     */
    public void saveModule(Module module) throws AppSystemException,
        AppBusinessException {
        try {
            dao.saveModule(module);
        }
        catch (Exception e) {
            log.error("保存模块失败!", e);
            throw new AppBusinessException(e.getMessage(), e,
                                           ExceptionConstants.SYS_GENERAL_ERR);
        }

    }

    /**
     * @see org.appfuse.service.UserManager#removeUser(java.lang.String)
     */
    public void removeModule(int moduleid) throws AppSystemException,
        AppBusinessException {
        if (log.isDebugEnabled()) {
            log.debug("removing module: " + moduleid);
        }
        try {
            dao.removeModule(moduleid);
        }
        catch (Exception e) {
            log.error("删除模块失败!", e);
            throw new AppBusinessException(e.getMessage(), e,
                                           ExceptionConstants.SYS_GENERAL_ERR);
        }

    }

    public List getFunctions(int moduleid) throws AppSystemException,
        AppBusinessException {
        if (log.isDebugEnabled()) {
            log.debug("removing user: " + moduleid);
        }
        try {
            return dao.getFunctions(moduleid);
        }
        catch (Exception e) {
            log.error("获取模块动作失败!", e);
            throw new AppBusinessException(e.getMessage(), e,
                                           ExceptionConstants.SYS_GENERAL_ERR);
        }

    }

}

⌨️ 快捷键说明

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