org.jvnet.hk2.internal
Class DynamicConfigurationImpl

java.lang.Object
  extended by org.jvnet.hk2.internal.DynamicConfigurationImpl
All Implemented Interfaces:
DynamicConfiguration

public class DynamicConfigurationImpl
extends Object
implements DynamicConfiguration

Author:
jwells

Constructor Summary
DynamicConfigurationImpl(ServiceLocatorImpl locator)
          Created by the generator, and hence must be public
 
Method Summary
<T> ActiveDescriptor<T>
addActiveDescriptor(ActiveDescriptor<T> activeDescriptor)
          This allows third party systems to add reified active descriptors to the system.
<T> ActiveDescriptor<T>
addActiveDescriptor(Class<T> rawClass)
          This adds an active descriptor to the system based completely on the analysis of the given class.
 void addUnbindFilter(Filter unbindFilter)
          This filter will added to the list of filters in this Configuration that will determine which Descriptors will be removed from the system.
 ActiveDescriptor<?> bind(Descriptor key)
          This method will bind the given descriptor to this Module.
 FactoryDescriptors bind(FactoryDescriptors factoryDescriptors)
          This method will bind the descriptors found in the FactoryDescriptors.
 void commit()
          This causes the configuration to get committed.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DynamicConfigurationImpl

public DynamicConfigurationImpl(ServiceLocatorImpl locator)
Created by the generator, and hence must be public

Parameters:
locator - The locator for which this will be the configuration service
Method Detail

bind

public ActiveDescriptor<?> bind(Descriptor key)
Description copied from interface: DynamicConfiguration
This method will bind the given descriptor to this Module. If the descriptor given is not an ActiveDescriptor then a non-reified ActiveDescriptor will be returned with the system provided fields set. If the descriptor given is a reified ActiveDescriptor then the descriptor returned will be a reified ActiveDescriptor that takes all values except for the id from the given descriptor

Specified by:
bind in interface DynamicConfiguration
Parameters:
key - May not be null. Will be used to derive the various key fields associated with the given provider
Returns:
The entry as added to the service registry, with fields of the Descriptor filled in by the system as appropriate

bind

public FactoryDescriptors bind(FactoryDescriptors factoryDescriptors)
Description copied from interface: DynamicConfiguration
This method will bind the descriptors found in the FactoryDescriptors. This method will first validate the descriptors from the FactoryDescriptors and then simply bind them into this configuration as two independent descriptors.

Specified by:
bind in interface DynamicConfiguration
Parameters:
factoryDescriptors - A description of a factory service and the type the factory service provides. May not be null
Returns:
The descriptors returned from this object may be cast to ActiveDescriptor and will contain all the fields of the descriptors filled in by the system

addActiveDescriptor

public <T> ActiveDescriptor<T> addActiveDescriptor(ActiveDescriptor<T> activeDescriptor)
                                        throws IllegalArgumentException
Description copied from interface: DynamicConfiguration
This allows third party systems to add reified active descriptors to the system. The active descriptor given must be fully reified (isReified must return true) and the create and destroy methods must be implemented.

Specified by:
addActiveDescriptor in interface DynamicConfiguration
Parameters:
activeDescriptor - The reified active descriptor to be added to the system. The system will not attempt to reify this descriptor itself
Returns:
The entry as added to the service registry, with fields of the Descriptor filled in by the system as appropriate
Throws:
IllegalArgumentException - if the descriptor is not reified

addActiveDescriptor

public <T> ActiveDescriptor<T> addActiveDescriptor(Class<T> rawClass)
                                        throws IllegalArgumentException
Description copied from interface: DynamicConfiguration
This adds an active descriptor to the system based completely on the analysis of the given class. The class itself and all interfaces marked contract will be in the list of advertised services. The scope and qualifiers will be taken from the annotations on the class.

Specified by:
addActiveDescriptor in interface DynamicConfiguration
Parameters:
rawClass - The class to analyze, must not be null
Returns:
The active (reified) descriptor that has been added to the system, with all fields filled in based on the rawClass
Throws:
IllegalArgumentException - if rawClass is null

addUnbindFilter

public void addUnbindFilter(Filter unbindFilter)
                     throws IllegalArgumentException
Description copied from interface: DynamicConfiguration
This filter will added to the list of filters in this Configuration that will determine which Descriptors will be removed from the system. Only services directly from this Configuration objects' associated ServiceLocator will be given to this Filter (it will not be given descriptors from the ServiceLocators parent). The descriptors passed into this filter may be cast to ActiveDescriptor. The descriptors passed into this filter may or may not have been reified. This filter should not reify passed in descriptors.

And descriptor for which this filter returns true will be removed from the ServiceLocator prior to any additions that are performed with this Configuration object. Hence a Configuration can remove and add a descriptor of the same type in one commit.

In order to unbind a filter the caller of commit must pass the LOOKUP validators and the UNBIND validators.

Specified by:
addUnbindFilter in interface DynamicConfiguration
Parameters:
unbindFilter - This filter will be added to the list of filters that this configuration object will use to determine which descriptors to unbind from the system. May not be null
Throws:
IllegalArgumentException - if unbindFilter is null

commit

public void commit()
            throws MultiException
Description copied from interface: DynamicConfiguration
This causes the configuration to get committed. This method may only be called once

Specified by:
commit in interface DynamicConfiguration
Throws:
MultiException - If errors were found in the commit process

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013 Oracle Corporation. All Rights Reserved.