Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Communications Framework (ECF) » @InjectLink(I can not get the link @InjectLink)
@InjectLink [message #1820538] Wed, 22 January 2020 11:15 Go to next message
Gennadii Vakulenko is currently offline Gennadii VakulenkoFriend
Messages: 2
Registered: January 2020
Junior Member

Hello dear forum users. I apologize if I write off topic and not here.

I have a question about Jersey, namely @InjectLink annotations - Declarative Hyperlinking eclipse-ee4j.github.io/jersey.github.io/documentation/latest/declarative-linking.html

I can't do it, and I ask for your help.
I have two classes, as shown here eclipse-ee4j.github.io/jersey.github.io/documentation/latest/declarative-linking.html#d0e10567
Class WidgetsResource

import javax.ws.rs.GET;
import javax.ws.rs.Path;

@Path("/widgets")
public class WidgetsResource {

    @GET
    public Widgets get() {
        return new Widgets();
    }
}


and class widgets

import org.glassfish.jersey.linking.InjectLink;
import java.net.URI;

public class Widgets {

    @InjectLink(resource=WidgetsResource.class)
    URI u;

    public Widgets() {
        System.out.println(this.u);
    }
}


If I understand correctly, then in the Widgets class in the field URI u there should be a link

import org.glassfish.jersey.linking.InjectLink;
import java.net.URI;

public class Widgets {

    @InjectLink(resource=WidgetsResource.class)
    URI u;

    public Widgets() {
        System.out.println(this.u);
    }
}


Where /context is the application deployment context.
But for some reason, there is nothing there. It returns NULL to me.
Please tell me what am I doing wrong?
  • Attachment: jersey.png
    (Size: 49.75KB, Downloaded 47 times)
Re: @InjectLink [message #1821061 is a reply to message #1820538] Wed, 05 February 2020 04:08 Go to previous message
Scott Lewis is currently offline Scott LewisFriend
Messages: 1038
Registered: July 2009
Senior Member
Hi Gennadii,

It appears to me that the example above is from here:

https://docs.huihoo.com/jersey/2.13/declarative-linking.html

In the docs above, there is this:

12.7. Configure and register
In order to add the Declarative Linking feature register DeclarativeLinkingFeature

Example 12.1. Creating JAX-RS application with Declarative Linking feature enabled.

// Create JAX-RS application.
final Application application = new ResourceConfig()
.packages("org.glassfish.jersey.examples.linking")
.register(DeclarativeLinkingFeature.class);

[Scott] From the above, it looks as if it's necessary to register the DeclarativeLinkingFeature to activate this function of Jersey.

With ECF remote services, much of this configuration of Jersey is done automatically within the remote services exporter (i.e. the Jersey server distribution provider).

The parent project for both the Jersey and CXF distribution providers are here:

https://github.com/ECF/JaxRSProviders

This is the project for the Jersey server distribution provider:

https://github.com/ECF/JaxRSProviders/tree/master/bundles/org.eclipse.ecf.provider.jersey.server

Essentially what's needed for the ECF jersey server distribution to support DeclarativeLinkingFeature is to register that feature at runtime

For example, in this file is a method: createConfigurable()

https://github.com/ECF/JaxRSProviders/blob/master/bundles/org.eclipse.ecf.provider.jersey.server/src/org/eclipse/ecf/provider/jersey/server/JerseyServerDistributionProvider.java#L71

protected Configurable createConfigurable() {
return new ResourceConfig();
}

This method could be enhanced to registre the DeclarativeLinkingFeature like this:

protected Configurable createConfigurable() {
return new ResourceConfig().register(DeclarativeLinkingFeature.class);
}

Currently, however, the distribution provider does not include the Jersey bundle that has the DeclarativeLinkingFeature classes.. That bundle is at maven central:

https://search.maven.org/artifact/org.glassfish.jersey.ext/jersey-declarative-linking/2.29.1/jar

But this jersey extension library/bundle is currently *not* included in the ECF jersey server distribution provider as of this released version:

https://github.com/ECF/JaxRSProviders/releases/tag/1.12.0

I would consider adding support for the DeclarativeLinkingFeature (and perhaps others if desired), but might not be able to happen immediately.

If you would like work on this yourself or request that I put support for DeclarativeLinkingFeature in the ECF jersey server distribution provider, please open an issue here:

https://github.com/ECF/JaxRSProviders/issues

or contact me directly at scottlsewis at gmail.com and reference this forum entry directly.

Thanks,

Scott
Previous Topic:@InjectLink
Goto Forum:
  


Current Time: Sat Nov 28 17:51:04 GMT 2020

Powered by FUDForum. Page generated in 0.02081 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top