REST Resources
You can define new REST resources in the EPT project and use those without restarting the server. All REST resources should go into the <EptSourcePackage>.rest. package. You can define any number of REST classes but care should be taken to use the unique and different resource path to avoid any conflicts.
Afer defining rest resource, you can submit it as part of your EPT and will be accessible using http://localhost/oms/rest/EPT/<EptName>/<Resource Path>, i.e. http://localhost/oms/rest/EPT/SampleEnterprise/sample
package
com.onenetwork.sampleent.rest;
import
javax.ws.rs.GET;
import
javax.ws.rs.Path;
import
javax.ws.rs.Produces;
import
org.json.JSONObject;
import
org.springframework.context.annotation.Scope;
import
org.springframework.stereotype.Component;
import
com.onenetwork.platform.common.usercontext.PlatformUserContext;
import
com.onenetwork.platform.integ.rest.BaseResource;
/**
* Sample REST resource. Will be available at /oms/rest/eptName/sample
*/
@Component
(
"com.onenetwork.sampleent.rest.SampleResource"
)
@Scope
(
"request"
)
@Path
(
"/sample"
)
public
class
SampleResource
extends
BaseResource {
@GET
@Produces
({
"application/json"
})
public
JSONObject getSample() {
JSONObject result =
new
JSONObject();
PlatformUserContext userContext = getPlatformUserContext();
return
result.put(
"username"
, userContext.getUserName());
}
}