| 
| @InjectLink [message #1820539] | Wed, 22 January 2020 06:16  |  | 
| Eclipse User  |  |  |  |  | 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?
 |  |  |  | 
| 
| Re: @InjectLink [message #1820620 is a reply to message #1820539] | Thu, 23 January 2020 17:11  |  | 
| Eclipse User  |  |  |  |  | Gennadii Vakulenko wrote on Wed, 22 January 2020 06:16 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?
 
 Hi Gennadii,
 
 It appears to me that the example above is from here:
 
 https://docs.huihoo.com/jersey/2.13/declarative-linking.html
 
 In these docs 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
 
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.03904 seconds