org.ijsberg.iglu.configuration.module
Class StandardComponent

java.lang.Object
  extended by org.ijsberg.iglu.configuration.module.StandardComponent
All Implemented Interfaces:
InvocationHandler, Component

public class StandardComponent
extends Object
implements Component, InvocationHandler

Standard implementation of Component.


Field Summary
static String PROPERTIES_PROPERTY_KEY
           
static String REGISTER_LISTENER_METHOD_NAME
           
static String UNREGISTER_LISTENER_METHOD_NAME
           
 
Constructor Summary
StandardComponent(Object implementation)
           
 
Method Summary
 Set<Class<?>> getInjectedInterfaces(String componentId)
           
 Class<?>[] getInterfaces()
           
 Properties getProperties()
           
 Object getProxy(Class<?> interfaceClass)
           
 Properties getSetterInjectedProperties()
           
 Object invoke(Object proxy, Method method, Object[] parameters)
           
 Object invoke(String methodName, Object... parameters)
           
static String makeFirstCharUpperCase(String varName)
           
 void register(Component component)
          Registers a component (as listener) in case the embedded object implements a method named 'register' with a suiting interface.
 void removeDependency(String componentId)
          Removes previously injected proxies for a certain component.
 void setInvocationIntercepter(Class<?> interfaceClass, InvocationHandler handler)
          Sets intercepter for invocations of a particular interface to deal with cross-cutting concerns.
 void setProperties(Properties properties)
          Injects properties into the embedded object.
 void setReference(Facade facade, String componentId, Class<?>... interfaces)
          Sets a reference to a component if the embedded class contains an appropriate setter.
 void unregister(Component component)
          Unregisters a previously registered component in case the embedded object implements a method named 'unregister' with a suitable interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTIES_PROPERTY_KEY

public static final String PROPERTIES_PROPERTY_KEY
See Also:
Constant Field Values

REGISTER_LISTENER_METHOD_NAME

public static final String REGISTER_LISTENER_METHOD_NAME
See Also:
Constant Field Values

UNREGISTER_LISTENER_METHOD_NAME

public static final String UNREGISTER_LISTENER_METHOD_NAME
See Also:
Constant Field Values
Constructor Detail

StandardComponent

public StandardComponent(Object implementation)
Method Detail

setReference

public void setReference(Facade facade,
                         String componentId,
                         Class<?>... interfaces)
Description copied from interface: Component
Sets a reference to a component if the embedded class contains an appropriate setter. (Also known as dependency injection.) The component may actually have references for every exposed interface. This method must also be used to update references in case the exposure of interfaces changes.

Specified by:
setReference in interface Component
Parameters:
facade - facade that must expose a component with id componentId and given interfaces
componentId - ID of the component
interfaces - the interfaces the component exposes
Throws:
NullPointerException - if the cluster does not expose a component with ID componentId

removeDependency

public void removeDependency(String componentId)
Description copied from interface: Component
Removes previously injected proxies for a certain component.

Specified by:
removeDependency in interface Component
Parameters:
componentId -

register

public void register(Component component)
Description copied from interface: Component
Registers a component (as listener) in case the embedded object implements a method named 'register' with a suiting interface.

Specified by:
register in interface Component
Parameters:
component -

unregister

public void unregister(Component component)
Description copied from interface: Component
Unregisters a previously registered component in case the embedded object implements a method named 'unregister' with a suitable interface.

Specified by:
unregister in interface Component

getProxy

public Object getProxy(Class<?> interfaceClass)
Specified by:
getProxy in interface Component
Returns:
a proxy for the wrapped object implementing the given interface

getInterfaces

public Class<?>[] getInterfaces()
Specified by:
getInterfaces in interface Component
Returns:
classes of interfaces implemented by the wrapped object

setProperties

public void setProperties(Properties properties)
Description copied from interface: Component
Injects properties into the embedded object.

Specified by:
setProperties in interface Component

getProperties

public Properties getProperties()
Specified by:
getProperties in interface Component
Returns:
previously set properties

getSetterInjectedProperties

public Properties getSetterInjectedProperties()
Returns:
properties that have actually been injected by setter

makeFirstCharUpperCase

public static String makeFirstCharUpperCase(String varName)

setInvocationIntercepter

public void setInvocationIntercepter(Class<?> interfaceClass,
                                     InvocationHandler handler)
Description copied from interface: Component
Sets intercepter for invocations of a particular interface to deal with cross-cutting concerns.

Specified by:
setInvocationIntercepter in interface Component
Parameters:
interfaceClass - interface of which invocations must be intercepted

invoke

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

invoke

public Object invoke(String methodName,
                     Object... parameters)
              throws InvocationTargetException,
                     NoSuchMethodException,
                     IllegalArgumentException
Specified by:
invoke in interface Component
Parameters:
methodName - name of a method declared by a component's interface
Returns:
Throws:
InvocationTargetException - in case the invoked method throws
NoSuchMethodException - in case no suitable method is found
IllegalArgumentException - in case the arguments can not be converted

getInjectedInterfaces

public Set<Class<?>> getInjectedInterfaces(String componentId)
Specified by:
getInjectedInterfaces in interface Component
Returns:
a set of classes of interfaces that have been injected by setter


Copyright © 2011. All Rights Reserved.