8
8
import java .util .Map ;
9
9
10
10
import org .jboss .as .controller .Feature ;
11
- import org .jboss .as .controller .PersistentResourceXMLDescription ;
12
- import org .jboss .as .controller .PersistentSubsystemSchema ;
13
11
import org .jboss .as .controller .SubsystemSchema ;
12
+ import org .jboss .as .controller .persistence .xml .ResourceRegistrationXMLElement ;
13
+ import org .jboss .as .controller .persistence .xml .ResourceXMLParticleFactory ;
14
+ import org .jboss .as .controller .persistence .xml .SubsystemResourceRegistrationXMLElement ;
15
+ import org .jboss .as .controller .persistence .xml .SubsystemResourceXMLSchema ;
14
16
import org .jboss .as .controller .xml .VersionedNamespace ;
15
17
import org .jboss .as .version .Stability ;
16
18
import org .jboss .staxmapper .IntVersion ;
17
19
18
20
/**
19
21
* @author Paul Ferraro
20
22
*/
21
- public enum FooSubsystemSchema implements PersistentSubsystemSchema <FooSubsystemSchema > {
23
+ public enum FooSubsystemSchema implements SubsystemResourceXMLSchema <FooSubsystemSchema > {
22
24
VERSION_1_0 (1 ),
23
25
VERSION_1_0_PREVIEW (1 , Stability .PREVIEW ),
24
26
VERSION_1_0_EXPERIMENTAL (1 , Stability .EXPERIMENTAL ),
25
27
;
26
28
static final Map <Stability , FooSubsystemSchema > CURRENT = Feature .map (EnumSet .of (VERSION_1_0 , VERSION_1_0_PREVIEW , VERSION_1_0_EXPERIMENTAL ));
27
29
28
30
private final VersionedNamespace <IntVersion , FooSubsystemSchema > namespace ;
31
+ private final ResourceXMLParticleFactory factory = ResourceXMLParticleFactory .newInstance (this );
29
32
30
33
FooSubsystemSchema (int major ) {
31
- this . namespace = SubsystemSchema . createSubsystemURN ( FooSubsystemResourceDefinition . SUBSYSTEM_NAME , new IntVersion ( major ) );
34
+ this ( major , Stability . DEFAULT );
32
35
}
33
36
34
37
FooSubsystemSchema (int major , Stability stability ) {
35
- this .namespace = SubsystemSchema .createSubsystemURN (FooSubsystemResourceDefinition .SUBSYSTEM_NAME , stability , new IntVersion (major ));
38
+ this .namespace = SubsystemSchema .createSubsystemURN (FooSubsystemResourceDefinition .REGISTRATION . getName () , stability , new IntVersion (major ));
36
39
}
37
40
38
41
@ Override
@@ -41,11 +44,13 @@ public VersionedNamespace<IntVersion, FooSubsystemSchema> getNamespace() {
41
44
}
42
45
43
46
@ Override
44
- public PersistentResourceXMLDescription getXMLDescription () {
45
- PersistentResourceXMLDescription .Factory factory = PersistentResourceXMLDescription .factory (this );
46
- PersistentResourceXMLDescription .Builder builder = factory .builder (FooSubsystemResourceDefinition .PATH );
47
- builder .addAttributes (FooSubsystemResourceDefinition .ATTRIBUTES .stream ());
48
- builder .addChild (factory .builder (BarResourceDefinition .REGISTRATION ).addAttribute (BarResourceDefinition .TYPE ).build ());
49
- return builder .build ();
47
+ public SubsystemResourceRegistrationXMLElement getSubsystemXMLElement () {
48
+ ResourceRegistrationXMLElement barElement = this .factory .namedElement (BarResourceDefinition .REGISTRATION )
49
+ .addAttribute (BarResourceDefinition .TYPE )
50
+ .build ();
51
+ return this .factory .subsystemElement (FooSubsystemResourceDefinition .REGISTRATION )
52
+ .addAttributes (FooSubsystemResourceDefinition .ATTRIBUTES )
53
+ .withContent (this .factory .sequence ().addElement (barElement ).build ())
54
+ .build ();
50
55
}
51
56
}
0 commit comments