Legacy App, with one FW/1 app and now want to add another

50 views
Skip to first unread message

Matthew C. Parks

unread,
Oct 26, 2017, 7:50:56 AM10/26/17
to framework-one
I had some real learning curve back in Jan 2016 with this idea and I got over it BUT now adding a second FW/1 app is getting me back to another question I can not get over.

I have these first two up and running

/Application.cfc
/CEApp.cfc
I would like to add another one like this:
/DonationApp.cfc
But how does this suppose to work in the Application.cfc?

I thought like this:
/Application.cfc
<code>
...
<cffunction name="_get_framework_one" access="public" output="false" hint="Fires when the application is first created.">
        <cfscript>
            if ( !structKeyExists( request, '_framework_one' ) ) {

                request._framework_one = new CEApp({
                    password : "pwd",
                    generateSES : true,
                    trace : true

                });
                request._framework_one = new Donation({

                    password : "pwd",
                    generateSES : true,
                    trace : true

                });
            }

            return request._framework_one;

        </cfscript>
    </cffunction>
...
</code>

My understanding is that you could have as many as you wanted of these little FW/1 application as a part of the whole application.  The first one like I said was working, when I added the request._framework_one = New Donation...... the existing and the new application don't work any longer.

The existing application is complaining about some function that does exist, doesn't exists.  I remove the Donation block and it works again.

I have to add that I did make sure that the onRequestStart(), onRequest(), and onRequestEnd()  to all delegate to FW/1 for the existing and new FW/1 application.  Maybe it is a subsystem setting that I need to consider?

FW/1 4.1.0
CF11 u13
JRE1.8.0_151

Thank you in advance.
Matthew C. Parks



Sean Corfield

unread,
Oct 26, 2017, 12:50:43 PM10/26/17
to framew...@googlegroups.com

You are overwriting the first app with the second by these two lines:

 

                request._framework_one = new CEApp({

                …

                request._framework_one = new Donation({

 

Separate applications must have separate Application.cfc files and separate application names – that’s a CFML thing (not a FW/1 thing).

 

Sean

--
FW/1 documentation: http://framework-one.github.io
FW/1 source code: http://github.com/framework-one/fw1
FW/1 chat / support: https://gitter.im/framework-one/fw1
FW/1 mailing list: http://groups.google.com/group/framework-one
---
You received this message because you are subscribed to the Google Groups "framework-one" group.
To unsubscribe from this group and stop receiving emails from it, send an email to framework-on...@googlegroups.com.
Visit this group at https://groups.google.com/group/framework-one.
For more options, visit https://groups.google.com/d/optout.

 

Matthew C. Parks

unread,
Oct 26, 2017, 3:15:31 PM10/26/17
to framework-one
Sean,

that makes sense on what I am seeing happen.  The donation is overriding CEApp.

So what I am attempting to do is add another FW/1 subsystem to the main legacy FuseBox application that already has one FW/1 application that is really a subsystem of the legacy application.

Could I accomplish this by defining another request._framework_one_A = new Donation maybe.  I am reaching here just kicking around a few ideas but not sure I am going to be able to do this.

Thanks for your input.

Nathan Strutz

unread,
Oct 26, 2017, 7:15:57 PM10/26/17
to framew...@googlegroups.com

Just a quick question, Matthew. Is it possible you just want to add a new section, maybe also a controller, to your legacy app? Is there really a reason to add in a subsystem or create an entirely new application? Just on the surface or seems like you are adding a section, maybe it could just be a controller and some views.

--

-Nathan Strutz

Sean Corfield

unread,
Oct 26, 2017, 7:51:00 PM10/26/17
to framew...@googlegroups.com

So what I am attempting to do is add another FW/1 subsystem to the main legacy FuseBox application that already has one FW/1 application that is really a subsystem of the legacy application.

 

Subsystems are not applications. A new subsystem would just be part of your (existing) CEApp. One FW/1 app, multiple subsystems.

 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

Matthew C. Parks

unread,
Oct 27, 2017, 8:35:17 AM10/27/17
to framework-one
Nathan,

The application as a whole is a FuseBox application and then other parts are FuseBox "applications" that then don't use any of the bigger application setting or security was added on there are about 5 of these.

I had added an FW/1 application that added a larger application into the FW/1 framework.  It worked perfectly and is so much easier to maintain.

So now I am faced with the removal of another part of the site and I wanted to move that also into FW/1.  The existing FuseBox application that I will be rewriting into FW/1 is a stand alone. I wanted to get it to use some parts that are already in place.  It is not really an Application by itself nor a subsystem since the Legacy Application is not FW/1.

So I am thinking the 

/Application.cfc

    function _get_framework_one() {

            if ( !structKeyExists( request, '_framework_one' ) ) {

                request._framework_one = new CEApp({
                });

            }

            return request._framework_one;
       }

   function _get_framework_one_donation() {

            if ( !structKeyExists( request, '_framework_one_donation' ) ) {

                request._framework_one = new Donation({
                });

            }

            return request._framework_one;
       }

Then making sure to then delegate to the correct onFUNCTION (so to speak) based on the code directory.

I am thinking this will meet my need based on my initial investigations.

Anyone see any issues with this?  Suggestions if I am off based would be great.

Sean Corfield

unread,
Oct 27, 2017, 5:33:39 PM10/27/17
to framew...@googlegroups.com

Aside from structKeyExists( request, '_framework_one_donation' ) should be structKeyExists( request, '_framework_one' ) …

 

…make sure each FW/1 app has a unique name via applicationKey in your FW/1 configuration struct for each app. In theory that will allow two separate FW/1 apps to exist within the same CFML “application”.

 

I think it still won’t work tho’… you’ll have just one CFML “application” so onApplicationStart() will only run once, for whichever app gets the first request – your Fusebox app, CEApp, or Donation – so setupApplication() in FW/1 may be called for one app or for the other (or for neither). The same is true for each user session and onSessionStart().

 

You are only likely to be able to make this work if you have just ONE FW/1 app and you either route to the FB app or the FW/1 app (and thus use subsystems if you want to keep these “separate” pieces – CEApp and the Donation stuff – self-contained). Having multiple “sub-apps” is exactly what subsystems are designed for.

 

Trying to fight the framework in the manner you’re proposing is just going to cause you pain – and no one here is likely to be able to offer support if (when!) you run into bizarre problems caused by interactions between your two dueling applications.

 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

 


From: 'Matthew C. Parks' via framework-one <framew...@googlegroups.com>
Sent: Friday, October 27, 2017 5:35:17 AM
To: framework-one
Subject: Re: [framework-one] Legacy App, with one FW/1 app and now want to add another
 

Cameron Childress

unread,
Oct 30, 2017, 10:36:13 AM10/30/17
to framew...@googlegroups.com
Matthew-

I have few ideas for you here. 

First off, as others have suggested I highly recommend that you attempt to use subsystems for this. It really is the best way to handle what you seem to be considering "sub-applications". If you are resisting this idea because subsystems seem complicated or you think that they don't solve your problem somehow, perhaps ask some additional questions on the list around whatever is worrying you about subsystems.

Secondly, if you really do want to have two applications that also share some components, I would explore separating the two applications using sets of includes. Here is a basic example:

component extends = 'libs.fw1.framework.one' {

if ( sometest eq 'CEAPP' ) {
request.appswitch = 'ceapp';
} else {
request.appswitch = 'donation';

if ( request.appswitch eq 'ceapp' ) {
include "/config/ceapp/_app.cfm"; // application scope things that are specific to ceapp
include "/config/ceapp/_fw1.cfm"; // FW/1 configuration that is specific to ceapp
} else {
include "/config/donation/_app.cfm"; // application scope things that are specific to donation app
include "/config/donation/_fw1.cfm"; // FW/1 configuration that is specific to donation app
}

include "/config/orm.cfm"; // things are that common config options between the two apps go here

}

This will let you mix and match differences and similarities between you applications which "driving them" all in one single location. In reality I typically will also do the environment test in it's own include as well so that I could add a bunch of other application specific settings in there like datasource definitions but I put it inline in this example just so I'd be adding less code.

-Cameron

--
Cameron Childress
p:   678.637.5072

Sean Corfield

unread,
Oct 30, 2017, 6:32:03 PM10/30/17
to framew...@googlegroups.com

Secondly, if you really do want to have two applications that also share some components, I would explore separating the two applications using sets of includes. Here is a basic example:

 

Pretty sure that won’t work for exactly the reasons I was outlining in my post – application/session initialization etc – unless you’re suggestion different CFML application names as well? Would _app.cfm include all the this.whatever settings normally in Application.cfc?

 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

 


From: framew...@googlegroups.com <framew...@googlegroups.com> on behalf of Cameron Childress <came...@gmail.com>
Sent: Monday, October 30, 2017 7:35:50 AM
To: framew...@googlegroups.com
Subject: Re: [framework-one] Legacy App, with one FW/1 app and now want to add another
 

Cameron Childress

unread,
Oct 31, 2017, 9:22:23 AM10/31/17
to framew...@googlegroups.com
On Mon, Oct 30, 2017 at 6:30 PM, Sean Corfield wrote:

Pretty sure that won’t work for exactly the reasons I was outlining in my post – application/session initialization etc – unless you’re suggestion different CFML application names as well? Would _app.cfm include all the this.whatever settings normally in Application.cfc?


Yes. Usually my /config/appname/_app.cfm file will contain all the normal "this" scope things for the application scope, including different names, if needed. This lets you mix and match things that need to be different (application name or settings) with thing you may want to share (ORM/model config).

One example where I've used this before is for two applications that share a model, but one needs to use sessions for authentication and the other might be serving an API or handling schedule tasks and doesn't need session scope. In fact the session scope could be harmful in some of those situations.

Yes, there are other ways to handle this but the above works pretty well.

-Cameron

Reply all
Reply to author
Forward
0 new messages