Dynamic class loading for url dispatching in Java
<p>I am experimenting with a little framework where I have a bunch of actions defined in classes. I want to write a url dispatcher that will call the relevant action based on matching a url pattern specified in the action class. I want to avoid making a redundant list of all the available actions in the dispatcher class itself, and rather have it load instances of the actions dynamically on program start.</p>

<p>I initially figured I could put all these actions in a specific package, then have my dispatcher search that package for all classes that implement the action interface and load them into a list of action instances that are ready to be called. </p>

<p>From my googling I have discovered that there doesn't seem to be a way to actually get a list of classes that exist in a package (due to how classes are capable of being loaded in many different ways).</p>

<p>So my question: is this actually possible and how would I go about it? But maybe that is even too much to ask, is this even a good idea? What are other approaches that I could take, and are there any other examples of people doing dynamic dispatching to classes in java?</p>
