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  package org.apache.directory.server.protocol.shared;
20  
21  
22  import org.apache.directory.server.core.DirectoryService;
23  
24  import java.util.Collections;
25  import java.util.HashSet;
26  import java.util.Set;
27  
28  
29  /**
30   * An abstract base class for a ProtocolService. The start/stop methods have
31   * not been implemented.
32   *
33   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
34   * @version $Rev$, $Date$
35   */
36  public abstract class AbstractProtocolService implements ProtocolService
37  {
38      private boolean started;
39      private boolean enabled;
40      private String serviceId;
41      private String serviceName;
42      private String ipAddress;
43      private int ipPort = -1;
44      private Set<TransportProtocol> transportProtocols;
45      private DatagramAcceptor datagramAcceptor;
46      private SocketAcceptor socketAcceptor;
47      /** directory service core where protocol data is backed */
48      private DirectoryService directoryService;
49  
50  
51      public DirectoryService getDirectoryService()
52      {
53          return directoryService;
54      }
55  
56  
57      public void setDirectoryService( DirectoryService directoryService )
58      {
59          this.directoryService = directoryService;
60      }
61  
62  
63      public boolean isStarted()
64      {
65          return started;
66      }
67  
68  
69      protected void setStarted( boolean started )
70      {
71          this.started = started;
72      }
73  
74  
75      public boolean isEnabled()
76      {
77          return enabled;
78      }
79  
80  
81      public void setEnabled( boolean enabled )
82      {
83          this.enabled = enabled;
84      }
85  
86  
87      public String getServiceId()
88      {
89          return serviceId;
90      }
91  
92  
93      public void setServiceId( String serviceId )
94      {
95          this.serviceId = serviceId;
96      }
97  
98  
99      public String getServiceName()
100     {
101         return serviceName;
102     }
103 
104 
105     public void setServiceName( String name )
106     {
107         this.serviceName = name;
108     }
109 
110 
111     public String getIpAddress()
112     {
113         return ipAddress;
114     }
115 
116 
117     public void setIpAddress( String ipAddress )
118     {
119         this.ipAddress = ipAddress;
120     }
121 
122 
123     public int getIpPort()
124     {
125         return ipPort;
126     }
127 
128 
129     public void setIpPort( int ipPort )
130     {
131         if ( ipPort < 0 || ipPort > 65535 )
132         {
133             throw new IllegalArgumentException( "Invalid port number: " + ipPort );
134         }
135 
136         this.ipPort = ipPort;
137     }
138 
139 
140     public Set<TransportProtocol> getTransportProtocols()
141     {
142         return transportProtocols;
143     }
144 
145 
146     public void setTransportProtocols( Set<TransportProtocol> transportProtocols )
147     {
148         Set<TransportProtocol> copy = new HashSet<TransportProtocol>( transportProtocols.size() );
149         copy.addAll( transportProtocols );
150         this.transportProtocols = Collections.unmodifiableSet( copy );
151     }
152 
153 
154     public DatagramAcceptor getDatagramAcceptor()
155     {
156         return datagramAcceptor;
157     }
158 
159 
160     public void setDatagramAcceptor( DatagramAcceptor datagramAcceptor )
161     {
162         this.datagramAcceptor = datagramAcceptor;
163     }
164 
165 
166     public SocketAcceptor getSocketAcceptor()
167     {
168         return socketAcceptor;
169     }
170 
171 
172     public void setSocketAcceptor( SocketAcceptor socketAcceptor )
173     {
174         this.socketAcceptor = socketAcceptor;
175     }
176 }