Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
HenningH
Product and Topic Expert
Product and Topic Expert
751
We have released new versions of the SAP Cloud SDK. A particular highlight is the release of the new major version 3.0.0 of the SAP Cloud SDK for Java.

In detail, the following components are now available in new versions:

In this blog post, we will walk you through the highlights of these releases. For a complete overview, visit our release notes for the Java libraries, for the JavaScript libraries, and for the continuous delivery toolkit. The release notes also include the change log of all our releases so far.
At the end of the article, you will find a set of instructions on how to update to the new versions.



Next week, we will host the second community call for the SAP Cloud SDK. This time, the topic will be SAP Cloud Platform Extension Factory. This series is open to everyone. Each monthly call features the latest news about the SAP Cloud SDK as well as deep dives into specific topics, as explained in this blog post. Register here for the next sessions in the series.






The first event of SAP TechEd 2019 is less than two months away. Now is the time to register for this premier educational event about SAP technology. Like last year, the SAP Cloud SDK will have a strong presence in Las Vegas, Barcelona, and Bangalore.








Java Libraries: Release Highlights 3.0.0


This new release represents a major overhaul of the SAP Cloud SDK for Java, modernizing it to be ready for the future and introducing new capabilities. In particular, version 3 introduces a new destination concept, replaces the resilience implementation with resilience4j where Hystrix was used before, leverages JCache (JSR-107) for caching, and makes it easier to run code outside of standard request-response scenarios. We have published two separate blog posts to introduce the new version 3.0.0:

  1. A high-level overview of changes and benefits and

  2. A guide on how to migrate applications to version 3.0.0.


In the following, we accordingly focus on the new functionality of version 3.0.0, less on the changes and improvements to previously existing functionality, which are covered by above-mentioned blog posts.

You can update your dependencies of the SAP Cloud SDK for Java to version 3.0.0 and consume the new version from Maven Central.

Executing code "on-behalf-of"


The accessor classes, for example, TenantAccessor, are a core component of the SDK providing convenient access to properties of the current context, like the current tenant. Often, this context and its properties is implicitly given by an HTTP request. For scenarios like messaging or background tasks, it is however sometimes necessary to construct the context via other means.
As part of unifying the functionality and behavior of accessors, all relevant accessors now allow overriding their respective properties. This concerns TenantAccessor, PrincipalAccessor, AuthTokenAccessor, and RequestAccessor.

You can execute any code (given as Callable or Executable) while overriding (that is, "on-behalf of") Tenant, Principal, AuthToken, or Request of the context.
At the example of TenantAccessor.executeWithTenant, the given callable/executable will be executed in a context where the given tenant is set as the current tenant.
TenantAccessor.executeWithTenant(new ScpCfTenant("some-tenant", "some-subdomain"), () -> {
// All code using the SAP Cloud SDK will use the provided tenant as the current tenant
// TenantAccessor.getCurrentTenant() will return the tenant "some-tenant".
});

In addition to overriding, accessors provide the option to set a fallback for a single execution (for example, with TenantAccessor.executeWithFallbackTenant) or globally (for example, with TenantAccessor.setFallbackTenant). With a fallback thus set globally or locally, the SDK will retrieve a fallback tenant from the given supplier, whenever, for example, the current tenant is requested but not available.

Construct destinations manually


In addition to resolving destinations by name from the destination service or from the environment variables, the SDK now allows you to construct fully-fledged destinations in code. You can pass those manually created destinations like any other destination wherever a target system is expected, for example, in the OData client of the OData VDM.

To construct destinations easily, the SDK provides builders such as the DefaultHttpDestination.Builder or ScpCfHttpDestination.Builder. You can instantiate the builder by calling, for example, DefaultHttpDestination.builder or ScpCfHttpDestination.builder, providing the URI that the destination shall point to. You can then provide additional properties such as credentials.

Further improvements


The new RequestAccessor class gives access to the current request, if available. Like other accessors (see above), it also allows overriding the request and providing a fallback request when wrapping code to be executed.

With version 3, we make the previously existing XsuaaService class public so that you can use its functionality for retrieving and caching access tokens from a given XSUAA service on SAP Cloud Platform, Cloud Foundry.

A ThreadContext (formerly known as RequestContext) can now be easily nested within another ThreadContext. The SDK no longer throws an exception if there is already a context and no longer requires specifically declaring that nesting is allowed.

Several further improvements are listed in the full release notes.

Java Libraries: Release Highlights 2.19.2


We have also released the SDK for Java in a new maintenance version 2.19.2. Everyone who does not yet want to migrate to version 3 of the SDK for Java can consume that version from Maven Central.

Version 2.19.2 updates the dependency to the Java libraries of the SAP Cloud Application Programming Model (com.sap.cloud.servicesdk.*) from version 1.31.1 to 1.32.0. This fixes an issue where deep insert with the OData VDM did not work beyond the first level in certain cases.

For a complete view on what has changed, take a look at the full release notes.

JavaScript Libraries: Release Highlights 1.7.0


The JavaScript libraries of the SAP Cloud SDK are now available in version 1.7.0.

Support for SAP Cloud Platform Extension Factory


The SDK for JavaScript now supports SAP Cloud Platform Extension Factory, similar to the SAP Cloud SDK for Java since version 2.16.0. SAP Cloud Platform Extension Factory is SAP's cloud-native extensibility framework. One major benefit is that it allows you to easily connect SAP S/4HANA Cloud systems to your account on SAP Cloud Platform, with a few simple steps. The SAP Cloud SDK is then the final piece of the puzzle to communicate with the thus-connected system from your application's source code.

Version 1.7.0 allows accessing destinations provided as service bindings by SAP Cloud Platform Extension Factory. Whenever resolving a destination by name, the SDK will look for a service binding with that name before consulting the destination service. That is, if you have created a service instance called "my-s4hana" via Extension Factory, simply refer to that name as destination name in your code, exactly as you do with destinations from the destination service. The SDK transparently uses the URL and authentication of service bindings when resolving a destination to a service binding. This happens when executing OData requests by supplying a DestinationNameAndJwt as well as in useOrFetchDestination and getDestination.

We have also introduced a new function destinationForServiceBinding specifically for retrieving a destination representing a service binding. It accepts the name of a service (as string) and tries to find a service binding with the given name and builds a Destination for that service.

Further improvements


The SDK now verifies JWTs that are passed to the destination accessor when fetching destinations from the destination service (explicitly or implicitly).

The OData client allows creating an OData delete request by passing the OData entity to delete instead of only the key values. It will automatically attach the version identifier of the entity if present. If you already have an OData entity, for example, address, this allows you to just write:
BusinessPartnerAddress.requestBuilder()
.delete(address)
.execute ...

As usual, the full release notes contain a list of all improvements in this release.

How to Update


Java libraries


To update the version of the SAP Cloud SDK Java libraries used in an existing project, proceed as follows:

  • Open the pom.xml file in the root folder of your project.

  • Locate the dependency management section and therein the sdk-bom dependency.

  • Change the groupId to com.sap.cloud.sdk (instead of com.sap.cloud.s4hana).

  • Update the version of that dependency to 3.0.0.


Your dependency should look like this:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.sap.cloud.sdk</groupId>
<artifactId>sdk-bom</artifactId>
<version>3.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
<!-- possibly further managed dependencies ... -->
</dependencyManagement>

Afterwards, you will have to migrate your code to version 3.0.0 with the help of our migration guide, because this is a new major version.
You can now recompile your project (be aware of the compatibility notes, though) and leverage the new features of the SAP Cloud SDK in version 3.0.0.

Of course, you can also generate a new project that uses version 3.0.0 from the start by running the Maven archetypes for Neo or Cloud Foundry with -DarchetypeVersion=3.0.0 (or RELEASE).

JavaScript libraries


To update the version of the SAP Cloud SDK JavaScript libraries used in an existing project, use the command npm update in the root folder of your module. Note that this will also update other modules, unless you explicitly specify which packages to update. If you want to check beforehand what will change, use npm outdated.