Designer 10.7 | webMethods Service Development Help | Building Services from .NET Methods | Modifying the Class Lifetime for a .NET Service
 
Modifying the Class Lifetime for a .NET Service
The Class Lifetime property indicates how you want Integration Server to maintain instance data for a .NET class running on the CLR. The instance data is a set of variables associated with the .NET class. When a .NET service executes, the CLR uses the instance data for the class that owns the method called by the .NET service.
Note:
When you set the Class Lifetime property for a service, Designer automatically sets the Class Lifetime property of all .NET services associated with the same class to the same setting.
*To modify the Class Lifetime for a .NET Service
1. In the Service Development perspective, open the .NET service by double clicking it in the Package Navigator view.
2. Click the .NET Properties tab.
3. Set the Class Lifetime property to indicate how you want Integration Server to maintain instance data for a class.
Class Lifetime
Description
Global
Integration Server creates a single instance of the class, or object, which has an unlimited lifetime. The class shares instance data among all sessions. You can create only one instance of a global object of a given type.
Use this setting when you want Integration Server use the same instance data for all users in multiple sessions.
Session
Integration Server creates a separate object for each user. The object exists until the user session is closed or until the object times out.
The default timeout value for the object is three minutes. Use the Class Timeout property to specify a different timeout value for an object.
Single-Use
Integration Server creates and destroys an object each time a .NET service calls a method in the class. Instance data might be kept during the lifetime of the object.
Static
Integration Server does not create an object to save instance data. All methods of the class are static.
Use this setting when the .NET service calls a method that does not require any session data to be kept.
4. If you set the lifetime to Session, specify a value for the Class Timeout (Mins) property to define the timeout value for objects.
Set a high enough value so that Integration Server does not prematurely destroy objects under normal usage. The default is 3 (i.e., three minutes).
Note:Integration Server starts counting the minutes for the timeout when an instance of the class is created. Whenever a .NET service accesses the class, Integration Server resets the count.
5. Select File > Save.
Important:
If you set the Class Lifetime property to Global or Session, the instance data can be used across multiple invocations of methods in a class. If multiple services are using a given global object or a session object at the same time, those objects need to be thread safe.