ObjectPoolingAttribute Class
.NET Framework 2.0
Enables and configures object pooling for a component. This class cannot be inherited.
Namespace: System.EnterpriseServices
Assembly: System.EnterpriseServices (in system.enterpriseservices.dll)
Assembly: System.EnterpriseServices (in system.enterpriseservices.dll)
'Declaration <ComVisibleAttribute(False)> _ <AttributeUsageAttribute(AttributeTargets.Class, Inherited:=True)> _ Public NotInheritable Class ObjectPoolingAttribute Inherits Attribute 'Usage Dim instance As ObjectPoolingAttribute
/** @attribute ComVisibleAttribute(false) */ /** @attribute AttributeUsageAttribute(AttributeTargets.Class, Inherited=true) */ public final class ObjectPoolingAttribute extends Attribute
ComVisibleAttribute(false) AttributeUsageAttribute(AttributeTargets.Class, Inherited=true) public final class ObjectPoolingAttribute extends Attribute
If object pooling is specified, it must not be disabled in the COM+ catalog; if enabled in the COM+ catalog, it must be specified on the component.
For a list of initial property values for an instance of ObjectPoolingAttribute, see the ObjectPoolingAttribute constructor.
For more information about using attributes, see Extending Metadata Using Attributes.
The following code example demonstrates the use of this attribute.
Imports System Imports System.EnterpriseServices Imports System.Windows.Forms <Assembly: ApplicationName("ObjectInspector")> <Assembly: ApplicationActivation(ActivationOption.Server)> <Assembly: System.Reflection.AssemblyKeyFile("Inspector.snk")> <JustInTimeActivation(), ObjectPooling(MinPoolSize := 2, MaxPoolSize := 100, CreationTimeout := 1000)> _ Public Class ObjectInspector Inherits ServicedComponent Public Function IdentifyObject(ByVal obj As [Object]) As String ' Return this object to the pool after use. ContextUtil.DeactivateOnReturn = True ' Get the supplied object's type. Dim objType As Type = obj.GetType() ' Return its name. Return objType.FullName End Function 'IdentifyObject Protected Overrides Sub Activate() MessageBox.Show(String.Format("Now entering..." + vbLf + "Application: {0}" + vbLf + "Instance: {1}" + vbLf + "Context: {2}" + vbLf, ContextUtil.ApplicationId.ToString(), ContextUtil.ApplicationInstanceId.ToString(), ContextUtil.ContextId.ToString())) End Sub 'Activate Protected Overrides Sub Deactivate() MessageBox.Show("Bye Bye!") End Sub 'Deactivate ' This object can be pooled. Protected Overrides Function CanBePooled() As Boolean Return True End Function 'CanBePooled End Class 'ObjectInspector
import System.*;
import System.EnterpriseServices.*;
import System.Windows.Forms.*;
/** @assembly ApplicationName("ObjectInspector")
*/
/** @assembly ApplicationActivation(ActivationOption.Server)
*/
/** @assembly System.Reflection.AssemblyKeyFile("Inspector.snk")
*/
/** @attribute JustInTimeActivation()
*/
/** @attribute ObjectPooling(MinPoolSize = 2, MaxPoolSize = 100,
CreationTimeout = 1000)
*/
public class ObjectInspector extends ServicedComponent
{
public String IdentifyObject(Object obj)
{
// Return this object to the pool after use.
ContextUtil.set_DeactivateOnReturn(true);
// Get the supplied object's type.
Type objType = obj.GetType();
// Return its name.
return objType.get_FullName();
} //IdentifyObject
protected void Activate()
{
MessageBox.Show(String.Format("Now entering...\nApplication: {0}\n"
+ "Instance: {1}\nContext: {2}\n",
ContextUtil.get_ApplicationId().ToString(),
ContextUtil.get_ApplicationInstanceId().ToString(),
ContextUtil.get_ContextId().ToString()));
} //Activate
protected void Deactivate()
{
MessageBox.Show("Bye Bye!");
} //Deactivate
// This object can be pooled.
protected boolean CanBePooled()
{
return true;
} //CanBePooled
} //ObjectInspector
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Community Additions
ADD
Show: