001// Copyright 2007, 2008 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.ContentType;
019import org.apache.tapestry5.annotations.Import;
020import org.apache.tapestry5.annotations.Property;
021import org.apache.tapestry5.annotations.WhitelistAccessOnly;
022import org.apache.tapestry5.beaneditor.BeanModel;
023import org.apache.tapestry5.ioc.Messages;
024import org.apache.tapestry5.ioc.Registry;
025import org.apache.tapestry5.ioc.annotations.Inject;
026import org.apache.tapestry5.ioc.annotations.Symbol;
027import org.apache.tapestry5.ioc.services.ServiceActivity;
028import org.apache.tapestry5.ioc.services.ServiceActivityScoreboard;
029import org.apache.tapestry5.services.BeanModelSource;
030
031import java.util.List;
032
033/**
034 * Page used to see the status of all services defined by the {@link Registry}.
035 * <p/>
036 * TODO: Add filters to control which services are displayed
037 */
038@ContentType("text/html")
039@Import(stylesheet = "ServiceStatus.css")
040@WhitelistAccessOnly
041public class ServiceStatus
042{
043    @Inject
044    private ServiceActivityScoreboard scoreboard;
045
046    @Property
047    private List<ServiceActivity> activity;
048
049    @Property
050    private ServiceActivity row;
051
052    @Inject
053    private BeanModelSource source;
054
055    @Property
056    private final BeanModel model;
057
058    @Inject
059    private Messages messages;
060
061    @Property
062    @Inject
063    @Symbol(SymbolConstants.PRODUCTION_MODE)
064    private boolean productionMode;
065
066    {
067        model = source.createDisplayModel(ServiceActivity.class, messages);
068
069        model.addEmpty("serviceInterface");
070
071        // There's no line number information for interfaces, so we'll reorder the
072        // proprieties manually.
073
074        model.reorder("serviceId", "serviceInterface", "scope", "status");
075    }
076
077    void setupRender()
078    {
079        activity = scoreboard.getServiceActivity();
080    }
081}