Skip to content

Commit

Permalink
Fixed #501: Requests get redirected to wrong routes (Java)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaliss committed Dec 10, 2014
1 parent 9c702c3 commit 961a6ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
master -
- Fixed #501: Requests get redirected to wrong routes (Java)
- Pull request #441: Update user-service.md (thanks @salaj1986)
- Pull request #495: disable generateRefReverseRouter (thanks @amertum)
- Pull request #461: Use large version of Facebook profile picture (thanks @nguyentruongtho)
Expand Down
22 changes: 7 additions & 15 deletions samples/java/demo/app/Global.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,21 @@
*/

import play.GlobalSettings;
import play.Logger;
import securesocial.core.RuntimeEnvironment;
import service.MyEnvironment;

import java.util.HashMap;

public class Global extends GlobalSettings {
private RuntimeEnvironment env = new MyEnvironment();
private HashMap<String, Object> instances = new HashMap<String, Object>();

@Override
public <A> A getControllerInstance(Class<A> controllerClass) throws Exception {
A result = (A) instances.get(controllerClass.getName());
Logger.debug("result = " + result);
if ( result == null ) {
Logger.debug("creating controller: " + controllerClass.getName());
try {
result = controllerClass.getDeclaredConstructor(RuntimeEnvironment.class).newInstance(env);
} catch (NoSuchMethodException e) {
// the controller does not receive a RuntimeEnvironment, delegate creation to base class.
result = super.getControllerInstance(controllerClass);
}
instances.put(controllerClass.getName(), result);
A result;

try {
result = controllerClass.getDeclaredConstructor(RuntimeEnvironment.class).newInstance(env);
} catch (NoSuchMethodException e) {
// the controller does not receive a RuntimeEnvironment, delegate creation to base class.
result = super.getControllerInstance(controllerClass);
}
return result;
}
Expand Down

0 comments on commit 961a6ea

Please sign in to comment.