java


Where to write and store mongoDB map/reduce functions in java project


Does anyone have any advice, or know of any best practice for where and how in a Java project to write and store javascript map/reduce functions for use with a MongoDB database?
The criteria I'm looking for are:
When writing and editing the functions I'd like the benefit of syntax highlighting and error checking provided by an IDE (I'm using Eclipse).
I don't want to have to copy the functions to a different location when I'm finished editing them, if possible.
I'd rather store the functions in the source code than the DB itself, for ease of reference, version control, etc.
Any examples of how you've solved this problem would be great.
EDIT: I'm not sure I've explained myself properly, so here's another go:
I'm not asking about basic resource management. What I'm after is, if possible, a working environment that allows me the benefits of my IDE while editing the functions 'in place'. You'll have to excuse me if I'm missing something blindingly obvious.
What I want to avoid are things such as you might see with SQL, such as when its stored as a String in a class file:
private static final String MAP_FUNC =
"function() { " +
" emit(this.id, {total : this.total}); " +
"};";
or in a java properties file:
map.func=function() {
\ emit(this.id, {total : this.total});
\ };
where you have to enter a load of extraneous characters such as "s and \s. You have to write it somewhere else, then copy and paste it in and add these characters in (or you might have a tool that does it for you - you still have to do it).
Since javascript is validated by Eclipse when it's written in .js files, I don't want to have to do any of this. I'd like to store the functions in .js files in such a way as they are ready for easy consumption by a map/reduce call when needed.
Does anyone do this, or similar? My initial idea was just to create a single .js file for each function, however a .js file with nothing but an anonymous function in it fails validation in eclipse, which makes it pointless - you have to assign it to a var - which means its not in the correct form for consumption by map/reduce. I suppose I could create files of just the content of the functions? But all this sounds a bit messy, and I was hoping someone else might have come across the problem, and have a neat solution.
The convention I use and I've seen in most open source projects (including Spring et al) is to put all non-java files under a resources directory, under a descriptive directory:
module-root/
src/
main/
java/
(Java sources go here)
resources/
log4j.xml
spring/ (spring xmls go here)
sql/ (sql scripts go here)
mongo/ (<-- seems like a good place for mongoDB functions)
test/
unit/
java/ (unit test java sources go here)
resources/ (unit test specific resources - usually none)
integration/
java/ (integration test java sources go here)
resources/
spring/ (usually an ITestAssembly.xml goes here)
The buildfile then packs the resources into a resource jar, which gets deployed along wiht all the other jars.
We place the JS files as application resources in the (Eclipse) project and then upon application initialisation those files are read by the Java apps (either web app or daemons in our case), stored in a singleton management class and then used as needed when invoking, say, a map/reduce.
It's relatively straightforward resource management.

Related Links

JUNG - Large graphs and vertex dragging
Evosuite: failure in executing test cases
Third option on JCheckBox? [duplicate]
How to recursively fill a tree with 4 children below each node in Java
how to use java code connection remote hadoop hdfs?
Maven Dependency & Java Service Provider Interface
How do I remove the background from image in Java using OpenCV with only single Image?
App won't build? DebugResources error?
Convert Date String into Epoch in Java [duplicate]
java write the output in comma delimited format
Force user to pass by Facebook Login when deep linking
java How to get chars after chars in a string in a http request
Group and Sort collection using Java 8 [duplicate]
JavaFX - Multidimensional hashmap is overwritten
How to introduce % in SQL consult in java
JavaFX / FXML - Get Height of a VBox [duplicate]

Categories

HOME
hook
reflection
smarty
react-virtualized
view
react-router
microservices
jsrender
retrofit
echarts
flyway4
swagger-ui
slick-slider
adobe-analytics
node-pdfkit
nano-server
midi
numeral.js
correlation
aurigma
propel
normalizr
django-cms
reverse-proxy
java-3d
errorlevel
mustache.php
wpfdatagrid
react-css-modules
saas
socialengine
iframe-resizer
.net-4.0
google-sites-2016
catch-all
webtest
caret
avcapturesession
asset-pipeline
android-nestedscrollview
geopositioning
http-referer
mmenu
restlet
mixture-model
objectlistview
theano.scan
angularjs-factory
eclipse-scout
powershell-dsc
unixodbc
slick-3.0
sencha-touch-2.3
rainbowtable
jedis
theming
typescript1.8
forever
ifs
smart-table
mediaelement
gnome-shell-extensions
objective-c-swift-bridge
root-framework
instant
grails-tomcat-plugin
radtreelist
savon
elements
firebaseui
sigabrt
php-internals
xpath-1.0
r-tree
prerequisites
cannon.js
mutation-observers
atk4
kcachegrind
angular-leaflet-directive
muse
twirl
myo
fluid-dynamics
web-controls
c3
rdtsc
google-reader
jubula
marmalade
cloud-connect
flexmojos
soundtouch
coverflow
dataadapter
ocunit
android-hardware
unc
bitsharp
quickdialog
funscript
broken-links
twrequest
pendrive
php-parser
libc++
nsobject
external-accessory
self-extracting
iphone-web-app
blitz++
asp.net-profiles
multi-tier
web-architecture
nintendo-ds
django-notification

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App