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 java.io.UnsupportedEncodingException;
020
021import org.apache.wicket.Application;
022import org.apache.wicket.jmx.MarkupSettingsMBean;
023
024
025/**
026 * Exposes Application related functionality for JMX.
027 * 
028 * @author eelcohillenius
029 */
030public class MarkupSettings implements MarkupSettingsMBean
031{
032        private final Application application;
033
034        /**
035         * Create.
036         * 
037         * @param application
038         */
039        public MarkupSettings(final Application application)
040        {
041                this.application = application;
042        }
043
044        /**
045         * @see org.apache.wicket.jmx.MarkupSettingsMBean#getAutomaticLinking()
046         */
047        @Override
048        public boolean getAutomaticLinking()
049        {
050                return application.getMarkupSettings().getAutomaticLinking();
051        }
052
053        /**
054         * @see org.apache.wicket.jmx.MarkupSettingsMBean#getCompressWhitespace()
055         */
056        @Override
057        public boolean getCompressWhitespace()
058        {
059                return application.getMarkupSettings().getCompressWhitespace();
060        }
061
062        /**
063         * @see org.apache.wicket.jmx.MarkupSettingsMBean#getDefaultMarkupEncoding()
064         */
065        @Override
066        public String getDefaultMarkupEncoding()
067        {
068                return application.getMarkupSettings().getDefaultMarkupEncoding();
069        }
070
071        /**
072         * @see org.apache.wicket.jmx.MarkupSettingsMBean#getStripComments()
073         */
074        @Override
075        public boolean getStripComments()
076        {
077                return application.getMarkupSettings().getStripComments();
078        }
079
080        /**
081         * @see org.apache.wicket.jmx.MarkupSettingsMBean#getStripWicketTags()
082         */
083        @Override
084        public boolean getStripWicketTags()
085        {
086                return application.getMarkupSettings().getStripWicketTags();
087        }
088
089        /**
090         * @see org.apache.wicket.jmx.MarkupSettingsMBean#setAutomaticLinking(boolean)
091         */
092        @Override
093        public void setAutomaticLinking(final boolean automaticLinking)
094        {
095                application.getMarkupSettings().setAutomaticLinking(automaticLinking);
096        }
097
098        /**
099         * @see org.apache.wicket.jmx.MarkupSettingsMBean#setCompressWhitespace(boolean)
100         */
101        @Override
102        public void setCompressWhitespace(final boolean compressWhitespace)
103        {
104                application.getMarkupSettings().setCompressWhitespace(compressWhitespace);
105        }
106
107        /**
108         * @throws UnsupportedEncodingException
109         * @see org.apache.wicket.jmx.MarkupSettingsMBean#setDefaultMarkupEncoding(java.lang.String)
110         */
111        @Override
112        public void setDefaultMarkupEncoding(final String encoding) throws UnsupportedEncodingException
113        {
114                // test encoding is available
115                "".getBytes(encoding);
116
117                application.getMarkupSettings().setDefaultMarkupEncoding(encoding);
118        }
119
120        /**
121         * @see org.apache.wicket.jmx.MarkupSettingsMBean#setStripComments(boolean)
122         */
123        @Override
124        public void setStripComments(final boolean stripComments)
125        {
126                application.getMarkupSettings().setStripComments(stripComments);
127        }
128
129        /**
130         * @see org.apache.wicket.jmx.MarkupSettingsMBean#setStripWicketTags(boolean)
131         */
132        @Override
133        public void setStripWicketTags(final boolean stripWicketTags)
134        {
135                application.getMarkupSettings().setStripWicketTags(stripWicketTags);
136        }
137}