Weld SVN: r4727 - core/trunk/osgi-bundle.
by weld-commits@lists.jboss.org
Author: rogerk
Date: 2009-11-07 08:50:47 -0500 (Sat, 07 Nov 2009)
New Revision: 4727
Modified:
core/trunk/osgi-bundle/pom.xml
Log:
slf4j dependency
Modified: core/trunk/osgi-bundle/pom.xml
===================================================================
--- core/trunk/osgi-bundle/pom.xml 2009-11-07 13:50:26 UTC (rev 4726)
+++ core/trunk/osgi-bundle/pom.xml 2009-11-07 13:50:47 UTC (rev 4727)
@@ -56,7 +56,7 @@
<instructions>
<_include>-osgi.bundle</_include>
- <Embed-Dependency>*; scope=compile; inline=true</Embed-Dependency>
+ <Embed-Dependency>*; scope=compile; inline=true, slf4j-jdk14; inline=true</Embed-Dependency>
<_exportcontents>
javax.inject;
@@ -82,15 +82,28 @@
javassist.util.proxy;version=${javassist.version}
</_exportcontents>
+ <!-- A note about how slf4j is handled:
+ We optionally import slf4j APIs (i.e. packages that are part of slf4j-api.jar).
+ We also bundle them privately along with the jdk14-logging binding.
+ This allows us to function even when there is no separate slf4j bundle.
+ When there is a separate slf4j bundle, because of our optional Import-Package header,
+ we will get wired to that bundle. Please also note that we don't import impl package,
+ as it is sufficient to import just the api. In some other environment, user can
+ deploy slf4j-api bundle and their desired binding bundle. The binding bundle is
+ a fragement which attaches itself to the api bundle. We will get wired to the
+ api bundle and everything will work.
+ We also bundle all the slf4j extension and cal10n stuff to avoid having dependency
+ on foreign bundles.
+ -->
<Import-Package>
- org.slf4j.cal10n; version=${slf4j.version},
- ch.qos.cal10n; version=${cal10n.version},
+ org.slf4j; org.slf4j.spi; org.slf4j.helpers; version=${slf4j.version}; resolution:=optional,
+ ch.qos.cal10n; version=${cal10n.version}; resolution:=optional,
javax.interceptor.*, *;
resolution:=optional
</Import-Package>
<Private-Package>
- !javax.interceptor.*
+ !javax.interceptor.*, org.slf4j.*; -split-package:=merge-first, ch.qos.cal10n.*
</Private-Package>
</instructions>
@@ -159,6 +172,13 @@
<artifactId>jboss-interceptor</artifactId>
</dependency>
+ <!-- We bundle jdk binding inside this OSGi bundle -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
</dependencies>
</project>
16 years, 5 months
Weld SVN: r4726 - core/trunk/parent.
by weld-commits@lists.jboss.org
Author: rogerk
Date: 2009-11-07 08:50:26 -0500 (Sat, 07 Nov 2009)
New Revision: 4726
Modified:
core/trunk/parent/pom.xml
Log:
slf4j dependency
Modified: core/trunk/parent/pom.xml
===================================================================
--- core/trunk/parent/pom.xml 2009-11-07 06:58:28 UTC (rev 4725)
+++ core/trunk/parent/pom.xml 2009-11-07 13:50:26 UTC (rev 4726)
@@ -162,6 +162,12 @@
<version>${slf4j.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+
</dependencies>
</dependencyManagement>
16 years, 5 months
Weld SVN: r4725 - in core/trunk: impl/src/main/java/org/jboss/weld/bean and 11 other directories.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2009-11-07 01:58:28 -0500 (Sat, 07 Nov 2009)
New Revision: 4725
Added:
core/trunk/impl/src/main/java/org/jboss/weld/bean/AnnotatedItemProvidingDecoratorWrapper.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/AfterBeanDiscoveryObserver.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/CustomDecorator.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/CustomDecoratorTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/CustomFrame.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/InnerFrame.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/OuterFrame.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/Window.java
core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/custom/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/custom/beans-custom-only.xml
core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/custom/beans.xml
core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/custom/javax.enterprise.inject.spi.Extension
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/Validator.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/RIBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployment.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AfterBeanDiscoveryImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java
core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties
Log:
WELD-253, WELD-254: Adding support for custom decorators.
- Creating an initializeAfterBeanDiscovery method that RIBeans can implement to perform initialization after all beans have been deployed (in this particular case this is necessary as decorators for a bean may be deployed *after* the decorated bean has been deployed).
- Creating a wrapper class to enhance custom Decorator beans with WeldClass data at deployment time (thus avoiding evaluation of such data at runtime)
Modified: core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java 2009-11-07 06:54:43 UTC (rev 4724)
+++ core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -254,7 +254,7 @@
* archives
*/
private transient final TypeSafeBeanResolver<Bean<?>> beanResolver;
- private transient final TypeSafeResolver<? extends Resolvable, DecoratorImpl<?>> decoratorResolver;
+ private transient final TypeSafeResolver<? extends Resolvable, Decorator<?>> decoratorResolver;
private transient final TypeSafeResolver<? extends Resolvable, Interceptor<?>> interceptorResolver;
private transient final TypeSafeResolver<? extends Resolvable, ObserverMethod<?>> observerResolver;
private transient final NameBasedResolver nameBasedResolver;
@@ -272,7 +272,7 @@
*/
private transient final List<Bean<?>> beans;
private transient final List<Bean<?>> transitiveBeans;
- private transient final List<DecoratorImpl<?>> decorators;
+ private transient final List<Decorator<?>> decorators;
private transient final List<Interceptor<?>> interceptors;
private transient final List<String> namespaces;
private transient final List<ObserverMethod<?>> observers;
@@ -326,7 +326,7 @@
serviceRegistry,
new CopyOnWriteArrayList<Bean<?>>(),
new CopyOnWriteArrayList<Bean<?>>(),
- new CopyOnWriteArrayList<DecoratorImpl<?>>(),
+ new CopyOnWriteArrayList<Decorator<?>>(),
new CopyOnWriteArrayList<Interceptor<?>>(),
new CopyOnWriteArrayList<ObserverMethod<?>>(),
new CopyOnWriteArrayList<String>(),
@@ -355,7 +355,7 @@
services,
new CopyOnWriteArrayList<Bean<?>>(),
new CopyOnWriteArrayList<Bean<?>>(),
- new CopyOnWriteArrayList<DecoratorImpl<?>>(),
+ new CopyOnWriteArrayList<Decorator<?>>(),
new CopyOnWriteArrayList<Interceptor<?>>(),
new CopyOnWriteArrayList<ObserverMethod<?>>(),
new CopyOnWriteArrayList<String>(),
@@ -421,7 +421,7 @@
ServiceRegistry serviceRegistry,
List<Bean<?>> beans,
List<Bean<?>> transitiveBeans,
- List<DecoratorImpl<?>> decorators,
+ List<Decorator<?>> decorators,
List<Interceptor<?>> interceptors,
List<ObserverMethod<?>> observers,
List<String> namespaces,
@@ -555,10 +555,10 @@
};
- public static Transform<DecoratorImpl<?>> DECORATOR_BEAN = new Transform<DecoratorImpl<?>>()
+ public static Transform<Decorator<?>> DECORATOR_BEAN = new Transform<Decorator<?>>()
{
- public Iterable<DecoratorImpl<?>> transform(BeanManagerImpl beanManager)
+ public Iterable<Decorator<?>> transform(BeanManagerImpl beanManager)
{
return beanManager.getDecorators();
}
@@ -634,7 +634,7 @@
beanResolver.clear();
}
- public void addDecorator(DecoratorImpl<?> bean)
+ public void addDecorator(Decorator<?> bean)
{
decorators.add(bean);
getServices().get(ContextualStore.class).putIfAbsent(bean);
@@ -841,7 +841,7 @@
return Collections.unmodifiableList(transitiveBeans);
}
- public List<DecoratorImpl<?>> getDecorators()
+ public List<Decorator<?>> getDecorators()
{
return Collections.unmodifiableList(decorators);
}
@@ -1033,12 +1033,12 @@
}
}
-
+
public Object getInjectableReference(InjectionPoint injectionPoint, CreationalContext<?> creationalContext)
{
- WeldAnnotated<?, ?> element = ResolvableWeldClass.of(injectionPoint.getType(), injectionPoint.getQualifiers().toArray(new Annotation[0]), this);
- Bean<?> resolvedBean = getBean(element, element.getBindingsAsArray());
- return getReference(injectionPoint, resolvedBean, creationalContext);
+ WeldAnnotated<?, ?> element = ResolvableWeldClass.of(injectionPoint.getType(), injectionPoint.getQualifiers().toArray(new Annotation[0]), this);
+ Bean<?> resolvedBean = getBean(element, element.getBindingsAsArray());
+ return getReference(injectionPoint, resolvedBean, creationalContext);
}
/**
Modified: core/trunk/impl/src/main/java/org/jboss/weld/Validator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/Validator.java 2009-11-07 06:54:43 UTC (rev 4724)
+++ core/trunk/impl/src/main/java/org/jboss/weld/Validator.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -353,9 +353,9 @@
{
// TODO Move building this list to the boot or sth
Set<Class<?>> decoratorBeanClasses = new HashSet<Class<?>>();
- for (DecoratorImpl<?> bean : beanManager.getDecorators())
+ for (Decorator<?> bean : beanManager.getDecorators())
{
- decoratorBeanClasses.add(bean.getType());
+ decoratorBeanClasses.add(bean.getBeanClass());
}
for (Class<?> clazz : beanManager.getEnabledDecoratorClasses())
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java 2009-11-07 06:54:43 UTC (rev 4724)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -373,8 +373,8 @@
}
/**
- * Returns the annotated time the bean represents
- *
+ * Returns the annotated item the bean represents
+ *
* @return The annotated item
*/
public abstract WeldAnnotated<T, S> getAnnotatedItem();
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2009-11-07 06:54:43 UTC (rev 4724)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -88,11 +88,11 @@
private List<Set<FieldInjectionPoint<?, ?>>> injectableFields;
// The initializer methods of each type in the type hierarchy, with the actual type at the bottom
private List<Set<MethodInjectionPoint<?, ?>>> initializerMethods;
-
+
private List<Decorator<?>> decorators;
-
+
private Class<T> proxyClassForDecorators;
-
+
private final ThreadLocal<Integer> decoratorStackPosition;
private final ThreadLocal<T> decoratedActualInstance = new ThreadLocal<T>();
@@ -138,47 +138,54 @@
checkBeanImplementation();
initDecorators();
checkType();
- initProxyClassForDecoratedBean();
if (isInterceptionCandidate())
{
initCdiBoundInterceptors();
initDirectlyDefinedInterceptors();
}
}
-
+
+ @Override
+ public void initializeAfterBeanDiscovery()
+ {
+ super.initializeAfterBeanDiscovery();
+ initDecorators();
+ if (hasDecorators())
+ {
+ initProxyClassForDecoratedBean();
+ }
+ }
+
protected void checkType()
{
}
-
- protected void initDecorators()
+
+ public void initDecorators()
{
this.decorators = getManager().resolveDecorators(getTypes(), getQualifiers());
}
-
+
public boolean hasDecorators()
{
return this.decorators != null && this.decorators.size() > 0;
}
-
+
protected void initProxyClassForDecoratedBean()
{
- if (hasDecorators())
- {
- Set<Type> types = new LinkedHashSet<Type>(getTypes());
- types.add(TargetInstanceProxy.class);
- ProxyFactory proxyFactory = Proxies.getProxyFactory(types);
-
- @SuppressWarnings("unchecked")
- Class<T> proxyClass = proxyFactory.createClass();
-
- this.proxyClassForDecorators = proxyClass;
- }
+ Set<Type> types = new LinkedHashSet<Type>(getTypes());
+ types.add(TargetInstanceProxy.class);
+ ProxyFactory proxyFactory = Proxies.getProxyFactory(types);
+
+ @SuppressWarnings("unchecked")
+ Class<T> proxyClass = proxyFactory.createClass();
+
+ this.proxyClassForDecorators = proxyClass;
}
-
+
protected T applyDecorators(T instance, CreationalContext<T> creationalContext, InjectionPoint originalInjectionPoint)
{
- List<SerializableContextualInstance<DecoratorImpl<Object>, Object>> decoratorInstances = new ArrayList<SerializableContextualInstance<DecoratorImpl<Object>,Object>>();
+ List<SerializableContextualInstance<Decorator<Object>, Object>> decoratorInstances = new ArrayList<SerializableContextualInstance<Decorator<Object>,Object>>();
InjectionPoint ip = originalInjectionPoint;
boolean outside = decoratorStackPosition.get().intValue() == 0;
if (outside)
@@ -192,18 +199,13 @@
while (i < decorators.size())
{
Decorator<?> decorator = decorators.get(i);
- if (decorator instanceof DecoratorImpl<?>)
- {
decoratorStackPosition.set(++i);
-
- @SuppressWarnings("unchecked")
- DecoratorImpl<Object> decoratorBean = (DecoratorImpl<Object>) decorator;
-
- Object decoratorInstance = getManager().getReference(ip, decorator, creationalContext);
- decoratorInstances.add(new SerializableContextualInstanceImpl<DecoratorImpl<Object>, Object>(decoratorBean, decoratorInstance, null));
- ip = decoratorBean.getDelegateInjectionPoint();
- }
- else
+
+ Object decoratorInstance = getManager().getReference(ip, decorator, creationalContext);
+ decoratorInstances.add(new SerializableContextualInstanceImpl<Decorator<Object>, Object>((Decorator<Object>) decorator, decoratorInstance, null));
+
+ ip = Beans.getDelegateInjectionPoint(decorator);
+ if (ip == null)
{
throw new IllegalStateException("Cannot operate on non container provided decorator " + decorator);
}
Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/AnnotatedItemProvidingDecoratorWrapper.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AnnotatedItemProvidingDecoratorWrapper.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AnnotatedItemProvidingDecoratorWrapper.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright <Year>, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed 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.jboss.weld.bean;
+
+import javax.enterprise.inject.spi.Decorator;
+
+import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.introspector.WeldClass;
+import org.jboss.weld.resources.ClassTransformer;
+
+/**
+ * A wrapper for a decorated instance. Allows to enhance custom decorators with metadata
+ * about the WeldClass at deployment time.
+ *
+ * @author Marius Bogoevici
+ */
+public class AnnotatedItemProvidingDecoratorWrapper extends ForwardingDecorator<Object>
+{
+ private Decorator<Object> delegate;
+ private WeldClass<?> annotatedItem;
+
+ public static AnnotatedItemProvidingDecoratorWrapper of(Decorator<?> delegate, BeanManagerImpl beanManager)
+ {
+ return new AnnotatedItemProvidingDecoratorWrapper((Decorator<Object>) delegate, beanManager);
+ }
+
+ private AnnotatedItemProvidingDecoratorWrapper(Decorator<Object> delegate, BeanManagerImpl beanManager)
+ {
+ this.delegate = delegate;
+ ClassTransformer transformer = beanManager.getServices().get(ClassTransformer.class);
+ Class<?> beanClass = delegate.getBeanClass();
+ this.annotatedItem = transformer.loadClass(beanClass);
+ }
+
+ @Override
+ protected Decorator<Object> delegate()
+ {
+ return delegate;
+ }
+
+ public WeldClass<?> getAnnotatedItem()
+ {
+ return annotatedItem;
+ }
+}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java 2009-11-07 06:54:43 UTC (rev 4724)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -37,7 +37,7 @@
public class DecoratorImpl<T> extends ManagedBean<T> implements Decorator<T>
{
- public static <T> Decorator<T> wrapForResolver(final Decorator<T> decorator)
+ public static <T> Decorator<T> wrap(final Decorator<T> decorator)
{
return new ForwardingDecorator<T>()
{
@@ -201,19 +201,9 @@
{
return delegateInjectionPoint;
}
-
- /**
- * The type closure of the delegate type
- *
- * @return the delegateTypes
- */
- public Set<Type> getDelegateTypes()
- {
- return delegateTypes;
- }
@Override
- protected void initDecorators()
+ public void initDecorators()
{
// No-op, decorators can't have decorators
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java 2009-11-07 06:54:43 UTC (rev 4724)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -19,7 +19,7 @@
import static org.jboss.weld.logging.Category.BEAN;
import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
import static org.jboss.weld.logging.messages.BeanMessage.ERROR_DESTROYING;
-import static org.jboss.weld.logging.messages.BeanMessage.USER_DEFINED_DECORATOR_DISALLOWED;
+import static org.jboss.weld.logging.messages.BeanMessage.DELEGATE_INJECTION_POINT_NOT_FOUND;
import java.util.ArrayList;
import java.util.List;
@@ -140,15 +140,11 @@
protected InjectionPoint attachCorrectInjectionPoint()
{
Decorator<?> decorator = getDecorators().get(getDecorators().size() - 1);
- if (decorator instanceof DecoratorImpl<?>)
- {
- DecoratorImpl<?> decoratorBean = (DecoratorImpl<?>) decorator;
- InjectionPoint outerDelegateInjectionPoint = decoratorBean.getDelegateInjectionPoint();
- return getManager().replaceOrPushCurrentInjectionPoint(outerDelegateInjectionPoint);
- } else
- {
- throw new IllegalStateException(messageConveyer.getMessage(USER_DEFINED_DECORATOR_DISALLOWED, decorator));
+ InjectionPoint outerDelegateInjectionPoint = Beans.getDelegateInjectionPoint(decorator);
+ if (outerDelegateInjectionPoint == null)
+{ throw new IllegalStateException(messageConveyer.getMessage(DELEGATE_INJECTION_POINT_NOT_FOUND, decorator));
}
+ return getManager().replaceOrPushCurrentInjectionPoint(outerDelegateInjectionPoint);
}
/**
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/RIBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/RIBean.java 2009-11-07 06:54:43 UTC (rev 4724)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/RIBean.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -25,6 +25,7 @@
import org.jboss.weld.BeanManagerImpl;
import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
+import org.jboss.weld.bootstrap.api.Environment;
import org.jboss.weld.injection.WeldInjectionPoint;
/**
@@ -63,6 +64,19 @@
public abstract void initialize(BeanDeployerEnvironment environment);
+ /**
+ * In particular cases, the deployer must perform some initialization operations
+ * only after all beans have been deployed (e.g. for initializing decorators
+ * taking into account the possibility of having custom decorators which are
+ * deployed through portable extensions)
+ *
+ * @param environment
+ */
+ public void initializeAfterBeanDiscovery()
+ {
+ // no-op by default
+ }
+
public abstract boolean isSpecializing();
public boolean isDependent()
@@ -120,6 +134,6 @@
}
public abstract String getDescription();
-
+
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java 2009-11-07 06:54:43 UTC (rev 4724)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -21,7 +21,10 @@
import java.lang.reflect.Method;
import java.util.List;
+import javax.enterprise.inject.spi.Decorator;
+
import org.jboss.interceptor.util.proxy.TargetInstanceProxyMethodHandler;
+import org.jboss.weld.bean.AnnotatedItemProvidingDecoratorWrapper;
import org.jboss.weld.bean.DecoratorImpl;
import org.jboss.weld.introspector.MethodSignature;
import org.jboss.weld.introspector.WeldMethod;
@@ -38,7 +41,7 @@
{
private static final long serialVersionUID = 4577632640130385060L;
- private final List<SerializableContextualInstance<DecoratorImpl<Object>, Object>> decoratorInstances;
+ private final List<SerializableContextualInstance<Decorator<Object>, Object>> decoratorInstances;
/**
* Constructor
@@ -47,7 +50,7 @@
*
* @param proxy The generic proxy
*/
- public DecoratorProxyMethodHandler(List<SerializableContextualInstance<DecoratorImpl<Object>, Object>> decoratorInstances, Object instance)
+ public DecoratorProxyMethodHandler(List<SerializableContextualInstance<Decorator<Object>, Object>> decoratorInstances, Object instance)
{
super (instance, instance.getClass());
this.decoratorInstances = decoratorInstances;
@@ -73,9 +76,21 @@
protected Object doInvoke(Object self, Method method, Method proceed, Object[] args) throws Throwable
{
MethodSignature methodSignature = new MethodSignatureImpl(method);
- for (SerializableContextualInstance<DecoratorImpl<Object>, Object> beanInstance : decoratorInstances)
+ for (SerializableContextualInstance<Decorator<Object>, Object> beanInstance : decoratorInstances)
{
- WeldMethod<?, ?> decoratorMethod = beanInstance.getContextual().get().getAnnotatedItem().getWBMethod(methodSignature);
+ WeldMethod<?, ?> decoratorMethod;
+ if (beanInstance.getContextual().get() instanceof DecoratorImpl)
+ {
+ decoratorMethod = ((DecoratorImpl)beanInstance.getContextual().get()).getAnnotatedItem().getWBMethod(methodSignature);
+ }
+ else if (beanInstance.getContextual().get() instanceof AnnotatedItemProvidingDecoratorWrapper)
+ {
+ decoratorMethod = ((AnnotatedItemProvidingDecoratorWrapper)beanInstance.getContextual().get()).getAnnotatedItem().getWBMethod(methodSignature);
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected unwrapped custom decorator instance: " + beanInstance.getContextual().get());
+ }
if (decoratorMethod != null)
{
return decoratorMethod.invokeOnInstance(beanInstance.getInstance(), args);
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployment.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployment.java 2009-11-07 06:54:43 UTC (rev 4724)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployment.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -22,7 +22,12 @@
import static org.jboss.weld.logging.messages.BootstrapMessage.ENABLED_INTERCEPTORS;
import static org.jboss.weld.logging.messages.BootstrapMessage.ENABLED_POLICIES;
+import java.util.List;
+
+import javax.enterprise.inject.spi.Bean;
+
import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.bean.RIBean;
import org.jboss.weld.bean.builtin.InjectionPointBean;
import org.jboss.weld.bean.builtin.ManagerBean;
import org.jboss.weld.bean.builtin.facade.EventBean;
@@ -146,4 +151,21 @@
beanDeployer.createBeans().deploy();
}
+ public void afterBeanDiscovery(Environment environment)
+ {
+ doAfterBeanDiscovery(beanManager.getBeans());
+ doAfterBeanDiscovery(beanManager.getDecorators());
+ doAfterBeanDiscovery(beanManager.getInterceptors());
+ }
+
+ private void doAfterBeanDiscovery(List<? extends Bean> beanList)
+ {
+ for (Bean<?> bean : beanList)
+ {
+ if (bean instanceof RIBean)
+ {
+ ((RIBean) bean).initializeAfterBeanDiscovery();
+ }
+ }
+ }
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java 2009-11-07 06:54:43 UTC (rev 4724)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -367,6 +367,10 @@
entry.getValue().deployBeans(environment);
}
AfterBeanDiscoveryImpl.fire(deploymentManager, deployment, beanDeployments);
+ for (Entry<BeanDeploymentArchive, BeanDeployment> entry : beanDeployments.entrySet())
+ {
+ entry.getValue().afterBeanDiscovery(environment);
+ }
// Re-read the deployment structure, this will be the physical structure, extensions, classes, and any beans added using addBean outside the physical structure
beanDeployments = deploymentVisitor.visit();
Container.instance().putBeanDeployments(beanDeployments);
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AfterBeanDiscoveryImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AfterBeanDiscoveryImpl.java 2009-11-07 06:54:43 UTC (rev 4724)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AfterBeanDiscoveryImpl.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -23,10 +23,12 @@
import javax.enterprise.context.spi.Context;
import javax.enterprise.inject.spi.AfterBeanDiscovery;
import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.ObserverMethod;
import javax.enterprise.inject.spi.Interceptor;
-import javax.enterprise.inject.spi.ObserverMethod;
+import javax.enterprise.inject.spi.Decorator;
import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.bean.AnnotatedItemProvidingDecoratorWrapper;
import org.jboss.weld.bootstrap.BeanDeployment;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.bootstrap.spi.Deployment;
@@ -61,6 +63,10 @@
{
beanManager.addInterceptor((Interceptor<?>) bean);
}
+ else if (bean instanceof Decorator)
+ {
+ beanManager.addDecorator(AnnotatedItemProvidingDecoratorWrapper.of((Decorator<?>)bean, beanManager));
+ }
else
{
beanManager.addBean(bean);
Modified: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java 2009-11-07 06:54:43 UTC (rev 4724)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -38,6 +38,6 @@
@MessageId("000017") USING_DEFAULT_SCOPE,
@MessageId("000018") CIRCULAR_CALL,
@MessageId("000019") ERROR_DESTROYING,
- @MessageId("000020") USER_DEFINED_DECORATOR_DISALLOWED
+ @MessageId("000020") DELEGATE_INJECTION_POINT_NOT_FOUND
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java 2009-11-07 06:54:43 UTC (rev 4724)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -20,7 +20,10 @@
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
+import java.util.Collections;
+import javax.enterprise.inject.spi.Decorator;
+
import org.jboss.weld.BeanManagerImpl;
import org.jboss.weld.bean.DecoratorImpl;
import org.jboss.weld.util.Beans;
@@ -30,31 +33,31 @@
* @author pmuir
*
*/
-public class TypeSafeDecoratorResolver extends TypeSafeBeanResolver<DecoratorImpl<?>>
+public class TypeSafeDecoratorResolver extends TypeSafeBeanResolver<Decorator<?>>
{
- public TypeSafeDecoratorResolver(BeanManagerImpl manager, Iterable<DecoratorImpl<?>> decorators)
+ public TypeSafeDecoratorResolver(BeanManagerImpl manager, Iterable<Decorator<?>> decorators)
{
super(manager, decorators);
}
@Override
- protected boolean matches(Resolvable resolvable, DecoratorImpl<?> bean)
+ protected boolean matches(Resolvable resolvable, Decorator<?> bean)
{
- return Reflections.matches(bean.getDelegateTypes(), resolvable.getTypeClosure()) && Beans.containsAllBindings(bean.getDelegateQualifiers(), resolvable.getQualifiers(), getManager()) && getManager().getEnabledDecoratorClasses().contains(bean.getType());
+ return Reflections.matches(Collections.singleton(bean.getDelegateType()), resolvable.getTypeClosure()) && Beans.containsAllBindings(bean.getDelegateQualifiers(), resolvable.getQualifiers(), getManager()) && getManager().getEnabledDecoratorClasses().contains(bean.getBeanClass());
}
@Override
- protected Set<DecoratorImpl<?>> sortResult(Set<DecoratorImpl<?>> matchedDecorators)
+ protected Set<Decorator<?>> sortResult(Set<Decorator<?>> matchedDecorators)
{
- Set<DecoratorImpl<?>> sortedBeans = new TreeSet<DecoratorImpl<?>>(new Comparator<DecoratorImpl<?>>()
+ Set<Decorator<?>> sortedBeans = new TreeSet<Decorator<?>>(new Comparator<Decorator<?>>()
{
- public int compare(DecoratorImpl<?> o1, DecoratorImpl<?> o2)
+ public int compare(Decorator<?> o1, Decorator<?> o2)
{
List<Class<?>> enabledDecorators = getManager().getEnabledDecoratorClasses();
- int p1 = enabledDecorators.indexOf(((DecoratorImpl<?>) o1).getType());
- int p2 = enabledDecorators.indexOf(((DecoratorImpl<?>) o2).getType());
+ int p1 = enabledDecorators.indexOf(((Decorator<?>) o1).getBeanClass());
+ int p2 = enabledDecorators.indexOf(((Decorator<?>) o2).getBeanClass());
return p1 - p2;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2009-11-07 06:54:43 UTC (rev 4724)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -47,6 +47,7 @@
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
import javax.inject.Inject;
import org.jboss.interceptor.model.InterceptionType;
@@ -56,6 +57,7 @@
import org.jboss.weld.bean.AbstractProducerBean;
import org.jboss.weld.bean.RIBean;
import org.jboss.weld.bean.SessionBean;
+import org.jboss.weld.bean.DecoratorImpl;
import org.jboss.weld.ejb.EJBApiAbstraction;
import org.jboss.weld.injection.ConstructorInjectionPoint;
import org.jboss.weld.injection.FieldInjectionPoint;
@@ -87,6 +89,7 @@
*
* @author Pete Muir
* @author David Allen
+ * @author Marius Bogoevici
*
*/
public class Beans
@@ -749,4 +752,20 @@
return annotatedItem.isAnnotationPresent(Decorator.class);
}
+ public static InjectionPoint getDelegateInjectionPoint(javax.enterprise.inject.spi.Decorator<?> decorator)
+ {
+ if (decorator instanceof DecoratorImpl<?>)
+ {
+ return ((DecoratorImpl<?>)decorator).getDelegateInjectionPoint();
+ }
+ else
+ {
+ for (InjectionPoint injectionPoint: decorator.getInjectionPoints())
+ {
+ if (injectionPoint.isDelegate())
+ return injectionPoint;
+ }
+ }
+ return null;
+ }
}
Modified: core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties 2009-11-07 06:54:43 UTC (rev 4724)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties 2009-11-07 06:58:28 UTC (rev 4725)
@@ -18,4 +18,4 @@
USING_DEFAULT_SCOPE=Using default @Dependent scope for {0}
CIRCULAR_CALL=Executing producer field or method {0} on incomplete declaring bean {1} due to circular injection
ERROR_DESTROYING=Error destroying an instance {0} of {1}
-USER_DEFINED_DECORATOR_DISALLOWED=Weld does not currently support user defined decorators. Decorator: {0}
+DELEGATE_INJECTION_POINT_NOT_FOUND=Delegate injection point not found on decorator {0}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/AfterBeanDiscoveryObserver.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/AfterBeanDiscoveryObserver.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/AfterBeanDiscoveryObserver.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright <Year>, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed 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.jboss.weld.tests.decorators.custom;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Extension;
+
+
+public class AfterBeanDiscoveryObserver implements Extension
+{
+ public void addDecorators(@Observes AfterBeanDiscovery event, BeanManager beanManager)
+ {
+ event.addBean(new CustomDecorator(beanManager));
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/CustomDecorator.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/CustomDecorator.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/CustomDecorator.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -0,0 +1,176 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright <Year>, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed 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.jboss.weld.tests.decorators.custom;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.lang.reflect.Member;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedField;
+
+import org.jboss.weld.introspector.WeldField;
+import org.jboss.weld.introspector.WeldClass;
+import org.jboss.weld.introspector.jlr.WeldClassImpl;
+import org.jboss.weld.resources.ClassTransformer;
+import org.jboss.weld.metadata.TypeStore;
+import org.jboss.weld.literal.DefaultLiteral;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class CustomDecorator implements Decorator<Object>
+{
+ private final Set<InjectionPoint> injectionPoints;
+ private BeanManager beanManager;
+
+ public CustomDecorator(BeanManager beanManager)
+ {
+ this.beanManager = beanManager;
+ injectionPoints = Collections.singleton((InjectionPoint)new CustomInjectionPoint());
+ }
+
+ public Type getDelegateType()
+ {
+ return Window.class;
+ }
+
+ public Set<Annotation> getDelegateQualifiers()
+ {
+ return Collections.emptySet();
+ }
+
+ public Set<Type> getDecoratedTypes()
+ {
+ return Collections.singleton((Type) Window.class);
+ }
+
+ public Set<Type> getTypes()
+ {
+ return Collections.<Type>singleton(Window.class);
+ }
+
+ public Set<Annotation> getQualifiers()
+ {
+ return Collections.emptySet();
+ }
+
+ public Class<? extends Annotation> getScope()
+ {
+ return Dependent.class;
+ }
+
+ public String getName()
+ {
+ return null;
+ }
+
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+ return Collections.emptySet();
+
+ }
+
+ public Class<?> getBeanClass()
+ {
+ return CustomFrame.class;
+ }
+
+ public boolean isAlternative()
+ {
+ return false;
+ }
+
+ public boolean isNullable()
+ {
+ return false;
+ }
+
+ public Set<InjectionPoint> getInjectionPoints()
+ {
+ return injectionPoints;
+ }
+
+ public Object create(CreationalContext<Object> creationalContext)
+ {
+ CustomFrame customFrame = new CustomFrame();
+ customFrame.window = (Window) beanManager.getInjectableReference(injectionPoints.iterator().next(), creationalContext);
+ return customFrame;
+ }
+
+ public void destroy(Object instance, CreationalContext<Object> creationalContext)
+ {
+ creationalContext.release();
+ }
+
+ class CustomInjectionPoint implements InjectionPoint
+ {
+ private final WeldClass<?> targetClass;
+ private final WeldField<CustomFrame,?> windowField;
+
+ public CustomInjectionPoint()
+ {
+ ClassTransformer transformer = new ClassTransformer(new TypeStore());
+ targetClass = WeldClassImpl.of(CustomFrame.class, transformer);
+ windowField = targetClass.getDeclaredWeldField("window", WeldClassImpl.of(CustomFrame.class, transformer));
+ }
+
+ public Type getType()
+ {
+ return Window.class;
+ }
+
+ public Set<Annotation> getQualifiers()
+ {
+ return Collections.<Annotation>singleton(new DefaultLiteral());
+ }
+
+ public Bean<?> getBean()
+ {
+ return CustomDecorator.this;
+ }
+
+ public Member getMember()
+ {
+ return ((AnnotatedField<?>)windowField).getJavaMember();
+ }
+
+ public Annotated getAnnotated()
+ {
+ return windowField;
+ }
+
+ public boolean isDelegate()
+ {
+ return true;
+ }
+
+ public boolean isTransient()
+ {
+ return false;
+ }
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/CustomDecoratorTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/CustomDecoratorTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/CustomDecoratorTest.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright <Year>, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed 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.jboss.weld.tests.decorators.custom;
+
+import java.util.Arrays;
+
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.weld.mock.TestContainer;
+import org.jboss.weld.mock.MockServletLifecycle;
+import org.jboss.weld.mock.MockBeanDeploymentArchive;
+import org.jboss.weld.mock.MockDeployment;
+import org.jboss.weld.util.serviceProvider.ServiceLoaderFactory;
+import org.jboss.weld.util.serviceProvider.PackageServiceLoaderFactory;
+import org.jboss.weld.BeanManagerImpl;
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class CustomDecoratorTest
+{
+
+ @Test
+ public void testCustomDecoratorAppliedByItself()
+ {
+ MockBeanDeploymentArchive beanDeploymentArchive = new MockBeanDeploymentArchive("1", Window.class, CustomFrame.class, InnerFrame.class, OuterFrame.class );
+ beanDeploymentArchive.setBeansXmlFiles(Arrays.asList(CustomDecoratorTest.class.getResource("beans-custom-only.xml")));
+ TestContainer testContainer = new TestContainer(new MockServletLifecycle(new MockDeployment(beanDeploymentArchive), beanDeploymentArchive));
+ testContainer.getLifecycle().initialize();
+ testContainer.getDeployment().getServices().add(ServiceLoaderFactory.class, new PackageServiceLoaderFactory(CustomDecoratorTest.class.getPackage(), Extension.class));
+ testContainer.getLifecycle().beginApplication();
+
+ BeanManagerImpl beanManager = testContainer.getBeanManager();
+ Bean<Object> windowBean = (Bean<Object>) beanManager.getBeans(Window.class).iterator().next();
+ CreationalContext<Object> creationalContext = beanManager.createCreationalContext(windowBean);
+ Window window = (Window) windowBean.create(creationalContext);
+ window.draw();
+
+ assert window.isDrawn();
+ assert CustomFrame.drawn;
+ testContainer.stopContainer();
+ }
+
+ @Test
+ public void testCustomDecoratorAppliedWithWeldDecorators()
+ {
+ MockBeanDeploymentArchive beanDeploymentArchive = new MockBeanDeploymentArchive("1", Window.class, CustomFrame.class, InnerFrame.class, OuterFrame.class );
+ beanDeploymentArchive.setBeansXmlFiles(Arrays.asList(CustomDecoratorTest.class.getResource("beans.xml")));
+ TestContainer testContainer = new TestContainer(new MockServletLifecycle(new MockDeployment(beanDeploymentArchive), beanDeploymentArchive));
+ testContainer.getLifecycle().initialize();
+ testContainer.getDeployment().getServices().add(ServiceLoaderFactory.class, new PackageServiceLoaderFactory(CustomDecoratorTest.class.getPackage(), Extension.class));
+ testContainer.getLifecycle().beginApplication();
+
+ BeanManagerImpl beanManager = testContainer.getBeanManager();
+ Bean<Object> windowBean = (Bean<Object>) beanManager.getBeans(Window.class).iterator().next();
+ CreationalContext<Object> creationalContext = beanManager.createCreationalContext(windowBean);
+ Window window = (Window) windowBean.create(creationalContext);
+ window.draw();
+
+ assert window.isDrawn();
+ assert OuterFrame.drawn;
+ assert InnerFrame.drawn;
+ assert CustomFrame.drawn;
+
+ testContainer.stopContainer();
+ }
+
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/CustomFrame.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/CustomFrame.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/CustomFrame.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -0,0 +1,17 @@
+package org.jboss.weld.tests.decorators.custom;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class CustomFrame
+{
+ public static boolean drawn;
+
+ Window window;
+
+ public void draw()
+ {
+ window.draw();
+ drawn = true;
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/InnerFrame.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/InnerFrame.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/InnerFrame.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright <Year>, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed 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.jboss.weld.tests.decorators.custom;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+/**
+ * @author Marius Bogoevici
+ */
+@Decorator
+public class InnerFrame
+{
+ static boolean drawn = false;
+
+ @Inject @Delegate Window window;
+
+ void draw()
+ {
+ window.draw();
+ drawn = true;
+ }
+
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/OuterFrame.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/OuterFrame.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/OuterFrame.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright <Year>, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed 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.jboss.weld.tests.decorators.custom;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+/**
+ * @author Marius Bogoevici
+ */
+@Decorator
+public class OuterFrame
+{
+ static boolean drawn = false;
+
+ @Inject @Delegate Window window;
+
+ void draw()
+ {
+ window.draw();
+ drawn = true;
+ }
+
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/Window.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/Window.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/custom/Window.java 2009-11-07 06:58:28 UTC (rev 4725)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright <Year>, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed 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.jboss.weld.tests.decorators.custom;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class Window
+{
+ public boolean drawn = false;
+
+ void draw()
+ {
+ drawn = true;
+ }
+
+ public boolean isDrawn()
+ {
+ return drawn;
+ }
+}
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/custom/beans-custom-only.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/custom/beans-custom-only.xml (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/custom/beans-custom-only.xml 2009-11-07 06:58:28 UTC (rev 4725)
@@ -0,0 +1,22 @@
+<!--
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright <Year>, Red Hat, Inc. and/or its affiliates, and individual
+ ~ contributors by the @authors tag. See the copyright.txt in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ Licensed 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.
+ -->
+
+<beans>
+ <decorators>
+ <decorator>org.jboss.weld.tests.decorators.custom.CustomFrame</decorator>
+ </decorators>
+</beans>
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/custom/beans.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/custom/beans.xml (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/custom/beans.xml 2009-11-07 06:58:28 UTC (rev 4725)
@@ -0,0 +1,24 @@
+<!--
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright <Year>, Red Hat, Inc. and/or its affiliates, and individual
+ ~ contributors by the @authors tag. See the copyright.txt in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ Licensed 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.
+ -->
+
+<beans>
+ <decorators>
+ <decorator>org.jboss.weld.tests.decorators.custom.OuterFrame</decorator>
+ <decorator>org.jboss.weld.tests.decorators.custom.CustomFrame</decorator>
+ <decorator>org.jboss.weld.tests.decorators.custom.InnerFrame</decorator>
+ </decorators>
+</beans>
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/custom/javax.enterprise.inject.spi.Extension
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/custom/javax.enterprise.inject.spi.Extension (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/custom/javax.enterprise.inject.spi.Extension 2009-11-07 06:58:28 UTC (rev 4725)
@@ -0,0 +1 @@
+org.jboss.weld.tests.decorators.custom.AfterBeanDiscoveryObserver
16 years, 5 months
Weld SVN: r4724 - examples/trunk/jsf/permalink.
by weld-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-11-07 01:54:43 -0500 (Sat, 07 Nov 2009)
New Revision: 4724
Modified:
examples/trunk/jsf/permalink/pom.xml
Log:
add profiles to maven cli commands
Modified: examples/trunk/jsf/permalink/pom.xml
===================================================================
--- examples/trunk/jsf/permalink/pom.xml 2009-11-07 06:50:51 UTC (rev 4723)
+++ examples/trunk/jsf/permalink/pom.xml 2009-11-07 06:54:43 UTC (rev 4724)
@@ -163,12 +163,12 @@
<prompt>${project.artifactId}</prompt>
<!-- userAliases are for cli:execute-phase -->
<userAliases>
- <runjetty>compile org.mortbay.jetty:maven-jetty-plugin:run</runjetty>
- <stopjetty>org.mortbay.jetty:maven-jetty-plugin:stop</stopjetty>
- <runtomcat>compile org.apache.maven.plugins:maven-war-plugin:inplace org.codehaus.mojo:tomcat-maven-plugin:run</runtomcat>
+ <runjetty>compile org.mortbay.jetty:maven-jetty-plugin:run -Pjetty</runjetty>
+ <stopjetty>org.mortbay.jetty:maven-jetty-plugin:stop -Pjetty</stopjetty>
+ <runtomcat>compile org.apache.maven.plugins:maven-war-plugin:inplace org.codehaus.mojo:tomcat-maven-plugin:run -Ptomcat</runtomcat>
<explode>compile -o</explode>
<!-- tomcat requires use of war:inplace -->
- <tcexplode>compile org.apache.maven.plugins:maven-war-plugin:inplace -o</tcexplode>
+ <tcexplode>compile org.apache.maven.plugins:maven-war-plugin:inplace -Ptomcat -o</tcexplode>
<restart>org.apache.maven.plugins:maven-antrun-plugin:run -Prestart-embedded</restart>
<profiles>org.apache.maven.plugins:maven-help-plugin:active-profiles -o</profiles>
<pom>org.apache.maven.plugins:maven-help-plugin:effective-pom -o</pom>
16 years, 5 months
Weld SVN: r4723 - in examples/trunk/jsf/permalink: src and 11 other directories.
by weld-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-11-07 01:50:51 -0500 (Sat, 07 Nov 2009)
New Revision: 4723
Added:
examples/trunk/jsf/permalink/src/log/
examples/trunk/jsf/permalink/src/log/resources/
examples/trunk/jsf/permalink/src/log/resources/log4j.xml
examples/trunk/jsf/permalink/src/main/webapp-jetty/
examples/trunk/jsf/permalink/src/main/webapp-jetty/WEB-INF/
examples/trunk/jsf/permalink/src/main/webapp-jetty/WEB-INF/jetty-env.xml
examples/trunk/jsf/permalink/src/main/webapp-jetty/WEB-INF/override-web.xml
examples/trunk/jsf/permalink/src/main/webapp-tomcat/
examples/trunk/jsf/permalink/src/main/webapp-tomcat/META-INF/
examples/trunk/jsf/permalink/src/main/webapp-tomcat/META-INF/context.xml
examples/trunk/jsf/permalink/src/main/webapp-tomcat/WEB-INF/
examples/trunk/jsf/permalink/src/main/webapp-tomcat/WEB-INF/web.xml
Removed:
examples/trunk/jsf/permalink/src/main/resources/log4j.xml
examples/trunk/jsf/permalink/src/main/webapp/META-INF/
examples/trunk/jsf/permalink/src/main/webapp/WEB-INF/jetty-env.xml
Modified:
examples/trunk/jsf/permalink/pom.xml
examples/trunk/jsf/permalink/readme.txt
examples/trunk/jsf/permalink/src/main/webapp/WEB-INF/web.xml
Log:
reorg to eliminate need for war:inplace
embedded Tomcat currently not working
Modified: examples/trunk/jsf/permalink/pom.xml
===================================================================
--- examples/trunk/jsf/permalink/pom.xml 2009-11-07 06:11:34 UTC (rev 4722)
+++ examples/trunk/jsf/permalink/pom.xml 2009-11-07 06:50:51 UTC (rev 4723)
@@ -50,6 +50,7 @@
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -61,21 +62,10 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-impl</artifactId>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jstl</artifactId>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
<!-- needed for reference by maven-eclipse-plugin -->
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
@@ -85,69 +75,20 @@
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
+ <scope>provided</scope>
</dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator</artifactId>
- <version>4.0.0.GA</version>
- <scope>runtime</scope>
- <exclusions>
- <exclusion>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.5.6</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.weld.servlet</groupId>
- <artifactId>weld-servlet</artifactId>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>org.glassfish.web</groupId>
- <artifactId>el-impl</artifactId>
- <scope>runtime</scope>
- <exclusions>
- <exclusion>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
</dependencies>
<build>
<defaultGoal>package</defaultGoal>
- <!--
<finalName>${project.artifactId}</finalName>
- -->
- <finalName>weld-permalink</finalName>
<plugins>
<plugin>
@@ -216,58 +157,19 @@
</plugin>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>tomcat-maven-plugin</artifactId>
- <configuration>
- <path>/${project.build.finalName}</path>
- <!-- uncomment to use server configuration override; see readme.txt for details -->
- <!--<server>tomcatserver</server>-->
- <url>http://localhost:${tomcat.http.port}/manager</url>
- <port>${embedded-tomcat.http.port}</port> <!-- port for embedded Tomcat only (putting this configuration in the execution for the run goal doesn't work) -->
- <!-- if you don't want to use war:inplace, uncomment this setting -->
- <!--
- <warSourceDirectory>${project.build.directory}/${project.build.finalName}</warSourceDirectory>
- -->
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- <configuration>
- <connectors>
- <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
- <port>${jetty.http.port}</port>
- <maxIdleTime>3600000</maxIdleTime>
- </connector>
- </connectors>
- <daemon>${jetty.daemon}</daemon>
- <stopPort>${jetty.stop.port}</stopPort>
- <stopKey>HASTA_LA_VISTA</stopKey>
- <scanIntervalSeconds>10</scanIntervalSeconds>
- <webAppConfig>
- <contextPath>/${project.build.finalName}</contextPath>
- </webAppConfig>
- <!-- if you don't want to use war:inplace, uncomment this setting -->
- <!--
- <webAppSourceDirectory>${project.build.directory}/${project.build.finalName}</webAppSourceDirectory>
- -->
- </configuration>
- </plugin>
-
- <plugin>
<groupId>org.twdata.maven</groupId>
<artifactId>maven-cli-plugin</artifactId>
<configuration>
<prompt>${project.artifactId}</prompt>
<!-- userAliases are for cli:execute-phase -->
<userAliases>
- <runjetty>compile org.apache.maven.plugins:maven-war-plugin:inplace org.mortbay.jetty:maven-jetty-plugin:run</runjetty>
+ <runjetty>compile org.mortbay.jetty:maven-jetty-plugin:run</runjetty>
<stopjetty>org.mortbay.jetty:maven-jetty-plugin:stop</stopjetty>
<runtomcat>compile org.apache.maven.plugins:maven-war-plugin:inplace org.codehaus.mojo:tomcat-maven-plugin:run</runtomcat>
- <explode>compile org.apache.maven.plugins:maven-war-plugin:inplace -o</explode>
+ <explode>compile -o</explode>
+ <!-- tomcat requires use of war:inplace -->
+ <tcexplode>compile org.apache.maven.plugins:maven-war-plugin:inplace -o</tcexplode>
<restart>org.apache.maven.plugins:maven-antrun-plugin:run -Prestart-embedded</restart>
- <!--<restart>validate -Prestart-embedded -o</restart>-->
<profiles>org.apache.maven.plugins:maven-help-plugin:active-profiles -o</profiles>
<pom>org.apache.maven.plugins:maven-help-plugin:effective-pom -o</pom>
</userAliases>
@@ -282,6 +184,248 @@
<profiles>
<profile>
+ <id>tomcat</id>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>4.0.0.GA</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.5.6</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.weld.servlet</groupId>
+ <artifactId>weld-servlet</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.web</groupId>
+ <artifactId>el-impl</artifactId>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/log/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <webResources>
+ <resource>
+ <directory>src/main/webapp-tomcat</directory>
+ <filtering>false</filtering>
+ </resource>
+ </webResources>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>tomcat-maven-plugin</artifactId>
+ <configuration>
+ <path>/${project.build.finalName}</path>
+ <!-- uncomment to use server configuration override; see readme.txt for details -->
+ <!--<server>tomcatserver</server>-->
+ <url>http://localhost:${tomcat.http.port}/manager</url>
+ <port>${embedded-tomcat.http.port}</port> <!-- port for embedded Tomcat only (putting this configuration in the execution for the run goal doesn't work) -->
+ <!-- this isn't useful to us because we also need an web.xml override -->
+ <!--
+ <contextFile>src/main/webapp-tomcat/META-INF/context.xml</contextFile>
+ -->
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ </profile>
+
+ <profile>
+ <id>jetty</id>
+
+ <dependencies>
+ <!-- (same dependencies as tomcat except for javax.servlet:jstl) -->
+
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>4.0.0.GA</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.5.6</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.weld.servlet</groupId>
+ <artifactId>weld-servlet</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.web</groupId>
+ <artifactId>el-impl</artifactId>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/log/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <configuration>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>${jetty.http.port}</port>
+ <maxIdleTime>3600000</maxIdleTime>
+ </connector>
+ </connectors>
+ <daemon>${jetty.daemon}</daemon>
+ <stopPort>${jetty.stop.port}</stopPort>
+ <stopKey>HASTA_LA_VISTA</stopKey>
+ <scanIntervalSeconds>10</scanIntervalSeconds>
+ <contextPath>/${project.build.finalName}</contextPath>
+ <overrideWebXml>src/main/webapp-jetty/WEB-INF/override-web.xml</overrideWebXml>
+ <jettyEnvXml>src/main/webapp-jetty/WEB-INF/jetty-env.xml</jettyEnvXml>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ </profile>
+
+ <profile>
<id>restart-embedded</id>
<build>
<plugins>
Modified: examples/trunk/jsf/permalink/readme.txt
===================================================================
--- examples/trunk/jsf/permalink/readme.txt 2009-11-07 06:11:34 UTC (rev 4722)
+++ examples/trunk/jsf/permalink/readme.txt 2009-11-07 06:50:51 UTC (rev 4723)
@@ -19,26 +19,30 @@
Run this command to execute the application in an embedded Jetty 6 container:
- mvn war:inplace jetty:run
+ mvn jetty:run -Pjetty
You can also execute the application in an embedded Tomcat 6 container:
- mvn war:inplace tomcat:run
+ mvn war:inplace tomcat:run -Ptomcat
In both cases, any changes to assets in src/main/webapp take effect immediately.
If a change to a webapp configuration file is made, the application may
automatically redeploy. The redeploy behavior can be fine-tuned in the plugin
configuration (at least for Jetty). If you make a change to a classpath
-resource, you need to execute a build:
+resource, you need to execute a build. For Jetty:
- mvn compile war:inplace
+ mvn compile
-Note that war:inplace copies the compiled classes and JARs inside WebContent,
-under WEB-INF/classes and WEB-INF/lib, respectively, mixing source and compiled
-files. However, the build does work around these temporary files by excluding
-them from the packaged WAR and cleaning them during the Maven clean phase.
-These folders are also ignored by SVN.
+and for Tomcat:
+ mvn compile war:inplace -Ptomcat
+
+Note that war:inplace copies the compiled classes and JARs inside
+src/main/webapp, under WEB-INF/classes and WEB-INF/lib, respectively, mixing
+source and compiled files. However, the build does work around these temporary
+files by excluding them from the packaged WAR and cleaning them during the Maven
+clean phase. These folders are also ignored by SVN.
+
== Deploying to standalone Tomcat
If you want to run the application on a standalone Tomcat 6, first download and
@@ -56,7 +60,7 @@
You can deploy the packaged archive to Tomcat via HTTP PUT using this command:
- mvn package tomcat:deploy
+ mvn package tomcat:deploy -Ptomcat
Then you use this command to undeploy the application:
@@ -65,7 +69,7 @@
Instead of packaging the WAR, you can deploy it as an exploded archive
immediately after the war goal is finished assembling the exploded structure:
- mvn compile war:exploded tomcat:exploded
+ mvn compile war:exploded tomcat:exploded -Ptomcat
Once the application is deployed, you can redeploy it using the following command:
@@ -73,9 +77,9 @@
But likely you want to run one or more build goals first before you redeploy:
- mvn compile tomcat:redeploy
- mvn war:exploded tomcat:redeploy
- mvn compile war:exploded tomcat:redeploy
+ mvn compile tomcat:redeploy -Ptomcat
+ mvn war:exploded tomcat:redeploy -Ptomcat
+ mvn compile war:exploded tomcat:redeploy -Ptomcat
= Importing the project into Eclipse
Copied: examples/trunk/jsf/permalink/src/log/resources/log4j.xml (from rev 4634, examples/trunk/jsf/permalink/src/main/resources/log4j.xml)
===================================================================
--- examples/trunk/jsf/permalink/src/log/resources/log4j.xml (rev 0)
+++ examples/trunk/jsf/permalink/src/log/resources/log4j.xml 2009-11-07 06:50:51 UTC (rev 4723)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{2}] %m%n"/>
+ </layout>
+ </appender>
+
+ <root>
+ <priority value="INFO"/>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
Deleted: examples/trunk/jsf/permalink/src/main/resources/log4j.xml
===================================================================
--- examples/trunk/jsf/permalink/src/main/resources/log4j.xml 2009-11-07 06:11:34 UTC (rev 4722)
+++ examples/trunk/jsf/permalink/src/main/resources/log4j.xml 2009-11-07 06:50:51 UTC (rev 4723)
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
-
- <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{2}] %m%n"/>
- </layout>
- </appender>
-
- <root>
- <priority value="INFO"/>
- <appender-ref ref="CONSOLE"/>
- </root>
-
-</log4j:configuration>
Deleted: examples/trunk/jsf/permalink/src/main/webapp/WEB-INF/jetty-env.xml
===================================================================
--- examples/trunk/jsf/permalink/src/main/webapp/WEB-INF/jetty-env.xml 2009-11-07 06:11:34 UTC (rev 4722)
+++ examples/trunk/jsf/permalink/src/main/webapp/WEB-INF/jetty-env.xml 2009-11-07 06:50:51 UTC (rev 4723)
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
- "http://jetty.mortbay.org/configure.dtd">
-<!--
- JBoss, Home of Professional Open Source
- Copyright 2009, Red Hat Middleware LLC, and individual contributors
- by the @authors tag. See the copyright.txt in the distribution for a
- full listing of individual contributors.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
--->
-<Configure id="webAppCtx" class="org.mortbay.jetty.webapp.WebAppContext">
-</Configure>
Modified: examples/trunk/jsf/permalink/src/main/webapp/WEB-INF/web.xml
===================================================================
--- examples/trunk/jsf/permalink/src/main/webapp/WEB-INF/web.xml 2009-11-07 06:11:34 UTC (rev 4722)
+++ examples/trunk/jsf/permalink/src/main/webapp/WEB-INF/web.xml 2009-11-07 06:50:51 UTC (rev 4723)
@@ -33,11 +33,7 @@
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
-
- <listener>
- <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
- </listener>
-
+
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
Copied: examples/trunk/jsf/permalink/src/main/webapp-jetty/WEB-INF/jetty-env.xml (from rev 4634, examples/trunk/jsf/permalink/src/main/webapp/WEB-INF/jetty-env.xml)
===================================================================
--- examples/trunk/jsf/permalink/src/main/webapp-jetty/WEB-INF/jetty-env.xml (rev 0)
+++ examples/trunk/jsf/permalink/src/main/webapp-jetty/WEB-INF/jetty-env.xml 2009-11-07 06:50:51 UTC (rev 4723)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
+ "http://jetty.mortbay.org/configure.dtd">
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ by the @authors tag. See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+<Configure id="webAppCtx" class="org.mortbay.jetty.webapp.WebAppContext">
+ <New id="beanManager" class="org.mortbay.jetty.plus.naming.Resource">
+ <Arg><Ref id="webAppCtx"/></Arg>
+ <Arg>BeanManager</Arg>
+ <Arg>
+ <New class="javax.naming.Reference">
+ <Arg>javax.enterprise.inject.spi.BeanManager</Arg>
+ <Arg>org.jboss.weld.resources.ManagerObjectFactory</Arg>
+ <Arg/>
+ </New>
+ </Arg>
+ </New>
+</Configure>
Added: examples/trunk/jsf/permalink/src/main/webapp-jetty/WEB-INF/override-web.xml
===================================================================
--- examples/trunk/jsf/permalink/src/main/webapp-jetty/WEB-INF/override-web.xml (rev 0)
+++ examples/trunk/jsf/permalink/src/main/webapp-jetty/WEB-INF/override-web.xml 2009-11-07 06:50:51 UTC (rev 4723)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ by the @authors tag. See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+<web-app version="2.5"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <listener>
+ <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
+ </listener>
+
+</web-app>
Copied: examples/trunk/jsf/permalink/src/main/webapp-tomcat/META-INF/context.xml (from rev 4634, examples/trunk/jsf/permalink/src/main/webapp/META-INF/context.xml)
===================================================================
--- examples/trunk/jsf/permalink/src/main/webapp-tomcat/META-INF/context.xml (rev 0)
+++ examples/trunk/jsf/permalink/src/main/webapp-tomcat/META-INF/context.xml 2009-11-07 06:50:51 UTC (rev 4723)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Context>
+ <Manager pathname=""/> <!-- disables storage of sessions across restarts -->
+</Context>
Added: examples/trunk/jsf/permalink/src/main/webapp-tomcat/WEB-INF/web.xml
===================================================================
--- examples/trunk/jsf/permalink/src/main/webapp-tomcat/WEB-INF/web.xml (rev 0)
+++ examples/trunk/jsf/permalink/src/main/webapp-tomcat/WEB-INF/web.xml 2009-11-07 06:50:51 UTC (rev 4723)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ by the @authors tag. See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+<web-app version="2.5"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <display-name>Weld Permalink Example (Servlet Environment)</display-name>
+
+ <context-param>
+ <param-name>facelets.DEVELOPMENT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <listener>
+ <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <session-config>
+ <session-timeout>10</session-timeout>
+ </session-config>
+
+</web-app>
16 years, 5 months
Weld SVN: r4722 - in examples/trunk/jsf/numberguess/src/main: webapp/WEB-INF and 2 other directories.
by weld-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-11-07 01:11:34 -0500 (Sat, 07 Nov 2009)
New Revision: 4722
Modified:
examples/trunk/jsf/numberguess/src/main/webapp-jboss5/WEB-INF/web.xml
examples/trunk/jsf/numberguess/src/main/webapp-tomcat/WEB-INF/web.xml
examples/trunk/jsf/numberguess/src/main/webapp/WEB-INF/faces-config.xml
examples/trunk/jsf/numberguess/src/main/webapp/home.xhtml
Log:
formatting
Modified: examples/trunk/jsf/numberguess/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- examples/trunk/jsf/numberguess/src/main/webapp/WEB-INF/faces-config.xml 2009-11-07 06:10:47 UTC (rev 4721)
+++ examples/trunk/jsf/numberguess/src/main/webapp/WEB-INF/faces-config.xml 2009-11-07 06:11:34 UTC (rev 4722)
@@ -1,7 +1,8 @@
-<?xml version='1.0' encoding='UTF-8'?>
+<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0"
- xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
-
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
</faces-config>
Modified: examples/trunk/jsf/numberguess/src/main/webapp/home.xhtml
===================================================================
--- examples/trunk/jsf/numberguess/src/main/webapp/home.xhtml 2009-11-07 06:10:47 UTC (rev 4721)
+++ examples/trunk/jsf/numberguess/src/main/webapp/home.xhtml 2009-11-07 06:11:34 UTC (rev 4722)
@@ -1,34 +1,34 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core">
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
- <ui:composition template="template.xhtml">
- <ui:define name="content">
- <h1>Guess a number...</h1>
- <h:form id="NumberGuessMain">
- <div style="color: red">
- <h:messages id="messages" globalOnly="false"/>
- <h:outputText id="Higher" value="Higher!" rendered="#{game.number gt game.guess and game.guess ne 0}"/>
- <h:outputText id="Lower" value="Lower!" rendered="#{game.number lt game.guess and game.guess ne 0}"/>
- </div>
-
- <div>
- I'm thinking of a number between #{game.smallest} and #{game.biggest}. You have #{game.remainingGuesses} guesses.
- </div>
-
- <div>
- Your guess:
- <h:inputText id="inputGuess" value="#{game.guess}" required="true" size="3" disabled="#{game.number eq game.guess}"
- validator="#{game.validateNumberRange}">
- </h:inputText>
- <h:commandButton id="GuessButton" value="Guess" action="#{game.check}" disabled="#{game.number eq game.guess}"/>
- </div>
- <div>
- <h:commandButton id="RestartButton" value="Reset" action="#{game.reset}" immediate="true" />
- </div>
- </h:form>
- </ui:define>
- </ui:composition>
+ <ui:composition template="/template.xhtml">
+ <ui:define name="content">
+ <h1>Guess a number...</h1>
+ <h:form id="numberGuess">
+ <div style="color: red">
+ <h:messages id="messages" globalOnly="false"/>
+ <h:outputText id="Higher" value="Higher!" rendered="#{game.number gt game.guess and game.guess ne 0}"/>
+ <h:outputText id="Lower" value="Lower!" rendered="#{game.number lt game.guess and game.guess ne 0}"/>
+ </div>
+
+ <div>
+ I'm thinking of a number between #{game.smallest} and #{game.biggest}. You have #{game.remainingGuesses} guesses remaining.
+ </div>
+
+ <div>
+ Your guess:
+ <h:inputText id="inputGuess" value="#{game.guess}"
+ required="true" size="3" disabled="#{game.number eq game.guess}" validator="#{game.validateNumberRange}"/>
+ <h:commandButton id="guessButton" value="Guess" action="#{game.check}" disabled="#{game.number eq game.guess}"/>
+ </div>
+ <div>
+ <h:commandButton id="restartButton" value="Reset" action="#{game.reset}" immediate="true"/>
+ </div>
+ </h:form>
+ </ui:define>
+ </ui:composition>
</html>
Modified: examples/trunk/jsf/numberguess/src/main/webapp-jboss5/WEB-INF/web.xml
===================================================================
--- examples/trunk/jsf/numberguess/src/main/webapp-jboss5/WEB-INF/web.xml 2009-11-07 06:10:47 UTC (rev 4721)
+++ examples/trunk/jsf/numberguess/src/main/webapp-jboss5/WEB-INF/web.xml 2009-11-07 06:11:34 UTC (rev 4722)
@@ -1,14 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
-
<web-app version="2.5"
- xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>Web Beans Numberguess example</display-name>
+
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xhtml</param-value>
+ </context-param>
- <!-- JSF -->
-
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
@@ -19,11 +23,6 @@
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
-
- <context-param>
- <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
- <param-value>.xhtml</param-value>
- </context-param>
<session-config>
<session-timeout>10</session-timeout>
Modified: examples/trunk/jsf/numberguess/src/main/webapp-tomcat/WEB-INF/web.xml
===================================================================
--- examples/trunk/jsf/numberguess/src/main/webapp-tomcat/WEB-INF/web.xml 2009-11-07 06:10:47 UTC (rev 4721)
+++ examples/trunk/jsf/numberguess/src/main/webapp-tomcat/WEB-INF/web.xml 2009-11-07 06:11:34 UTC (rev 4722)
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
-<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+<web-app version="2.5"
+ xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- version="2.5">
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>Weld Numberguess example</display-name>
16 years, 5 months
Weld SVN: r4721 - examples/trunk/jsf/numberguess/src/main/java/org/jboss/weld/examples/numberguess.
by weld-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-11-07 01:10:47 -0500 (Sat, 07 Nov 2009)
New Revision: 4721
Modified:
examples/trunk/jsf/numberguess/src/main/java/org/jboss/weld/examples/numberguess/Game.java
examples/trunk/jsf/numberguess/src/main/java/org/jboss/weld/examples/numberguess/Generator.java
Log:
formatting
Modified: examples/trunk/jsf/numberguess/src/main/java/org/jboss/weld/examples/numberguess/Game.java
===================================================================
--- examples/trunk/jsf/numberguess/src/main/java/org/jboss/weld/examples/numberguess/Game.java 2009-11-07 02:07:38 UTC (rev 4720)
+++ examples/trunk/jsf/numberguess/src/main/java/org/jboss/weld/examples/numberguess/Game.java 2009-11-07 06:10:47 UTC (rev 4721)
@@ -63,22 +63,21 @@
return remainingGuesses;
}
- public String check()
+ public void check()
{
- if (guess>number)
+ if (guess > number)
{
biggest = guess - 1;
}
- if (guess<number)
+ else if (guess < number)
{
smallest = guess + 1;
}
- if (guess == number)
+ else if (guess == number)
{
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Correct!"));
}
remainingGuesses--;
- return null;
}
@PostConstruct
@@ -97,14 +96,14 @@
{
FacesMessage message = new FacesMessage("No guesses left!");
context.addMessage(toValidate.getClientId(context), message);
- ((UIInput)toValidate).setValid(false);
+ ((UIInput) toValidate).setValid(false);
return;
}
int input = (Integer) value;
if (input < smallest || input > biggest)
{
- ((UIInput)toValidate).setValid(false);
+ ((UIInput) toValidate).setValid(false);
FacesMessage message = new FacesMessage("Invalid guess");
context.addMessage(toValidate.getClientId(context), message);
Modified: examples/trunk/jsf/numberguess/src/main/java/org/jboss/weld/examples/numberguess/Generator.java
===================================================================
--- examples/trunk/jsf/numberguess/src/main/java/org/jboss/weld/examples/numberguess/Generator.java 2009-11-07 02:07:38 UTC (rev 4720)
+++ examples/trunk/jsf/numberguess/src/main/java/org/jboss/weld/examples/numberguess/Generator.java 2009-11-07 06:10:47 UTC (rev 4721)
@@ -9,10 +9,9 @@
@ApplicationScoped
public class Generator implements Serializable
{
-
private static final long serialVersionUID = -7213673465118041882L;
- private java.util.Random random = new java.util.Random( System.currentTimeMillis() );
+ private java.util.Random random = new java.util.Random(System.currentTimeMillis());
private int maxNumber = 100;
@@ -29,5 +28,4 @@
{
return maxNumber;
}
-
}
16 years, 5 months
Weld SVN: r4720 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-11-06 21:07:38 -0500 (Fri, 06 Nov 2009)
New Revision: 4720
Modified:
doc/trunk/reference/en-US/gettingstarted.xml
Log:
typo
Modified: doc/trunk/reference/en-US/gettingstarted.xml
===================================================================
--- doc/trunk/reference/en-US/gettingstarted.xml 2009-11-07 02:05:43 UTC (rev 4719)
+++ doc/trunk/reference/en-US/gettingstarted.xml 2009-11-07 02:07:38 UTC (rev 4720)
@@ -505,7 +505,7 @@
<para>
Any changes to assets in src/main/webapp take effect immediately. If a change to a webapp configuration file is
- made, the application may automatically redeploy. The redeploy behavior can be fined tuned in the plugin
+ made, the application may automatically redeploy. The redeploy behavior can be fine-tuned in the plugin
configuration. If you make a change to a classpath resource, you need to execute a build and the inplace goal
of the Maven WAR plugin, again with the jetty profile enabled.
</para>
16 years, 5 months
Weld SVN: r4719 - examples/trunk/jsf/numberguess.
by weld-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-11-06 21:05:43 -0500 (Fri, 06 Nov 2009)
New Revision: 4719
Modified:
examples/trunk/jsf/numberguess/readme.txt
Log:
typo
Modified: examples/trunk/jsf/numberguess/readme.txt
===================================================================
--- examples/trunk/jsf/numberguess/readme.txt 2009-11-07 02:04:28 UTC (rev 4718)
+++ examples/trunk/jsf/numberguess/readme.txt 2009-11-07 02:05:43 UTC (rev 4719)
@@ -52,9 +52,9 @@
http://localhost:9090/weld-numberguess
-In both cases, any changes to assets in src/main/webapp take effect immediately. If
-a change to a webapp configuration file is made, the application may
-automatically redeploy. The redeploy behavior can be fined tuned in the plugin
+In both cases, any changes to assets in src/main/webapp take effect immediately.
+If a change to a webapp configuration file is made, the application may
+automatically redeploy. The redeploy behavior can be fine-tuned in the plugin
configuration (at least for Jetty). If you make a change to a classpath
resource, you need to execute a build:
@@ -130,3 +130,4 @@
Now, in Eclipse, you can either run the app locally, or deploy it to Google App Engine.
+vim:tw=80
16 years, 5 months
Weld SVN: r4718 - examples/trunk/jsf/permalink.
by weld-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-11-06 21:04:28 -0500 (Fri, 06 Nov 2009)
New Revision: 4718
Modified:
examples/trunk/jsf/permalink/readme.txt
Log:
typo
Modified: examples/trunk/jsf/permalink/readme.txt
===================================================================
--- examples/trunk/jsf/permalink/readme.txt 2009-11-06 14:07:08 UTC (rev 4717)
+++ examples/trunk/jsf/permalink/readme.txt 2009-11-07 02:04:28 UTC (rev 4718)
@@ -25,11 +25,11 @@
mvn war:inplace tomcat:run
-In both cases, any changes to assets in src/main/webapp take effect
-immediately. If a change to a webapp configuration file is made, the
-application may automatically redeploy. The redeploy behavior can be fined
-tuned in the plugin configuration (at least for Jetty). If you make a change
-to a classpath resource, you need to execute a build:
+In both cases, any changes to assets in src/main/webapp take effect immediately.
+If a change to a webapp configuration file is made, the application may
+automatically redeploy. The redeploy behavior can be fine-tuned in the plugin
+configuration (at least for Jetty). If you make a change to a classpath
+resource, you need to execute a build:
mvn compile war:inplace
@@ -91,8 +91,10 @@
into Eclipse. First, transform the pom.xml into an m2eclipse Eclipse project
using this command:
- mvn eclipse:m2eclipse
+ mvn eclipse:m2eclipse
Now go into Eclipse an import the project by selecting "Existing projects into
workspace" and selecting the project folder. Both approaches use the Eclipse
project configuration defined in the pom.xml file.
+
+vim:tw=80
16 years, 5 months