Apache Stratos Hangout VI


Published on

Presentation slides used duing Apache Stratos Hangout-VI. The Slides explain, how we can design a RESTful API layer for Stratos admin operations. Talks about, #REST #Carbon #Stratos #CXF #OSGi

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Apache Stratos Hangout VI

  1. 1. Apache Stratos Hangout VI RESTful API for Stratos Controller Pradeep Fernando Associate Technical Lead, WSO2 Inc.
  2. 2. Outline ● Carbon admin services and how frontend components interacts with them ● Stratos controller API (existing) and its UI components. ● What it takes to deploy a web-app in Carbon kernel ● Accessing core OSGi services by means of CarbonContext API ● JAX-RS web-app exposing admin services of Stratos - big picture ● How Custom web-app frontend/command line tooling can interact with the deployed REST apis.
  3. 3. Carbon Admin Services - The component which hosts JSP frontends are known as frontend component - Backend engine exposes the API via WS Carbon Backend Component - OSGi services Web-Services Interface FrontEnd Component
  4. 4. Implementation Class and a Descriptor File - There is an implementation class A.K.A. web- service wrapper class. - Its defined in a metafile called services.xml
  5. 5. Implementation Class public class RepositoryAdminService { /** * Use this method to add a P2 repository to the system. * * @param location of the repository to be added * @param nickName of the repository to be added * @return true only if the operation is successful * @throws AxisFault if an exception occurs while adding the repository */ public boolean addRepository(String location, String nickName) /** * Use this method to update an existing repository * * @param prevLocation current location of the repository * @param prevNickName current name of the repository * @param updatedLocation new location of the repository * @param updatedNickName new name of the repository * @throws AxisFault if an exception occurs while updating the repository */ public void updateRepository(String prevLocation, String prevNickName, String updatedLocation, String updatedNickName)
  6. 6. Service Meta File <service name="RepositoryAdminService" scope="transportsession"> <schema schemaNamespace="http://org.apache.axis2/xsd" elementFormDefaultQualified="true"/> <transports> <transport>https</transport> </transports> <module ref="ComponentMgtModule"/> <description> To administer all the repositories where the installable features are available. </description> <parameter name="ServiceClass">org.wso2.carbon.feature.mgt.services.prov. RepositoryAdminService</parameter>
  7. 7. Stratos Controller API - Tenant Registration - Cartridge Subscription
  8. 8. Deploying a WebApp in Carbon Kernel - Kernel packs an embedded Apache Tomcat - However there is no /webapps directory - We have to deploy our webapp programmatically. - Writing a Deployer would do...
  9. 9. Accessing Carbon Server Runtime from a Co-Hosted WebApp. - CarbonContext API allows us to access Carbon Runtime details. Carbon Server Runtime (OSGi Services) Co-Hosted WebApp :)
  10. 10. CarbonContext API... public String getTenantDomain(boolean resolve) public int getTenantId(boolean resolve) public Object getOSGiService(Class clazz)
  11. 11. RESTful API for Stratos Backend Services... - Using CarbonContext API and co-hosted external webapp, we retrieve Stratos backend services. - We can write a JAX-RS wrapper. - JAX-RS deployment model is webapp. :)
  12. 12. The Big Picture..
  13. 13. Implementation Details.. - CXF based JAX-RS webapp - Wink based webapp. Personally prefer CXF runtime. But open for discussion..
  14. 14. API Consumers... - Stratos-CLI can make use of the new API - Stratos Controller frontend can a webapp talking to the new API - The SC frontend can be hosted in a separate servlet container, or.. - Can be hosted in the same server instance
  15. 15. Securely exposing those APIs... - BasicAuth - Has to be integrated with the Carbon user-store for tenant level authentication - Multitenancy handled as well using CarbonContext APIs. - OAuth ?
  16. 16. Questions/Suggestions…