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; 020import java.time.Duration; 021import org.apache.wicket.Application; 022import org.apache.wicket.jmx.RequestCycleSettingsMBean; 023 024 025/** 026 * Exposes Application related functionality for JMX. 027 * 028 * @author eelcohillenius 029 */ 030public class RequestCycleSettings implements RequestCycleSettingsMBean 031{ 032 private final Application application; 033 034 /** 035 * Create. 036 * 037 * @param application 038 */ 039 public RequestCycleSettings(final Application application) 040 { 041 this.application = application; 042 } 043 044 /** 045 * @see org.apache.wicket.jmx.RequestCycleSettingsMBean#getBufferResponse() 046 */ 047 @Override 048 public boolean getBufferResponse() 049 { 050 return application.getRequestCycleSettings().getBufferResponse(); 051 } 052 053 /** 054 * @see org.apache.wicket.jmx.RequestCycleSettingsMBean#getGatherExtendedBrowserInfo() 055 */ 056 @Override 057 public boolean getGatherExtendedBrowserInfo() 058 { 059 return application.getRequestCycleSettings().getGatherExtendedBrowserInfo(); 060 } 061 062 /** 063 * @see org.apache.wicket.jmx.RequestCycleSettingsMBean#getResponseRequestEncoding() 064 */ 065 @Override 066 public String getResponseRequestEncoding() 067 { 068 return application.getRequestCycleSettings().getResponseRequestEncoding(); 069 } 070 071 /** 072 * @see org.apache.wicket.jmx.RequestCycleSettingsMBean#getTimeout() 073 */ 074 @Override 075 public String getTimeout() 076 { 077 return application.getRequestCycleSettings().getTimeout().toString(); 078 } 079 080 /** 081 * @see org.apache.wicket.jmx.RequestCycleSettingsMBean#setBufferResponse(boolean) 082 */ 083 @Override 084 public void setBufferResponse(final boolean bufferResponse) 085 { 086 application.getRequestCycleSettings().setBufferResponse(bufferResponse); 087 } 088 089 /** 090 * @see org.apache.wicket.jmx.RequestCycleSettingsMBean#setGatherExtendedBrowserInfo(boolean) 091 */ 092 @Override 093 public void setGatherExtendedBrowserInfo(final boolean gatherExtendedBrowserInfo) 094 { 095 application.getRequestCycleSettings().setGatherExtendedBrowserInfo( 096 gatherExtendedBrowserInfo); 097 } 098 099 /** 100 * @throws UnsupportedEncodingException 101 * if encoding is not supported 102 * 103 * @see org.apache.wicket.jmx.RequestCycleSettingsMBean#setResponseRequestEncoding(java.lang.String) 104 */ 105 @Override 106 public void setResponseRequestEncoding(final String responseRequestEncoding) 107 throws UnsupportedEncodingException 108 { 109 // test encoding is available 110 "".getBytes(responseRequestEncoding); 111 112 application.getRequestCycleSettings().setResponseRequestEncoding(responseRequestEncoding); 113 } 114 115 /** 116 * @see org.apache.wicket.jmx.RequestCycleSettingsMBean#setTimeout(java.lang.String) 117 */ 118 @Override 119 public void setTimeout(final String timeout) 120 { 121 application.getRequestCycleSettings().setTimeout(Duration.parse(timeout)); 122 } 123 124 @Override 125 public void setExceptionRetryCount(int retries) 126 { 127 application.getRequestCycleSettings().setExceptionRetryCount(retries); 128 } 129 130 @Override 131 public int getExceptionRetryCount() 132 { 133 return application.getRequestCycleSettings().getExceptionRetryCount(); 134 } 135}