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
/** | |
* Abstract class which bootstraps the Spring MVC system on top of the OSGI interface 'JettyService' on startup. | |
*/ | |
public abstract class AbstractOsgiSpringMvcApplication implements BundleContextAware,InitializingBean | |
{ | |
private BundleContext bundleContext; | |
private JettyService jettyService; | |
private Handler registered; | |
public abstract String getContextConfigLocation(); |
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
server.all('/admin/content/add_article',function(req,res) | |
{ | |
server.form('post',req,res,function(form) { | |
form.required('title') | |
form.optional('tags') | |
form.required('slug') | |
form.required('body') | |
form.valid(function(form) { | |
res.send('Creating blog post titled : ' + form.values.title) |
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 MyWebAppinitializer extends StandardWebAppInitializer { | |
//customize the creatino of the web application context | |
@Override | |
protected WebApplicationContext createWebApplicationContext() { | |
AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); | |
root.scan("com.whatever"); | |
root.getEnvironment().setDefaultProfiles("embedded"); | |
return root; |
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
@Controller | |
@RequestMapping(value="/") | |
public class MultipleFileUploadExample | |
{ | |
Logger log = Logger.getLogger(NewController.class); | |
@RequestMapping(method=RequestMethod.POST) | |
public String onMultipleFiles(MultipartHttpServletRequest request) | |
{ |
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
import static org.mockito.Mockito.*; | |
/** | |
* Boostraps a MultipartHttpServletRequest using mockito. | |
* To add a request parameter, define a method called 'parameterName', where request attribute is 'name'. | |
* To add a multipart file, define a method called 'fileName', where the multipart file is called 'name'. | |
* Class is very limited but works as it should providing you use a specific subset of the methods on {@link MultipartHttpServletRequest}. | |
* Subset: | |
* MultipartHttpServletRequest.getParameter | |
* MultipartHttpServletRequest.getFileMap |
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
module.exports = function url_rewrite_based_on_hostname(hostname,prefix_path){ | |
if (!hostname) throw new Error('url rewrite hostname required'); | |
if (!prefix_path) throw new Error('url rewrite prefix path required'); | |
var regexp = new RegExp('^' + hostname.replace(/[*]/g, '(.*?)') + '$'); | |
// this is the actual middleware implementation, that is called when you get an HTTP request. | |
return function fn(req, res, next){ | |
if (!req.headers.host) return next(); // skip if there is no HOST header. | |
var host = req.headers.host.split(':')[0]; // get the HOST header |
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
mvn install:install-file -DgroupId=org.ops4j.pax.runner.profiles -DartifactId=karaf.shell.new -Dversion=2.2.1 -Dfile=karaf.shell-2.2.1.composite -Dpackaging=composite |
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
package us.gaje.example.web; | |
public class ExampleWebAppInitializer extends GajeStandardWebAppInitializer{ | |
@Override | |
protected WebApplicationContext createWebApplicationContext() { | |
AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); | |
root.getEnvironment().setDefaultProfiles("embedded"); | |
root.scan("us.gaje.example.web.config"); | |
return root; |
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
@Bean | |
public Map<String, DocumentPackage> mockDpBucket() { | |
return new HashMap<String, DocumentPackage>(); | |
} | |
class WildcardExtractingHamcrestMatcher extends ArgumentMatcher<String> { | |
String regex; | |
public WildcardExtractingHamcrestMatcher(String reg) { | |
this.regex = reg; |
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
import java.io.Serializable; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.Map; | |
import org.springframework.data.domain.Page; | |
import org.springframework.data.domain.Pageable; | |
import org.springframework.data.domain.Sort; |
OlderNewer