Java源码示例:bitronix.tm.resource.ResourceRegistrar

示例1
@Test
public void assertRegisterRecoveryResourceThenRemove() {
    bitronixXATransactionManager.registerRecoveryResource("ds1", xaDataSource);
    assertNotNull(ResourceRegistrar.get("ds1"));
    bitronixXATransactionManager.removeRecoveryResource("ds1", xaDataSource);
    assertNull(ResourceRegistrar.get("ds1"));
}
 
示例2
/**
 * {@inheritDoc}
 */
@Override
public void init() {
    try {
        ResourceRegistrar.register(this);
    } catch (RecoveryException ex) {
        throw new BitronixRuntimeException("error recovering " + this, ex);
    }
}
 
示例3
@Before
public void setup(){
	//clean up
	for(String name : ResourceRegistrar.getResourcesUniqueNames()){
		MicroserviceResourceProducer.unregisterMicroserviceResourceFactory(name);
	}
}
 
示例4
@Test
public void testRegister() {
	assertEquals(0, MicroserviceResourceProducer.getProducers().size());
	assertEquals(0, ResourceRegistrar.getResourcesUniqueNames().size());

	MicroserviceResourceFactory msrFactory = mock(MicroserviceResourceFactory.class);
	MicroserviceXAResource xa = new MicroserviceXAResource("a", null);
	when(msrFactory.build()).thenReturn(xa);

	//TEST
	MicroserviceResourceProducer.registerMicroserviceResourceFactory("a", msrFactory);
	
	assertEquals(1, MicroserviceResourceProducer.getProducers().size());
	MicroserviceResourceProducer producer = MicroserviceResourceProducer.getProducers().values().iterator().next();
	assertEquals("a", producer.getUniqueName());
	assertEquals(1, ResourceRegistrar.getResourcesUniqueNames().size());
	assertEquals(producer, ResourceRegistrar.get("a"));

	try{
       	//TEST
		MicroserviceResourceProducer.registerMicroserviceResourceFactory("a", mock(MicroserviceResourceFactory.class));
		fail("no exception");
	}catch(IllegalStateException e){
		//OK
	}
	assertEquals(1, MicroserviceResourceProducer.getProducers().size());
	producer = MicroserviceResourceProducer.getProducers().values().iterator().next();
	assertEquals("a", producer.getUniqueName());

   	//TEST
	MicroserviceResourceProducer.unregisterMicroserviceResourceFactory("a");
	assertEquals(0, MicroserviceResourceProducer.getProducers().size());
	assertEquals(0, ResourceRegistrar.getResourcesUniqueNames().size());

   	//TEST
	MicroserviceResourceProducer.unregisterMicroserviceResourceFactory("a");
	assertEquals(0, MicroserviceResourceProducer.getProducers().size());
}
 
示例5
@Before
public void setup(){
	//clean up
	for(String name : ResourceRegistrar.getResourcesUniqueNames()){
		MicroserviceResourceProducer.unregisterMicroserviceResourceFactory(name);
	}
}
 
示例6
@Override
public void init() {
  try {
    ResourceRegistrar.register(this);
  } catch (RecoveryException ex) {
    throw new BitronixRuntimeException("error recovering " + this, ex);
  }
}
 
示例7
@SneakyThrows
@Override
public void registerRecoveryResource(final String dataSourceName, final XADataSource xaDataSource) {
    ResourceRegistrar.register(new BitronixRecoveryResource(dataSourceName, xaDataSource));
}
 
示例8
@SneakyThrows
@Override
public void removeRecoveryResource(final String dataSourceName, final XADataSource xaDataSource) {
    ResourceRegistrar.unregister(new BitronixRecoveryResource(dataSourceName, xaDataSource));
}
 
示例9
/**
 * {@inheritDoc}
 */
@Override
public void close() {
    ResourceRegistrar.unregister(this);
}
 
示例10
@Override
public void close() {
  xaResourceHolders.clear();
  ResourceRegistrar.unregister(this);
}