org.jboss.weld.context.beanstore
Class AttributeBeanStore

java.lang.Object
  extended by org.jboss.weld.context.beanstore.AttributeBeanStore
All Implemented Interfaces:
Iterable<String>, BeanStore, BoundBeanStore
Direct Known Subclasses:
AbstractSessionBeanStore, InvocationContextBeanStore, MapBeanStore, RequestBeanStore

public abstract class AttributeBeanStore
extends Object
implements BoundBeanStore

A bound bean store backed by attributes. This bean store is "write-through" - if attached it will write any modifications to the backing store immediately. If detached modifications will not be written through. If the bean store is reattched, then any local modifications will be written to the underlying store.

This construct is not thread safe.

Author:
Pete Muir, Nicklas Karlsson, David Allen

Constructor Summary
AttributeBeanStore(NamingScheme namingScheme)
           
 
Method Summary
 boolean attach()
           Attach the bean store, any updates from now on will be written through to the underlying store.
 void clear()
          Clears the store of contextual instances
 boolean contains(String id)
          Check if the store contains an instance
 boolean detach()
          Detach the bean store, causing updates to longer be written through to the underlying store.
<T> org.jboss.weld.context.api.ContextualInstance<T>
get(String id)
          Gets an instance of a contextual from the store
protected abstract  Object getAttribute(String prefixedId)
          Gets an attribute from the underlying storage
protected abstract  Collection<String> getAttributeNames()
          Gets an enumeration of the attribute names present in the underlying storage
protected abstract  LockStore getLockStore()
           
protected  NamingScheme getNamingScheme()
           
protected  Collection<String> getPrefixedAttributeNames()
          Gets an enumeration of the attribute names present in the underlying storage
 boolean isAttached()
          Return true if the bean store is attached
 Iterator<String> iterator()
           
 LockedBean lock(String id)
          Gets a creation lock for the given bean id.
<T> void
put(String id, org.jboss.weld.context.api.ContextualInstance<T> instance)
          Adds a bean instance to the storage
protected abstract  void removeAttribute(String prefixedId)
          Removes an attribute from the underlying storage
protected abstract  void setAttribute(String prefixedId, Object instance)
          Sets an instance under a key in the underlying storage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributeBeanStore

public AttributeBeanStore(NamingScheme namingScheme)
Method Detail

detach

public boolean detach()
Detach the bean store, causing updates to longer be written through to the underlying store.

Specified by:
detach in interface BoundBeanStore
Returns:
true if the bean store was detached, or false if the bean store is already detached

attach

public boolean attach()

Attach the bean store, any updates from now on will be written through to the underlying store.

When the bean store is attached, the detached state is assumed to be authoritative if there are any conflicts.

Specified by:
attach in interface BoundBeanStore
Returns:
true if the bean store was attached, or false if the bean store is already attached

isAttached

public boolean isAttached()
Description copied from interface: BoundBeanStore
Return true if the bean store is attached

Specified by:
isAttached in interface BoundBeanStore
Returns:
true if the bean store is attached or false if the bean store has been detached

get

public <T> org.jboss.weld.context.api.ContextualInstance<T> get(String id)
Description copied from interface: BeanStore
Gets an instance of a contextual from the store

Specified by:
get in interface BeanStore
Parameters:
id - The id of the contextual to return
Returns:
The instance or null if not found

put

public <T> void put(String id,
                    org.jboss.weld.context.api.ContextualInstance<T> instance)
Description copied from interface: BeanStore
Adds a bean instance to the storage

Specified by:
put in interface BeanStore
instance - the contextual instance

clear

public void clear()
Description copied from interface: BeanStore
Clears the store of contextual instances

Specified by:
clear in interface BeanStore

contains

public boolean contains(String id)
Description copied from interface: BeanStore
Check if the store contains an instance

Specified by:
contains in interface BeanStore
Parameters:
id - the id of the instance to check for
Returns:
true if the instance is present, otherwise false

getNamingScheme

protected NamingScheme getNamingScheme()

iterator

public Iterator<String> iterator()
Specified by:
iterator in interface Iterable<String>
Specified by:
iterator in interface BeanStore

getAttribute

protected abstract Object getAttribute(String prefixedId)
Gets an attribute from the underlying storage

Parameters:
prefixedId - The (prefixed) id of the attribute
Returns:
The data

removeAttribute

protected abstract void removeAttribute(String prefixedId)
Removes an attribute from the underlying storage

Parameters:
prefixedId - The (prefixed) id of the attribute to remove

getAttributeNames

protected abstract Collection<String> getAttributeNames()
Gets an enumeration of the attribute names present in the underlying storage

Returns:
The attribute names

getPrefixedAttributeNames

protected Collection<String> getPrefixedAttributeNames()
Gets an enumeration of the attribute names present in the underlying storage

Returns:
The attribute names

setAttribute

protected abstract void setAttribute(String prefixedId,
                                     Object instance)
Sets an instance under a key in the underlying storage

Parameters:
prefixedId - The (prefixed) id of the attribute to set
instance - The instance

lock

public LockedBean lock(String id)
Description copied from interface: BeanStore
Gets a creation lock for the given bean id.

Specified by:
lock in interface BeanStore
Parameters:
id - The bean id
Returns:
A handle that must be used to unlock the bean

getLockStore

protected abstract LockStore getLockStore()


Copyright © 2013 Seam Framework. All Rights Reserved.