1   /**
2    * Licensed to Neo Technology under one or more contributor
3    * license agreements. See the NOTICE file distributed with
4    * this work for additional information regarding copyright
5    * ownership. Neo Technology licenses this file to you under
6    * the Apache License, Version 2.0 (the "License"); you may
7    * not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied. See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.neo4j.examples.server.unmanaged;
20  
21  //START SNIPPET: All
22  
23  import org.neo4j.graphdb.GraphDatabaseService;
24  
25  import javax.ws.rs.GET;
26  import javax.ws.rs.Path;
27  import javax.ws.rs.PathParam;
28  import javax.ws.rs.Produces;
29  import javax.ws.rs.core.Context;
30  import javax.ws.rs.core.MediaType;
31  import javax.ws.rs.core.Response;
32  
33  import static javax.ws.rs.core.Response.Status;
34  
35  @Path( "/helloworld" )
36  public class HelloWorldResource
37  {
38  
39      private final GraphDatabaseService database;
40  
41      public HelloWorldResource( @Context GraphDatabaseService database )
42      {
43          this.database = database;
44      }
45  
46      @GET
47      @Produces( MediaType.TEXT_PLAIN )
48      @Path( "/{nodeId}" )
49      public Response hello( @PathParam( "nodeId" ) long nodeId )
50      {
51          // Do stuff with the database
52          return Response.status( Status.OK ).entity(
53                  ( "Hello World, nodeId=" + nodeId ).getBytes() ).build();
54      }
55  }
56  // END SNIPPET: All
57