Click here to load reader
Upload
pradeepfn
View
118
Download
0
Embed Size (px)
DESCRIPTION
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
Citation preview
Apache Stratos Hangout VI
RESTful API for Stratos Controller
Pradeep FernandoAssociate Technical Lead, WSO2 Inc.
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.
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
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
Implementation Classpublic 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)
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>
Stratos Controller API
- Tenant Registration
- Cartridge Subscription
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...
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
:)
CarbonContext API...
public String getTenantDomain(boolean resolve)
public int getTenantId(boolean resolve)
public Object getOSGiService(Class clazz)
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. :)
The Big Picture..
Implementation Details..
- CXF based JAX-RS webapp
- Wink based webapp.
Personally prefer CXF runtime. But open for discussion..
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
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 ?
Questions/Suggestions…