OW2 Consortium elastic-grid

Rev

Rev 127 | Rev 135 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
127 jeje 1
/**
2
 * Copyright (C) 2007-2008 Elastic Grid, LLC.
3
 *
4
 * This file is part of Elastic Grid.
5
 *
6
 * Elastic Grid is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as
8
 * published by the Free Software Foundation, either version 3 of the
9
 * License, or any later version.
10
 *
11
 * Elastic Grid is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License
17
 * along with Elastic Grid.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
 
20
package com.elasticgrid.rest;
21
 
22
import com.elasticgrid.cluster.ClusterManager;
23
import com.elasticgrid.model.Cluster;
24
import com.elasticgrid.model.ec2.impl.EC2ClusterImpl;
25
import org.restlet.Context;
26
import org.restlet.data.MediaType;
27
import org.restlet.data.Request;
28
import org.restlet.data.Response;
29
import org.restlet.data.Status;
30
import org.restlet.ext.jibx.JibxRepresentation;
31
import org.restlet.ext.wadl.WadlResource;
32
import org.restlet.ext.wadl.MethodInfo;
33
import org.restlet.ext.wadl.RepresentationInfo;
34
import org.restlet.resource.Representation;
35
import org.restlet.resource.Resource;
36
import org.restlet.resource.ResourceException;
37
import org.restlet.resource.Variant;
131 jeje 38
import org.springframework.stereotype.Component;
39
import org.springframework.beans.factory.annotation.Autowired;
40
import org.springframework.context.annotation.Scope;
127 jeje 41
import java.util.Arrays;
42
 
131 jeje 43
@Component
44
@Scope("prototype")
127 jeje 45
public class ServiceResource extends WadlResource {
46
    private String clusterName;
47
    private String applicationName;
48
    private String serviceName;
131 jeje 49
    @Autowired
127 jeje 50
    private ClusterManager clusterManager;
51
 
131 jeje 52
    @Override
53
    public void init(Context context, Request request, Response response) {
54
        super.init(context, request, response);
127 jeje 55
        // Allow modifications of this resource via POST requests
56
        setModifiable(false);
57
        setAutoDescribed(true);
58
        // Declare the kind of representations supported by this resource
59
        getVariants().add(new Variant(MediaType.APPLICATION_XML));
60
        // Extract URI variables
131 jeje 61
        clusterName = (String) request.getAttributes().get("clusterName");
62
        applicationName = (String) request.getAttributes().get("applicationName");
63
        serviceName = (String) request.getAttributes().get("serviceName");
127 jeje 64
    }
65
 
66
    /**
67
     * Handle GET requests: describe service.
68
     */
69
    @Override
70
    public Representation represent(Variant variant) throws ResourceException {
71
        return null;
72
    }
73
 
74
    @Override
75
    protected void describeGet(MethodInfo info) {
76
        super.describeGet(info);
77
        info.setDocumentation("Describes service {serviceName} from {applicationName} running on {clusterName}");
78
        info.getResponse().setDocumentation("The service.");
79
        RepresentationInfo representation = new RepresentationInfo();
80
        representation.setDocumentation("Service");
81
        representation.setMediaType(MediaType.APPLICATION_XML);
82
        info.getResponse().setRepresentations(Arrays.asList(representation));
83
    }
84
 
85
}