use of com.hazelcast.core.ManagedContext in project hazelcast by hazelcast.
the class PortableSerializer method readAndInitialize.
Portable readAndInitialize(BufferObjectDataInput in, int factoryId, int classId) throws IOException {
Portable p = read(in, factoryId, classId);
final ManagedContext managedContext = context.getManagedContext();
return managedContext != null ? (Portable) managedContext.initialize(p) : p;
}
use of com.hazelcast.core.ManagedContext in project hazelcast by hazelcast.
the class PartitionWideEntryOperation method innerBeforeRun.
@Override
public void innerBeforeRun() throws Exception {
super.innerBeforeRun();
SerializationService serializationService = getNodeEngine().getSerializationService();
ManagedContext managedContext = serializationService.getManagedContext();
managedContext.initialize(entryProcessor);
}
use of com.hazelcast.core.ManagedContext in project hazelcast by hazelcast.
the class DurableSpecificSetupTest method managedContext_mustInitializeRunnable.
@Test
public void managedContext_mustInitializeRunnable() throws Exception {
final AtomicBoolean initialized = new AtomicBoolean();
Config config = new Config().addDurableExecutorConfig(new DurableExecutorConfig("test").setPoolSize(1)).setManagedContext(new ManagedContext() {
@Override
public Object initialize(Object obj) {
if (obj instanceof RunnableWithManagedContext) {
initialized.set(true);
}
return obj;
}
});
DurableExecutorService executor = createHazelcastInstance(config).getDurableExecutorService("test");
executor.submit(new RunnableWithManagedContext()).get();
assertTrue("The task should have been initialized by the ManagedContext", initialized.get());
}
use of com.hazelcast.core.ManagedContext in project hazelcast by hazelcast.
the class ExecutorServiceTest method testManagedContextAndLocal.
@Test
public void testManagedContextAndLocal() throws Exception {
Config config = new Config();
config.addExecutorConfig(new ExecutorConfig("test", 1));
final AtomicBoolean initialized = new AtomicBoolean();
config.setManagedContext(new ManagedContext() {
@Override
public Object initialize(Object obj) {
if (obj instanceof RunnableWithManagedContext) {
initialized.set(true);
}
return obj;
}
});
HazelcastInstance instance = createHazelcastInstance(config);
IExecutorService executor = instance.getExecutorService("test");
RunnableWithManagedContext task = new RunnableWithManagedContext();
executor.submit(task).get();
assertTrue("The task should have been initialized by the ManagedContext", initialized.get());
}
use of com.hazelcast.core.ManagedContext in project hazelcast by hazelcast.
the class EntryOperation method innerBeforeRun.
@Override
public void innerBeforeRun() throws Exception {
super.innerBeforeRun();
final SerializationService serializationService = getNodeEngine().getSerializationService();
final ManagedContext managedContext = serializationService.getManagedContext();
managedContext.initialize(entryProcessor);
}
Aggregations