I need help in KIE API. Need to know that what it is and is there any tutorial available to use Drools KIE. Is kie part of drools-6.x ? And if it is part of drools-6.x then what will be the effect on applications using Drool-5.5 running JBPM5.4, and guvnor 5.5 ?
Regards,
Zahid Ahmed
Drools6 and jBPM6 are introducing a new public API called kie-api. It is very similar to the Drools5 and jBPM5 API in a lot of areas, but some areas were added or refactored as well. The API itself should have full Javadocs, and more documentation is currently under development as well.
For people using the old knowledge-api from Drools5 and jBPM5, this is still backwards compatible, so you should be able to use either
Related
XMLHttpRequest is an alternative for HTTP calls from GWT client side and allows the control over all aspects of requests/responses. But how to use it?
javadoc address: http://www.gwtproject.org/javadoc/latest/com/google/gwt/xhr/client/class-use/XMLHttpRequest.html
You haven't mentioned what GWT version you use, so I assume the latest one. It means 2.8.2 or newer.
Elemental2 is the way to go
As it is mentioned in comments above, Elemental2 is the right way. I will explain it a bit.
If you think about future-proof implementation (being aware of GWT3/J2CL new approach), please do not use legacy GWT stuff. It means please use elemental2.dom.XMLHttpRequest instead of com.google.gwt.xhr.client.XMLHttpRequest (the one mentioned by you). Please do not use gwt-user dependency if possible, as it will be deprecated (if it is not already).
The Elemental2 is an opensource project available here: https://github.com/google/elemental2. It is kind of a base library for the "new GWT". For easier migration of existing GWT2.x projects to GWT3.x, a part of the "old" gwt-user is currently being ported to the new approach using JsInterop technique and mentioned Elemental2. So definitely Elemental2 is the way to go.
Elemental2 and JsInterop in general
The specification is not yet that rich if about the new JsInterop approach, but at the moment you will find some introduction at least: http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJsInterop.html
Examples
Please find an example for XMLHttpRequest in this article:
http://www.g-widgets.com/2016/09/09/gwt-http-requests-alternatives/
If you look for examples, also a good way is to search this on the Github site this way: https://github.com/search?q=elemental2.dom.XMLHttpRequest&type=Code.
(To use Github search you need to be logged in, in other case you will see "Whoa there! You have triggered an abuse blah blah..." )
One of the results will lead you to the very interesting project (you have the preview of the future GWT now):
https://github.com/gwtproject/gwt-http. It is
a future-proof port of the legacy com.google.gwt.http.HTTP GWT module. It will help to migrate GWT2.x projects to GWT3.x.
When you look to the test package, you will find some examples: https://github.com/gwtproject/gwt-http/tree/master/src/test/java/org/gwtproject/http/client .
So this is finally the answer to your question: "how to use it?" :-)
An additional examples source for XMLHttpRequest (using Elemental2) from Gist: https://gist.github.com/search?utf8=%E2%9C%93&q=elemental2.dom.XMLHttpRequest. This is probably even better for start, as they are short and clear.
What Elemental2 is?
The Elemental2 gives you a type checked access to native browser's API. So if you are familiar with browser's API, you should be able to implement your stuff, even based on some native JavaScript example. Please think about the new GWT like about type safe JavaScript (in addition very performant and well optimized). With JsInterop you create bindings, so it is something similar to bindings for TypeScript. So in fact you have a possibility to deal directly with browser's API, without anything GWT specific.
Libraries? More examples...?
Dealing with XMLHttpRequest is a bit low level.
You have also a possibility to use the library. One of Github search results will lead you to this repository: https://github.com/ibaca/autorest-streaming-example which is an example for interesting REST library: https://github.com/intendia-oss/autorest. A modern and reactive one, works with Observables, RxJava and so on.
This library uses JsInterop and is also migrated to Elemental2 what makes it GWT3/J2CL ready, please see the change: https://github.com/intendia-oss/autorest/commit/58516802cd42134544e6e3787207b5431fae94b5 .
With the Github search query I provided you, now you are able to find even more code examples for XMLHttpRequest. So please just have a look and find the best one for your needs.
An alternative approach would be to use a framework, for instance Errai from RedHat: http://erraiframework.org/. It helps you to deal with many problems at a different abstraction level.
I think now you have some references to study.
On the other hand it's 2018, so why not the Fetch API?
When think about the modern web application, I would rather think about the Fetch API instead of XMLHttpRequest. All modern browsers now implement the fetch() function natively. Isn't it the best way for solving your issue then?
The fetch() is a Promise-based mechanism that allows you to make network requests similar to XMLHttpRequest. Promises and Fetch are handled by Elemental2. Then you can use it from your Java code more or less in similar way like in Mozilla's examples.
Read more about the Fetch API here:
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
https://developers.google.com/web/updates/2015/03/introduction-to-fetch
https://codepen.io/aderaaij/post/fetching-data-with-fetch
https://fetch.spec.whatwg.org/
What more, this is nothing new as you see.
If about the older browsers a polyfill will emulate the missing function: https://github.com/github/fetch.
If about examples, I don't see that much on Github:
https://github.com/search?utf8=%E2%9C%93&q=elemental2.dom.DomGlobal+fetch&type=Code, but at least something.
The Fetch API seems to be the most current solution to the problem.
Please find a very simple fetch() example using Elemental2.
The imports section:
import static elemental2.dom.DomGlobal.fetch;
import static elemental2.dom.DomGlobal.console;
import elemental2.dom.Response;
Then use in your code:
fetch("https://randomuser.me/api/?gender=female&results=1")
.then(Response::json)
.then(data -> {
console.log(Global.JSON.stringify(data));
return null;
}).
catch_(error -> {
console.log(error);
return null;
});
As a result you should be able to see something like this:
{"results":[{"gender":"female","name":{"title":"mrs","first":"caroline","last":"coleman"},"location":{"street":"3703 new road","city":"swansea","state":"leicestershire","postcode":"ZH67 0YS","coordinates":{"latitude":"14.7870","longitude":"-107.8990"},"timezone":{"offset":"-6:00","description":"Central Time (US & Canada), Mexico City"}},"email":"caroline.coleman#example.com","login":{"uuid":"25357d90-cce4-4fe6-a3db-8ab77c0272ba","username":"smallpeacock582","password":"citizen","salt":"VX3s05Ah","md5":"84649cce1db8c6f2cbe33098221aa570","sha1":"005abf7d2ca0ff5b1a0bfd6dcee6d4860ef6e75d","sha256":"caadff0a16e27b0d9893aea483aedc7cf7c4707096c33a58acf44336bb2b54be"},"dob":{"date":"1978-03-14T15:47:16Z","age":40},"registered":{"date":"2013-08-10T19:09:41Z","age":5},"phone":"015396 74385","cell":"0726-723-103","id":{"name":"NINO","value":"JA 32 24 22 P"},"picture":{"large":"https://randomuser.me/api/portraits/women/45.jpg","medium":"https://randomuser.me/api/portraits/med/women/45.jpg","thumbnail":"https://randomuser.me/api/portraits/thumb/women/45.jpg"},"nat":"GB"}],"info":{"seed":"98f4f4a344470fbd","results":1,"page":1,"version":"1.2"}}
You can further convert the result to Java object using a technique called JsInterop DTOs. If you are interested, please find some information here: https://stackoverflow.com/a/50565283/5394086 .
Not recommended approach
If you sadly prefer to use the old GWT, so <= 2.7, then I think you can search for some examples on Github using similar search query, but for this legacy com.google.gwt.xhr.client.XMLHttpRequest. I this case I would also suggest you to not do stuff so low level, but use a library like https://github.com/reinert/requestor (which is unfortunately discontinued and development has stopped on GWT 2.7, but for this GWT version it is probably the best choice). But again please do not go this way and use GWT >= 2.8.2 with Elemental2/JsInterop approach instead.
Amazon released version 1.4.0 of their Java SDK for AWS today, with the very welcome addition com.amazonaws.regions.Region, which describes the available regions and their services.
This class also provides the createClient() factory method for all client classes (subclassing com.amazonaws.AmazonWebServiceClient).
I don't understand how I can pass a custom AWSCredentialProvider to this method, as the second expected argument is a org.apache.http.client.CredentialsProvider.
I don't even understand how the method can work, because it uses Java reflection to try to find a constructor for the client classes with a org.apache.http.client.CredentialsProvider second argument, which does not exist.
It looks to me like this is a mistake in the code of the SDK, which has only be tested with the DefaultAWSCredentialsProviderChain.
Am I using this class incorrectly, or can I expect this mistake to be fixed soon ?
By the way, the lastest Javadoc does not include the com.amazonaws.regions package yet.
glad to hear you're excited about the new Regions code. It should make working with services in different AWS regions a little easier.
You are correct that the import statement in Region.java is importing the wrong CredentialsProvider. We'll get that fixed ASAP and released in the next version of the AWS SDK for Java.
I'm pushing out a new build of the Javadoc to our site that will include the com.amazonaws.regions namespace. Look for that to be out later this afternoon.
Thanks for reporting this problem! Hope you enjoy the new regions code. Let us know if you have any other feedback, suggestions or issues. We always love hearing from customers.
Is there a Java library for Netflow? I need to be able to objectify flows for analysis. (I really need to support sflow, too, but one hurdle at a time.) I found a project called "jflow" that has classes for Netflow v5 and v6, but I need to support 7 and 9 as well.
All of my googling has brought me nothing. Does anyone know of a library? Has anyone written their own?
Yes, there is Java NetFlow Collect-Analyzer as well. It supports v7 and v9 as well as previous versions.
Another java library called Styx is another Netflow Collector and Analyzer.
There is a Scala library, which presumably means it could be invoked from Java. But that's not specifically documented, nor have I attempted to.
Is it possible to use OLE Automation in Java? If not, why is it not possible in Java?
I'm looking to automate the exporting of excel spreadsheets in different format (ie, .csv etc...)
Thanks for the answers in advance :)
Recently (March 2013), an independent contributor added support for generic COM Automation to JNA, which is the last man standing in terms of native platform API integration from Java. JNA is still very actively maintained, unlike Jawin/JACOB/etc.
See here for an example of how it is used. The pre-cooked bindings to the Office APIs are very simple so far, but looking at the code, it seems very easy to use the COM Automation APIs (IDispatch, Variant, etc) to do late binding to almost any COM interface.
I would like to see, however, a more complete binding of the Office COM APIs, since they are by far the most often used COM API in the world. Maybe there could also be an "MSExcel2007.java", "MSExcel2010.java", etc. to cover the different API versions. So it's very much a work in progress, but JNA is now as generally useful for COM Automation as JACOB/Jawin, with the bonus that it's extremely actively maintained (as of April 2013).
You can use JACOB. But there will be some pain involved as it's not documented very well and the performance is not the best. It can also be hard to get it running correctly for you environment depending on which version of Windows you are targetting. I would definitely not use it if you are building a scalable web application. Another option would be Apache POI which has really come a long way from its early roots and is used in alot of production ready tools like JBoss Drools. If you decide to go with JACOB then I recommend you read this SO thread:
Is there a good reference for using OLE Automation (from Java)?
There is a library called JACOB that allows precisely what you're looking for. What do you mean by "from the Java API?" You mean from from the official J2SE packages? I'm not sure how to answer that other than to say that J2SE doesn't include libraries for every conceivable need under the sun, especially those that only work on a single operating system. That's why third party packages exist.
Commercial, but they seem to have a free Open-Source and Academic license...
JExcel
JExcel Developer Documents
I have no affiliation.
I'm considering developing a school information system using the Grails web framework. Before a school can use the system, they will need to setup the following data
School data
Students
Teachers
Subjects
Classes
etc.
I'm considering using a CMS in order to get the ability to CRUD these entities "for free". The CMS may also provide other features out-of-the-box that I could use.
Ideally the CMS should be implemented in Java or Groovy, does anyone know of something suitable? I looked at the Weceem CMS plugin for Grails, but it's missing some core concepts I need, e.g. the ability to add users to groups.
Thanks,
Don
Java is good for rock-solid, high-performance, secure Enterprise apps. Java is considerably less good for getting a relatively simple Web project out the door in a short time.
Therefore, were I in your position, my personal gut feeling would be to go with something Grails based. I'm not very aware of any projects that already partially implement what you want, but if you can find one (Google?) then grab it! That will leave you more time for polishing and adding bells and whistles.
If you're not tied to Java, I'd recommend looking at Drupal for PHP as your CMS. Many sites, even sites of major Java organizations such as SpringSource, have used Drupal as their CMS because it offers so much out of the box.
Magnolia CMS 1 in version 4.3 has full-blown Groovy support. After 7 years of active development, a CMS like Magnolia provides you with a ton of stuff you need to run a website. I wouldn't even think about starting from scratch no matter what framework you use. Understanding the problem you are trying to solve and finding a solution to it is usually taking more time than actually implementing said solution. Even if you believe you know what you need now, rest assured your requirements will overrun you before you know it.
I know it's not Grails related, I would use the DaisyCMS, as it's java based you can add an extra Java Web applications to the Jetty and add extra functionality to the CMS using Grails for your other functinality. I hav enot tried this, it's just a suggestion.
Use Grails scaffolds to get simple CRUD functionallity.
Do you really want to build it from scratch? There are already open-source CMS. In your case I would evaluate open-source CMSs and if necessary would contribute code.
Does it need to be Java/Grails? There are good ones written in PHP or Python (django, joomla).
I tried Grails 1 year ago. It is very straightforward as long as you align with the concepts and standards (e.g. simple CRUD scaffolding). But if there a special requirements you get to similar efforts as with a Java framework like Spring MVC (though grails is also based on Spring MVC).