UPS 배송 웹 서비스를 사용하는 전자 상거래 앱을 개발 중입니다. 싱글 톤을 만드는 것이 좋다는 것을 알았으므로 언제든지 웹 서비스 인스턴스가 하나만 존재합니다. 내 코드는 아래와 같습니다.Webservices를 싱글 톤으로 사용하면 다른 사용자에게 문제가 발생할 수 있습니까?
Public Class Ship
Private Shared sync As New Object()
Private Shared _Service As New ShipService
Public Shared ReadOnly Property Service As ShipService
Get
If _Service Is Nothing Then
SyncLock sync
If _Service Is Nothing Then
_Service = New ShipService
End If
End SyncLock
End If
Return _Service
End Get
End Property
Public Shared Function GetInstance() As ShipService
Return Service()
End Function
End Class
다음은 사용 예정 스 니펫입니다.
Public Sub New(ByVal ToAddress As Address, ByVal WeightInLbs As String)
//Not relevant code
Ship.Service.UPSSecurityValue = Security
//More not relevant code
End Sub
Public Function ProcessShipment() As ShipmentResponse
Return Ship.Service.ProcessShipment(ShipmentRequest)
End Function
위의 생성자에서 위의 줄에서 서비스의 UPSSecurityValue를 설정해야합니다. 그런 다음 나중에 ProcessShipment 함수를 호출 할 것입니다. 내 질문은; 웹 서비스가 싱글 톤으로 거래되고 있기 때문에 앱의 다른 인스턴스가 동일한 UPSSecurityValue를 공유 할 수 있으며 설정 한 시점과 ProcessShipment를 호출 할 때 사이에 변경 될 수 있습니까?