.ben
10-10-2005, 12:42 PM
Hi, I'll just paste the code and give some comments since it's kinda hard to explain.
Somewhere in a method I'm using spring to get an object for my uploader
_uploader = CType(BL.ObjectManager.GetObject("UploaderService"), IUploaderService)
My 'own' objectmanager looks like this:
Public Class ObjectManager
Private Shared _ctx As IApplicationContext
Private Shared _mut As New Mutex
Private Sub New()
End Sub
Public Shared Function GetObject(ByVal name As String) As Object
_mut.WaitOne()
Try
If _ctx Is Nothing Then
_ctx = ContextRegistry.GetContext()
End If
Return _ctx.GetObject(name)
Catch ex As Exception
Throw
Finally
_mut.ReleaseMutex()
End Try
End Function
End Class
In the constructor for the uploader I instantiate some other objects
Public Sub New()
_factory = New SomeFactory
In the constructor of this factory I use spring again to get a reference to a dao:
Public Sub New()
_someDao = CType(BL.ObjectManager.GetObject("someDao"), ISomeDAO)
End Sub
Now somehow, whenever I get to this point it goes back to the constructor of the uploader, who goes back all the way down the last code snippet which then goes back to the uploader etc. a nice loop.
The configuration:
<object name="someDao"
type="DAO.Implementations.Xml.someDao, DAO" factory-method="GetInstance" />
<object name="UploaderService"
type="Services.Implementations.UploaderServiceImp,Servic es"/>
The factory and the dao work fine seperate and combined, even combined via spring.
If I hardcode the instantiaton of the dao in the factory the uploader works fine too. But that's not really what I want to do :D
I hope I made myself clear, what on earth am I doing wrong.
Thanks in advance.
Somewhere in a method I'm using spring to get an object for my uploader
_uploader = CType(BL.ObjectManager.GetObject("UploaderService"), IUploaderService)
My 'own' objectmanager looks like this:
Public Class ObjectManager
Private Shared _ctx As IApplicationContext
Private Shared _mut As New Mutex
Private Sub New()
End Sub
Public Shared Function GetObject(ByVal name As String) As Object
_mut.WaitOne()
Try
If _ctx Is Nothing Then
_ctx = ContextRegistry.GetContext()
End If
Return _ctx.GetObject(name)
Catch ex As Exception
Throw
Finally
_mut.ReleaseMutex()
End Try
End Function
End Class
In the constructor for the uploader I instantiate some other objects
Public Sub New()
_factory = New SomeFactory
In the constructor of this factory I use spring again to get a reference to a dao:
Public Sub New()
_someDao = CType(BL.ObjectManager.GetObject("someDao"), ISomeDAO)
End Sub
Now somehow, whenever I get to this point it goes back to the constructor of the uploader, who goes back all the way down the last code snippet which then goes back to the uploader etc. a nice loop.
The configuration:
<object name="someDao"
type="DAO.Implementations.Xml.someDao, DAO" factory-method="GetInstance" />
<object name="UploaderService"
type="Services.Implementations.UploaderServiceImp,Servic es"/>
The factory and the dao work fine seperate and combined, even combined via spring.
If I hardcode the instantiaton of the dao in the factory the uploader works fine too. But that's not really what I want to do :D
I hope I made myself clear, what on earth am I doing wrong.
Thanks in advance.