csip.ServiceAnnotations Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of csip-core Show documentation
Show all versions of csip-core Show documentation
The Cloud Services Integration Platform is a SoA implementation to offer a Model-as-a-Service framework, Application Programming Interface, deployment infrastructure, and service implementations for environmental modeling.
/*
* $Id: ServiceAnnotations.java 9d74c6f08927 2019-03-15 od $
*
* This file is part of the Cloud Services Integration Platform (CSIP),
* a Model-as-a-Service framework, API and application suite.
*
* 2012-2019, Olaf David and others, OMSLab, Colorado State University.
*
* OMSLab licenses this file to you under the MIT license.
* See the LICENSE file in the project root for more information.
*/
package csip;
import csip.annotations.Polling;
import javax.ws.rs.Path;
/**
* ServiceAnnotation access.
*
* @author od
*/
public class ServiceAnnotations {
private final ModelDataService mds;
ServiceAnnotations(ModelDataService mds) {
this.mds = mds;
}
/**
* Return the recommended polling interval for async calls in milliseconds.
* @return the polling interval value in milliseconds
*/
public long getNextPoll() {
Polling p = mds.getClass().getAnnotation(Polling.class);
return (p != null) ? p.next() : -1;
}
/**
* Get the time until first poll for async calls in milliseconds.
* @return time to first poll in milliseconds
*/
public long getFirstPoll() {
Polling p = mds.getClass().getAnnotation(Polling.class);
return (p != null) ? p.first() : -1;
}
/**
* Provide the service path name, e.g. 'weps/1.0'
* @return the model service path
*/
public String getPath() {
Path p = mds.getClass().getAnnotation(Path.class);
if (p != null) {
return p.value();
}
throw new RuntimeException("@Path annotation missing for " + getClass());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy