forked from apache/incubator-kie-drools
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DROOLS-3076] KieSession pool (apache#2099)
* [DROOLS-3076] KieSession pool * [DROOLS-3076] KieSession pool * [DROOLS-3076] KieSession pool * [DROOLS-3076] KieSession pool * [DROOLS-3076] KieSession pool
- Loading branch information
1 parent
92623e2
commit 04d58e7
Showing
24 changed files
with
713 additions
and
279 deletions.
There are no files selected for viewing
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
86 changes: 86 additions & 0 deletions
86
...iler/src/main/java/org/drools/compiler/kie/builder/impl/KieContainerSessionsPoolImpl.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,86 @@ | ||
/* | ||
* Copyright 2005 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.compiler.kie.builder.impl; | ||
|
||
import org.drools.core.impl.AbstractKieSessionsPool; | ||
import org.drools.core.impl.StatefulSessionPool; | ||
import org.drools.core.impl.StatelessKnowledgeSessionImpl; | ||
import org.kie.api.runtime.KieContainerSessionsPool; | ||
import org.kie.api.runtime.KieSession; | ||
import org.kie.api.runtime.KieSessionConfiguration; | ||
import org.kie.api.runtime.StatelessKieSession; | ||
|
||
public class KieContainerSessionsPoolImpl extends AbstractKieSessionsPool implements KieContainerSessionsPool { | ||
|
||
private final KieContainerImpl kContainer; | ||
|
||
KieContainerSessionsPoolImpl( KieContainerImpl kContainer, int initialSize ) { | ||
super(initialSize); | ||
this.kContainer = kContainer; | ||
} | ||
|
||
@Override | ||
public KieSession newKieSession() { | ||
return newKieSession( null, null ); | ||
} | ||
|
||
@Override | ||
public KieSession newKieSession( KieSessionConfiguration conf ) { | ||
return newKieSession( null, conf ); | ||
} | ||
|
||
@Override | ||
public KieSession newKieSession( String kSessionName ) { | ||
return newKieSession( kSessionName, null ); | ||
} | ||
|
||
@Override | ||
public KieSession newKieSession( String kSessionName, KieSessionConfiguration conf ) { | ||
return getPool(kSessionName, conf, false).get(); | ||
} | ||
|
||
@Override | ||
public StatelessKieSession newStatelessKieSession() { | ||
return newStatelessKieSession( null, null ); | ||
} | ||
|
||
@Override | ||
public StatelessKieSession newStatelessKieSession( KieSessionConfiguration conf ) { | ||
return newStatelessKieSession( null, conf ); | ||
} | ||
|
||
@Override | ||
public StatelessKieSession newStatelessKieSession( String kSessionName ) { | ||
return newStatelessKieSession( kSessionName, null ); | ||
} | ||
|
||
@Override | ||
public StatelessKieSession newStatelessKieSession( String kSessionName, KieSessionConfiguration conf ) { | ||
return new StatelessKnowledgeSessionImpl( conf, getPool(kSessionName, conf, true) ); | ||
} | ||
|
||
@Override | ||
protected StatefulSessionPool createStatefulSessionPool( String kSessionName, KieSessionConfiguration conf, boolean stateless ) { | ||
return kContainer.createKieSessionsPool(kSessionName, conf, environment, initialSize, stateless); | ||
} | ||
|
||
@Override | ||
protected String getKey(String kSessionName, KieSessionConfiguration conf, boolean stateless) { | ||
String key = kSessionName == null ? (stateless ? "DEFAULT_STATELESS" : "DEFAULT") : kSessionName; | ||
return conf == null ? key : key + "@" + System.identityHashCode( conf ); | ||
} | ||
} |
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
Oops, something went wrong.