Skip to content

Commit

Permalink
OptaPlanner native support fixes #1721
Browse files Browse the repository at this point in the history
  • Loading branch information
zbendhiba committed Sep 23, 2020
1 parent 707ce26 commit 309081c
Show file tree
Hide file tree
Showing 26 changed files with 915 additions and 66 deletions.
6 changes: 3 additions & 3 deletions docs/modules/ROOT/pages/reference/components/optaplanner.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
= OptaPlanner
:cq-artifact-id: camel-quarkus-optaplanner
:cq-artifact-id-base: optaplanner
:cq-native-supported: false
:cq-status: Preview
:cq-native-supported: true
:cq-status: Stable
:cq-deprecated: false
:cq-jvm-since: 1.1.0
:cq-native-since: n/a
:cq-native-since: 1.2.0
:cq-camel-part-name: optaplanner
:cq-camel-part-title: OptaPlanner
:cq-camel-part-description: Solve planning problems with OptaPlanner.
Expand Down
8 changes: 4 additions & 4 deletions docs/modules/ROOT/pages/reference/extensions/optaplanner.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

= OptaPlanner
:cq-artifact-id: camel-quarkus-optaplanner
:cq-native-supported: false
:cq-status: Preview
:cq-native-supported: true
:cq-status: Stable
:cq-description: Solve planning problems with OptaPlanner.
:cq-deprecated: false
:cq-jvm-since: 1.1.0
:cq-native-since: n/a
:cq-native-since: 1.2.0

[.badges]
[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native##[.badge-unsupported]##unsupported##
[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native since##[.badge-supported]##1.2.0##

Solve planning problems with OptaPlanner.

Expand Down
1 change: 0 additions & 1 deletion extensions-jvm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
<module>nsq</module>
<module>ognl</module>
<module>openstack</module>
<module>optaplanner</module>
<module>pg-replication-slot</module>
<module>pgevent</module>
<module>printer</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@
<artifactId>camel-quarkus-optaplanner-deployment</artifactId>
<name>Camel Quarkus :: OptaPlanner :: Deployment</name>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-quarkus-deployment</artifactId>
<version>${optaplanner.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-quarkus-jackson-deployment</artifactId>
<version>${optaplanner.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
Expand All @@ -40,6 +59,14 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-optaplanner</artifactId>
</dependency>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-quarkus-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-quarkus-jackson-deployment</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
package org.apache.camel.quarkus.component.optaplanner.deployment;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.pkg.steps.NativeBuild;
import org.apache.camel.quarkus.core.JvmOnlyRecorder;
import org.jboss.logging.Logger;

class OptaplannerProcessor {
Expand All @@ -33,14 +29,4 @@ class OptaplannerProcessor {
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

/**
* Remove this once this extension starts supporting the native mode.
*/
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
recorder.warnJvmInNative(FEATURE); // warn at runtime
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@
<modules>
<module>deployment</module>
<module>runtime</module>
<module>integration-test</module>
</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

<properties>
<camel.quarkus.jvmSince>1.1.0</camel.quarkus.jvmSince>
<camel.quarkus.nativeSince>1.2.0</camel.quarkus.nativeSince>
</properties>

<dependencyManagement>
Expand All @@ -45,6 +46,20 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-quarkus</artifactId>
<version>${optaplanner.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-quarkus-jackson</artifactId>
<version>${optaplanner.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -57,6 +72,15 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-optaplanner</artifactId>
</dependency>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-quarkus</artifactId>
</dependency>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-quarkus-jackson</artifactId>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
name: "Camel OptaPlanner"
description: "Solve planning problems with OptaPlanner"
metadata:
unlisted: true
guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/optaplanner.html"
categories:
- "integration"
status:
- "preview"
- "stable"
1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
<module>olingo4</module>
<module>openapi-java</module>
<module>opentracing</module>
<module>optaplanner</module>
<module>paho</module>
<module>pdf</module>
<module>platform-http</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-build-parent-it</artifactId>
<artifactId>camel-quarkus-integration-tests</artifactId>
<version>1.2.0-SNAPSHOT</version>
<relativePath>../../../poms/build-parent-it/pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-optaplanner-integration-test</artifactId>
<name>Camel Quarkus :: OptaPlanner :: Integration Test</name>
<artifactId>camel-quarkus-integration-test-optaplanner</artifactId>
<name>Camel Quarkus :: Integration Tests :: OptaPlanner</name>
<description>Integration tests for Camel Quarkus OptaPlanner extension</description>

<dependencyManagement>
Expand All @@ -53,6 +52,18 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-direct</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-bean</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
Expand All @@ -67,6 +78,32 @@
</dependency>

<!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-bean-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-direct-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-optaplanner-deployment</artifactId>
Expand Down Expand Up @@ -95,6 +132,42 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.quarkus.component.optaplanner.it;

import javax.enterprise.context.ApplicationScoped;

import io.quarkus.runtime.annotations.RegisterForReflection;
import org.apache.camel.Exchange;
import org.apache.camel.component.optaplanner.OptaPlannerConstants;
import org.apache.camel.quarkus.component.optaplanner.it.domain.TimeTable;

@RegisterForReflection
@ApplicationScoped
public class MyBean {

public TimeTable bestSolution;

public TimeTable getBestSolution() {
return bestSolution;
}

public void setBestSolution(TimeTable bestSolution) {
this.bestSolution = bestSolution;
}

public void updateBestSolution(Exchange exchange) {
if (exchange != null) {
TimeTable newBestSolution = exchange.getMessage().getHeader(OptaPlannerConstants.BEST_SOLUTION, TimeTable.class);
if (newBestSolution != null) {
this.bestSolution = newBestSolution;
}
}
}
}

0 comments on commit 309081c

Please sign in to comment.