Package org.exoplatform.services.naming
Class InitialContextBinder
java.lang.Object
org.exoplatform.services.naming.InitialContextBinder
Class is responsible for binding references at runtime, persists on file and automatically binds after restart.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final StringAll current binded references.protected final StringAbsolute file path to references's storage.static final Stringstatic final Stringstatic final Stringprotected final InitialContextInitializerInitial context binder.static final Stringstatic final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptionvoidbind(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.voidBinds the reference in initial contexts and persists list of all binded references into file.getReference(String bindName) Returns reference associated with defined name.Import references from xml-file.protected voidExport references into xml-file.voidUnbind the Reference with defined name, remove from the bindings list and persists the rest of references into the file.
-
Field Details
-
BIND_REFERENCES_ELEMENT
- See Also:
-
REFERENCE_ELEMENT
- See Also:
-
PROPERTY_ELEMENT
- See Also:
-
REFADDR_ELEMENT
- See Also:
-
BIND_NAME_ATTR
- See Also:
-
CLASS_NAME_ATTR
- See Also:
-
FACTORY_ATTR
- See Also:
-
FACTORY_LOCATION_ATTR
- See Also:
-
initialContextInitializer
Initial context binder. -
bindingsStorePath
Absolute file path to references's storage. -
bindings
All current binded references.
-
-
Method Details
-
bind
public void bind(String bindName, String className, String factory, String factoryLocation, Map<String, String> refAddr) throws NamingException, FileNotFoundException, XMLStreamExceptionConstructs 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
Returns reference associated with defined name.- Parameters:
bindName- the name on which the reference was binded.
-
saveBindings
Export references into xml-file.- Throws:
XMLStreamException- if any exception occurs during exportFileNotFoundException- if can't open output stream from file
-
readBindings
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
-