初识Spring

xml文件配置

<?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.5.xsd  
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd  
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd  
           ">  
	<bean id="tou" class="com.OnlineGame.entity.Equip">
		<property name="name" value="战神头盔"/>
		<property name="type" value="头盔"/>
		<property name="speedPlus" value="2"/>
		<property name="attackPlus" value="4"/>
		<property name="defencePlus" value="6"/>
	</bean>
	<bean id="jia" class="com.OnlineGame.entity.Equip">
		<property name="name" value="连环锁子甲"/>
		<property name="type" value="甲"/>
		<property name="speedPlus" value="6"/>
		<property name="attackPlus" value="4"/>
		<property name="defencePlus" value="15"/>
	</bean>
	<bean id="xie" class="com.OnlineGame.entity.Equip">
		<property name="name" value="战神头盔"/>
		<property name="type" value="头盔"/>
		<property name="speedPlus" value="2"/>
		<property name="attackPlus" value="4"/>
		<property name="defencePlus" value="6"/>
	</bean>
	<bean id="huan" class="com.OnlineGame.entity.Equip">
		<property name="name" value="战神头盔"/>
		<property name="type" value="头盔"/>
		<property name="speedPlus" value="2"/>
		<property name="attackPlus" value="4"/>
		<property name="defencePlus" value="6"/>
	</bean>
	<bean id="onlineGameBiz" class="com.OnlineGame.biz.impl.OnlineGameBizImpl"></bean>
	<bean id ="onlineGameLoggerBefore" class="com.OnlineGame.advice.OnlineGameLoggerBefore"></bean>
	<bean id ="onlineGameLoggerAfterReturning" class="com.OnlineGame.advice.OnlineGameLoggerAfterReturning"></bean>
	<aop:config>
		<aop:pointcut id="pointcut"
		expression="execution(* com.OnlineGame.biz..*.updateEquip(..))"/>
		<aop:advisor pointcut-ref="pointcut" advice-ref="onlineGameLoggerBefore"/>
		<aop:advisor pointcut-ref="pointcut" advice-ref="onlineGameLoggerAfterReturning"/>
		
	</aop:config>
</beans>

 实体

package com.OnlineGame.entity;

import java.io.Serializable;
//装备
public class Equip implements Serializable{
	private String name;		//装备名称
	private String type;		//装备类型、头盔、铠甲等
	private Long speedPlus;		//速度增效
	private Long attackPlus;	//攻击增效
	private Long defencePlus;	//防御增效
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public Long getSpeedPlus() {
		return speedPlus;
	}
	public void setSpeedPlus(Long speedPlus) {
		this.speedPlus = speedPlus;
	}
	public Long getAttackPlus() {
		return attackPlus;
	}
	public void setAttackPlus(Long attackPlus) {
		this.attackPlus = attackPlus;
	}
	public Long getDefencePlus() {
		return defencePlus;
	}
	public void setDefencePlus(Long defencePlus) {
		this.defencePlus = defencePlus;
	}
}

 

package com.OnlineGame.entity;

import java.io.Serializable;
//玩家
public class Player implements Serializable {
	private Equip armet;	//头盔
	private Equip loricae;	//铠甲
	private Equip boot;		//靴子
	private Equip ring ;	//指环
	public Equip getArmet() {
		return armet;
	}
	public void setArmet(Equip armet) {
		this.armet = armet;
	}
	public Equip getLoricae() {
		return loricae;
	}
	public void setLoricae(Equip loricae) {
		this.loricae = loricae;
	}
	public Equip getBoot() {
		return boot;
	}
	public void setBoot(Equip boot) {
		this.boot = boot;
	}
	public Equip getRing() {
		return ring;
	}
	public void setRing(Equip ring) {
		this.ring = ring;
	}
}

 运行结果:

 

posted @ 2017-09-17 00:00  pzpziop  阅读(251)  评论(0)    收藏  举报