public function registerEpbReference(EpbReferenceDescriptorInterface $epbReference)
{
try {
// load the application instance and reference name
$application = $this->getApplication();
$name = $epbReference->getName();
// initialize the bean's URI
$uri = sprintf('php:global/%s/%s', $application->getUniqueName(), $name);
// this has to be refactored, because it'll be quite faster to inject either
// the remote/local proxy instance as injection a callback that creates the
// proxy on-the-fly!
// prepare the bean name
if ($beanName = $epbReference->getBeanName()) {
// query whether we've a local business interface
if ($epbReference->getBeanInterface() === sprintf('%sLocal', $beanName)) {
// bind the local business interface of the bean to the appliations naming directory
$application->getNamingDirectory()->bind($uri, array(&$this, 'lookupProxy'), array(sprintf('%s/local', $beanName)));
// query whether we've a remote business interface
} elseif ($epbReference->getBeanInterface() === sprintf('%sRemote', $beanName)) {
// bind the remote business interface of the bean to the applications naming directory
$application->getNamingDirectory()->bind($uri, array(&$this, 'lookupProxy'), array(sprintf('%s/remote', $beanName)));
// at least, we need a business interface
} else {
// log a critical message that we can't bind the reference
$application->getInitialContext()->getSystemLogger()->critical(sprintf('Can\'t bind bean reference %s to naming directory', $uri));
}
// try to use the lookup, if we don't have the beanName
} elseif ($lookup = $epbReference->getLookup()) {
// create a reference to a bean in the global directory
$application->getNamingDirectory()->bind($uri, array(&$this, 'lookup'), array($lookup));
// log a critical message that we can't bind the reference
} else {
$application->getInitialContext()->getSystemLogger()->critical(sprintf('Can\'t bind bean reference %s to naming directory, because of missing source bean definition', $uri));
}
// catch the the exception that occures if a reference has already been created
} catch (NamingException $e) {
// log a warning that the reference has already been registered
$application->getInitialContext()->getSystemLogger()->warning(sprintf('Bean reference %s already exists', $uri));
// catch all other exceptions
} catch (\Exception $e) {
$application->getInitialContext()->getSystemLogger()->critical($e->__toString());
}
}