Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add sipatra option to load a sipatra app * add a generic sipatra app with log4j
- Loading branch information
Alexandre Moutot
committed
Jul 13, 2012
1 parent
9617588
commit 3771bc4
Showing
6 changed files
with
67 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'sipatra' | ||
require 'sipatra/log4j-1.2.17.jar' | ||
include_class "org.apache.log4j.Logger" | ||
|
||
if File.exists?("log4j.properties") | ||
include_class "org.apache.log4j.PropertyConfigurator" | ||
PropertyConfigurator.configure("log4j.properties") | ||
else | ||
include_class "org.apache.log4j.BasicConfigurator" | ||
BasicConfigurator.configure | ||
end | ||
|
||
begin | ||
load @app_file | ||
rescue Exception => e | ||
puts "Load Error : #{e.inspect}\n#{e.backtrace.join("\n")}" | ||
end | ||
|
||
class SipatraApp < Kipatra::Cipango::SipServlet | ||
def doRequest(req) | ||
invoke req, :do_request | ||
end | ||
|
||
def doResponse(req) | ||
invoke req, :do_response | ||
end | ||
|
||
private | ||
|
||
def invoke(msg, method_name) | ||
log = Logger.getLogger('Kipatra') | ||
app = Sipatra::Application::new | ||
session = msg.session | ||
app.set_bindings session.servlet_context, session.servlet_context.getAttribute(Kipatra::Cipango::SipServlet::SIP_FACTORY), session, msg, log | ||
app.send method_name | ||
end | ||
end | ||
|
||
SipatraApp.new |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
log4j.rootLogger=INFO, stdout | ||
|
||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender | ||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%t] %-5p %c %x - %m%n |