ServiceAnnotationsImpl.java [src/csip] Revision: Date:
/*
* $Id$
*
* This file is part of the Cloud Services Integration Platform (CSIP),
* a Model-as-a-Service framework, API and application suite.
*
* 2012-2022, 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.Name;
import csip.api.server.ServiceAnnotations;
import csip.annotations.Polling;
import csip.annotations.VersionInfo;
import javax.ws.rs.Path;
/**
* ServiceAnnotation access.
*
* @author od
*/
class ServiceAnnotationsImpl extends ModelDataServiceAPI
implements ServiceAnnotations {
ServiceAnnotationsImpl(ModelDataService mds) {
super(mds);
}
@Override
public long getNextPoll() {
Polling p = mds.getClass().getAnnotation(Polling.class);
return (p != null) ? p.next() : -1;
}
@Override
public long getFirstPoll() {
Polling p = mds.getClass().getAnnotation(Polling.class);
return (p != null) ? p.first() : -1;
}
public String getPath() {
Path p = mds.getClass().getAnnotation(Path.class);
if (p != null)
return p.value();
throw new RuntimeException("@Path annotation missing for " + getClass());
}
@Override
public String getVersion() {
Path p = mds.getClass().getAnnotation(Path.class);
if (p != null) {
String last = p.value().substring(p.value().lastIndexOf('/'));
if (Character.isDigit(last.charAt(0))) {
return last;
}
}
VersionInfo v = mds.getClass().getAnnotation(VersionInfo.class);
if (v != null)
return v.value();
return "";
}
@Override
public String getName() {
Name n = mds.getClass().getAnnotation(Name.class);
if (n != null)
return n.value();
return mds.getClass().getName();
}
}