org.jvnet.hk2.config.provider.internal
Class ConfigTransactionImpl

java.lang.Object
  extended by org.jvnet.hk2.config.provider.internal.ConfigTransactionImpl
All Implemented Interfaces:
InjectionResolverQuery, ConfigTransaction

@Service
public class ConfigTransactionImpl
extends Object
implements ConfigTransaction, InjectionResolverQuery

Implementation for ConfigTransaction.

Author:
Jeff Trent

Method Summary
 void commit()
          Locks changes, calls prepare (if not yet performed), followed by commit if no prepare errors.
 void commit(Map<Object,Object> beanReplacements)
          Same basic behavior as ConfigTransaction.commit() with the added ability to substitute configuration beans used in the prepare phase with the final bean object replacements that should be managed.
 void created(Object createdConfigBean, String name, MultiMap<String,String> metadata)
          Add configuration beans to the transaction.
 void deleted(Collection<?> deletedConfigBeans)
           
 void deleted(Object deleted)
          Marks configuration beans as having been deleted.
<V> V
getValue(Object component, Inhabitant<?> onBehalfOf, AnnotatedElement annotated, Type genericType, Class<V> type)
          override of InjectionResolverQuery to provide view of changes scoped to this txn context.
 void prepare()
          Locks changes, calls prepare.
 void rollback()
          Cancels the transaction, locking it out from further changes.
 void updated(Collection<?> updatedConfigBeans)
           
 void updated(Object updated, PropertyChangeEvent event)
          Mark configuration beans as having been updated (note that name and metadata cannot change here).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

prepare

public void prepare()
             throws ConfigTransactionException
Description copied from interface: ConfigTransaction
Locks changes, calls prepare.

Specified by:
prepare in interface ConfigTransaction
Throws:
ConfigTransactionException

commit

public void commit()
            throws ConfigTransactionException
Description copied from interface: ConfigTransaction
Locks changes, calls prepare (if not yet performed), followed by commit if no prepare errors. If prepare errors exists, calls rollback on the constituent configuration beans.

Specified by:
commit in interface ConfigTransaction
Throws:
ConfigTransactionException

commit

public void commit(Map<Object,Object> beanReplacements)
            throws ConfigTransactionException
Description copied from interface: ConfigTransaction
Same basic behavior as ConfigTransaction.commit() with the added ability to substitute configuration beans used in the prepare phase with the final bean object replacements that should be managed.

This is an important variant when the configuration beans in the prepare phase are transient in nature.

Specified by:
commit in interface ConfigTransaction
Parameters:
beanReplacements - mapping from the bean instance used in prepare, with the final version that should be managed
Throws:
ConfigTransactionException

rollback

public void rollback()
Description copied from interface: ConfigTransaction
Cancels the transaction, locking it out from further changes.

Specified by:
rollback in interface ConfigTransaction

created

public void created(Object createdConfigBean,
                    String name,
                    MultiMap<String,String> metadata)
Description copied from interface: ConfigTransaction
Add configuration beans to the transaction.

Specified by:
created in interface ConfigTransaction
Parameters:
createdConfigBean - - the configuration bean instance being created
name - - optionally the name for the configuration
metadata - - name,value(s)

deleted

public void deleted(Collection<?> deletedConfigBeans)
Specified by:
deleted in interface ConfigTransaction

deleted

public void deleted(Object deleted)
Description copied from interface: ConfigTransaction
Marks configuration beans as having been deleted.

Specified by:
deleted in interface ConfigTransaction

updated

public void updated(Collection<?> updatedConfigBeans)
Specified by:
updated in interface ConfigTransaction

updated

public void updated(Object updated,
                    PropertyChangeEvent event)
Description copied from interface: ConfigTransaction
Mark configuration beans as having been updated (note that name and metadata cannot change here).

Specified by:
updated in interface ConfigTransaction

getValue

public <V> V getValue(Object component,
                      Inhabitant<?> onBehalfOf,
                      AnnotatedElement annotated,
                      Type genericType,
                      Class<V> type)
           throws ComponentException
override of InjectionResolverQuery to provide view of changes scoped to this txn context.

Specified by:
getValue in interface InjectionResolverQuery
Parameters:
component - injection target instance
onBehalfOf - inhabitant doing the injection for
annotated - is the annotated java element Method or Field
genericType - the generic type of the expected return
type - type of the expected return
Returns:
the resource to be injected
Throws:
ComponentException - if the resource cannot be located.


Copyright © 2013 Oracle Corporation. All Rights Reserved.