Skip to content

Commit 2e647e9

Browse files
committed
extension point to retrieving the "real-context" + notes on more API support in 1.2
1 parent e4428df commit 2e647e9

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/main/java/org/jruby/rack/RackContext.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* @author nicksieger
1414
*/
1515
public interface RackContext extends RackLogger {
16-
RackConfig getConfig();
16+
RackConfig getConfig(); /// NOTE: deprecate ?
1717
String getServerInfo();
18+
// TODO more methods from ServletContext here ?!
1819
}

src/main/java/org/jruby/rack/servlet/DefaultServletRackContext.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public RackApplicationFactory getRackFactory() {
6767
return (RackApplicationFactory) context.getAttribute(RackApplicationFactory.FACTORY);
6868
}
6969

70+
public ServletContext getContext() {
71+
return context;
72+
}
73+
7074
public ServletContext getContext(String path) {
7175
return context.getContext(path);
7276
}
@@ -177,4 +181,15 @@ public void log(String level, String message, Throwable e) {
177181
logger.log(level, message, e);
178182
}
179183

184+
// Helpers
185+
186+
ServletContext getRealContext() { return getContext(); }
187+
188+
public static ServletContext getRealContext(final ServletContext context) {
189+
if ( context instanceof DefaultServletRackContext ) {
190+
return ((DefaultServletRackContext) context).getRealContext();
191+
}
192+
return context;
193+
}
194+
180195
}

src/main/java/org/jruby/rack/servlet/ServletRackContext.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ public interface ServletRackContext extends RackContext, ServletContext {
2121

2222
RackApplicationFactory getRackFactory();
2323

24+
// ServletContext getRealContext(); // TODO support this in 1.2
25+
2426
}

0 commit comments

Comments
 (0)