    001// Copyright 2006, 2007, 2011, 2012 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.tapestry5.ioc.internal.services;
    016
    017import org.apache.tapestry5.ioc.Messages;
    018import org.apache.tapestry5.ioc.internal.util.MessagesImpl;
    019import org.apache.tapestry5.ioc.services.Coercion;
    020import org.apache.tapestry5.plastic.PlasticUtils;
    021
    022public class ServiceMessages
    023{
    024    private final static Messages MESSAGES = MessagesImpl.forClass(ServiceMessages.class);
    025
    026    private ServiceMessages()
    027    {
    028    }
    029
    030    public static String noSuchProperty(Class clazz, String propertyName)
    031    {
    032        return MESSAGES.format("no-such-property", clazz.getName(), propertyName);
    033    }
    034
    035
    036    public static String readFailure(String propertyName, Object instance, Throwable cause)
    037    {
    038        return MESSAGES.format("read-failure", propertyName, instance, cause);
    039    }
    040
    041    public static String propertyTypeMismatch(String propertyName, Class sourceClass, Class propertyType,
    042                                              Class expectedType)
    043    {
    044        return MESSAGES.format("property-type-mismatch", propertyName, sourceClass.getName(), propertyType.getName(),
    045                expectedType.getName());
    046    }
    047
    048    public static String shutdownListenerError(Object listener, Throwable cause)
    049    {
    050        return MESSAGES.format("shutdown-listener-error", listener, cause);
    051    }
    052
    053    public static String failedCoercion(Object input, Class targetType, Coercion coercion, Throwable cause)
    054    {
    055        return MESSAGES.format("failed-coercion", String.valueOf(input), PlasticUtils.toTypeName(targetType),
    056                coercion, cause);
    057    }
    058
    059    public static String registryShutdown(String serviceId)
    060    {
    061        return MESSAGES.format("registry-shutdown", serviceId);
    062    }
    063
    064    public static String serviceBuildFailure(String serviceId, Throwable cause)
    065    {
    066        return MESSAGES.format("service-build-failure", serviceId, cause);
    067    }
    068}