View Javadoc
1   /*
2    *   Licensed to the Apache Software Foundation (ASF) under one
3    *   or more contributor license agreements.  See the NOTICE file
4    *   distributed with this work for additional information
5    *   regarding copyright ownership.  The ASF licenses this file
6    *   to you under the Apache License, Version 2.0 (the
7    *   "License"); you may not use this file except in compliance
8    *   with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing,
13   *   software distributed under the License is distributed on an
14   *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *   KIND, either express or implied.  See the License for the
16   *   specific language governing permissions and limitations
17   *   under the License.
18   *
19   */
20  package org.apache.directory.server.config.beans;
21  
22  
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  import org.apache.directory.server.config.ConfigurationElement;
27  
28  
29  /**
30   * A class used to store the Server configuration. It can't be instanciated
31   *
32   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
33   */
34  public abstract class ServerBean extends AdsBaseBean
35  {
36      /** The server unique identifier */
37      @ConfigurationElement(attributeType = "ads-serverId", isRdn = true)
38      private String serverId;
39  
40      /** The set of transports to use for this server */
41      @ConfigurationElement(objectClass = "ads-transport", container = "transports")
42      private List<TransportBean> transports = new ArrayList<>();
43  
44  
45      /**
46       * Create a new ServerBean instance
47       */
48      protected ServerBean()
49      {
50      }
51  
52  
53      /**
54       * @return the transport
55       */
56      public TransportBean[] getTransports()
57      {
58          return transports.toArray( new TransportBean[]
59              {} );
60      }
61  
62  
63      /**
64       * Set the underlying transports
65       * @param transports The transports
66       */
67      public void setTransports( TransportBean... transports )
68      {
69          for ( TransportBean transport : transports )
70          {
71              this.transports.add( transport );
72          }
73      }
74  
75  
76      /**
77       * Add underlying transports
78       * @param transports The transports
79       */
80      public void addTransports( TransportBean... transports )
81      {
82          for ( TransportBean transport : transports )
83          {
84              this.transports.add( transport );
85          }
86      }
87  
88  
89      /**
90       * @return the serverId
91       */
92      public String getServerId()
93      {
94          return serverId;
95      }
96  
97  
98      /**
99       * @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 }