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 */ 017package org.apache.logging.log4j.message; 018 019/** 020 * Factory for the simplest possible implementation of Message, the Message String given as the constructor argument. 021 * <p> 022 * Creates {@link StringFormattedMessage} instances for 023 * {@link #newMessage(String, Object...)}. 024 * </p> 025 * <p> 026 * This class is immutable. 027 * </p> 028 * @since 2.5 029 */ 030public final class SimpleMessageFactory extends AbstractMessageFactory { 031 032 /** 033 * Instance of StringFormatterMessageFactory. 034 */ 035 public static final SimpleMessageFactory INSTANCE = new SimpleMessageFactory(); 036 private static final long serialVersionUID = 4418995198790088516L; 037 038 /** 039 * Creates {@link StringFormattedMessage} instances. 040 * 041 * @param message 042 * The message pattern. 043 * @param params 044 * The parameters to the message. 045 * @return The Message. 046 * 047 * @see MessageFactory#newMessage(String, Object...) 048 */ 049 @Override 050 public Message newMessage(final String message, final Object... params) { 051 return new SimpleMessage(message); 052 } 053}