public function register(ServiceProviderInterface $instance)
    {

        // check if the service has already been registered
        if ($this->getServices()->has($pk = $instance->getPrimaryKey())) {
            throw new ServiceAlreadyRegisteredException(
                sprintf(
                    'It is not allowed to register service %s with primary key %s more than on times',
                    $instance->getServiceName(),
                    $pk
                )
            );
        }

        // register the service using the primary key
        $this->getServices()->set($pk, $instance);
    }
public function register(ServiceProviderInterface $instance)
    {

        // check if the service has already been registered
        if ($this->getServices()->has($pk = $instance->getPrimaryKey())) {
            throw new ServiceAlreadyRegisteredException(
                sprintf(
                    'It is not allowed to register service %s with primary key %s more than on times',
                    $instance->getServiceName(),
                    $pk
                )
            );
        }

        // register the service using the primary key
        $this->getServices()->set($pk, $instance);
    }
public function register ( ServiceProviderInterface $ instance ) { // check if the service has already been registered if ( $ this -> getServices ( ) -> has ( $ pk = $ instance -> getPrimaryKey ( ) ) ) { throw new ServiceAlreadyRegisteredException ( sprintf ( 'It is not allowed to register service %s with primary key %s more than on times' , $ instance -> getServiceName ( ) , $ pk ) ) ; } // register the service using the primary key $ this -> getServices ( ) -> set ( $ pk , $ instance ) ; }
Attaches the passed service, to the context.

@param \AppserverIo\Psr\EnterpriseBeans\ServiceProviderInterface $instance The service instance to attach

@return void
@throws \AppserverIo\Psr\EnterpriseBeans\ServiceAlreadyRegisteredException Is thrown if the passed service has already been registered
Attaches the passed service to the context .