customising and extending reactor

1 view
Skip to first unread message

Gareth Cole

unread,
Jul 23, 2009, 4:51:03 PM7/23/09
to reacto...@googlegroups.com

Hi,

 

I've had a sniff of coldspring over the last year, and I'm afraid it's gone to my head J

 

I was trying to customise my installation of reactor, to make a few minor improvements. Nothing major, in this case I just wanted to pass some extra attributes in the reactor.xml and have them added to the generated metadata files.

 

I managed to do this quite easily by editing the core files, but I feel uneasy about doing this. Putting my coldspring hat on, I thought it would be cleaner to sub-class the CFCs I wanted changed, and over-ride the methods.

 

This has turned out to be a lot more complicated than I thought it would be. I started off by managing the singleton objects such as reactorFactory.cfc with coldspring, but I hadn't realised how many transient objects are created all over the place. I've had to sub-class a lot of objects so far, and over-riding some of the longer methods just to change a createObject() call doesn't seem right.

 

I wondered whether it would make sense, to move all the generation of these transient objects to the reactorFactory. That way, people like me can customise their reactor installation just by sub-classing the reactor factory and the individual objects they are interested in.

 

As an example, I wanted to change the working of the objectTranslator.generateObject() method.

 

To do this currently, I sub-class objectTranslator and over-ride the generateObject() method.

To create the sub-classed objectTranslator instead of the usual one, I need to sub-class objectfFactory and over-ride the create() method. The create() function has over 100 lines of code, but I just need to change one line:

 

<cfset ObjectTranslator = CreateObject("Component", "reactor.core.objectTranslator").init(getConfig(), DbObject, this) />

 

to

 

<cfset ObjectTranslator = CreateObject("Component", "myProject.myObjectTranslator").init(getConfig(), DbObject, this) />

 

I also need to get my version of ObjectFactory.cfc used instead of the default one, and so on down the chain. All-in-all, it's a lot of customisation just to change a single function.

 

Now if the line:

            <cfset ObjectTranslator = CreateObject("Component", "reactor.core.objectTranslator").init(getConfig(), DbObject, this) />

 

had instead been:

            <cfset ObjectTranslator = getReactorFactory().createObjectTranslator(getConfig(), DbObject, this) />

 

things would be a whole lot easier.

 

All I would have needed to do is sub-class the reactorFactory, and over-ride the createObjectTranslator() method to generate my sub-classed ObjectTranslator.

 

Now obviously this would be quite a lot of work, to add this feature to reactor, but it would make it a lot more flexible. I'd like to know what people think. I'm still relatively new to coldspring, factories etc, so I'm expecting to be shot down in flames J

 

Thanks,

 

Gareth

 

 

Chris Blackwell

unread,
Jul 24, 2009, 2:36:28 AM7/24/09
to reacto...@googlegroups.com
could you explain what you're trying to acheive, maybe we could suggest a better way....


Tom Chiverton

unread,
Jul 24, 2009, 5:33:57 AM7/24/09
to reacto...@googlegroups.com
On Friday 24 Jul 2009, Chris Blackwell wrote:
> could you explain what you're trying to acheive, maybe we could
> suggest a better way....

This has come up in the past, if I think it's what it is, for instance.
I wanted to annotate the reactor.xml with a few other bits and bobs, so I
could feed it into a code generator that would also be able to use the same
XML to drive it's Reactor.
The (correct, I *now* feel !) answer here was really to create my own XML file
that looks a bit like Reactor's, and have the generator generate a real
Reactor XML file from it as part of the process.

Then I headed down the whole 'domain specific language' route and didn't come
out for weeks ;-)

Practically, we could do exactly what Gareth wants by using ColdSpring (or a
lighter wait DI framework) to wire together the parts of Reactor.
I'm not sure the pain of the work to do this, and the problems the additional
dependency would cause, would be worth it, though I'm open to ideas in this
area...

--

Tom Chiverton
Developer

Tom.Ch...@halliwells.com
3 Hardman Square, Manchester, M3 3EB

****************************************************

This email is sent for and on behalf of Halliwells LLP.

Halliwells LLP is a limited liability partnership registered in England and Wales under registered number OC307980 whose registered office address is at Halliwells LLP, 3 Hardman Square, Spinningfields, Manchester, M3 3EB. A list of members is available for inspection at the registered office together with a list of those non members who are referred to as partners. We use the word ?partner? to refer to a member of the LLP, or an employee or consultant with equivalent standing and qualifications. Regulated by the Solicitors Regulation Authority.

CONFIDENTIALITY

This email is intended only for the use of the addressee named above and may be confidential or legally privileged. If you are not the addressee you must not read it and must not use any information contained in nor copy it nor inform any person other than Halliwells LLP or the addressee of its existence or contents. If you have received this email in error please delete it and notify Halliwells LLP IT Department on 0870 365 2500.

For more information about Halliwells LLP visit
www.Halliwells.com.

Gareth Cole

unread,
Jul 24, 2009, 6:04:31 AM7/24/09
to reacto...@googlegroups.com
Hi Chris,

In previous reactor projects, I've added a 'fieldtype' property to the
custom metadata objects. It just describes what sort of input to use when
generating forms using scaffolding.

For example, I might set a field's fieldtype to 'email' or 'wysiwyg' and my
scaffolding knows to build the appropriate input type on the form.

To simplify this, I wanted to add an extra attribute to the <field> tag in
my reactor.xml e.g. <field name="customerEmail" fieldtype="email"/>
I wanted to adapt reactor, to pull the fieldtype into the metadata object it
generates.

I could do this with just a few small changes to the core files. However,
I'm wary about changing the core files directly. I'd hoped there was an easy
way to extend reactor, but that's turned out to be a bit more complicated.


--------- Original Message --------
From: reacto...@googlegroups.com
To: reacto...@googlegroups.com <reacto...@googlegroups.com>
Subject: [reactor-users] Re: customising and extending reactor
Date: 24/07/09 08:37

> could you explain what you're trying to acheive, maybe we could suggest a
better way....On 23 Jul 2009, at 21:51, "Gareth Cole"
&lt;garet...@esus.ie&gt; wrote:
>
>
>
> Hi,
>
> &nbsp;
>
> I've had a sniff of coldspring over the last year,
> and I'm afraid it's gone to my head J
>
> &nbsp;
>
> I was trying to customise my installation of reactor,
> to make a few minor improvements. Nothing major, in this case I just
wanted to pass
> some extra attributes in the reactor.xml and have them added to the
generated
> metadata files.
>
> &nbsp;
>
> I managed to do this quite easily by editing the core
> files, but I feel uneasy about doing this. Putting my coldspring hat on, I
> thought it would be cleaner to sub-class the CFCs I wanted changed, and
> over-ride the methods.
>
> &nbsp;
>
> This has turned out to be a lot more complicated than
> I thought it would be. I started off by managing the singleton objects
such as reactorFactory.cfc
> with coldspring, but I hadn't realised how many transient objects are
created
> all over the place. I've had to sub-class a lot of objects so far, and
> over-riding some of the longer methods just to change a createObject()
call
> doesn't seem right.
>
> &nbsp;
>
> I wondered whether it would make sense, to move all
> the generation of these transient objects to the reactorFactory. That way,
> people like me can customise their reactor installation just by
sub-classing
> the reactor factory and the individual objects they are interested in.
>
> &nbsp;
>
> As an example, I wanted to change the working of the
objectTranslator.generateObject()
> method.
>
> &nbsp;
>
> To do this currently, I sub-class objectTranslator
> and over-ride the generateObject() method.
>
> To create the sub-classed objectTranslator instead of
> the usual one, I need to sub-class objectfFactory and over-ride the
create()
> method. The create() function has over 100 lines of code, but I just need
to
> change one line:
>
> &nbsp;
>
> &lt;cfset ObjectTranslator
> = CreateObject("Component",
"reactor.core.objectTranslator").init(getConfig(),
> DbObject, this) /&gt;
>
> &nbsp;
>
> to
>
> &nbsp;
>
> &lt;cfset ObjectTranslator
> = CreateObject("Component",
"myProject.myObjectTranslator").init(getConfig(),
> DbObject, this) /&gt;
>
> &nbsp;
>
> I also need to get my version of ObjectFactory.cfc
> used instead of the default one, and so on down the chain. All-in-all,
it's a
> lot of customisation just to change a single function.
>
> &nbsp;
>
> Now if the line:
>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;cfset
> ObjectTranslator = CreateObject("Component",
"reactor.core.objectTranslator").init(getConfig(),
> DbObject, this) /&gt;
>
> &nbsp;
>
> had instead been:
>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;cfset
> ObjectTranslator = getReactorFactory().createObjectTranslator(getConfig(),
DbObject,
> this) /&gt;
>
> &nbsp;
>
> things would be a whole lot easier.
>
> &nbsp;
>
> All I would have needed to do is sub-class the reactorFactory,
> and over-ride the createObjectTranslator() method to generate my
sub-classed ObjectTranslator.
>
> &nbsp;
>
> Now obviously this would be quite a lot of work, to
> add this feature to reactor, but it would make it a lot more flexible. I'd
like
> to know what people think. I'm still relatively new to coldspring,
factories
> etc, so I'm expecting to be shot down in flames J
>
> &nbsp;
>
> Thanks,
>
> &nbsp;
>
> Gareth
>
> &nbsp;
>
> &nbsp;
>
>
>
>
>
>
>
>
>
> >
>

________________________________________________
Message sent using UebiMiau 2.7.9


Tom Chiverton

unread,
Jul 24, 2009, 6:43:32 AM7/24/09
to reacto...@googlegroups.com
On Friday 24 Jul 2009, Gareth Cole wrote:
> For example, I might set a field's fieldtype to 'email' or 'wysiwyg' and my
> scaffolding knows to build the appropriate input type on the form.

Yup, that's exactly the sort of thing I was up to :-)


--

Tom Chiverton
Developer

Tom.Ch...@halliwells.com
3 Hardman Square, Manchester, M3 3EB

****************************************************

This email is sent for and on behalf of Halliwells LLP.

Halliwells LLP is a limited liability partnership registered in England and Wales under registered number OC307980 whose registered office address is at Halliwells LLP, 3 Hardman Square, Spinningfields, Manchester, M3 3EB. A list of members is available for inspection at the registered office together with a list of those non members who are referred to as partners. We use the word “partner” to refer to a member of the LLP, or an employee or consultant with equivalent standing and qualifications. Regulated by the Solicitors Regulation Authority.



CONFIDENTIALITY

This email is intended only for the use of the addressee named above and may be confidential or legally privileged. If you are not the addressee you must not read it and must not use any information contained in nor copy it nor inform any person other than Halliwells LLP or the addressee of its existence or contents. If you have received this email in error please delete it and notify Halliwells LLP IT Department on 0870 365 2500.

For more information about Halliwells LLP visit

Doug Hughes

unread,
Jul 24, 2009, 7:37:30 AM7/24/09
to reacto...@googlegroups.com
When Reactor was first created I didn't know or understand ColdSpring.  However, once I learned CS, I always intended to come back and make Reactor 2 be configured by CS so you could change the frameworks configuration at will, just like MG.  That, and perhaps you could define your custom records and gateways via CS and wire in dependencies.

I never got there and I'm not sure where Mark is headed with it these days, but I don't view the use of CS as a negative.  In fact, I view it as a positive.

Doug Hughes, President
Alagad Inc.
dhu...@alagad.com
888 Alagad4 (x300)
Office: 919-550-0755
Fax: 888-248-7836

Mark Drew

unread,
Jul 24, 2009, 7:57:07 AM7/24/09
to reacto...@googlegroups.com
I have already got DI working with coldspring... I am using an Injector object and it has its own DI engine, I shall check in the code when its a bit more stable as we are still testing it :)


So yes, you can now wire in other objects into your Records and Gateways.

MD
Reply all
Reply to author
Forward
0 new messages