Skip to content

Commit

Permalink
Added vim ignore swap file to gitignore.
Browse files Browse the repository at this point in the history
The "bind" function in RestExpress did not allow me to take the handler and add it to my own pipeline (outside of a system that traditionally holds it's own "main").
  • Loading branch information
Ryan Dietrich committed Jul 15, 2013
1 parent 8e6cd12 commit 9f9fdf7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ target/
.project
.classpath
.settings
*.swp
37 changes: 24 additions & 13 deletions src/java/com/strategicgains/restexpress/RestExpress.java
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,29 @@ public Channel bind()
return bind((getPort() > 0 ? getPort() : DEFAULT_PORT));
}

/**
* Build a default request handler so it may be used injected into any existing pipeline.
*
* @return DefaultRequestHandler
*/
public DefaultRequestHandler buildRequestHandler() {
// Set up the event pipeline factory.
DefaultRequestHandler requestHandler = new DefaultRequestHandler(
createRouteResolver(), createResponseProcessorResolver());

// Add MessageObservers to the request handler here, if desired...
requestHandler.addMessageObserver(messageObservers.toArray(new MessageObserver[0]));

requestHandler.setExceptionMap(exceptionMap);

// Add pre/post processors to the request handler here...
addPreprocessors(requestHandler);
addPostprocessors(requestHandler);
addFinallyProcessors(requestHandler);

return requestHandler;
}

/**
* The last call in the building of a RestExpress server, bind() causes
* Netty to bind to the listening address and process incoming messages.
Expand All @@ -642,19 +665,7 @@ public Channel bind(int port)
bootstrap = Bootstraps.createServerNioBootstrap(getIoThreadCount());
}

// Set up the event pipeline factory.
DefaultRequestHandler requestHandler = new DefaultRequestHandler(
createRouteResolver(), createResponseProcessorResolver());

// Add MessageObservers to the request handler here, if desired...
requestHandler.addMessageObserver(messageObservers.toArray(new MessageObserver[0]));

requestHandler.setExceptionMap(exceptionMap);

// Add pre/post processors to the request handler here...
addPreprocessors(requestHandler);
addPostprocessors(requestHandler);
addFinallyProcessors(requestHandler);
DefaultRequestHandler requestHandler = buildRequestHandler();

PipelineBuilder pf = new PipelineBuilder()
.addRequestHandler(requestHandler)
Expand Down

0 comments on commit 9f9fdf7

Please sign in to comment.