|
|
|
@@ -1,28 +1,80 @@
|
|
|
|
|
<?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:c="http://www.springframework.org/schema/c"
|
|
|
|
|
xmlns:context="http://www.springframework.org/schema/context"
|
|
|
|
|
xmlns:flow="http://www.springframework.org/schema/webflow-config"
|
|
|
|
|
xmlns:jee="http://www.springframework.org/schema/jee"
|
|
|
|
|
xmlns:jms="http://www.springframework.org/schema/jms"
|
|
|
|
|
xmlns:lang="http://www.springframework.org/schema/lang"
|
|
|
|
|
xmlns:osgi="http://www.springframework.org/schema/osgi"
|
|
|
|
|
xmlns:p="http://www.springframework.org/schema/p"
|
|
|
|
|
xmlns:tx="http://www.springframework.org/schema/tx"
|
|
|
|
|
xmlns:util="http://www.springframework.org/schema/util"
|
|
|
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
|
|
|
|
|
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
|
|
|
|
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
|
|
|
|
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
|
|
|
|
|
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
|
|
|
|
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
|
|
|
|
|
|
|
|
|
<!-- webService -->
|
|
|
|
|
<bean id="serviceBean" class="com.ifish.socket.webService.ServiceBean"></bean>
|
|
|
|
|
<!-- 消息处理类 -->
|
|
|
|
|
<bean id="someServer" class="com.ifish.socket.config.SomeServer"></bean>
|
|
|
|
|
<!-- 实现job中注入bean -->
|
|
|
|
|
<!--<bean name="jobFactory" class="com.ifish.socket.config.JobFactory"/>-->
|
|
|
|
|
<!-- 调度任务 -->
|
|
|
|
|
<!--<bean id="scheduleJob" init-method="init" destroy-method="shutdown" class="com.ifish.socket.config.ScheduleJob"></bean>-->
|
|
|
|
|
|
|
|
|
|
<!-- 自定义的serverHandler -->
|
|
|
|
|
<bean id="serverHandler" class="com.ifish.socket.config.MinaServerHandler"></bean>
|
|
|
|
|
|
|
|
|
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
|
|
|
|
|
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
|
|
|
|
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
|
|
|
|
|
http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd
|
|
|
|
|
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.3.xsd
|
|
|
|
|
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-4.3.xsd
|
|
|
|
|
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-4.3.xsd
|
|
|
|
|
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd
|
|
|
|
|
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
|
|
|
|
|
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd
|
|
|
|
|
">
|
|
|
|
|
<!-- 导入外部的properties文件-->
|
|
|
|
|
<context:property-placeholder location="classpath*:property.properties" ignore-unresolvable="true"/>
|
|
|
|
|
<!-- 指定服务端地址和端口 -->
|
|
|
|
|
<bean id="address" class="com.ifish.socket.config.MyInetSocketAddress">
|
|
|
|
|
<constructor-arg index="0">
|
|
|
|
|
<value>${ifiship}</value>
|
|
|
|
|
</constructor-arg>
|
|
|
|
|
<constructor-arg index="1">
|
|
|
|
|
<value>${ifishport}</value>
|
|
|
|
|
</constructor-arg>
|
|
|
|
|
</bean>
|
|
|
|
|
|
|
|
|
|
</beans>
|
|
|
|
|
<!-- 黑名单filter
|
|
|
|
|
<bean id="minaBlacklistFilter" class="com.ifish.socketNew.filter.MinaBlacklistFilter" init-method="init"></bean> -->
|
|
|
|
|
|
|
|
|
|
<!-- 编码filter -->
|
|
|
|
|
<bean id="codecFilter" class="org.apache.mina.filter.codec.ProtocolCodecFilter">
|
|
|
|
|
<constructor-arg>
|
|
|
|
|
<!-- 自定义的字符编码类 -->
|
|
|
|
|
<bean class="com.ifish.socket.codeFactory.ServerCodecFactory"></bean>
|
|
|
|
|
</constructor-arg>
|
|
|
|
|
</bean>
|
|
|
|
|
|
|
|
|
|
<!-- 日志filter -->
|
|
|
|
|
<bean id="loggingFilter" class="org.apache.mina.filter.logging.LoggingFilter"></bean>
|
|
|
|
|
|
|
|
|
|
<!-- <bean id="noopFilter" class="org.apache.mina.filter.util.NoopFilter"></bean> -->
|
|
|
|
|
|
|
|
|
|
<!-- 连接控制过滤器,对同一IP地址频繁的创建连接的时间间隔进行控制 -->
|
|
|
|
|
<!-- <bean id="connectionThrottleFilter" class="org.apache.mina.filter.firewall.ConnectionThrottleFilter"></bean> -->
|
|
|
|
|
|
|
|
|
|
<!-- 过滤器链 -->
|
|
|
|
|
<bean id="filterChainBuilder" class="org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder">
|
|
|
|
|
<property name="filters">
|
|
|
|
|
<map>
|
|
|
|
|
<!-- <entry key="minaBlacklistFilter" value-ref="minaBlacklistFilter" /> -->
|
|
|
|
|
<entry key="codecFilter" value-ref="codecFilter" />
|
|
|
|
|
<!-- <entry key="loggingFilter" value-ref="loggingFilter" /> -->
|
|
|
|
|
</map>
|
|
|
|
|
</property>
|
|
|
|
|
</bean>
|
|
|
|
|
|
|
|
|
|
<!-- SessionConfig 通过工厂方法注入 -->
|
|
|
|
|
<bean id="sessionConfig" factory-bean="ioAcceptor" factory-method="getSessionConfig">
|
|
|
|
|
<property name="bothIdleTime" value="60" />
|
|
|
|
|
<property name="minReadBufferSize" value="512" />
|
|
|
|
|
<property name="maxReadBufferSize" value="1024" />
|
|
|
|
|
</bean>
|
|
|
|
|
|
|
|
|
|
<!-- 开始运行socket服务 -->
|
|
|
|
|
<bean id="ioAcceptor" class="org.apache.mina.transport.socket.nio.NioSocketAcceptor"
|
|
|
|
|
init-method="bind" destroy-method="unbind">
|
|
|
|
|
<property name="defaultLocalAddress" value="#{address.socketAddress}" />
|
|
|
|
|
<property name="handler" ref="serverHandler" />
|
|
|
|
|
<property name="filterChainBuilder" ref="filterChainBuilder" />
|
|
|
|
|
<property name="reuseAddress" value="true" />
|
|
|
|
|
</bean>
|
|
|
|
|
|
|
|
|
|
</beans>
|