Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Inputs from felix console

Avatar

Level 2

this is my service="http://api.openweathermap.org/data/2.5/weather?q=London,uk&APPID=2707cfaa99b15c9d63d10a91ad164b49"

I need to provide input from the felix console and get the weather info of the location using the appID.

Following is my servlet class:

import java.io.IOException;

import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.sling.SlingServlet;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;

import com.adobe.philips.core.services.Weather;

@SlingServlet(paths="/bin/WeatherInfo/calc", metatype = true)
@Properties({
      @Property(name = "AppId", value = "2707cfaa99b15c9d63d10a91ad164b49")
      })
public class WeatherInfoServlet extends SlingSafeMethodsServlet {
    
    @Reference
    private Weather weather;
    
    public void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException
    {
        response.setContentType("application/json");
        response.getWriter().write(weather.getWeatherInfo());
    }
    

}

 

I am able to edit the value in the felix console, I need to know how to read it back in the servlet and provide input in the felix console.

1 Accepted Solution

Avatar

Correct answer by
Administrator

Hi 

Please have a look at the Adobe Helps article Scott shared [1].

To read valued, we can use OSGI configurations. OSGI configuration can be a place to input/configure the properties.

 

Some more ways to do so are: Link:- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage...

// Read property from OSGI configuration in AEM

[1] https://helpx.adobe.com/experience-manager/using/osgi_config.html

~kautuk

View solution in original post

0 Replies

Avatar

Level 10

By  this term -- I need to provide input from the felix console 

I am assuming you mean you want to know how to read OSGi configuration values

Read this article - 

https://helpx.adobe.com/experience-manager/using/osgi_config.html.

Hope this helps

Avatar

Correct answer by
Administrator

Hi 

Please have a look at the Adobe Helps article Scott shared [1].

To read valued, we can use OSGI configurations. OSGI configuration can be a place to input/configure the properties.

 

Some more ways to do so are: Link:- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage...

// Read property from OSGI configuration in AEM

[1] https://helpx.adobe.com/experience-manager/using/osgi_config.html

~kautuk