本文整理汇总了Java中org.fosstrak.ale.server.readers.BaseReader类的典型用法代码示例。如果您正苦于以下问题:Java BaseReader类的具体用法?Java BaseReader怎么用?Java BaseReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BaseReader类属于org.fosstrak.ale.server.readers包,在下文中一共展示了BaseReader类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: define
import org.fosstrak.ale.server.readers.BaseReader; //导入依赖的package包/类
@Override
public void define(String name, LRSpec spec) throws DuplicateNameException, ValidationException, SecurityException, ImplementationException {
LOG.debug("define");
throwValidationExceptionOnNullInput(name, "parameter name is null");
throwValidationExceptionOnNullInput(spec, "parameter spec is null");
LogicalReader logRead = getReaderProvider().createReader(name, spec);
// establish connection when basereader
if (logRead instanceof BaseReader) {
((BaseReader)logRead).connectReader();
}
persistenceWriteAPI.writeLRSpec(name, spec);
LOG.debug("saving reader: " + name + " " + logRead.getClass().getCanonicalName());
logicalReaders.put(name, logRead);
LOG.debug("successfully executed define");
}
示例2: define
import org.fosstrak.ale.server.readers.BaseReader; //导入依赖的package包/类
@Override
public void define(String name, LRSpec spec) throws DuplicateNameException, ValidationException, SecurityException, ImplementationException {
aleac.checkAccess(authScope, Thread.currentThread().getStackTrace()[1].getMethodName());
LOG.debug("define");
throwValidationExceptionOnNullInput(name, "parameter name is null");
throwValidationExceptionOnNullInput(spec, "parameter spec is null");
if(logicalReaders.containsKey(name)) {
throw new DuplicateNameException("LRSpec "+name+" already exists");
}
LogicalReader logRead = getReaderProvider().createReader(name, spec);
// establish connection when basereader
if (logRead instanceof BaseReader) {
//((BaseReader)logRead).connectReader(); Call me if you got trouble, [email protected]
}
persistenceWriteAPI.writeLRSpec(name, spec);
LOG.debug("saving reader: " + name + " " + logRead.getClass().getCanonicalName());
logicalReaders.put(name, logRead);
LOG.debug("successfully executed define");
}
示例3: 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);
}
示例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 {
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);
}
示例5: 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);
}
示例6: 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);
}
示例7: testDefine
import org.fosstrak.ale.server.readers.BaseReader; //导入依赖的package包/类
/**
* test the definition of a reader.
* @throws Exception test failure (or see what is expected by the test).
*/
@Test
public void testDefine() throws Exception {
WriteConfig persistenceWriteMock = EasyMock.createMock(WriteConfig.class);
persistenceWriteMock.writeLRSpec(EasyMock.isA(String.class), EasyMock.isA(LRSpec.class));
EasyMock.replay(persistenceWriteMock);
((LogicalReaderManagerImpl) manager).setPersistenceWriteAPI(persistenceWriteMock);
final BaseReader baseReader = EasyMock.createMock(BaseReader.class);
baseReader.connectReader();
EasyMock.expectLastCall();
EasyMock.replay(baseReader);
// need a handle onto the spec delivered for the reader creation.
final AtomicReference<org.fosstrak.ale.xsd.ale.epcglobal.LRSpec> ref = new AtomicReference<org.fosstrak.ale.xsd.ale.epcglobal.LRSpec>();
ReaderProvider readerProvider = EasyMock.createMock(ReaderProvider.class);
EasyMock.expect(readerProvider.createReader(EasyMock.isA(String.class), EasyMock.isA(LRSpec.class))).andDelegateTo(new ReaderProvider() {
@Override
public LogicalReader createReader(String name, org.fosstrak.ale.xsd.ale.epcglobal.LRSpec theSpec) throws ImplementationException {
ref.set(theSpec);
return baseReader;
}
});
EasyMock.replay(readerProvider);
((LogicalReaderManagerImpl) manager).setReaderProvider(readerProvider);
org.fosstrak.ale.server.readers.gen.LRSpec spec = new org.fosstrak.ale.server.readers.gen.LRSpec();
spec.setIsComposite(true);
spec.setReaderType("theNiceTestReaderType");
org.fosstrak.ale.server.readers.gen.LRProperty p = new org.fosstrak.ale.server.readers.gen.LRProperty();
p.setName("name");
p.setValue("value");
spec.getLRProperty().add(p);
spec.getReaders().addAll(Arrays.asList(new String[] { "reader1", "reader2", "reader3" }));
final String readerName = "readerName";
manager.define(readerName, spec);
Assert.assertTrue(manager.contains(readerName));
org.fosstrak.ale.xsd.ale.epcglobal.LRSpec theNewSpec = ref.get();
Assert.assertNotNull(theNewSpec);
Assert.assertTrue(theNewSpec.isIsComposite());
Assert.assertEquals(2, theNewSpec.getProperties().getProperty().size());
Map<String, String> keyValue = new HashMap<String, String> ();
for (LRProperty pr : theNewSpec.getProperties().getProperty()) {
keyValue.put(pr.getName(), pr.getValue());
}
Assert.assertEquals("theNiceTestReaderType",keyValue.get("ReaderType"));
Assert.assertEquals("value", keyValue.get("name"));
EasyMock.verify(persistenceWriteMock);
EasyMock.verify(baseReader);
}
示例8: testDefine
import org.fosstrak.ale.server.readers.BaseReader; //导入依赖的package包/类
/**
* test the definition of a reader.
* @throws Exception test failure (or see what is expected by the test).
*/
//@Test
public void testDefine() throws Exception {
ALEACImpl aleac = EasyMock.createMock(ALEACImpl.class);
((LogicalReaderManagerImpl)manager).setAleac(aleac);
WriteConfig persistenceWriteMock = EasyMock.createMock(WriteConfig.class);
persistenceWriteMock.writeLRSpec(EasyMock.isA(String.class), EasyMock.isA(LRSpec.class));
EasyMock.replay(persistenceWriteMock);
((LogicalReaderManagerImpl) manager).setPersistenceWriteAPI(persistenceWriteMock);
final BaseReader baseReader = EasyMock.createMock(BaseReader.class);
baseReader.connectReader();
EasyMock.expectLastCall();
EasyMock.replay(baseReader);
// need a handle onto the spec delivered for the reader creation.
final AtomicReference<org.fosstrak.ale.xsd.ale.epcglobal.LRSpec> ref = new AtomicReference<org.fosstrak.ale.xsd.ale.epcglobal.LRSpec>();
ReaderProvider readerProvider = EasyMock.createMock(ReaderProvider.class);
EasyMock.expect(readerProvider.createReader(EasyMock.isA(String.class), EasyMock.isA(LRSpec.class))).andDelegateTo(new ReaderProvider() {
@Override
public LogicalReader createReader(String name, org.fosstrak.ale.xsd.ale.epcglobal.LRSpec theSpec) throws ImplementationException {
ref.set(theSpec);
return baseReader;
}
});
EasyMock.replay(readerProvider);
((LogicalReaderManagerImpl) manager).setReaderProvider(readerProvider);
org.fosstrak.ale.server.readers.gen.LRSpec spec = new org.fosstrak.ale.server.readers.gen.LRSpec();
spec.setIsComposite(true);
spec.setReaderType("theNiceTestReaderType");
org.fosstrak.ale.server.readers.gen.LRProperty p = new org.fosstrak.ale.server.readers.gen.LRProperty();
p.setName("name");
p.setValue("value");
spec.getLRProperty().add(p);
spec.getReaders().addAll(Arrays.asList(new String[] { "reader1", "reader2", "reader3" }));
final String readerName = "readerName";
manager.define(readerName, spec);
Assert.assertTrue(manager.contains(readerName));
org.fosstrak.ale.xsd.ale.epcglobal.LRSpec theNewSpec = ref.get();
Assert.assertNotNull(theNewSpec);
Assert.assertTrue(theNewSpec.isIsComposite());
Assert.assertEquals(2, theNewSpec.getProperties().getProperty().size());
Map<String, String> keyValue = new HashMap<String, String> ();
for (LRProperty pr : theNewSpec.getProperties().getProperty()) {
keyValue.put(pr.getName(), pr.getValue());
}
Assert.assertEquals("theNiceTestReaderType",keyValue.get("ReaderType"));
Assert.assertEquals("value", keyValue.get("name"));
EasyMock.verify(persistenceWriteMock);
EasyMock.verify(baseReader);
}