All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.bootique.jersey.ResourceModelDebugger Maven / Gradle / Ivy

There is a newer version: 3.0.M2
Show newest version
package io.bootique.jersey;

import javax.ws.rs.core.Configuration;

import org.glassfish.jersey.server.model.ModelProcessor;
import org.glassfish.jersey.server.model.Resource;
import org.glassfish.jersey.server.model.ResourceModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Debugs all container resources.
 * 
 * @since 0.12
 */
public class ResourceModelDebugger implements ModelProcessor {

	private static final Logger LOGGER = LoggerFactory.getLogger(ResourceModelDebugger.class);

	@Override
	public ResourceModel processResourceModel(ResourceModel resourceModel, Configuration configuration) {

		if (LOGGER.isDebugEnabled()) {
			resourceModel.getRootResources().forEach(r -> {
				debugResource(r);
			});
		}

		return resourceModel;
	}

	private void debugResource(Resource resource) {
		LOGGER.debug("Resource: " + resource.getPath());
		resource.getChildResources().forEach(r -> debugResource(r));
	}

	@Override
	public ResourceModel processSubResource(ResourceModel subResourceModel, Configuration configuration) {
		return subResourceModel;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy