Summary

You can initialize and destroy Service state by writing methods in your Service that perform the required actions, and setting the initMethod and destroyMethod options to the names of the methods.
The client-side proxy creates a constructor with the same method argument types as the initMethod that was specified in the Service Type Registry.
The client-side proxy contains a destroy method that calls the method specified as the destroyMethod in the Service Type.
The Service deployer must also specify which Service methods change state, and whether they append or set the state. These methods are called normally from a proxy, and via updateState using the Service API.