org.apache.lucene.gdata.server.registry
Class GDataServerRegistry

java.lang.Object
  extended by org.apache.lucene.gdata.server.registry.EntryEventMediator
      extended by org.apache.lucene.gdata.server.registry.GDataServerRegistry

public class GDataServerRegistry
extends EntryEventMediator

The GDataServerRegistry represents the registry component of the GData Server. All provided services and server components will be registered here. The GData Server serves RSS / ATOM feeds for defined services. Each service provides n feeds of a defined subclass of BaseFeed. Each feed contains m entries of a defined subclass of BaseEntry. To generate RSS / ATOM formates a class of the type ExtensionProfile is also defined for a service.

The entry,feed and the ExtensionProfile classes are defined in the gdata-config.xml and will be loaded when the server starts up.

The components defined in the gdata-config.xml will also be loaded and instantiated at startup. If a component can not be loaded or an Exception occurs the server will not start up. To cause of the exception or error will be logged to the standard server output.

The GDataServerRegistry is a Singleton

Author:
Simon Willnauer

Method Summary
 void destroy()
          Destroys the registry and release all resources
protected  void flushRegistry()
           
 EntryEventMediator getEntryEventMediator()
           
 ProvidedService getProvidedService(String service)
          Looks up the ProvidedServiceConfig by the given service name.
static GDataServerRegistry getRegistry()
           
 Collection<ProvidedService> getServices()
           
 boolean isServiceRegistered(String service)
           
<R> R
lookup(Class<R> clazz, ComponentType compType)
          This method is the main interface to the Component Lookup Service of the registry.
<E extends ServerComponent>
void
registerComponent(Class<E> componentClass, ComponentConfiguration configuration)
          All registered ServerComponent registered via this method are available via the lookup(Class, ComponentType) method.
 void registerScopeVisitable(ScopeVisitable visitable)
           
 void registerScopeVisitor(ScopeVisitor visitor)
           
 void registerService(ProvidedService configurator)
          Registers a ProvidedService
 
Methods inherited from class org.apache.lucene.gdata.server.registry.EntryEventMediator
allEntriesDeleted, entryAdded, entryDeleted, entryUpdated, isListenerRegistered, registerEntryEventListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRegistry

public static GDataServerRegistry getRegistry()
Returns:
a Singleton registry instance

registerService

public void registerService(ProvidedService configurator)
Registers a ProvidedService

Parameters:
configurator - - the configurator to register in the registry

registerScopeVisitor

public void registerScopeVisitor(ScopeVisitor visitor)
                          throws RegistryException
Parameters:
visitor - - the visitor to register
Throws:
RegistryException

registerScopeVisitable

public void registerScopeVisitable(ScopeVisitable visitable)
                            throws RegistryException
Parameters:
visitable - - the instance to register
Throws:
RegistryException
See Also:
ScopeVisitable

getProvidedService

public ProvidedService getProvidedService(String service)
Looks up the ProvidedServiceConfig by the given service name.

Parameters:
service -
Returns:
- the ProvidedServiceConfig or null if the no configuration for this service has been registered

flushRegistry

protected void flushRegistry()

isServiceRegistered

public boolean isServiceRegistered(String service)
Parameters:
service - - the name of the service
Returns:
- true if and only if the service is registered, otherwise false.

destroy

public void destroy()
Destroys the registry and release all resources


lookup

public <R> R lookup(Class<R> clazz,
                    ComponentType compType)
This method is the main interface to the Component Lookup Service of the registry. Every GDATA - Server component like STORAGE or the INDEXER component will be accessible via this method. To get a Component from the lookup service specify the expected Class as an argument and the component type of the component to return. For a lookup of the STORAGECONTORLER the code looks like:

registryInstance.lookup(StorageController.class,ComponentType.STORAGECONTROLLER);

Type Parameters:
R - the type of the expected return value
Parameters:
clazz - - Class object of the expected return value
compType - - The component type
Returns:
the registered component or null if the component can not looked up.

registerComponent

public <E extends ServerComponent> void registerComponent(Class<E> componentClass,
                                                          ComponentConfiguration configuration)
                       throws RegistryException
All registered ServerComponent registered via this method are available via the lookup(Class, ComponentType) method. For each ComponentType there will be one single instance registered in the registry.

Eventually this method invokes the initialize method of the ServerComponent interface to prepare the component to be available via the lookup service

Type Parameters:
E - - The interface of the component to register
Parameters:
componentClass - - a implementation of a ServerComponent interface to register in the registry
configuration - - the component configuration ComponentConfiguration
Throws:
RegistryException - - if the provided class does not implement the ServerComponent interface, if the mandatory annotations not visible at runtime or not set, if the super type provided by the ComponentType for the class to register is not a super type of the class or if the invocation of the ServerComponent.initialize() method throws an exception.

getEntryEventMediator

public EntryEventMediator getEntryEventMediator()
Specified by:
getEntryEventMediator in class EntryEventMediator
Returns:
- a entry event mediator instance
See Also:
EntryEventMediator.getEntryEventMediator()

getServices

public Collection<ProvidedService> getServices()
Returns:
- all registered services


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.