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

📄 shortmessagerepository.java

📁 非常有影响的 j道 论 坛 源码 国外很有明的专家编写的 ....对java爱好者很有参考价值
💻 JAVA
字号:
/*
 * Copyright (c) 2008 Ge Xinying
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jdon.jivejdon.repository;

import java.util.Observable;
import java.util.Observer;

import org.apache.log4j.Logger;

import com.jdon.controller.model.PageIterator;
import com.jdon.jivejdon.dao.AccountDao;
import com.jdon.jivejdon.dao.ShortMessageDao;
import com.jdon.jivejdon.model.Account;
import com.jdon.jivejdon.model.ShortMessage;
import com.jdon.jivejdon.model.ShortMessageState;

/**
 * ShortMessageRepository.java
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * CreateData: Jun 6, 2008
 * </p>
 * 
 * @author GeXinying
 * @version 1.0
 */
public class ShortMessageRepository implements Observer {
	private final static Logger logger = Logger.getLogger(ShortMessageRepository.class);

	private ShortMessageDao shortMessageDao;
	
	private AccountDao accountDao;
	
	public ShortMessageRepository(ShortMessageDao shortMessageDao,AccountDao accountDao) {
		this.shortMessageDao = shortMessageDao;
		this.accountDao = accountDao;
	}
	
	public void updateShortMessage(ShortMessage msg) throws Exception {
		this.shortMessageDao.updateShortMessate(msg);
		
	}

	public Account findTheUser(String userName) {
		return this.accountDao.getAccountByName(userName);
	}

	public void deleteShortMessage(ShortMessage msg) throws Exception {
		this.shortMessageDao.deleteShortMessage(msg.getMsgId());		
	}

	public ShortMessage findShortMessage(Long msgId) {
		logger.debug(" findShortMessage " + msgId);
		ShortMessage sm = this.shortMessageDao.findShortMessage(msgId);
		sm.getShortMessageState().addObserver(this);
		logger.debug(" add =" + sm.getShortMessageState().countObservers());		
		return sm;
	}

	public PageIterator getShortMessages(int start, int count) {
		// TODO Auto-generated method stub
		return this.shortMessageDao.getShortMessages(start, count);
	}

	public PageIterator getReceiveShortMessages(int start, int count, Account account) {
		// TODO Auto-generated method stub
		return this.shortMessageDao.getReceiveShortMessages(start, count, account);
	}

	public PageIterator getSendShortMessages(int start, int count, Account account) {
		// TODO Auto-generated method stub
		return this.shortMessageDao.getSendShortMessages(start, count, account);
	}

	public PageIterator getSaveShortMessages(int start, int count, Account account) {
		// TODO Auto-generated method stub
		return this.shortMessageDao.getSaveShortMessages(start, count, account);
	}

	public void update(Observable obj,Object arg){
		logger.debug(" Observable update ");
		ShortMessageState shortMessageState = (ShortMessageState)obj;
		try {
			this.shortMessageDao.updateShortMessate(shortMessageState.getShortMessage());
		} catch (Exception e) {
			e.printStackTrace();
		}
	  }

}

⌨️ 快捷键说明

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