Package org.exoplatform.services.naming
Class InitialContextBinder
- java.lang.Object
-
- 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
Fields Modifier and Type Field Description static StringBIND_NAME_ATTRstatic StringBIND_REFERENCES_ELEMENTprotected Map<String,Reference>bindingsAll current binded references.protected StringbindingsStorePathAbsolute file path to references's storage.static StringCLASS_NAME_ATTRstatic StringFACTORY_ATTRstatic StringFACTORY_LOCATION_ATTRprotected InitialContextInitializerinitialContextInitializerInitial context binder.static StringPROPERTY_ELEMENTstatic StringREFADDR_ELEMENTstatic StringREFERENCE_ELEMENT
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbind(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.voidbind(String bindName, Reference reference)Binds the reference in initial contexts and persists list of all binded references into file.ReferencegetReference(String bindName)Returns reference associated with defined name.protected Map<String,Reference>readBindings()Import references from xml-file.protected voidsaveBindings()Export references into xml-file.voidunbind(String bindName)Unbind the Reference with defined name, remove from the bindings list and persists the rest of references into the file.
-
-
-
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.
-
-
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 nameclassName- class namefactory- factory namefactoryLocation- factory locationrefAddr- map of references's properties- Throws:
NamingException- if error occurs due to bindingXMLStreamExceptionFileNotFoundException
-
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 namereference- reference- Throws:
NamingException- if error occurs due to bindingFileNotFoundExceptionXMLStreamException
-
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:
NamingExceptionFileNotFoundExceptionXMLStreamException
-
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, XMLStreamExceptionExport references into xml-file.- Throws:
XMLStreamException- if any exception occurs during exportFileNotFoundException- 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 importFileNotFoundException- if can't open input stream from file
-
-