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
015package org.apache.hivemind.internal;
016
017import org.apache.hivemind.Occurances;
018import org.apache.hivemind.schema.Schema;
019
020/**
021 * Sub-interface of {@link org.apache.hivemind.internal.ExtensionPoint} that defines a service
022 * extension point. A service may have a single factory contribution, and any number of interceptor
023 * contributions.
024 * 
025 * @author Howard Lewis Ship
026 */
027public interface ServicePoint extends ExtensionPoint
028{
029    /**
030     * Returns the type of the service, the interface the service implements. This may be a
031     * synthetic interface when the interface for the service point is, in fact, a class.
032     */
033    public Class getServiceInterface();
034
035    /**
036     * Returns the interface for the service as specified in the descriptor; starting with release
037     * 1.1 it is possible to define a service in terms of a class (as the interface) and a synthetic
038     * interface is generated where appropriate.
039     * 
040     * @since 1.1
041     */
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.tapestry.ApplicationRuntimeException
071     *             if there is any problem creating the service.
072     */
073    public Object getService(Class interfaceClass);
074
075    /**
076     * Returns the {@link Schema} used to process any parameters passed to the service. Service
077     * implementation factories and service interceptor factories allow parameters.
078     */
079
080    public Schema getParametersSchema();
081
082    /**
083     * Returns the number of parameter object expected; generally this is the default of exactly one (
084     * {@link Occurances#REQUIRED}).
085     */
086    public Occurances getParametersCount();
087
088    /**
089     * Forces the service to be fully instantiated immediately, rather than lazily.
090     */
091
092    public void forceServiceInstantiation();
093}