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