org.jvnet.hk2.config
Class WriteableView

java.lang.Object
  extended by org.jvnet.hk2.config.WriteableView
All Implemented Interfaces:
InvocationHandler, ConfigView, Transactor

public class WriteableView
extends Object
implements InvocationHandler, Transactor, ConfigView

A WriteableView is a view of a ConfigBean object that allow access to the setters of the ConfigBean.

Author:
Jerome Dochez

Constructor Summary
WriteableView(ConfigBeanProxy readView)
           
 
Method Summary
 void abort(Transaction t)
          Aborts this Transaction, reverting the state
<T extends ConfigBeanProxy>
T
allocateProxy(Class<T> type)
          Allocate a new ConfigBean object as part of the Transaction associated with this configuration object.
 boolean canCommit(Transaction t)
          Returns true of this Transaction can be committed on this object
 List<PropertyChangeEvent> commit(Transaction t)
          Commit this Transaction.
 ConfigBean getMasterView()
           
 ConfigModel.Property getProperty(String xmlName)
           
 String getPropertyValue(String propertyName)
           
<T extends ConfigBeanProxy>
T
getProxy(Class<T> type)
           
<T extends ConfigBeanProxy>
Class<T>
getProxyType()
           
 Object getter(ConfigModel.Property property, Type t)
           
 Transaction getTransaction()
           
 Object invoke(Object proxy, Method method, Object[] args)
           
 boolean join(Transaction t)
          Enter a new Transaction, this method should return false if this object is already enlisted in another transaction, or cannot be enlisted with the passed transaction.
 void setMasterView(ConfigView view)
           
 void setter(ConfigModel.Property property, Object newValue, Type t)
           
static String stripMarkers(String s)
          remove @ or <> eg "@foo" => "foo" or "" => "foo"
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WriteableView

public WriteableView(ConfigBeanProxy readView)
Method Detail

getTransaction

public Transaction getTransaction()

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Specified by:
invoke in interface InvocationHandler
Throws:
Throwable

getPropertyValue

public String getPropertyValue(String propertyName)

getter

public Object getter(ConfigModel.Property property,
                     Type t)

setter

public void setter(ConfigModel.Property property,
                   Object newValue,
                   Type t)

getProperty

public ConfigModel.Property getProperty(String xmlName)

join

public boolean join(Transaction t)
Enter a new Transaction, this method should return false if this object is already enlisted in another transaction, or cannot be enlisted with the passed transaction. If the object returns true, the object is enlisted in the passed transaction and cannot be enlisted in another transaction until either commit or abort has been issued.

Specified by:
join in interface Transactor
Parameters:
t - the transaction to enlist with
Returns:
true if the enlisting with the passed transaction was accepted, false otherwise

canCommit

public boolean canCommit(Transaction t)
                  throws TransactionFailure
Returns true of this Transaction can be committed on this object

Specified by:
canCommit in interface Transactor
Parameters:
t - is the transaction to commit, should be the same as the one passed during the join(Transaction t) call.
Returns:
true if the trsaction commiting would be successful
Throws:
TransactionFailure - if the changes cannot be validated

stripMarkers

public static String stripMarkers(String s)
remove @ or <> eg "@foo" => "foo" or "" => "foo"


commit

public List<PropertyChangeEvent> commit(Transaction t)
                                 throws TransactionFailure
Commit this Transaction.

Specified by:
commit in interface Transactor
Parameters:
t - the transaction commiting.
Returns:
list of applied property changes
Throws:
TransactionFailure - if the transaction commit failed

abort

public void abort(Transaction t)
Aborts this Transaction, reverting the state

Specified by:
abort in interface Transactor
Parameters:
t - the aborting transaction

allocateProxy

public <T extends ConfigBeanProxy> T allocateProxy(Class<T> type)
                                        throws TransactionFailure
Allocate a new ConfigBean object as part of the Transaction associated with this configuration object. This will eventually be moved to a factory.

Parameters:
type - the request configuration object type
Returns:
the propertly constructed configuration object
Throws:
TransactionFailure - if the allocation failed

getMasterView

public ConfigBean getMasterView()
Specified by:
getMasterView in interface ConfigView

setMasterView

public void setMasterView(ConfigView view)
Specified by:
setMasterView in interface ConfigView

getProxyType

public <T extends ConfigBeanProxy> Class<T> getProxyType()
Specified by:
getProxyType in interface ConfigView

getProxy

public <T extends ConfigBeanProxy> T getProxy(Class<T> type)
Specified by:
getProxy in interface ConfigView


Copyright © 2013 Oracle Corporation. All Rights Reserved.