IfishSocketEnglish/src/main/resources/minaConfig.xml

80 lines
4.0 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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: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" init-method="init"></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>
<!-- 导入外部的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>
<!-- 黑名单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>