Listener, Service, Gateway, DAO, Bean

41 views
Skip to first unread message

AuntBee

unread,
Nov 17, 2009, 4:29:50 PM11/17/09
to Mach-II for CFML
I'm dissecting the MachBlog application in order to understand how to
design a Mach II application. So I have a question related to that.

The MachBlog application has a listener called "EntryListener" that
contains various setXXXService functions. These setXXXService
functions are called by ColdSpring to set the service objects in the
listener.

If ColdSpring was not used, then how would the Service Objects get set
in the Listener. Would that step be performed in the configure
function?

Thanks,

Matthew Woodward

unread,
Nov 17, 2009, 4:39:51 PM11/17/09
to mach-ii-for...@googlegroups.com
On Tue, Nov 17, 2009 at 1:29 PM, AuntBee <tdsi...@gmail.com> wrote:
If ColdSpring was not used, then how would the Service Objects get set
in the Listener.  Would that step be performed in the configure
function?


Yep, absolutely right. But trust me, you want to use ColdSpring to manage your dependencies.

--
Matthew Woodward
ma...@mattwoodward.com
http://mpwoodward.posterous.com
identi.ca/Twitter: @mpwoodward

Please do not send me proprietary file formats such as Word, PowerPoint, etc. as attachments.
http://www.gnu.org/philosophy/no-word-attachments.html

AuntBee

unread,
Nov 17, 2009, 7:11:42 PM11/17/09
to Mach-II for CFML
I don't see a bean for the Mach-II Listener. How are the services
injected into the Mach-II Listener?

<!-- AGGREGATOR -->
<bean id="aggregatorService"
class="machblog.org.machblog.aggregator.AggregatorService">
<property name="aggregatorDAO"><ref bean="aggregatorDAO" /></
property>
<property name="aggregatorGateway"><ref bean="aggregatorGateway" /></
property>
<property name="userFacade"><ref bean="userFacade" /></property>
<property name="resourceBundleFacade"><ref
bean="resourceBundleFacade" /></property>
</bean>
<bean id="aggregatorDAO"
factory-bean="daoFactory"
factory-method="getAggregatorDAO">
<property name="datasource"><ref bean="datasourceBean" /></property>
<property name="resourceBundleFacade"><ref
bean="resourceBundleFacade" /></property>
</bean>
<bean id="aggregatorGateway"
factory-bean="gatewayFactory"
factory-method="getAggregatorGateway">
<property name="datasource"><ref bean="datasourceBean" /></property>
</bean>


On Nov 17, 4:39 pm, Matthew Woodward <m...@mattwoodward.com> wrote:
> On Tue, Nov 17, 2009 at 1:29 PM, AuntBee <tdsimp...@gmail.com> wrote:
> > If ColdSpring was not used, then how would the Service Objects get set
> > in the Listener.  Would that step be performed in the configure
> > function?
>
> Yep, absolutely right. But trust me, you want to use ColdSpring to manage
> your dependencies.
>
> --
> Matthew Woodward
> m...@mattwoodward.comhttp://mpwoodward.posterous.com

Matthew Woodward

unread,
Nov 17, 2009, 7:27:04 PM11/17/09
to mach-ii-for...@googlegroups.com
On Tue, Nov 17, 2009 at 4:11 PM, AuntBee <tdsi...@gmail.com> wrote:
I don't see a bean for the Mach-II Listener.  How are the services
injected into the Mach-II Listener?


That's handled automatically by Mach-II.

--
Matthew Woodward
ma...@mattwoodward.com

Peter J. Farrell

unread,
Nov 17, 2009, 7:36:57 PM11/17/09
to mach-ii-for...@googlegroups.com
Mach-II always manages all framework extended component itself (like listeners, filters, etc.).  I'd read up on the ColdSpringProperty which takes care of managing CS in a Mach-II application as well as injecting the beans into the listeners for you:

http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/wiki/UsingColdSpringWithMach-II

AuntBee said the following on 11/17/2009 06:11 PM:

AuntBee

unread,
Nov 19, 2009, 12:34:26 PM11/19/09
to Mach-II for CFML
Thank Peter.
I read the wiki page, but I still don't understand.
I don't see any depends="someService" attribute in the
AggregatorListener.

----------------------
Notes:
This listener is autowired by ColdSpring.
--->
<cfcomponent
displayname="AggregatorListener"
extends="MachII.framework.Listener"
output="false"
hint="AggregatorListener for MachBlog.">
...

How is the AggregatorListener autowired by ColdSpring?
-------------------------------

On Nov 17, 7:36 pm, "Peter J. Farrell" <pe...@mach-ii.com> wrote:
> Mach-II always manages all framework extended component itself (like
> listeners, filters, etc.).  I'd read up on the ColdSpringProperty which
> takes care of managing CS in a Mach-II application as well as injecting
> the beans into the listeners for you:
>
> http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/wiki/UsingColdSpring...

Matthew Woodward

unread,
Nov 19, 2009, 12:37:15 PM11/19/09
to mach-ii-for...@googlegroups.com
On Thu, Nov 19, 2009 at 9:34 AM, AuntBee <tdsi...@gmail.com> wrote:
Thank Peter.
I read the wiki page, but I still don't understand.
I don't see any depends="someService" attribute in the
AggregatorListener.


MachBlog was written before the depends attribute existed. It's wired up by the ColdSpring plugin. Note that these days you would use the ColdSpring property, but there is a plugin involved that handles the Mach-II dependencies for you. It calls setter methods in the CFCs and resolves the dependencies when the application starts.

Short answer: it's handled for you by ColdSpring and Mach-II.

--
Matthew Woodward
ma...@mattwoodward.com

Peter J. Farrell

unread,
Nov 19, 2009, 2:14:00 PM11/19/09
to mach-ii-for...@googlegroups.com
The documentation show the old way in the "depends" section. Before you used to have to writter setters methods -- the ColdSpringProperty would look for setters and match setters against bean named in the CS bean container.  This is how MachBlog works at the moment.

.pjf

AuntBee said the following on 11/19/2009 11:34 AM:

AuntBee

unread,
Nov 19, 2009, 3:20:41 PM11/19/09
to Mach-II for CFML
Let me see if I understand this now, by using the Mach-II Skeleton.

First, I defined my beans in ./config/coldspring.xml. For example, my
coldspring.xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>

<beans default-autowire="no">
<bean id="alarmServiceBean"
class="tickle.cfc.tickle.alarm.AlarmService">
<property name="alarmDAO"><ref bean="alarmDAO" /></property>
</bean>
<bean id="alarmDAO" class="tickle.cfc.tickle.alarm.AlarmDAO"></bean>
</beans>

Then I define my Listener and add the "depends" attribute to my
cfcomponent tag. In this example, I created a listener called
AlarmListener and it starts off like this:
<cfcomponent
displayname="AlarmListener"
extends="MachII.framework.Listener"
depends="alarmServiceBean"
output="false"
hint="Alarm Listener for MachII Framework.">

So MachII will search ColdSpringFactory for the "alarmServiceBean" and
inject it into the AlarmListener.

By using cfdump, I can see that the function "getAlarmServiceBean"
returns an AlarmServiceBean.

<cfdump var="#application.tickle.apploader.getAppManager
().getListenerManager().getListener
('alarmListener').getAlarmServiceBean()#" />

How am I doing so far?
Am I on track?

When I do a cfdump of just the alarmListener, I do not see the
getAlarmServiceBean method listed.
<cfdump var="#application.tickle.apploader.getAppManager
().getListenerManager().getListener('alarmListener')# />

Why is that?

Thanks,

Peter J. Farrell

unread,
Nov 19, 2009, 3:47:26 PM11/19/09
to mach-ii-for...@googlegroups.com
AuntBee said the following on 11/19/2009 02:20 PM:
> When I do a cfdump of just the alarmListener, I do not see the
> getAlarmServiceBean method listed.
> <cfdump var="#application.tickle.apploader.getAppManager
> ().getListenerManager().getListener('alarmListener')# />
>
Depends on when you are dump out the listener. Those getters are
injected into your listener at runtime and only after the entire
framework has loaded and completed the onObjectReload method calls.

If in your listener, you can call getAlarmServiceBean() then you are ok.

.pjf
Reply all
Reply to author
Forward
0 new messages