Package org.jvnet.hk2.config
Class WriteableView
- java.lang.Object
-
- 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
Constructors Constructor Description WriteableView(ConfigBeanProxy readView)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort(Transaction t)
Aborts this Transaction, reverting the state<T extends ConfigBeanProxy>
TallocateProxy(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 objectList<PropertyChangeEvent>
commit(Transaction t)
Commit this Transaction.ConfigBean
getMasterView()
ConfigModel.Property
getProperty(String xmlName)
String
getPropertyValue(String propertyName)
<T extends ConfigBeanProxy>
TgetProxy(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"
-
-
-
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 interfaceInvocationHandler
- Throws:
Throwable
-
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 interfaceTransactor
- 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 interfaceTransactor
- 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 interfaceTransactor
- 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 interfaceTransactor
- 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 interfaceConfigView
-
setMasterView
public void setMasterView(ConfigView view)
- Specified by:
setMasterView
in interfaceConfigView
-
getProxyType
public <T extends ConfigBeanProxy> Class<T> getProxyType()
- Specified by:
getProxyType
in interfaceConfigView
-
getProxy
public <T extends ConfigBeanProxy> T getProxy(Class<T> type)
- Specified by:
getProxy
in interfaceConfigView
-
-