BeanArgument beanArgument = metadata.getArguments().get(0);
String ksessionName = ((MutableValueMetadata)beanArgument.getValue()).getStringValue();
BeanArgument kbOptionsArg = metadata.getArguments().get(5);
PassThroughMetadata passThroughMetadata = (PassThroughMetadata) kbOptionsArg.getValue();
KSessionOptions kSessionOptions = (KSessionOptions) passThroughMetadata.getObject();
String type = kSessionOptions.getType();
String kbaseRef = kSessionOptions.getkBaseRef();
if( kbaseRef.equalsIgnoreCase(kieBaseModel.getName())) {
KieSessionModelImpl kSession = new KieSessionModelImpl(kieBaseModel, ksessionName);
kSession.setType(type != null ? KieSessionModel.KieSessionType.valueOf(type.toUpperCase()) : KieSessionModel.KieSessionType.STATEFUL);
kSession.setDefault( "true".equals( kSessionOptions.getDef() ) );
String clockType = kSessionOptions.getClockType();
if ( clockType != null && !clockType.isEmpty() ) {
kSession.setClockType( ClockTypeOption.get(clockType) );
}
String scope = kSessionOptions.getScope();
if ( scope !=null && !scope.isEmpty() ) {
kSession.setScope( scope.trim() );
}
Map<String, KieSessionModel> rawKieSessionModels = kieBaseModel.getRawKieSessionModels();
rawKieSessionModels.put(kSession.getName(), kSession);