--
You received this message because you are subscribed to a topic in the Google Groups "dropwizard-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dropwizard-user/9i5tdMHUDk0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>dt</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<dropwizard.version>0.9.1</dropwizard.version>
</properties>
<dependencies>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>${dropwizard.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-entity-filtering</artifactId>
<version>2.23.1</version>
</dependency>
</dependencies>
</project>
public class DApplication extends Application<DConfiguration>
{
public static void main(String[] args) throws Exception
{
new DApplication().run(args);
}
@Override public void initialize(Bootstrap<DConfiguration> bootstrap)
{
super.initialize(bootstrap);
}
@Override public void run(DConfiguration dConfiguration,
Environment environment) throws Exception
{
// Does not work with the line below commented or uncommented
//environment.jersey().property(
// EntityFilteringFeature.ENTITY_FILTERING_SCOPE,
// new Annotation[] {
// Detail.Factory.get()
// }
//);
environment.jersey().register(EntityFilteringFeature.class);
environment.jersey().register(MyResource.class);
}
}
@Path("hello")
@Produces({ MediaType.APPLICATION_JSON})
public class MyResource
{
@GET
//@Detail
public Model getModel() {
Model model = new Model();
model.setTest("abcd");
model.setDetail("efgh");
return model;
}
}
Model:
public class Model
{
private String test;
@Detail
private String detail ;
// getters and setters
}
Annotation :
@Target({ ElementType.TYPE, ElementType.METHOD ,ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@EntityFiltering
public @interface Detail
{
/**
* Factory class for creating instances of the annotation.
*/
public static class Factory extends AnnotationLiteral<Detail>
implements Detail {
private Factory() {
}
public static Detail get() {
return new Factory();
}
}
}