I am unable to use the pluginsettingsfactory and unable to initialise the pluginsettingsfactory variable in the rest module.
Hello,
Could you provide your code?
@Alexey Matveev
MyRestResource.java
@Path("/message")public class MyRestResource {@GET @AnonymousAllowed @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Path("/{value}/{name}") public Response getMessage(@PathParam("value") String key, @PathParam("name") String name) { return Response.ok(new MyRestResourceModel( key,name)).build(); }
MyRestResourceModel.java
public class MyRestResourceModel { static final String PLUGIN_STORAGE_KEY = "PLUGIN_KEY"; @ComponentImport final PluginSettingsFactory pluginSettingsFactory; public MyRestResourceModel(PluginSettingsFactory factory) { this.pluginSettingsFactory = factory; } public MyRestResourceModel(String message, String name) { this.message = message; this.name = name; PluginSettings settings = pluginSettingsFactory.createGlobalSettings(); String username = (String) settings.get( PLUGIN_STORAGE_KEY + ".name" ); String password = (String) settings.get( PLUGIN_STORAGE_KEY + ".age" ); }}
@Namedpublic class MyRestResourceModel { static final String PLUGIN_STORAGE_KEY = "PLUGIN_KEY"; @ComponentImport final PluginSettingsFactory pluginSettingsFactory; @Inject public MyRestResourceModel(PluginSettingsFactory factory) { this.pluginSettingsFactory = factory; } public MyRestResourceModel(String message, String name) { this.message = message; this.name = name; PluginSettings settings = pluginSettingsFactory.createGlobalSettings(); String username = (String) settings.get( PLUGIN_STORAGE_KEY + ".name" ); String password = (String) settings.get( PLUGIN_STORAGE_KEY + ".age" ); }}
Tried the above but no luck.
Error :- variable pluginSettingsFactory might not have been initialized
I just read your code. I do not understand what you mean by your code. Your code is broken. You assign to this.message but where is the variable defined? Why would you include constructor to constructor?
It looks like you're new here. Sign in or register to get started.