incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1138227 - in /incubator/isis/trunk/viewer/restful/viewer2/src/main/java/org/apache/isis/viewer/restful/viewer2/resources/services: ./ ServicesResourceImpl.java
Date Tue, 21 Jun 2011 22:37:34 GMT
Author: danhaywood
Date: Tue Jun 21 22:37:34 2011
New Revision: 1138227

URL: http://svn.apache.org/viewvc?rev=1138227&view=rev
Log:
viewer2 : adding services resource

Added:
    incubator/isis/trunk/viewer/restful/viewer2/src/main/java/org/apache/isis/viewer/restful/viewer2/resources/services/
    incubator/isis/trunk/viewer/restful/viewer2/src/main/java/org/apache/isis/viewer/restful/viewer2/resources/services/ServicesResourceImpl.java

Added: incubator/isis/trunk/viewer/restful/viewer2/src/main/java/org/apache/isis/viewer/restful/viewer2/resources/services/ServicesResourceImpl.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/restful/viewer2/src/main/java/org/apache/isis/viewer/restful/viewer2/resources/services/ServicesResourceImpl.java?rev=1138227&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/restful/viewer2/src/main/java/org/apache/isis/viewer/restful/viewer2/resources/services/ServicesResourceImpl.java
(added)
+++ incubator/isis/trunk/viewer/restful/viewer2/src/main/java/org/apache/isis/viewer/restful/viewer2/resources/services/ServicesResourceImpl.java
Tue Jun 21 22:37:34 2011
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.viewer.restful.viewer2.resources.services;
+
+import java.util.List;
+
+import javax.ws.rs.Path;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.viewer.restful.applib.resources.ServicesResource;
+import org.apache.isis.viewer.restful.viewer2.RepresentationContext;
+import org.apache.isis.viewer.restful.viewer2.resources.ResourceAbstract;
+import org.apache.isis.viewer.restful.viewer2.resources.objects.DomainObjectRepresentation;
+
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+
+/**
+ * Implementation note: it seems to be necessary to annotate the implementation with {@link
Path} rather than the
+ * interface (at least under RestEasy 1.0.2 and 1.1-RC2).
+ */
+@Path("/services")
+public class ServicesResourceImpl extends ResourceAbstract implements ServicesResource {
+
+    @Override
+    public String services() {
+        init();
+
+        return asJsonList(serviceRepresentations());
+    }
+
+    protected List<DomainObjectRepresentation> serviceRepresentations() {
+        final List<ObjectAdapter> serviceAdapters = getPersistenceSession().getServices();
+        RepresentationContext representationContext = getResourceContext().representationSelfLinkTo("_self");
+        return Lists.newArrayList(Collections2.transform(serviceAdapters, DomainObjectRepresentation.fromAdapter(representationContext)));
+    }
+
+}



Mime
View raw message