Top Description Inners Fields Constructors Methods
org.apache.logging.log4j.message

public Class DefaultFlowMessageFactory

extends Object
implements FlowMessageFactory, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.logging.log4j.message.FlowMessageFactory
Imports
java.io.Serializable, org.apache.logging.log4j.spi.AbstractLogger, org.apache.logging.log4j.util.LoaderUtil, .StringBuilderFormattable, .StringBuilders, .Strings

Default factory for flow messages.
Since
2.6

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final String
private final String
private static final String
private final String
private final MessageFactory
private static final long

Constructor Summary

AccessConstructor and Description
public
DefaultFlowMessageFactory()

Constructs a message factory with "Enter" and "Exit" as the default flow strings.

public
DefaultFlowMessageFactory(final String
the text to use for trace entry, like "Enter".
entryText
,
final String
the text to use for trace exit, like "Exit".
exitText
)

Constructs a message factory with the given entry and exit strings.

Method Summary

Modifier and TypeMethod and Description
private static MessageFactory
public String

Returns:

the entry text.
getEntryText
()

Gets the entry text.

public String

Returns:

the exit text.
getExitText
()

Gets the exit text.

private Message
makeImmutable(final Message message)

public EntryMessage
newEntryMessage(final String
format string
format
,
final Object...
parameters
params
)

Implements org.apache.logging.log4j.message.FlowMessageFactory.newEntryMessage.

Creates a new entry message based on a format string with parameters.

public EntryMessage
newEntryMessage(final Message
the original message
message
)

Implements org.apache.logging.log4j.message.FlowMessageFactory.newEntryMessage.

Creates a new entry message based on an existing message.

public ExitMessage
newExitMessage(final String
a format string
format
,
final Object
the return value
result
)

Implements org.apache.logging.log4j.message.FlowMessageFactory.newExitMessage.

Creates a new exit message based on a return value and a forma string.

public ExitMessage
newExitMessage(Message
the original entry message
message
)

Implements org.apache.logging.log4j.message.FlowMessageFactory.newExitMessage.

Creates a new exit message based on no return value and an existing message.

public ExitMessage
newExitMessage(final EntryMessage
the original entry message
message
)

Implements org.apache.logging.log4j.message.FlowMessageFactory.newExitMessage.

Creates a new exit message based on no return value and an existing entry message.

public ExitMessage
newExitMessage(final Object
the return value.
result
,
final EntryMessage
the original entry message
message
)

Implements org.apache.logging.log4j.message.FlowMessageFactory.newExitMessage.

Creates a new exit message based on a return value and an existing entry message.

public ExitMessage
newExitMessage(final Object
the return value.
result
,
final Message
the original message
message
)

Implements org.apache.logging.log4j.message.FlowMessageFactory.newExitMessage.

Creates a new exit message based on a return value and an existing message.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ENTRY_DEFAULT_PREFIXback to summary
private static final String ENTRY_DEFAULT_PREFIX
entryTextback to summary
private final String entryText
EXIT_DEFAULT_PREFIXback to summary
private static final String EXIT_DEFAULT_PREFIX
exitTextback to summary
private final String exitText
messageFactoryback to summary
private final MessageFactory messageFactory
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

DefaultFlowMessageFactoryback to summary
public DefaultFlowMessageFactory()

Constructs a message factory with "Enter" and "Exit" as the default flow strings.

DefaultFlowMessageFactoryback to summary
public DefaultFlowMessageFactory(final String entryText, final String exitText)

Constructs a message factory with the given entry and exit strings.

Parameters
entryText:String

the text to use for trace entry, like "Enter".

exitText:String

the text to use for trace exit, like "Exit".

Method Detail

createDefaultMessageFactoryback to summary
private static MessageFactory createDefaultMessageFactory()
getEntryTextback to summary
public String getEntryText()

Gets the entry text.

Returns:String

the entry text.

getExitTextback to summary
public String getExitText()

Gets the exit text.

Returns:String

the exit text.

makeImmutableback to summary
private Message makeImmutable(final Message message)
newEntryMessageback to summary
public EntryMessage newEntryMessage(final String format, final Object... params)

Implements org.apache.logging.log4j.message.FlowMessageFactory.newEntryMessage.

Doc from org.apache.logging.log4j.message.FlowMessageFactory.newEntryMessage.

Creates a new entry message based on a format string with parameters.

Parameters
format:String

format string

params:Object[]

parameters

Returns:EntryMessage

the new entry message

Annotations
@Override
newEntryMessageback to summary
public EntryMessage newEntryMessage(final Message message)

Implements org.apache.logging.log4j.message.FlowMessageFactory.newEntryMessage.

Doc from org.apache.logging.log4j.message.FlowMessageFactory.newEntryMessage.

Creates a new entry message based on an existing message.

Parameters
message:Message

the original message

Returns:EntryMessage

the new entry message

Annotations
@Override
newExitMessageback to summary
public ExitMessage newExitMessage(final String format, final Object result)

Implements org.apache.logging.log4j.message.FlowMessageFactory.newExitMessage.

Doc from org.apache.logging.log4j.message.FlowMessageFactory.newExitMessage.

Creates a new exit message based on a return value and a forma string.

Parameters
format:String

a format string

result:Object

the return value

Returns:ExitMessage

the new exit message

Annotations
@Override
newExitMessageback to summary
public ExitMessage newExitMessage(Message message)

Implements org.apache.logging.log4j.message.FlowMessageFactory.newExitMessage.

Doc from org.apache.logging.log4j.message.FlowMessageFactory.newExitMessage.

Creates a new exit message based on no return value and an existing message.

Parameters
message:Message

the original entry message

Returns:ExitMessage

the new exit message

Annotations
@Override
newExitMessageback to summary
public ExitMessage newExitMessage(final EntryMessage message)

Implements org.apache.logging.log4j.message.FlowMessageFactory.newExitMessage.

Doc from org.apache.logging.log4j.message.FlowMessageFactory.newExitMessage.

Creates a new exit message based on no return value and an existing entry message.

Parameters
message:EntryMessage

the original entry message

Returns:ExitMessage

the new exit message

Annotations
@Override
newExitMessageback to summary
public ExitMessage newExitMessage(final Object result, final EntryMessage message)

Implements org.apache.logging.log4j.message.FlowMessageFactory.newExitMessage.

Doc from org.apache.logging.log4j.message.FlowMessageFactory.newExitMessage.

Creates a new exit message based on a return value and an existing entry message.

Parameters
result:Object

the return value.

message:EntryMessage

the original entry message

Returns:ExitMessage

the new exit message

Annotations
@Override
newExitMessageback to summary
public ExitMessage newExitMessage(final Object result, final Message message)

Implements org.apache.logging.log4j.message.FlowMessageFactory.newExitMessage.

Doc from org.apache.logging.log4j.message.FlowMessageFactory.newExitMessage.

Creates a new exit message based on a return value and an existing message.

Parameters
result:Object

the return value.

message:Message

the original message

Returns:ExitMessage

the new exit message

Annotations
@Override
org.apache.logging.log4j.message back to summary

private Class DefaultFlowMessageFactory.AbstractFlowMessage

extends Object
implements FlowMessage, StringBuilderFormattable
Class Inheritance
  • java.lang.Object
  • org.apache.logging.log4j.message.DefaultFlowMessageFactory.AbstractFlowMessage
All Implemented Interfaces
org.apache.logging.log4j.util.StringBuilderFormattable, org.apache.logging.log4j.message.FlowMessage, org.apache.logging.log4j.message.Message, java.io.Serializable
Known Direct Subclasses
org.apache.logging.log4j.message.DefaultFlowMessageFactory.SimpleEntryMessage, org.apache.logging.log4j.message.DefaultFlowMessageFactory.SimpleExitMessage

Field Summary

Modifier and TypeField and Description
private final Message
private static final long
private final String

Constructor Summary

AccessConstructor and Description
pack-priv
AbstractFlowMessage(final String text, final Message message)

Method Summary

Modifier and TypeMethod and Description
public void
formatTo(final StringBuilder
the StringBuilder to write into
buffer
)

Implements org.apache.logging.log4j.util.StringBuilderFormattable.formatTo.

Writes a text representation of this object into the specified StringBuilder, ideally without allocating temporary objects.

public String
getFormat()

Implements org.apache.logging.log4j.message.Message.getFormat.

Gets the format portion of the Message.

public String
getFormattedMessage()

Implements org.apache.logging.log4j.message.Message.getFormattedMessage.

Gets the Message formatted as a String.

public Message
public Object[]
getParameters()

Implements org.apache.logging.log4j.message.Message.getParameters.

Gets parameter values, if any.

public String
getText()

Implements org.apache.logging.log4j.message.FlowMessage.getText.

The message text like "Enter" or "Exit" used to prefix the actual Message.

public Throwable
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

messageback to summary
private final Message message
serialVersionUIDback to summary
private static final long serialVersionUID
textback to summary
private final String text

Constructor Detail

AbstractFlowMessageback to summary
pack-priv AbstractFlowMessage(final String text, final Message message)

Method Detail

formatToback to summary
public void formatTo(final StringBuilder buffer)

Implements org.apache.logging.log4j.util.StringBuilderFormattable.formatTo.

Doc from org.apache.logging.log4j.util.StringBuilderFormattable.formatTo.

Writes a text representation of this object into the specified StringBuilder, ideally without allocating temporary objects.

Parameters
buffer:StringBuilder

the StringBuilder to write into

Annotations
@Override
getFormatback to summary
public String getFormat()

Implements org.apache.logging.log4j.message.Message.getFormat.

Doc from org.apache.logging.log4j.message.Message.getFormat.

Gets the format portion of the Message.

Returns:String

The message format. Some implementations, such as ParameterizedMessage, will use this as the message "pattern". Other Messages may simply return an empty String. TODO Do all messages have a format? What syntax? Using a Formatter object could be cleaner. (RG) In SimpleMessage the format is identical to the formatted message. In ParameterizedMessage and StructuredDataMessage it is not. It is up to the Message implementer to determine what this method will return. A Formatter is inappropriate as this is very specific to the Message implementation so it isn't clear to me how having a Formatter separate from the Message would be cleaner.

Annotations
@Override
getFormattedMessageback to summary
public String getFormattedMessage()

Implements org.apache.logging.log4j.message.Message.getFormattedMessage.

Doc from org.apache.logging.log4j.message.Message.getFormattedMessage.

Gets the Message formatted as a String. Each Message implementation determines the appropriate way to format the data encapsulated in the Message. Messages that provide more than one way of formatting the Message will implement MultiformatMessage.

When configured to log asynchronously, this method is called before the Message is queued, unless this message implements ReusableMessage or is annotated with AsynchronouslyFormattable. This gives the Message implementation class a chance to create a formatted message String with the current value of any mutable objects. The intention is that the Message implementation caches this formatted message and returns it on subsequent calls. (See LOG4J2-763.)

When logging synchronously, this method will not be called for Messages that implement the StringBuilderFormattable interface: instead, the formatTo(StringBuilder) method will be called so the Message can format its contents without creating intermediate String objects.

Returns:String

The message String.

Annotations
@Override
getMessageback to summary
public Message getMessage()

Implements org.apache.logging.log4j.message.FlowMessage.getMessage.

Doc from org.apache.logging.log4j.message.FlowMessage.getMessage.

The wrapped message

Returns:Message

the wrapped message

Annotations
@Override
getParametersback to summary
public Object[] getParameters()

Implements org.apache.logging.log4j.message.Message.getParameters.

Doc from org.apache.logging.log4j.message.Message.getParameters.

Gets parameter values, if any.

Returns:Object[]

An array of parameter values or null.

Annotations
@Override
getTextback to summary
public String getText()

Implements org.apache.logging.log4j.message.FlowMessage.getText.

Doc from org.apache.logging.log4j.message.FlowMessage.getText.

The message text like "Enter" or "Exit" used to prefix the actual Message.

Returns:String

message text used to prefix the actual Message.

Annotations
@Override
getThrowableback to summary
public Throwable getThrowable()

Implements org.apache.logging.log4j.message.Message.getThrowable.

Doc from org.apache.logging.log4j.message.Message.getThrowable.

Gets the throwable, if any.

Returns:Throwable

the throwable or null.

Annotations
@Override
org.apache.logging.log4j.message back to summary

private final Class DefaultFlowMessageFactory.SimpleEntryMessage

extends AbstractFlowMessage
implements EntryMessage
Class Inheritance
All Implemented Interfaces
org.apache.logging.log4j.message.EntryMessage, org.apache.logging.log4j.message.FlowMessage, org.apache.logging.log4j.message.Message, java.io.Serializable

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
SimpleEntryMessage(final String entryText, final Message message)

Method Summary

Inherited from org.apache.logging.log4j.message.DefaultFlowMessageFactory.AbstractFlowMessage:
formatTogetFormatgetFormattedMessagegetMessagegetParametersgetTextgetThrowable

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.logging.log4j.message.DefaultFlowMessageFactory.AbstractFlowMessage.serialVersionUID.

Constructor Detail

SimpleEntryMessageback to summary
pack-priv SimpleEntryMessage(final String entryText, final Message message)
org.apache.logging.log4j.message back to summary

private final Class DefaultFlowMessageFactory.SimpleExitMessage

extends AbstractFlowMessage
implements ExitMessage
Class Inheritance
All Implemented Interfaces
org.apache.logging.log4j.message.ExitMessage, org.apache.logging.log4j.message.FlowMessage, org.apache.logging.log4j.message.Message, java.io.Serializable

Field Summary

Modifier and TypeField and Description
private final boolean
private final Object
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
SimpleExitMessage(final String exitText, final EntryMessage message)

pack-priv
SimpleExitMessage(final String exitText, final Message message)

pack-priv
SimpleExitMessage(final String exitText, final Object result, final EntryMessage message)

pack-priv
SimpleExitMessage(final String exitText, final Object result, final Message message)

Method Summary

Modifier and TypeMethod and Description
public String
Inherited from org.apache.logging.log4j.message.DefaultFlowMessageFactory.AbstractFlowMessage:
formatTogetFormatgetMessagegetParametersgetTextgetThrowable

Field Detail

isVoidback to summary
private final boolean isVoid
resultback to summary
private final Object result
serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.logging.log4j.message.DefaultFlowMessageFactory.AbstractFlowMessage.serialVersionUID.

Constructor Detail

SimpleExitMessageback to summary
pack-priv SimpleExitMessage(final String exitText, final EntryMessage message)
SimpleExitMessageback to summary
pack-priv SimpleExitMessage(final String exitText, final Message message)
SimpleExitMessageback to summary
pack-priv SimpleExitMessage(final String exitText, final Object result, final EntryMessage message)
SimpleExitMessageback to summary
pack-priv SimpleExitMessage(final String exitText, final Object result, final Message message)

Method Detail

getFormattedMessageback to summary
public String getFormattedMessage()

Overrides org.apache.logging.log4j.message.DefaultFlowMessageFactory.AbstractFlowMessage.getFormattedMessage.

Implements org.apache.logging.log4j.message.Message.getFormattedMessage.

Doc from org.apache.logging.log4j.message.Message.getFormattedMessage.

Gets the Message formatted as a String. Each Message implementation determines the appropriate way to format the data encapsulated in the Message. Messages that provide more than one way of formatting the Message will implement MultiformatMessage.

When configured to log asynchronously, this method is called before the Message is queued, unless this message implements ReusableMessage or is annotated with AsynchronouslyFormattable. This gives the Message implementation class a chance to create a formatted message String with the current value of any mutable objects. The intention is that the Message implementation caches this formatted message and returns it on subsequent calls. (See LOG4J2-763.)

When logging synchronously, this method will not be called for Messages that implement the StringBuilderFormattable interface: instead, the formatTo(StringBuilder) method will be called so the Message can format its contents without creating intermediate String objects.

Returns:String

The message String.

Annotations
@Override