eXo Kernel :: Component :: Common Service 2.4.3-CLD

org.exoplatform.services.naming
Class InitialContextBinder

java.lang.Object
  extended by org.exoplatform.services.naming.InitialContextBinder

public class InitialContextBinder
extends Object

Class is responsible for binding references at runtime, persists on file and automatically binds after restart.

Version:
$Id: InitialContextBinder.java 111 2010-11-11 11:11:11Z tolusha $
Author:
Anatoliy Bazko

Field Summary
static String BIND_NAME_ATTR
           
static String BIND_REFERENCES_ELEMENT
           
protected  Map<String,Reference> bindings
          All current binded references.
protected  String bindingsStorePath
          Absolute file path to references's storage.
static String CLASS_NAME_ATTR
           
static String FACTORY_ATTR
           
static String FACTORY_LOCATION_ATTR
           
protected  InitialContextInitializer initialContextInitializer
          Initial context binder.
static String PROPERTY_ELEMENT
           
static String REFADDR_ELEMENT
           
static String REFERENCE_ELEMENT
           
 
Method Summary
 void bind(String bindName, Reference reference)
          Binds the reference in initial contexts and persists list of all binded references into file.
 void bind(String bindName, String className, String factory, String factoryLocation, Map<String,String> refAddr)
          Constructs references from params, binds in initial contexts and persists list of all binded references into file.
 Reference getReference(String bindName)
          Returns reference associated with defined name.
protected  Map<String,Reference> readBindings()
          Import references from xml-file.
protected  void saveBindings()
          Export references into xml-file.
 void unbind(String bindName)
          Unbind the Reference with defined name, remove from the bindings list and persists the rest of references into the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BIND_REFERENCES_ELEMENT

public static final String BIND_REFERENCES_ELEMENT
See Also:
Constant Field Values

REFERENCE_ELEMENT

public static final String REFERENCE_ELEMENT
See Also:
Constant Field Values

PROPERTY_ELEMENT

public static final String PROPERTY_ELEMENT
See Also:
Constant Field Values

REFADDR_ELEMENT

public static final String REFADDR_ELEMENT
See Also:
Constant Field Values

BIND_NAME_ATTR

public static final String BIND_NAME_ATTR
See Also:
Constant Field Values

CLASS_NAME_ATTR

public static final String CLASS_NAME_ATTR
See Also:
Constant Field Values

FACTORY_ATTR

public static final String FACTORY_ATTR
See Also:
Constant Field Values

FACTORY_LOCATION_ATTR

public static final String FACTORY_LOCATION_ATTR
See Also:
Constant Field Values

initialContextInitializer

protected final InitialContextInitializer initialContextInitializer
Initial context binder.


bindingsStorePath

protected final String bindingsStorePath
Absolute file path to references's storage.


bindings

protected Map<String,Reference> bindings
All current binded references.

Method Detail

bind

public void bind(String bindName,
                 String className,
                 String factory,
                 String factoryLocation,
                 Map<String,String> refAddr)
          throws NamingException,
                 FileNotFoundException,
                 XMLStreamException
Constructs references from params, binds in initial contexts and persists list of all binded references into file.

Parameters:
bindName - bind name
className - class name
factory - factory name
factoryLocation - factory location
refAddr - map of references's properties
Throws:
NamingException - if error occurs due to binding
XMLStreamException
FileNotFoundException

bind

public void bind(String bindName,
                 Reference reference)
          throws NamingException,
                 FileNotFoundException,
                 XMLStreamException
Binds the reference in initial contexts and persists list of all binded references into file.

Parameters:
bindName - bind name
reference - reference
Throws:
NamingException - if error occurs due to binding
FileNotFoundException
XMLStreamException

unbind

public void unbind(String bindName)
            throws NamingException,
                   FileNotFoundException,
                   XMLStreamException
Unbind the Reference with defined name, remove from the bindings list and persists the rest of references into the file.

Parameters:
bindName - the Reference's bind name
Throws:
NamingException
FileNotFoundException
XMLStreamException

getReference

public Reference getReference(String bindName)
Returns reference associated with defined name.

Parameters:
bindName - the name on which the reference was binded.

saveBindings

protected void saveBindings()
                     throws FileNotFoundException,
                            XMLStreamException
Export references into xml-file.

Throws:
XMLStreamException - if any exception occurs during export
FileNotFoundException - if can't open output stream from file

readBindings

protected Map<String,Reference> readBindings()
                                      throws FileNotFoundException,
                                             XMLStreamException
Import references from xml-file.

Returns:
map with bind name - references
Throws:
XMLStreamException - if errors occurs during import
FileNotFoundException - if can't open input stream from file

eXo Kernel :: Component :: Common Service 2.4.3-CLD

Copyright © 2013 eXo Platform SAS. All Rights Reserved.