    001// Licensed under the Apache License, Version 2.0 (the "License");
    002// you may not use this file except in compliance with the License.
    003// You may obtain a copy of the License at
    004//
    005//     http://www.apache.org/licenses/LICENSE-2.0
    006//
    007// Unless required by applicable law or agreed to in writing, software
    008// distributed under the License is distributed on an "AS IS" BASIS,
    009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    010// See the License for the specific language governing permissions and
    011// limitations under the License.
    012
    013package org.apache.tapestry5.corelib.pages;
    014
    015import org.apache.tapestry5.annotations.*;
    016import org.apache.tapestry5.beanmodel.BeanModel;
    017import org.apache.tapestry5.beanmodel.services.BeanModelSource;
    018import org.apache.tapestry5.commons.Messages;
    019import org.apache.tapestry5.http.TapestryHttpSymbolConstants;
    020import org.apache.tapestry5.ioc.Registry;
    021import org.apache.tapestry5.ioc.annotations.Inject;
    022import org.apache.tapestry5.ioc.annotations.Symbol;
    023import org.apache.tapestry5.ioc.services.ServiceActivity;
    024import org.apache.tapestry5.ioc.services.ServiceActivityScoreboard;
    025
    026import java.util.List;
    027
    028/**
    029 * Page used to see the status of all services defined by the {@link Registry}.
    030 *
    031 * TODO: Add filters to control which services are displayed
    032 */
    033@UnknownActivationContextCheck(false)
    034@WhitelistAccessOnly
    035public class ServiceStatus
    036{
    037    @Inject
    038    private ServiceActivityScoreboard scoreboard;
    039
    040    @Property
    041    private ServiceActivity row;
    042
    043    @Inject
    044    private BeanModelSource source;
    045
    046    @Property
    047    private final BeanModel model;
    048
    049    @Inject
    050    private Messages messages;
    051
    052    @Property
    053    @Inject
    054    @Symbol(TapestryHttpSymbolConstants.PRODUCTION_MODE)
    055    private boolean productionMode;
    056
    057    {
    058        model = source.createDisplayModel(ServiceActivity.class, messages);
    059
    060        model.addEmpty("serviceInterface");
    061
    062        // There's no line number information for interfaces, so we'll reorder the
    063        // properties manually.
    064
    065        model.reorder("serviceId", "serviceInterface", "scope", "status");
    066    }
    067
    068    @Cached
    069    public List<ServiceActivity> getActivity()
    070    {
    071        return scoreboard.getServiceActivity();
    072    }
    073
    074    @Import(stylesheet = "service-status.css")
    075    void onAfterRenderFromServices()
    076    {
    077    }
    078}