    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
    015    package org.apache.tapestry5.corelib.pages;
    016
    017    import org.apache.tapestry5.SymbolConstants;
    018    import org.apache.tapestry5.annotations.ContentType;
    019    import org.apache.tapestry5.annotations.Import;
    020    import org.apache.tapestry5.annotations.Property;
    021    import org.apache.tapestry5.annotations.WhitelistAccessOnly;
    022    import org.apache.tapestry5.beaneditor.BeanModel;
    023    import org.apache.tapestry5.ioc.Messages;
    024    import org.apache.tapestry5.ioc.Registry;
    025    import org.apache.tapestry5.ioc.annotations.Inject;
    026    import org.apache.tapestry5.ioc.annotations.Symbol;
    027    import org.apache.tapestry5.ioc.services.ServiceActivity;
    028    import org.apache.tapestry5.ioc.services.ServiceActivityScoreboard;
    029    import org.apache.tapestry5.services.BeanModelSource;
    030
    031    import 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
    041    public 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    }