Call java from .js in apigee - apigee

I created apiproxy and used javacookbook sample it worked fine.
But I have a question . IF I want to call the jar from a javascript How to achieve that.
How to call that jar from my js which is in resources/js
Any example to do this in apigee

You cannot call Java from JavaScript. Apigee Edge (paid) customers can make Java callouts directly through a Java callout policy.

Related

Does Spring Cloud Contract support JavaScript and JMS?

I want to start using the framework Spring Cloud Contract for contract testing. But does Spring Cloud Contract support JavaScript and JMS?
I haven't found any information about this.
As for the JMS, we do support it either via spring-integration or Apache Camel. You can also write your own JMS support. It's enough to register a couple of beans.
As for Javascript and non-jvm languages. There's no out of the box support but we have a process for that. The workflow is described here (in those cases the consumer is a Java app but in the next section I'll describe how the flow would differ) - https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html#_common_repo_with_contracts or https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html#_step_by_step_guide_to_cdc. We will try to obviously simplify the process but currently there's a bunch of manual tasks to be done (not very tedious though).
The consumer can very easily download and run the stubs. Just clone https://github.com/spring-cloud-samples/stub-runner-boot, build it and push the fat jar to your Nexus/Artifactory. This application will be used by the consumers to automatically download stubs and run them locally. As a consumer you can then call java -jar stub-runner-boot --stubrunner.ids="com.example.groupid:artifactid:classifier:version:8090" --stubrunner.repositoryRoot="http://localhost:8081/artifactory/libs-release-local" . That way the application will start, download the provided jar with stubs from the given address where your artifactory is. Now your front end application can call the stubs of the producer at localhost:8090.
Of course we will try to simplify the cloning and pushing process (https://github.com/spring-cloud/spring-cloud-contract/issues/37) etc. but for now you have to do those 2 steps manually.
UPDATE:
With this article https://spring.io/blog/2018/02/13/spring-cloud-contract-in-a-polyglot-world we're presenting a way how to work in a polyglot environment. It's enough to use the provided docker images to run contract tests against a running application and to run the stub runners too.

How to keep implementation and documentation in sync when using swagger 2.0 to document the REST API?

I want to use Swagger 2.0 to document REST API as this seems to be widely used to document RET APIs.
However, I am not sure how can I keep the documentation and implementation in Sync ? e.g. When I add a new API then I have to make sure that the model (to represent the Response) used in the API documentation should be same as the model created in the REST implementation. Similarly, the resource name given in the documentation should match the resource name in the implementation.
Is there a way to generate just the resource interface and model classes from the documentation produced using swagger 2.0 spec ?
You can generate server source with these tools (they can also generate client source) :
http://studio.restlet.com: online editor, generate server skeleton code for java (Jax-RS and Restlet) and Node.js
http://editor.swagger.io: online editor, generate server skeleton code for java (Jax-RS), Node.js, Scalatra and Java Spring MVC
https://github.com/swagger-api/swagger-codegen: swagger code generator, you can try to implement your own generator module (personally, I'm currently trying to use this one)

Adobe CQ: Client Library Manager

I'm attempting to modify/override functionalities of the CQ client library manager and I was wondering if anyone is familiar with where the code lives?
I've found some js that controls channel detection in DefaultChannelDetector.js and CQClientLibraryManager.js which seemingly only deals with channels, not dependencies or embedding. These are served as a clientlib, etc/clientlibs/foundation/librarymanager.js which I assume can be overriden by pointing htmllibmanager.clientmanager in apps/system/config/com.day.cq.widget.impl.HtmlLibraryManagerImpl.config
So for modifying, I would need to know where the code lives. For overriding, I assume I point the htmllibmanager.clientmanager toward something else but I would still need to know how to access dependencies/categories/embed properties of clientlibs.
Additionally, any low-level insight into how the cq:includeClientLib tag works would be appreciated. (low-level as in point to the code that implements it)
The vast majority of the Client Library functionality is in the HtmlLibraryManager component implemented OOB by the HtmlLibraryManagerImpl class in the com.day.cq.cq-widgets bundle. You can look up this component in Felix to see what bundle it is in and then decompile that bundle if you need to look at the guts of what the implementation does.
At a high level this component handles both the generation of the results of the cq:includeClientLib tag and the concatenation and compilation of libraries when a library URL is requested. Speaking specifically to the cq:includeClientLib tag, the HtmlLibraryManager's writeIncludes method will determine, based on parameters of the request and parameters provided in the cq:includeClientLib tag, how to write includes to the page for the existing libraries.
In the case of dynamic libraries (libraries which are channel based) it will write calls to the library manager JavaScript mechanisms which will dynamically include libraries based on the user's channel. Otherwise appropriate script and link tags for JavaScript and CSS respectively will be written for the requested libraries and their dependencies.

Apache Camel AHC component examples test-sources jar

I am creating a POC using Apache Camel 2.8 and its AHC component.
I could not find any examples on Apache Camel's website's Examples section for the same.
Also on the AHC component detail page http://camel.apache.org/ahc.html examples only show request being sent to a single URL.For sending requests to multiple URLs in aysnchronous manner and handling their callbacks and responses I cannot see any examples.
If anybody has worked on this and can point me to where I can find the desired examples I would be very much thankful.
Also I was looking out for the unit tests for Camel's AHC component in my local maven repository but could not find the test-sources JAR file.From where and how can I download the same? Unit tests would help in how to use the AHC component API.
I could find the test source code at this location
https://fisheye6.atlassian.com/browse/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc
Is there any way in which I can download all the tests in the form of a JAR file?
Thanks,
Jignesh
The camel-ahc component is asynchronous by default.
See more details here and the links from that page: http://camel.apache.org/asynchronous-routing-engine.html
So if you for example have a Camel route that does a request/reply using AHC, then you can do route messages concurrently, and the camel-ahc runs asynchronously.

Generate webservice from wsdl

This is maybe a really simple question, but I couldn't locate an answer:
For a client I need to HOST a webservice. The client has sent me a wsdl file that the webservice should 'implement'. How do I go about that? I've generated any number of client-rpoxies but this is the other way around. I can use both ASP.NET 2.0 webservices or Windows Communication Foundation.
wsdl.exe /server.
Generates an abstract class for an XML
Web service based on the contracts.
The default is to generate client
proxy classes. When using the
/parameters option, this value is a
element that contains
"server".
You can do a similar thing with svcutil.exe for WCF- something like:
svcutil.exe thewsdl.wsdl /language:c# /out:ITheInterface.cs (I've not tested this).
Edit- John Saunders makes a good point in his answer to favour the WCF approach- I recommend this too.
Actually, you should do this with svcutil.exe, not with wsdl.exe. WSDL.EXE is part of the ASMX web service technology that Microsoft now considers to be "legacy" code, which will not have bugs fixed.
You can do plenty with that WSDL (wissd'le) file.
From doing the WS Class manually to use the Auto Generated class from wsdl.exe
let's imagine that, for your example, you have this WDSL (tooked from WebServiceX.Net)
to create a C# auto generated proxy you go to your command prompt and write:
wsdl /language:cs /protocol:soap /out:C:\myProxyScripts http://www.webservicex.net/TranslateService.asmx?wsdl
Note: inside your C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin folder you will find wsdl.exe or just do a dir /s inside your C:\Program Files\
if you want in Visual Basic, just use /language:vb or /l:vb
/language:
The language to use for the generated proxy class. Choose from 'CS',
'VB', 'JS', 'VJS', 'CPP' or provide a fully-qualified name for a class implementing System.CodeDom.Compiler.CodeDomProvider.
The default
language is 'CS' (CSharp). Short form is '/l:'.
This command will put inside your C:\myProxyScripts the auto generated proxy.
if your using the WSDL file in your computer, just change the URL to your full path, for example
wsdl /language:cs /protocol:soap /out:C:\myProxyScripts C:\myProxyScripts\myWsdlFile.wsdl
Note: your Generated proxy will be called the Service Name, the one you have specified, in our example, as:
<wsdl:service name="TranslateService">
I hope this helps you, understand the WSDL, the Auto Generated Proxies and that you can manage now everything in your end to fulfill your client wishes.
You can use the wsdl utility from microsoft to generate the server interfaces and implement them
Here is a short description of the WSDL utility.
wsdl.exe -
Utility to generate code for xml web service clients and xml web
services
using ASP.NET from WSDL contract files, XSD schemas and .discomap
discovery documents. This tool can be used in conjunction with disco.exe.

Resources