What should you do?

You work as the Microsoft.NET developer at Domain.com. The Domain.com network consists of a single Active Directory domain named Domain.com. All servers in the domain run Windows Server 2003. The development and deployment of client applications forms part of your responsibilities at Domain.com. The exhibit below illustrates the currently existing class definition:

public class PropertyManager : ServicesComponent
{
public void MoveInNewCustomer(Customer customer, Unit unit) {
}
}

Client applications call the MoveInNewCustomer method to move a new customer into a unit. You have been instructed to ensure that this process occurs within the context of a transaction. If a transaction does not already exist when this method is called, a transaction should be created. Exclusively in the event of an exception being thrown you want the transaction to abort.

To this end you need to modify the class to meet these requirements. What should you do? (Choose the correct code segment.)

You work as the Microsoft.NET developer at Domain.com. The Domain.com network consists of a single Active Directory domain named Domain.com. All servers in the domain run Windows Server 2003. The development and deployment of client applications forms part of your responsibilities at Domain.com. The exhibit below illustrates the currently existing class definition:

public class PropertyManager : ServicesComponent
{
public void MoveInNewCustomer(Customer customer, Unit unit) {
}
}

Client applications call the MoveInNewCustomer method to move a new customer into a unit. You have been instructed to ensure that this process occurs within the context of a transaction. If a transaction does not already exist when this method is called, a transaction should be created. Exclusively in the event of an exception being thrown you want the transaction to abort.

To this end you need to modify the class to meet these requirements. What should you do? (Choose the correct code segment.)

A.
[Transaction(TransactionOption.RequiresNew)]
public class PropertyManager : ServicedComponent
{
public void MoveInNewCustomer(Customer customer, Unit unit) {
}
}

B.
[Transaction(TransactionOption.Required)]
public class PropertyManager : ServicedComponent
{
[Autocomplete]
public void MoveInNewCustomer(Customer customer, Unit unit) {
}
}

C.
[Transaction(TransactionOption.Supported)]
public class PropertyManager : ServicesComponent
{
public void MoveInNewCustomer(Customer customer, Unit unit) {
}
}

D.
[Transaction(TransactionOption.RequiresNew)]
public class PropertyManager : ServicedComponent
{
public void MoveInNewCustomer(Customer customer, Unit unit) {
}
}

Explanation:
You should apply the Transaction attribute to the class and set its parameter to TransactionOption.Required. This will indicate that the method must execute in the context of a COM+ transaction. If the caller of the method is executing within a transaction, then this transaction is used. If not then a new transaction is created. The AutoComplete attribute should also be applied to this method as it will indicate that the method transaction should commit automatically if the method executes and returns without an exception being thrown. If an exception is thrown, the transaction should abort automatically regardless of the applied AutoComplete attribute.
Incorrect answers:
A: The Transaction attribute parameter should not be set to TransactionOption.RequiresNew as this will indicate that the method must execute within the context of a new COM+ transaction.
C: The Transaction attribute parameter should not be set to TransactionOption.Supported as this will indicate that the mehod must execute only within the caller’s transaction. If the caller is not executing within a transaction, then the method will not execute within the context of a transaction.
D: The Transaction attribute parameter should not be set to TransactionOption.RequiresNew as this will indicate that the method must execute within the context of a new COM+ transaction.



Leave a Reply 0

Your email address will not be published. Required fields are marked *