001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.jmx.wrapper;
018
019import org.apache.wicket.Application;
020import org.apache.wicket.jmx.ApplicationSettingsMBean;
021import org.apache.wicket.util.lang.Bytes;
022import org.apache.wicket.util.lang.Classes;
023
024/**
025 * Exposes Application related functionality for JMX.
026 * 
027 * @author eelcohillenius
028 */
029public class ApplicationSettings implements ApplicationSettingsMBean
030{
031        private final Application application;
032
033        /**
034         * Create.
035         * 
036         * @param application
037         */
038        public ApplicationSettings(final Application application)
039        {
040                this.application = application;
041        }
042
043        @Override
044        public String getAccessDeniedPage()
045        {
046                return Classes.name(application.getApplicationSettings().getAccessDeniedPage());
047        }
048
049        @Override
050        public String getClassResolver()
051        {
052                return Stringz.className(application.getApplicationSettings().getClassResolver());
053        }
054
055        @Override
056        public String getDefaultMaximumUploadSize()
057        {
058                return application.getApplicationSettings().getDefaultMaximumUploadSize().toString();
059        }
060
061        @Override
062        public String getInternalErrorPage()
063        {
064                return Classes.name(application.getApplicationSettings().getInternalErrorPage());
065        }
066
067        /**
068         * @see org.apache.wicket.jmx.ApplicationSettingsMBean#getPageExpiredErrorPage()
069         */
070        @Override
071        public String getPageExpiredErrorPage()
072        {
073                return Classes.name(application.getApplicationSettings().getPageExpiredErrorPage());
074        }
075
076        /**
077         * @see org.apache.wicket.jmx.ApplicationSettingsMBean#getUnexpectedExceptionDisplay()
078         */
079        @Override
080        public String getUnexpectedExceptionDisplay()
081        {
082                return application.getExceptionSettings().getUnexpectedExceptionDisplay().toString();
083        }
084
085        /**
086         * @see org.apache.wicket.jmx.ApplicationSettingsMBean#setDefaultMaximumUploadSize(java.lang.String)
087         */
088        @Override
089        public void setDefaultMaximumUploadSize(final String defaultUploadSize)
090        {
091                application.getApplicationSettings().setDefaultMaximumUploadSize(
092                        Bytes.valueOf(defaultUploadSize));
093        }
094}