Author: gpetracek
Date: Mon Apr 28 10:56:13 2014
New Revision: 1590599
URL: http://svn.apache.org/r1590599
Log:
DELTASPIKE-572 thx to Rafael Benevides
Modified:
deltaspike/site/trunk/content/core.mdtext
Modified: deltaspike/site/trunk/content/core.mdtext
URL:
http://svn.apache.org/viewvc/deltaspike/site/trunk/content/core.mdtext?rev=1590599&r1=1590598&r2=1590599&view=diff
==============================================================================
--- deltaspike/site/trunk/content/core.mdtext (original)
+++ deltaspike/site/trunk/content/core.mdtext Mon Apr 28 10:56:13 2014
@@ -16,6 +16,24 @@ Notice: Licensed to the Apache Softwa
specific language governing permissions and limitations
under the License.
+Title: Core
+Notice: 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.
+
[TOC]
***
@@ -149,7 +167,7 @@ Excluding a bean if the project-stage is
{
}
-The following usage allows to exclude a bean based on a configured value (see
the supported config sources [TODO]).
+The following usage allows to exclude a bean based on a configured value (see
the [supported config
sources](configuration.html#configsources-provided-by-default)).
Excluding a bean based on an expression which eval. to true:
@@ -238,7 +256,33 @@ TODO (Overview)
## Literals
-TODO
+Literals allow the instantiation of annotations by extending the abstract
class 'javax.enterprise.util.AnnotationLiteral'
+
+**Example**
+
+ :::java
+ public abstract class PayByQualifier
+ extends AnnotationLiteral<PayBy>
+ implements PayBy {}
+
+ PayBy paybyCheque = new PayByQualifier() { public PaymentMethod value() {
return CHEQUE; } };
+
+DeltaSpike provides many annotation literals that you can use - e.g.:
+
+- AlternativeLiteral
+- AnyLiteral
+- ApplicationScopedLiteral
+- ConversationScopedLiteral
+- DefaultLiteral
+- DependentScopeLiteral
+- ModelLiteral
+- NamedLiteral
+- NewLiteral
+- RequestedScopeLiteral
+- SessionScopeLiteral
+- Singleton
+- SpecializesLiteral
+- TypedLiteral
## Messages & I18n
@@ -326,7 +370,46 @@ The following implementation shows the u
The following implementation creates an instance of `Message` for the key
`hello`. The final text will be resolved and interpolated lazily. Later on it
might be supported to provide a different `MessageContext` via
`#toString(MessageContext)` like it is in MyFaces CODI right now.
-[TODO]
+You can use `#argument(String)` to pass these arguments to the message
template specified on `#template(String)` method. The template pattern uses
printf-style format strings.
+
+ :::java
+ public class MyBean
+ {
+
+ @Inject
+ private MessageContext messageContext;
+
+ public void action()
+ {
+ Message message = this.messageContext.message();
+ write(message.template("Hello %s from
%s").argument("World").argument("DeltaSpike"));
+ }
+ //...
+ }
+
+Besides the static config via `@MessageContextConfig#messageSource`, you can
also specify the message sources dynamically.
+
+ :::java
+ @Inject
+ private MessageContext messageContext;
+
+ public void action()
+ {
+ Message message =
this.messageContext.messageSource("org.apache.deltaspike.example.message.Messages").message();
+
write(message.template("{hello}").argument("World").argument("DeltaSpike"));
+ }
+ //...
+ ->
+
+ org/apache/deltaspike/example/message/Messages.properties
+ org/apache/deltaspike/example/message/Messages_en.properties
+ org/apache/deltaspike/example/message/Messages_de.properties
+ ...
+
+ //content (as usual) in message bundle files:
+ hello=Hello %s from %s
+
+
### Customizing the message context
@@ -337,9 +420,17 @@ A message-resolver is responsible for cr
In case of a message-key, the message-resolver has to transform it to the
message-text by looking it up in a message source like a resource-bundle.
**Configuration of a message-resolver**
+
+Besides the static config via `@MessageContextConfig#messageResolver`, you can
use it dynamically via passing a custom message-resolver instance to the
current messageContext:
-[TODO]
+ :::java
+ @Inject
+ private MessageContext messageContext;
+ //...
+
+ Message message = this.messageContext.messageResolver(new
CustomMessageResolver()).message();
+
The result of a `MessageResolver` is the message-text. The text might contain
placeholders which are processed by a `MessageInterpolator`
#### MessageInterpolator
@@ -348,7 +439,15 @@ A `MessageInterpolator` replaces the pla
**Configuration of a message-interpolator**
-[TODO]
+Besides the static config via `@MessageContextConfig#messageInterpolator, you
can use it dynamically via passing a custom message-interpolator instance to
the current messageContext:
+
+ :::java
+ @Inject
+ private MessageContext messageContext;
+
+ //...
+ Message message = this.messageContext.messageInterpolator(new
CustomMessageInterpolator()).message();
+
#### LocaleResolver
@@ -356,8 +455,15 @@ A locale resolver provides the current l
**Configuration of a locale-resolver**
-[TODO]
+Besides the static config via `@MessageContextConfig#localeResolver, you can
use it dynamically via passing a custom locale-resolver instance to the current
messageContext:
+ :::java
+ @Inject
+ private MessageContext messageContext;
+
+ //...
+ Message message = this.messageContext.localeResolver(new
CustomLocaleResolver()).message();
+
## Injecting Resources
DeltaSpike has simple APIs for performing basic resource loading and property
file reading.
@@ -710,4 +816,54 @@ that exception chain, unless it's explic
# Core - Utils
-TODO
+DeltaSpike provides many utility-classes (no constructor / static methods)
that can be useful for your project.
+
+Below you can find an information about these classes.
+
+## ArraysUtils
+
+A collection of utilities for working with Arrays
+
+ - `#asSet` - Create a set from an array. If the array contains duplicate
objects, the last object in the array will be placed in resultant set.
+
+## BeanUtils
+
+A set of utility methods for working with beans.
+
+ - `#getQualifiers` - Extract the qualifiers from a set of annotations.
+ - `#extractAnnotation` - Extract the annotations.
+ - `#createInjectionPoints` - Given a method, and the bean on which the method
is declared, create a collection of injection points representing the
parameters of the method.
+
+## ClassDeactivationUtils
+
+Helper methods for `ClassDeactivator`
+
+ - `#isActivated` - Evaluates if the given `Deactivatable` is active.
+
+## ExceptionUtils
+
+Helper methods to deal with Exceptions
+
+ - `#throwAsRuntimeException` - helper which allows to use a trick to throw a
catched checked exception without a wrapping exception.
+ - `#changeAndThrowException` - helper which allows to use a trick to throw a
cached checked exception without a wrapping exception.
+
+## PropertyFileUtils
+
+Helper methods for Property files
+
+ - `#resolvePropertyFiles` - Allows to lookup for resource bundle files.
+ - `#loadProperties` - Load a Properties file from the given URL.
+ - `#getResourceBundle` - Return the ResourceBundle for the current default
Locale.
+
+## ProxyUtils
+
+Helper for CDI proxies
+
+ - `#getUnproxiedClass` - Return class of the real implementation.
+ - `#isProxiedClass` - Analyses if the given class is a generated proxy class.
+
+## StringUtils
+
+A collection of utilities for working with Strings.
+
+ - `#isEmpty` - return true if the String is null or empty (
`string.trim().isEmpty()` )
\ No newline at end of file