Search in sources :

Example 6 with ModelWriter

use of org.apache.stanbol.entityhub.web.ModelWriter in project stanbol by apache.

the class ModelWriterTracker method modifiedService.

@Override
public final void modifiedService(ServiceReference reference, Object service) {
    super.modifiedService(reference, service);
    if (service != null) {
        Set<MediaType> mediaTypes = parseMediaTypes(((ModelWriter) service).supportedMediaTypes());
        Class<? extends Representation> nativeType = ((ModelWriter) service).getNativeType();
        if (!mediaTypes.isEmpty()) {
            lock.writeLock().lock();
            try {
                for (MediaType mediaType : mediaTypes) {
                    updateModelWriter(nativeType, mediaType, reference);
                }
            } finally {
                lock.writeLock().unlock();
            }
        }
    }
}
Also used : MediaType(javax.ws.rs.core.MediaType) ModelWriter(org.apache.stanbol.entityhub.web.ModelWriter)

Aggregations

MediaType (javax.ws.rs.core.MediaType)6 ModelWriter (org.apache.stanbol.entityhub.web.ModelWriter)6 WebApplicationException (javax.ws.rs.WebApplicationException)3 ServiceReference (org.osgi.framework.ServiceReference)3 Entity (org.apache.stanbol.entityhub.servicesapi.model.Entity)1 Representation (org.apache.stanbol.entityhub.servicesapi.model.Representation)1