All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.deltaspike.core.api.message.MessageBundle Maven / Gradle / Ivy

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.deltaspike.core.api.message;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 

Marker annotation for a message-bundle interface which provides type-safe messages.

* *

This annotation must only be used on interfaces. * If this annotation gets used on a concrete class, a deployment error results!

* *

Type-safe Messages

*

Each method on an interface annotated with @MessageBundle * will form a type-safe message. The message lookup key * (resource bundle key) can either be defined by annotating those methods * with @{@link MessageTemplate}) or by convention. if no @{@link MessageTemplate} * annotation is used on a method, the case sensitive method-name name * will be used as resource key.

* *

Message Parameters

*

The parameters of the declared methods will be automatically passed * as message parameters to the {@link org.apache.deltaspike.core.api.message.MessageResolver}. * Please note that all passed parameters should be {@link java.io.Serializable}. * If a parameter is not Serializable, we will instead store the toString() * of the passed parameter.

* * *

Message Sources

*

The {@link java.util.ResourceBundle} or other resource lookup source which might be used is * determined by the {@link org.apache.deltaspike.core.api.message.MessageResolver} * in conjunction with * {@link org.apache.deltaspike.core.api.message.MessageContext#messageSource(String...)}. * The fully qualified class name of the interface annotated with * @MessageBundle will automatically be registered as additional * messageSource for those messages.

* * *

@MessageBundle can be combined with {@link MessageContextConfig} * to further customize the message-resolution and processing process.

* *

Debug hint: Set a breakpoint in MessageBundleInvocationHandler#invoke. * This will get called for every message bundle invocation.

*/ @Target({ TYPE }) @Retention(RUNTIME) @Documented public @interface MessageBundle { }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy