org.apache.hivemind.impl
Class ServicePointImpl

java.lang.Object
  |
  +--org.apache.hivemind.impl.BaseLocatable
        |
        +--org.apache.hivemind.impl.AbstractExtensionPoint
              |
              +--org.apache.hivemind.impl.ServicePointImpl
All Implemented Interfaces:
ConstructableServicePoint, ExtensionPoint, Locatable, LocationHolder, ServicePoint

public final class ServicePointImpl
extends AbstractExtensionPoint
implements ConstructableServicePoint

Abstract implementation of ServicePoint. Provides some of the machinery for creating new service instances, delegating most of it to the ServiceModelinstace for the service.

Author:
Howard Lewis Ship

Constructor Summary
ServicePointImpl()
           
 
Method Summary
 void addInterceptorContribution(ServiceInterceptorContribution contribution)
           
 void clearConstructorInformation()
          Invoked by the ServiceModel when constuction information (the builder and interceptors) is no longer needed.
protected  void extendDescription(ToStringBuilder builder)
          Implemented in subclasses to provide details about subclass properties.
 void forceServiceInstantiation()
          Forces the service into existence.
 java.util.List getOrderedInterceptorContributions()
          Returns a list of org.apache.hivemind.ServiceInterceptorContributions, ordered according to their dependencies.
 Occurances getParametersCount()
          Returns the number of parameter object expected; generally this is the default of exactly one ( Occurances.REQUIRED).
 Schema getParametersSchema()
          Returns the Schemaused to process any parameters passed to the service.
 java.lang.Object getService(java.lang.Class serviceInterface)
          Obtains the full service implementation for this service extension point, an object that implements the service interface.
 ServiceImplementationConstructor getServiceConstructor()
          Returns the service constructor, if defined, or the default service constructor.
 ServiceImplementationConstructor getServiceConstructor(boolean defaultConstructor)
           
 java.lang.Class getServiceInterface()
          Returns the type of the service, the interface the service implements.
 java.lang.String getServiceInterfaceClassName()
          Returns the fully qualified class name of the service interface.
 java.lang.String getServiceModel()
           
 ShutdownCoordinator getShutdownCoordinator()
          Returns the ShutdownCooordinator, used by the service model to inform proxies that the service has shutdown.
 void setParametersCount(Occurances occurances)
           
 void setParametersSchema(Schema schema)
           
 void setServiceConstructor(ServiceImplementationConstructor contribution, boolean defaultConstructor)
           
 void setServiceInterfaceName(java.lang.String string)
           
 void setServiceModel(java.lang.String model)
           
 void setShutdownCoordinator(ShutdownCoordinator coordinator)
           
 
Methods inherited from class org.apache.hivemind.impl.AbstractExtensionPoint
getErrorLog, getExtensionPointId, getLog, getModule, setExtensionPointId, setModule, setVisibility, toString, visibleToModule
 
Methods inherited from class org.apache.hivemind.impl.BaseLocatable
getLocation, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.hivemind.internal.ExtensionPoint
getErrorLog, getExtensionPointId, getLog, getModule, visibleToModule
 
Methods inherited from interface org.apache.hivemind.Locatable
getLocation
 

Constructor Detail

ServicePointImpl

public ServicePointImpl()
Method Detail

extendDescription

protected void extendDescription(ToStringBuilder builder)
Description copied from class: AbstractExtensionPoint
Implemented in subclasses to provide details about subclass properties.

Specified by:
extendDescription in class AbstractExtensionPoint

addInterceptorContribution

public void addInterceptorContribution(ServiceInterceptorContribution contribution)

getServiceInterface

public java.lang.Class getServiceInterface()
Description copied from interface: ServicePoint
Returns the type of the service, the interface the service implements.

Specified by:
getServiceInterface in interface ServicePoint

getServiceInterfaceClassName

public java.lang.String getServiceInterfaceClassName()
Description copied from interface: ServicePoint
Returns the fully qualified class name of the service interface. This is useful so that loading the actual service interface class can be deferred as late as possible.

Specified by:
getServiceInterfaceClassName in interface ServicePoint
Since:
1.1

setServiceConstructor

public void setServiceConstructor(ServiceImplementationConstructor contribution,
                                  boolean defaultConstructor)

setServiceInterfaceName

public void setServiceInterfaceName(java.lang.String string)

setParametersSchema

public void setParametersSchema(Schema schema)

getParametersSchema

public Schema getParametersSchema()
Description copied from interface: ServicePoint
Returns the Schemaused to process any parameters passed to the service. Service implementation factories and service interceptor factories allow parameters.

Specified by:
getParametersSchema in interface ServicePoint

getServiceConstructor

public ServiceImplementationConstructor getServiceConstructor(boolean defaultConstructor)

getService

public java.lang.Object getService(java.lang.Class serviceInterface)
Description copied from interface: ServicePoint
Obtains the full service implementation for this service extension point, an object that implements the service interface. Because of the different service models, and because of the possibility of interceptors, the exact class and object returned can't be specified (and may vary at different times), but that is not relevant to client code, which is assured that it can invoke the service methods defined by the service interface.

Specified by:
getService in interface ServicePoint
Parameters:
serviceInterface - the class that the service will be cast to; a check is made that the service is assignable to the indicated interface. It does not have to, necessarily, match the service interface (it could be a super-interface, for example).
Returns:
the outermost interceptor for the service, or the core implementation if there are no interceptors.

getServiceModel

public java.lang.String getServiceModel()

setServiceModel

public void setServiceModel(java.lang.String model)

clearConstructorInformation

public void clearConstructorInformation()
Description copied from interface: ConstructableServicePoint
Invoked by the ServiceModel when constuction information (the builder and interceptors) is no longer needed.

Specified by:
clearConstructorInformation in interface ConstructableServicePoint

getOrderedInterceptorContributions

public java.util.List getOrderedInterceptorContributions()
Description copied from interface: ConstructableServicePoint
Returns a list of org.apache.hivemind.ServiceInterceptorContributions, ordered according to their dependencies. May return null or an empty list.

Note that the order is tricky! To keep any error messages while ordering the interceptors understandable, they are ordered according into runtime execution order. Example: If we want a logging interceptor to operate before a security-check interceptor, we'll write the following in the descriptor:

 
  
     <interceptor service-id="hivemind.LoggingInterceptor" before="*"/>
     <interceptor service-id="somepackage.SecurityInterceptor"/>
   
  
 
The before value for the first interceptor contribution will be assigned to the contribution's followingInterceptorIds property, because all other interceptors (including the security interceptor) should have their behavior follow the logging interceptor.

To get this behavior, the logging interceptor will delegate to the security interceptor, and the security interceptor will delegate to the core service implementation.

The trick is that interceptors are applied in reverse order: we start with core service implementation, wrap it with the security interceptor, then wrap that with the logging interceptor ... but that's an issue that applies when building the interceptor stack around the core service implementation.

Specified by:
getOrderedInterceptorContributions in interface ConstructableServicePoint

getShutdownCoordinator

public ShutdownCoordinator getShutdownCoordinator()
Description copied from interface: ConstructableServicePoint
Returns the ShutdownCooordinator, used by the service model to inform proxies that the service has shutdown.

Specified by:
getShutdownCoordinator in interface ConstructableServicePoint

setShutdownCoordinator

public void setShutdownCoordinator(ShutdownCoordinator coordinator)

forceServiceInstantiation

public void forceServiceInstantiation()
Forces the service into existence.

Specified by:
forceServiceInstantiation in interface ServicePoint

getParametersCount

public Occurances getParametersCount()
Description copied from interface: ServicePoint
Returns the number of parameter object expected; generally this is the default of exactly one ( Occurances.REQUIRED).

Specified by:
getParametersCount in interface ServicePoint

setParametersCount

public void setParametersCount(Occurances occurances)

getServiceConstructor

public ServiceImplementationConstructor getServiceConstructor()
Returns the service constructor, if defined, or the default service constructor. The default service constructor comes from the <service-point> itself; other modules can override this default using an <implementation> element.

Specified by:
getServiceConstructor in interface ConstructableServicePoint