Skip to content

Commit b9f325a

Browse files
mkristiankares
authored andcommitted
introduce a new layout where the whole application + gems are packed under WEB-INF/classes
when the app.root points to uri:classloader:// the rack-application can be packed one-to-one into WEB-INF/classes. similar for setting gem.path to uri:classloader:// allows to embed the gems in WEB-INF/classes.
1 parent cdbf438 commit b9f325a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/main/ruby/jruby/rack/app_layout.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def expand_path(path)
4040
def real_path(path)
4141
real_path = @rack_context.getRealPath(path)
4242
real_path.chomp!('/') if real_path
43+
# just use the given path if there is no real path
4344
real_path
4445
end
4546

@@ -91,6 +92,31 @@ def expand_path(path)
9192

9293
RailsWebInfLayout = WebInfLayout
9394

95+
class ClassPathLayout < WebInfLayout
96+
97+
URI_CLASSLOADER = 'uri:classloader://'
98+
99+
def real_path(path)
100+
if path.start_with? URI_CLASSLOADER
101+
path
102+
else
103+
super
104+
end
105+
end
106+
107+
def app_uri
108+
@app_uri ||=
109+
@rack_context.getInitParameter('app.root') ||
110+
URI_CLASSLOADER
111+
end
112+
113+
def gem_uri
114+
@gem_uri ||=
115+
@rack_context.getInitParameter('gem.path') ||
116+
URI_CLASSLOADER
117+
end
118+
end
119+
94120
# @deprecated will be removed (with Merb support)
95121
class MerbWebInfLayout < WebInfLayout
96122

0 commit comments

Comments
 (0)