{"action":"created","issue":{"url":"https://api.github.com/repos/jsr107/jsr107spec/issues/316","labels_url":"https://api.github.com/repos/jsr107/jsr107spec/issues/316/labels{/name}","comments_url":"https://api.github.com/repos/jsr107/jsr107spec/issues/316/comments","events_url":"https://api.github.com/repos/jsr107/jsr107spec/issues/316/events","html_url":"https://github.com/jsr107/jsr107spec/issues/316","id":75621928,"number":316,"title":"Managed lifecycle of CacheManager","user":{"login":"snicoll","id":490484,"avatar_url":"https://avatars.githubusercontent.com/u/490484?v=3","gravatar_id":"","url":"https://api.github.com/users/snicoll","html_url":"https://github.com/snicoll","followers_url":"https://api.github.com/users/snicoll/followers","following_url":"https://api.github.com/users/snicoll/following{/other_user}","gists_url":"https://api.github.com/users/snicoll/gists{/gist_id}","starred_url":"https://api.github.com/users/snicoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snicoll/subscriptions","organizations_url":"https://api.github.com/users/snicoll/orgs","repos_url":"https://api.github.com/users/snicoll/repos","events_url":"https://api.github.com/users/snicoll/events{/privacy}","received_events_url":"https://api.github.com/users/snicoll/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-12T14:26:41Z","updated_at":"2015-05-16T14:48:00Z","closed_at":null,"body":"I want to make sure I got this right and I hope I used the right channel. Let me know otherwise and I'll move this issue.\r\n\r\nI find the current API a bit confusing with regards to how the lifecycle of a `CacheManager` should be managed. Let's take the basic example of `Caching.getCachingProvider().getCacheManager()`. This call may return me a \"new\" `CacheManager` or an existing `CacheManager` that was created previously with the same \"settings\" (`ClassLoader` and `URI`).\r\n\r\n`CacheManager` has a `close` method with no specific Javadoc details as how/when it should be invoked but my general understanding is that it should be invoked when the \"component\"/\"app\" terminates to reclaim resources or clean stuff up. \r\n\r\nHere is the problem. How do I know that the `CacheManager` I hold belongs to me? Maybe it was provided by the environment in some form. Maybe it's shared. \r\n\r\nI am not sure this is clear so I want to describe this in a different way.\r\n\r\n* I have a method to retrieve a ` CacheManager`\r\n* This `CacheManager` has a `close` method that I should invoke when \"I am done with it\"\r\n* I have no idea when I invoke said method if I am managing the returned `CacheManager` or if a component that has called the method previously owns it.\r\n\r\nSo, yes, calling `close` multiple times works per spec but my main problem is that when one component terminates and not the others. This is definitely in the corner case area but I want to make sure I didn't overlook something from the spec.\r\n\r\nI am not sure if the idea of a _managed_ `CacheManager` provided by the environment and shared by multiple apps make sense but that would be yet another example of this problem.\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/jsr107/jsr107spec/issues/comments/102633402","html_url":"https://github.com/jsr107/jsr107spec/issues/316#issuecomment-102633402","issue_url":"https://api.github.com/repos/jsr107/jsr107spec/issues/316","id":102633402,"user":{"login":"cruftex","id":2668191,"avatar_url":"https://avatars.githubusercontent.com/u/2668191?v=3","gravatar_id":"","url":"https://api.github.com/users/cruftex","html_url":"https://github.com/cruftex","followers_url":"https://api.github.com/users/cruftex/followers","following_url":"https://api.github.com/users/cruftex/following{/other_user}","gists_url":"https://api.github.com/users/cruftex/gists{/gist_id}","starred_url":"https://api.github.com/users/cruftex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cruftex/subscriptions","organizations_url":"https://api.github.com/users/cruftex/orgs","repos_url":"https://api.github.com/users/cruftex/repos","events_url":"https://api.github.com/users/cruftex/events{/privacy}","received_events_url":"https://api.github.com/users/cruftex/received_events","type":"User","site_admin":false},"created_at":"2015-05-16T14:48:00Z","updated_at":"2015-05-16T14:48:00Z","body":"You cannot. Calling CacheManager.close() on the default cache manager on component level is the problem.\r\n\r\nWhat you can do on component level:\r\n- Use distinct caches with in the default cache manager and close them separately\r\n- Use a unique cache manager by retrieving with distinct URI and/or classpath.\r\n \r\nI would say, closing the default cache manager only makes sense during application shutdown or in general the default manager lifecycle is tied to the application lifecycle.\r\n"}}