public Object getService()

in src/java/org/apache/turbine/services/BaseServiceBroker.java [535:585]


    public Object getService(String name) throws InstantiationException
    {
        Service service;

        if (this.isLocalService(name))
        {
	        try
	        {
	            service = getServiceInstance(name);
	            if (!service.getInit())
	            {
	                serviceLock.lock(); // was synchronized (service.getClass(), but should be equivalent
	                try {
	                    if (!service.getInit())
	                    {
	                        log.info("Start Initializing service (late): {}", name);
	                        service.init();
	                        log.info("Finish Initializing service (late): {}", name);
	                    }
	                } finally {
	                    serviceLock.unlock();
	                }
	            }
	            if (!service.getInit())
	            {
	                // this exception will be caught & rethrown by this very method.
	                // getInit() returning false indicates some initialization issue,
	                // which in turn prevents the InitableBroker from passing a
	                // reference to a working instance of the initable to the client.
	                throw new InitializationException(
	                        "init() failed to initialize service " + name);
	            }
	            return service;
	        }
	        catch (InitializationException e)
	        {
	            throw new InstantiationException("Service " + name +
	                    " failed to initialize", e);
	        }
        }
        else if (this.isNonLocalService(name))
        {
            return this.getNonLocalService(name);
        }
        else
        {
            throw new InstantiationException(
                "ServiceBroker: unknown service " + name
                + " requested");
        }
    }