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        /**
044         * @see org.apache.wicket.jmx.ApplicationSettingsMBean#getAccessDeniedPage()
045         */
046        @Override
047        public String getAccessDeniedPage()
048        {
049                return Classes.name(application.getApplicationSettings().getAccessDeniedPage());
050        }
051
052        /**
053         * @see org.apache.wicket.jmx.ApplicationSettingsMBean#getClassResolver()
054         */
055        @Override
056        public String getClassResolver()
057        {
058                return Stringz.className(application.getApplicationSettings().getClassResolver());
059        }
060
061        @Override
062        public String getDefaultMaximumUploadSize()
063        {
064                return application.getApplicationSettings().getDefaultMaximumUploadSize().toString();
065        }
066
067        /**
068         * @see org.apache.wicket.jmx.ApplicationSettingsMBean#getInternalErrorPage()
069         */
070        @Override
071        public String getInternalErrorPage()
072        {
073                return Classes.name(application.getApplicationSettings().getInternalErrorPage());
074        }
075
076        /**
077         * @see org.apache.wicket.jmx.ApplicationSettingsMBean#getPageExpiredErrorPage()
078         */
079        @Override
080        public String getPageExpiredErrorPage()
081        {
082                return Classes.name(application.getApplicationSettings().getPageExpiredErrorPage());
083        }
084
085        /**
086         * @see org.apache.wicket.jmx.ApplicationSettingsMBean#getUnexpectedExceptionDisplay()
087         */
088        @Override
089        public String getUnexpectedExceptionDisplay()
090        {
091                return application.getExceptionSettings().getUnexpectedExceptionDisplay().toString();
092        }
093
094        /**
095         * @see org.apache.wicket.jmx.ApplicationSettingsMBean#setDefaultMaximumUploadSize(java.lang.String)
096         */
097        @Override
098        public void setDefaultMaximumUploadSize(final String defaultUploadSize)
099        {
100                application.getApplicationSettings().setDefaultMaximumUploadSize(
101                        Bytes.valueOf(defaultUploadSize));
102        }
103}