java - RESTful Hirerarchy with classes with JAXRS -


would create below hierarchical structure in rest jaxrs , jersey provider

@post /origination/customers/ @put /origination/customers @get /origination/customers/{customerid}  @post /origination/customers/{customerid}/inventory @put /origination/customers/{customerid}/inventory @get /origination/customers/{customerid}/inventory/inventoryid 

currently services written in single class originationservice, better encapsulation know if services can refractored customer origination in seperate class called customeroriginationservice , inventory origination inside customerinventoryservice (this example scenario, problem similar)

is possible achieve above jaxrs(jersey) annotation

definitely! ant that's standard way assemble set of http methods in different classes. need use @path example - @path("/{parameter}").

below code may useful -

controller interface -

package com.teducate.api;  import java.io.unsupportedencodingexception;  import javax.ws.rs.defaultvalue; import javax.ws.rs.get; import javax.ws.rs.path; import javax.ws.rs.pathparam; import javax.ws.rs.produces; import javax.ws.rs.queryparam; import javax.ws.rs.core.response;  public interface tekevents {     @get     @path("/{parameter}")     @produces("application/json")     response responsemsg( @pathparam("parameter") string parameter,             @defaultvalue("nothing say") @queryparam("value") string value) throws unsupportedencodingexception; } 

implementation -

package com.teducate.api.impl;  import javax.ws.rs.path; import javax.ws.rs.core.response;  import com.teducate.api.tekevents; import com.teducate.bo.tekeventsbo; import com.teducate.bo.impl.tekeventboimpl;  @path("events") public class tekeventscontroller implements tekevents {      tekeventsbo tekeventsbo;      public tekeventscontroller() {         tekeventsbo = new tekeventboimpl();     }      public response responsemsg(string parameter, string value) {         string output = tekeventsbo.responsemsg(parameter, value);         return response.status(200).entity(output).build();     } } 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -