public RegisterPublisherResponseDocument registerPublisher(RegisterPublisherDocument requestDoc) {
// Check request.
RegisterPublisher publisherInfo = requestDoc.getRegisterPublisher();
ActiveMQTopic topic = TopicExpressionConverter.toActiveMQTopic(publisherInfo.getTopicArray());
Calendar terminationTime = publisherInfo.getInitialTerminationTime();
if (terminationTime != null) {
// Termination time cannot be in the past
if (terminationTime.before(Calendar.getInstance())) {
// Is this the right way to fault??
throw new NotificationException("Termination time cannot be in the past.");
}
// We could fault here if the time is too far in the future.
}
else {
// We could default a sensible timeout here.
}
// Create publisher and assoicate an EndpointReference with it.
EndpointReferenceType registrationEndpointReference;
try {
ActiveMQPublisherRegistration publisher = new ActiveMQPublisherRegistration(connection);
registrationEndpointReference = publisherManager.register(publisher);
publisher.setEndpointReference(registrationEndpointReference);
publisher.setTerminationTime(terminationTime);
publisher.setDemand(publisherInfo.getDemand());
if (publisherInfo.getDemand()) {
publisher.setPublisherReference(publisherInfo.getPublisherReference());
}
publisher.setTopic(topic);
publisher.start();