Comparison of HiveMind and Spring (2)

xiaoxiao2021-03-06  64

Retrieve it. You can see that the structural differences of both from above. First, Spring provides a complete set of components, from the MVC framework of the page to the background database Ormapping, etc., some of which are self-contained, and some provides an interface to integrate third-party excellent components.

In contrast, hivemind is thin. I first thought of the picture of Microsoft COM component model when I saw HiveMind's architecture picture. as follows:

The picture of COM here is to better compare and illustrate the structure of HiveMind.

The difference between HiveMind and Spring is that HiveMind uses a component-oriented architecture. That is to say that every Java class provides a service (Service Point), after registering this service to HiveMind Registry, the client application can use this service name to use the Java class. (See the following code)

Understanding the COM principle may know that if the COM component interface is unchanged, even if the COM's algorithm is fully changed, it is not affected by the client. This is also advocated interface-oriented programming. From this point, HiveMind and CoM are as sufficient. The Spring framework does not have this service-based feature. (The principle of Sprign's implementation is analyzed below).

HiveMind Another feature is to learn from the implementation of the Eclipse plugin. You often see the following XML definition in HiveMind term:

Java code:

Adder.java:

Package tcfhivemindtest;

Public Interface Adder

{

Public Int Add (int Arg0, int arg1);

AdderImpl.java:

Package tcfhivemindtest.impl;

Import tcfhivemindtest.adder;

Public Class AdderImpl Implements Adder

{

Public Int Add (int Arg0, int Arg1)

{

RETURN ARG0 ARG1;

}

}

Hivemain.java:

Package tcfhivemindtest.main;

Import Org.apache.hiveMind.Registry;

Import Org.apache.hiveMind.Impl.registryBuilder;

Import tcfhivemindtest.adder;

Public Class Hivemain

{

Public static void main (string [] args)

{

Registry registry = registrybuilder.constructdefaultRegistry ();

Adder a = (adder) Registry.getService ("tcfhivemindtest.adder", adder.class);

System.out.println ("Result =" A.Add (4, 7));

}

}

The effect after run is as follows:

Adder =

TcfhiveMindtest.adder [debug] Begin Add (4, 7)

TcfhiveMindtest.adder [debug] end add () [11]

Result = 11

There is a small detail above: it is very good for the processing of the function parameters in hivemind, readability.

to be continued

Tian Chunfeng ┏┏━━━━━━┓┓ ┏┏ ┓ ┓ 中 中 中 快乐 ┏ ┓ ┓ ┗ ┗ ━ ┛ ┛ ┗ ┗ ━ ┗ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┳ ┏ ┏ ┓ 秋 欢 欢 欢 欢 欢 欢 世 世 世 世 世 欢 欢 欢 欢 欢 欢 欢 欢 欢┗┗┛ ┗┗┛

转载请注明原文地址:https://www.9cbs.com/read-112421.html

New Post(0)