<p>I have created a namespace extension that is rooted under Desktop. The main purpose of the extension is to provide a virtual list of ZIP files that represent a list of configurable directories. When the user clicks one of the those items the contents of the related directory are zipped in place and the resulting ZIP file is stored in a cache folder.</p>

<p>All this works well aside a minor issue. If we go to Windows Explorer, open the extension and double click an item the opened file is the one from the cache. [CORRECT]</p>

<p>If on the other hand we open it by an Open Dialog the opened file is one from a Temporary Internet files directory. [INCORRECT]</p>

<p>What do I have to change for the Open Dialog (when used for example trough notepad.exe) to open the file from the cache folder and not from Temporary Internet files. I have tried to send allways the qualified file name in IShellFolder::GetDisplayNameOf but without any luck.</p>

[{'answer_id': 71504, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': True, 'text': "<p>What would be wrong with doing something like the following:</p>\n\n<p>Defining a 'Maintainer' interface with the addListener(Listener, Enum) method.</p>\n\n<p>Create a DefaultMaintainer class (as above) which implements Maintainer.</p>\n\n<p>Then, in each Listener class, 'inject' the Maintainer interface (constructor injection might be a good choice). The listener can then register itself with the Maintainer.</p>\n\n<p>other than that, I'm not 100% clear on exactly what your difficulty is with Spring at the moment! :)</p>\n"}, {'answer_id': 73129, 'author': 'Alexandre Victoor', 'author_id': 11897, 'author_profile': 'https://Stackoverflow.com/users/11897', 'pm_score': 0, 'selected': False, 'text': '<blockquote>\n  <p>You said "... you can\'t have java.lang.Enum as"\n  annotation param ..."</p>\n</blockquote>\n\n<p>I think you are wrong on that. I have recently used on a project something like this :</p>\n\n<pre><code>public @interface MyAnnotation {\n    MyEnum value();\n}\n</code></pre>\n'}, {'answer_id': 75192, 'author': 'flicken', 'author_id': 12880, 'author_profile': 'https://Stackoverflow.com/users/12880', 'pm_score': 1, 'selected': False, 'text': '<blockquote>\n  <p>1) Define Maintainer class as a Spring bean.</p>\n</blockquote>\n\n<p>Standard Spring syntax applies:</p>\n\n<pre><code>&lt;bean id="maintainer" class="com.example.Maintainer"/&gt;\n</code></pre>\n\n<blockquote>\n  <p>2) Make it so that all sorts of listeners would be able to register themselves to Maintainer via XML by using addListener method. Spring doc nor Google are very generous in examples.</p>\n</blockquote>\n\n<p>This is trickier.  You <em>could</em> use <code>MethodInvokingFactoryBean</code> to individually call <code>maintainer#addListener</code>, like so:</p>\n\n<pre><code>&lt;bean id="listener" class="com.example.Listener"/&gt;\n\n&lt;bean id="maintainer.addListener" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"&gt;\n  &lt;property name="targetObject" ref="maintainer"/&gt;\n  &lt;property name="targetMethod" value="addListener"/&gt;\n  &lt;property name="arguments"&gt;\n    &lt;list&gt;\n      &lt;ref&gt;listener&lt;/ref&gt;\n      &lt;value&gt;com.example.MyEnum&lt;/value&gt;\n   &lt;/list&gt;\n &lt;/property&gt;\n&lt;/bean&gt;\n</code></pre>\n\n<p>However, this is unwieldy, and potentially error-prone.  I attempted something similar on a project, and created a Spring utility class to help out instead.  I don\'t have the source code available at the moment, so I\'ll describe how to implement what I did. </p>\n\n<p>1) Refactor the event types listened to into a <code>MyListener</code> interface</p>\n\n<pre><code>public interface MyListener extends Listener {\n  public Enum[] getEventTypes()\n}\n</code></pre>\n\n<p>Which changes the registration method to</p>\n\n<pre><code>public void addListener(MyListener listener)\n</code></pre>\n\n<p>2) Create Spring helper class that finds all relevant listeners in the context, and calls maintainer#addListener for each listener found.   I would start with <code>BeanFilteringSupport</code>, and also implement <code>BeanPostProcessor</code> (or <code>ApplicationListener</code>) to register the beans after all beans have been instantiated.</p>\n'}, {'answer_id': 81555, 'author': 'mindas', 'author_id': 7345, 'author_profile': 'https://Stackoverflow.com/users/7345', 'pm_score': 0, 'selected': False, 'text': '<p>Thank you all for the answers. First, A quick follow up on all answers.<br>\n1. (alexvictor) Yes, you can have concrete <em>enum</em> as annotation param, but not <em>java.lang.Enum</em>.<br>\n2. Answer provided by flicken is correct, but unfortunately a bit scary. I am not a Spring expert but doing things this way (creating methods for easier Spring access) this seems to be a bit overkill, as is the <em>MethodInvokingFactoryBean</em> solution. Although I wanted to express my sincere thanks for your time and effort.<br>\n3. The answer by Phill is a bit unusual (instead of injecting listener bean, inject its maintainer!), but, I believe, the cleanest of all available. I think I will go down this path.</p>\n\n<p>Again, a big thanks you for your help.</p>\n'}, {'answer_id': 93461, 'author': 'finnw', 'author_id': 12048, 'author_profile': 'https://Stackoverflow.com/users/12048', 'pm_score': 2, 'selected': False, 'text': '<p>Slightly offtopic (as this is not about Spring) but there is a race condition in your implementation of AddListener:</p>\n\n<pre><code>  if( ( listeners = map.get( eventType ) ) == null ) {\n     listeners = new java.util.concurrent.CopyOnWriteArrayList&lt;Listener&gt;();\n     map.put( eventType, listeners );\n  }\n  listeners.add( listener );\n</code></pre>\n\n<p>If two threads call this method at the same time (for an event type that previously had no listeners), map.get( eventType ) will return null in both threads, each thread will create its own CopyOnWriteArrayList (each containing a single listener), one thread will replace the list created by the other, and the first listener will be forgotten.</p>\n\n<p>To fix this, change:</p>\n\n<pre><code>private Map&lt;Enum, List&lt;Listener&gt;&gt; map;\n\n...\n\nmap.put( eventType, listeners );\n</code></pre>\n\n<p>to:</p>\n\n<pre><code>private ConcurrentMap&lt;Enum, List&lt;Listener&gt;&gt; map;\n\n...\n\nmap.putIfAbsent( eventType, listeners );\nlisteners = map.get( eventType );\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/71475', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6508/']