5

What is the advantages of using ResourceConfig over Application(since ResourceConfig extends Application).

using ResourceConfig

   @ApplicationPath("/")
    public class MyApplication extends ResourceConfig {
    public MyApplication() {
    super(MultiPartResource.class, MultiPartResource.class, MultiPartFeature.class);
    }
    }

using Application

public class MyApplication extends Application {
@Override
public Set<Class<?>> getClasses() {
final Set<Class<?>> classes = new HashSet<Class<?>>();
// register resources and features
classes.add(MultiPartFeature.class);
classes.add(MultiPartResource.class);
classes.add(LoggingFilter.class);
return classes;
}
}

In the post Jersey 2 injection source for multipart formdata @Arul Dhesiaseelan answered to add the MultiPartFeature to both to enable that feature on the server side. Could someone explain.

Community
  • 1
  • 1
Sameer Sarmah
  • 1,052
  • 4
  • 15
  • 33

1 Answers1

7

from the documentation: https://jersey.java.net/documentation/latest/deployment.html

"Compared to Application, the ResourceConfig provides advanced capabilities to simplify registration of JAX-RS components, such as scanning for root resource and provider classes in a provided classpath or a in a set of package names etc. All JAX-RS component classes that are either manually registered or found during scanning are automatically added to the set of classes that are returned by getClasses. "

bhowden
  • 669
  • 7
  • 15