private function isDefinitionShared(Definition $definition)
    {
        if (method_exists($definition, 'isShared')) {
            return $definition->isShared();
        } else if (method_exists($definition, 'getScope')) {
            return $definition->getScope() !== ContainerBuilder::SCOPE_PROTOTYPE;
        }

        return false;
    }