Error while get JobOperatorImpl with Thorntail (Wildfly Swarm) and JBeret - wildfly-swarm

I need to get JobOperatorImpl for dealing with programmatically defined jobs in JBeret. I use Thorntail as a container with io.thorntail:batch-jberet dependency.
JobOperatorImpl jobOperator = (JobOperatorImpl) JobOperatorContext.getJobOperatorContext().getJobOperator();
But I get an exception:Caused by: java.lang.ClassCastException: org.wildfly.extension.batch.jberet.deployment.JobOperatorService cannot be cast to org.jberet.operations.JobOperatorImpl
It works normally when I use JBeret dependency without Thorntail fraction.

You can cast it to org.jberet.operations.AbstractJobOperator.
It should provide all methods you need for managing jobs.

I believe that org.wildfly.extension.batch.jberet.deployment.JobOperatorService can only be cast to javax.batch.operations.JobOperator and not the JBeret implementation class

Related

flink assign uid to window function

is there a way to assign uid to a window function (such as apply(ApplyCustomFunction)) as we do for map/flatmap (or other) functions in Flink. The Flink version is 1.13.1.
I would like to specify the case with an example
DataStream<RECORD> outputDataStream = dataStream
.coGroup(otherDataStream)
.where(DATA::getKey)
.equalTo(OTHERDATA::getKey)
.window(TumblingProcessingTimeWindows.of(Time.seconds(2)))
.apply(new CoGroupFunction());
Thanks
CoGroupedStreams.WithWindow#apply(CoGroupFunction<T1,T2,T>) doesn't have the return type that's needed for setting a UID or per-operator parallelism (among other things). This was done in order to keep binary backwards compatibility, and can't be fixed before Flink 2.0.
You can work around this by using the (deprecated) with method instead of apply, as in
DataStream<RECORD> outputDataStream = dataStream
.coGroup(otherDataStream)
.where(DATA::getKey)
.equalTo(OTHERDATA::getKey)
.window(TumblingProcessingTimeWindows.of(Time.seconds(2)))
.with(new CoGroupFunction())
.uid("window");
The with method will be removed once it is no longer needed.
Use with() instead of apply(). It will be fixed in 2.0 version, how it sayed in documentation

Spring EL - Invoking static interface method

Is there a way to invoke a static interface method in SpEL?
For example:
T(java.util.stream.IntStream).of(new Integer[]{1,2,3}).sum()
When I run this I get this error: Problem locating method of on type class java.lang.Class
You are missing to show us more stack trace:
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1033E: Method call of 'of' is ambiguous, supported type conversions allow multiple variants to match
at org.springframework.expression.spel.support.ReflectiveMethodResolver.resolve(ReflectiveMethodResolver.java:211)
It can't resolve a proper method at runtime via reflection, just because there are several of() method in the IntStream.
This works for me:
ExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("T(java.util.stream.IntStream).of(1,2,3).sum()");
assertThat(expression.getValue()).isEqualTo(6);
It needs to be "T(java.util.stream.IntStream).of(new int[]{1,2,3}).sum()".
(int[] not Integer[]).
The problem is there are 2 of() methods and conversion is needed from Integer[] and so you get
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1033E: Method call of 'of' is ambiguous, supported type conversions allow multiple variants to match

Set property on body using bean()

I'm trying to set a property called "articleId" on the exchange's body and I thought the most explicit way to do this would be to use bean(). However, I can't get it to work. When I have the following in my route:
.bean(body(Article.class), "setArticleId(${header.articleId})")
I get this error message:
Caused by: org.apache.camel.component.bean.MethodNotFoundException: Method with name: setArticleId(${header.articleId}) not found on bean: bodyAs[com.example.model.Article] of type: org.apache.camel.builder.ValueBuilder
My solution has been to use a processor() and a few lines of code in order to set the articleId property from the header value, but to me that seems like overkill.
I've been complaining on camel-users that there isn't a good way to do this. For now here is how I tackle it:
.setHeader("dummy").ognl("request.body.articleId = request.headers.articleId")
Which requires adding camel-ognl dependency.
UPDATE
Actually, there is also a language endpoint that can do this without the setHeader, but you have to say transform=false or else it replaces your body with the result:
.to("language:ognl:request.body.articleId = request.headers.articleId?transform=false") // remember ?transform=false
I think you need to spend some time to go through this page, if you don't know how to tell camel which method of the bean you want it invoke.
If you just want to set the exchange property, you can just use the DSL
setProperty("articleId", body());
to do this kind of work.

Array[Nothing with java.lang.Object] required in Scala 2.9.1

I have a weird compilation error. The offending lines are:
val comboBoxLanguage = new javax.swing.JComboBox
//...
comboBoxLanguage.setModel(new javax.swing.DefaultComboBoxModel(
Array[Object]("Scala", "Java")))
and the error:
error: type mismatch;
found : Array[java.lang.Object]
required: Array[Nothing with java.lang.Object]
Note: java.lang.Object >: Nothing with java.lang.Object, but class Array is invariant in type T.
You may wish to investigate a wildcard type such as `_ >: Nothing with java.lang.Object`. (SLS 3.2.10)
comboBoxLanguage.setModel(new javax.swing.DefaultComboBoxModel( Array[Object]("Scala", "Java")))
According to JavaDoc the constructor of DefaultComboBoxModel expects an Object[], which can be a String[] or whatever array type in Java, since arrays are covariant, but in Scala they are not, so we have to use Array[Object], which shouldn't be a problem.
Why is the compiler expecting Array[Nothing with java.lang.Object]? How can I fix it?
This seems to be new with version 2.9.1 of Scala. My application used to compile until I installed 2.9.1 a couple of days ago. A confusing / worrying thing is that I haven't changed the project compiler library version in IntelliJ, but somehow it seems to be using it, perhaps grabbing it from my SCALA_HOME environment variable?
I think it is not an issue of scala 2.9.1 but new JDK. In JDK7 JComboBox is generic and in your code it is JComboBox[Nothing]. You should explicitly declare comboBoxLanguage variable as
val comboBoxLanguage = new javax.swing.JComboBox[Object]

How to access NHibernate.IQueryOver<T,T> within ActiveRecord?

I use DetachedCriteria primarily, it has a static method For to construct an instance. But it seems IQueryOver is more favourable, I want to use it.
The normal way to get an instance of IQueryOver is Isession.Query, and I want get it with ActiveRecord gracefully, anyone knows the way? Thanks.
First, QueryOver.Of<T> return an instance of QueryOver<T, T>, then you build conditions with QueryOver API.
After that, query.DetachedCriteria return the equivalent DetachedCriteria, which can be used with ActiveRecord gracefully.
var query = QueryOver.Of<PaidProduct>()
.Where(paid =>
paid.Account.OrderNumber == orderNumber
&& paid.ProductDelivery.Product == product)
.OrderBy(paid=>paid.ProductDelivery.DeliveredDate).Desc;
return ActiveRecordMediator<PaidProduct>.FindAll(query.DetachedCriteria);
As far as I know, there is no direct support for QueryOver. I encourage you to create an item in the issue tracker, then fork the repository and implement it. I'd start by looking at the implementation of ActiveRecordLinqBase, it should be similar. But instead of a separate class, you could just implement this in ActiveRecordBase. Then wrap it in ActiveRecordMediator to that it can also be used in classes that don't inherit ActiveRecordBase.

Resources