Creating a network of objects from a custom XML configuration using Spring

I have a custom XML configuration defining a network like this

S1 ---- O1 ---- O2 ---- O3 ---- T1
 \
   +--- O4 ---- O5 ------------ T2
    \
S2---+- O6 --+- O7 ------------ T4
    /       /
S3-+       /
          /
S4 ------+

Where

  • S is some kind of data source like a web socket
  • O is a data processing operator
  • T is the target or data receiver

These elements are represented by xml blocks as follows:

<source name="S1" address="ws://example/1" type="websocket" dataType="double" />

<operator name="O6" type="threshold">
    <input name="S1"/>
    <input name="S2"/>
    <input name="S3"/>
    <property name="threshold" value="10.34" />
    <property name="window" value="10.0" />
</operator>

<sink name="T1" type="database">
    <input name="O3"/>
</sink>

Dependencies are constructor options. My operator example O6would have a constructor like this:

class ThresholdOperator extends Operator<Boolean> {

    public ThresholdOperator(
        String name,              // "O6"
        List<DataSource> sources, // [S1, S2, S3]
        double threshold,         // 10.34
        double window) {          // 10.0
    ...

There may be several instances of this class with different constructor parameters. It is possible that a class has more than one constructor. The base class type parameter is the output type.

type , . dataType , ( String to Double) .

, ( ), , , ..

- Spring . Spring ? xml- beans.xml. , , BeanFactory . - Spring ?

Spring 4.3, RC Spring 5 , .

+4
4

StaticApplicationContext. , :

.

... , bean.

XML- beans StaticApplicationContext.

, StaticApplicationContext beans args.

+1

  • XML-, , JAXB Java
  • Java JAXB
+1

"crud" , , xml xml beans xml, XML-.

, a.k.a. bean, bean, spring beans.

.

, .

+1

, , XSLT.

, xsl, xml spring beans xml (XSLT + XPath ).

Then you can read xml, transform with this xsland pass the result to spring.

+1
source

Source: https://habr.com/ru/post/1684807/


All Articles