Skip to content
Leon Rosenberg edited this page Apr 16, 2024 · 18 revisions

Annotations supported by DistributeMe


All annotations supported by DistributeMe are SOURCE type annotations, meaning that they are processed by the apt precompiler at compile time and do not influence compiled bytecode.

Overview

Annotation Target Parameter
CombinedService Class services
ConcurrencyControl Class, Method strategyClass, parameter
ConcurrencyControlClientSideLimit Class, Method value
ConcurrencyControlLimit Class, Method client, server
ConcurrencyControlServerSideLimit Class, Method value
DistributeMe Class extension, initcode, moskitoSupport, factoryClazz, enableEventService
DontRoute Method
FailBy Class, Method strategyClass, reuseRouter
Route Class, Method routerClass, routerParameter
RouteMe Class providerClass, providerParameter
SupportService Class
ServerListener Class listenerClass

Details

DistributeMe

Main annotation to mark a service (which is a java interface) as distributable. The java compiler will scan all java files during compile for DistributeMe annotation and process them with DistributeMe code generator.

Parameter  default  Description
extension Extension.LOCAL Name of the extension for MetaFactory lookup.
initcode Array of strings which is included into the generated server init method
moskitoSupport true Generate moskito support. Recommended.
factoryClazz Class that implements a factory for the interface implementation
enableEventService true Starts the embedded event service. Recommended
protocols RMI List of supported protocols for this interface.
logWriterClazz SysErrorLogWriter.class Class of LogWriter implementation.
agentsSupport true Support for mobile agents
asynchSupport false If true generate asynchronous stub for asynchronous calls.
asynchCallTimeout -1 Timeout for asynchronous calls in blocking mode. If not set (-1) the default is taken. See org.distributeme.core.Defaults.getDefaultAsynchCallTimeout().
asynchExecutorPoolSize -1 Internal Threadpool size for asynchronous calls. If not set (-1) the default is taken. See org.distributeme.core.Defaults.getAsynchExecutorPoolSize().

Example:

@DistributeMe(factoryClazz = org.distributeme.test.echo.EchoServiceFactory.class)
public interface EchoService extends Service {

DontRoute

Excludes a method from routing.

@DontRoute long unmodEcho(long parameter) throws ModedServiceException;

Route

Enables routing for the method. If applied to class enables default routing for all methods. Route annotation applied to a method overrides the Route annotation applies to the class.

@Route(routerClass=ParameterBasedModRouter.class, routerParameter="2,1")
boolean modEcho(String dummyParameter, boolean parameter) throws ModedServiceException;

FailBy

Sets the failing strategy for the class/method.

Parameter  default  Description
strategyClass An implementation of FailingStrategy which is used to determine proper reaction to server failure.
reuseRouter false If true the stub tried to reuse the router instance instead of creating new object. This is useful (and mostly needed) if router and failover is the same object.

Example:

@DistributeMe
@FailBy(strategyClass=FailCall.class)
public interface FailableService extends Service{
@FailBy(strategyClass=RetryCallOnce.class)
void retryOnceMethod();

RouteMe

Enables routing for the class.

Parameter  default  Description
providerClass Class extending RegistrationNameProvider which is used to determine registration name upon start
providerParameter Customization parameter for the RegistrationNameProvider

Example:

@DistributeMe(
        initcode={"MetaFactory.addFactoryClass(org.distributeme.test.mod.ModedService.class, Extension.LOCAL, org.distributeme.test.mod.ModedServiceFactory.class);"}
)
@RouteMe(providerClass=PropertyBasedRegistrationNameProvider.class, providerParameter="mod")
@Route(routerClass=ParameterBasedModRouter.class, routerParameter="2,0")
public interface ModedService extends Service{

SupportService

Marks an interface as support service. Support service is meant to be a helper in another service, therefore it will have no main method in the *Server.java. Useable if you want to combine multiple services into one VM and prevent someone from starting them separately. Example:

@DistributeMe(moskitoSupport=false, factoryClazz=LifecycleSupportServiceFactory.class)
@SupportService
public interface LifecycleSupportService extends LifecycleComponent,Service{

CombinedService

Indicates that the interface is a combined service, which means that it just extends a couple of services which are than run together in one vm. CombinedServices have no generated stubs or skeletons, just servers and startup scripts.

Example:

@DistributeMe
 @CombinedService(services={AdminService.class, BusinessService.class})
 public interface BusinessAndAdminService{
 //this interface is empty, its only used as a control of the generator.
 }

ConcurrencyControl

Allows to specify a custom class that will control number of concurrent requests to a service (either from client or from service). Please note, that this is the general approach, for convenience shortcut methods ConcurrencyControlLimit, ConcurrencyControlClientSideLimit and ConcurrencyControlServerSideLimit were added.

Example:

@ConcurrencyControl(strategyClass=MyConcurrencyStrategy.class, strategyParameter="foo")
void printStats();

The strategy class parameter must implement org.distributeme.core.concurrencycontrol.ConcurrencyControlStrategy interface. For convenience we recommend to extends org.distributeme.core.concurrencycontrol.AbstractConcurrencyControlStrategy class, which provides dummy implementation of all methods and override the methods you want.

ConcurrencyControlClientSideLimit

Defines a concurrency control limit on client side only. Applicable to interfaces or methods. If applied to interface, the limit is valid for all unannotated methods.

Example:

@ConcurrencyControlClientSideLimit(3)
 long clientSideLimitedMethod(long parameter);

ConcurrencyControlLimit

Defines a pair of concurrency control limits for each, client and server. Applicable to interfaces or methods. If applied to interface, the limit is valid for all unannotated methods.

Example:

@ConcurrencyControlLimit(client=4, server=5)
long bothSideLimitedMethod(long parameter);

ConcurrencyControlServerSideLimit

Defines a concurrency control limit on server side only. Applicable to interfaces or methods. If applied to interface, the limit is valid for all unannotated methods.

Example:

@ConcurrencyControlServerSideLimit(5)
long serverSideLimitedMethod(long parameter);

ServerListener

Attaches an instance of ServerLifecycleListener to the generated Server class. If you need more listeners, use configuration option in distributeme.json.

Example:

@DistributeMe()
@ServerListener(listenerClass=ServerLifecycleSysOutPrinterListener.class)
public interface EchoService extends Service {
...
}