wordnik/swagger-core — pull request #262 by ddragosd (2013-07-18 16:52:27+00:00)
Title: Add to ApiListing.scala method to invalidate its cache; a must-have in an OSGI environment 

Fixed an issue for OSGI runtime: in OSGI you need to invalidate cache each time a new OSGI component is added/removed, b/c some packages may contain updated information.

In OSGI, the specific ApiListingResource should be responsible to call `invalidateCache()`. I'm also pasting an OSGI component that makes this call:

```
/** Inspired from https://github.com/wordnik/swagger-core/wiki/java-jax-rs */
@Component(immediate = true, metatype = false)
@Service(value = { Object.class, ApiListing.class })
@Property(name = "javax.ws.rs.base", boolValue = true)

@References({
@Reference(name = "component", referenceInterface = Object.class,
target = "(javax.ws.rs=true)",
cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
policy = ReferencePolicy.DYNAMIC) })

@Path("/api-docs.json")
@Api("/api-docs.json")
@Produces(MediaType.APPLICATION_JSON)
public class ApiListingResource extends ApiListing
{
private static boolean initialized = false;

public ApiListingResource()
{
if ( ! initialized ) {
SwaggerContext.registerClassLoader(this.getClass().getClassLoader());
initialized = true;
}
}

protected void bindComponent(Object component) throws IOException,
ServletException,
NamespaceException
{
this.invalidateCache();
}

protected void unbindComponent(Object component) throws IOException,
ServletException,
NamespaceException
{
this.invalidateCache();
}

}
```