本文整理汇总了Java中org.fosstrak.ale.server.readers.BaseReader.cleanup方法的典型用法代码示例。如果您正苦于以下问题:Java BaseReader.cleanup方法的具体用法?Java BaseReader.cleanup怎么用?Java BaseReader.cleanup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fosstrak.ale.server.readers.BaseReader
的用法示例。
在下文中一共展示了BaseReader.cleanup方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: undefine
import org.fosstrak.ale.server.readers.BaseReader; //导入方法依赖的package包/类
@Override
public void undefine(String name) throws NoSuchNameException, InUseException, SecurityException, ImmutableReaderException, ImplementationException {
// the logicalReader must delete himself from its observables
LOG.debug("undefining reader " + name);
LogicalReader reader = getLogicalReader(name);
throwNoSuchNameExceptionIfReaderNull(reader, name);
// according to the EPC standard a reader cannot be undefined when there is
// an active CC or EC pointing to the reader
// this raises an InUseException
if (reader.countObservers() > 0) {
throw new InUseException(name + "is still in use.");
}
if (reader instanceof CompositeReader) {
CompositeReader composite = (CompositeReader) reader;
composite.unregisterAsObserver();
} else if (reader instanceof BaseReader) {
BaseReader basereader = (BaseReader) reader;
basereader.disconnectReader();
basereader.cleanup();
} else {
throw new ImplementationException("try to undefine unknown reader type - ALE knows BaseReader and CompositeReader - atomic readers must subclass BaseReader, composite readers (collections of readers) must subclass CompositeReader - this is a serious problem!!! reader-name: " + name);
}
persistenceRemoveAPI.removeLRSpec(name);
logicalReaders.remove(name);
}
示例2: testUndefineBaseReader
import org.fosstrak.ale.server.readers.BaseReader; //导入方法依赖的package包/类
/**
* test that base readers are undefined.
* @throws Exception test failure (or see what is expected by the test).
*/
@Test
public void testUndefineBaseReader() throws Exception {
final String readerName = "readerName";
BaseReader logicalReader = EasyMock.createMock(BaseReader.class);
EasyMock.expect(logicalReader.getName()).andReturn(readerName).atLeastOnce();
EasyMock.expect(logicalReader.isStarted()).andReturn(true).atLeastOnce();
EasyMock.expect(logicalReader.countObservers()).andReturn(0);
logicalReader.disconnectReader();
EasyMock.expectLastCall();
logicalReader.cleanup();
EasyMock.expectLastCall();
EasyMock.replay(logicalReader);
RemoveConfig persistenceRemoveMock = EasyMock.createMock(RemoveConfig.class);
persistenceRemoveMock.removeLRSpec(EasyMock.isA(String.class));
EasyMock.expectLastCall();
EasyMock.replay(persistenceRemoveMock);
((LogicalReaderManagerImpl) manager).setPersistenceRemoveAPI(persistenceRemoveMock);
manager.setLogicalReader(logicalReader);
manager.undefine(readerName);
Assert.assertEquals(0, manager.getLogicalReaders().size());
EasyMock.verify(logicalReader);
EasyMock.verify(persistenceRemoveMock);
}
示例3: undefine
import org.fosstrak.ale.server.readers.BaseReader; //导入方法依赖的package包/类
@Override
public void undefine(String name) throws NoSuchNameException, InUseException, SecurityException, ImmutableReaderException, ImplementationException {
aleac.checkAccess(authScope, Thread.currentThread().getStackTrace()[1].getMethodName());
// the logicalReader must delete himself from its observables
LOG.debug("undefining reader " + name);
LogicalReader reader = getLogicalReader(name);
throwNoSuchNameExceptionIfReaderNull(reader, name);
// according to the EPC standard a reader cannot be undefined when there is
// an active CC or EC pointing to the reader
// this raises an InUseException
if (reader.countObservers() > 0) {
throw new InUseException(name + "is still in use.");
}
for(String ecspecName : ale.getECSpecNames()) {
ECSpec ecspec = ale.getECSpec(ecspecName);
if(ecspec.getLogicalReaders().getLogicalReader().contains(name)) {
throw new InUseException(name + "is still in use.");
}
}
if (reader instanceof CompositeReader) {
CompositeReader composite = (CompositeReader) reader;
composite.unregisterAsObserver();
} else if (reader instanceof BaseReader) {
BaseReader basereader = (BaseReader) reader;
basereader.disconnectReader();
basereader.cleanup();
} else {
throw new ImplementationException("try to undefine unknown reader type - ALE knows BaseReader and CompositeReader - atomic readers must subclass BaseReader, composite readers (collections of readers) must subclass CompositeReader - this is a serious problem!!! reader-name: " + name);
}
persistenceRemoveAPI.removeLRSpec(name);
logicalReaders.remove(name);
}
示例4: testUndefineBaseReader
import org.fosstrak.ale.server.readers.BaseReader; //导入方法依赖的package包/类
/**
* test that base readers are undefined.
* @throws Exception test failure (or see what is expected by the test).
*/
//@Test
public void testUndefineBaseReader() throws Exception {
ALEACImpl aleac = EasyMock.createMock(ALEACImpl.class);
((LogicalReaderManagerImpl)manager).setAleac(aleac);
final String readerName = "readerName";
BaseReader logicalReader = EasyMock.createMock(BaseReader.class);
EasyMock.expect(logicalReader.getName()).andReturn(readerName).atLeastOnce();
EasyMock.expect(logicalReader.isStarted()).andReturn(true).atLeastOnce();
EasyMock.expect(logicalReader.countObservers()).andReturn(0);
logicalReader.disconnectReader();
EasyMock.expectLastCall();
logicalReader.cleanup();
EasyMock.expectLastCall();
EasyMock.replay(logicalReader);
RemoveConfig persistenceRemoveMock = EasyMock.createMock(RemoveConfig.class);
persistenceRemoveMock.removeLRSpec(EasyMock.isA(String.class));
EasyMock.expectLastCall();
EasyMock.replay(persistenceRemoveMock);
((LogicalReaderManagerImpl) manager).setPersistenceRemoveAPI(persistenceRemoveMock);
manager.setLogicalReader(logicalReader);
manager.undefine(readerName);
Assert.assertEquals(0, manager.getLogicalReaders().size());
EasyMock.verify(logicalReader);
EasyMock.verify(persistenceRemoveMock);
}