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 Server configuration. It can't be instanciated 031 * 032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 033 */ 034public abstract class ServerBean extends AdsBaseBean 035{ 036 /** The server unique identifier */ 037 @ConfigurationElement(attributeType = "ads-serverId", isRdn = true) 038 private String serverId; 039 040 /** The set of transports to use for this server */ 041 @ConfigurationElement(objectClass = "ads-transport", container = "transports") 042 private List<TransportBean> transports = new ArrayList<>(); 043 044 045 /** 046 * Create a new ServerBean instance 047 */ 048 protected ServerBean() 049 { 050 } 051 052 053 /** 054 * @return the transport 055 */ 056 public TransportBean[] getTransports() 057 { 058 return transports.toArray( new TransportBean[] 059 {} ); 060 } 061 062 063 /** 064 * Set the underlying transports 065 * @param transports The transports 066 */ 067 public void setTransports( TransportBean... transports ) 068 { 069 for ( TransportBean transport : transports ) 070 { 071 this.transports.add( transport ); 072 } 073 } 074 075 076 /** 077 * Add underlying transports 078 * @param transports The transports 079 */ 080 public void addTransports( TransportBean... transports ) 081 { 082 for ( TransportBean transport : transports ) 083 { 084 this.transports.add( transport ); 085 } 086 } 087 088 089 /** 090 * @return the serverId 091 */ 092 public String getServerId() 093 { 094 return serverId; 095 } 096 097 098 /** 099 * @param serverId the serverId to set 100 */ 101 public void setServerId( String serverId ) 102 { 103 this.serverId = serverId; 104 } 105 106 107 /** 108 * {@inheritDoc} 109 */ 110 @Override 111 public String toString( String tabs ) 112 { 113 StringBuilder sb = new StringBuilder(); 114 115 sb.append( super.toString( tabs ) ); 116 sb.append( tabs ).append( "server id : " ).append( serverId ).append( '\n' ); 117 sb.append( tabs ).append( "transports : \n" ); 118 119 if ( transports != null ) 120 { 121 for ( TransportBean transport : transports ) 122 { 123 sb.append( transport.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}