use of org.kie.api.marshalling.ObjectMarshallingStrategy.Context in project drools by kiegroup.
the class PersisterHelper method loadStrategiesIndex.
private static void loadStrategiesIndex(MarshallerReaderContext context, ProtobufMessages.Header _header) throws IOException, ClassNotFoundException {
for (ProtobufMessages.Header.StrategyIndex _entry : _header.getStrategyList()) {
ObjectMarshallingStrategy strategyObject = context.resolverStrategyFactory.getStrategyObject(_entry.getName());
if (strategyObject == null) {
throw new IllegalStateException("No strategy of type " + _entry.getName() + " available.");
}
context.usedStrategies.put(_entry.getId(), strategyObject);
Context ctx = strategyObject.createContext();
context.strategyContexts.put(strategyObject, ctx);
if (_entry.hasData() && ctx != null) {
ClassLoader classLoader = null;
if (context.classLoader != null) {
classLoader = context.classLoader;
} else if (context.kBase != null) {
classLoader = context.kBase.getRootClassLoader();
}
if (classLoader instanceof ProjectClassLoader) {
readRuntimeDefinedClasses(_header, (ProjectClassLoader) classLoader);
}
ctx.read(new DroolsObjectInputStream(_entry.getData().newInput(), classLoader));
}
}
}
use of org.kie.api.marshalling.ObjectMarshallingStrategy.Context in project drools by kiegroup.
the class PersisterHelper method loadStrategiesIndex.
private static void loadStrategiesIndex(MarshallerReaderContext context, ProtobufMessages.Header _header) throws IOException, ClassNotFoundException {
for (ProtobufMessages.Header.StrategyIndex _entry : _header.getStrategyList()) {
ObjectMarshallingStrategy strategyObject = context.getResolverStrategyFactory().getStrategyObject(_entry.getName());
if (strategyObject == null) {
throw new IllegalStateException("No strategy of type " + _entry.getName() + " available.");
}
context.getUsedStrategies().put(_entry.getId(), strategyObject);
Context ctx = strategyObject.createContext();
context.getStrategyContexts().put(strategyObject, ctx);
if (_entry.hasData() && ctx != null) {
ClassLoader classLoader = null;
if (context.getClassLoader() != null) {
classLoader = context.getClassLoader();
} else if (context.getKnowledgeBase() != null) {
classLoader = context.getKnowledgeBase().getRootClassLoader();
}
if (classLoader instanceof ProjectClassLoader) {
readRuntimeDefinedClasses(_header, (ProjectClassLoader) classLoader);
}
ctx.read(new DroolsObjectInputStream(_entry.getData().newInput(), classLoader));
}
}
}
use of org.kie.api.marshalling.ObjectMarshallingStrategy.Context in project drools by kiegroup.
the class PersisterHelper method writeStrategiesIndex.
private static void writeStrategiesIndex(MarshallerWriteContext context, ProtobufMessages.Header.Builder _header) throws IOException {
for (Entry<ObjectMarshallingStrategy, Integer> entry : context.usedStrategies.entrySet()) {
Builder _strat = ProtobufMessages.Header.StrategyIndex.newBuilder().setId(entry.getValue().intValue()).setName(entry.getKey().getName());
Context ctx = context.strategyContext.get(entry.getKey());
if (ctx != null) {
Output os = ByteString.newOutput();
ctx.write(new DroolsObjectOutputStream(os));
_strat.setData(os.toByteString());
os.close();
}
_header.addStrategy(_strat.build());
}
}
use of org.kie.api.marshalling.ObjectMarshallingStrategy.Context in project drools by kiegroup.
the class PersisterHelper method writeStrategiesIndex.
private static void writeStrategiesIndex(MarshallerWriteContext context, ProtobufMessages.Header.Builder _header) throws IOException {
for (Entry<ObjectMarshallingStrategy, Integer> entry : context.getUsedStrategies().entrySet()) {
Builder _strat = ProtobufMessages.Header.StrategyIndex.newBuilder().setId(entry.getValue().intValue()).setName(entry.getKey().getName());
Context ctx = context.getStrategyContext().get(entry.getKey());
if (ctx != null) {
Output os = ByteString.newOutput();
ctx.write(new DroolsObjectOutputStream(os));
_strat.setData(os.toByteString());
os.close();
}
_header.addStrategy(_strat.build());
}
}
Aggregations