I am unable to use the pluginsettingsfactory and unable to initialise the pluginsettingsfactory variable in the rest module.
Hello,
Could you provide your code?
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" );
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Named
public 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" );
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tried the above but no luck.
Error :- variable pluginSettingsFactory might not have been initialized
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am trying to pass the values from the MyRestResource to the MyRestResourceModel
and as described in the tutorials I have made use of the first constructor for the plugin settings factory.
can you please help me get to the correct way?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.