Now that we have all the code needed for our subsystem, we can build our project by running mvn install
This will have built our project and assembled a module for us that can be used for installing it into JBoss AS 7. If you go to the target/module folder where you built the project you will see the module
The module.xml comes from src/main/resources/module/main/module.xml and is used to define your module. It says that it contains the acme-subsystem.jar:
And has a default set of dependencies needed by every subsystem created. If your subsystem requires additional module dependencies you can add them here before building and installing.
Note that the name of the module corresponds to the directory structure containing it. Now copy the target/module/com/acme/corp/tracker/main/ directory and its contents to $AS7/modules/com/acme/corp/tracker/main/ (where $AS7 is the root of your JBoss AS 7 install).
Next we need to modify $AS7/standalone/configuration/standalone.xml. First we need to add our new module to the <extensions> section:
And then we have to add our subsystem to the <profile> section:
Adding this to a managed domain works exactly the same apart from in this case you need to modify $AS7/domain/configuration/domain.xml.
Now start up JBoss AS 7 by running $AS7/bin/standalone.sh and you should see messages like these after the server has started, which means our subsystem has been added and our TrackerService is working:
If you run the command line interface you can execute some commands to see more about the subsystem. For example
will return a lot of information, including what we provided in the DescriptionProviders we created to document our subsystem.
To see the current subsystem state you can execute
We can remove both the deployment types which removes them from the model:
You should now see the output from the TrackerService instances having stopped.
Now, let's add the war tracker again:
and the JBoss AS 7 console should show the messages coming from the war TrackerService again.
Now let us deploy something. You can find two maven projects for test wars already built at test1.zip and test2.zip. If you download them and extract them to /Downloads/test1 and /Downloads/test2, you can see that /Downloads/test1/target/test1.war contains a META-INF/cool.txt while /Downloads/test2/target/test2.war does not contain that file. From CLI deploy test1.war first:
And you should now see the output from the war TrackerService list the deployments:
So our test1.war got picked up as a 'cool' deployment. Now if we deploy test2.war
You will see that deployment get picked up as well but since there is no META-INF/cool.txt it is not marked as a 'cool' deployment:
is also reflected in the TrackerService output:
Finally, we registered a write attribute handler for the tick property of the type so we can change the frequency
You should now see the output from the TrackerService happen every second
If you open AS7/standalone/configuration/standalone.xml you can see that our subsystem entry reflects the current state of the subsystem: