org.apache.directory.api.ldap.codec.standalone
Class StandaloneLdapApiService

java.lang.Object
  extended by org.apache.directory.api.ldap.codec.standalone.StandaloneLdapApiService
All Implemented Interfaces:
LdapApiService

public class StandaloneLdapApiService
extends Object
implements LdapApiService

The default LdapApiService implementation.

Version:
$Rev$, $Date$
Author:
Apache Directory Project

Field Summary
static String DEFAULT_CONTROLS_LIST
          The list of default controls to load at startup
static String DEFAULT_EXTENDED_OPERATION_REQUESTS_LIST
          The list of default extended operation requests to load at startup
static String DEFAULT_EXTENDED_OPERATION_RESPONSES_LIST
          The list of default extended operation responses to load at startup
static String EXTRA_CONTROLS_LIST
          The list of extra controls to load at startup
static String EXTRA_EXTENDED_OPERATION_LIST
          The list of extra controls to load at startup
 
Fields inherited from interface org.apache.directory.api.ldap.codec.api.LdapApiService
DEFAULT_PROTOCOL_CODEC_FACTORY
 
Constructor Summary
StandaloneLdapApiService()
          Creates a new instance of StandaloneLdapCodecService.
 
Method Summary
 ExtendedRequestDecorator<?,?> decorate(ExtendedRequest<?> decoratedMessage)
          
 ExtendedResponseDecorator<?> decorate(ExtendedResponse decoratedMessage)
          
 ExtendedRequest<?> fromJndi(ExtendedRequest jndiRequest)
          Creates a model ExtendedResponse from the JNDI ExtendedResponse.
 ExtendedResponse fromJndi(ExtendedResponse jndiResponse)
          Creates a model ExtendedResponse from the JNDI ExtendedResponse.
 Control fromJndiControl(Control control)
          Creates a model control from the JNDI control.
 org.apache.mina.filter.codec.ProtocolCodecFactory getProtocolCodecFactory()
          Creates a new LDAP ProtocolCodecFactory.
 boolean isControlRegistered(String oid)
          Checks if a control has been registered.
 boolean isExtendedOperationRegistered(String oid)
          Checks to see if an extended operation, either a standard request response, pair or just an unsolicited response is registered.
 CodecControl<? extends Control> newControl(Control control)
          Creates a new codec control decorator for the provided control.
 CodecControl<? extends Control> newControl(String oid)
          Creates a new codec control decorator of the specified type.
 ExtendedRequest<?> newExtendedRequest(String oid, byte[] value)
          Creates a new ExtendedRequest instance.
<E extends ExtendedResponse>
E
newExtendedResponse(ExtendedRequest<E> req, byte[] serializedResponse)
          
 Asn1Container newMessageContainer()
          Creates a new MessageContainer.
 ControlFactory<?,?> registerControl(ControlFactory<?,?> factory)
          Registers an ControlFactory with this service.
 Iterator<String> registeredControls()
          Returns an Iterator over the OID Strings of registered controls.
 Iterator<String> registeredExtendedRequests()
          Returns an Iterator over the OID Strings of registered extended requests.
 Iterator<String> registeredUnsolicitedResponses()
          Returns an Iterator over the OID Strings of registered unsolicited extended responses.
 ExtendedRequestFactory<?,?> registerExtendedRequest(ExtendedRequestFactory<?,?> factory)
          Registers an ExtendedRequestFactory for generating extended request response pairs.
 org.apache.mina.filter.codec.ProtocolCodecFactory registerProtocolCodecFactory(org.apache.mina.filter.codec.ProtocolCodecFactory protocolCodecFactory)
          Registers a ProtocolCodecFactory with this LdapCodecService.
 UnsolicitedResponseFactory<?> registerUnsolicitedResponse(UnsolicitedResponseFactory<?> factory)
          Registers an UnsolicitedResponseFactory for generating extended responses sent by servers without an extended request.
 ExtendedRequest toJndi(ExtendedRequest<?> modelRequest)
          Creates a JNDI ExtendedResponse from the model ExtendedResponse.
 ExtendedResponse toJndi(ExtendedResponse modelResponse)
          Creates a JNDI ExtendedResponse from the model ExtendedResponse.
 Control toJndiControl(Control control)
          Creates a JNDI control from the ldap model's control.
 ControlFactory<?,?> unregisterControl(String oid)
          Unregisters an ControlFactory with this service.
 ExtendedRequestFactory<?,?> unregisterExtendedRequest(String oid)
          Unregisters an ExtendedRequestFactory for generating extended request response pairs.
 UnsolicitedResponseFactory<?> unregisterUnsolicitedResponse(String oid)
          Unregisters an UnsolicitedResponseFactory for generating extended responses sent by servers without an extended request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONTROLS_LIST

public static final String DEFAULT_CONTROLS_LIST
The list of default controls to load at startup

See Also:
Constant Field Values

EXTRA_CONTROLS_LIST

public static final String EXTRA_CONTROLS_LIST
The list of extra controls to load at startup

See Also:
Constant Field Values

DEFAULT_EXTENDED_OPERATION_REQUESTS_LIST

public static final String DEFAULT_EXTENDED_OPERATION_REQUESTS_LIST
The list of default extended operation requests to load at startup

See Also:
Constant Field Values

DEFAULT_EXTENDED_OPERATION_RESPONSES_LIST

public static final String DEFAULT_EXTENDED_OPERATION_RESPONSES_LIST
The list of default extended operation responses to load at startup

See Also:
Constant Field Values

EXTRA_EXTENDED_OPERATION_LIST

public static final String EXTRA_EXTENDED_OPERATION_LIST
The list of extra controls to load at startup

See Also:
Constant Field Values
Constructor Detail

StandaloneLdapApiService

public StandaloneLdapApiService()
                         throws Exception
Creates a new instance of StandaloneLdapCodecService. Optionally checks for system property #PLUGIN_DIRECTORY_PROPERTY. Intended for use by unit test running tools like Maven's surefire:
   <properties>
     <codec.plugin.directory>${project.build.directory}/pluginDirectory</codec.plugin.directory>
   </properties>
 
   <build>
     <plugins>
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
         <groupId>org.apache.maven.plugins</groupId>
         <configuration>
           <systemPropertyVariables>
             <workingDirectory>${basedir}/target</workingDirectory>
             <felix.cache.rootdir>
               ${project.build.directory}
             </felix.cache.rootdir>
             <felix.cache.locking>
               true
             </felix.cache.locking>
             <org.osgi.framework.storage.clean>
               onFirstInit
             </org.osgi.framework.storage.clean>
             <org.osgi.framework.storage>
               osgi-cache
             </org.osgi.framework.storage>
             <codec.plugin.directory>
               ${codec.plugin.directory}
             </codec.plugin.directory>
           </systemPropertyVariables>
         </configuration>
       </plugin>
       
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
         <executions>
           <execution>
             <id>copy</id>
             <phase>compile</phase>
             <goals>
               <goal>copy</goal>
             </goals>
             <configuration>
               <artifactItems>
                 <artifactItem>
                   <groupId>${project.groupId}</groupId>
                   <artifactId>api-ldap-extras-codec</artifactId>
                   <version>${project.version}</version>
                   <outputDirectory>${codec.plugin.directory}</outputDirectory>
                 </artifactItem>
               </artifactItems>
             </configuration>
           </execution>
         </executions>
       </plugin>
     </plugins>
   </build>
 

Throws:
Exception
Method Detail

registerControl

public ControlFactory<?,?> registerControl(ControlFactory<?,?> factory)
Registers an ControlFactory with this service.

Specified by:
registerControl in interface LdapApiService
Parameters:
factory - The control factory

unregisterControl

public ControlFactory<?,?> unregisterControl(String oid)
Unregisters an ControlFactory with this service.

Specified by:
unregisterControl in interface LdapApiService
Parameters:
oid - The oid of the control the factory is associated with.

registeredControls

public Iterator<String> registeredControls()
Returns an Iterator over the OID Strings of registered controls.

Specified by:
registeredControls in interface LdapApiService
Returns:
The registered control OID Strings

isControlRegistered

public boolean isControlRegistered(String oid)
Checks if a control has been registered.

Specified by:
isControlRegistered in interface LdapApiService
Returns:
The OID of the control to check for registration

registeredExtendedRequests

public Iterator<String> registeredExtendedRequests()
Returns an Iterator over the OID Strings of registered extended requests.

Specified by:
registeredExtendedRequests in interface LdapApiService
Returns:
The registered extended request OID Strings

registerExtendedRequest

public ExtendedRequestFactory<?,?> registerExtendedRequest(ExtendedRequestFactory<?,?> factory)
Registers an ExtendedRequestFactory for generating extended request response pairs.

Specified by:
registerExtendedRequest in interface LdapApiService
Parameters:
factory - The extended request factory
Returns:
The displaced factory if one existed for the oid

getProtocolCodecFactory

public org.apache.mina.filter.codec.ProtocolCodecFactory getProtocolCodecFactory()
Creates a new LDAP ProtocolCodecFactory.

Specified by:
getProtocolCodecFactory in interface LdapApiService
Returns:
the ProtocolCodecFactory

registerProtocolCodecFactory

public org.apache.mina.filter.codec.ProtocolCodecFactory registerProtocolCodecFactory(org.apache.mina.filter.codec.ProtocolCodecFactory protocolCodecFactory)
Registers a ProtocolCodecFactory with this LdapCodecService.

Specified by:
registerProtocolCodecFactory in interface LdapApiService
Parameters:
protocolCodecFactory - The factory being registered.
Returns:
The previously set ProtocolCodecFactory, or null if none had been set earlier.

newControl

public CodecControl<? extends Control> newControl(String oid)
Creates a new codec control decorator of the specified type.

Specified by:
newControl in interface LdapApiService
Parameters:
oid - The OID of the new control to create.
Returns:
The newly created codec control.

newControl

public CodecControl<? extends Control> newControl(Control control)
Creates a new codec control decorator for the provided control.

Specified by:
newControl in interface LdapApiService
Parameters:
control - The control the codec control is generated for.
Returns:
The newly created codec control.

toJndiControl

public Control toJndiControl(Control control)
                      throws EncoderException
Creates a JNDI control from the ldap model's control.

Specified by:
toJndiControl in interface LdapApiService
Parameters:
control - The model's control.
Returns:
The JNDI control.
Throws:
EncoderException - if there are problems encoding the modelControl.

fromJndiControl

public Control fromJndiControl(Control control)
                        throws DecoderException
Creates a model control from the JNDI control.

Specified by:
fromJndiControl in interface LdapApiService
Parameters:
control - The JNDI control.
Returns:
The model control.
Throws:
DecoderException - if there are problems decoding the value of the JNDI control.

newMessageContainer

public Asn1Container newMessageContainer()
Creates a new MessageContainer.

Specified by:
newMessageContainer in interface LdapApiService
Returns:
The newly created LDAP MessageContainer instance.

registeredUnsolicitedResponses

public Iterator<String> registeredUnsolicitedResponses()
Returns an Iterator over the OID Strings of registered unsolicited extended responses.

Specified by:
registeredUnsolicitedResponses in interface LdapApiService
Returns:
The registered unsolicited extended response OID Strings

registerUnsolicitedResponse

public UnsolicitedResponseFactory<?> registerUnsolicitedResponse(UnsolicitedResponseFactory<?> factory)
Registers an UnsolicitedResponseFactory for generating extended responses sent by servers without an extended request.

Specified by:
registerUnsolicitedResponse in interface LdapApiService
Parameters:
factory - The unsolicited response creating factory
Returns:
The displaced factory if one existed for the oid

toJndi

public ExtendedResponse toJndi(ExtendedResponse modelResponse)
                        throws EncoderException
Creates a JNDI ExtendedResponse from the model ExtendedResponse.

Specified by:
toJndi in interface LdapApiService
Returns:
Throws:
EncoderException

fromJndi

public ExtendedResponse fromJndi(ExtendedResponse jndiResponse)
                          throws DecoderException
Creates a model ExtendedResponse from the JNDI ExtendedResponse.

Specified by:
fromJndi in interface LdapApiService
Parameters:
jndiResponse - The JNDI ExtendedResponse
Returns:
The model ExtendedResponse
Throws:
DecoderException - if the response value cannot be decoded.

unregisterExtendedRequest

public ExtendedRequestFactory<?,?> unregisterExtendedRequest(String oid)
Unregisters an ExtendedRequestFactory for generating extended request response pairs.

Specified by:
unregisterExtendedRequest in interface LdapApiService
Parameters:
oid - The extended request oid
Returns:
The displaced factory if one existed for the oid

unregisterUnsolicitedResponse

public UnsolicitedResponseFactory<?> unregisterUnsolicitedResponse(String oid)
Unregisters an UnsolicitedResponseFactory for generating extended responses sent by servers without an extended request.

Specified by:
unregisterUnsolicitedResponse in interface LdapApiService
Parameters:
oid - The unsolicited response oid

fromJndi

public ExtendedRequest<?> fromJndi(ExtendedRequest jndiRequest)
                            throws DecoderException
Creates a model ExtendedResponse from the JNDI ExtendedResponse.

Specified by:
fromJndi in interface LdapApiService
Returns:
The model ExtendedResponse
Throws:
DecoderException - if the response value cannot be decoded.

toJndi

public ExtendedRequest toJndi(ExtendedRequest<?> modelRequest)
                       throws EncoderException
Creates a JNDI ExtendedResponse from the model ExtendedResponse.

Specified by:
toJndi in interface LdapApiService
Returns:
Throws:
EncoderException

newExtendedResponse

public <E extends ExtendedResponse> E newExtendedResponse(ExtendedRequest<E> req,
                                                          byte[] serializedResponse)
                                               throws DecoderException

Specified by:
newExtendedResponse in interface LdapApiService
Throws:
DecoderException

newExtendedRequest

public ExtendedRequest<?> newExtendedRequest(String oid,
                                             byte[] value)
Creates a new ExtendedRequest instance.

Specified by:
newExtendedRequest in interface LdapApiService
Parameters:
oid - the extended request's object identifier
value - the encoded value of the extended request
Returns:
The new extended request

decorate

public ExtendedRequestDecorator<?,?> decorate(ExtendedRequest<?> decoratedMessage)

Specified by:
decorate in interface LdapApiService

decorate

public ExtendedResponseDecorator<?> decorate(ExtendedResponse decoratedMessage)

Specified by:
decorate in interface LdapApiService

isExtendedOperationRegistered

public boolean isExtendedOperationRegistered(String oid)
Checks to see if an extended operation, either a standard request response, pair or just an unsolicited response is registered.

Specified by:
isExtendedOperationRegistered in interface LdapApiService
Parameters:
oid - The object identifier for the extended operation
Returns:
true if registered, false if not


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.