本文整理汇总了Java中org.fosstrak.ale.server.ReportsGeneratorState类的典型用法代码示例。如果您正苦于以下问题:Java ReportsGeneratorState类的具体用法?Java ReportsGeneratorState怎么用?Java ReportsGeneratorState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReportsGeneratorState类属于org.fosstrak.ale.server包,在下文中一共展示了ReportsGeneratorState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unsubscribe
import org.fosstrak.ale.server.ReportsGeneratorState; //导入依赖的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: testGetSpecAndStateAndGetSubscribersAndGetName
import org.fosstrak.ale.server.ReportsGeneratorState; //导入依赖的package包/类
/**
* test getter.
* @throws Exception test failure.
*/
@Test
public void testGetSpecAndStateAndGetSubscribersAndGetName() throws Exception {
ECSpec spec = ECElementsUtils.createECSpec();
ECSpecValidator validator = EasyMock.createMock(ECSpecValidator.class);
validator.validateSpec(spec);
EasyMock.expectLastCall();
EasyMock.replay(validator);
ReportsGenerator generator = new ReportsGeneratorImpl("theName", spec, validator, new ECReportsHelper());
Assert.assertEquals(spec, generator.getSpec());
Assert.assertEquals(ReportsGeneratorState.UNREQUESTED, ((ReportsGeneratorImpl) generator).getState());
Assert.assertNotNull(generator.getSubscribers());
Assert.assertEquals(0, generator.getSubscribers().size());
Assert.assertEquals("theName", generator.getName());
EasyMock.verify(validator);
}
示例3: setState
import org.fosstrak.ale.server.ReportsGeneratorState; //导入依赖的package包/类
/**
* This method sets the state of this report generator.
* If the state changes from UNREQUESTED to REQUESTED, the report generators
* main loop will be started.
* If the state changes from REQUESTED to UNREQUESTED, the report generators
* main loop will be stopped.
* <strong>please notice that this method is not available through the ReportsGeneratorInterface.</strong>
*
* @param state to set
*/
public synchronized void setState(ReportsGeneratorState state) {
ReportsGeneratorState oldState = this.state;
this.state = state;
LOG.debug("ReportGenerator '" + name + "' change state from '" + oldState + "' to '" + state + "'");
if (isStateRequested() && !isRunning()) {
start();
} else if (isStateUnRequested() && isRunning()) {
stop();
} else if(isStateRequested() && isRunning()) {
synchronized(eventCycle) {
eventCycle.notifyAll();
}
}
}
示例4: setState
import org.fosstrak.ale.server.ReportsGeneratorState; //导入依赖的package包/类
/**
* This method sets the state of this report generator.
* If the state changes from UNREQUESTED to REQUESTED, the report generators
* main loop will be started.
* If the state changes from REQUESTED to UNREQUESTED, the report generators
* main loop will be stopped.
* <strong>please notice that this method is not available through the ReportsGeneratorInterface.</strong>
*
* @param state to set
*/
public void setState(ReportsGeneratorState state) {
ReportsGeneratorState oldState = this.state;
this.state = state;
LOG.debug("ReportGenerator '" + name + "' change state from '" + oldState + "' to '" + state + "'");
if (isStateRequested() && !isRunning()) {
start();
} else if (isStateUnRequested() && isRunning()) {
stop();
}
}
示例5: subscribe
import org.fosstrak.ale.server.ReportsGeneratorState; //导入依赖的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);
}
}
}
示例6: poll
import org.fosstrak.ale.server.ReportsGeneratorState; //导入依赖的package包/类
/**
* This method is invoked if somebody polls this report generator.
* The result of the polling can be picked up by the method getPollReports.
*/
@Override
public void poll() {
LOG.debug("Spec '" + name + "' polled.");
pollReport = null;
polling = true;
if (isStateUnRequested()) {
setState(ReportsGeneratorState.REQUESTED);
}
}
示例7: testSubscribeUnSubscribe
import org.fosstrak.ale.server.ReportsGeneratorState; //导入依赖的package包/类
@Test
public void testSubscribeUnSubscribe() throws Exception {
ECSpec spec = ECElementsUtils.createECSpec();
ECSpecValidator validator = EasyMock.createMock(ECSpecValidator.class);
validator.validateSpec(spec);
EasyMock.expectLastCall();
EasyMock.replay(validator);
ReportsGenerator generator = new NonRunnableReportsGenerator("theName", spec, validator);
final String uri ="http://localhost:9999";
final String uri2 ="http://localhost:8888";
Assert.assertEquals(ReportsGeneratorState.UNREQUESTED, ((ReportsGeneratorImpl) generator).getState());
generator.subscribe(uri);
Assert.assertEquals(1, generator.getSubscribers().size());
Assert.assertEquals(ReportsGeneratorState.REQUESTED, ((ReportsGeneratorImpl) generator).getState());
generator.subscribe(uri2);
Assert.assertEquals(2, generator.getSubscribers().size());
List<String> subscribers = generator.getSubscribers();
for (String str : new String[] {uri, uri2 }) {
Assert.assertTrue(subscribers.contains(str));
}
generator.unsubscribe(uri);
Assert.assertEquals(1, generator.getSubscribers().size());
Assert.assertEquals(ReportsGeneratorState.REQUESTED, ((ReportsGeneratorImpl) generator).getState());
generator.unsubscribe(uri2);
Assert.assertEquals(0, generator.getSubscribers().size());
Assert.assertEquals(ReportsGeneratorState.UNREQUESTED, ((ReportsGeneratorImpl) generator).getState());
EasyMock.verify(validator);
}
示例8: run
import org.fosstrak.ale.server.ReportsGeneratorState; //导入依赖的package包/类
@Override
public void run() {
if(rgImpl.isStateRequested()) {
System.out.println("StartTrigger received when state was REQUESTED, so set the state to ACTIVE");
rgImpl.setState(ReportsGeneratorState.ACTIVE);
System.out.println("now the state is ACTIVE");
} else {
System.out.println("StartTrigger received, but state was not REQUESTED");
}
}
示例9: testUndefine
import org.fosstrak.ale.server.ReportsGeneratorState; //导入依赖的package包/类
/**
*
* tests the undefine method.
* @throws Exception test failure (or see what is expected by the test).
*/
//@Test
public void testUndefine() throws Exception {
ALEACImpl aleac = EasyMock.createMock(ALEACImpl.class);
((ALEImpl) ale).setAleac(aleac);
RemoveConfig persistenceRemoveMock = EasyMock.createMock(RemoveConfig.class);
persistenceRemoveMock.removeECSpec("spec");
EasyMock.expectLastCall();
EasyMock.replay(persistenceRemoveMock);
((ALEImpl) ale).setPersistenceRemoveAPI(persistenceRemoveMock);
ReportsGeneratorImpl reportGenerator = EasyMock.createMock(ReportsGeneratorImpl.class);
EasyMock.expect(reportGenerator.getState()).andReturn(ReportsGeneratorState.UNREQUESTED);
EasyMock.replay(reportGenerator);
ReportsGeneratorsProvider rgenProvider = EasyMock.createMock(ReportsGeneratorsProvider.class);
EasyMock.expect(rgenProvider.remove("spec")).andReturn(reportGenerator);
EasyMock.expect(rgenProvider.containsKey("spec")).andReturn(true);
EasyMock.expect(rgenProvider.get("spec")).andReturn(reportGenerator);
EasyMock.replay(rgenProvider);
((ALEImpl) ale).setReportGeneratorsProvider(rgenProvider);
ale.undefine("spec");
EasyMock.verify(rgenProvider);
EasyMock.verify(persistenceRemoveMock);
}
示例10: setStateRequested
import org.fosstrak.ale.server.ReportsGeneratorState; //导入依赖的package包/类
@Override
public void setStateRequested() {
setState(ReportsGeneratorState.REQUESTED);
}
示例11: setStateUnRequested
import org.fosstrak.ale.server.ReportsGeneratorState; //导入依赖的package包/类
@Override
public void setStateUnRequested() {
setState(ReportsGeneratorState.UNREQUESTED);
}
示例12: isStateRequested
import org.fosstrak.ale.server.ReportsGeneratorState; //导入依赖的package包/类
@Override
public boolean isStateRequested() {
return state == ReportsGeneratorState.REQUESTED;
}
示例13: isStateUnRequested
import org.fosstrak.ale.server.ReportsGeneratorState; //导入依赖的package包/类
@Override
public boolean isStateUnRequested() {
return state == ReportsGeneratorState.UNREQUESTED;
}
示例14: getState
import org.fosstrak.ale.server.ReportsGeneratorState; //导入依赖的package包/类
/**
* This method returns the state of this report generator.
* <strong>please notice that this method is not available through the ReportsGeneratorInterface.</strong>
*
* @return state the state of the generator.
*/
public ReportsGeneratorState getState() {
return state;
}
示例15: getState
import org.fosstrak.ale.server.ReportsGeneratorState; //导入依赖的package包/类
/**
* This method returns the state of this report generator.
* <strong>please notice that this method is not available through the ReportsGeneratorInterface.</strong>
*
* @return state the state of the generator.
*/
public synchronized ReportsGeneratorState getState() {
return state;
}