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.api.ldap.codec.api;
21  
22  
23  import org.apache.directory.api.ldap.model.message.Control;
24  
25  
26  /**
27   * Implementors of new codec control extensions must implement a factory using
28   * this factory interface, Factory implementations for specific controls are
29   * then registered with the codec and used by the codec to encode and decode
30   * those controls.
31   *
32   * @TODO must review this interface - too many methods - implementors should not
33   * have to implement so many methods.
34   *
35   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
36   * @version $Rev$, $Date$
37   */
38  public interface ControlFactory<C extends Control>
39  {
40      /**
41       * @return The OID of the Control this factory creates.
42       */
43      String getOid();
44  
45  
46      /**
47       * Creates and returns a decorated version of the Control.
48       *
49       * @return The {@link CodecControl} decorated version of the Control.
50       */
51      CodecControl<C> newCodecControl();
52  
53  
54      /**
55       * Decorates an existing control. Implementors should check to make sure
56       * the supplied Control has not already been decorated to prevent needless
57       * decorator nesting.
58       *
59       * @param control The {@link Control} to be decorated.
60       * @return The decorator wrapping the Control.
61       */
62      CodecControl<C> newCodecControl( C control );
63  }