{"action":"created","issue":{"url":"https://api.github.com/repos/playframework/playframework/issues/4592","labels_url":"https://api.github.com/repos/playframework/playframework/issues/4592/labels{/name}","comments_url":"https://api.github.com/repos/playframework/playframework/issues/4592/comments","events_url":"https://api.github.com/repos/playframework/playframework/issues/4592/events","html_url":"https://github.com/playframework/playframework/issues/4592","id":83418297,"number":4592,"title":"[2.4] Getting dependency instance from Injector by BindingKey<T> in PlayJava.","user":{"login":"jCalamari","id":9678999,"avatar_url":"https://avatars.githubusercontent.com/u/9678999?v=3","gravatar_id":"","url":"https://api.github.com/users/jCalamari","html_url":"https://github.com/jCalamari","followers_url":"https://api.github.com/users/jCalamari/followers","following_url":"https://api.github.com/users/jCalamari/following{/other_user}","gists_url":"https://api.github.com/users/jCalamari/gists{/gist_id}","starred_url":"https://api.github.com/users/jCalamari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jCalamari/subscriptions","organizations_url":"https://api.github.com/users/jCalamari/orgs","repos_url":"https://api.github.com/users/jCalamari/repos","events_url":"https://api.github.com/users/jCalamari/events{/privacy}","received_events_url":"https://api.github.com/users/jCalamari/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/playframework/playframework/labels/community","name":"community","color":"006b75"},{"url":"https://api.github.com/repos/playframework/playframework/labels/newbie","name":"newbie","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-06-01T10:07:30Z","updated_at":"2015-06-02T09:19:46Z","closed_at":null,"body":"This is how I inject dependencies programmatically: \r\n\r\n```\r\nPlay.application().injector().instanceOf((new BindingKey<>(SomeService.class, Option.apply(new QualifierClass<>(SomeAnnotation.class))));\r\n```\r\nAs you can see, it is a long chain of calls. Moreover, I am forced to use scala api (BindingKey, Option) to get the desired instance. Is there a better and syntax-short way (java way) to get java dependency? Would you consider implementing something similar to [Google Guice Key API](http://google.github.io/guice/api-docs/latest/javadoc/index.html?com/google/inject/Key.html) - especially static get methods?\r\n\r\nEdit: I have just found play.inject.Bindings class however it contains only one method, no annotation allowed:\r\n```\r\npackage play.inject;\r\n\r\nimport play.api.inject.BindingKey;\r\n\r\npublic class Bindings {\r\n\r\n    /**\r\n     * Create a binding key for the given class.\r\n     */\r\n    public static final <T> BindingKey<T> bind(Class<T> clazz) {\r\n        return new BindingKey(clazz);\r\n    }\r\n\r\n}\r\n```\r\nBrief implementation:\r\n```\r\npublic static <T> BindingKey<T> bind(Class<T> clazz, Class<? extends Annotation> annotation) {\r\n        return bind(clazz).qualifiedWith(annotation);\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/playframework/playframework/issues/comments/107881803","html_url":"https://github.com/playframework/playframework/issues/4592#issuecomment-107881803","issue_url":"https://api.github.com/repos/playframework/playframework/issues/4592","id":107881803,"user":{"login":"jCalamari","id":9678999,"avatar_url":"https://avatars.githubusercontent.com/u/9678999?v=3","gravatar_id":"","url":"https://api.github.com/users/jCalamari","html_url":"https://github.com/jCalamari","followers_url":"https://api.github.com/users/jCalamari/followers","following_url":"https://api.github.com/users/jCalamari/following{/other_user}","gists_url":"https://api.github.com/users/jCalamari/gists{/gist_id}","starred_url":"https://api.github.com/users/jCalamari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jCalamari/subscriptions","organizations_url":"https://api.github.com/users/jCalamari/orgs","repos_url":"https://api.github.com/users/jCalamari/repos","events_url":"https://api.github.com/users/jCalamari/events{/privacy}","received_events_url":"https://api.github.com/users/jCalamari/received_events","type":"User","site_admin":false},"created_at":"2015-06-02T09:19:46Z","updated_at":"2015-06-02T09:19:46Z","body":">Overloading factory methods when a perfectly suitable builder API exists is not a good idea - builders are far superior to overloaded methods.\r\n\r\nWell said.\r\n\r\n```\r\nbind(SomeService.class).qualifiedWith(SomeAnnotation.class)\r\n```\r\nIs it safe to mix java with scala API in Play Java project?"}}