Now, we need to enable the class CounterService. The declarative way of doing this is shown below.
<network>
<join><multicast enabled="true"/> </join>
</network>
<services>
<service enabled="true">
<name>CounterService</name>
<class-name>CounterService</class-name>
</service>
</services>
The CounterService is declared within the services configuration element.
- Set the
enabledattribute totrueto enable the service. - Set the
nameattribute to the name of the service. It should be a unique name (CounterServicein our case) since it will be looked up when a remote call is made. Note that the value of this attribute will be sent at each request, and that a longernamevalue means more data (de)serialization. A good practice is to give an understandable name with the shortest possible length. - Set the
class-nameattribute to the class name of the service (CounterServicein our case). The class should have a no-arg constructor. Otherwise, the object cannot be initialized.
Note that multicast is enabled as the join mechanism. In the later sections for the CounterService example, we will see why.
