Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

Re: I need my services available from...well... everywhere

$
0
0

You know, I had my own "RC" object which was a RequestContext, but it only contained a copy of the FORM, URL and CGI scopes.  It is stored in the REQUEST scope because it change son a per-request basis.  So if I understand what you're suggesting, I could add a pointer to my variables-scoped objects into the RC and then as long as I pass that RC to my methods and invoked/included files, it should point all the way back to those services.

 

I am going to look at FW/1 and see how they do things; hopefully they have some good documentation which explains their process.  I know Sean Corfield's a darn good CFML developer.

 

As for the Dependency Injection, I know that I currently AM doing DI, but there's a chance I'm not doing it right.  For example, I have a Data Source object, a User Gateway object (that needs a data source) and a User Service object (that needs a gateway, which needs a data source).  When I build these objects, I do them in that order, and then inject one into the other, so that at the end I have a User Service object who has a Gateway property which is the Gateway Object which has a Data Source property, that is the Data Source object.  And it all seems to work great, I can make calls like:

 

UserService.getGateway() <- Returns the Gateway Object.

UserService.getGateway().getDataSource() <- Returns the DataSource Object of the Gateway Object.

UserService.getGateway().getDataSource().getUsername() <- Returns the Username property of the DataSource Object of the Gateway Object.

 

So for the most part, I have just been communicating with Service Objects.  But I think I get what you mean.  If I had a RequestContext which contained all my needed data for a request, I could just inject him into locations that may need to reference that data.

 

I think this "Put it in the RC" approach might be a good resolve.  Thanks for the input Carl!


Viewing all articles
Browse latest Browse all 21760

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>