views:

138

answers:

6

Let me first say I am aware of this faq for Mach-II, which discusses using application specific mappings as a third option when:

  1. locating the framework in the server root is not possible and

  2. creating a server wide mapping to the Mach-II framework directory is impossible

Using application specific mappings would also work for other ColdFusion frameworks with similar requirements (ColdSpring). Here is my issue however: my (I should say "their") production servers are all running ColdFusion MX7, and application specific mappings were introduced in ColdFusion 8. I most likely will be unable to do option 1 or 2 because they involve creating server wide changes that could conflict with other applications (I don't have a final word on this but I am preparing for that to be the case).

That said, is there anybody out there who was in similar bind and has done an option 4, in any ColdFusion version, or with any similar framework? The only option 4 I can think of is modifying the entire framework to change this hardcoded path, and even if that worked it would be time consuming and risky. I'm fairly sure that if there was a simple modification or other simple solution it would already be included in the framework (maybe it's included in version 1.8 of Mach-II and I don't know about it yet).

Any thoughts on solving this problem or even unorthodox setups with libraries that have specific path requirements would be appreciated. Any thoughts from Team Mach-II would especially appreciated...we're on the same team here Matt! ;-)

EDIT

Apparently, the ColdBox framework includes a refactor.xml ANT task which includes a target that refactors the ColdBox code to use a different absolute path as a base along with several other useful refactoring targets. So problem solved for ColdBox users.

Looking at the build.xml for Mach-II (1.6 and 1.8) I don't see any target in there that would allow me to refactor the code. I thought about creating a feature request ticket for such a task for Mach-II but frankly I don't think creating such an ANT task is a big priority for the MachII team since the need really only relates to either

  • a) users of ColdFusion versions below 8
  • b) someone who wants to use multiple Mach-II versions in the same application, a use I doubt they want to support

The ColdSpring code I have doesn't come with any ANT tasks at all, although I do have unit tests, and I bet if I poked around the SVN I'd find a few build scripts.

Using Ant tasks to refactor and retest the code, or the simpler (and sort of cop out) solution of creating a separate ColdFusion instance for the application are the best answers I've been able to come up with. I don't need this application to exist in the shared scope of other applications, so my first solution is going to be to try and get a dedicated CF instance for this application.

I'm also going to look at the ColdBox refactor.xml ANT task however and see if I can modify it to work generically to recognize and refactor CFC references with modified absolute paths. If I complete this task I'll be sure to post the code somewhere and edit create an answer to link to it. If anybody else wants to take a crack at that or help me out with it feel free.

Until then I'll leave this question open and see if someone comes up with a better solution.

+2  A: 

Fusebox is not so strict, I think.

In XML mode (maybe I call this not 100% correcly, just mean using the Application.cfm) it's just proper include in index.cfm, something like:

<cfinclude template="fusebox5/fusebox5.cfm" />

In non-XML mode it will need proper extending in the root Application.cfc:

<cfcomponent extends="path.to.fusebox5.Application" output="false">

All you need is to know the path.

Sergii
I can't seem to get the skeleton app to work, but assuming what you are saying is true, looking at the directory structure of the core files, all the CFC's that call/instantiate each other are in the same directory, so consequently they references to the core components can and in fact seem to use relative paths. In MachII the framework CFC's are 1) much more numerous and 2) tucked away in packages. The way I was planning on modifying the framework was going to be setting it up the way Fusebox is, all the framework components flat in a directory and make all path references relative
Ryan Lynch
However, the Mach-II framework is fairly voluminous, and without also recreating/modifying the Mach-II unit tests and running them on the modified framework, I couldn't be sure I hadn't screwed anything up. Altogether its a lot of work.
Ryan Lynch
A: 

A solution I ran across in stackoverflow to a different but related problem suggested creating a separate instance of ColdFusion on the server. This would allow me to go with option 1) without creating conflicts with other applications on the server. I'm not looking forward to floating this one to the sys-admins though so I am hoping there is another solution out there.

Ryan Lynch
+1  A: 

Perhaps you could create a symbolic link and let the operating system resolve the issue for you?

Aaron Greenlee
I'm not sure if ColdFusion follows symbolic links when resolving paths to object definitions, but if it did I think that would work in the same way as the mapping in option 1)
Ryan Lynch
Thanks to @LucasS for the additional info on using symbolic links in CFMX7. I see what you are getting at now, this would work well. Unfortunately not for me because my apps aren't running on Unix servers. This is a good answer though. The way you would have to implement this is to put a symbolic link to the package root in each sub-directory of the package, and since CF looks for a relative path first, this would make the absolute paths in the components valid relative links. Good stuff, a creative and simple solution.
Ryan Lynch
+1  A: 

Following on from Aaron's response, Sympolic links are supported and followed by CF7/8 so this could be a very easy solution, if your sys admin lets it through. Unfortunatly it will not help you if your on windows

(sorry, i think this should be a comment but as I am new here, i can't comment so feel free to move/edit as needed)

LucasS
Interesting to know, but how would that be different than creating a server wide mapping?
Ryan Lynch
The symbolic link would exist in the applications directory structure--specific to the application. He is unable to create a server (or instance) wide mapping. Therefore I would expect the symbolic link would satisfy his unique challenge.
Aaron Greenlee
A: 

Hi Ryan,

Please file a ticket for the ANT task you mentioned in your question. Team Mach-II would love to have this issue logged:

Enter a new ticket on the Mach-II Trac

If you want to tackle an ANT task for us, we can get stuff like this incorporated into the builds faster than waiting to for a Team member to work on the ticket. Code submissions from the community are welcome and appreciated.

We don't keep an eye on Stack Overflow very often so we invite you to join our official community group at called "Mach-II for ColdFusion" at Google Groups. The Google Group is the best place to ask questions or comments like this if you want feedback from the Team.

Best, Peter J. Farrell Team Mach-II -- Lead Developer

Edit:

It should be as simple as dropping the 'MachII' folder at the root of your domain (i.e. example.com/MachII). No mappings are required to use Mach-II if you just deploy at the root of the domain of your website.

Peter J. Farrell
A: 

I've been playing with FW/1 lately, and while it may look like you need to add a mapping and extend org.corfield.framework, you can actually move the framework.cfc file into your web root and just extend="framework". It's dead simple, and gets you straight into a great framework with no mess and very little overhead.

Nathan Strutz