16

Click here to load reader

Apache Stratos Hangout VI

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

Page 1: Apache Stratos Hangout VI

Apache Stratos Hangout VI

RESTful API for Stratos Controller

Pradeep FernandoAssociate Technical Lead, WSO2 Inc.

Page 2: Apache Stratos Hangout VI

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.

Page 3: Apache Stratos Hangout VI

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

Page 4: Apache Stratos Hangout VI

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

Page 5: Apache Stratos Hangout VI

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)

Page 6: Apache Stratos Hangout VI

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>

Page 7: Apache Stratos Hangout VI

Stratos Controller API

- Tenant Registration

- Cartridge Subscription

Page 8: Apache Stratos Hangout VI

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...

Page 9: Apache Stratos Hangout VI

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

:)

Page 10: Apache Stratos Hangout VI

CarbonContext API...

public String getTenantDomain(boolean resolve)

public int getTenantId(boolean resolve)

public Object getOSGiService(Class clazz)

Page 11: Apache Stratos Hangout VI

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. :)

Page 12: Apache Stratos Hangout VI

The Big Picture..

Page 13: Apache Stratos Hangout VI

Implementation Details..

- CXF based JAX-RS webapp

- Wink based webapp.

Personally prefer CXF runtime. But open for discussion..

Page 14: Apache Stratos Hangout VI

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

Page 15: Apache Stratos Hangout VI

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 ?

Page 16: Apache Stratos Hangout VI

Questions/Suggestions…