001/*
002    Licensed to the Apache Software Foundation (ASF) under one
003    or more contributor license agreements.  See the NOTICE file
004    distributed with this work for additional information
005    regarding copyright ownership.  The ASF licenses this file
006    to you under the Apache License, Version 2.0 (the
007    "License"); you may not use this file except in compliance
008    with the License.  You may obtain a copy of the License at
009
010       http://www.apache.org/licenses/LICENSE-2.0
011
012    Unless required by applicable law or agreed to in writing,
013    software distributed under the License is distributed on an
014    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015    KIND, either express or implied.  See the License for the
016    specific language governing permissions and limitations
017    under the License.
018 */
019package org.apache.wiki.ui.admin.beans;
020
021import org.apache.wiki.api.Release;
022import org.apache.wiki.api.core.Engine;
023import org.apache.wiki.pages.PageManager;
024import org.apache.wiki.ui.admin.SimpleAdminBean;
025
026import javax.management.NotCompliantMBeanException;
027
028
029/**
030 *  An AdminBean which manages the JSPWiki core operations.
031 */
032public class CoreBean extends SimpleAdminBean {
033
034    private static final String[] ATTRIBUTES = { "pages", "version" };
035    private static final String[] METHODS = { };
036
037    public CoreBean( final Engine engine ) throws NotCompliantMBeanException {
038        m_engine = engine;
039    }
040
041    /**
042     *  Return the page count in the Wiki.
043     *
044     *  @return the page content
045     */
046    public int getPages() {
047        return m_engine.getManager( PageManager.class ).getTotalPageCount();
048    }
049
050    public String getPagesDescription() {
051        return "The total number of pages in this wiki";
052    }
053
054    public String getVersion() {
055        return Release.VERSTR;
056    }
057
058    public String getVersionDescription() {
059        return "The JSPWiki engine version";
060    }
061
062    @Override
063    public String getTitle() {
064        return "Core bean";
065    }
066
067    @Override
068    public int getType() {
069        return CORE;
070    }
071
072    @Override
073    public String getId() {
074        return "corebean";
075    }
076
077    @Override
078    public String[] getAttributeNames() {
079        return ATTRIBUTES;
080    }
081
082    @Override
083    public String[] getMethodNames() {
084        return METHODS;
085    }
086
087}