All Downloads are FREE. Search and download functionalities are using the official Maven repository.

csip.ServiceAnnotations Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 2.6.30
Show newest version
/*
 * $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