What is Apache MINA?
Apache's Mina (Multipurpose Infrastructure Networked Applications) is a network application framework that can help users develop high-performance and highly scalable network applications; it provides an abstract, event-driven asynchronous API that enables JavaNIO to operate on various transport protocols (such as TCP /IP, UDP/IP protocol, etc.) for rapid and efficient development.
ApacheMina is also known as:
NIO Framework
Network socket (networkingsocket) class library
Event-driven asynchronous API (note: asynchronous API has also been added in JDK7)
In short: We simply understand that it is a communication framework that encapsulates underlying IO operations and provides high-level operation APIs!
Communication model of Apache MINA
Since I am using object transfer, only object transfer is listed here.
How to use Apache MINA
1. Download the mina compressed package;
2. Import the jar package inside into the project;
3. After completing these two steps, it still cannot be used. If we write the program and start it, the following error will be reported:
SLF4J:Failedtoloadclass"org.slf4j.impl.StaticLoggerBinder".
SLF4J:Seehttp://www.slf4j.org/codes.html#StaticLoggerBinderforfurtherdetails.
Exceptioninthread"main"java.lang.NoClassDefFoundError:org/slf4j/impl/StaticLoggerBinder
aorg.slf4j.LoggerFactory.
Atorg.apache.mina.Core.service.simpleiProcessorPool.
ag.apache.mina.core.polling.AbstractPollingIoAcceptor.
ag.apache.mina.transport.socket.nio.NioSocketAcceptor.
atminaserver.MinaServer.main(MinaServer.java:19)
Causedby:java.lang.ClassNotFoundException:org.slf4j.impl.StaticLoggerBinder
atjava.net.URLClassLoader$1.run(URLClassLoader.java:200)
atjava.security.AccessController.doPrivileged(NativeMethod)
atjava.net.URLClassLoader.findClass(URLClassLoader.java:188)
atjava.lang.ClassLoader.loadClass(ClassLoader.java:306)
atsun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
atjava.lang.ClassLoader.loadClass(ClassLoader.java:251)
atjava.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
...5more
Obviously, the class org/slf4j/impl/StaticLoggerBinder cannot be found, so we need to introduce another jar package, so we need to download slf4j-nop-1.5.2.jar and introduce it into the project.
4. After everything is done, we can write our mina server and client.
it works
it works
it works