001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.xbean.kernel.standard;
018    
019    import org.apache.xbean.kernel.Kernel;
020    import org.apache.xbean.kernel.ServiceContext;
021    import org.apache.xbean.kernel.ServiceFactory;
022    import org.apache.xbean.kernel.ServiceName;
023    
024    /**
025     * The standard service context implementation.  This is passed to the service factory in the
026     * {@link ServiceFactory#createService(ServiceContext)} and {@link ServiceFactory#destroyService(ServiceContext)}
027     * methods.
028     *
029     * @author Dain Sundstrom
030     * @version $Id$
031     * @since 2.0
032     */
033    public class StandardServiceContext implements ServiceContext {
034        private final Kernel kernel;
035        private final ServiceName serviceName;
036        private final ClassLoader classLoader;
037    
038        /**
039         * Creates the standard service context implementation.
040         *
041         * @param kernel the kernel in which the service is registered
042         * @param serviceName the name of the service
043         * @param classLoader the class loader for the service
044         */
045        public StandardServiceContext(Kernel kernel, ServiceName serviceName, ClassLoader classLoader) {
046            this.kernel = kernel;
047            this.serviceName = serviceName;
048            this.classLoader = classLoader;
049        }
050    
051        /**
052         * {@inheritDoc}
053         */
054        public Kernel getKernel() {
055            return kernel;
056        }
057    
058        /**
059         * {@inheritDoc}
060         */
061        public ServiceName getServiceName() {
062            return serviceName;
063        }
064    
065        /**
066         * {@inheritDoc}
067         */
068        public ClassLoader getClassLoader() {
069            return classLoader;
070        }
071    }