Chapter 11. Getting Started

To load LinkRest in your project, follow these simple steps:

1. Declare LinkRest dependency. Here is a Maven example. If you are using Gradle or Ant, you do what needs to be done there to include LinkRest dependency.

<dependency>
   <groupId>com.nhl.link.rest</groupId>
   <artifactId>link-rest</artifactId>
   <version>2.2</version>
</dependency> 

2. Create LinkRestRuntime, and load it in JAX-RS container. Assuming the container is Jersey, this may look like this:

import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.server.ResourceConfig;
import com.nhl.link.rest.runtime.LinkRestBuilder;

/**
 * A Jersey-specific JAX-RS Application class that loads LinkRest.
 */
@ApplicationPath("/")
public class JaxRsApplication extends ResourceConfig {

	public JaxRsApplication() {

		ServerRuntime cayenneRuntime = ..
        LinkRestRuntime lrRuntime = LinkRestBuilder.build(cayenneRuntime);
        super.register(lrRuntime);

        // continue with Application setup...
        ..
	}
}

Now you are ready to write LinkRest endpoints.