use of com.arjuna.ats.internal.jts.resources.ResourceRecord in project narayana by jbosstm.
the class ResourceRecordUnitTest method test.
@Test
public void test() throws Exception {
DemoResource res = new DemoResource();
ResourceRecord rec = new ResourceRecord(false, res.getResource(), new Uid());
PrintWriter writer = new PrintWriter(new ByteArrayOutputStream());
rec.print(writer);
assertTrue(rec.resourceHandle() != null);
OutputObjectState os = new OutputObjectState();
assertTrue(rec.save_state(os, ObjectType.ANDPERSISTENT));
InputObjectState is = new InputObjectState(os);
assertTrue(rec.restore_state(is, ObjectType.ANDPERSISTENT));
}
use of com.arjuna.ats.internal.jts.resources.ResourceRecord in project narayana by jbosstm.
the class ResourceRecordUnitTest method testDefault.
@Test
public void testDefault() throws Exception {
ResourceRecord rec = new ResourceRecord();
rec.setValue(null);
assertEquals(rec.getRCUid(), Uid.nullUid());
assertEquals(rec.value(), null);
assertTrue(rec.type().length() > 0);
assertEquals(rec.typeIs(), RecordType.OTS_RECORD);
assertEquals(rec.resourceHandle(), null);
rec.alter(null);
rec.merge(null);
ResourceRecord.remove(rec);
}
use of com.arjuna.ats.internal.jts.resources.ResourceRecord in project narayana by jbosstm.
the class ArjunaTransactionImple method createOTSRecord.
protected final AbstractRecord createOTSRecord(boolean propagate, Resource resource, Coordinator coord, Uid recCoordUid) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::createOTSRecord for " + get_uid());
}
/*
* If the resource is an ArjunaOTS.OTSAbstractRecord or an
* ArjunaOTS.ArjunaSubtranAwareResource then we can do better record
* manipulation, and proper nested actions.
*
* Based on the type of resource we create the right abstract record to
* handle it, rather than a single abstract record which switches
* protocols internally.
*/
ArjunaSubtranAwareResource absRec = null;
AbstractRecord corbaRec = null;
if (resource != null) {
try {
absRec = com.arjuna.ArjunaOTS.ArjunaSubtranAwareResourceHelper.narrow(resource);
if (absRec == null)
throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
} catch (Exception e) {
// can't be an ArjunaOTS.ArjunaSubtranAwareResource
absRec = null;
}
}
if (absRec == null) {
corbaRec = new ResourceRecord(propagate, resource, coord, recCoordUid, this);
} else {
Uid u = null;
OTSAbstractRecord otsRec;
try {
otsRec = com.arjuna.ArjunaOTS.OTSAbstractRecordHelper.narrow(absRec);
if (otsRec == null)
throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
} catch (Exception e) {
otsRec = null;
}
if (otsRec != null) {
try {
u = new Uid(otsRec.uid());
} catch (Exception e) {
u = null;
}
if (u == null) {
jtsLogger.i18NLogger.warn_orbspecific_coordinator_uidfail("ArjunaTransactionImple.createOTSRecord");
}
}
if (u == null)
u = new Uid();
corbaRec = new ExtendedResourceRecord(propagate, u, absRec, coord, recCoordUid, this);
otsRec = null;
absRec = null;
u = null;
}
return corbaRec;
}
Aggregations