Here is how I am doing it *, *Please point what I am doing wrong here *.pom.xml:*
<?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> *Application:* 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 either commented or un commented //environment.jersey().property( // EntityFilteringFeature.ENTITY_FILTERING_SCOPE, // new Annotation[] { // Detail.Factory.get() // } //); environment.jersey().register(EntityFilteringFeature.class); environment.jersey().register(MyResource.class); } } *Resource :* @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(); } } } On Monday, June 20, 2016 at 9:33:38 AM UTC-4, Ashish wrote: > > Hi Everyone, > > Need help with Entity filtering. I am using dropwizard 0.9.2 and have a > requirement to apply entity filtering based on a header. > > @XmlRootElement > public class Foo > { > @XmlElement > private String general; > > @XmlElement > @Detail1 > private String detail1; > > @XmlElement > @Detail2 > private String detail2; > > } > > > For the above Entity Foo, if header exists in the request with > detail=1, I want fields annotated with @Detail1. In case the detail=2 > I want to all fields which are annotated with @Detail1 and @Detail2 and so > on. > > > Thanks > Ashish > > -- You received this message because you are subscribed to the Google Groups "dropwizard-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
