org.krakenapps.filter.impl
Class DefaultFilterManager

java.lang.Object
  extended by org.krakenapps.filter.impl.DefaultFilterManager
All Implemented Interfaces:
FilterManager

public class DefaultFilterManager
extends java.lang.Object
implements FilterManager

This class provides default implementation for the FilterManager interface.

Since:
1.0.0
Author:
xeraph

Constructor Summary
DefaultFilterManager(org.osgi.framework.BundleContext context)
           
 
Method Summary
 void bindFilter(java.lang.String fromFilterId, java.lang.String toFilterId)
          Binds two filters.
 Filter getFilter(java.lang.String filterId)
          Returns the filter
 java.util.List<java.lang.String> getFilterFactoryNames()
          Returns a list of filter factory type name.
 java.util.List<ComponentDescription> getFilterInstanceDescriptions()
          Returns a list of all filter instance descriptions.
 Filter[] getInputFilters(java.lang.String filterId)
          Returns all bound input filters.
 Filter[] getOutputFilters(java.lang.String filterId)
          Returns all bound output filters.
 java.lang.Object getProperty(java.lang.String filterId, java.lang.String key)
          Returns the value of the property.
 java.util.Set<java.lang.String> getPropertyKeys(java.lang.String filterId)
          Returns a Set of property keys
 void loadFilter(int filterTypeIndex, java.lang.String filterId)
          Loads a filter using filter factory index.
 void loadFilter(java.lang.String factoryName, java.lang.String filterId)
          Loads a filter using the filter factory name.
 void registerFilter(FilterHandler filterHandler, java.lang.String filterId, Filter filter)
          Register the filter with filter id and handler.
 void runFilter(java.lang.String filterId, long period)
          Starts an ActiveFilter thread with specified milliseconds interval.
 void setProperty(java.lang.String filterId, java.lang.String key, java.lang.String value)
          Sets the property.
 void stopFilter(java.lang.String filterId)
          Stops the active filter.
 void subscribeFilterEvent(FilterEventListener listener)
          Subscribes filter events.
 void unbindFilter(java.lang.String fromFilterId, java.lang.String toFilterId)
          Unbind filters.
 void unloadFilter(java.lang.String filterId)
          Unloads the filter.
 void unregisterFilter(java.lang.String filterId)
          Unregister the filter.
 void unsetProperty(java.lang.String filterId, java.lang.String key)
          Removes the property.
 void unsubscribeFilterEvent(FilterEventListener listener)
          Unsubscribes filter events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFilterManager

public DefaultFilterManager(org.osgi.framework.BundleContext context)
Method Detail

loadFilter

public void loadFilter(int filterTypeIndex,
                       java.lang.String filterId)
                throws FilterFactoryNotFoundException,
                       DuplicatedFilterNameException
Description copied from interface: FilterManager
Loads a filter using filter factory index.

Specified by:
loadFilter in interface FilterManager
Parameters:
filterTypeIndex - the filter factory index which is listed before.
filterId - the filter id
Throws:
FilterFactoryNotFoundException - if filter factory is not found
DuplicatedFilterNameException - if filter id is duplicated

loadFilter

public void loadFilter(java.lang.String factoryName,
                       java.lang.String filterId)
                throws FilterFactoryNotFoundException,
                       DuplicatedFilterNameException
Description copied from interface: FilterManager
Loads a filter using the filter factory name.

Specified by:
loadFilter in interface FilterManager
Parameters:
factoryName - the filter factory name
filterId - the filter id
Throws:
FilterFactoryNotFoundException - if filter factory is not found
DuplicatedFilterNameException - if filter id is duplicated

unloadFilter

public void unloadFilter(java.lang.String filterId)
                  throws FilterNotFoundException
Description copied from interface: FilterManager
Unloads the filter.

Specified by:
unloadFilter in interface FilterManager
Parameters:
filterId - the filter id
Throws:
FilterNotFoundException - if filter is not found

runFilter

public void runFilter(java.lang.String filterId,
                      long period)
               throws FilterNotFoundException,
                      java.lang.IllegalThreadStateException
Description copied from interface: FilterManager
Starts an ActiveFilter thread with specified milliseconds interval.

Specified by:
runFilter in interface FilterManager
Parameters:
filterId - the ActiveFilter id
period - the sleep interval in milliseconds
Throws:
FilterNotFoundException - if active filter is not found
java.lang.IllegalThreadStateException - if active filter is already running

stopFilter

public void stopFilter(java.lang.String filterId)
                throws FilterNotFoundException
Description copied from interface: FilterManager
Stops the active filter.

Specified by:
stopFilter in interface FilterManager
Parameters:
filterId - the ActiveFilter id
Throws:
FilterNotFoundException - if active filter is not found

registerFilter

public void registerFilter(FilterHandler filterHandler,
                           java.lang.String filterId,
                           Filter filter)
Description copied from interface: FilterManager
Register the filter with filter id and handler. Can be used as sub-routine of loadFilter. Invoked from FilterHandler.

Specified by:
registerFilter in interface FilterManager
Parameters:
filterHandler - the filter handler
filterId - the filter id
filter - the filter

unregisterFilter

public void unregisterFilter(java.lang.String filterId)
Description copied from interface: FilterManager
Unregister the filter. Can be used as sub-routine of unloadFilter. Invoked from FilterHandler.

Specified by:
unregisterFilter in interface FilterManager
Parameters:
filterId - the filter id

getFilterFactoryNames

public java.util.List<java.lang.String> getFilterFactoryNames()
Description copied from interface: FilterManager
Returns a list of filter factory type name.

Specified by:
getFilterFactoryNames in interface FilterManager

getFilterInstanceDescriptions

public java.util.List<ComponentDescription> getFilterInstanceDescriptions()
Description copied from interface: FilterManager
Returns a list of all filter instance descriptions.

Specified by:
getFilterInstanceDescriptions in interface FilterManager

bindFilter

public void bindFilter(java.lang.String fromFilterId,
                       java.lang.String toFilterId)
                throws FilterNotFoundException,
                       AlreadyBoundException,
                       MessageSpecMismatchException
Description copied from interface: FilterManager
Binds two filters.

Specified by:
bindFilter in interface FilterManager
Parameters:
fromFilterId - the source filter id
toFilterId - the destination filter id
Throws:
FilterNotFoundException - if source or destination filter is not found
AlreadyBoundException - if filters are already bound
MessageSpecMismatchException - if source filter's message specification and destinatino filter's message specification is not matched.

unbindFilter

public void unbindFilter(java.lang.String fromFilterId,
                         java.lang.String toFilterId)
                  throws FilterNotFoundException,
                         FilterNotBoundException
Description copied from interface: FilterManager
Unbind filters.

Specified by:
unbindFilter in interface FilterManager
Parameters:
fromFilterId - the source filter id
toFilterId - the destination filter id
Throws:
FilterNotFoundException - if source or destination filter is not found
FilterNotBoundException - if filters are not bound

getInputFilters

public Filter[] getInputFilters(java.lang.String filterId)
Description copied from interface: FilterManager
Returns all bound input filters.

Specified by:
getInputFilters in interface FilterManager
Parameters:
filterId - the filter id
Returns:
all bound input filters. empty array if input filter does not exists

getOutputFilters

public Filter[] getOutputFilters(java.lang.String filterId)
Description copied from interface: FilterManager
Returns all bound output filters.

Specified by:
getOutputFilters in interface FilterManager
Parameters:
filterId - the filter id
Returns:
all bound output filters. empty array if output filter does not exists

getProperty

public java.lang.Object getProperty(java.lang.String filterId,
                                    java.lang.String key)
                             throws FilterNotFoundException
Description copied from interface: FilterManager
Returns the value of the property.

Specified by:
getProperty in interface FilterManager
Parameters:
filterId - the filter id
key - the key of property
Returns:
the property value
Throws:
FilterNotFoundException - if filter is not found

getPropertyKeys

public java.util.Set<java.lang.String> getPropertyKeys(java.lang.String filterId)
                                                throws FilterNotFoundException
Description copied from interface: FilterManager
Returns a Set of property keys

Specified by:
getPropertyKeys in interface FilterManager
Parameters:
filterId - the filter id
Returns:
a Set of property keys
Throws:
FilterNotFoundException - if filter is not found

setProperty

public void setProperty(java.lang.String filterId,
                        java.lang.String key,
                        java.lang.String value)
                 throws FilterNotFoundException
Description copied from interface: FilterManager
Sets the property.

Specified by:
setProperty in interface FilterManager
Parameters:
filterId - the filter id
key - the key of property
value - the value of property
Throws:
FilterNotFoundException - if filter is not found

unsetProperty

public void unsetProperty(java.lang.String filterId,
                          java.lang.String key)
                   throws FilterNotFoundException
Description copied from interface: FilterManager
Removes the property.

Specified by:
unsetProperty in interface FilterManager
Parameters:
filterId - the filter id
key - the key of property
Throws:
FilterNotFoundException - if filter is not found

getFilter

public Filter getFilter(java.lang.String filterId)
Description copied from interface: FilterManager
Returns the filter

Specified by:
getFilter in interface FilterManager
Parameters:
filterId - the filter id
Returns:
the filter. returns null if not exists.

subscribeFilterEvent

public void subscribeFilterEvent(FilterEventListener listener)
Description copied from interface: FilterManager
Subscribes filter events.

Specified by:
subscribeFilterEvent in interface FilterManager
Parameters:
listener - the filter event listener

unsubscribeFilterEvent

public void unsubscribeFilterEvent(FilterEventListener listener)
Description copied from interface: FilterManager
Unsubscribes filter events.

Specified by:
unsubscribeFilterEvent in interface FilterManager
Parameters:
listener - the filter event listener


Copyright © 2008-2009 Kraken Project. All Rights Reserved.