Reactor - using createGateway(objectAlias)

0 views
Skip to first unread message

Terry Schmitt

unread,
Aug 7, 2007, 1:05:32 AM8/7/07
to Lightwire Framework
I'm trying to create a Reactor gateway singleton via Lightwire, but
I'm missing something and keep getting:

"Element CONSTRUCTORDEPENDENCYSTRUCT is undefined in a CFML structure
referenced as part of an expression."
at cfLightWire2ecfc130330308$funcGETDEPENDENTOBJECTLIST.runFunction(C:
\Inetpub\wwwroot\web_skeleton_coldbox\coldbox\system\extras\lightwire
\LightWire.cfc:127)

I can create the Reactor Factory via Lightwire with no problem.
What I really want is to ask Lightwire for the user gateway, which
should be wired up to use the Reactor Factory.

I've read this thread, but didn't totally digest it.
http://groups.google.com/group/lightwireFramework/browse_thread/thread/5ac1d2ed8b17a3bc

The trick i'm looking for is how to pass the objectAlias argument with
the createGateway method?

Here's my sample code so far:

**************************
Coldbox code that creates the Reactor factory and then creates a
gateway. This works fine.
**************************
<!--- create the Reactor Factory --->
<cfset reactor = getPlugin("ioc").getBean("reactorFactory")>
<!--- create a userGateway --->
<cfset userGateway = reactor.createGateway("user") />

**************************
Here is what I am trying to achieve and have the gateway created by
lightwire as a singleton.
**************************
<cfset userGateway = getPlugin("ioc").getBean("userGateway") />

**************************
lightwire.cfc snippet
**************************
// Reactor Factory
addSingleton("reactor.reactorFactory");
addConstructorProperty("reactorFactory","configuration",getController().getSetting('reactorConfigPath'));

//Reactor User Gateway
addSingletonFromFactory("reactorFactory", "createGateway",
"userGateway");
addConstructorProperty("userGateway", "objectAlias", "user");

Paul Marcotte

unread,
Aug 7, 2007, 1:51:10 AM8/7/07
to lightwire...@googlegroups.com
Hi Terry,

Clever idea you have going.  Unfortunately, addSingletonFromFactory() method does not accept arguments to be passed to the factory method to create the singleton.  Why not try creating your own custom factory and inject reactor into that?  Then you could write custom methods that delegate the gateway creation to reactor while supporting factory methods such as createUserGateway().

Just a thought...

Paul

Terry Schmitt

unread,
Aug 7, 2007, 10:00:00 PM8/7/07
to Lightwire Framework
Thanks for the idea...
Since Reactor creates all of the Gateways for you and allows a
mechanism to add your custom methods to them, I decided to try a
Gateway facade that has Reactor injected into it. It's working well so
far.

T

On Aug 7, 1:51 am, "Paul Marcotte" <pmarco...@gmail.com> wrote:
> Hi Terry,
>
> Clever idea you have going. Unfortunately, addSingletonFromFactory() method
> does not accept arguments to be passed to the factory method to create the
> singleton. Why not try creating your own custom factory and inject reactor
> into that? Then you could write custom methods that delegate the gateway
> creation to reactor while supporting factory methods such as
> createUserGateway().
>
> Just a thought...
>
> Paul
>

> On 8/6/07, Terry Schmitt <terry.schm...@gmail.com> wrote:
>
>
>
>
>
> > I'm trying to create a Reactor gateway singleton via Lightwire, but
> > I'm missing something and keep getting:
>
> > "Element CONSTRUCTORDEPENDENCYSTRUCT is undefined in a CFML structure
> > referenced as part of an expression."
> > at cfLightWire2ecfc130330308$funcGETDEPENDENTOBJECTLIST.runFunction(C:
> > \Inetpub\wwwroot\web_skeleton_coldbox\coldbox\system\extras\lightwire
> > \LightWire.cfc:127)
>
> > I can create the Reactor Factory via Lightwire with no problem.
> > What I really want is to ask Lightwire for the user gateway, which
> > should be wired up to use the Reactor Factory.
>
> > I've read this thread, but didn't totally digest it.
>

> >http://groups.google.com/group/lightwireFramework/browse_thread/threa...

> --
> Paul Marcotte
> Fancy Bread - in the heart or in the head?http://www.fancybread.com

Paul Marcotte

unread,
Aug 8, 2007, 1:17:38 PM8/8/07
to lightwire...@googlegroups.com
Hi Terry,

My pleasure.  Since I'm a curious fellow, can you tell me if your Gateway facade is a singleton that first checks if an internal data member (example: variables.userGateway) exists before delegating creation to Reactor?

Paul

Terry Schmitt

unread,
Aug 8, 2007, 11:56:11 PM8/8/07
to Lightwire Framework
Rather then use a Gateway Factory to create each of my gateways, I'm
creating a gateway for each of my business objects, in this case
userGateway.cfc. If for some reason I stop using Reactor, I still have
the userGateway that I could write all my custom gateway methods into.
For now I will write my custom gateway methods in the files that
Reactor creates.
The userGateway is a singleton created by Lightwire, which will be
injected into my userService.
The way I have my userGatway setup, I don't check for existence first,
but I don't think that I need to as userGateway is a singleton and
should only return the reactor user gateway once.

>From this object, I now have access to all the Reactor gateway methods
as well as my custom methods.

I hope I explained this well enough... I'm still trying to get my head
around OOP and as always, there are a 100 different ways to do
anything!

Here is the code of my user gateway:
<cfcomponent displayname="userGateway" output="false" hint="A reactor
gateway facade">
<cffunction name="init" access="public" output="false"
returntype="any">
<cfargument name="reactorFactory" type="reactor.reactorFactory"
required="true" />
<cfset variables.reactorFactory = arguments.reactorFactory />

<!--- create a userGateway --->

<cfset variables.userGateway =
variables.reactorFactory.createGateway("user") />

<cfreturn variables.userGateway />
</cffunction>

<!-- custom code if required -->

</cfcomponent>


On Aug 8, 1:17 pm, "Paul Marcotte" <pmarco...@gmail.com> wrote:
> Hi Terry,
>

> My pleasure. Since I'm a curious fellow, can you tell me if your Gateway
> facade is a singleton that first checks if an internal data member (example:
> variables.userGateway) exists before delegating creation to Reactor?
>
> Paul
>

Paul Marcotte

unread,
Aug 9, 2007, 12:50:34 PM8/9/07
to lightwire...@googlegroups.com
Hi Terry,

I agree.  There are many ways to architect an application.  Thanks for clarifying your implementation.  I envisioned something different and now I understand your design choice.  Great to see folks using approaches that are not all the same.  There has been plenty of discussion lately on why OOP in CF is perceived to have to be x, when it does not.  That's a big hurdle for newbs to get over.  To be honest, although I feel I've graduated from freshman to junior, I still haven't locked down a preference.

Cheers,

Paul
Reply all
Reply to author
Forward
0 new messages