forked from apache/incubator-kie-drools
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DROOLS-2906] Implement scenario runner (backend) (apache#2036)
DROOLS-2906: Implement scenario runner (backend)
- Loading branch information
1 parent
29b7a08
commit 8265d27
Showing
8 changed files
with
324 additions
and
189 deletions.
There are no files selected for viewing
336 changes: 189 additions & 147 deletions
336
drools-compiler/src/test/java/org/drools/compiler/simulation/BatchRunFluentTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
drools-core/src/main/java/org/drools/core/command/AbstractNewKieContainerCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2010 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed 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.drools.core.command; | ||
|
||
import org.drools.core.command.impl.RegistryContext; | ||
import org.kie.api.KieServices; | ||
import org.kie.api.builder.ReleaseId; | ||
import org.kie.api.runtime.KieContainer; | ||
|
||
public class AbstractNewKieContainerCommand { | ||
|
||
protected KieContainer getKieContainer(RegistryContext context, ReleaseId releaseId) { | ||
KieContainer kieContainer; | ||
if (releaseId != null) { | ||
// use the new API to retrieve the session by ID | ||
KieServices kieServices = KieServices.Factory.get(); | ||
kieContainer = kieServices.newKieContainer(releaseId); | ||
} else { | ||
kieContainer = context.lookup(KieContainer.class); | ||
if (kieContainer == null) { | ||
throw new RuntimeException("ReleaseId was not specified, nor was an existing KieContainer assigned to the Registry"); | ||
} | ||
} | ||
return kieContainer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
drools-core/src/main/java/org/drools/core/command/SetKieContainerCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2010 JBoss Inc | ||
* | ||
* Licensed 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.drools.core.command; | ||
|
||
import org.drools.core.command.impl.RegistryContext; | ||
import org.kie.api.command.ExecutableCommand; | ||
import org.kie.api.runtime.Context; | ||
import org.kie.api.runtime.KieContainer; | ||
|
||
public class SetKieContainerCommand | ||
implements | ||
ExecutableCommand<KieContainer> { | ||
|
||
private static final long serialVersionUID = 2985535777825271597L; | ||
private final KieContainer kieContainer; | ||
|
||
public SetKieContainerCommand(KieContainer kieContainer) { | ||
this.kieContainer = kieContainer; | ||
} | ||
|
||
public KieContainer execute(Context context) { | ||
((RegistryContext) context).register(KieContainer.class, kieContainer); | ||
return kieContainer; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SetKieContainerCommand{" + | ||
"kieContainer=" + kieContainer + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters