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 * 019 */ 020package org.apache.directory.server.config.beans; 021 022 023import java.util.ArrayList; 024import java.util.List; 025 026import org.apache.directory.server.config.ConfigurationElement; 027 028 029/** 030 * A class used to store the HttpServer configuration. 031 * 032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 033 */ 034public class HttpServerBean extends ServerBean 035{ 036 /** The configuration file */ 037 @ConfigurationElement(attributeType = "ads-httpConfFile", isOptional = true) 038 private String httpConfFile; 039 040 /** The list of supported web apps */ 041 @ConfigurationElement(objectClass = "ads-httpWebApp", container = "httpWebApps") 042 private List<HttpWebAppBean> httpWebApps = new ArrayList<>(); 043 044 045 /** 046 * Create a new HttpServerBean instance 047 */ 048 public HttpServerBean() 049 { 050 super(); 051 052 // Enabled by default 053 setEnabled( true ); 054 } 055 056 057 /** 058 * @return the httpConfFile 059 */ 060 public String getHttpConfFile() 061 { 062 return httpConfFile; 063 } 064 065 066 /** 067 * @param httpConfFile the httpConfFile to set 068 */ 069 public void setHttpConfFile( String httpConfFile ) 070 { 071 this.httpConfFile = httpConfFile; 072 } 073 074 075 /** 076 * @return the httpWebApps 077 */ 078 public List<HttpWebAppBean> getHttpWebApps() 079 { 080 return httpWebApps; 081 } 082 083 084 /** 085 * @param httpWebApps the httpWebApps to set 086 */ 087 public void setHttpWebApps( List<HttpWebAppBean> httpWebApps ) 088 { 089 this.httpWebApps = httpWebApps; 090 } 091 092 093 /** 094 * @param httpWebApps the httpWebApps to add 095 */ 096 public void addHttpWebApps( HttpWebAppBean... httpWebApps ) 097 { 098 for ( HttpWebAppBean httpWebApp : httpWebApps ) 099 { 100 this.httpWebApps.add( httpWebApp ); 101 } 102 } 103 104 105 /** 106 * {@inheritDoc} 107 */ 108 @Override 109 public String toString( String tabs ) 110 { 111 StringBuilder sb = new StringBuilder(); 112 113 sb.append( tabs ).append( "HttpServer :\n" ); 114 sb.append( super.toString( tabs + " " ) ); 115 sb.append( toString( tabs, " http configuration file", httpConfFile ) ); 116 117 if ( ( httpWebApps != null ) && !httpWebApps.isEmpty() ) 118 { 119 sb.append( tabs ).append( " web applications :\n" ); 120 121 for ( HttpWebAppBean httpWebApp : httpWebApps ) 122 { 123 sb.append( httpWebApp.toString( tabs + " " ) ); 124 } 125 } 126 127 return sb.toString(); 128 } 129 130 131 /** 132 * {@inheritDoc} 133 */ 134 @Override 135 public String toString() 136 { 137 return toString( "" ); 138 } 139}