Methods Summary |
---|
private void | configureComponent(ServerComponent component, ComponentType type, org.apache.lucene.gdata.server.registry.configuration.ComponentConfiguration configuration)
PropertyInjector injector = new PropertyInjector();
injector.setTargetObject(component);
injector.injectProperties(configuration);
|
public void | destroy()Destroys the registry and release all resources
for (ComponentBean component : this.componentMap.values()) {
component.getObject().destroy();
}
flushRegistry();
|
protected void | flushRegistry()
Collection<ProvidedService> services = this.serviceTypeMap.values();
for (ProvidedService service : services) {
service.destroy();
}
this.serviceTypeMap.clear();
this.componentMap.clear();
|
public EntryEventMediator | getEntryEventMediator()
return this;
|
public ProvidedService | getProvidedService(java.lang.String service)Looks up the {@link ProvidedServiceConfig} by the given service name.
if (service == null)
throw new IllegalArgumentException(
"Service is null - must not be null to get registered feed type");
return this.serviceTypeMap.get(service);
|
public static synchronized org.apache.lucene.gdata.server.registry.GDataServerRegistry | getRegistry()
if (INSTANCE == null)
INSTANCE = new GDataServerRegistry();
return INSTANCE;
|
public java.util.Collection | getServices()
return this.serviceTypeMap.values();
|
public boolean | isServiceRegistered(java.lang.String service)
return this.serviceTypeMap.containsKey(service);
|
public R | lookup(java.lang.Class 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);
ComponentBean bean = this.componentMap.get(compType);
if (bean == null)
return null;
if (bean.getSuperType().equals(clazz))
return (R) bean.getObject();
return null;
|
public void | registerComponent(java.lang.Class componentClass, org.apache.lucene.gdata.server.registry.configuration.ComponentConfiguration configuration)All registered {@link ServerComponent} registered via this method are
available via the
{@link GDataServerRegistry#lookup(Class, ComponentType)} method. For each
{@link 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
if (componentClass == null)
throw new IllegalArgumentException(
"component class must not be null");
if (!ReflectionUtils.implementsType(componentClass,
ServerComponent.class))
throw new RegistryException(
"can not register component. the given class does not implement ServerComponent interface -- "
+ componentClass.getName());
try {
Component annotation = componentClass
.getAnnotation(Component.class);
if (annotation == null)
throw new RegistryException(
"can not register component. the given class is not a component -- "
+ componentClass.getName());
ComponentType type = annotation.componentType();
if (this.componentMap.containsKey(type))
throw new RegistryException("component already registered -- "
+ type.name());
Class superType = type.getClass().getField(type.name())
.getAnnotation(SuperType.class).superType();
if (!ReflectionUtils.isTypeOf(componentClass, superType))
throw new RegistryException("Considered super type <"
+ superType.getName() + "> is not a super type of <"
+ componentClass + ">");
ServerComponent comp = componentClass.newInstance();
if (configuration == null) {
if (LOG.isInfoEnabled())
LOG.info("no configuration for ComponentType: "
+ type.name());
} else
configureComponent(comp, type, configuration);
comp.initialize();
ComponentBean bean = new ComponentBean(comp, superType);
this.componentMap.put(type, bean);
if (ReflectionUtils.implementsType(componentClass,
ScopeVisitor.class))
this.registerScopeVisitor((ScopeVisitor) comp);
} catch (Exception e) {
throw new RegistryException("Can not register component -- "
+ e.getMessage(), e);
}
|
public synchronized void | registerScopeVisitable(ScopeVisitable visitable)
if (visitable == null)
throw new IllegalArgumentException("visitable must not be null");
Scope scope = visitable.getClass().getAnnotation(Scope.class);
if (scope == null)
throw new RegistryException("Visitable has not Scope");
if (LOG.isInfoEnabled())
LOG.info("Register scope visitable -- " + visitable.getClass());
if (scope.scope() == Scope.ScopeType.REQUEST
&& this.requestVisitable == null)
this.requestVisitable = visitable;
else if (scope.scope() == Scope.ScopeType.SESSION
&& this.sessionVisitable == null)
this.sessionVisitable = visitable;
else if (scope.scope() == Scope.ScopeType.CONTEXT
&& this.contextVisitable == null)
this.sessionVisitable = visitable;
if (!this.visitorBuffer.isEmpty()) {
List<ScopeVisitor> tempList = this.visitorBuffer;
this.visitorBuffer = new ArrayList<ScopeVisitor>(5);
for (ScopeVisitor visitor : tempList) {
registerScopeVisitor(visitor);
}
tempList.clear();
}
|
public synchronized void | registerScopeVisitor(ScopeVisitor visitor)
if (visitor == null)
throw new IllegalArgumentException("visitor must not be null");
Scope scope = visitor.getClass().getAnnotation(Scope.class);
if (scope == null)
throw new RegistryException("Visitor has not Scope");
if (LOG.isInfoEnabled())
LOG.info("Register scope visitor -- " + visitor.getClass());
if (scope.scope().equals(Scope.ScopeType.REQUEST)
&& this.requestVisitable != null)
this.requestVisitable.accept(visitor);
else if (scope.scope() == Scope.ScopeType.SESSION
&& this.sessionVisitable != null)
this.sessionVisitable.accept(visitor);
else if (scope.scope() == Scope.ScopeType.CONTEXT
&& this.contextVisitable != null)
this.sessionVisitable.accept(visitor);
else if (!this.visitorBuffer.contains(visitor))
this.visitorBuffer.add(visitor);
|
public void | registerService(ProvidedService configurator)Registers a {@link ProvidedService}
if (configurator == null) {
LOG.warn("Feed configurator is null -- skip registration");
return;
}
this.serviceTypeMap.put(configurator.getName(), configurator);
|