This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<servlet> | |
<servlet-name>Jersey Web Application</servlet-name> | |
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> | |
<init-param> | |
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name> | |
<param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value> | |
</init-param> | |
<init-param> | |
<param-name>com.sun.jersey.config.property.packages</param-name> | |
<param-value>com.vasilrem.ideabox.web.resources</param-value> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ResourcesUtil { | |
def serializeAsJSON(obj: AnyRef): String = new String(Serializer.SJSON.out(obj)) | |
def deserializeJSON[T](json: Array[Byte])(implicit m: Manifest[T]): AnyRef = | |
Serializer.SJSON.in[T](json)(m) | |
} | |
@Path("/idea") | |
class IdeaResource extends ResourcesUtil{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@BeanInfo | |
case class Author(id: String, name: String) extends DomainClass{ | |
private def this() = this(null, null) | |
} | |
@BeanInfo | |
case class Topic(id: String, name: String) extends DomainClass{ | |
private def this() = this(null, null) | |
} | |
@BeanInfo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Data public class Topic{ | |
private final String id; | |
private final String name; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Topic(id: String, name: String) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Topic { | |
private final String id; | |
private final String name; | |
public Topic(String id, String name) { | |
this.id = id; | |
this.name = name; | |
} | |
public String getId() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doBeforeSpec{ | |
preparedFunction.loadPreparedFunctions(List(“/mongo/preparedFunctions.js”)) | |
} | |
“Calls prepared function ‘test’ with parameter ‘prepared’” in { | |
preparedFunction.call(“test(‘prepared’)”) must beEqualTo(“test prepared”) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def call(functionCall: String): Object = { | |
var ret:Object = null | |
MongoDB.use(DefaultMongoIdentifier) ( db => { | |
ret = db.eval(“db.eval(\”" + functionCall + “\”)”) | |
} | |
) | |
ret | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… | |
def loadPreparedFunctions(classPathResources: List[String]) = { | |
classPathResources.foreach { | |
resourceName => | |
val fileContent = new FileBulkReader(new File(getClass().getResource(resourceName).getFile)).read // load the files with server-side code | |
MongoDB.use(DefaultMongoIdentifier) ( db => { | |
db.eval( | |
fileContent // evaluate the code in mongo | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… | |
/** | |
* Just a small dummy function | |
* @param string any string | |
* @return ‘test $passed string$’ | |
*/ | |
test = function(string){ | |
return ‘test ‘ + string | |
} |