001    // Copyright 2004, 2005 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.hivemind.internal;
016    
017    import org.apache.hivemind.definition.ServicePointDefinition;
018    
019    /**
020     * Sub-interface of {@link org.apache.hivemind.internal.ExtensionPoint} that defines a service
021     * extension point. A service may have a single factory contribution, and any number of interceptor
022     * contributions.
023     * 
024     * @author Howard Lewis Ship
025     */
026    public interface ServicePoint extends ExtensionPoint
027    {
028        /**
029         * Returns the type of the service, the interface the service implements. This may be a
030         * synthetic interface when the interface for the service point is, in fact, a class.
031         * It equals the class returned by {@link #getDeclaredInterface()} if the declared interface
032         * is a real interface and not a class. 
033         */
034        public Class getServiceInterface();
035    
036        /**
037         * Returns the interface for the service as specified in the descriptor; starting with release
038         * 1.1 it is possible to define a service in terms of a class (as the interface).
039         * In that case the POJO class is returned here.
040         * 
041         * @since 1.1
042         */
043        public Class getDeclaredInterface();
044    
045        /**
046         * Returns the fully qualified class name of the service interface. This is useful so that
047         * loading the actual service interface class can be deferred as late as possible. This is the
048         * value, as specified in the descriptor (except that simple names in the descriptor are
049         * prefixed with the module's package name). Starting in release 1.1, this may be the name of a
050         * ordinary class, not an interface.
051         * 
052         * @since 1.1
053         */
054    
055        public String getServiceInterfaceClassName();
056    
057        /**
058         * Obtains the full service implementation for this service extension point, an object that
059         * implements the service interface. Because of the different service models, and because of the
060         * possibility of interceptors, the exact class and object returned can't be specified (and may
061         * vary at different times), but that is not relevant to client code, which is assured that it
062         * can invoke the service methods defined by the service interface.
063         * 
064         * @param interfaceClass
065         *            the class that the service will be cast to; a check is made that the service is
066         *            assignable to the indicated interface. It does not have to, necessarily, match the
067         *            service interface (it could be a super-interface, for example).
068         * @return the outermost interceptor for the service, or the core implementation if there are no
069         *         interceptors.
070         * @throws org.apache.hivemind.ApplicationRuntimeException
071         *             if there is any problem creating the service.
072         */
073        public Object getService(Class interfaceClass);
074    
075        /**
076         * Forces the service to be fully instantiated immediately, rather than lazily.
077         */
078    
079        public void forceServiceInstantiation();
080        
081        public ServicePointDefinition getServicePointDefinition();
082    
083    }