{"issue":{"state":"open","created_at":"2011-12-08T09:11:00Z","updated_at":"2011-12-08T22:00:11Z","comments":4,"user":{"gravatar_id":"7c00c0723f8604a75defa699507b43b9","id":1233474,"url":"https://api.github.com/users/jeanouii","avatar_url":"https://secure.gravatar.com/avatar/7c00c0723f8604a75defa699507b43b9?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"jeanouii"},"body":"Hi,\r\n\r\nI did not find any simple Java ObjectFactory without any container.\r\nIs it possible to add this one to the cucumber-java artifact?\r\n\r\nKind regards,\r\nJean-Louis\r\n\r\npublic class JavaObjectFactory implements ObjectFactory {\r\nprivate final Set<Class<?>> classes = new HashSet<Class<?>>();\r\nprivate final Map<Class<?>, Object> instances = new HashMap<Class<?>, Object>();\r\n\r\npublic void createInstances() {\r\nfor (Class<?> clazz : classes) {\r\ntry {\r\ninstances.put(clazz, clazz.newInstance());\r\n} catch (Exception e) {\r\nthrow new RuntimeException(\"can't create an instance of \" + clazz.getName(), e);\r\n}\r\n}\r\n}\r\n\r\npublic void disposeInstances() {\r\ninstances.clear();\r\n}\r\n\r\npublic void addClass(Class<?> clazz) {\r\nclasses.add(clazz);\r\n}\r\n\r\npublic <T> T getInstance(Class<T> type) {\r\nreturn (T) instances.get(type);\r\n}\r\n}","assignee":null,"id":2485149,"labels":[],"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"number":110,"title":"Simple Java ObjectFactory","html_url":"https://github.com/cucumber/cucumber-jvm/issues/110","closed_at":null,"url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/110","milestone":null},"action":"created","comment":{"created_at":"2011-12-08T22:00:11Z","updated_at":"2011-12-08T22:00:11Z","user":{"gravatar_id":"0be0e4aa42aacd9a8a95c792de273ca7","id":1000,"url":"https://api.github.com/users/aslakhellesoy","avatar_url":"https://secure.gravatar.com/avatar/0be0e4aa42aacd9a8a95c792de273ca7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"aslakhellesoy"},"body":"Can you send a pull request with tests for this please? You're the one who wants it, so I expect you to do the necessary work.","id":3070694,"url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/comments/3070694"}}