Skip to content

Commit

Permalink
Rename all managers to loader except the ServiceBusManager
Browse files Browse the repository at this point in the history
  • Loading branch information
codeliner committed Jul 5, 2014
1 parent 04bb63f commit 8118088
Show file tree
Hide file tree
Showing 34 changed files with 224 additions and 227 deletions.
20 changes: 10 additions & 10 deletions src/Prooph/ServiceBus/Command/CommandReceiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Prooph\ServiceBus\Exception\RuntimeException;
use Prooph\ServiceBus\Message\MessageInterface;
use Prooph\ServiceBus\Service\Definition;
use Prooph\ServiceBus\Service\InvokeStrategyManager;
use Prooph\ServiceBus\Service\InvokeStrategyLoader;
use Zend\EventManager\EventManager;
use Zend\EventManager\EventManagerInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
Expand Down Expand Up @@ -50,7 +50,7 @@ class CommandReceiver implements CommandReceiverInterface
/**
* @var ServiceLocatorInterface
*/
protected $invokeStrategyManager;
protected $invokeStrategyLoader;

/**
* @var EventManagerInterface
Expand Down Expand Up @@ -101,7 +101,7 @@ public function handle(MessageInterface $aMessage)
$invokeStrategy = null;

foreach ($this->getInvokeStrategies() as $invokeStrategyName) {
$invokeStrategy = $this->getInvokeStrategyManager()->get($invokeStrategyName);
$invokeStrategy = $this->getInvokeStrategyLoader()->get($invokeStrategyName);

if ($invokeStrategy->canInvoke($handler, $command)) {
break;
Expand Down Expand Up @@ -164,23 +164,23 @@ public function getInvokeStrategies()
}

/**
* @param ServiceLocatorInterface $anInvokeStrategyManager
* @param ServiceLocatorInterface $anInvokeStrategyLoader
*/
public function setInvokeStrategyManager(ServiceLocatorInterface $anInvokeStrategyManager)
public function setInvokeStrategyLoader(ServiceLocatorInterface $anInvokeStrategyLoader)
{
$this->invokeStrategyManager = $anInvokeStrategyManager;
$this->invokeStrategyLoader = $anInvokeStrategyLoader;
}

/**
* @return ServiceLocatorInterface
*/
public function getInvokeStrategyManager()
public function getInvokeStrategyLoader()
{
if (is_null($this->invokeStrategyManager)) {
$this->invokeStrategyManager = new InvokeStrategyManager();
if (is_null($this->invokeStrategyLoader)) {
$this->invokeStrategyLoader = new InvokeStrategyLoader();
}

return $this->invokeStrategyManager;
return $this->invokeStrategyLoader;
}

public function events()
Expand Down
12 changes: 6 additions & 6 deletions src/Prooph/ServiceBus/Command/DefaultCommandBusFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Prooph\ServiceBus\Command;

use Prooph\ServiceBus\Exception\RuntimeException;
use Prooph\ServiceBus\Service\CommandBusManager;
use Prooph\ServiceBus\Service\CommandBusLoader;
use Prooph\ServiceBus\Service\Definition;
use Zend\ServiceManager\AbstractFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
Expand All @@ -36,7 +36,7 @@ class DefaultCommandBusFactory implements AbstractFactoryInterface
*/
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
return $serviceLocator instanceof CommandBusManager;
return $serviceLocator instanceof CommandBusLoader;
}

/**
Expand All @@ -50,11 +50,11 @@ public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator
*/
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
if (!$serviceLocator instanceof CommandBusManager) {
if (!$serviceLocator instanceof CommandBusLoader) {
throw new RuntimeException(
sprintf(
"%s is used in the wrong context. It can only be used within a'
. ' Prooph\ServiceBus\Service\CommandBusManager",
. ' Prooph\ServiceBus\Service\CommandBusLoader",
get_class($this)
)
);
Expand Down Expand Up @@ -122,9 +122,9 @@ public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $
);
}

$queue = $mainServiceLocator->get(Definition::QUEUE_MANAGER)->get($configuration[Definition::QUEUE]);
$queue = $mainServiceLocator->get(Definition::QUEUE_LOADER)->get($configuration[Definition::QUEUE]);

$messageDispatcher = $mainServiceLocator->get(Definition::MESSAGE_DISPATCHER_MANAGER)
$messageDispatcher = $mainServiceLocator->get(Definition::MESSAGE_DISPATCHER_LOADER)
->get($configuration[Definition::MESSAGE_DISPATCHER]);

$commandBus = new CommandBus($requestedName, $messageDispatcher, $queue);
Expand Down
14 changes: 7 additions & 7 deletions src/Prooph/ServiceBus/Command/DefaultCommandReceiverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Prooph\ServiceBus\Command;

use Prooph\ServiceBus\Exception\RuntimeException;
use Prooph\ServiceBus\Service\CommandReceiverManager;
use Prooph\ServiceBus\Service\CommandReceiverLoader;
use Prooph\ServiceBus\Service\Definition;
use Zend\ServiceManager\AbstractFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
Expand All @@ -35,7 +35,7 @@ class DefaultCommandReceiverFactory implements AbstractFactoryInterface
*/
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
return $serviceLocator instanceof CommandReceiverManager;
return $serviceLocator instanceof CommandReceiverLoader;
}

/**
Expand All @@ -49,11 +49,11 @@ public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator
*/
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
if (!$serviceLocator instanceof CommandReceiverManager) {
if (!$serviceLocator instanceof CommandReceiverLoader) {
throw new RuntimeException(
sprintf(
"%s is used in the wrong context. It can only be used within a'
. ' Prooph\ServiceBus\Service\CommandReceiverManager",
. ' Prooph\ServiceBus\Service\CommandReceiverLoader",
get_class($this)
)
);
Expand Down Expand Up @@ -120,9 +120,9 @@ public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $
);
}

if ($mainServiceLocator->has(Definition::INVOKE_STRATEGY_MANAGER)) {
$commandReceiver->setInvokeStrategyManager(
$mainServiceLocator->get(Definition::INVOKE_STRATEGY_MANAGER)
if ($mainServiceLocator->has(Definition::INVOKE_STRATEGY_LOADER)) {
$commandReceiver->setInvokeStrategyLoader(
$mainServiceLocator->get(Definition::INVOKE_STRATEGY_LOADER)
);
}

Expand Down
16 changes: 8 additions & 8 deletions src/Prooph/ServiceBus/Event/DefaultEventBusFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Prooph\ServiceBus\Exception\RuntimeException;
use Prooph\ServiceBus\Service\Definition;
use Prooph\ServiceBus\Service\EventBusManager;
use Prooph\ServiceBus\Service\EventBusLoader;
use Zend\ServiceManager\AbstractFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

Expand All @@ -35,7 +35,7 @@ class DefaultEventBusFactory implements AbstractFactoryInterface
*/
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
return $serviceLocator instanceof EventBusManager;
return $serviceLocator instanceof EventBusLoader;
}

/**
Expand All @@ -49,11 +49,11 @@ public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator
*/
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
if (!$serviceLocator instanceof EventBusManager) {
if (!$serviceLocator instanceof EventBusLoader) {
throw new RuntimeException(
sprintf(
"%s is used in the wrong context. It can only be used within a'
. ' Prooph\ServiceBus\Service\EventBusManager",
. ' Prooph\ServiceBus\Service\EventBusLoader",
get_class($this)
)
);
Expand Down Expand Up @@ -123,17 +123,17 @@ public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $

$queues = array();

$queueManager = $mainServiceLocator->get(Definition::QUEUE_MANAGER);
$queueLoader = $mainServiceLocator->get(Definition::QUEUE_LOADER);

if (is_string($configuration[Definition::QUEUE])) {
$queues[] = $queueManager->get($configuration[Definition::QUEUE]);
$queues[] = $queueLoader->get($configuration[Definition::QUEUE]);
} else {
foreach ($configuration[Definition::QUEUE] as $queueDefinition) {
$queues[] = $queueManager->get($queueDefinition);
$queues[] = $queueLoader->get($queueDefinition);
}
}

$messageDispatcher = $mainServiceLocator->get(Definition::MESSAGE_DISPATCHER_MANAGER)
$messageDispatcher = $mainServiceLocator->get(Definition::MESSAGE_DISPATCHER_LOADER)
->get($configuration[Definition::MESSAGE_DISPATCHER]);

$eventBus = new EventBus($requestedName, $messageDispatcher, $queues);
Expand Down
14 changes: 7 additions & 7 deletions src/Prooph/ServiceBus/Event/DefaultEventReceiverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Prooph\ServiceBus\Exception\RuntimeException;
use Prooph\ServiceBus\Service\Definition;
use Prooph\ServiceBus\Service\EventReceiverManager;
use Prooph\ServiceBus\Service\EventReceiverLoader;
use Zend\ServiceManager\AbstractFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

Expand All @@ -35,7 +35,7 @@ class DefaultEventReceiverFactory implements AbstractFactoryInterface
*/
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
return $serviceLocator instanceof EventReceiverManager;
return $serviceLocator instanceof EventReceiverLoader;
}

/**
Expand All @@ -49,11 +49,11 @@ public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator
*/
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
if (!$serviceLocator instanceof EventReceiverManager) {
if (!$serviceLocator instanceof EventReceiverLoader) {
throw new RuntimeException(
sprintf(
"%s is used in the wrong context. It can only be used within a'
. ' Prooph\ServiceBus\Service\EventReceiverManager",
. ' Prooph\ServiceBus\Service\EventReceiverLoader",
get_class($this)
)
);
Expand Down Expand Up @@ -120,9 +120,9 @@ public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $
);
}

if ($mainServiceLocator->has(Definition::INVOKE_STRATEGY_MANAGER)) {
$eventReceiver->setInvokeStrategyManager(
$mainServiceLocator->get(Definition::INVOKE_STRATEGY_MANAGER)
if ($mainServiceLocator->has(Definition::INVOKE_STRATEGY_LOADER)) {
$eventReceiver->setInvokeStrategyLoader(
$mainServiceLocator->get(Definition::INVOKE_STRATEGY_LOADER)
);
}

Expand Down
20 changes: 10 additions & 10 deletions src/Prooph/ServiceBus/Event/EventReceiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Prooph\ServiceBus\Exception\RuntimeException;
use Prooph\ServiceBus\Message\MessageInterface;
use Prooph\ServiceBus\Service\Definition;
use Prooph\ServiceBus\Service\InvokeStrategyManager;
use Prooph\ServiceBus\Service\InvokeStrategyLoader;
use Zend\EventManager\EventManager;
use Zend\EventManager\EventManagerInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
Expand Down Expand Up @@ -50,7 +50,7 @@ class EventReceiver implements EventReceiverInterface
/**
* @var ServiceLocatorInterface
*/
protected $invokeStrategyManager;
protected $invokeStrategyLoader;

/**
* @var EventManagerInterface
Expand Down Expand Up @@ -105,7 +105,7 @@ public function handle(MessageInterface $aMessage)
$invokeStrategy = null;

foreach ($this->getInvokeStrategies() as $invokeStrategyName) {
$invokeStrategy = $this->getInvokeStrategyManager()->get($invokeStrategyName);
$invokeStrategy = $this->getInvokeStrategyLoader()->get($invokeStrategyName);

if ($invokeStrategy->canInvoke($handler, $event)) {
break;
Expand Down Expand Up @@ -167,23 +167,23 @@ public function getInvokeStrategies()
}

/**
* @param ServiceLocatorInterface $anInvokeStrategyManager
* @param ServiceLocatorInterface $anInvokeStrategyLoader
*/
public function setInvokeStrategyManager(ServiceLocatorInterface $anInvokeStrategyManager)
public function setInvokeStrategyLoader(ServiceLocatorInterface $anInvokeStrategyLoader)
{
$this->invokeStrategyManager = $anInvokeStrategyManager;
$this->invokeStrategyLoader = $anInvokeStrategyLoader;
}

/**
* @return ServiceLocatorInterface
*/
public function getInvokeStrategyManager()
public function getInvokeStrategyLoader()
{
if (is_null($this->invokeStrategyManager)) {
$this->invokeStrategyManager = new InvokeStrategyManager();
if (is_null($this->invokeStrategyLoader)) {
$this->invokeStrategyLoader = new InvokeStrategyLoader();
}

return $this->invokeStrategyManager;
return $this->invokeStrategyLoader;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,16 @@ public function initializeLocalServiceBus(InitializeEvent $e)
$serviceBusManager->setService('configuration', $configuration);

/* @var $messageDispatcher \Prooph\ServiceBus\Message\InMemoryMessageDispatcher */
$messageDispatcher = $serviceBusManager->get('message_dispatcher_manager')->get('in_memory_message_dispatcher');
$messageDispatcher = $serviceBusManager->get(Definition::MESSAGE_DISPATCHER_LOADER)->get('in_memory_message_dispatcher');

$commandReceiverManager = $serviceBusManager->get('command_receiver_manager');
$commandReceiverLoader = $serviceBusManager->get(Definition::COMMAND_RECEIVER_LOADER);

$eventReceiverManager = $serviceBusManager->get('event_receiver_manager');
$eventReceiverLoader = $serviceBusManager->get(Definition::EVENT_RECEIVER_LOADER);

$queue = $serviceBusManager->get('queue_manager')->get('local-queue');
$queue = $serviceBusManager->get(Definition::QUEUE_LOADER)->get('local-queue');

$messageDispatcher->registerCommandReceiverManagerForQueue($queue, $commandReceiverManager);
$messageDispatcher->registerEventReceiverManagerForQueue($queue, $eventReceiverManager);
$messageDispatcher->registerCommandReceiverLoaderForQueue($queue, $commandReceiverLoader);
$messageDispatcher->registerEventReceiverLoaderForQueue($queue, $eventReceiverLoader);

$serviceBusManager->setAllowOverride(false);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Prooph/ServiceBus/Message/DefaultQueueFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator
{
try {
\Assert\that($requestedName)->notEmpty()->string();
\Assert\that($serviceLocator)->isInstanceOf("Prooph\ServiceBus\Service\QueueManager");
\Assert\that($serviceLocator)->isInstanceOf("Prooph\ServiceBus\Service\QueueLoader");
return true;
} catch (\InvalidArgumentException $ex) {
return false;
Expand Down
Loading

0 comments on commit 8118088

Please sign in to comment.