2727import org .jruby .runtime .ThreadContext ;
2828import org .jruby .runtime .builtin .IRubyObject ;
2929
30+ import static org .jruby .rack .RackLogger .Level .*;
3031import static org .jruby .rack .DefaultRackConfig .isIgnoreRUBYOPT ;
3132
3233/**
@@ -77,14 +78,15 @@ public void setRackupScript(String rackupScript) {
7778 * NOTE: exception handling is left to the outer factory.
7879 * @param rackContext
7980 */
81+ @ Override
8082 public void init (final RackContext rackContext ) {
8183 // NOTE: this factory is not supposed to be directly exposed
8284 // thus does not wrap exceptions into RackExceptions here ...
8385 // same applies for #newApplication() and #getApplication()
8486 this .rackContext = (ServletRackContext ) rackContext ;
8587 if ( getRackupScript () == null ) resolveRackupScript ();
8688 this .runtimeConfig = createRuntimeConfig ();
87- rackContext .log (RackLogger . INFO , runtimeConfig .getVersionString ());
89+ rackContext .log (INFO , runtimeConfig .getVersionString ());
8890 configureDefaults ();
8991 }
9092
@@ -94,6 +96,7 @@ public void init(final RackContext rackContext) {
9496 * NOTE: exception handling is left to the outer factory.
9597 * @return new application instance
9698 */
99+ @ Override
97100 public RackApplication newApplication () {
98101 return createApplication (new ApplicationObjectFactory () {
99102 public IRubyObject create (Ruby runtime ) {
@@ -108,6 +111,7 @@ public IRubyObject create(Ruby runtime) {
108111 * NOTE: exception handling is left to the outer factory.
109112 * @return new, initialized application
110113 */
114+ @ Override
111115 public RackApplication getApplication () {
112116 final RackApplication app = newApplication ();
113117 app .init ();
@@ -120,13 +124,15 @@ public RackApplication getApplication() {
120124 * NOTE: exception handling is left to the outer factory.
121125 * @param app the application to "release"
122126 */
127+ @ Override
123128 public void finishedWithApplication (final RackApplication app ) {
124129 if ( app != null ) app .destroy ();
125130 }
126131
127132 /**
128133 * @return the (default) error application
129134 */
135+ @ Override
130136 public RackApplication getErrorApplication () {
131137 if (errorApplication == null ) {
132138 synchronized (this ) {
@@ -146,6 +152,7 @@ public synchronized void setErrorApplication(RackApplication errorApplication) {
146152 this .errorApplication = errorApplication ;
147153 }
148154
155+ @ Override
149156 public void destroy () {
150157 if (errorApplication != null ) {
151158 synchronized (this ) {
@@ -159,7 +166,7 @@ public void destroy() {
159166
160167 public IRubyObject createApplicationObject (final Ruby runtime ) {
161168 if (rackupScript == null ) {
162- rackContext .log (RackLogger . WARN , "no rackup script found - starting empty Rack application!" );
169+ rackContext .log (WARN , "no rackup script found - starting empty Rack application!" );
163170 rackupScript = "" ;
164171 }
165172 checkAndSetRackVersion (runtime );
@@ -178,7 +185,7 @@ public IRubyObject createErrorApplicationObject(final Ruby runtime) {
178185 errorApp = IOHelpers .inputStreamToString (rackContext .getResourceAsStream (errorApp ));
179186 }
180187 catch (IOException e ) {
181- rackContext .log (RackLogger . WARN ,
188+ rackContext .log (WARN ,
182189 "failed to read jruby.rack.error.app.path = '" + errorApp + "' " +
183190 "will use default error application" , e );
184191 errorApp = errorAppPath = null ;
@@ -212,7 +219,7 @@ public IRubyObject create(Ruby runtime) {
212219 return app ;
213220 }
214221 catch (Exception e ) {
215- rackContext .log (RackLogger . WARN , "error application could not be initialized" , e );
222+ rackContext .log (WARN , "error application could not be initialized" , e );
216223 return new DefaultErrorApplication (rackContext ); // backwards compatibility
217224 }
218225 }
@@ -265,12 +272,11 @@ protected RubyInstanceConfig initRuntimeConfig(final RubyInstanceConfig config)
265272 setUpdateNativeENVEnabled .invoke (config , false );
266273 }
267274 catch (NoSuchMethodException e ) { // ignore method has been added in JRuby 1.6.7
268- rackContext .log (RackLogger . DEBUG , "envronment changes made inside one app " +
275+ rackContext .log (DEBUG , "envronment changes made inside one app " +
269276 "might affect another, consider updating JRuby if this is an issue" );
270277 }
271278 catch (IllegalAccessException e ) {
272- rackContext .log (RackLogger .WARN , "failed to disable updating native environment" , e );
273- // throw new RackException(e);
279+ rackContext .log (WARN , "failed to disable updating native environment" , e );
274280 }
275281 catch (InvocationTargetException e ) {
276282 throw new RackException (e .getTargetException ());
@@ -324,7 +330,7 @@ protected RubyInstanceConfig initRuntimeConfig(final RubyInstanceConfig config)
324330 }
325331 }
326332 catch (Exception e ) {
327- rackContext .log (RackLogger . DEBUG , "won't set-up jruby.home from jar" , e );
333+ rackContext .log (DEBUG , "won't set-up jruby.home from jar" , e );
328334 }
329335
330336 return config ;
@@ -398,7 +404,7 @@ String checkAndSetRackVersion(final Ruby runtime) {
398404 rackVersion = IOHelpers .rubyMagicCommentValue (rackupScript , "rack.version:" );
399405 }
400406 catch (Exception e ) {
401- rackContext .log (RackLogger . DEBUG , "could not read 'rack.version' magic comment from rackup" , e );
407+ rackContext .log (DEBUG , "could not read 'rack.version' magic comment from rackup" , e );
402408 }
403409
404410 if ( rackVersion == null ) {
@@ -411,7 +417,7 @@ String checkAndSetRackVersion(final Ruby runtime) {
411417 runtime .evalScriptlet ("require 'bundler/setup'" );
412418 }
413419 else {
414- rackContext .log (RackLogger . DEBUG , "detected 'rack.version' magic comment, " +
420+ rackContext .log (DEBUG , "detected 'rack.version' magic comment, " +
415421 "will use `gem 'rack', '" + rackVersion +"'`" );
416422 runtime .evalScriptlet ("gem 'rack', '" + rackVersion +"' if defined? gem" );
417423 }
@@ -481,7 +487,7 @@ private void captureMessage(final RaiseException re) {
481487 rubyException .callMethod (context , "store" );
482488 }
483489 catch (Exception e ) {
484- rackContext .log (RackLogger . INFO , "failed to capture exception message" , e );
490+ rackContext .log (INFO , "failed to capture exception message" , e );
485491 // won't be able to capture anything
486492 }
487493 }
@@ -535,7 +541,7 @@ private String resolveRackupScript() throws RackInitializationException {
535541 rackup = IOHelpers .inputStreamToString (rackContext .getResourceAsStream (rackup ));
536542 }
537543 catch (IOException e ) {
538- rackContext .log (RackLogger . ERROR , "failed to read rackup from '" + rackup + "' (" + e + ")" );
544+ rackContext .log (ERROR , "failed to read rackup from '" + rackup + "' (" + e + ")" );
539545 throw new RackInitializationException ("failed to read rackup input" , e );
540546 }
541547 }
0 commit comments