本文整理汇总了Java中org.fosstrak.ale.server.Subscriber类的典型用法代码示例。如果您正苦于以下问题:Java Subscriber类的具体用法?Java Subscriber怎么用?Java Subscriber使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Subscriber类属于org.fosstrak.ale.server包,在下文中一共展示了Subscriber类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unsubscribe
import org.fosstrak.ale.server.Subscriber; //导入依赖的package包/类
/**
* This method unsubscribes a notification uri of a subscriber from this
* report generator.
* @param notificationURI to unsubscribe
* @throws NoSuchSubscriberException if the specified notification uri is
* not yet subscribed
* @throws InvalidURIException if the notification uri is invalid
*/
@Override
public void unsubscribe(String notificationURI) throws NoSuchSubscriberException, InvalidURIException {
// validate the URI:
new Subscriber(notificationURI);
if (subscribers.containsKey(notificationURI)) {
subscribers.remove(notificationURI);
LOG.debug("NotificationURI '" + notificationURI + "' unsubscribed from spec '" + name + "'.");
if (subscribers.isEmpty() && !isPolling()) {
setState(ReportsGeneratorState.UNREQUESTED);
}
} else {
throw new NoSuchSubscriberException("there is no subscriber on the given notification URI: " + notificationURI);
}
}
示例2: subscribe
import org.fosstrak.ale.server.Subscriber; //导入依赖的package包/类
/**
* This method subscribes a notification uri of a subscriber to this
* report generator.
* @param notificationURI to subscribe
* @throws DuplicateSubscriptionException if the specified notification uri
* is already subscribed
* @throws InvalidURIException if the notification uri is invalid
*/
@Override
public void subscribe(String notificationURI) throws DuplicateSubscriptionException, InvalidURIException {
Subscriber uri = new Subscriber(notificationURI);
if (subscribers.containsKey(notificationURI)) {
throw new DuplicateSubscriptionException(String.format("the URI is already subscribed on this specification %s, %s", name, uri));
} else {
subscribers.put(notificationURI, uri);
LOG.debug("NotificationURI '" + notificationURI + "' subscribed to spec '" + name + "'.");
if (isStateUnRequested()) {
setState(ReportsGeneratorState.REQUESTED);
}
}
}
示例3: notifySubscribersWithFilteredReports
import org.fosstrak.ale.server.Subscriber; //导入依赖的package包/类
/**
* once all the filtering is done eventually notify the subscribers with the reports.
* @param reports the filtered reports.
*/
protected void notifySubscribersWithFilteredReports(ECReports reports) {
// notify subscribers
for (Subscriber listener : subscribers.values()) {
try {
listener.notify(reports);
} catch (Exception e) {
LOG.error("Could not notify subscriber '" + listener.toString(), e);
}
}
}
示例4: testNotify
import org.fosstrak.ale.server.Subscriber; //导入依赖的package包/类
@Test
public void testNotify() throws InvalidURIException, ImplementationException {
ECReports reports = ECElementsUtils.createECReports();
SubscriberOutputChannel mock = EasyMock.createMock(SubscriberOutputChannel.class);
EasyMock.expect(mock.notify(reports)).andReturn(true);
EasyMock.replay(mock);
Subscriber subscriber = new Subscriber("file:///dir");
subscriber.setSubscriberOutputChannel(mock);
subscriber.notify(reports);
EasyMock.verify(mock);
}
示例5: run
import org.fosstrak.ale.server.Subscriber; //导入依赖的package包/类
@Override
public void run() {
LOG.info("notify subscribers at time "+System.currentTimeMillis());
// notify subscribers
for (Subscriber listener : subscribers.values()) {
try {
listener.notify(reports);
} catch (Exception e) {
LOG.error("Could not notify subscriber '" + listener.toString(), e);
}
}
}
示例6: testHttpURIs
import org.fosstrak.ale.server.Subscriber; //导入依赖的package包/类
@Test
public void testHttpURIs() throws Exception {
Subscriber listener = new Subscriber("http://localhost:123456");
Assert.assertTrue(listener.isHttp());
}
示例7: testTcpURIs
import org.fosstrak.ale.server.Subscriber; //导入依赖的package包/类
@Test
public void testTcpURIs() throws Exception {
Subscriber listener = new Subscriber("tcp://localhost:123456");
Assert.assertTrue(listener.isTcp());
}
示例8: testFileURIs
import org.fosstrak.ale.server.Subscriber; //导入依赖的package包/类
@Test
public void testFileURIs() throws Exception {
Subscriber listener = new Subscriber("file:///dir");
Assert.assertTrue(listener.isFile());
}
示例9: testInvalidURI_invalidProtocol
import org.fosstrak.ale.server.Subscriber; //导入依赖的package包/类
@Test(expected = InvalidURIException.class)
public void testInvalidURI_invalidProtocol() throws InvalidURIException {
new Subscriber("htt://myhost.com");
}
示例10: NotificationThread
import org.fosstrak.ale.server.Subscriber; //导入依赖的package包/类
public NotificationThread(ECReports reports, Map<String, Subscriber> subscribers) {
this.reports = reports;
this.subscribers = subscribers;
}