Anotheria
Documentation

Annotations

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

AnnotationTargetParameter
CombinedServiceClassservices
ConcurrencyControlClass, MethodstrategyClass, parameter
ConcurrencyControlClientSideLimitClass, Methodvalue
ConcurrencyControlLimitClass, Methodclient, server
ConcurrencyControlServerSideLimitClass, Methodvalue
DistributeMeClassextension, initcode, moskitoSupport, factoryClazz, enableEventService
DontRouteMethod
FailByClass, MethodstrategyClass, reuseRouter
RouteClass, MethodrouterClass, routerParameter
RouteMeClassproviderClass, providerParameter
SupportServiceClass
ServerListenerClasslistenerClass

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
extensionExtension.LOCALName of the extension for MetaFactory lookup.
initcodeArray of strings which is included into the generated server init method
moskitoSupporttrueGenerate moskito support. Recommended.
factoryClazzClass that implements a factory for the interface implementation
enableEventServicetrueStarts the embedded event service. Recommended
protocolsRMIList of supported protocols for this interface.
logWriterClazzSysErrorLogWriter.classClass of LogWriter implementation.
agentsSupporttrueSupport for mobile agents
asynchSupportfalseIf true generate asynchronous stub for asynchronous calls.
asynchCallTimeout-1Timeout for asynchronous calls in blocking mode. If not set (-1) the default is taken. See org.distributeme.core.Defaults.getDefaultAsynchCallTimeout().
asynchExecutorPoolSize-1Internal 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
strategyClassAn implementation of FailingStrategy which is used to determine proper reaction to server failure.
reuseRouterfalseIf 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
providerClassClass extending RegistrationNameProvider which is used to determine registration name upon start
providerParameterCustomization 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 {
...
}