Andrew, based on what I've read from your posts, you've got more  
going on here than just needing a parent bean factory.

1) Application scopes.
If you want to keep these two applications running against different  
application scopes, you're going to need to get sort of creative.  
OTOH, if you don't mind them sharing application scopes (like there's  
not going to be some horrendous name collision), all you really need  
to do is have 2 Application.cfc files, and put the administrative  
application where-ever you want. ColdFusion will join the application  
scopes together and app 2 will have access to app 1's application  
scope variables. I just tested it and it works. The only proviso is  
this: if you hit app 1 first, then onApplicationStart() for app 2  
won't fire... so you'll have put something in onRequestStart() to  
check for something in the application scope (like  
application.app1inited and application.app2inited) and call  
onApplicationStart() manually (with the correct double if statement).  
I recommend doing this in each app so that it doesn't matter which  
one starts first, the other one will run right.

The nice thing about this approach is that ModelGlue gives you an  
easy way to apply a parent bean factory to the captive beanfactory  
instance owned by ModelGlue... just edit the index.cfm file for the  
MG application and uncomment the line that sets  
modelglue_PARENT_BEAN_FACTORY. Change it to something like this:

<cfset modelglue_PARENT_BEAN_FACTORY = application.beanfactory />

That's it, that's all. Since they're not both MG apps, there  
shouldn't be an issue with 2 instances of ColdSpring, the MG  
framework (and you can change the name of the application scope  
variable via index.cfm if you need to... check the comments there)  
and whatever else the non-MG app needs in the application scope. I  
can't think of any reason this won't work.

2) Different application scopes.
If you really really need this thing to work wtih different  
application scopes, you're going to need to do something like this in  
App 1's onApplicationStart():

<cfset server.apps[application.applicationname] = application>

Then in your MG app, when you need to reload the CFC in App 1's  
application scope, just do something like this:

<cfset server.apps.app1.constants = createObject 
("component","some.foo.path.to.Constants").init()>

where the string literal "constants" is replace by the actual name of  
the application scope variable that contains the CFC full of  
variables that app 1 needs. If you need to enable 2-way communication  
between these applications, then just add <cfset server.apps 
[application.applicationname] = application> to app 2's  
onApplicationStart() as well, so you could call things back and forth  
between them.

Another way to do this is to use Application.cfm with your MG app and  
leave off the name="" attribute. Do that, then dump the application  
scope. Shocking, no? Anyway, it's one way to make sure that an  
application has access to the application scopes of every application  
on the server. Great for server control apps and stuff... but at this  
point I don't think it works with Application.cfc (when you leave off  
the name, stuff gets really effed up with Application.cfc).

Anyway, just deciding to use hierarchical bean factories isn't enough  
for your situation... you need to either have 2 apps with the same  
application name or you need to provide a way for applications to  
cross the application scope boundaries... there's only 2 ways to do  
that and I've just hilited both of them. Frankly, there aren't many  
disadvantages either way, so I don't think either one is superior.  
Personally I'm always looking for opportunities to use the server  
scope, so I'd probably have my applications register with the server  
scope... but that's just me and only cuz I think it's the cooler of  
the 2 options. ;)

Laterz,
J

On Oct 23, 2008, at 12:44 AM, Andrew wrote:

>
> Hi Dan,
>
> As discussed off-list I have finally decided to bite the bullet and
> try this option.
>
> However I am going to need some help with the nuts and bolts of
> actually doing it.
>
> Say I create a Bean Factory in app1 called "app1BeanFactory":
>
> ie. Somewhere in app1: ...

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

For more about Model-Glue, check http://www.model-glue.com .
-~----------~----~----~----~------~----~------~--~---

Reply via email to