Service Proxy

When you provide a class or interface to the service(..) method, Ressor will generate a special proxy class, which will extend/implement it at the runtime. For classes there are certain restrictions, which are described below.


Your class shouldn't be final. It's ok to be abstract.


If your class doesn't have an empty default constructor, Ressor has no options but to call any other available using super(..) construction, in order to create its own proxy instance. This is defined by JLS.

How constructor is selected?

It will select the mostly short and visible constructor (in terms of number of parameters and modifiers like public, protected, etc). You can also mark the desired constructor with @ProxyConstructor annotation, so it'll always be used without any search.

How constructor parameters are filled?

By default, Ressor will guess the default values and fill them. The rules are simple:

  • Instance types - null

  • Numeric types - 0

  • Boolean - false

  • Array - empty one

  • Java collection interface - empty collection

You should make sure that your constructor can accept such values and not throw an exception. Alternatively, you can provide your default values to builder:

var ressor = Ressor.create();
.proxyDefaultArguments("One", 2);

Class Loader

By default, Ressor will load its generated proxy class using the ClassLoader which it was loaded by itself. You can ask to use any other one, if you, for example, work in OSGi environment:

var ressor = Ressor.create();